CreateProcess的难题!Api高手进来!关于错误捕获。(200分)

  • 主题发起人 主题发起人 hyawind
  • 开始时间 开始时间
H

hyawind

Unregistered / Unconfirmed
GUEST, unregistred user!
当我在程序A中使用CreateProcess运行另一个进程B的时候,如果进程B本身有问题(例如除零错误),Windows就会谈出窗口来报错(地址xxxxxxx错误)。我们知道程序A中如果处理这些问题可以用try..except。 那么怎么捕获掉程序B中的错误呢? (让他不弹出Windows错误窗口) 我目前找不到相应参数,难题! 200分!
 
应该是hStdError这个句柄吧
 
用getlasterror吧
 
可以在调用CreateProcess的时候指定为debug方式,这样就可以调试捕捉子进程的异常,就如脱壳机一般
 
try<br> &nbsp; &nbsp;if not CreateProcess(nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; PChar(fExePath),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Security,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; @Security,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; True,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; NORMAL_PRIORITY_CLASS,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nil,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; start,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ProcessInfo) then RaiseLastWin32Error; //抛出错误<br> &nbsp;except<br> &nbsp; &nbsp;on e:Exception do<br> &nbsp; &nbsp;begin<br> &nbsp; &nbsp;end;<br> &nbsp;end;
 

Similar threads

后退
顶部