Changeset 5973 for trunk/src/user32/HOOK.CPP
- Timestamp:
- Jun 12, 2001, 7:02:42 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/HOOK.CPP
r5935 r5973 1 /* $Id: HOOK.CPP,v 1.2 0 2001-06-09 14:50:15sandervl Exp $ */1 /* $Id: HOOK.CPP,v 1.21 2001-06-12 17:02:33 sandervl Exp $ */ 2 2 3 3 /* … … 86 86 //Global DLL Data 87 87 //SvL: Disabled global system hooks for now 88 ////#pragma data_seg(_GLOBALDATA) 88 //#define GLOBAL_HOOKS 89 #ifdef GLOBAL_HOOKS 90 #pragma data_seg(_GLOBALDATA) 91 #endif 89 92 static HANDLE HOOK_systemHooks[WH_NB_HOOKS] = { 0 }; 93 #ifdef GLOBAL_HOOKS 90 94 static VMutex systemHookMutex(VMUTEX_SHARED, &hGlobalHookMutex); 91 ////#pragma data_seg() 95 #pragma data_seg() 96 #else 97 static CRITICAL_SECTION systemCritSect = {0}; 98 #endif 92 99 static HANDLE HOOK_threadHooks[WH_NB_HOOKS] = { 0 }; 93 static VMutex threadHookMutex; 100 static CRITICAL_SECTION threadCritSect = {0}; 101 102 #ifdef GLOBAL_HOOKS 103 #define SYSTEMHOOK_LOCK() systemHookMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalHookMutex); 104 #define SYSTEMHOOK_UNLOCK() systemHookMutex.leave(&hGlobalHookMutex); 105 #else 106 #define SYSTEMHOOK_LOCK() EnterCriticalSection(&systemCritSect); 107 #define SYSTEMHOOK_UNLOCK() LeaveCriticalSection(&systemCritSect); 108 #endif 94 109 95 110 typedef VOID (*HOOK_MapFunc)(INT, INT, WPARAM *, LPARAM *); … … 324 339 return 0; 325 340 } 326 threadHookMutex.enter();341 EnterCriticalSection(&threadCritSect); 327 342 data->next = teb->o.odin.hooks[id - WH_MINHOOK]; 328 343 teb->o.odin.hooks[id - WH_MINHOOK] = (DWORD)data; 329 threadHookMutex.leave();344 LeaveCriticalSection(&threadCritSect); 330 345 } 331 346 else 332 347 { 333 systemHookMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalHookMutex);348 SYSTEMHOOK_LOCK(); 334 349 data->next = HOOK_systemHooks[id - WH_MINHOOK]; 335 350 HOOK_systemHooks[id - WH_MINHOOK] = (HANDLE)data; 336 systemHookMutex.leave(&hGlobalHookMutex);351 SYSTEMHOOK_UNLOCK(); 337 352 } 338 353 … … 374 389 return FALSE; 375 390 } 376 threadHookMutex.enter();391 EnterCriticalSection(&threadCritSect); 377 392 prevHook = (HOOKDATA **)&teb->o.odin.hooks[data->id - WH_MINHOOK]; 378 393 } 379 394 else { 380 systemHookMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalHookMutex);395 SYSTEMHOOK_LOCK(); 381 396 prevHook = (HOOKDATA **)&HOOK_systemHooks[data->id - WH_MINHOOK]; 382 397 } … … 386 401 if (!prevHook) { 387 402 if (data->ownerThread) { 388 threadHookMutex.leave();403 LeaveCriticalSection(&threadCritSect); 389 404 } 390 else systemHookMutex.leave(&hGlobalHookMutex);405 else SYSTEMHOOK_UNLOCK(); 391 406 392 407 return FALSE; … … 395 410 396 411 if (data->ownerThread) { 397 threadHookMutex.leave();398 } 399 else systemHookMutex.leave(&hGlobalHookMutex);412 LeaveCriticalSection(&threadCritSect); 413 } 414 else SYSTEMHOOK_UNLOCK(); 400 415 401 416 HeapFree(GetProcessHeap(), 0, (LPVOID)data );
Note:
See TracChangeset
for help on using the changeset viewer.