Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: MD5 checksums for wbfs backups - master listing [please contribute]

  1. #11
    New Member
    Join Date
    Feb 2013
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mauifrog View Post
    Best way to verify a dump is with
    WIT: Wiimms ISO Tools

    Just do
    wit verify game.iso -vvv
    or
    wit verify game.wbfs -vvv
    or
    wit verify -r hdd:\wbfs\ -vvv
    It will check the hash in the game's tmd with the content, if it is bad it will let you know.
    I know of these tools, but was completely unaware that a checksum hash was stored in the Wii game image.

    Curious- what does TMD stand for? [nevermind, found it - Title Meta Data]

    Is there a tool to read that hash from TMD and dump it?

    So I ran it and output looks to confirm its a good image. It looks like from output that it scans several sections to verify this. So it looks like there are multiple hash checksums in the file or is it just a single one in the header that represents the whole image?

    Y:\wbfs\MarioKartWii [RMCE01]>wit verify RMCE01.wbfs -vvv

    wit: Wiimms ISO Tool v2.10a r4118 cygwin - Dirk Clemens - 2012-10-10

    1 object scanned, 1 supported file found.
    >scan .0 UPDATE RMCE01 RMCE01.wbfs/#0
    >info TICKET & TMD are well signed. Partition is encrypted.
    +OK .0 UPDATE RMCE01 RMCE01.wbfs/#0
    >scan .1 DATA RMCE01 RMCE01.wbfs/#0
    >info TICKET & TMD are well signed. Partition is encrypted and scr
    ubbed.
    +OK .1 DATA RMCE01 RMCE01.wbfs/#0
    >scan .2 CHANNEL RMCE01 RMCE01.wbfs/#0
    >info TICKET & TMD are well signed. Partition is encrypted.
    +OK .2 CHANNEL RMCE01 RMCE01.wbfs/#0

    UPDATE:

    With a little googleFu, I found this command. But I can't read much of it. Be nice to see a tool that just dumps the title-id, SHA-1 hash, etc in plain text.]
    Looks as if there are 3 parts to the ISO update, data, and channel. Not sure if its always just 3 of them in eash ISO/WBFS

    Code:
    Y:\wbfs\MarioKartWii [RMCE01]>wit dump RMCE01.wbfs --show TMD
    
    Dump of file RMCE01.wbfs/#0
    
      Partition table #0, partition #0, type 1 [UPDATE]:
        TMD:
          Issuer:            Root-CA00000001-CP00000004
          Signature type:        10001/hex =      65537  [RSA-2048, size=256, OK]
          Version:                   0
          CA version:                0
          Signer version:            0
          System version:    00000001 00000004 = IOS 0x04 = IOS 4
          Title ID:          00010000 00555045 = '.....UPE'
          Title type:               1/hex =          1
          Group ID:                 3/hex =          3
          Access rights:            0/hex =          0
          Title version:            a/hex =         10
          Boot index:               0/hex =          0
          N(content):               1/hex =          1
          Content #0, ID:           6/hex =          6
          Content #0, index:        0/hex =          0
          Content #0, type:         3/hex =          3
          Content #0, size:   a5e8000/hex =  173965312
          Content #0, hash:  b56c9c8a fec8c60a 2e7828a0 c6b2d45c 69e7d76a
          Relevant SHA1:     b45399de 1f12939a 973035e0 68242804 13a67eb8
    
      Partition table #0, partition #1, type 0 [DATA]:
        TMD:
          Issuer:            Root-CA00000001-CP00000004
          Signature type:        10001/hex =      65537  [RSA-2048, size=256, OK]
          Version:                   0
          CA version:                0
          Signer version:            0
          System version:    00000001 00000024 = IOS 0x24 = IOS 36
          Title ID:          00010004 524d4345 = '....RMCE'
          Title type:               1/hex =          1
          Group ID:              3031/hex =      12337
          Access rights:            0/hex =          0
          Title version:            0/hex =          0
          Boot index:               0/hex =          0
          N(content):               1/hex =          1
          Content #0, ID:           0/hex =          0
          Content #0, index:        0/hex =          0
          Content #0, type:         3/hex =          3
          Content #0, size:  fdba8000/hex = 4256858112
          Content #0, hash:  bce17ccd 7b83679a 9dd502f8 ee6f0a17 f49c174a
          Relevant SHA1:     95a85fab 57e6d018 58c4b381 132de4ae dcc3b9f3
    
      Partition table #0, partition #2, type 2 [CHANNEL]:
        TMD:
          Issuer:            Root-CA00000001-CP00000004
          Signature type:        10001/hex =      65537  [RSA-2048, size=256, OK]
          Version:                   0
          CA version:                0
          Signer version:            0
          System version:    00000001 00000021 = IOS 0x21 = IOS 33
          Title ID:          00010000 00494e53 = '.....INS'
          Title type:               1/hex =          1
          Group ID:              3031/hex =      12337
          Access rights:            0/hex =          0
          Title version:            0/hex =          0
          Boot index:               0/hex =          0
          N(content):               1/hex =          1
          Content #0, ID:           0/hex =          0
          Content #0, index:        0/hex =          0
          Content #0, type:         3/hex =          3
          Content #0, size:   1c20000/hex =   29491200
          Content #0, hash:  66d3c1bb 5c02b51e 218431a7 fe0556d1 ea3d801a
          Relevant SHA1:     a69fd880 82c2d668 3d14e80b f1b8a975 ce578430
    Last edited by matrixman1013; 02-02-2013 at 05:50 PM.

  2. #12
    Senior Member
    WiiHacks Staff
    Forum Administrator
    Dr. House @ Wiihacks
    Only Site Donators Can PM Staff
    nightstah's Avatar
    Join Date
    Nov 2009
    Location
    Repatriated to WH
    Posts
    18,754
    Thanks
    1,900
    Thanked 4,404 Times in 3,693 Posts
    Blog Entries
    5
    It should be noted I have moved this thread to what is likely more topical section (this really isn't "Game Playing Issues For Some Specific Backups Softmods" relevant). Left one day auto-expiring redirect.

  3. #13
    New Member
    Join Date
    Feb 2013
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by nightstah View Post
    It should be noted I have moved this thread to what is likely more topical section (this really isn't "Game Playing Issues For Some Specific Backups Softmods" relevant). Left one day auto-expiring redirect.
    Agreed, perhaps there is a better place for it. Where did it end up?

    I had just thought should people have issues with game they could at least first eliminate that its a bad iso and then go from there.

    I still am utterly confused why the same game would give different MD5 hashes. They should all be the same.

  4. #14
    Senior Member
    WiiHacks Staff
    Forum Administrator
    Dr. House @ Wiihacks
    Only Site Donators Can PM Staff
    nightstah's Avatar
    Join Date
    Nov 2009
    Location
    Repatriated to WH
    Posts
    18,754
    Thanks
    1,900
    Thanked 4,404 Times in 3,693 Posts
    Blog Entries
    5
    "Creating, Burning, and Dumping Tools" (obviously the last is what I associate this with).

  5. #15
    Senior Member
    DA KINE WiiHacker
    mauifrog's Avatar
    Join Date
    May 2009
    Posts
    9,191
    Thanks
    307
    Thanked 9,585 Times in 2,974 Posts
    Blog Entries
    15
    Quote Originally Posted by matrixman1013 View Post

    I still am utterly confused why the same game would give different MD5 hashes. They should all be the same.
    Depending on how the game is dumped, it can be a 1:1 rip with the update, data, and in games like MK channel partitions. In many cases, only the data partition is dump as this is all that is typically needed. That would give different hash values for the iso as a whole, but the data partition would be the same and should pass a wit verify.
    Ipsa scientia potestas est.


    Warning: Piracy is NOT supported. Word your questions carefully.

  6. #16
    New Member
    Join Date
    Feb 2013
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by mauifrog View Post
    Depending on how the game is dumped, it can be a 1:1 rip with the update, data, and in games like MK channel partitions. In many cases, only the data partition is dump as this is all that is typically needed. That would give different hash values for the iso as a whole, but the data partition would be the same and should pass a wit verify.
    A few questions:

    1. Can I ask is wit verify fullproof, that is, if it identifies all sections as OK, then the image must be valid and exact copy of disc data that wit verified?

    2. So based on what you said, if MD5's of rips are compared and have been done by same method (USB GX Loader) then would it be correct to say they would always match?

    3. I am a programmer and wondering how hard would it be to write a program to grab the SHA-1 value and game ID from the TMD. Is there an API or code someone has for parsing the TMD header of the ISO/WBFS? Are most dol apps written in C code or is their a good resource thread on programming for the Wii.



    BTW, thanks for your excellent AIO Homebrew guide, it was a pleasure to follow.

  7. #17
    Senior Member
    DA KINE WiiHacker
    mauifrog's Avatar
    Join Date
    May 2009
    Posts
    9,191
    Thanks
    307
    Thanked 9,585 Times in 2,974 Posts
    Blog Entries
    15
    Quote Originally Posted by matrixman1013 View Post
    A few questions:

    1. Can I ask is wit verify fullproof, that is, if it identifies all sections as OK, then the image must be valid and exact copy of disc data that wit verified?

    2. So based on what you said, if MD5's of rips are compared and have been done by same method (USB GX Loader) then would it be correct to say they would always match?

    3. I am a programmer and wondering how hard would it be to write a program to grab the SHA-1 value and game ID from the TMD. Is there an API or code someone has for parsing the TMD header of the ISO/WBFS? Are most dol apps written in C code or is their a good resource thread on programming for the Wii.



    BTW, thanks for your excellent AIO Homebrew guide, it was a pleasure to follow.
    1. Wit checks the hash values in the tmd. AFAIK, each file in the partition has a hash, then the how thing is officially signed by nintendo. So if you wit verify and it says all is good, then the dump is good. This would be the same check the wii does before loading the disc from the disc channel, if it is not valid it will not load. Now you could have a modified disc, in which wit would tell you it was fakesigned but the partition would still be good as the hash is modified when fakesigning. I think wit verify is very full proof on an unmodified iso, if it is fakesigned and modified I don't know.

    2. Yes they should be the same assuming the disc that it was dumped from was the same. However it is possible that several release versions of game disc may exist with some differences. So that may not always be true.

    3. I don't know much on this, but here is a starting point. Making homebrew - WiiBrew
    Ipsa scientia potestas est.


    Warning: Piracy is NOT supported. Word your questions carefully.

  8. #18
    New Member
    Join Date
    Feb 2013
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I decided wit verify was way to go to verify my backups on USB drive (kudos to mauifrog for the tip).

    So I wanted to contribute here a windows script I wrote that goes thru all the files in ones wbfs folder and outputs the wit verify results to a single file in a nice format.
    I intend on making the changes as indicated in the TODO section. Any feedback or improvement/suggestions are welcome. Hoping someone other then me finds this useful.

    UPDATE:
    ok after all that effort I discover the recurse option and thus the main goal of this script can be achieved via the below example command line. However, if I add some of the TODO items to this script, I still think it could add some value. Your thoughts?

    Example command line to scan all wbfs files in a folder:
    wit verify -vvv --recurse Y:\wbfs2
    This vbs script is best run using cscript to hide command windows during execution. So from command window you would type cscript and then the name of the script.
    See comments in code and make sure to change the values in the "CHANGE ME" section accordingly to your setup and drive mapping.

    The script [verify_wbfs.vbs]:
    Code:
    Option Explicit
    Dim strFolderToSearch, objFSO, objRootFolder, objFolder, colSubfolders, strOutput, strStdOut, witcmd
    Dim WshShell, objScriptExec, gamelist, gameLine, gameItem, witvercmd, gamefolder
    Dim outputFileStream, outputFile
    
    'save this file as something like this - verify_wbfs.vbs and run with script from windows command prompt
    'Example - cscript verify_wbfs.vbs
    
    'This program will perform a wit verify on all wbfs game files and send output results to file
    'Credits to Dirk Clemens creators of Wiimms ISO Tool and to stackoverflow.com for programming info
    
    
    'TODO-FIX
    ' force cscript execution
    ' add timestamp to out file
    ' add option to scan only files added in last ## of days
    ' scan wit output for bad check result and compile list to display at script end of bad files
    ' output sha-1 or md5 checksum for each file
    
    ' ********** CHANGE ME *****************
    'set this to location of your wbfs game files
    strFolderToSearch = "w:\wbfs\"
    'set this to location and filename you want for the verify results
    outputFile = strFolderToSearch & "witVerify-output.txt"
    '**************************************
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objRootFolder = objFSO.GetFolder(strFolderToSearch)
    Set colSubfolders = objRootFolder.SubFolders
    
    Set outputFileStream = objFSO.CreateTextFile(outputFile,True)
    
    Set WshShell = CreateObject("WScript.Shell")
    For Each objFolder in colSubfolders
         gamefolder = objFolder.name
         'get list of wbfs files in game folder
         witcmd = "dir " & chr(34) & strFolderToSearch & gamefolder & "\*.wbf*" & chr(34) & "/b /o-n"
         runCommandNoOutput witcmd
    
         outputFileStream.Write(vbCrLf & "*********************************************************" & vbCrLf)
         outputFileStream.Write(gamefolder & " (" & FormatSize(objFolder.size) & ")" & " - begin verify" & vbCrLf)
    
         gamelist = Split(strStdOut, vbCrLf)
         For Each gameLine in gamelist
            gameItem = strFolderToSearch & gamefolder & "\" & gameLine
            If Len(gameLine) > 0 then
              'Msgbox gameItem
              runWitVerify gameItem
            End If
         Next
         Set gamelist = Nothing
    Next
    
    'cleanup and close
    Set WshShell = Nothing
    outputFileStream.Close
    
    Sub runWitVerify(strParm)
       'clear stdout in prep for wit results only
       Set strStdOut = Nothing
       witvercmd = "wit verify " & chr(34) & strParm & chr(34) & " -vvv"
       'Msgbox witvercmd
       runCommand witvercmd
       Set witvercmd = Nothing
    End Sub
    
    
    Sub runCommand(strCommand)
            'redirect StdErr to StdOut using the POSIX standard 2>&1
            Set objScriptExec = WshShell.Exec("cmd /c " &  strCommand  & " 2>&1")
            'TODO - ReadAll could block and hang if cmd process writes more then 4K to stdout
            'Should not be issue since output from wit verify on wbfs file is small and we clear buffer after each
            strStdOut = objScriptExec.StdOut.ReadAll
            'capture stdOut to file
            outputFileStream.Write(strStdOut)
            'Msgbox strStdOut
            Set objScriptExec = Nothing
    End Sub
    
    
    Sub runCommandNoOutput(strCommand)
            'redirect StdErr to StdOut using the POSIX standard 2>&1
            Set objScriptExec = WshShell.Exec("cmd /c " &  strCommand  & " 2>&1")
            'TODO - ReadAll could block and hang if cmd process writes more then 4K to stdout
            'Should not be issue since output from wit verify on wbfs file is small and we clear buffer after each
            strStdOut = objScriptExec.StdOut.ReadAll
            'Msgbox strStdOut
            Set objScriptExec = Nothing
    End Sub
    
    Public Function FormatSize(ByVal Bytes)
       Dim currval, countdiv, buildstr 
       Dim lookupprefix()
        
       ReDim LookupPrefix(8)
       LookupPrefix(0) = " Bytes"
       LookupPrefix(1) = "KB"
       LookupPrefix(2) = "MB"
       LookupPrefix(3) = "GB"
       LookupPrefix(4) = "TB"
       LookupPrefix(5) = "PB"
       LookupPrefix(6) = "EB"
       LookupPrefix(7) = "ZB"
       LookupPrefix(8) = "YB"
    
       currval = Bytes
       Do Until currval < 1024
           currval = currval / 1024
           countdiv = countdiv + 1
       Loop
    
       buildstr = Trim(FormatNumber(Round(currval, 2)))
       buildstr = buildstr + " " + Lookupprefix(countdiv)
       FormatSize = buildstr
    End Function
    Example of Output:

    Looks like my Thrillville did not backup well and is corrupt.
    Or its possible wit verify cannot handle split files, I will try to get a non-split file of it to verify and post back results.

    Code:
    *********************************************************
    Cars 2 [SCYE4Q] (1.97 GB) - begin verify
    
    wit: Wiimms ISO Tool v2.10a r4118 cygwin - Dirk Clemens - 2012-10-10
    
    1 object scanned, 1 supported file found ... 
    1 object scanned, 1 supported file found.   
    >scan   .0  DATA    SCYE4Q /cygdrive/y/wbfs2/Cars 2 [SCYE4Q]/SCYE4Q.wbfs/#0
    >info               TICKET & TMD are well signed. Partition is encrypted and scrubbed.
    +OK     .0  DATA    SCYE4Q /cygdrive/y/wbfs2/Cars 2 [SCYE4Q]/SCYE4Q.wbfs/#0
    
    *********************************************************
    Pirates vs Ninjas Dodgeball [R5JES5] (278.00 MB) - begin verify
    
    wit: Wiimms ISO Tool v2.10a r4118 cygwin - Dirk Clemens - 2012-10-10
    
    1 object scanned, 1 supported file found ... 
    1 object scanned, 1 supported file found.   
    >scan   .0  DATA    R5JES5 /cygdrive/y/wbfs2/Pirates vs Ninjas Dodgeball [R5JES5]/R5JES5.wbfs/#0
    >info               TICKET & TMD are well signed. Partition is encrypted and scrubbed.
    +OK     .0  DATA    R5JES5 /cygdrive/y/wbfs2/Pirates vs Ninjas Dodgeball [R5JES5]/R5JES5.wbfs/#0
    
    *********************************************************
    Super Fruit Fall [RF4E36] (66.00 MB) - begin verify
    
    wit: Wiimms ISO Tool v2.10a r4118 cygwin - Dirk Clemens - 2012-10-10
    
    1 object scanned, 1 supported file found ... 
    1 object scanned, 1 supported file found.   
    >scan   .0  DATA    RF4E36 /cygdrive/y/wbfs2/Super Fruit Fall [RF4E36]/RF4E36.wbfs/#0
    >info               TICKET & TMD are well signed. Partition is encrypted and scrubbed.
    +OK     .0  DATA    RF4E36 /cygdrive/y/wbfs2/Super Fruit Fall [RF4E36]/RF4E36.wbfs/#0
    
    *********************************************************
    SUPER PAPER MARIO [R8PE01] (408.00 MB) - begin verify
    
    wit: Wiimms ISO Tool v2.10a r4118 cygwin - Dirk Clemens - 2012-10-10
    
    1 object scanned, 1 supported file found ... 
    1 object scanned, 1 supported file found.   
    >scan   .0  DATA    R8PE01 /cygdrive/y/wbfs2/SUPER PAPER MARIO [R8PE01]/R8PE01.wbfs/#0
    >info               TICKET & TMD are well signed. Partition is encrypted and scrubbed.
    +OK     .0  DATA    R8PE01 /cygdrive/y/wbfs2/SUPER PAPER MARIO [R8PE01]/R8PE01.wbfs/#0
    
    *********************************************************
    Thrillville2 [RTVE64] (4.11 GB) - begin verify
    
    wit: Wiimms ISO Tool v2.10a r4118 cygwin - Dirk Clemens - 2012-10-10
    
    1 object scanned, 1 supported file found ... 
    1 object scanned, 1 supported file found.   
    >scan   .0  DATA    RTVE64 /cygdrive/y/wbfs2/Thrillville2 [RTVE64]/RTVE64.wbfs/#0
    >info               TICKET & TMD are well signed. Partition is encrypted.
    !H1-ERR .0  DATA    RTVE64 /cygdrive/y/wbfs2/Thrillville2 [RTVE64]/RTVE64.wbfs/#0
    !H1-ERR .0  DATA    RTVE64 /cygdrive/y/wbfs2/Thrillville2 [RTVE64]/RTVE64.wbfs/#0
    !H1-ERR .0  DATA    RTVE64 /cygdrive/y/wbfs2/Thrillville2 [RTVE64]/RTVE64.wbfs/#0
    !H1-ERR .0  DATA    RTVE64 /cygdrive/y/wbfs2/Thrillville2 [RTVE64]/RTVE64.wbfs/#0
    wit: Command 'VERIFY' returns with status #1 [FILES DIFFER]
    
    wit: Wiimms ISO Tool v2.10a r4118 cygwin - Dirk Clemens - 2012-10-10
    
    !! wit: ERROR #28 [WRONG FILE TYPE] in SourceIteratorHelper() @ src/lib-sf.c#5918
    !!      GameCube or Wii ISO image expected: /cygdrive/y/wbfs2/Thrillville2
    !!      [RTVE64]/RTVE64.wbf1
    1 object scanned.   
    ! wit: No valid source file found.
    wit: Command 'VERIFY' returns with status #2 [NOTHING TO DO]
    Last edited by matrixman1013; 02-07-2013 at 03:02 AM.

  9. #19
    New Member
    Join Date
    Feb 2013
    Posts
    20
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Here is updated version of the script. This does add some useful functionality beyond just using wit tool itself from command line.
    Hope everyone finds it useful.

    Script: verify_wbfs.vbs:

    Code:
    'Script: verify_wbfs.vbs
    'Author: matrixman1013
    'Date: 2/8/2013
    
    Option Explicit
    Dim argCount, strFolderToSearch, objFSO, objRootFolder, objFolder, colSubfolders, strOutput, strStdOut, witcmd
    Dim WshShell, objScriptExec, gamelist, gameLine, gameItem, witvercmd, gamefolder, gamesize
    Dim outputFileStream, outputFile, gamefolder_fq, bad_count, bad_filelist, start_time, x, outputFilename
    Dim scan_days, folder_pattern, foundMatchFolder, foundMatchDate, scandaysprint, folderDateDiff
    
    '**************************************************************
    ' Comments Section
    '
    'save this file as something like this - verify_wbfs.vbs and run with cscript from windows command prompt
    'Example - cscript verify_wbfs.vbs
    '
    'This program will perform a wit verify on all wbfs game files and send output results to file
    'Features: 
    '           - ability to limit game folder verify to select game folder name pattern
    '           - ability to verify files created within specific # of days  
    '           - prints summary at end that includes list of identified bad/corrupt game backups
    '
    'Credits to Dirk Clemens creators of Wiimms ISO Tool and to stackoverflow.com for programming info
    '
    'TODO-FIX
    ' check if folder arg exists
    ' force cscript execution
    '**************************************************************
    
    'record start time
    start_time = Now
    
    'test for command line usage prompt
    argCount = WScript.Arguments.Count
    If (argCount < 1) then
      displayUsagePrompt
      WScript.Quit
    End If
    If (argCount = 1) then
      If (WScript.Arguments.Item(0) = "help") Or (WScript.Arguments.Item(0) = "?") then
        displayUsagePrompt
        WScript.Quit
      End If
    End If
    
    'grab cmdline args and set output filename
    strFolderToSearch = WScript.Arguments.Item(0) & "\"
    outputFilename = FilenameTimestamped("witVerify-output")
    outputFile = strFolderToSearch & outputFilename
    
    'determine if days option arg is provided, if not scan all files
    'I think a default of more than 100 years should cover shelf life of Wii for scan all files
    scan_days = 99999
    If (argCount > 1) then
      If IsNumeric(WScript.Arguments.Item(1)) then scan_days = WScript.Arguments.Item(1)
    End If
    
    'determine if file pattern is provided, if not use default
    folder_pattern = "*"
    If argCount = 3 then
      folder_pattern = WScript.Arguments.Item(2)
    End If
    If (argCount = 2) then
      If Not IsNumeric(WScript.Arguments.Item(1)) then
        folder_pattern = WScript.Arguments.Item(1)
      End If
    End If
    
    
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objRootFolder = objFSO.GetFolder(strFolderToSearch)
    Set colSubfolders = objRootFolder.SubFolders
    
    Set outputFileStream = objFSO.CreateTextFile(outputFile,True)
    
    Set WshShell = CreateObject("WScript.Shell")
    x = 0
    For Each objFolder in colSubfolders
        foundMatchDate = 0
        foundMatchFolder = 0
        folderDateDiff = CLng(DateDiff("d", objFolder.DateCreated, Now))
        gamefolder = objFolder.name
        If CLng(scan_days) >= folderDateDiff then
           foundMatchDate = 1
        End If
        If folder_pattern = "*" then 
           foundMatchFolder = 1
        End If
        If Not (folder_pattern = "*") then 
           If Instr(1, gamefolder, folder_pattern, 1) > 0 then 
              foundMatchFolder = 1
           End If
        End If
        If (foundMatchFolder=1) And (foundMatchDate=1) then
            x = x + 1
            gamesize = FormatSize(objFolder.size)
            outputFileStream.Write(vbCrLf & "*********************************************************" & vbCrLf)
            outputFileStream.Write(gamefolder & " (" & gamesize & " " & objFolder.DateCreated & ")" & " - begin verify" & vbCrLf)
            gamefolder_fq = strFolderToSearch & gamefolder
            runWitVerify gamefolder_fq
        End If
    Next
    
    'write summary to output file
    scandaysprint = scan_days
    If scan_days = 99999 then scandaysprint = "ALL"
    outputFileStream.Write(vbCrLf & vbCrLf & "*********************************************************" & vbCrLf)
    outputFileStream.Write("VERIFY SUMMARY:" & vbCrLf)
    outputFileStream.Write(vbCrLf & "Criteria: " & "folder_pattern=" & folder_pattern & ", scan_days=" & scandaysprint)
    outputFileStream.Write(vbCrLf & "Start Time: " & start_time)
    outputFileStream.Write(vbCrLf & "End Time: " & Now)
    outputFileStream.Write(vbCrLf & "Games Verified: " & x)
    outputFileStream.Write(vbCrLf & vbCrLf & "Bad Files Identified: " & vbCrLf)
    If Len(bad_filelist) > 0 then
      outputFileStream.Write(vbCrLf & bad_filelist)
    Else
      outputFileStream.Write(vbCrLf & "No bad found, all games verified good.")
    End If
    
    'cleanup and close
    Set WshShell = Nothing
    outputFileStream.Close
    
    Sub runWitVerify(strParm)
       'clear stdout in prep for wit results only
       Set strStdOut = Nothing
       witvercmd = "wit verify " & chr(34) & strParm & chr(34) & " -vvv"
       'Msgbox witvercmd
       runCommand witvercmd
       Set witvercmd = Nothing
    End Sub
    
    
    Sub runCommand(strCommand)
            'redirect StdErr to StdOut using the POSIX standard 2>&1
            Set objScriptExec = WshShell.Exec("cmd /c " &  strCommand  & " 2>&1")
            'TODO - ReadAll could block and hang if cmd process writes more then 4K to stdout
            'Should not be issue since output from wit verify on wbfs file is small and we clear buffer after each
            strStdOut = objScriptExec.StdOut.ReadAll
            'check for corrupted game backup
            bad_count = Instr(strStdOut, "H1-ERR")
            If bad_count > 0 then
               bad_filelist = bad_filelist & gamefolder & " (" & gamesize & ")" & vbCrLf
            End If
            'capture stdOut to output file
            outputFileStream.Write(strStdOut)
            'Msgbox strStdOut
            Set objScriptExec = Nothing
    End Sub
    
    
    Sub runCommandNoOutput(strCommand)
            'redirect StdErr to StdOut using the POSIX standard 2>&1
            Set objScriptExec = WshShell.Exec("cmd /c " &  strCommand  & " 2>&1")
            'TODO - ReadAll could block and hang if cmd process writes more then 4K to stdout
            'Should not be issue since output from wit verify on wbfs file is small and we clear buffer after each
            strStdOut = objScriptExec.StdOut.ReadAll
            'Msgbox strStdOut
            Set objScriptExec = Nothing
    End Sub
    
    Sub displayUsagePrompt
      WScript.Echo "usage: "
      WScript.Echo "  verify_wbfs.vbs [path] [optional: # of days in past, 0 for today] [optional: folder pattern]"
      WScript.Echo " "
      WScript.Echo "Examples:"
      WScript.Echo "verify_wbfs.vbs w:\wbfs (verify all files)"
      WScript.Echo "verify_wbfs.vbs w:\wbfs 10 (verify files created in last 10 days)"
      WScript.Echo "verify_wbfs.vbs w:\wbfs 0 (verify files created only today)"
      WScript.Echo "verify_wbfs.vbs w:\wbfs 0 sonic (verify files created only today and game folder name contains sonic)"
      WScript.Echo "verify_wbfs.vbs w:\wbfs sonic (verify all files where game folder name contains sonic)"
    End Sub
    
    Public Function FormatSize(ByVal Bytes)
       Dim currval, countdiv, buildstr 
       Dim lookupprefix()
        
       ReDim LookupPrefix(8)
       LookupPrefix(0) = " Bytes"
       LookupPrefix(1) = "KB"
       LookupPrefix(2) = "MB"
       LookupPrefix(3) = "GB"
       LookupPrefix(4) = "TB"
       LookupPrefix(5) = "PB"
       LookupPrefix(6) = "EB"
       LookupPrefix(7) = "ZB"
       LookupPrefix(8) = "YB"
    
       currval = Bytes
       Do Until currval < 1024
           currval = currval / 1024
           countdiv = countdiv + 1
       Loop
    
       buildstr = Trim(FormatNumber(Round(currval, 2)))
       buildstr = buildstr + " " + Lookupprefix(countdiv)
       FormatSize = buildstr
    End Function
    
    
    Public Function FilenameTimestamped(filename)
       Dim strSafeDate, strSafeTime, strDateTime
      
       strSafeDate = DatePart("yyyy",Date) & Right("0" & DatePart("m",Date), 2) & Right("0" & DatePart("d",Date), 2)
    
       strSafeTime = Right("0" & Hour(Now), 2) & Right("0" & Minute(Now), 2) & Right("0" & Second(Now), 2)
    
       'Set strDateTime equal to a string representation of the current date and time, for use as part of a valid Windows filename
       strDateTime = strSafeDate & "-" & strSafeTime
    
       'Assemble the path and filename
       FilenameTimestamped = filename & "_" & strDateTime & ".txt"
    End Function
    Last edited by matrixman1013; 02-08-2013 at 12:44 PM.

  10. #20
    Junior Member dniMretsaM's Avatar
    Join Date
    May 2010
    Location
    NE Ohio
    Posts
    1,142
    Thanks
    76
    Thanked 331 Times in 269 Posts
    Here's a quick shell script that does the same thing. I ran it on Ubuntu, but it should work on most UNIX systems I believe:
    Code:
    #!/bin/sh
    
    find $@ -name "*.wbf*" | while read GAME
    do
        echo "*********************************************************
    $GAME -- begin verify"
        wit verify -vvv "$GAME"
    done
    echo "********************************************************"
    Usage: wit_script.sh [/path/to/WBFS/]

    If you don't put a path, it just searches from the working directory.
    Last edited by dniMretsaM; 02-08-2013 at 02:39 PM.
    Quote Originally Posted by sven
    [16:26:34] i'm never sarcastic.
    [16:26:41] feel free to quote me on that.

Page 2 of 3 FirstFirst 123 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •