Patch several bytes in an external file


Question

I'd like to patch several bytes in an external file. How can I do that?

Answer

Assuming that bytes' values to be used to patch together with offsets are stored in a table named tblBytesToPatch and using the function from topic "Patch byte in an external file" you can write the following function to solve the problem of patching an external file:

Public Function PatchFile()
    Dim dbs As Database
    Dim rst As Recordset
    Dim strFilePath As String
    Dim strSql As String
    
    Set dbs = CodeDb()
    
    strSql = "select * from [tblBytesToPatch]"
    strFilePath = "c:\daisytst\libraries\smslib.mdb"
    Set rst = dbs.OpenRecordset(strSql, dbOpenDynaset)
    While Not rst.EOF
        PatchByte strtFilePath, rst![Offset], rst![ByteValue]
        rst.MoveNext
    Wend
End Function

Copyright 1999-2008 by Shamil Salakhetdinov. All rights reserved.