I'm using Visual Studio 2017. I have a compiled dll which sets some variables and uses some functions at some addresses when loaded like this:
#define func_address 0xdeadbeef;
typedef int func(int a, int b);
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved ) {
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
func* f = (func*)func_address;
int c = f(3, 1);
break;
}
return TRUE;
}
I need to compile PE where specific function would compile at specific address so that when dll module loaded it would have done its job:
int func(int a, int b) { /* <= Compile this at address 0xdeadbeef */
return a + b;
}
int main()
{
//somestuff
return 0;
}
The most promising I could find was that construction, but seems this only for keil arm compiler http://www.keil.com/support/man/docs/ARMCC/armcc_chr1359124981140.htm:
int func(int a, int b) __attribute__((at(0xdeadbeef)));
So the question is how can I archive function compilation at specific address inside PE?
User contributions licensed under CC BY-SA 3.0