Ignore:
Timestamp:
Jun 12, 2001, 7:02:42 PM (24 years ago)
Author:
sandervl
Message:

FillRect & CS_CLASSDC fixes; use critical secions for hooks

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/HOOK.CPP

    r5935 r5973  
    1 /* $Id: HOOK.CPP,v 1.20 2001-06-09 14:50:15 sandervl Exp $ */
     1/* $Id: HOOK.CPP,v 1.21 2001-06-12 17:02:33 sandervl Exp $ */
    22
    33/*
     
    8686//Global DLL Data
    8787//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
    8992static HANDLE HOOK_systemHooks[WH_NB_HOOKS] = { 0 };
     93#ifdef GLOBAL_HOOKS
    9094static VMutex systemHookMutex(VMUTEX_SHARED, &hGlobalHookMutex);
    91 ////#pragma data_seg()
     95#pragma data_seg()
     96#else
     97static CRITICAL_SECTION systemCritSect = {0};
     98#endif
    9299static HANDLE HOOK_threadHooks[WH_NB_HOOKS] = { 0 };
    93 static VMutex threadHookMutex;
     100static 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
    94109
    95110typedef VOID (*HOOK_MapFunc)(INT, INT, WPARAM *, LPARAM *);
     
    324339                return 0;
    325340        }
    326         threadHookMutex.enter();
     341        EnterCriticalSection(&threadCritSect);
    327342        data->next = teb->o.odin.hooks[id - WH_MINHOOK];
    328343        teb->o.odin.hooks[id - WH_MINHOOK] = (DWORD)data;
    329         threadHookMutex.leave();
     344        LeaveCriticalSection(&threadCritSect);
    330345    }
    331346    else
    332347    {
    333         systemHookMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalHookMutex);
     348        SYSTEMHOOK_LOCK();
    334349        data->next = HOOK_systemHooks[id - WH_MINHOOK];
    335350        HOOK_systemHooks[id - WH_MINHOOK] = (HANDLE)data;
    336         systemHookMutex.leave(&hGlobalHookMutex);
     351        SYSTEMHOOK_UNLOCK();
    337352    }
    338353
     
    374389                return FALSE;
    375390        }
    376         threadHookMutex.enter();
     391        EnterCriticalSection(&threadCritSect);
    377392        prevHook = (HOOKDATA **)&teb->o.odin.hooks[data->id - WH_MINHOOK];
    378393    }
    379394    else {
    380         systemHookMutex.enter(VMUTEX_WAIT_FOREVER, &hGlobalHookMutex);
     395        SYSTEMHOOK_LOCK();
    381396        prevHook = (HOOKDATA **)&HOOK_systemHooks[data->id - WH_MINHOOK];
    382397    }
     
    386401    if (!prevHook) {
    387402        if (data->ownerThread) {
    388                 threadHookMutex.leave();
     403                LeaveCriticalSection(&threadCritSect);
    389404        }
    390         else    systemHookMutex.leave(&hGlobalHookMutex);
     405        else    SYSTEMHOOK_UNLOCK();
    391406
    392407        return FALSE;
     
    395410
    396411    if (data->ownerThread) {
    397          threadHookMutex.leave();
    398     }
    399     else systemHookMutex.leave(&hGlobalHookMutex);
     412         LeaveCriticalSection(&threadCritSect);
     413    }
     414    else SYSTEMHOOK_UNLOCK();
    400415
    401416    HeapFree(GetProcessHeap(), 0, (LPVOID)data );
Note: See TracChangeset for help on using the changeset viewer.