From: Sergei A. <pr...@qu...> - 2002-06-27 09:09:06
|
Hello! I'd like to make an .exe program with relocation table. So that it can be either executed as exe or loaded into another process as dll. But the way I used for creating relocations when compiled dlls doesn't seem to work now: string constants don't become relocatable. Is there a way to accomplish my task (though it's so strange)? I used to make something similar in VC for setting global hook that was placed in the same exe that set the hook. I'm quite new to MinGW, don't know what to try... ============ compile.bat gcc -c reloc.cpp gcc -mdll -o junk.tmp -Wl,--base-file,reloc.base reloc.o dlltool -e exports.o -d reloc.def -b reloc.base reloc.o gcc reloc.o exports.o -o reloc.exe ----------------- ============ reloc.cpp #include <string.h> #include <stdio.h> extern "C" int f() { char s[]={'A', 0}; return strcmp(s, "A"); } int main() { printf("%d\n", f()); return 0; } ------------------ ============ reloc.def LIBRARY EXPORTS f ------------------ ============ test.cpp #include <windows.h> #include <stdio.h> main() { HMODULE h=LoadLibrary("reloc.exe"); printf("h=%x\n", h); typedef int (*F)(); F f=(F)GetProcAddress(h, "f"); printf("f=%x\n", f); printf("%d\n", f()); FreeLibrary(h); } ------------------ -- With best regards, Sergei Antonov. E-mail: pr...@qu... |