I am no AutoIt expert, but in .Net, I would attempt to Process.Kill(); Engine.exe before it exits. That would instantly close the process without it saving any data. This is one reason why autoIt is not a good language to be dealing with window APIs and calling DLL functions.
P.S. You realize it only returns 1 if the process no longer EXISTS.
Code:
ProcessWait Close
Pauses script execution until a given process does not exist.
ProcessWait Close ( "process" [, timeout] )
Smart comeback but you realize you didn't do what you mentioned above?
Code:
Func _FREEREMOTEDLL($HMODULE, $PROCESS)
Local $RET, $ERR = 0
Local $HPROCESS = _GETPROCHANDLE($PROCESS)
If Not $HPROCESS Then
$ERR = 7
Else
Local $FREELIBRARY = _GETPROCADDRESS(_WinAPI_GetModuleHandle("kernel32.dll"), "FreeLibrary")
$RET = _CREATEREMOTETHREAD($HPROCESS, $FREELIBRARY, $HMODULE)
If Not $RET Then
$ERR = 12
Else
_WinAPI_WaitForSingleObject($RET)
_WinAPI_CloseHandle($RET)
EndIf
_WinAPI_CloseHandle($HPROCESS)
EndIf
Return SetError($ERR, 0, Number(($ERR = 0)))
EndFunc
Func _GETPROCHANDLE($PROCESS)
Local $HPROCESS = 0
Local $PERMISSION = BitOR(2, 8, 32)
If IsInt($PROCESS) Then
If $PROCESS > 0 Then
Local $RET = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $PROCESS)
If ((Not @error) And $RET[0]) Then
$HPROCESS = $RET[0]
EndIf
EndIf
EndIf
Return SetError(Number(($HPROCESS = 0)), 0, $HPROCESS)
You can never know if "_GETPROCHANDLE" fails, because it even if $PROCESS isn't an int, it still returns 0.
And BTW, the coding scipt for autoIT .dll injection can be found with a click of a button on google, so I don't know if you really did that yourself or not. And considering your style of recording things down and coding, it's very doubtful you did it from scratch. If you had to look at a reference while you coded that thing. That shows you don't know much either.