Home > Net >  About c # call CreateThread loading PE file, process directly closed questions. ~ for help
About c # call CreateThread loading PE file, process directly closed questions. ~ for help

Time:10-20

Recently doing, the great god is a such a memory load PE file in c #, get in front of the PE class all goes well, but in the end, access to the program entry address of PE,
Use kernel32. DLL CreateThread incoming program entry pointer, but what's wrong all don't, process will be closed directly, the following code will not perform, the incoming PE file, of course, also have no, really can't find the way, here to consult everybody, loading PE.net key code below
 
IntPtr threadStart=IntPtr. Add (codebase, (int) PE. OptionalHeader64. AOEP);
Console. WriteLine (" threadStart location: "+ threadStart (int));
IntPtr hThread=NativeDeclarations. CreateThread (IntPtr. Zero, Zero, threadStart, IntPtr. Zero, Zero, IntPtr. Zero).
NativeDeclarations. WaitForSingleObject (hThread, 0 XFFFFFFFF);


Then I introduced into c + + exe file, is open a calculator directly used as a test. That's all
 
Void main () {
//insert code here...
WinExec (" calc. Exe, "SW_SHOWMAXIMIZED);
}

Check some data if the program entry address is not correct to hThread return null? I decompiling, execution, and step by step to CreateThread this line of code, directly dropped out, I couldn't see what's wrong, and what is unusual,,
Beginner's development, code has a problem please point out, thank you.
  •  Tags:  
  • C#
  • Related