📄 cextls.cpp
字号:
// CExTls.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
//This is the shared slot
static DWORD g_dwTlsSlot;
//User Struct
struct UserData
{
};
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
LPVOID lpData;
switch(ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
//Find the index that will be global for all threads
g_dwTlsSlot = TlsAlloc();
if(g_dwTlsSlot == 0xFFFFFFFF)
return FALSE;
case DLL_THREAD_ATTACH:
//Initialize the TLS index for this thread
lpData = (LPVOID)LocalAlloc(LPTR, sizeof(struct UserData));
if(lpData != NULL)
if(TlsSetValue(g_dwTlsSlot, lpData))
{
//This should be handled
}
break;
case DLL_THREAD_DETACH:
//Release the allocated memory for this thread
lpData = TlsGetValue(g_dwTlsSlot);
if(lpData != NULL)
LocalFree((HLOCAL)lpData);
break;
case DLL_PROCESS_DETACH:
//Release the allocated memory for this thread
lpData = TlsGetValue(g_dwTlsSlot);
if(lpData != NULL)
LocalFree((HLOCAL)lpData);
//Give back the TLS slot
TlsFree(g_dwTlsSlot);
break;
default:
break;
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -