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.

151 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 2001 Microsoft Corporation
  3. Module Name:
  4. avrfutil.h
  5. Abstract:
  6. Common headers for app verifier utility functions - used by the exe as well as the shims
  7. Revision History:
  8. 08/26/2001 dmunsil Created.
  9. --*/
  10. #pragma once
  11. #ifndef _AVRFUTIL_H_
  12. #define _AVRFUTIL_H_
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <ntldr.h>
  17. #include <windows.h>
  18. #include <prsht.h>
  19. #include "shimdb.h"
  20. namespace ShimLib
  21. {
  22. //
  23. // Registry key path where we store our settings.
  24. // See shimdb.w for define of APPCOMPAT_KEY_PATH_MACHINE.
  25. //
  26. #define AV_KEY APPCOMPAT_KEY_PATH_MACHINE L"\\AppVerifier"
  27. //
  28. // Used to indicate whether we should call DbgBreakPoint
  29. // when VLOG gets called.
  30. //
  31. #define AV_BREAKIN L"BreakOnLog"
  32. //
  33. // Used to indicate if we're running in internal mode
  34. // or not. This value is stored under the AV_KEY
  35. // defined above. This affects the tests that are displayed
  36. // in the UI and how we filter the log files.
  37. //
  38. #define AV_INTERNALMODE L"InternalMode"
  39. BOOL SaveShimSettingDWORD(
  40. LPCWSTR szShim,
  41. LPCWSTR szExe,
  42. LPCWSTR szSetting,
  43. DWORD dwSetting
  44. );
  45. DWORD GetShimSettingDWORD(
  46. LPCWSTR szShim,
  47. LPCWSTR szExe,
  48. LPCWSTR szSetting,
  49. DWORD dwDefault
  50. );
  51. BOOL SaveShimSettingString(
  52. LPCWSTR szShim,
  53. LPCWSTR szExe,
  54. LPCWSTR szSetting,
  55. LPCWSTR szValue
  56. );
  57. BOOL GetShimSettingString(
  58. LPCWSTR szShim,
  59. LPCWSTR szExe,
  60. LPCWSTR szSetting,
  61. LPWSTR szResult,
  62. DWORD dwBufferLen // in WCHARs
  63. );
  64. DWORD GetAppVerifierLogPath(
  65. LPWSTR pwszBuffer,
  66. DWORD cchBufferSize
  67. );
  68. BOOL
  69. IsInternalModeEnabled(
  70. void
  71. );
  72. BOOL
  73. EnableDisableInternalMode(
  74. DWORD dwSetting
  75. );
  76. //
  77. // Handy macro-like name extraction utility for property sheets
  78. // NOTE: only works during WM_INITDIALOG!!!
  79. //
  80. inline LPCWSTR ExeNameFromLParam(LPARAM lParam)
  81. {
  82. if (lParam) {
  83. LPCWSTR szRet = (LPCWSTR)(((LPPROPSHEETPAGE)lParam)->lParam);
  84. if (szRet) {
  85. return szRet;
  86. }
  87. }
  88. return AVRF_DEFAULT_SETTINGS_NAME_W;
  89. }
  90. //
  91. // useful utility function for getting the current exe name during shim
  92. // startup (so it extracts the correct settings)
  93. //
  94. inline LPWSTR GetCurrentExeName(LPWSTR szName, DWORD dwChars)
  95. {
  96. HMODULE hMod = GetModuleHandle(NULL);
  97. if (!hMod) {
  98. return NULL;
  99. }
  100. WCHAR szModule[MAX_PATH];
  101. DWORD dwC = GetModuleFileNameW(hMod, szModule, MAX_PATH);
  102. if (!dwC) {
  103. return NULL;
  104. }
  105. int nLen = (int)wcslen(szModule);
  106. for (int i = nLen - 1; i != -1; --i) {
  107. if (szModule[i] == L'\\') {
  108. break;
  109. }
  110. }
  111. ++i;
  112. wcsncpy(szName, &szModule[i], dwChars);
  113. szName[dwChars - 1] = 0;
  114. return szName;
  115. }
  116. }; // end of namespace ShimLib
  117. #endif