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.

117 lines
2.4 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;
  41. int i;
  42. int cFail;
  43. CAutoLPWSTR wszStrBuf;
  44. WCHAR const *pwsz;
  45. wszStrBuf = (LPWSTR)LocalAlloc(LMEM_FIXED, 2048);
  46. _JumpIfAllocFailed(wszStrBuf, error);
  47. fDump = NULL != getenv("CertSrv_DumpStrings");
  48. cFail = 0;
  49. for (i = 0; NULL != g_aResString[i].pwszSymbol; i++)
  50. {
  51. if (!LoadString(
  52. hInstance,
  53. g_aResString[i].IdString,
  54. wszStrBuf,
  55. sizeof(wszStrBuf)/sizeof(WCHAR)))
  56. {
  57. hr = myHLastError();
  58. if (S_OK == hr)
  59. {
  60. hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
  61. }
  62. _PrintErrorStr(hr, "LoadString", g_aResString[i].pwszSymbol);
  63. cFail++;
  64. wcscpy(wszStrBuf, L"-- MISSING");
  65. }
  66. if (fDump)
  67. {
  68. DBGPRINT((
  69. DBG_SS_CERTLIB,
  70. "Resource(%ws: %ws)\n",
  71. g_aResString[i].pwszSymbol,
  72. wszStrBuf));
  73. }
  74. }
  75. if (!GetModuleFileName(hInstance, wszStrBuf, ARRAYSIZE(wszStrBuf)))
  76. {
  77. HRESULT hr2 = myHLastError();
  78. _PrintError(hr2, "GetModuleFileName");
  79. wcscpy(wszStrBuf, L"UNKNOWN MODULE");
  80. }
  81. if (0 == cFail)
  82. {
  83. if (fDump)
  84. {
  85. DBGPRINT((
  86. DBG_SS_CERTLIB,
  87. "%ws: Resource strings all present\n",
  88. wszStrBuf));
  89. }
  90. }
  91. else
  92. {
  93. DBGPRINT((
  94. DBG_SS_ERROR,
  95. "%ws: %u Resource strings missing\n",
  96. wszStrBuf,
  97. cFail));
  98. }
  99. error:
  100. return(hr);
  101. }
  102. #endif // DBG