質問

Ok this is odd. It's the first time I've seen such a line of code. Basically this calls the entry point into an application once you've specified an offset (address) from a program's PE header.

As you can tell - I've been playing lately with writing my own PE loader. I'm still a beginner and attempting to understand the structure - but what exactly is that function call mean?

((void(*)(void))EntryPoint)();

//where 0x4484502 is gotten from:

PIMAGE_NT_HEADERS nt_header;
DWORD EntryPoint = nt_header->OptionalHeader.ImageBase + nt_header->OptionalHeader.AddressOfEntryPoint;

((void(*)(void))0x4484502)();
役に立ちましたか?

解決

The line

((void(*)(void))0x4484502)();

Casts the integer 0x4484502 to a point to a function (starting at that address) that has void parameters and returns void. Once cast, the function pointer is called.

EDIT: Just re-read the question.... replace 0x4484502 with EntryPoint does exactly the same thing... the variable EntryPoint is cast as a pointer to a function that has void params and returns void. Pointer then used to call function.

他のヒント

notation

(some_type)something

it is C-style cast. It is equal to a sequence of C++ casts, but without dynamic_cast so it is dangerous - it allows you to cast a pointer to private base to a pointer to derived class not only in derived class functions.

here we have

(void(*)(void))0x4484502

it means that 0x4484502 is casted to a pointer to a function that takes void and returns void.

the notation func_ptr()

means call the function pointed to by func_ptr.


you can always check such strange declarations on cdecl

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top