DLL的入口点函数
1 DLL入口点函数
dll可以包含一些入口点函数,这些函数是具有通知性质的,通常是DLL执行一些进程或线程相关的初始化or清理工作时触发的。一般可以这么写
//入口点函数
BOOL WINAPI DllMain(HINSTANCE hInstDll, DWORD fdwReason, PVOID FImpLoad) {
{
case DLL_PROCESS_ATTACH:
//The DLL is mapped into the process' address space
break;
case DLL_THREAD_ATTACH:
//A thread is being created
break;
case DLL_THREAD_DETACH:
// A thread is exiting cleanly.
break;
case DLL_PROCESS_DETACH:
// The DLL is beign unmapped from the process' address space
break;
}
return (TRUE); // Used only for DLL_PROCESS_ATTACH
}
"""参数说明
1. hInstDll:DLL实例的句柄,一个虚拟内存地址
2. fdwReason:调入的原因,也就是触发通知的原因
3. FImpload:显式载入为0,隐式载入为非零
"""