I tried to write a pedal. I first load the executable image and all its dependent dlls (including kernel32.dll and ntdll.dll) into memory, process the entire import address table, rewrite all the data that needs to be moved.
Then I call the entire EntryPoint image in order. I get return code 0 from ntdll.dll EntryPoint, but kernel32.dll returns 0xC0000000. When I tried to invoke the EntryPoint executable image, the program crashed.
I know that the Windows system already loads the ntdll.dll and kernel32.dll files into the process memory when creating the process. My question is how to load another copy of the ntdll.dll and kernel32.dll file into memory and associate my module with copies.
I am doing an experiment: 1. Copy the ntdll.dll file → a.dll
- copy kernel32.dll → b.dll
- modify the b.dll PE image so that it does not depend on ntdll.dll, but a.dll
- write a simple program a.exe and change the PE-image file a.exe so that it does not depend on kernel32.dll, but b.dll
- run a.exe and the program crashed
Is it possible to execute a.exe correctly?
This is my first stack overflow question, sorry for my poor english. Thanks.
source share