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.

104 lines
2.7 KiB

  1. // MessageFile.cpp : Defines the entry point for the DLL application.
  2. //
  3. #include "stdafx.h"
  4. // RG ---------- Part of message file registration -------------
  5. static CHAR s_pwszEventSource[] = "IISSCOv50";
  6. HINSTANCE g_hDllInst;
  7. CHAR c_szMAPS[11] = "IISSCOv50";
  8. //-------------- end RG -----------------------------------------
  9. BOOL APIENTRY DllMain( HINSTANCE hModule,
  10. DWORD ul_reason_for_call,
  11. LPVOID lpReserved
  12. )
  13. {
  14. g_hDllInst = hModule;
  15. return true;
  16. }
  17. /////////////////////////////////////////////////////////////////////////////
  18. // DllRegisterServer - Adds entries to the system registry
  19. STDAPI DllRegisterServer(void)
  20. {
  21. // -------Added by to register message file -----------------------
  22. HRESULT hr = E_FAIL;
  23. TCHAR szModulePath[200];
  24. DWORD cPathLen, dwData;
  25. LONG lRes;
  26. HKEY hkey = NULL, hkApp = NULL;
  27. // RG - This returns full filename and path to this DLL. I just want the directory
  28. cPathLen = GetModuleFileName(g_hDllInst, szModulePath,
  29. sizeof(szModulePath)/sizeof(TCHAR));
  30. if (cPathLen == 0)
  31. goto LocalCleanup;
  32. lRes = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
  33. "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\",
  34. 0, KEY_ALL_ACCESS, &hkey);
  35. if (lRes != ERROR_SUCCESS)
  36. goto LocalCleanup;
  37. lRes = RegCreateKeyEx(hkey, c_szMAPS, 0, NULL, REG_OPTION_NON_VOLATILE,
  38. KEY_ALL_ACCESS, NULL, &hkApp, NULL);
  39. if (lRes != ERROR_SUCCESS)
  40. goto LocalCleanup;
  41. lRes = RegSetValueEx(hkApp, "EventMessageFile",
  42. 0, REG_EXPAND_SZ,
  43. (LPBYTE) szModulePath,
  44. (sizeof(szModulePath[0]) * cPathLen) + 1);
  45. if (lRes != ERROR_SUCCESS)
  46. goto LocalCleanup;
  47. dwData = (EVENTLOG_ERROR_TYPE
  48. | EVENTLOG_WARNING_TYPE
  49. | EVENTLOG_INFORMATION_TYPE);
  50. lRes = RegSetValueEx(hkApp, "TypesSupported",
  51. 0, REG_DWORD,
  52. (LPBYTE) &dwData,
  53. sizeof(dwData));
  54. if (lRes != ERROR_SUCCESS)
  55. goto LocalCleanup;
  56. hr = S_OK;
  57. LocalCleanup:
  58. if (hkApp)
  59. {
  60. RegCloseKey(hkApp);
  61. }
  62. if (hkey)
  63. {
  64. // Cleanup on complete failure
  65. if (FAILED(hr))
  66. {
  67. RegDeleteKey(hkey, c_szMAPS);
  68. }
  69. RegCloseKey(hkey);
  70. }
  71. return hr;
  72. //----------- End of Register IISScoMessageFile.dll -----------
  73. //return TRUE;
  74. }
  75. STDAPI DllUnregisterServer(void)
  76. {
  77. return S_OK;
  78. }
  79. void __declspec( dllexport ) dummyfunc( void )
  80. {
  81. return ;
  82. }