I want to patch an old project what hasn't central european, arab, russian etc. character sheet. The ISO-8859-2; ISO-8859-3 and the others. Only Latin characters.
With this C code I can decrypt the whole code from the program:
#include <stdio.h>
int main() {
FILE *fp;
int c;
// open the current input file
fp = fopen(__FILE__,"r");
do {
c = getc(fp); // read character
putchar(c); // display character
}
while(c != EOF); // loop until the end of file is reached
fclose(fp);
return 0;
}
When I find the corresponding part, then is enough to complete the source code and compile it again? I have found some stuff with good explanation and I think could be work. The main question: Can be a C program patched this way and with this process what I suggested above? Thanks!
CodePudding user response:
This is not an answer: it just gives a rough idea of what you have to do to patch an executable, assuming you know the area to patch.
- Is your patch bigger or smaller than what exists? a) If it is smaller, does the assembler have a no-operation keyword (eg Intel is CC). You can patch in the new code and NOP the rest - that is, if the language has a NOP. What do ou do if the assembler does not have a NOP b) if it is bigger, you need to jump somewhere else, run the patch and then jump back and nop to the end of the code it replaces. You also need to find a place where the patch can be placed. This isn't trivial - a bunch of NOPs, doesn't always mean the area is available - it may be space for local variables in which case you code gets overwritten.
- Very often these records have checksums or CRCs. You need to find out how these are computed and where to patch the new checksum.
- If the new code is a lot larger than the old one, what do you do? There is code, data and all sorts of other things.
- Does the code use absolute or relative addresses - big or little endian. Are there any special things that are handled by the loader, eg maybe $7000 has a special meaning