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.

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