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.

277 lines
5.4 KiB

  1. #ifndef __APPHELP_LIB_H
  2. #define __APPHELP_LIB_H
  3. #include <assert.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include <stddef.h>
  8. #include <memory.h>
  9. #include <malloc.h>
  10. #include <nt.h>
  11. #include <ntrtl.h>
  12. #include <nturtl.h>
  13. #include <windows.h>
  14. #include "shimdb.h"
  15. #if DBG // make sure that apphelp_tools is defined when compiling checked
  16. #ifndef APPHELP_TOOLS
  17. #define APPHELP_TOOLS
  18. #endif
  19. #endif
  20. //
  21. // Routines in ahcache.c
  22. //
  23. BOOL
  24. BaseUpdateAppcompatCache(
  25. LPCWSTR pwszPath,
  26. HANDLE hFile,
  27. BOOL bRemove
  28. );
  29. BOOL
  30. BaseFlushAppcompatCache(
  31. VOID
  32. );
  33. BOOL
  34. BaseCheckAppcompatCache(
  35. LPCWSTR pwszPath,
  36. HANDLE hFile,
  37. PVOID pEnvironment,
  38. DWORD* dwReason
  39. );
  40. VOID
  41. BaseDumpAppcompatCache(
  42. VOID
  43. );
  44. //
  45. // Apphelp api to update the cache
  46. //
  47. //
  48. BOOL
  49. WINAPI
  50. ApphelpUpdateCacheEntry(
  51. LPCWSTR pwszPath, // nt path or dos path (see bNTPath)
  52. HANDLE hFile, // file handle (or INVALID_HANDLE_VALUE if not needed)
  53. BOOL bDeleteEntry, // TRUE if we are to delete the entry
  54. BOOL bNTPath // if TRUE -- NT path, FALSE - dos path
  55. );
  56. //
  57. // Reasons:
  58. //
  59. #define SHIM_CACHE_NOT_FOUND 0x00000001
  60. #define SHIM_CACHE_BYPASS 0x00000002 // bypass cache (either removable media or temp dir)
  61. #define SHIM_CACHE_LAYER_ENV 0x00000004 // layer env variable set
  62. #define SHIM_CACHE_MEDIA 0x00000008
  63. #define SHIM_CACHE_TEMP 0x00000010
  64. #define SHIM_CACHE_NOTAVAIL 0x00000020
  65. //
  66. // Routines in check.c
  67. //
  68. INT_PTR CALLBACK
  69. AppCompatDlgProc(
  70. HWND hDlg,
  71. UINT uMsg,
  72. WPARAM wParam,
  73. LPARAM lParam
  74. );
  75. DWORD
  76. ShowApphelpDialog(
  77. PAPPHELP_DATA pApphelpData
  78. );
  79. // in apphelppath.c
  80. BOOL
  81. ConvertToDosPath(
  82. OUT LPWSTR* ppDosPath,
  83. IN LPCWSTR pwszPath
  84. );
  85. BOOL
  86. CheckStringPrefixUnicode(
  87. PUNICODE_STRING pStrPrefix,
  88. PUNICODE_STRING pString,
  89. BOOL CaseInSensitive);
  90. // this function is used to free the dos path
  91. // it checks whether the path was allocated or
  92. // the static buffer was used
  93. VOID
  94. FreeDosPath(WCHAR* pDosPath);
  95. //
  96. // in matchApphelp.c
  97. //
  98. BOOL
  99. GetExeSxsData(
  100. HSDB hSDB,
  101. TAGREF trExe,
  102. PVOID* ppSxsData,
  103. DWORD* pcbSxsData
  104. );
  105. //
  106. // in apphelpcache.c
  107. //
  108. VOID ShimUpdateCache(LPCWSTR pwszPath, PSDBQUERYRESULT psdbQuery);
  109. VOID ShimCacheProcessCleanup(VOID);
  110. VOID ShimCacheThreadCleanup(VOID);
  111. BOOL ShimCacheProcessInit(VOID);
  112. VOID ShimInitCache(PVOID pCache);
  113. VOID ShimRemoveExeFromCache(LPCWSTR pwszPath);
  114. BOOL
  115. LookupCache(
  116. LPCWSTR pwszPath,
  117. PSDBQUERYRESULT psdbQuery
  118. );
  119. BOOL
  120. BypassCache(
  121. LPCWSTR pwszPath,
  122. WCHAR* pEnvironment,
  123. BOOL* pbLayer
  124. );
  125. //
  126. // in apphelpcheck.c
  127. //
  128. //
  129. DWORD
  130. ShowApphelp(
  131. IN OUT PAPPHELP_DATA pApphelpData,
  132. IN LPCWSTR pwszDetailsDatabasePath,
  133. IN PDB pdbDetails
  134. );
  135. //
  136. // same is in shell/published and also the same as used in shimdbc
  137. //
  138. #define APPTYPE_TYPE_MASK 0x000000FF
  139. #define APPTYPE_INC_NOBLOCK 0x00000001
  140. #define APPTYPE_INC_HARDBLOCK 0x00000002
  141. #define APPTYPE_MINORPROBLEM 0x00000003
  142. #define APPTYPE_REINSTALL 0x00000004
  143. #define APPTYPE_VERSIONSUB 0x00000005
  144. #define APPTYPE_SHIM 0x00000006
  145. #define APPTYPE_NONE 0x00000000
  146. enum ShimAppHelpSeverityType
  147. {
  148. APPHELP_MINORPROBLEM = APPTYPE_MINORPROBLEM,
  149. APPHELP_HARDBLOCK = APPTYPE_INC_HARDBLOCK,
  150. APPHELP_NOBLOCK = APPTYPE_INC_NOBLOCK,
  151. APPHELP_VERSIONSUB = APPTYPE_VERSIONSUB,
  152. APPHELP_SHIM = APPTYPE_SHIM,
  153. APPHELP_REINSTALL = APPTYPE_REINSTALL,
  154. APPHELP_NONE = APPTYPE_NONE
  155. };
  156. //
  157. // SDBAPI internal functions that we use to obtain flags for ntvdm
  158. //
  159. BOOL
  160. SDBAPI
  161. SdbpPackCmdLineInfo(
  162. IN PVOID pvFlagInfoList,
  163. OUT PVOID* ppFlagInfo
  164. );
  165. BOOL
  166. SDBAPI
  167. SdbpFreeFlagInfoList(
  168. IN PVOID pvFlagInfoList
  169. );
  170. //
  171. // Alloc/free routines from dblib
  172. //
  173. extern void* SdbAlloc(size_t);
  174. extern void SdbFree(void*);
  175. //
  176. // Stack allocation routine
  177. //
  178. #ifndef STACK_ALLOC
  179. //
  180. //
  181. // Exact same definition for stack-related routines is found in sdbp.h
  182. //
  183. VOID
  184. SdbResetStackOverflow(
  185. VOID
  186. );
  187. #if DBG | defined(_WIN64)
  188. #define STACK_ALLOC(ptrVar, nSize) \
  189. { \
  190. PVOID* ppVar = (PVOID*)&(ptrVar); \
  191. *ppVar = SdbAlloc(nSize); \
  192. }
  193. #define STACK_FREE(pMemory) \
  194. SdbFree(pMemory)
  195. #else // !DBG
  196. //
  197. // HACK ALERT
  198. //
  199. // The code below works because when we hit a stack overflow - we catch the exception
  200. // and subsequently fix the stack up using a crt routine
  201. //
  202. //
  203. // this routine lives in sdbapi, semi-private api
  204. //
  205. #define STACK_ALLOC(ptrVar, nSize) \
  206. __try { \
  207. PVOID* ppVar = (PVOID*)&(ptrVar); \
  208. *ppVar = _alloca(nSize); \
  209. } __except (GetExceptionCode() == EXCEPTION_STACK_OVERFLOW ? \
  210. EXCEPTION_EXECUTE_HANDLER:EXCEPTION_CONTINUE_SEARCH) { \
  211. (ptrVar) = NULL; \
  212. } \
  213. \
  214. if (ptrVar == NULL) { \
  215. SdbResetStackOverflow(); \
  216. }
  217. #define STACK_FREE(pMemory)
  218. #endif // DBG
  219. #endif // !defined(STACK_ALLOC)
  220. #endif