Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.2 KiB

  1. #include "precomp.h"
  2. #include "list.h"
  3. CRegisteredEventList g_RegisteredEventList;
  4. VOID
  5. NhInitializeCallBack(VOID)
  6. {
  7. return;
  8. }
  9. //
  10. //
  11. //
  12. VOID
  13. NhUnRegisterEvent(HANDLE WaitHandle)
  14. {
  15. HANDLE hEvent;
  16. UnregisterWaitEx(WaitHandle,INVALID_HANDLE_VALUE);
  17. g_RegisteredEventList.Remove(WaitHandle,&hEvent);
  18. CloseHandle(hEvent);
  19. return;
  20. }
  21. //
  22. //
  23. //
  24. VOID
  25. NhEventCallBackFunction(
  26. PVOID Context,
  27. BOOLEAN TimerOrWait
  28. )
  29. {
  30. HANDLE hEvent = (HANDLE)Context;
  31. HANDLE WaitHandle;
  32. VOID *Context1;
  33. VOID *Context2;
  34. EVENT_CALLBACK CallBack;
  35. g_RegisteredEventList.Remove(&WaitHandle,hEvent,&CallBack,&Context1,&Context2);
  36. CloseHandle(hEvent);
  37. (*CallBack)(TimerOrWait,Context1,Context2);
  38. return;
  39. }
  40. //
  41. //
  42. //
  43. HANDLE
  44. NhRegisterEvent(
  45. HANDLE hEvent,
  46. EVENT_CALLBACK CallBack,
  47. VOID* Context,
  48. VOID* Context2,
  49. ULONG TimeOut
  50. )
  51. {
  52. VOID *nContext;
  53. HANDLE WaitHandle = NULL;
  54. BOOL Err;
  55. Err = RegisterWaitForSingleObject(&WaitHandle,hEvent,NhEventCallBackFunction,(PVOID)hEvent,TimeOut,
  56. WT_EXECUTEDEFAULT | WT_EXECUTEONLYONCE);
  57. if (Err)
  58. g_RegisteredEventList.Insert(WaitHandle,hEvent,CallBack,Context,Context2);
  59. else
  60. WaitHandle = NULL;
  61. return WaitHandle;
  62. }