77#include < LineReader.h>
88#include < Utility.h>
99
10- static volatile void const * g_pCopyByte;
10+ volatile void const * g_pCopyByte;
11+ volatile bool g_breakOnFound = true ;
12+ volatile bool g_breakOnOther = true ;
1113
1214struct UnmapViewOfFile_delete
1315{
@@ -281,6 +283,10 @@ CheckListFile(
281283 knownGoodPath.c_str (),
282284 localHr);
283285 hr = localHr;
286+ if (g_breakOnOther)
287+ {
288+ __debugbreak ();
289+ }
284290 continue ;
285291 }
286292
@@ -290,6 +296,10 @@ CheckListFile(
290296 filename,
291297 knownGoodFile.Size ,
292298 copyFile.Size );
299+ if (g_breakOnOther)
300+ {
301+ __debugbreak ();
302+ }
293303 continue ;
294304 }
295305
@@ -309,8 +319,12 @@ CheckListFile(
309319 offset,
310320 *pKnownGoodByte,
311321 *pCopyByte,
312- pCopyByte );
322+ g_pCopyByte );
313323 foundMismatch = true ;
324+ if (g_breakOnFound)
325+ {
326+ __debugbreak ();
327+ }
314328 }
315329 }
316330
@@ -319,6 +333,10 @@ CheckListFile(
319333 LogWarning (listFileName, lineReader.LineNumber (),
320334 " Hash mismatch but content matches for file '%ls' ???" ,
321335 filename);
336+ if (g_breakOnOther)
337+ {
338+ __debugbreak ();
339+ }
322340 }
323341 }
324342
@@ -349,14 +367,43 @@ wmain(int argc, _In_count_(argc) PWSTR argv[])
349367
350368 try
351369 {
352- if (argc != 4 )
370+ if (argc != 6 )
353371 {
354- fprintf (stderr, " Usage: %ls ListFile.txt KnownGoodDir CopyDir\n " , argv[0 ]);
372+ fprintf (stderr, R"(
373+ Usage: %ls ListFile.txt KnownGoodDir CopyDir BreakOnFound BreakOnOther
374+
375+ Operation:
376+
377+ - Reads the ListFile.txt, which should contain lines of the form:
378+ <Hex MurMur3 expected hash value> <whitespace> <filename>
379+ - For each line, computes the MurMur3 hash of the file with the given name
380+ under CopyDir and compares it to the expected hash value.
381+ - If the hash value does not match, compares the file to the file with the
382+ same name under KnownGoodDir.
383+ - Logs the address(es) of the difference(s).
384+ - If BreakOnFound is nonzero, DebugBreak() when an address of a difference
385+ is found.
386+ - If BreakOnOther is nonzero, DebugBreak() when any other difference is
387+ found, e.g. if the known-good file cannot be opened, if a size difference
388+ is found, or if no differences are found despite a hash mismatch.
389+ )" , argv[0 ]);
355390 hr = 1 ;
356391 goto Done;
357392 }
358393
359394 auto const hashListFileName = argv[1 ];
395+ auto const pKnownGoodDir = argv[2 ];
396+ auto const pCopyDir = argv[3 ];
397+ g_breakOnFound = _wtoi (argv[4 ]) != 0 ;
398+ g_breakOnOther = _wtoi (argv[5 ]) != 0 ;
399+
400+ fprintf (stderr, " BreakOnFound=%u, BreakOnOther=%u, ListFile=%ls, KnownGoodDir=%ls, CopyDir=%ls\n " ,
401+ g_breakOnFound,
402+ g_breakOnOther,
403+ hashListFileName,
404+ pKnownGoodDir,
405+ pCopyDir);
406+
360407 auto const hashListFile = FopenTextInputWithLogging (hashListFileName);
361408 if (!hashListFile)
362409 {
@@ -367,8 +414,8 @@ wmain(int argc, _In_count_(argc) PWSTR argv[])
367414 hr = CheckListFile (
368415 hashListFileName,
369416 hashListFile.get (),
370- argv[ 2 ] ,
371- argv[ 3 ] );
417+ pKnownGoodDir ,
418+ pCopyDir );
372419 }
373420 catch (HrException const & ex)
374421 {
0 commit comments