Search code examples
windowsdriverentry-point

Why should Windows driver's entry name be "DriverEntry"? (Or WinMain/DllMain too)


Why should Windows driver's entry name be "DriverEntry"? Can't Windows find the driver's entry point using the PE header or, say, just call main() function to initialize the driver?

Also

In case of WinMain, too.

I think main() or MainCRTSetup()should be main() or MainCRTSetup() unless we change the compiler setting, to let the compiler know that is the entry of our program.

However that is for compiler, isn't it? Why does Windows require the entry function name of drivers be DriverEntry?


Solution

  • The people at Microsoft decided that the Entry point for a .sys file would be DriverEntry, and that is the value that gets added to the PE header.

    I think they made it incompatible with a windows EXE or DLL to ensure that an exe could not be used in place of a .SYS