I have a file (binary, from a game) and I would like to replace some part inside - easy.... no
Code: Select all
tbl = {["a"] = $58,["c"] = $68,["e"]= $78,["g"] = $88,["h"]= $90,["k"] = $A8,["n"]= $C0,["t"] = $F0,["u"]= $F8,[" "]= $4E,["_"]= $47}
OpenFile(1,"org_bidat")
Local size=FileSize("org_bidat")
Local data$=ReadBytes(1,size)
Local s$="kann gut tau_chen"
Local hexChain=""
For Local i=0 To StrLen(s$)-1
Local idx=MidStr(s$,i,1)
hexChain=hexChain..hexstr(tbl[idx]).." "
Next
Local pos=FindStr(data$,sR,True,0,#ENCODING_RAW)
DebugPrint(hexChain)
DebugPrint(pos)
CloseFile(1)
It means that my string was not found (-1)$A8 $58 $C0 $C0 $4E $88 $F8 $F0 $4E $F0 $58 $F8 $47 $68 $90 $78 $C0
-1
But that string really exists in the file:
Later I realized that #ENCODING_RAW in following line
Code: Select all
Local pos=FindStr(data$,sR,True,0,#ENCODING_RAW)
So now I know why nothing was found - it is not looking for my original string anymore.$A8 $58 $C0 $C0 $4E $88 $F8 $F0 $4E $F0 $58 $F8 $47 $68 $90 $78 $C0
$E8 $58 $C0 $C0 $4E $C8 $F8 $F0 $4E $F0 $58 $F8 $47 $68 $D0 $78 $C0
But when I remove #ENCODING_RAW I get error :
How to find that string????Error in line 75 (test.hws): Invalid UTF-8 string in argument 1!
Please!!! Help!!!