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.

212 lines
3.4 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. isudump.c
  5. Abstract:
  6. Calls InstallShield APIs to dump out an install log file (foo.isu)
  7. Author:
  8. Jim Schmidt (jimschm) 19-Feb-1999
  9. Revision History:
  10. <full name> (<alias>) <date> <comments>
  11. --*/
  12. #include "pch.h"
  13. #include "ismig.h"
  14. HANDLE g_hHeap;
  15. HINSTANCE g_hInst;
  16. BOOL WINAPI MigUtil_Entry (HINSTANCE, DWORD, PVOID);
  17. BOOL
  18. pCallEntryPoints (
  19. DWORD Reason
  20. )
  21. {
  22. HINSTANCE Instance;
  23. //
  24. // Simulate DllMain
  25. //
  26. Instance = g_hInst;
  27. //
  28. // Initialize the common libs
  29. //
  30. if (!MigUtil_Entry (Instance, Reason, NULL)) {
  31. return FALSE;
  32. }
  33. return TRUE;
  34. }
  35. BOOL
  36. Init (
  37. VOID
  38. )
  39. {
  40. g_hHeap = GetProcessHeap();
  41. g_hInst = GetModuleHandle (NULL);
  42. return pCallEntryPoints (DLL_PROCESS_ATTACH);
  43. }
  44. VOID
  45. Terminate (
  46. VOID
  47. )
  48. {
  49. pCallEntryPoints (DLL_PROCESS_DETACH);
  50. }
  51. VOID
  52. HelpAndExit (
  53. VOID
  54. )
  55. {
  56. //
  57. // This routine is called whenever command line args are wrong
  58. //
  59. _ftprintf (
  60. stderr,
  61. TEXT("Command Line Syntax:\n\n")
  62. TEXT(" isudump <file>\n")
  63. TEXT("\nDescription:\n\n")
  64. TEXT(" isudump dumps an InstallShield log file. It requires ismig.dll.\n")
  65. TEXT("\nArguments:\n\n")
  66. TEXT(" <file> Specifies full path to InstallShield log file\n")
  67. );
  68. exit (1);
  69. }
  70. INT
  71. __cdecl
  72. _tmain (
  73. INT argc,
  74. PCTSTR argv[]
  75. )
  76. {
  77. INT i;
  78. PCTSTR FileArg = NULL;
  79. PISUGETALLSTRINGS ISUGetAllStrings;
  80. HANDLE Lib;
  81. BOOL LoadError = FALSE;
  82. HGLOBAL List;
  83. PCSTR MultiSz;
  84. MULTISZ_ENUMA e;
  85. PCSTR AnsiFileName;
  86. INT Count;
  87. for (i = 1 ; i < argc ; i++) {
  88. if (argv[i][0] == TEXT('/') || argv[i][0] == TEXT('-')) {
  89. HelpAndExit();
  90. } else {
  91. //
  92. // Parse other args that don't require / or -
  93. //
  94. if (FileArg) {
  95. HelpAndExit();
  96. }
  97. FileArg = argv[i];
  98. }
  99. }
  100. if (!FileArg) {
  101. HelpAndExit();
  102. }
  103. //
  104. // Begin processing
  105. //
  106. if (!Init()) {
  107. return 0;
  108. }
  109. Lib = LoadLibrary (TEXT("ismig.dll"));
  110. if (Lib) {
  111. ISUGetAllStrings = (PISUGETALLSTRINGS) GetProcAddress (Lib, "ISUGetAllStrings");
  112. if (!ISUGetAllStrings) {
  113. LoadError = TRUE;
  114. }
  115. } else {
  116. LoadError = TRUE;
  117. }
  118. if (!LoadError) {
  119. AnsiFileName = CreateDbcs (FileArg);
  120. List = ISUGetAllStrings (AnsiFileName);
  121. if (!List) {
  122. fprintf (
  123. stderr,
  124. "ERROR: Can't get strings from %s (rc=%u)\n",
  125. AnsiFileName,
  126. GetLastError()
  127. );
  128. } else {
  129. MultiSz = (PCSTR) GlobalLock (List);
  130. Count = 0;
  131. if (EnumFirstMultiSzA (&e, MultiSz)) {
  132. do {
  133. Count++;
  134. printf ("%s\n", e.CurrentString);
  135. } while (EnumNextMultiSzA (&e));
  136. }
  137. printf ("\n%i total string%s\n", Count, i == 1 ? "" : "s");
  138. GlobalUnlock (List);
  139. GlobalFree (List);
  140. }
  141. DestroyDbcs (AnsiFileName);
  142. } else {
  143. _ftprintf (stderr, TEXT("ERROR: Can't load ISMIG.DLL (rc=%u)\n"), GetLastError());
  144. }
  145. if (Lib) {
  146. FreeLibrary (Lib);
  147. }
  148. //
  149. // End of processing
  150. //
  151. Terminate();
  152. return 0;
  153. }