Leaked source code of windows server 2003
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.

59 lines
1.4 KiB

  1. #include "stdafx.h"
  2. #include "BridgeCP.h"
  3. #include "Factory.h"
  4. DWORD g_tls = (DWORD) -1;
  5. //------------------------------------------------------------------------------
  6. BridgeData *
  7. GetBridgeData()
  8. {
  9. return (BridgeData *) TlsGetValue(g_tls);
  10. }
  11. //------------------------------------------------------------------------------
  12. BOOL
  13. InitBridge()
  14. {
  15. if (g_tls == (DWORD) -1) {
  16. g_tls = TlsAlloc();
  17. if (g_tls == (DWORD) -1) {
  18. SetError(DU_E_OUTOFKERNELRESOURCES);
  19. return FALSE;
  20. }
  21. }
  22. return TRUE;
  23. }
  24. //------------------------------------------------------------------------------
  25. DUser::Gadget *
  26. BuildBridgeGadget(
  27. IN HCLASS hcl,
  28. IN DUser::Gadget::ConstructInfo * pmicData,
  29. IN EventProc pfnEvent,
  30. IN MethodProc pfnMethod)
  31. {
  32. if (g_tls == -1) {
  33. SetError(DU_E_NOTINITIALIZED);
  34. return NULL;
  35. }
  36. BridgeData * pbd = (BridgeData *) TlsGetValue(g_tls);
  37. if (pbd == NULL) {
  38. pbd = (BridgeData *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BridgeData));
  39. if (pbd == NULL) {
  40. SetError(E_OUTOFMEMORY);
  41. return NULL;
  42. }
  43. TlsSetValue(g_tls, pbd);
  44. }
  45. pbd->pfnEvent = pfnEvent;
  46. pbd->pfnMethod = pfnMethod;
  47. return DUserBuildGadget(hcl, pmicData);
  48. }