Step by step read data from exe file to memory.

This is a discussion on Step by step read data from exe file to memory. within the C++ Programming forums, part of the General Programming Boards category; Hello everyone.
I have exe-file which I want manually map to memory.
I open a file with: HANDLE hFile = ...

Starting at the address given by allocating (VirtualAlloc) memory from the Imagebase at EBX + 8, copy the separate sections to the "new" process memory that has been unmapped. I also noticed that when running from the self executable, I had to make a workaround for a failure in copying the .bss section (which didn't exist).

Also, I would highly suggest giving the reason for what you're doing, because hijacking process memory space is a well-known malware technique, and most people here wouldn't care much to help someone trying to hack. I helped you because I've been there and done that, and I haven't caused and never had the intention to cause harm.