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.

112 lines
2.5 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: csresstr.h
  7. //
  8. // Contents: Cert Server resource verification support
  9. //
  10. //---------------------------------------------------------------------------
  11. // Build a local resstr.h, include this include file in one compiland, and
  12. // invoke myVerifyResourceStrings() to verify all resources are present.
  13. #if DBG
  14. #define myVerifyResourceStrings(h) _myVerifyResourceStrings(h)
  15. #else
  16. #define myVerifyResourceStrings(h) S_OK
  17. #endif
  18. #if DBG
  19. typedef struct _RESSTRING
  20. {
  21. WCHAR const *pwszSymbol;
  22. DWORD IdString;
  23. } RESSTRING;
  24. #define RESSTR(id) { L#id, id }
  25. RESSTRING g_aResString[] = {
  26. #include "resstr.h"
  27. { NULL, 0 }
  28. };
  29. //+------------------------------------------------------------------------
  30. // Function: _myVerifyResourceStrings
  31. //
  32. // Synopsis: Load and verify all resource strings are present
  33. //
  34. //-------------------------------------------------------------------------
  35. HRESULT
  36. _myVerifyResourceStrings(
  37. HINSTANCE hInstance)
  38. {
  39. HRESULT hr = S_OK;
  40. BOOL fDump, fRet;
  41. int i;
  42. int cFail;
  43. CAutoLPWSTR pwszStrBuf;
  44. WCHAR wszBuf[64];
  45. fDump = NULL != getenv("CertSrv_DumpStrings");
  46. cFail = 0;
  47. for (i = 0; NULL != g_aResString[i].pwszSymbol; i++)
  48. {
  49. pwszStrBuf = myLoadResourceStringNoCache(
  50. hInstance,
  51. g_aResString[i].IdString);
  52. if (pwszStrBuf == NULL)
  53. {
  54. hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  55. _PrintErrorStr(hr, "myLoadResourceStringNoCache", g_aResString[i].pwszSymbol);
  56. cFail++;
  57. }
  58. if (fDump)
  59. {
  60. DBGPRINT((
  61. DBG_SS_CERTLIB,
  62. "Resource(%ws: %ws)\n",
  63. g_aResString[i].pwszSymbol,
  64. pwszStrBuf != NULL? pwszStrBuf : L"-- MISSING"));
  65. }
  66. pwszStrBuf.Cleanup();
  67. }
  68. fRet = GetModuleFileName(hInstance, wszBuf, ARRAYSIZE(wszBuf));
  69. wszBuf[ARRAYSIZE(wszBuf) - 1] = L'\0';
  70. if (!fRet)
  71. {
  72. HRESULT hr2 = myHLastError();
  73. _PrintError(hr2, "GetModuleFileName");
  74. wcscpy(wszBuf, L"UNKNOWN MODULE");
  75. }
  76. if (0 == cFail)
  77. {
  78. if (fDump)
  79. {
  80. DBGPRINT((
  81. DBG_SS_CERTLIB,
  82. "%ws: Resource strings all present\n",
  83. wszBuf));
  84. }
  85. }
  86. else
  87. {
  88. DBGPRINT((
  89. DBG_SS_ERROR,
  90. "%ws: %u Resource strings missing\n",
  91. wszBuf,
  92. cFail));
  93. }
  94. //error:
  95. return(hr);
  96. }
  97. #endif // DBG