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.

232 lines
5.0 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. debug.c
  5. Abstract:
  6. This module implements debug only routines.
  7. Author:
  8. vadimb created sometime in 2000
  9. Revision History:
  10. clupu cleanup 12/27/2000
  11. --*/
  12. #include "apphelp.h"
  13. #if defined(APPHELP_TOOLS)
  14. //
  15. // this functionality will not be available (temporary)
  16. //
  17. DWORD
  18. ApphelpShowUI(
  19. TAGREF trExe, // tagref for the exe (should be a "LOCAL" tagref)
  20. LPCWSTR pwszDatabase, // database path (we will make a local db out of it
  21. LPCWSTR pwszDetailsDatabase,
  22. LPCWSTR pwszApphelpPath,
  23. BOOL bLocalChum,
  24. BOOL bUseHtmlHelp
  25. )
  26. /*++
  27. Return: The same as what ShowApphelp returns.
  28. Desc: Given the database and the (local) tagref it procures the dialog
  29. with all the information in it for a given htmlhelpid.
  30. This api is for internal use only and it is available on
  31. checked builds only
  32. --*/
  33. {
  34. /*
  35. HSDB hSDB = NULL;
  36. APPHELP_DATA ApphelpData;
  37. DWORD dwRet = (DWORD)-1;
  38. PAPPHELPCONTEXT pContext;
  39. pContext = InitializeApphelpContext();
  40. if (pContext == NULL) {
  41. DBGPRINT((sdlError,
  42. "iShowApphelpDebug",
  43. "Failed to initialize Apphelp context for thread id 0x%x\n",
  44. GetCurrentThreadId()));
  45. goto ExitShowApphelpDebug;
  46. }
  47. hSDB = SdbInitDatabase(HID_NO_DATABASE, NULL);
  48. if (hSDB == NULL) {
  49. DBGPRINT((sdlError, "iShowApphelpDebug", "Failed to initialize database\n"));
  50. goto Done;
  51. }
  52. //
  53. // Open local database
  54. //
  55. if (!SdbOpenLocalDatabase(hSDB, pwszDatabase)) {
  56. DBGPRINT((sdlError,
  57. "iShowApphelpDebug",
  58. "Failed to open database \"%ls\"\n",
  59. pwszDatabase));
  60. goto Done;
  61. }
  62. if (SdbIsTagrefFromMainDB(trExe)) {
  63. DBGPRINT((sdlError, "iShowApphelpDebug", "Can only operate on local tagrefs\n"));
  64. goto Done;
  65. }
  66. //
  67. // Now we venture out and read apphelp data
  68. //
  69. if (!SdbReadApphelpData(hSDB, trExe, &ApphelpData)) {
  70. DBGPRINT((sdlError,
  71. "iShowApphelpDebug",
  72. "Error while trying to read Apphelp data for 0x%x in \"%S\"\n",
  73. trExe,
  74. pwszDatabase));
  75. goto Done;
  76. }
  77. //
  78. // We have the data and everything else we need to throw a dialog,
  79. // set debug chum ...
  80. //
  81. pContext->bShowOfflineContent = bLocalChum;
  82. //
  83. // Should we use html help instead ?
  84. //
  85. pContext->bUseHtmlHelp = bUseHtmlHelp;
  86. //
  87. // Pointer to the local chum.
  88. //
  89. pContext->pwszApphelpPath = pwszApphelpPath;
  90. //
  91. // And now throw a dialog...
  92. //
  93. dwRet = ShowApphelp(&ApphelpData, pwszDetailsDatabase, NULL);
  94. Done:
  95. if (hSDB != NULL) {
  96. SdbReleaseDatabase(hSDB);
  97. }
  98. //
  99. // Release the context for this thread/instance
  100. //
  101. ReleaseApphelpContext();
  102. ExitShowApphelpDebug:
  103. return dwRet;
  104. */
  105. return TRUE;
  106. }
  107. BOOL
  108. ApphelpShowDialog(
  109. IN PAPPHELP_INFO pAHInfo, // the info necessary to find the apphelp data
  110. IN PHANDLE phProcess // [optional] returns the process handle of
  111. // the process displaying the apphelp.
  112. // When the process completes, the return value
  113. // (from GetExitCodeProcess()) will be zero
  114. // if the app should not run, or non-zero
  115. // if it should run.
  116. )
  117. {
  118. BOOL bRunApp = TRUE;
  119. SdbShowApphelpDialog(pAHInfo,
  120. phProcess,
  121. &bRunApp);
  122. return bRunApp;
  123. }
  124. //
  125. // Get all the file's attributes
  126. //
  127. //
  128. BOOL
  129. ApphelpGetFileAttributes(
  130. IN LPCWSTR lpwszFileName,
  131. OUT PATTRINFO* ppAttrInfo,
  132. OUT LPDWORD lpdwAttrCount
  133. )
  134. /*++
  135. Return: The same as what SdbGetFileAttributes returns.
  136. Desc: Stub to call SdbGetFileAttributes.
  137. --*/
  138. {
  139. return SdbGetFileAttributes(lpwszFileName, ppAttrInfo, lpdwAttrCount);
  140. }
  141. BOOL
  142. ApphelpFreeFileAttributes(
  143. IN PATTRINFO pAttrInfo
  144. )
  145. /*++
  146. Return: The same as what SdbFreeFileAttributes returns.
  147. Desc: Stub to call SdbFreeFileAttributes.
  148. --*/
  149. {
  150. return SdbFreeFileAttributes(pAttrInfo);
  151. }
  152. #endif // APPHELP_TOOLS
  153. void CALLBACK
  154. ShimFlushCache(
  155. HWND hwnd,
  156. HINSTANCE hInstance,
  157. LPSTR lpszCmdLine,
  158. int nCmdShow
  159. )
  160. /*++
  161. Return: void.
  162. Desc: Entry point for rundll32.exe. This is used to flush cache
  163. after installing a brand new shim database. Use:
  164. "rundll32 apphelp.dll,ShimFlushCache"
  165. --*/
  166. {
  167. #ifndef WIN2K_NOCACHE
  168. BaseFlushAppcompatCache();
  169. #endif
  170. }
  171. void CALLBACK
  172. ShimDumpCache(
  173. HWND hwnd,
  174. HINSTANCE hInstance,
  175. LPSTR lpszCmdLine,
  176. int nCmdShow
  177. )
  178. {
  179. #ifndef WIN2K_NOCACHE
  180. BaseDumpAppcompatCache();
  181. #endif
  182. }