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.

96 lines
2.7 KiB

  1. /*****************************************************************************
  2. *
  3. * map.c - Key Remap
  4. *
  5. *****************************************************************************/
  6. #include "map.h"
  7. /*****************************************************************************
  8. *
  9. * The sqiffle for this file.
  10. *
  11. *****************************************************************************/
  12. #define sqfl sqflDll
  13. /*****************************************************************************
  14. *
  15. * DllGetClassObject
  16. *
  17. * OLE entry point. Produces an IClassFactory for the indicated GUID.
  18. *
  19. *****************************************************************************/
  20. STDAPI
  21. DllGetClassObject(REFCLSID rclsid, RIID riid, PPV ppvObj)
  22. {
  23. HRESULT hres;
  24. EnterProc(DllGetClassObject, (_ "G", rclsid));
  25. if (IsEqualIID(rclsid, &CLSID_KeyRemap)) {
  26. hres = CMapFactory_New(riid, ppvObj);
  27. } else {
  28. *ppvObj = 0;
  29. hres = CLASS_E_CLASSNOTAVAILABLE;
  30. }
  31. ExitOleProcPpv(ppvObj);
  32. return hres;
  33. }
  34. /*****************************************************************************
  35. *
  36. * DllCanUnloadNow
  37. *
  38. * OLE entry point. Fail iff there are outstanding refs.
  39. *
  40. * There is an unavoidable race condition between DllCanUnloadNow
  41. * and the creation of a new reference: Between the time we
  42. * return from DllCanUnloadNow() and the caller inspects the value,
  43. * another thread in the same process may decide to call
  44. * DllGetClassObject, thus suddenly creating an object in this DLL
  45. * when there previously was none.
  46. *
  47. * It is the caller's responsibility to prepare for this possibility;
  48. * there is nothing we can do about it.
  49. *
  50. *****************************************************************************/
  51. STDAPI
  52. DllCanUnloadNow(void)
  53. {
  54. SquirtSqflPtszV(sqfl, TEXT("DllCanUnloadNow() - g_cRef = %d"), g_cRef);
  55. return g_cRef ? S_FALSE : S_OK;
  56. }
  57. /*****************************************************************************
  58. *
  59. * Entry32
  60. *
  61. * DLL entry point.
  62. *
  63. *****************************************************************************/
  64. STDAPI_(BOOL)
  65. Entry32(HINSTANCE hinst, DWORD dwReason, LPVOID lpReserved)
  66. {
  67. switch (dwReason) {
  68. case DLL_PROCESS_ATTACH:
  69. g_hinst = hinst;
  70. #ifdef DEBUG
  71. sqflCur = GetProfileInt(TEXT("DEBUG"), TEXT("KeyRemap"), 0);
  72. SquirtSqflPtszV(sqfl, TEXT("LoadDll - KeyRemap"));
  73. #endif
  74. }
  75. return 1;
  76. }
  77. /*****************************************************************************
  78. *
  79. * The long-awaited CLSID
  80. *
  81. *****************************************************************************/
  82. #include <initguid.h>
  83. DEFINE_GUID(CLSID_KeyRemap, 0x176AA2C0, 0x9E15, 0x11cf,
  84. 0xbf,0xc7,0x44,0x45,0x53,0x54,0,0);