1

I am trying to replace a file's contents. The file is a huge binary file (500 MB).

I need to change some of bytes in it with my Inno Setup script.

How can I do it?

Here is the screenshot of my file's hex code that I want to change.

Here is the files:

enter image description here

I want to make the right side file just like the one on the left side.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • It's not clear to me, what change do you want to. How do you identify bytes (not lines, contrary to your question title) that you want to modify? – Martin Prikryl Nov 15 '18 at 06:44
  • I have 2 same files. For example; A.xxx B.xxx But A.xxx's some HEX codes are changed. (minor HEX changes on some offsets.) I need to apply this changes to B.xxx with my inno setup installation file. So A.xxx and B.xxx should be exactly same after the process. –  Nov 15 '18 at 11:50
  • So why don't you overwrite `B.xxx` with `A.xxx`? – Martin Prikryl Nov 15 '18 at 12:19
  • Because A.xxx is 500 mb and B.xxx is already on other computer. So if i will put A.xxx in my setup file, my setup file will be 502 megabytes. –  Nov 15 '18 at 16:06
  • OK, so you want to replace those about 400 bytes starting at offset 217F6DF1, leaving the rest of file as it is, right? OK, those are all pretty important information, that you should edit into your question. Particularly the size of the file limits possible solutions significantly. – Martin Prikryl Nov 15 '18 at 16:10

1 Answers1

0

Start here: Writing binary file in Inno Setup.

And you need to do two changes:

  • Open an existing file for writing, instead of creating a new one:

    Stream := TFileStream.Create(FileName, fmOpenReadWrite);
    
  • Seek to the desired position before writing the data:

    Stream.Seek($217F6DF1, soFromBeginning)
    Stream.WriteBuffer(Buffer, Size);
    
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992