poison2012, on 02 Sept 2013 - 8:24 PM, said:
you can have the starting address by using either an API such like VirtualQuery or you can do from asm (it's 32 bit code but you can port it to 64bit):
Please Login or Register to see this Hidden Content
you clear the low bytes since memory blocks always starts on aligment for instance if you have 404543h after mask you get 400000h
you may also want to check if 400000h points to "MZ" signature, if not you have to go further by subtracting 10000h until you reach the MZ header.
ps.: you don't need to access segment register as everything is in "flat" mode, one big 4GB memory accesible for you (in 64bit it's even more)
Yes, you are right.
I allready know about the call pop trick to get the address of the code, no problem there.
I'm not trying to get the address of my code (already done), and it doesn't have a PE header so searching for MZ wouldn't work.
And yes you can access any address without using segment registers, but on Windows the fs (32bit) or gs (64bit) registers points to the TEB (Thread Environment Block), I want to trick the system to use different information, but since I seem to be unable to modify the registers, I will atempt to patch the code instead.
So I still don't know how to modify the segment registers, but might have found a workaround.
//DualCoder