rsts wrote:When you set *searchdata = "hello" you're attempting to set the string "hello" as a memory address, thus the error.
setting *searchdata = @"hello" sets the memorypointer *searchdata to the location in memory of the string "hello" or @(the memory location of)"hello"
cheers
Oh okay, so if i set *searchdata = @"hello", it jumps to the first position in the memory block containing that string?
BTW, I tested this and it went very slowly and ultimately did not change anything in the file.
Code: Select all
Procedure.s AsciiToHex(binData$)
tdata$ = Space(Len(binData$)*2)
BinToHex(@binData$,Len(binData$),@tdata$,#False)
ProcedureReturn tdata$
EndProcedure
Procedure.s HexToAscii(hexdata$)
hdata$ = Space(Len(hexdata$))
HexToBin(@hexdata$,Len(hexdata$),@hdata$)
ProcedureReturn hdata$
EndProcedure
length = 7 ; or whatever it is
*searchdata = AllocateMemory(length)
*replacedata = AllocateMemory(length)
*testdata = AllocateMemory(length)
;///////////////////////////////////////////////////////////
*searchdata = @HexToAscii("F606017415538D")
*replacedata = @HexToAscii("8026007415538D")
MessageRequester("","get here?",#MB_OK)
;///////////////////////////////////////////////////////////
If OpenFile(0, "test.dll")
readpos = 0
thiseof = Lof(0) - length
While (Not Eof(0)) And readpos <= thiseof
FileSeek(0, readpos)
ReadData(0, *testdata, length)
If CompareMemory(*testdata, *searchdata, length)
WriteData(readpos, *replacedata, length)
EndIf
readpos + 1
Wend
CloseFile(0)
EndIf
Any ideas? I'm sure the search string (in hex) is in the file.

Procrastinators unite... tomorrow!