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.

1163 lines
55 KiB

  1. /*++
  2. Copyright (c) 2000-2001 Microsoft Corporation
  3. Module Name:
  4. engine.cpp
  5. Abstract:
  6. The file system dump utility engine.
  7. Author:
  8. Stefan R. Steiner [ssteiner] 02-18-2000
  9. Revision History:
  10. Avinash Pillai [apillai] 07-29-2002 Added options -o:t, -o:y, -o:f and -o:i
  11. --*/
  12. #include "stdafx.h"
  13. #include "direntrs.h"
  14. #include "extattr.h"
  15. #include "engine.h"
  16. static VOID
  17. TimeString(
  18. IN FILETIME *pFileTime,
  19. IN BOOL bAddSecsToTimestamps,
  20. IN BOOL bAddMillisecsToTimestamps,
  21. OUT LPWSTR pwszTimeStr
  22. );
  23. /*++
  24. Routine Description:
  25. Performs the actual dump of the directory or file.
  26. Arguments:
  27. Return Value:
  28. <Enter return values here>
  29. --*/
  30. DWORD
  31. CDumpEngine::PerformDump()
  32. {
  33. //
  34. // Perform the actual dump
  35. //
  36. DWORD dwRet;
  37. //
  38. // Kind of a hack, set the no data string if we want something other than dashes
  39. //
  40. if ( m_pcParams->m_bDumpCommaDelimited )
  41. FsdEaSetNoDataString( L"" );
  42. //
  43. // Volume state manager manages all state about all volumes that are encountered during
  44. // the dump.
  45. //
  46. CFsdVolumeStateManager cFsdVolStateManager( m_pcParams );
  47. //
  48. // Get information about the volume
  49. //
  50. CFsdVolumeState *pcFsdVolState;
  51. dwRet = cFsdVolStateManager.GetVolumeState( m_cwsDirFileSpec, &pcFsdVolState );
  52. assert( dwRet != ERROR_ALREADY_EXISTS );
  53. if ( dwRet != ERROR_SUCCESS )
  54. return dwRet;
  55. if ( m_pcParams->m_bDumpCommaDelimited )
  56. {
  57. if(!m_pcParams->m_bNoShortFileName)
  58. {
  59. if(!m_pcParams->m_bNoFileSystemType)
  60. m_pcParams->DumpPrintAlways( L"File name,Short Name,Creation date,Last modification date,File size,Attr,DACE,SACE,SDCtl,UNamChkS,DStr,DStrSize,DStrChkS,Prop,RPTag,RPSize,RPChkS,EncrChkS,DACLSize,DACLChkS,SACLSize,SACLChkS,NLnk,ObjectId,OIDChkS,FS,Owner Sid,Group Sid" );
  61. else
  62. m_pcParams->DumpPrintAlways( L"File name,Short Name,Creation date,Last modification date,File size,Attr,DACE,SACE,SDCtl,UNamChkS,DStr,DStrSize,DStrChkS,Prop,RPTag,RPSize,RPChkS,EncrChkS,DACLSize,DACLChkS,SACLSize,SACLChkS,NLnk,ObjectId,OIDChkS,Owner Sid,Group Sid" );
  63. }
  64. else
  65. {
  66. if(!m_pcParams->m_bNoFileSystemType)
  67. m_pcParams->DumpPrintAlways( L"File name,Creation date,Last modification date,File size,Attr,DACE,SACE,SDCtl,UNamChkS,DStr,DStrSize,DStrChkS,Prop,RPTag,RPSize,RPChkS,EncrChkS,DACLSize,DACLChkS,SACLSize,SACLChkS,NLnk,ObjectId,OIDChkS,FS,Owner Sid,Group Sid" );
  68. else
  69. m_pcParams->DumpPrintAlways( L"File name,Creation date,Last modification date,File size,Attr,DACE,SACE,SDCtl,UNamChkS,DStr,DStrSize,DStrChkS,Prop,RPTag,RPSize,RPChkS,EncrChkS,DACLSize,DACLChkS,SACLSize,SACLChkS,NLnk,ObjectId,OIDChkS,Owner Sid,Group Sid" );
  70. }
  71. //
  72. // Put the current time into the CSV dump file for easy detection of when
  73. // dumps are taken
  74. //
  75. FILETIME sSysFT, sLocalFT;
  76. ::GetSystemTimeAsFileTime( &sSysFT );
  77. ::FileTimeToLocalFileTime( &sSysFT, &sLocalFT );
  78. WCHAR wszCurrentTime[32];
  79. ::TimeString( &sLocalFT, TRUE, FALSE, wszCurrentTime );
  80. m_pcParams->DumpPrintAlways( L"Dump time: %s", wszCurrentTime );
  81. }
  82. else
  83. {
  84. // if ( ( m_pcParams->m_eFsDumpType == eFsDumpVolume ) &&
  85. // ( m_cwsDirFileSpec != pcFsdVolState->GetVolumePath() ) )
  86. // {
  87. // m_pcParams->ErrPrint( L"'%s' is not a drive specifier or mountpoint, use -dd instead",
  88. // m_cwsDirFileSpec.c_str() );
  89. // return 1;
  90. // }
  91. m_pcParams->DumpPrintAlways( L"\nDumping: '%s' on volume '%s'", m_cwsDirFileSpec.c_str(), pcFsdVolState->GetVolumePath() );
  92. if(!m_pcParams->m_bNoShortFileName)
  93. {
  94. if ( m_pcParams->m_bAddMillisecsToTimestamps )
  95. m_pcParams->DumpPrintAlways(
  96. L" Creation date Last modification date FileSize Attr FileName ShortName DACE SACE SDCtl UNamChkS DStr DStrSize DStrChkS Prop RPTag RPSize RPChkS EncrChkS DACLSize DACLChkS SACLSize SACLChkS NLnk ObjectId OIDChkS OwnerSid/GroupSid" );
  97. else if (m_pcParams->m_bAddSecsToTimestamps)
  98. m_pcParams->DumpPrintAlways( L" Creation date Last mod. date FileSize Attr FileName ShortName DACE SACE SDCtl UNamChkS DStr DStrSize DStrChkS Prop RPTag RPSize RPChkS EncrChkS DACLSize DACLChkS SACLSize SACLChkS NLnk ObjectId OIDChkS OwnerSid/GroupSid" );
  99. else
  100. m_pcParams->DumpPrintAlways( L" Creation date Last mod. date FileSize Attr FileName ShortName DACE SACE SDCtl UNamChkS DStr DStrSize DStrChkS Prop RPTag RPSize RPChkS EncrChkS DACLSize DACLChkS SACLSize SACLChkS NLnk ObjectId OIDChkS OwnerSid/GroupSid" );
  101. }
  102. else
  103. {
  104. if ( m_pcParams->m_bAddMillisecsToTimestamps )
  105. m_pcParams->DumpPrintAlways(
  106. L" Creation date Last modification date FileSize Attr FileName DACE SACE SDCtl UNamChkS DStr DStrSize DStrChkS Prop RPTag RPSize RPChkS EncrChkS DACLSize DACLChkS SACLSize SACLChkS NLnk ObjectId OIDChkS OwnerSid/GroupSid" );
  107. else if (m_pcParams->m_bAddSecsToTimestamps)
  108. m_pcParams->DumpPrintAlways( L" Creation date Last mod. date FileSize Attr FileName DACE SACE SDCtl UNamChkS DStr DStrSize DStrChkS Prop RPTag RPSize RPChkS EncrChkS DACLSize DACLChkS SACLSize SACLChkS NLnk ObjectId OIDChkS OwnerSid/GroupSid" );
  109. else
  110. m_pcParams->DumpPrintAlways( L" Creation date Last mod. date FileSize Attr FileName DACE SACE SDCtl UNamChkS DStr DStrSize DStrChkS Prop RPTag RPSize RPChkS EncrChkS DACLSize DACLChkS SACLSize SACLChkS NLnk ObjectId OIDChkS OwnerSid/GroupSid" );
  111. }
  112. }
  113. ////////////////////////////////////////////////////////////////////
  114. //
  115. // Get the file info for the root dir or file
  116. // Bug # 157915
  117. //
  118. ////////////////////////////////////////////////////////////////////
  119. bool bRootIsADir = true;
  120. CBsString cwsDirFileSpecWithoutSlash( m_cwsDirFileSpec );
  121. if ( cwsDirFileSpecWithoutSlash.Right( 1 ) == L"\\" )
  122. cwsDirFileSpecWithoutSlash = cwsDirFileSpecWithoutSlash.Left( cwsDirFileSpecWithoutSlash.GetLength() - 1 );
  123. try
  124. {
  125. CDirectoryEntries cRootEntry(
  126. m_pcParams,
  127. cwsDirFileSpecWithoutSlash
  128. );
  129. //
  130. // Only one entry should be returned in either the directory list or file list
  131. //
  132. SDirectoryEntry *psDirEntry;
  133. //
  134. // See if it is file entry
  135. //
  136. CDirectoryEntriesIterator *pListIter;
  137. pListIter = cRootEntry.GetFileListIterator();
  138. if ( pListIter->GetNext( psDirEntry ) )
  139. {
  140. bRootIsADir = false;
  141. ++m_ullNumFiles;
  142. m_ullNumBytesTotalUnnamedStream += ( ( ( ULONGLONG )psDirEntry->m_sFindData.nFileSizeHigh ) << 32 ) |
  143. psDirEntry->m_sFindData.nFileSizeLow;
  144. if ( psDirEntry->m_sFindData.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED )
  145. ++m_ullNumEncryptedFiles;
  146. PrintEntry( pcFsdVolState, cwsDirFileSpecWithoutSlash,
  147. cwsDirFileSpecWithoutSlash.GetLength(), psDirEntry, TRUE );
  148. ASSERT( pListIter->GetNext( psDirEntry ) == false );
  149. }
  150. delete pListIter;
  151. //
  152. // See if it is a directory entry
  153. //
  154. pListIter = cRootEntry.GetDirListIterator();
  155. if ( pListIter->GetNext( psDirEntry ) )
  156. {
  157. ASSERT( bRootIsADir );
  158. // It is
  159. ++m_ullNumDirs;
  160. PrintEntry( pcFsdVolState, cwsDirFileSpecWithoutSlash,
  161. cwsDirFileSpecWithoutSlash.GetLength(), psDirEntry, TRUE );
  162. ASSERT( pListIter->GetNext( psDirEntry ) == false );
  163. }
  164. delete pListIter;
  165. }
  166. catch ( DWORD dwRet )
  167. {
  168. if ( dwRet == ERROR_INVALID_NAME || dwRet == ERROR_BAD_NET_NAME )
  169. {
  170. //
  171. // Must be working with the root of the drive letter name space which
  172. // means we do things slightly differently.
  173. //
  174. SDirectoryEntry sDirEntry;
  175. ::memset( &sDirEntry.m_sFindData, 0x00, sizeof( sDirEntry.m_sFindData ) );
  176. PrintEntry( pcFsdVolState, m_cwsDirFileSpec,
  177. m_cwsDirFileSpec.GetLength(), &sDirEntry, TRUE );
  178. }
  179. else
  180. m_pcParams->ErrPrint( L"PerformDump: Unexpected error trying to process '%s', dwRet: %d",
  181. m_cwsDirFileSpec.c_str(), dwRet );
  182. }
  183. catch ( ... )
  184. {
  185. m_pcParams->ErrPrint( L"ProcessDir() Caught an unexpected exception processing file: '%s', Last dwRet: %d",
  186. m_cwsDirFileSpec.c_str(), ::GetLastError() );
  187. }
  188. //
  189. // Now traverse into the volume/directory if necessary
  190. //
  191. if ( m_pcParams->m_eFsDumpType != eFsDumpFile )
  192. {
  193. if ( bRootIsADir )
  194. {
  195. dwRet = ProcessDir(
  196. &cFsdVolStateManager,
  197. pcFsdVolState,
  198. m_cwsDirFileSpec,
  199. m_cwsDirFileSpec.GetLength(),
  200. ::wcslen( pcFsdVolState->GetVolumePath() ) );
  201. }
  202. //
  203. // Print out some stats about the dump
  204. //
  205. m_pcParams->DumpPrint( L"\nSTATISTICS for '%s':", m_cwsDirFileSpec.c_str() );
  206. if ( m_pcParams->m_bHex )
  207. {
  208. m_pcParams->DumpPrint( L" Number of directories (including mountpoints): %16I64x(hex)", m_ullNumDirs );
  209. m_pcParams->DumpPrint( L" Number of files: %16I64x(hex)", m_ullNumFiles );
  210. m_pcParams->DumpPrint( L" Number of mountpoints: %16I64x(hex)", m_ullNumMountpoints );
  211. m_pcParams->DumpPrint( L" Number of reparse points (excluding mountpoints): %16I64x(hex)", m_ullNumReparsePoints );
  212. m_pcParams->DumpPrint( L" Number of hard-linked files: %16I64x(hex)", m_ullNumHardLinks );
  213. m_pcParams->DumpPrint( L" Number of discrete DACL ACEs: %16I64x(hex)", m_ullNumDiscreteDACEs );
  214. m_pcParams->DumpPrint( L" Number of discrete SACL ACEs: %16I64x(hex)", m_ullNumDiscreteSACEs );
  215. m_pcParams->DumpPrint( L" Number of encrypted files: %16I64x(hex)", m_ullNumEncryptedFiles );
  216. m_pcParams->DumpPrint( L" Number of files with object ids: %16I64x(hex)", m_ullNumFilesWithObjectIds );
  217. if ( m_pcParams->m_bUseExcludeProcessor )
  218. m_pcParams->DumpPrint( L" Number of files excluded due to exclusion rules: %16I64x(hex)", m_ullNumFilesExcluded );
  219. m_pcParams->DumpPrint( L" Total bytes of checksummed data: %16I64x(hex)", m_ullNumBytesChecksummed );
  220. m_pcParams->DumpPrint( L" Total bytes of unnamed stream data: %16I64x(hex)", m_ullNumBytesTotalUnnamedStream );
  221. m_pcParams->DumpPrint( L" Total bytes of named data stream data: %16I64x(hex)", m_ullNumBytesTotalNamedDataStream );
  222. }
  223. else
  224. {
  225. m_pcParams->DumpPrint( L" Number of directories (including mountpoints): %16I64u", m_ullNumDirs );
  226. m_pcParams->DumpPrint( L" Number of files: %16I64u", m_ullNumFiles );
  227. m_pcParams->DumpPrint( L" Number of mountpoints: %16I64u", m_ullNumMountpoints );
  228. m_pcParams->DumpPrint( L" Number of reparse points (excluding mountpoints): %16I64u", m_ullNumReparsePoints );
  229. m_pcParams->DumpPrint( L" Number of hard-linked files: %16I64u", m_ullNumHardLinks );
  230. m_pcParams->DumpPrint( L" Number of discrete DACL ACEs: %16I64u", m_ullNumDiscreteDACEs );
  231. m_pcParams->DumpPrint( L" Number of discrete SACL ACEs: %16I64u", m_ullNumDiscreteSACEs );
  232. m_pcParams->DumpPrint( L" Number of encrypted files: %16I64u", m_ullNumEncryptedFiles );
  233. m_pcParams->DumpPrint( L" Number of files with object ids: %16I64u", m_ullNumFilesWithObjectIds );
  234. if ( m_pcParams->m_bUseExcludeProcessor )
  235. m_pcParams->DumpPrint( L" Number of files excluded due to exclusion rules: %16I64u", m_ullNumFilesExcluded );
  236. m_pcParams->DumpPrint( L" Total bytes of checksummed data: %16I64u", m_ullNumBytesChecksummed );
  237. m_pcParams->DumpPrint( L" Total bytes of unnamed stream data: %16I64u", m_ullNumBytesTotalUnnamedStream );
  238. m_pcParams->DumpPrint( L" Total bytes of named data stream data: %16I64u", m_ullNumBytesTotalNamedDataStream );
  239. }
  240. if ( m_pcParams->m_bUseExcludeProcessor )
  241. {
  242. //
  243. // Print out exclusion information
  244. //
  245. cFsdVolStateManager.PrintExclusionInformation();
  246. }
  247. cFsdVolStateManager.PrintHardLinkInfo();
  248. }
  249. return dwRet;
  250. }
  251. /*++
  252. Routine Description:
  253. Traverses into a directory and dumps all the information about the dir.
  254. NOTE: This is a recursive function.
  255. Arguments:
  256. cwsDirPath - The directory path or file to dump information about
  257. Return Value:
  258. <Enter return values here>
  259. --*/
  260. DWORD
  261. CDumpEngine::ProcessDir(
  262. IN CFsdVolumeStateManager *pcFsdVolStateManager,
  263. IN CFsdVolumeState *pcFsdVolState,
  264. IN const CBsString& cwsDirPath,
  265. IN INT cDirFileSpecLength,
  266. IN INT cVolMountPointOffset
  267. )
  268. {
  269. DWORD dwRet = ERROR_SUCCESS;
  270. try
  271. {
  272. if ( !m_pcParams->m_bDumpCommaDelimited )
  273. {
  274. if ( cwsDirPath.GetLength() == cDirFileSpecLength )
  275. {
  276. //
  277. // This is the root of the directory
  278. //
  279. m_pcParams->DumpPrintAlways( L"'.\\' - %s", ( pcFsdVolState != NULL ) ? pcFsdVolState->GetFileSystemName() : L"???" );
  280. }
  281. else
  282. {
  283. m_pcParams->DumpPrintAlways( L"'%s' - %s", cwsDirPath.c_str() + cDirFileSpecLength,
  284. ( pcFsdVolState != NULL ) ? pcFsdVolState->GetFileSystemName() : L"???" );
  285. }
  286. }
  287. //
  288. // Get the directory entries for the directory/file
  289. //
  290. CDirectoryEntries cDirEntries(
  291. m_pcParams,
  292. cwsDirPath + L"*"
  293. );
  294. SDirectoryEntry *psDirEntry;
  295. //
  296. // First dump out the sub-directory entries
  297. //
  298. CDirectoryEntriesIterator *pDirListIter;
  299. pDirListIter = cDirEntries.GetDirListIterator();
  300. while ( pDirListIter->GetNext( psDirEntry ) )
  301. {
  302. ++m_ullNumDirs;
  303. if ( psDirEntry->m_sFindData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT )
  304. {
  305. ++m_ullNumMountpoints;
  306. }
  307. PrintEntry( pcFsdVolState, cwsDirPath, cDirFileSpecLength, psDirEntry );
  308. }
  309. //
  310. // Next dump out the non-sub-directory entries
  311. //
  312. CDirectoryEntriesIterator *pFileListIter;
  313. pFileListIter = cDirEntries.GetFileListIterator();
  314. while ( pFileListIter->GetNext( psDirEntry ) )
  315. {
  316. ++m_ullNumFiles;
  317. m_ullNumBytesTotalUnnamedStream += ( ( ( ULONGLONG )psDirEntry->m_sFindData.nFileSizeHigh ) << 32 ) |
  318. psDirEntry->m_sFindData.nFileSizeLow;
  319. if ( psDirEntry->m_sFindData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT )
  320. ++m_ullNumReparsePoints;
  321. if ( psDirEntry->m_sFindData.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED )
  322. ++m_ullNumEncryptedFiles;
  323. //
  324. // Check to see if we should exclude the file
  325. //
  326. if ( pcFsdVolState->IsExcludedFile( cwsDirPath, cVolMountPointOffset, psDirEntry->GetFileName() ) )
  327. ++m_ullNumFilesExcluded;
  328. else
  329. PrintEntry( pcFsdVolState, cwsDirPath, cDirFileSpecLength, psDirEntry );
  330. }
  331. delete pFileListIter;
  332. if ( m_pcParams->m_eFsDumpType == eFsDumpVolume
  333. || m_pcParams->m_eFsDumpType == eFsDumpDirTraverse )
  334. {
  335. //
  336. // Now traverse into each sub-directory
  337. //
  338. pDirListIter->Reset();
  339. CBsString cwsTraversePath;
  340. while ( pDirListIter->GetNext( psDirEntry ) )
  341. {
  342. if ( m_pcParams->m_bDontTraverseMountpoints
  343. && psDirEntry->m_sFindData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT )
  344. continue;
  345. cwsTraversePath = cwsDirPath + psDirEntry->GetFileName();
  346. cwsTraversePath += L'\\';
  347. //
  348. // Now go into recursion mode
  349. //
  350. if ( psDirEntry->m_sFindData.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT )
  351. {
  352. //
  353. // Traversing into another volume, get it's state
  354. //
  355. CFsdVolumeState *pcNewFsdVolState;
  356. DWORD dwRet;
  357. dwRet = pcFsdVolStateManager->GetVolumeState( cwsTraversePath, &pcNewFsdVolState );
  358. if ( dwRet == ERROR_ALREADY_EXISTS )
  359. {
  360. //
  361. // Mountpoint cycle, stop traversing. Need to print the fully qualified
  362. // path if the traversal mountpoint is the same as the mountpoint
  363. // we started with, otherwise we AV.
  364. //
  365. INT cVolStateSpecLength;
  366. cVolStateSpecLength = ( ::wcslen( pcNewFsdVolState->GetVolumePath() ) <= (size_t)cDirFileSpecLength )
  367. ? 0 : cDirFileSpecLength;
  368. m_pcParams->DumpPrint( L"'%s' - Not traversing, already traversed through '%s' mountpoint",
  369. cwsTraversePath.c_str() + cDirFileSpecLength, pcNewFsdVolState->GetVolumePath() + cVolStateSpecLength );
  370. }
  371. else if ( dwRet == ERROR_SUCCESS )
  372. {
  373. ProcessDir(
  374. pcFsdVolStateManager,
  375. pcNewFsdVolState,
  376. cwsTraversePath,
  377. cDirFileSpecLength,
  378. ::wcslen( pcNewFsdVolState->GetVolumePath() ) );
  379. }
  380. else
  381. {
  382. //
  383. // Error message already printed out
  384. //
  385. }
  386. }
  387. else
  388. {
  389. ProcessDir(
  390. pcFsdVolStateManager,
  391. pcFsdVolState,
  392. cwsTraversePath,
  393. cDirFileSpecLength,
  394. cVolMountPointOffset );
  395. }
  396. }
  397. }
  398. delete pDirListIter;
  399. }
  400. catch ( DWORD dwRet )
  401. {
  402. m_pcParams->ErrPrint( L"ProcessDir: Error trying to process '%s' directory, dwRet: %d", cwsDirPath.c_str(), dwRet );
  403. }
  404. catch ( ... )
  405. {
  406. m_pcParams->ErrPrint( L"ProcessDir() Caught an unexpected exception processing dir: '%s', Last dwRet: %d",
  407. cwsDirPath.c_str(), ::GetLastError() );
  408. }
  409. return 0;
  410. }
  411. //
  412. // printf style format strings which format each line
  413. //
  414. #define DIR_STR L"<DIR>"
  415. #define JUNCTION_STR L"<JUNCTION>"
  416. #define FMT_DIR_STR_HEX L" %s %s %-16s %04x %-32s %-12s %4d %4d %04x -------- %4d %8I64x %s %4d %s %6hx %s %s %8hx %s %8hx %s %4d %36s %s %%s/%s"
  417. #define FMT_DIR_STR_HEX_NO_SFN L" %s %s %-16s %04x %-32s %4d %4d %04x -------- %4d %8I64x %s %4d %s %6hx %s %s %8hx %s %8hx %s %4d %36s %s %%s/%s"
  418. #define FMT_DIR_STR L" %s %s %-16s %04x %-32s %-12s %4d %4d %04x -------- %4d %8I64d %s %4d %s %6hu %s %s %8hd %s %8hd %s %4d %36s %s %s/%s"
  419. #define FMT_DIR_STR_NO_SFN L" %s %s %-16s %04x %-32s %4d %4d %04x -------- %4d %8I64d %s %4d %s %6hu %s %s %8hd %s %8hd %s %4d %36s %s %s/%s"
  420. #define FMT_FILE_STR_HEX L" %s %s %16I64x %04x %-32s %-12s %4d %4d %04x %s %4d %8I64x %s %4d %s %6hx %s %s %8hx %s %8hx %s %4d %36s %s %s/%s"
  421. #define FMT_FILE_STR_HEX_NO_SFN L" %s %s %16I64x %04x %-32s %4d %4d %04x %s %4d %8I64x %s %4d %s %6hx %s %s %8hx %s %8hx %s %4d %36s %s %s/%s"
  422. #define FMT_FILE_STR L" %s %s %16I64d %04x %-32s %-12s %4d %4d %04x %s %4d %8I64d %s %4d %s %6hu %s %s %8hd %s %8hd %s %4d %36s %s %s/%s"
  423. #define FMT_FILE_STR_NO_SFN L" %s %s %16I64d %04x %-32s %4d %4d %04x %s %4d %8I64d %s %4d %s %6hu %s %s %8hd %s %8hd %s %4d %36s %s %s/%s"
  424. #define BLANKTIMESTAMPWITHOUTMS L" "
  425. #define BLANKTIMESTAMPWITHMS L" "
  426. #define BLANKTIMESTAMPWITHOUTS L" "
  427. #define FMT_CSV_DIR_STR L"\"'%s%s\\'\",%s,%s,%s,%s,0x%04x,%d,%d,0x%04x,,%d,%I64d,%s,%d,%s,%hu,%s,%s,%hd,%s,%hd,%s,%d,%s,%s,%s,%s,%s"
  428. #define FMT_CSV_DIR_STR_NO_SFN L"\"'%s%s\\'\",%s,%s,%s,0x%04x,%d,%d,0x%04x,,%d,%I64d,%s,%d,%s,%hu,%s,%s,%hd,%s,%hd,%s,%d,%s,%s,%s,%s,%s" //No Short File Name
  429. #define FMT_CSV_DIR_STR_NO_FST L"\"'%s%s\\'\",%s,%s,%s,%s,0x%04x,%d,%d,0x%04x,,%d,%I64d,%s,%d,%s,%hu,%s,%s,%hd,%s,%hd,%s,%d,%s,%s,%s,%s" //No File System Type
  430. #define FMT_CSV_DIR_STR_NO_SFN_FST L"\"'%s%s\\'\",%s,%s,%s,0x%04x,%d,%d,0x%04x,,%d,%I64d,%s,%d,%s,%hu,%s,%s,%hd,%s,%hd,%s,%d,%s,%s,%s,%s" //No Short File Name and File System Type
  431. #define FMT_CSV_FILE_STR L"\"'%s%s'\",%s,%s,%s,%I64d,0x%04x,%d,%d,0x%04x,%s,%d,%I64d,%s,%d,%s,%hu,%s,%s,%hd,%s,%hd,%s,%d,%s,%s,%s,%s,%s"
  432. #define FMT_CSV_FILE_STR_NO_SFN L"\"'%s%s'\",%s,%s,%I64d,0x%04x,%d,%d,0x%04x,%s,%d,%I64d,%s,%d,%s,%hu,%s,%s,%hd,%s,%hd,%s,%d,%s,%s,%s,%s,%s" //No Short File Name
  433. #define FMT_CSV_FILE_STR_NO_FST L"\"'%s%s'\",%s,%s,%s,%I64d,0x%04x,%d,%d,0x%04x,%s,%d,%I64d,%s,%d,%s,%hu,%s,%s,%hd,%s,%hd,%s,%d,%s,%s,%s,%s" //No File System Type
  434. #define FMT_CSV_FILE_STR_NO_SFN_FST L"\"'%s%s'\",%s,%s,%I64d,0x%04x,%d,%d,0x%04x,%s,%d,%I64d,%s,%d,%s,%hu,%s,%s,%hd,%s,%hd,%s,%d,%s,%s,%s,%s" //No Short File Name and File System Type
  435. /*++
  436. Routine Description:
  437. Prints out all the information about one directory entry.
  438. Arguments:
  439. cwsDirPath - The path leading up to the entry
  440. psDirEntry - The directory entry information
  441. Return Value:
  442. NONE
  443. --*/
  444. VOID
  445. CDumpEngine::PrintEntry(
  446. IN CFsdVolumeState *pcFsdVolState,
  447. IN const CBsString& cwsDirPath,
  448. IN INT cDirFileSpecLength,
  449. IN SDirectoryEntry *psDirEntry,
  450. IN BOOL bSingleEntryOutput
  451. )
  452. {
  453. WIN32_FILE_ATTRIBUTE_DATA *pFD = &psDirEntry->m_sFindData;
  454. LPWSTR pwszFmtStr;
  455. WCHAR wszCreationTime[32];
  456. WCHAR wszLastWriteTime[32];
  457. //
  458. // Get the additional information about the file/dir
  459. //
  460. SFileExtendedInfo sExtendedInfo;
  461. ::GetExtendedFileInfo( m_pcParams, pcFsdVolState, cwsDirPath, bSingleEntryOutput, psDirEntry, &sExtendedInfo );
  462. //
  463. // Convert the timestamps into formatted strings
  464. //
  465. if ( pFD->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
  466. && m_pcParams->m_bDontShowDirectoryTimestamps )
  467. {
  468. if ( m_pcParams->m_bDumpCommaDelimited )
  469. {
  470. wszCreationTime[0] = L'\0';
  471. wszLastWriteTime[0] = L'\0';
  472. }
  473. else if ( m_pcParams->m_bAddMillisecsToTimestamps )
  474. {
  475. ::wcscpy( wszCreationTime, BLANKTIMESTAMPWITHMS );
  476. ::wcscpy( wszLastWriteTime, BLANKTIMESTAMPWITHMS );
  477. }
  478. else if ( m_pcParams->m_bAddSecsToTimestamps)
  479. {
  480. ::wcscpy( wszCreationTime, BLANKTIMESTAMPWITHOUTMS );
  481. ::wcscpy( wszLastWriteTime, BLANKTIMESTAMPWITHOUTMS );
  482. }
  483. else
  484. {
  485. ::wcscpy( wszCreationTime, BLANKTIMESTAMPWITHOUTS );
  486. ::wcscpy( wszLastWriteTime, BLANKTIMESTAMPWITHOUTS );
  487. }
  488. }
  489. else
  490. {
  491. TimeString( &psDirEntry->m_sFindData.ftCreationTime,
  492. m_pcParams->m_bAddSecsToTimestamps,
  493. m_pcParams->m_bAddMillisecsToTimestamps,
  494. wszCreationTime );
  495. TimeString( &psDirEntry->m_sFindData.ftLastWriteTime,
  496. m_pcParams->m_bAddSecsToTimestamps,
  497. m_pcParams->m_bAddMillisecsToTimestamps,
  498. wszLastWriteTime );
  499. }
  500. //
  501. // Mask out the requested file attribute bits
  502. //
  503. pFD->dwFileAttributes &= ~m_pcParams->m_dwFileAttributesMask;
  504. m_ullNumBytesChecksummed += sExtendedInfo.ullTotalBytesChecksummed;
  505. m_ullNumBytesTotalNamedDataStream += sExtendedInfo.ullTotalBytesNamedDataStream;
  506. if ( sExtendedInfo.lNumberOfLinks > 1 )
  507. ++m_ullNumHardLinks;
  508. if ( sExtendedInfo.lNumDACEs != -1 )
  509. m_ullNumDiscreteDACEs += sExtendedInfo.lNumDACEs;
  510. if ( sExtendedInfo.lNumSACEs != -1 )
  511. m_ullNumDiscreteSACEs += sExtendedInfo.lNumSACEs;
  512. if ( !sExtendedInfo.cwsObjectId.IsEmpty() )
  513. ++m_ullNumFilesWithObjectIds;
  514. WCHAR wszReparsePointTag[32];
  515. if ( sExtendedInfo.ulReparsePointTag == 0 )
  516. {
  517. if ( m_pcParams->m_bDumpCommaDelimited )
  518. wszReparsePointTag[0] = L'\0';
  519. else
  520. ::memcpy( wszReparsePointTag, L"--------", sizeof( WCHAR ) * 9 );
  521. }
  522. else
  523. {
  524. wsprintf( wszReparsePointTag, m_pcParams->m_pwszULongHexFmt, sExtendedInfo.ulReparsePointTag );
  525. }
  526. if ( pFD->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
  527. {
  528. LPWSTR pwszDirType;
  529. if ( pFD->dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT )
  530. pwszDirType = JUNCTION_STR;
  531. else
  532. pwszDirType = DIR_STR;
  533. if ( m_pcParams->m_bDumpCommaDelimited )
  534. {
  535. //
  536. // If single file output mode, then processing the root directory
  537. //
  538. if ( bSingleEntryOutput )
  539. psDirEntry->m_cwsFileName = L".";
  540. CBsString cwsFixedShortName;
  541. if ( !psDirEntry->GetShortName().IsEmpty() )
  542. {
  543. cwsFixedShortName = L"\"'" + psDirEntry->GetShortName() + L"'\"";
  544. }
  545. if(!m_pcParams->m_bNoShortFileName && !m_pcParams->m_bNoFileSystemType)
  546. {
  547. m_pcParams->DumpPrintAlways( FMT_CSV_DIR_STR,
  548. cwsDirPath.c_str() + cDirFileSpecLength,
  549. LPCWSTR( psDirEntry->GetFileName() ),
  550. LPCWSTR( cwsFixedShortName ),
  551. wszCreationTime,
  552. wszLastWriteTime,
  553. pwszDirType,
  554. pFD->dwFileAttributes,
  555. sExtendedInfo.lNumDACEs,
  556. sExtendedInfo.lNumSACEs,
  557. sExtendedInfo.wSecurityDescriptorControl,
  558. sExtendedInfo.lNumNamedDataStreams,
  559. sExtendedInfo.ullTotalBytesNamedDataStream,
  560. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  561. sExtendedInfo.lNumPropertyStreams,
  562. wszReparsePointTag,
  563. sExtendedInfo.wReparsePointDataSize,
  564. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  565. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  566. sExtendedInfo.wDACLSize,
  567. sExtendedInfo.cwsDACLChecksum.c_str(),
  568. sExtendedInfo.wSACLSize,
  569. sExtendedInfo.cwsSACLChecksum.c_str(),
  570. sExtendedInfo.lNumberOfLinks,
  571. sExtendedInfo.cwsObjectId.c_str(),
  572. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  573. pcFsdVolState->GetFileSystemName(),
  574. sExtendedInfo.cwsOwnerSid.c_str(),
  575. sExtendedInfo.cwsGroupSid.c_str() );
  576. }
  577. else if(m_pcParams->m_bNoShortFileName && m_pcParams->m_bNoFileSystemType)
  578. {
  579. m_pcParams->DumpPrintAlways( FMT_CSV_DIR_STR_NO_SFN_FST,
  580. cwsDirPath.c_str() + cDirFileSpecLength,
  581. LPCWSTR( psDirEntry->GetFileName() ),
  582. wszCreationTime,
  583. wszLastWriteTime,
  584. pwszDirType,
  585. pFD->dwFileAttributes,
  586. sExtendedInfo.lNumDACEs,
  587. sExtendedInfo.lNumSACEs,
  588. sExtendedInfo.wSecurityDescriptorControl,
  589. sExtendedInfo.lNumNamedDataStreams,
  590. sExtendedInfo.ullTotalBytesNamedDataStream,
  591. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  592. sExtendedInfo.lNumPropertyStreams,
  593. wszReparsePointTag,
  594. sExtendedInfo.wReparsePointDataSize,
  595. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  596. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  597. sExtendedInfo.wDACLSize,
  598. sExtendedInfo.cwsDACLChecksum.c_str(),
  599. sExtendedInfo.wSACLSize,
  600. sExtendedInfo.cwsSACLChecksum.c_str(),
  601. sExtendedInfo.lNumberOfLinks,
  602. sExtendedInfo.cwsObjectId.c_str(),
  603. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  604. sExtendedInfo.cwsOwnerSid.c_str(),
  605. sExtendedInfo.cwsGroupSid.c_str() );
  606. }
  607. else if(m_pcParams->m_bNoShortFileName)
  608. {
  609. m_pcParams->DumpPrintAlways( FMT_CSV_DIR_STR_NO_SFN,
  610. cwsDirPath.c_str() + cDirFileSpecLength,
  611. LPCWSTR( psDirEntry->GetFileName() ),
  612. wszCreationTime,
  613. wszLastWriteTime,
  614. pwszDirType,
  615. pFD->dwFileAttributes,
  616. sExtendedInfo.lNumDACEs,
  617. sExtendedInfo.lNumSACEs,
  618. sExtendedInfo.wSecurityDescriptorControl,
  619. sExtendedInfo.lNumNamedDataStreams,
  620. sExtendedInfo.ullTotalBytesNamedDataStream,
  621. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  622. sExtendedInfo.lNumPropertyStreams,
  623. wszReparsePointTag,
  624. sExtendedInfo.wReparsePointDataSize,
  625. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  626. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  627. sExtendedInfo.wDACLSize,
  628. sExtendedInfo.cwsDACLChecksum.c_str(),
  629. sExtendedInfo.wSACLSize,
  630. sExtendedInfo.cwsSACLChecksum.c_str(),
  631. sExtendedInfo.lNumberOfLinks,
  632. sExtendedInfo.cwsObjectId.c_str(),
  633. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  634. pcFsdVolState->GetFileSystemName(),
  635. sExtendedInfo.cwsOwnerSid.c_str(),
  636. sExtendedInfo.cwsGroupSid.c_str() );
  637. }
  638. else if(m_pcParams->m_bNoFileSystemType)
  639. {
  640. m_pcParams->DumpPrintAlways( FMT_CSV_DIR_STR,
  641. cwsDirPath.c_str() + cDirFileSpecLength,
  642. LPCWSTR( psDirEntry->GetFileName() ),
  643. LPCWSTR( cwsFixedShortName ),
  644. wszCreationTime,
  645. wszLastWriteTime,
  646. pwszDirType,
  647. pFD->dwFileAttributes,
  648. sExtendedInfo.lNumDACEs,
  649. sExtendedInfo.lNumSACEs,
  650. sExtendedInfo.wSecurityDescriptorControl,
  651. sExtendedInfo.lNumNamedDataStreams,
  652. sExtendedInfo.ullTotalBytesNamedDataStream,
  653. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  654. sExtendedInfo.lNumPropertyStreams,
  655. wszReparsePointTag,
  656. sExtendedInfo.wReparsePointDataSize,
  657. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  658. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  659. sExtendedInfo.wDACLSize,
  660. sExtendedInfo.cwsDACLChecksum.c_str(),
  661. sExtendedInfo.wSACLSize,
  662. sExtendedInfo.cwsSACLChecksum.c_str(),
  663. sExtendedInfo.lNumberOfLinks,
  664. sExtendedInfo.cwsObjectId.c_str(),
  665. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  666. sExtendedInfo.cwsOwnerSid.c_str(),
  667. sExtendedInfo.cwsGroupSid.c_str() );
  668. }
  669. }
  670. else
  671. {
  672. //
  673. // If single file output mode, then processing the root directory
  674. //
  675. if ( bSingleEntryOutput )
  676. psDirEntry->m_cwsFileName = L".";
  677. //
  678. // Print with quotes around the file name
  679. //
  680. WCHAR wszNameWithQuotes[ MAX_PATH + 2 ];
  681. wszNameWithQuotes[ 0 ] = L'\'';
  682. ::wcscpy( wszNameWithQuotes + 1, psDirEntry->GetFileName() );
  683. ::wcscat( wszNameWithQuotes, L"\\\'" );
  684. if(!m_pcParams->m_bNoShortFileName)
  685. {
  686. if ( m_pcParams->m_bHex )
  687. pwszFmtStr = FMT_DIR_STR_HEX;
  688. else
  689. pwszFmtStr = FMT_DIR_STR;
  690. m_pcParams->DumpPrintAlways( pwszFmtStr,
  691. wszCreationTime,
  692. wszLastWriteTime,
  693. pwszDirType,
  694. pFD->dwFileAttributes,
  695. wszNameWithQuotes,
  696. LPCWSTR( psDirEntry->GetShortName() ),
  697. sExtendedInfo.lNumDACEs,
  698. sExtendedInfo.lNumSACEs,
  699. sExtendedInfo.wSecurityDescriptorControl,
  700. sExtendedInfo.lNumNamedDataStreams,
  701. sExtendedInfo.ullTotalBytesNamedDataStream,
  702. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  703. sExtendedInfo.lNumPropertyStreams,
  704. wszReparsePointTag,
  705. sExtendedInfo.wReparsePointDataSize,
  706. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  707. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  708. sExtendedInfo.wDACLSize,
  709. sExtendedInfo.cwsDACLChecksum.c_str(),
  710. sExtendedInfo.wSACLSize,
  711. sExtendedInfo.cwsSACLChecksum.c_str(),
  712. sExtendedInfo.lNumberOfLinks,
  713. sExtendedInfo.cwsObjectId.c_str(),
  714. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  715. sExtendedInfo.cwsOwnerSid.c_str(),
  716. sExtendedInfo.cwsGroupSid.c_str() );
  717. }
  718. else
  719. {
  720. if ( m_pcParams->m_bHex )
  721. pwszFmtStr = FMT_DIR_STR_HEX_NO_SFN;
  722. else
  723. pwszFmtStr = FMT_DIR_STR_NO_SFN;
  724. m_pcParams->DumpPrintAlways( pwszFmtStr,
  725. wszCreationTime,
  726. wszLastWriteTime,
  727. pwszDirType,
  728. pFD->dwFileAttributes,
  729. wszNameWithQuotes,
  730. sExtendedInfo.lNumDACEs,
  731. sExtendedInfo.lNumSACEs,
  732. sExtendedInfo.wSecurityDescriptorControl,
  733. sExtendedInfo.lNumNamedDataStreams,
  734. sExtendedInfo.ullTotalBytesNamedDataStream,
  735. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  736. sExtendedInfo.lNumPropertyStreams,
  737. wszReparsePointTag,
  738. sExtendedInfo.wReparsePointDataSize,
  739. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  740. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  741. sExtendedInfo.wDACLSize,
  742. sExtendedInfo.cwsDACLChecksum.c_str(),
  743. sExtendedInfo.wSACLSize,
  744. sExtendedInfo.cwsSACLChecksum.c_str(),
  745. sExtendedInfo.lNumberOfLinks,
  746. sExtendedInfo.cwsObjectId.c_str(),
  747. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  748. sExtendedInfo.cwsOwnerSid.c_str(),
  749. sExtendedInfo.cwsGroupSid.c_str() );
  750. }
  751. }
  752. }
  753. else
  754. {
  755. ULONGLONG ullFileSize = ( ( (ULONGLONG)pFD->nFileSizeHigh ) << 32 ) + pFD->nFileSizeLow;
  756. if ( m_pcParams->m_bDumpCommaDelimited )
  757. {
  758. CBsString cwsFixedShortName;
  759. if ( !psDirEntry->GetShortName().IsEmpty() )
  760. {
  761. cwsFixedShortName = L"\"'" + psDirEntry->GetShortName() + L"'\"";
  762. }
  763. if(!m_pcParams->m_bNoShortFileName && !m_pcParams->m_bNoFileSystemType)
  764. {
  765. m_pcParams->DumpPrintAlways( FMT_CSV_FILE_STR,
  766. cwsDirPath.c_str() + cDirFileSpecLength,
  767. LPCWSTR( psDirEntry->GetFileName() ),
  768. LPCWSTR( cwsFixedShortName ),
  769. wszCreationTime,
  770. wszLastWriteTime,
  771. ullFileSize,
  772. pFD->dwFileAttributes,
  773. sExtendedInfo.lNumDACEs,
  774. sExtendedInfo.lNumSACEs,
  775. sExtendedInfo.wSecurityDescriptorControl,
  776. sExtendedInfo.cwsUnnamedStreamChecksum.c_str(),
  777. sExtendedInfo.lNumNamedDataStreams,
  778. sExtendedInfo.ullTotalBytesNamedDataStream,
  779. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  780. sExtendedInfo.lNumPropertyStreams,
  781. wszReparsePointTag,
  782. sExtendedInfo.wReparsePointDataSize,
  783. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  784. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  785. sExtendedInfo.wDACLSize,
  786. sExtendedInfo.cwsDACLChecksum.c_str(),
  787. sExtendedInfo.wSACLSize,
  788. sExtendedInfo.cwsSACLChecksum.c_str(),
  789. sExtendedInfo.lNumberOfLinks,
  790. sExtendedInfo.cwsObjectId.c_str(),
  791. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  792. pcFsdVolState->GetFileSystemName(),
  793. sExtendedInfo.cwsOwnerSid.c_str(),
  794. sExtendedInfo.cwsGroupSid.c_str() );
  795. }
  796. else if(m_pcParams->m_bNoShortFileName && m_pcParams->m_bNoFileSystemType)
  797. {
  798. m_pcParams->DumpPrintAlways( FMT_CSV_FILE_STR_NO_SFN_FST,
  799. cwsDirPath.c_str() + cDirFileSpecLength,
  800. LPCWSTR( psDirEntry->GetFileName() ),
  801. wszCreationTime,
  802. wszLastWriteTime,
  803. ullFileSize,
  804. pFD->dwFileAttributes,
  805. sExtendedInfo.lNumDACEs,
  806. sExtendedInfo.lNumSACEs,
  807. sExtendedInfo.wSecurityDescriptorControl,
  808. sExtendedInfo.cwsUnnamedStreamChecksum.c_str(),
  809. sExtendedInfo.lNumNamedDataStreams,
  810. sExtendedInfo.ullTotalBytesNamedDataStream,
  811. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  812. sExtendedInfo.lNumPropertyStreams,
  813. wszReparsePointTag,
  814. sExtendedInfo.wReparsePointDataSize,
  815. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  816. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  817. sExtendedInfo.wDACLSize,
  818. sExtendedInfo.cwsDACLChecksum.c_str(),
  819. sExtendedInfo.wSACLSize,
  820. sExtendedInfo.cwsSACLChecksum.c_str(),
  821. sExtendedInfo.lNumberOfLinks,
  822. sExtendedInfo.cwsObjectId.c_str(),
  823. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  824. sExtendedInfo.cwsOwnerSid.c_str(),
  825. sExtendedInfo.cwsGroupSid.c_str() );
  826. }
  827. else if(m_pcParams->m_bNoShortFileName)
  828. {
  829. m_pcParams->DumpPrintAlways( FMT_CSV_FILE_STR_NO_SFN,
  830. cwsDirPath.c_str() + cDirFileSpecLength,
  831. LPCWSTR( psDirEntry->GetFileName() ),
  832. wszCreationTime,
  833. wszLastWriteTime,
  834. ullFileSize,
  835. pFD->dwFileAttributes,
  836. sExtendedInfo.lNumDACEs,
  837. sExtendedInfo.lNumSACEs,
  838. sExtendedInfo.wSecurityDescriptorControl,
  839. sExtendedInfo.cwsUnnamedStreamChecksum.c_str(),
  840. sExtendedInfo.lNumNamedDataStreams,
  841. sExtendedInfo.ullTotalBytesNamedDataStream,
  842. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  843. sExtendedInfo.lNumPropertyStreams,
  844. wszReparsePointTag,
  845. sExtendedInfo.wReparsePointDataSize,
  846. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  847. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  848. sExtendedInfo.wDACLSize,
  849. sExtendedInfo.cwsDACLChecksum.c_str(),
  850. sExtendedInfo.wSACLSize,
  851. sExtendedInfo.cwsSACLChecksum.c_str(),
  852. sExtendedInfo.lNumberOfLinks,
  853. sExtendedInfo.cwsObjectId.c_str(),
  854. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  855. pcFsdVolState->GetFileSystemName(),
  856. sExtendedInfo.cwsOwnerSid.c_str(),
  857. sExtendedInfo.cwsGroupSid.c_str() );
  858. }
  859. else if(m_pcParams->m_bNoFileSystemType)
  860. {
  861. m_pcParams->DumpPrintAlways( FMT_CSV_FILE_STR_NO_FST,
  862. cwsDirPath.c_str() + cDirFileSpecLength,
  863. LPCWSTR( psDirEntry->GetFileName() ),
  864. LPCWSTR( cwsFixedShortName ),
  865. wszCreationTime,
  866. wszLastWriteTime,
  867. ullFileSize,
  868. pFD->dwFileAttributes,
  869. sExtendedInfo.lNumDACEs,
  870. sExtendedInfo.lNumSACEs,
  871. sExtendedInfo.wSecurityDescriptorControl,
  872. sExtendedInfo.cwsUnnamedStreamChecksum.c_str(),
  873. sExtendedInfo.lNumNamedDataStreams,
  874. sExtendedInfo.ullTotalBytesNamedDataStream,
  875. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  876. sExtendedInfo.lNumPropertyStreams,
  877. wszReparsePointTag,
  878. sExtendedInfo.wReparsePointDataSize,
  879. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  880. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  881. sExtendedInfo.wDACLSize,
  882. sExtendedInfo.cwsDACLChecksum.c_str(),
  883. sExtendedInfo.wSACLSize,
  884. sExtendedInfo.cwsSACLChecksum.c_str(),
  885. sExtendedInfo.lNumberOfLinks,
  886. sExtendedInfo.cwsObjectId.c_str(),
  887. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  888. sExtendedInfo.cwsOwnerSid.c_str(),
  889. sExtendedInfo.cwsGroupSid.c_str() );
  890. }
  891. }
  892. else
  893. {
  894. //
  895. // Print with quotes around the file name
  896. //
  897. WCHAR wszNameWithQuotes[ MAX_PATH + 2 ];
  898. wszNameWithQuotes[ 0 ] = L'\'';
  899. ::wcscpy( wszNameWithQuotes + 1, psDirEntry->GetFileName() );
  900. ::wcscat( wszNameWithQuotes, L"\'" );
  901. if(!m_pcParams->m_bNoShortFileName)
  902. {
  903. if ( m_pcParams->m_bHex )
  904. pwszFmtStr = FMT_FILE_STR_HEX;
  905. else
  906. pwszFmtStr = FMT_FILE_STR;
  907. m_pcParams->DumpPrintAlways( pwszFmtStr,
  908. wszCreationTime,
  909. wszLastWriteTime,
  910. ullFileSize,
  911. pFD->dwFileAttributes,
  912. wszNameWithQuotes,
  913. LPCWSTR( psDirEntry->GetShortName() ),
  914. sExtendedInfo.lNumDACEs,
  915. sExtendedInfo.lNumSACEs,
  916. sExtendedInfo.wSecurityDescriptorControl,
  917. sExtendedInfo.cwsUnnamedStreamChecksum.c_str(),
  918. sExtendedInfo.lNumNamedDataStreams,
  919. sExtendedInfo.ullTotalBytesNamedDataStream,
  920. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  921. sExtendedInfo.lNumPropertyStreams,
  922. wszReparsePointTag,
  923. sExtendedInfo.wReparsePointDataSize,
  924. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  925. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  926. sExtendedInfo.wDACLSize,
  927. sExtendedInfo.cwsDACLChecksum.c_str(),
  928. sExtendedInfo.wSACLSize,
  929. sExtendedInfo.cwsSACLChecksum.c_str(),
  930. sExtendedInfo.lNumberOfLinks,
  931. sExtendedInfo.cwsObjectId.c_str(),
  932. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  933. sExtendedInfo.cwsOwnerSid.c_str(),
  934. sExtendedInfo.cwsGroupSid.c_str() );
  935. }
  936. else
  937. {
  938. if ( m_pcParams->m_bHex )
  939. pwszFmtStr = FMT_FILE_STR_HEX_NO_SFN;
  940. else
  941. pwszFmtStr = FMT_FILE_STR_NO_SFN;
  942. m_pcParams->DumpPrintAlways( pwszFmtStr,
  943. wszCreationTime,
  944. wszLastWriteTime,
  945. ullFileSize,
  946. pFD->dwFileAttributes,
  947. wszNameWithQuotes,
  948. sExtendedInfo.lNumDACEs,
  949. sExtendedInfo.lNumSACEs,
  950. sExtendedInfo.wSecurityDescriptorControl,
  951. sExtendedInfo.cwsUnnamedStreamChecksum.c_str(),
  952. sExtendedInfo.lNumNamedDataStreams,
  953. sExtendedInfo.ullTotalBytesNamedDataStream,
  954. sExtendedInfo.cwsNamedDataStreamChecksum.c_str(),
  955. sExtendedInfo.lNumPropertyStreams,
  956. wszReparsePointTag,
  957. sExtendedInfo.wReparsePointDataSize,
  958. sExtendedInfo.cwsReparsePointDataChecksum.c_str(),
  959. sExtendedInfo.cwsEncryptedRawDataChecksum.c_str(),
  960. sExtendedInfo.wDACLSize,
  961. sExtendedInfo.cwsDACLChecksum.c_str(),
  962. sExtendedInfo.wSACLSize,
  963. sExtendedInfo.cwsSACLChecksum.c_str(),
  964. sExtendedInfo.lNumberOfLinks,
  965. sExtendedInfo.cwsObjectId.c_str(),
  966. sExtendedInfo.cwsObjectIdExtendedDataChecksum.c_str(),
  967. sExtendedInfo.cwsOwnerSid.c_str(),
  968. sExtendedInfo.cwsGroupSid.c_str() );
  969. }
  970. }
  971. }
  972. }
  973. /*++
  974. Routine Description:
  975. Formats dates into a common string format.
  976. Arguments:
  977. Return Value:
  978. <Enter return values here>
  979. --*/
  980. static VOID
  981. TimeString(
  982. IN FILETIME *pFileTime,
  983. IN BOOL bAddSecsToTimestamps,
  984. IN BOOL bAddMillisecsToTimestamps,
  985. OUT LPWSTR pwszTimeStr
  986. )
  987. {
  988. SYSTEMTIME szTime;
  989. ::FileTimeToSystemTime( pFileTime, &szTime );
  990. if ( bAddMillisecsToTimestamps )
  991. {
  992. wsprintf( pwszTimeStr,
  993. L"%02d/%02d/%02d %02d:%02d:%02d.%03d",
  994. szTime.wMonth,
  995. szTime.wDay,
  996. szTime.wYear,
  997. szTime.wHour,
  998. szTime.wMinute,
  999. szTime.wSecond,
  1000. szTime.wMilliseconds );
  1001. }
  1002. else if( bAddSecsToTimestamps )
  1003. {
  1004. wsprintf( pwszTimeStr,
  1005. L"%02d/%02d/%02d %02d:%02d:%02d",
  1006. szTime.wMonth,
  1007. szTime.wDay,
  1008. szTime.wYear,
  1009. szTime.wHour,
  1010. szTime.wMinute,
  1011. szTime.wSecond );
  1012. }
  1013. else
  1014. {
  1015. wsprintf( pwszTimeStr,
  1016. L"%02d/%02d/%02d %02d:%02d",
  1017. szTime.wMonth,
  1018. szTime.wDay,
  1019. szTime.wYear,
  1020. szTime.wHour,
  1021. szTime.wMinute );
  1022. }
  1023. }
  1024. LPCSTR
  1025. CDumpEngine::GetHeaderInformation()
  1026. {
  1027. LPSTR pszHeaderInfo =
  1028. "Creation date - Creation date of the file/dir\n"
  1029. "Last mod. date - Last modification date of the file/dir\n"
  1030. "FileSize - Size of the unnamed data stream if a file\n"
  1031. "Attr - File attributes with Archive and Normal bits masked by\n"
  1032. " default (hex)\n"
  1033. "FileName - Name of the file in single quotes\n"
  1034. "ShortName - The classic 8.3 file name. If <->, FileName is in\n"
  1035. " classic format\n"
  1036. "DACE - Number of discretionary ACL entries\n"
  1037. "SACE - Number of system ACL entries\n"
  1038. "SDCtl - Security Descripter control word (hex)\n"
  1039. "UNamChkS - Data checksum of the unnamed data stream (hex)\n"
  1040. "DStr - Number of named data streams\n"
  1041. "DStrSize - Size of all of the named data streams\n"
  1042. "DStrChkS - Data checksum of all named data streams including their\n"
  1043. " names (hex)\n"
  1044. "Prop - Number of property data streams\n"
  1045. "RPTag - Reparse point tag value (hex)\n"
  1046. "RPSize - Size of reparse point data\n"
  1047. "RPChkS - Checksum of the reparse point data (hex)\n"
  1048. "EncrChkS - Raw encrypted data checksum (hex)\n"
  1049. "DACLSize - Size of the complete discretionary ACL\n"
  1050. "DACLChkS - Checksum of the complete discretionary ACL (hex)\n"
  1051. "SACLSize - Size of the complete system ACL\n"
  1052. "SACLChkS - Checksum of the complete system ACL (hex)\n"
  1053. "NLnk - Number of hard links\n"
  1054. "ObjectId - Object Id GUID on the file if it has one\n"
  1055. "OIDChkS - Object Id extended data checksum\n"
  1056. "FS - Type of file system (in CSV format only)\n"
  1057. "OwnerSid/GroupSid - The owner and group sid values\n";
  1058. return pszHeaderInfo;
  1059. }