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.

295 lines
9.6 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. showinst.c
  5. Abstract:
  6. This program displays the contents of an Installation Modification Log file
  7. created by the INSTALER program
  8. Author:
  9. Steve Wood (stevewo) 15-Jan-1996
  10. Revision History:
  11. --*/
  12. #include "instutil.h"
  13. #include "iml.h"
  14. BOOLEAN DisplayContentsOfTextFiles;
  15. int
  16. ProcessShowIml(
  17. PINSTALLATION_MODIFICATION_LOGFILE pIml
  18. );
  19. int
  20. __cdecl
  21. main(
  22. int argc,
  23. char *argv[]
  24. )
  25. {
  26. int Result;
  27. char *s;
  28. PWSTR pw;
  29. PINSTALLATION_MODIFICATION_LOGFILE pIml;
  30. InitCommonCode( "SHOWINST",
  31. "[-c]",
  32. "-c specifies to display the contents of text files\n"
  33. );
  34. DisplayContentsOfTextFiles = FALSE;
  35. while (--argc) {
  36. s = *++argv;
  37. if (*s == '-' || *s == '/') {
  38. while (*++s) {
  39. switch( tolower( *s ) ) {
  40. case 'c':
  41. DisplayContentsOfTextFiles = TRUE;
  42. break;
  43. default:
  44. CommonSwitchProcessing( &argc, &argv, *s );
  45. break;
  46. }
  47. }
  48. }
  49. else
  50. if (!CommonArgProcessing( &argc, &argv )) {
  51. Usage( "Arguments not supported - '%s'", (ULONG)s );
  52. }
  53. }
  54. if (ImlPath == NULL) {
  55. Usage( "Must specify an installation name as first argument", 0 );
  56. }
  57. if (!SetCurrentDirectory( InstalerDirectory )) {
  58. FatalError( "Unable to change to '%ws' directory (%u)",
  59. (ULONG)InstalerDirectory,
  60. GetLastError()
  61. );
  62. }
  63. pIml = LoadIml( ImlPath );
  64. if (pIml == NULL) {
  65. FatalError( "Unable to open '%ws' (%u)",
  66. (ULONG)ImlPath,
  67. GetLastError()
  68. );
  69. }
  70. Result = ProcessShowIml( pIml );
  71. CloseIml( pIml );
  72. exit( Result );
  73. return Result;
  74. }
  75. int
  76. ProcessShowIml(
  77. PINSTALLATION_MODIFICATION_LOGFILE pIml
  78. )
  79. {
  80. PIML_FILE_RECORD pFile;
  81. PIML_FILE_RECORD_CONTENTS pOldFile;
  82. PIML_FILE_RECORD_CONTENTS pNewFile;
  83. PIML_KEY_RECORD pKey;
  84. PIML_VALUE_RECORD pValue;
  85. PIML_VALUE_RECORD_CONTENTS pOldValue;
  86. PIML_VALUE_RECORD_CONTENTS pNewValue;
  87. PIML_INI_RECORD pIni;
  88. PIML_INISECTION_RECORD pSection;
  89. PIML_INIVARIABLE_RECORD pVariable;
  90. BOOLEAN FileNameShown;
  91. BOOLEAN SectionNameShown;
  92. if (pIml->NumberOfFileRecords > 0) {
  93. printf( "File Modifications:\n" );
  94. pFile = MP( PIML_FILE_RECORD, pIml, pIml->FileRecords );
  95. while (pFile != NULL) {
  96. pOldFile = MP( PIML_FILE_RECORD_CONTENTS, pIml, pFile->OldFile );
  97. pNewFile = MP( PIML_FILE_RECORD_CONTENTS, pIml, pFile->NewFile );
  98. printf( " %ws - ", MP( PWSTR, pIml, pFile->Name ) );
  99. switch( pFile->Action ) {
  100. case CreateNewFile:
  101. printf( "created\n" );
  102. break;
  103. case ModifyOldFile:
  104. printf( "overwritten\n" );
  105. if (pOldFile != NULL) {
  106. printf( " Old size is %u bytes\n", pOldFile->FileSize );
  107. }
  108. break;
  109. case DeleteOldFile:
  110. printf( "deleted\n" );
  111. if (pOldFile != NULL) {
  112. printf( " Old size is %u bytes\n", pOldFile->FileSize );
  113. }
  114. break;
  115. case ModifyFileDateTime:
  116. printf( "date/time modified\n" );
  117. break;
  118. case ModifyFileAttributes:
  119. printf( "attributes modified\n" );
  120. break;
  121. }
  122. pFile = MP( PIML_FILE_RECORD, pIml, pFile->Next );
  123. }
  124. printf( "\n" );
  125. }
  126. if (pIml->NumberOfKeyRecords > 0) {
  127. printf( "Registry Modifications:\n" );
  128. pKey = MP( PIML_KEY_RECORD, pIml, pIml->KeyRecords );
  129. while (pKey != NULL) {
  130. printf( " %ws - ", MP( PWSTR, pIml, pKey->Name ) );
  131. switch( pKey->Action ) {
  132. case CreateNewKey:
  133. printf( "created\n" );
  134. break;
  135. case DeleteOldKey:
  136. printf( "deleted\n" );
  137. break;
  138. case ModifyKeyValues:
  139. printf( "modified\n" );
  140. break;
  141. }
  142. pValue = MP( PIML_VALUE_RECORD, pIml, pKey->Values );
  143. while (pValue != NULL) {
  144. pOldValue = MP( PIML_VALUE_RECORD_CONTENTS, pIml, pValue->OldValue );
  145. pNewValue = MP( PIML_VALUE_RECORD_CONTENTS, pIml, pValue->NewValue );
  146. printf( " %ws - ", MP( PWSTR, pIml, pValue->Name ) );
  147. if (pValue->Action != DeleteOldValue) {
  148. printf( "%s [%x]",
  149. FormatEnumType( 0, ValueDataTypeNames, pNewValue->Type, FALSE ),
  150. pNewValue->Length
  151. );
  152. if (pNewValue->Type == REG_SZ ||
  153. pNewValue->Type == REG_EXPAND_SZ
  154. ) {
  155. printf( " '%ws'", MP( PWSTR, pIml, pNewValue->Data ) );
  156. }
  157. else
  158. if (pNewValue->Type == REG_DWORD) {
  159. printf( " 0x%x", *MP( PULONG, pIml, pNewValue->Data ) );
  160. }
  161. }
  162. if (pValue->Action == CreateNewValue) {
  163. printf( " (created)\n" );
  164. }
  165. else {
  166. if (pValue->Action == DeleteOldValue) {
  167. printf( " (deleted" );
  168. }
  169. else {
  170. printf( " (modified" );
  171. }
  172. printf( " - was %s [%x]",
  173. FormatEnumType( 0, ValueDataTypeNames, pOldValue->Type, FALSE ),
  174. pOldValue->Length
  175. );
  176. if (pOldValue->Type == REG_SZ ||
  177. pOldValue->Type == REG_EXPAND_SZ
  178. ) {
  179. printf( " '%ws'", MP( PWSTR, pIml, pOldValue->Data ) );
  180. }
  181. else
  182. if (pOldValue->Type == REG_DWORD) {
  183. printf( " 0x%x", *MP( PULONG, pIml, pOldValue->Data ) );
  184. }
  185. printf( " )\n" );
  186. }
  187. pValue = MP( PIML_VALUE_RECORD, pIml, pValue->Next );
  188. }
  189. pKey = MP( PIML_KEY_RECORD, pIml, pKey->Next );
  190. }
  191. printf( "\n" );
  192. }
  193. if (pIml->NumberOfIniRecords > 0) {
  194. printf( ".INI File modifications:\n" );
  195. pIni = MP( PIML_INI_RECORD, pIml, pIml->IniRecords );
  196. while (pIni != NULL) {
  197. FileNameShown = FALSE;
  198. pSection = MP( PIML_INISECTION_RECORD, pIml, pIni->Sections );
  199. while (pSection != NULL) {
  200. SectionNameShown = FALSE;
  201. pVariable = MP( PIML_INIVARIABLE_RECORD, pIml, pSection->Variables );
  202. while (pVariable != NULL) {
  203. if (!FileNameShown) {
  204. printf( "%ws", MP( PWSTR, pIml, pIni->Name ) );
  205. if (pIni->Action == CreateNewIniFile) {
  206. printf( " (created)" );
  207. }
  208. printf( "\n" );
  209. FileNameShown = TRUE;
  210. }
  211. if (!SectionNameShown) {
  212. printf( " [%ws]", MP( PWSTR, pIml, pSection->Name ) );
  213. if (pSection->Action == CreateNewSection) {
  214. printf( " (created)" );
  215. }
  216. else
  217. if (pSection->Action == DeleteOldSection) {
  218. printf( " (deleted)" );
  219. }
  220. printf( "\n" );
  221. SectionNameShown = TRUE;
  222. }
  223. printf( " %ws = ", MP( PWSTR, pIml, pVariable->Name ) );
  224. if (pVariable->Action == CreateNewVariable) {
  225. printf( "'%ws' (created)\n", MP( PWSTR, pIml, pVariable->NewValue ) );
  226. }
  227. else
  228. if (pVariable->Action == DeleteOldVariable) {
  229. printf( " (deleted - was '%ws')\n", MP( PWSTR, pIml, pVariable->OldValue ) );
  230. }
  231. else {
  232. printf( "'%ws' (modified - was '%ws')\n",
  233. MP( PWSTR, pIml, pVariable->NewValue ),
  234. MP( PWSTR, pIml, pVariable->OldValue )
  235. );
  236. }
  237. pVariable = MP( PIML_INIVARIABLE_RECORD, pIml, pVariable->Next );
  238. }
  239. pSection = MP( PIML_INISECTION_RECORD, pIml, pSection->Next );
  240. }
  241. if (FileNameShown) {
  242. printf( "\n" );
  243. }
  244. pIni = MP( PIML_INI_RECORD, pIml, pIni->Next );
  245. }
  246. }
  247. return 0;
  248. }