Microsoft documentation gives WinMain() as the entry point for a
Windows program
No, Microsoft's documentation doesn't give WinMain() as the entry point for a Windows program.
From the WinMain() documentation to which you linked above (emphasis mine) - "WinMain entry point [is] the user-provided entry point for a graphical Windows-based application... Depending on the programming framework, the call to the WinMain function can be preceded and followed by additional activities specific to that framework."
In other words, if you're building a native application, your compiler will likely build your executable file such that its framework initialization code is executed before your WinMain() function.
Does anyone know of any documentation - official or otherwise -
regarding the game rules for PE32(+) entry points?
Yes, from the Microsoft PE and COFF Specification, the AddressOfEntryPoint
field in the PE header is defined as "For program images, this is the starting address." It's this field that will typically point to the framework initialization code described above.
Note that despite AddressOfEntryPoint
being the starting address of the program, the code at that address will be executed after TLS callback functions (also documented in the PE/COFF documentation) if they exist, and after statically loaded DLLs' DllMain() functions.
parameters passed to the entry point by the Windows loader
As explained here by @igor-skochinsky, "the registers at the entry point of PE file do not have defined values." However, as he points out, EAX
often points to the AddressOfEntryPoint
and EBX
often points to the PEB.
You may want to refer to @Ange's Initial values documentation to find other unofficial register values at entry point.