Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Read Data Write Data (Delphi)[Help]

Featured Replies

Posted

I need to Read data from .exe file for example this is OEP (virtual address) 00000023 I've converted it to physical and now I need to check if data on this address = $55 then WriteFile(H, buf, SizeOf(buf), written, nil);

How to do that? Sorry for my bad English language :(

I need to Read data from .exe file for example this is OEP (virtual address) 00000023 I've converted it to physical and now I need to check if data on this address = $55 then WriteFile(H, buf, SizeOf(buf), written, nil);

How to do that? Sorry for my bad English language :(

Use ReadFile Api, has the same params as WriteFile.

You can read file into memory all at once, or use SetFilePointer api to choose where to read from ..

Also you can use FileStream / MemoryStream Delphi classes, but they are lame and you get much smaller code using apis .. :)

Check if this works for you. Of course, you can modify it to add checks and everything you need...

type
BufferByte = array of Byte;procedure ReadBufferFromFile(PathToMyFile : AnsiString; Offset : Integer; var buf : BufferByte);
var
MyFile : TFileStream; begin
try
MyFile := TFileStream.Create(PathToMyFile,fmOpenRead);
MyFile.Seek(Offset,SoFromBeginning);
MyFile.Read(buf[0],Length(buf));
finally
MyFile.Free;
end;
end;procedure WriteBufferToFile(PathToMyFile : AnsiString; Offset : Integer; var buf : BufferByte);
var
MyFile : TFileStream; begin
try
MyFile := TFileStream.Create(PathToMyFile,fmOpenWrite);
MyFile.Seek(Offset,SoFromBeginning);
MyFile.Write(buf[0],Length(buf));
finally
MyFile.Free;
end;
end;procedure CheckOEPAndFix;
var
Offset : Integer;
PathToMyFile : AnsiString;
bufRead, bufWrite : BufferByte;begin
Offset := $1523; // Example of address of your OEP, it must be offset of a file, not Virtual Address
PathToMyFile := 'C:\Program Files\MyExe.exe'
SetLength(bufRead,1);
ReadBufferFromFile(PathToMyFile,Offset,bufRead);
if bufRead[0] = $55 then
begin
........ // Treatment of your buffer to be written
........
WriteBufferToFile(PathToMyFile,Offset,bufWrite);
end;
end;
  • Author

thanks it works !! :)

but,

 PathToMyFile := 'C:\Program Files\MyExe.exe' <-- here must be ";" this
PathToMyFile := 'C:\Program Files\MyExe.exe';

Nice! Now you can try to find how to improve your techniques, by modifying that code for your needings.

About the missing ';', hehe, when you code this happens for sure! :^

Luckily there are good coompilers warning you about things like that...

Best regards

Nacho_dj

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.