Code: Select all
//! loadedProgram is where the image was loaded to
IMAGE_DOS_HEADER* pImage = (IMAGE_DOS_HEADER*) loadedProgram;
//! go to NT HEADERS
IMAGE_NT_HEADERS* pHeaders = (IMAGE_NT_HEADERS*)(loadedProgram + pImage->e_lfanew);
//! get image base and entry point address from optional header
int base = pHeaders->OptionalHeader.ImageBase;
int entryPoint = pHeaders->OptionalHeader.AddressOfEntryPoint;
//! entry point function is at base+entryPoint
void (*entryFunction) () = (entryPoint + base);
//! call program entry point
entryFunction();
'initializing' : cannot convert from 'int' to 'void (__cdecl *)(void)'
Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
Code: Select all
void (*entryFunction) () = (entryPoint + base); // <- generates error C2440