dlpb Advanced Cheater Reputation: 0
Joined: 11 Dec 2013 Posts: 71
|
Posted: Fri Dec 23, 2016 8:22 pm Post subject: Best Way to overwrite partial section of file using resource |
|
|
Code: |
R := TResourceStream.Create(HInstance, 'LaunchDat', RT_RCDATA);
TRY
RPoint:= R.memory;
if Modlist.Text <> '***' then
Inc(RPoint, $425F0);
LauncherFS.Position:= 0;
LauncherFs.WriteBuffer(RPoint^, $425F0)
FINALLY
R.Free;
END; |
I am using Delphi 7. This is how I am doing it. "LauncherFS" opens an executable file for writing [not shown above]. Different sets of bytes will be written depending if "Modlist.text" = *** or not. I noticed that the buffer in Writebuffer can accept a pointer to the data - and that TResourceStream returns the address to the embedded data using .memory.
Is this the best way of doing this?
I could have used external binary file with the needed changes, but chose to place it inside the project exe.
See what I am thinking is, the resource data (in this case a binary file) is in the project exe regardless of if I use "R.create". So question is if it's possible to find the address of that data without using R.Create / .memory ?
|
|