madiyaan
December 17th, 2009, 19:06
I have a binary that refers to a text string, for example:
MOV DWORD PTR SS:[ESP], 0x1000000 ; ASCII "Bla"
CALL MY_PRINTF ; Prints whatever was written to ESP before this instruction
MY_PRINTF might print the string whose pointer gets written to the top of stack (this is just a made up example)
I want to change this so that it prints a much longer string (say, "Hello World"
. The problem is that the bytes of "Bla" are located in relocatable segment of the executable and are immediately followed by another constant string that I don't want to trample over.
Basically I want to add a custom (perhaps long) text string to the constant section of the binary and add the address of that to the instruction before printf. The address should be such that when the loader patches the exe after relocating the text section, it should grab the correct value.
Can anyone help me with this? I haven't been able to find an online resource/tutorial that describes adding a new text (I know how to change instructions or add NOPs, etc., but don't know how to add relocatable strings to the binary).
Thanks in advance,
MOV DWORD PTR SS:[ESP], 0x1000000 ; ASCII "Bla"
CALL MY_PRINTF ; Prints whatever was written to ESP before this instruction
MY_PRINTF might print the string whose pointer gets written to the top of stack (this is just a made up example)
I want to change this so that it prints a much longer string (say, "Hello World"

Basically I want to add a custom (perhaps long) text string to the constant section of the binary and add the address of that to the instruction before printf. The address should be such that when the loader patches the exe after relocating the text section, it should grab the correct value.
Can anyone help me with this? I haven't been able to find an online resource/tutorial that describes adding a new text (I know how to change instructions or add NOPs, etc., but don't know how to add relocatable strings to the binary).
Thanks in advance,