flat assembler
Message board for the users of flat assembler.
Index
> Windows > Simple compare and patch generator+patch programme |
Author |
|
bzdashek 08 Apr 2012, 21:00
Good evening,
While experimenting with assembler, I ran into a problem of comparing two files of equal size. The "original" and "patched" version. I wrote two simple programmes in order to do that: 1. fcompare - compares 2 files and writes the result to the *.fcp file. 2. fcp - opens the *.fcp file, searches for original programme with human help, and then turns it magically into fixed version. I reused the error reporting technique that Tomasz used in FA.asm and some code regarding file operations from fasm\TOOLS\WIN32\SYSTEM.INC. Structure of *.fcp file: Code: 4 bytes - signature 2 bytes - file version 2 bytes - number of entries 4 bytes - original file size 2 bytes - file name length 1..260 bytes - target filename --- end of header --- ;1 entry 4 bytes - offset from the start of file 1 byte - original byte 1 byte - patched byte .... ;n-th entry 4 bytes - offset from the start of file 1 byte - original byte 1 byte - patched byte --- end of file --- Size of Entry - 6 bytes Maximum number of entries in *.fcp file is 65536. Hence, maximum *.fcp file size is 14 + (1..260) + 65536*6 = 393230..393489 bytes. The limit for size of patched file to compare is 100 Mb. Programme reads the whole two files into memory, that might be bad practice, I did consider using 64k blocks for compare procedure, but I was lazy to implement it. I tested it on number of files, but I might have missed some bugs, so it would be wonderful if you could report bugs in this thread. Or you can fix them yourself. I'm attaching full sources. I know I'm not the first to write such thing, but I want to hope that it will be useful for the ASM society. Thanks for your attention.
Last edited by bzdashek on 09 Apr 2012, 08:39; edited 1 time in total |
|||||||||||
08 Apr 2012, 21:00 |
|
typedef 08 Apr 2012, 21:38
One way also is to use the hashing technique.
|
|||
08 Apr 2012, 21:38 |
|
shutdownall 08 Apr 2012, 23:51
I would sell this program to Microsoft. For the next patch day.
|
|||
08 Apr 2012, 23:51 |
|
bzdashek 14 Apr 2012, 21:48
This is the standalone patch generator. You compile it specifying a file include directive @ patch_data label (see source). After that patch file is included in exe. You can distribute it afterwards, for example.
At first I tried to combine them with copy /b, but when programme starts, windows loads just what is specified in the header of EXE file. I was lazy to dig the PE specification.
|
|||||||||||
14 Apr 2012, 21:48 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.