Skip to content
This repository has been archived by the owner on Jul 11, 2020. It is now read-only.

Commit

Permalink
Added additional console output for WaitForSingleObject and GetThread…
Browse files Browse the repository at this point in the history
…ExitCode calls if errors occur. Also added msvcr120.dll to release packages. lua52.dll is dependent on msvcr120.dll. A missing dependency on a machine might prevent the LoadLibrary call in the remote thread from succeeding as it tried to load IEex.dll and its dependencies.
  • Loading branch information
mrfearless committed Sep 12, 2019
1 parent 9a275f3 commit a01e4f1
Show file tree
Hide file tree
Showing 14 changed files with 117 additions and 108 deletions.
128 changes: 72 additions & 56 deletions IEex/IEex.asm
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,13 @@ WinMain PROC USES EBX hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdSh
; Inject IEex.dll into IE game and resume IE game execution
;
; IEex.dll will be loaded by IE game and call its DllEntry procedure
; which will call IEex.dll:IEexInitDll to begin searching for lua
; functions and patching the IE game to redirect a call to IEexLuaInit
;
; call XXXIEgame:luaL_loadstring replaced with call IEex.dll:IEexLuaInit
; which will call IEex.dll:IEexInitDll
;----------------------------------------------------------------------
.IF gConsoleStartedMode == TRUE
Invoke ConsoleText, Addr szStatusEntry
Invoke ConsoleText, Addr szStatusInjectingDLL
Invoke ConsoleText, Addr szCRLF
Invoke ConsoleText, Addr szCRLF
.ENDIF

IFDEF DEBUG32
Expand All @@ -447,48 +445,12 @@ WinMain PROC USES EBX hInst:HINSTANCE, hPrevInst:HINSTANCE, CmdLine:LPSTR, CmdSh
Invoke ResumeThread, pi.hThread

.IF gConsoleStartedMode == TRUE
;------------------------------------------------------------------
; Redirect IE game output to our allocated console
;------------------------------------------------------------------
;mov childconsolesize.x, 80
;mov childconsolesize.y, 1
;Invoke SetConsoleScreenBufferSize, hChildStd_OUT_Rd, Addr childconsolesize
; Invoke ConsoleText, Addr szStatusEntry
; Invoke ConsoleText, Addr szStatusRedirectCon
; Invoke ConsoleText, Addr szCRLF
; Invoke ConsoleText, Addr szCRLF
;
; IFDEF DEBUG32
; PrintText 'ReadFromPipe'
; ENDIF
;
; ;Invoke ReadFromPipe
;
; IFDEF DEBUG32
; PrintText 'Exit From ReadFromPipe'
; ENDIF
Invoke ConsoleText, Addr szCRLF
;Invoke ConsoleSendEnterKey
;Invoke FreeConsole
Invoke CloseHandle, hChildStd_OUT_Rd
Invoke CloseHandle, hChildStd_OUT_Wr
Invoke CloseHandle, hChildStd_IN_Rd
Invoke CloseHandle, hChildStd_IN_Wr
.IF hLogFile != 0
Invoke CloseHandle, hLogFile
.ENDIF
.ENDIF

; IFDEF DEBUG32
; PrintText 'CloseHandle for thread and process'
; ENDIF

;Invoke CloseHandle, pi.hThread
;Invoke CloseHandle, pi.hProcess
.IF dwExitCode != TRUE
ret
.ENDIF
.ELSE ; CreateProcess failed
.IF gConsoleStartedMode == TRUE
Invoke ConsoleText, Addr szErrorEntry
Expand Down Expand Up @@ -577,6 +539,7 @@ InjectDLL PROC hProcess:HANDLE, szDLLPath:DWORD
LOCAL hRemoteThread:DWORD
LOCAL dwRemoteThreadID:DWORD
LOCAL dwExitCode:DWORD
LOCAL ReturnVal:DWORD

Invoke lstrlen, szDLLPath
mov szLibPathSize, eax
Expand Down Expand Up @@ -668,42 +631,95 @@ InjectDLL PROC hProcess:HANDLE, szDLLPath:DWORD
Invoke WaitForSingleObject, hRemoteThread, INFINITE

.IF eax == WAIT_ABANDONED
.IF gConsoleStartedMode == TRUE
Invoke ConsoleText, Addr szErrorEntry
Invoke ConsoleText, Addr szErrorWaitAbandoned
Invoke ConsoleText, Addr szCRLF
.ENDIF
.ELSEIF eax == WAIT_OBJECT_0
; .IF gConsoleStartedMode == TRUE
; Invoke ConsoleText, Addr szStatusEntry
; Invoke ConsoleText, Addr szErrorWaitObject0
; Invoke ConsoleText, Addr szCRLF
; .ENDIF

.ELSEIF eax == WAIT_TIMEOUT
.IF gConsoleStartedMode == TRUE
Invoke ConsoleText, Addr szErrorEntry
Invoke ConsoleText, Addr szErrorWaitTimeout
Invoke ConsoleText, Addr szCRLF
.ENDIF
.ELSEIF eax == WAIT_FAILED
Invoke GetLastError
Invoke DisplayErrorMessage, Addr szErrorWaitSingleObj, eax
mov eax, FALSE
ret
.IF gConsoleStartedMode == TRUE
Invoke ConsoleText, Addr szErrorEntry
Invoke ConsoleText, Addr szErrorWaitFailed
Invoke ConsoleText, Addr szCRLF
.ELSE
Invoke GetLastError
Invoke DisplayErrorMessage, Addr szErrorWaitFailed, eax
.ENDIF
mov ReturnVal, FALSE
jmp InjectDLLExit
.ELSE
Invoke GetLastError
Invoke DisplayErrorMessage, Addr szErrorWaitSingleInv, 0
mov eax, FALSE
ret
mov ReturnVal, FALSE
jmp InjectDLLExit
.ENDIF

Invoke GetExitCodeThread, hRemoteThread, Addr dwExitCode
.IF eax == 0
Invoke GetLastError
Invoke DisplayErrorMessage, Addr szErrorExitCodeThread, 0
mov eax, FALSE
ret
Invoke DisplayErrorMessage, Addr szErrorExitCodeThreadFailed, 0
mov ReturnVal, FALSE
jmp InjectDLLExit
.ELSE
; .IF gConsoleStartedMode == TRUE
; Invoke ConsoleText, Addr szStatusEntry
; Invoke ConsoleText, Addr szErrorExitCodeThreadSuccess
; Invoke ConsoleText, Addr szCRLF
; .ENDIF
.ENDIF

.IF dwExitCode == STILL_ACTIVE
Invoke GetLastError
Invoke DisplayErrorMessage, Addr szErrorThreadActive, 0
mov eax, FALSE
ret
mov eax, dwExitCode
.IF eax == STILL_ACTIVE
.IF gConsoleStartedMode == TRUE
Invoke ConsoleText, Addr szErrorEntry
Invoke ConsoleText, Addr szErrorThreadActive
Invoke ConsoleText, Addr szCRLF
.ELSE
Invoke GetLastError
Invoke DisplayErrorMessage, Addr szErrorThreadActive, 0
.ENDIF
mov ReturnVal, FALSE
.ELSEIF eax == TRUE
.IF gConsoleStartedMode == TRUE
Invoke ConsoleText, Addr szErrorEntry
Invoke ConsoleText, Addr szErrorRemoteThreadExitTrue
Invoke ConsoleText, Addr szCRLF
.ENDIF
mov ReturnVal, TRUE
.ELSEIF eax == FALSE
.IF gConsoleStartedMode == TRUE
Invoke ConsoleText, Addr szErrorEntry
Invoke ConsoleText, Addr szErrorRemoteThreadExitFalse
Invoke ConsoleText, Addr szCRLF
.ENDIF
mov ReturnVal, FALSE
.ENDIF

InjectDLLExit:
Invoke CloseHandle, hRemoteThread
Invoke VirtualFreeEx, hProcess, lpLibAddress, 0, MEM_RELEASE
Invoke CloseHandle, hProcess

mov eax, dwExitCode
mov eax, ReturnVal
ret
InjectDLL endp

Expand Down
Binary file modified IEex/IEex.exe
Binary file not shown.
12 changes: 9 additions & 3 deletions IEex/IEex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ IEEX_ALIGN TEXTEQU <ALIGN 16>
;------------------------------------------------------------------------------
AppName DB "IEex loader",0
szAppName DB "[IEex loader]",0
szAppVersion DB " v1.0.0.7",0
szAppVersion DB " v1.0.0.8",0
szIEexLoaderByfearless DB "IEex loader by fearless: github.com/mrfearless/IEexLoader",0
szIEexByBubb DB "IEex by Bubb: github.com/Bubb13/IEex",0
szCRLF DB 13,10,0
Expand Down Expand Up @@ -116,10 +116,16 @@ szErrorWriteProcessMem DB "InjectDLL: WriteProcessMemory failed. ",0
szErrorGetModuleHandle DB "InjectDLL: GetModuleHandle failed. ",0
szErrorGetProcAddress DB "InjectDLL: GetProcAddress failed. ",0
szErrorRemoteThread DB "InjectDLL: CreateRemoteThread failed. ", 0
szErrorWaitSingleObj DB "InjectDLL: WaitForSingleObject failed. ",0
szErrorWaitAbandoned DB "InjectDLL: WaitForSingleObject abandoned. ",0
szErrorWaitObject0 DB "InjectDLL: WaitForSingleObject success. ",0
szErrorWaitTimeout DB "InjectDLL: WaitForSingleObject timed out. ",0
szErrorWaitFailed DB "InjectDLL: WaitForSingleObject failed. ",0
szErrorWaitSingleInv DB "InjectDLL: WaitForSingleObject returned invalid value. ",0
szErrorExitCodeThread DB "InjectDLL: GetExitCodeThread failed. ",0
szErrorExitCodeThreadFailed DB "InjectDLL: GetExitCodeThread failed. ",0
szErrorExitCodeThreadSuccess DB "InjectDLL: GetExitCodeThread success. ",0
szErrorThreadActive DB "InjectDLL: hRemoteThread still active. ",0
szErrorRemoteThreadExitTrue DB "InjectDLL::CreateRemoteThread::LoadLibrary success. ", 0
szErrorRemoteThreadExitFalse DB "InjectDLL::CreateRemoteThread::LoadLibrary failed. ", 0

szStatusLaunchingIEGame DB "Launching IE game executable: ",0
szStatusInjectingDLL DB "Injecting IEex.dll into IE game executable.",0
Expand Down
40 changes: 20 additions & 20 deletions IEex/IEex.rap
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ Menu=1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0
[VerInf]
Nme=VERINF1
ID=1
FV=1.0.0.7
PV=1.0.0.7
FV=1.0.0.8
PV=1.0.0.8
VerOS=0x00000004
VerFT=0x00000001
VerLNG=0x00000409
VerCHS=0x000004B0
ProductVersion=1.0.0.7
ProductVersion=1.0.0.8
ProductName=IEex.exe
OriginalFilename=IEex.exe
LegalTrademarks=fearless
LegalCopyright=fearless
InternalName=IEex.exe
FileDescription=IEex loader
FileVersion=1.0.0.7
FileVersion=1.0.0.8
CompanyName=fearless
[Group]
Group=Assembly,Resources,Misc
Expand All @@ -82,21 +82,21 @@ Group=Assembly,Resources,Misc
[AutoLoad]
AutoLoad=2,4,5,1
[Find]
1="StartedMode"
2="BEGIN"
3="EEEX_ALIGN"
4="EE"
5="szStatusLaunchingEEGame"
6="szBeamdog_BGEE"
7="szErrorBeamdog_PSTEE"
8="szErrorBeamdog_IWD2EE"
9="szErrorBeamdog_IWDEE"
10="szErrorBeamdog_BG2EE"
1="szStatusInjectingDLL"
2="StartedMode"
3="BEGIN"
4="EEEX_ALIGN"
5="EE"
6="szStatusLaunchingEEGame"
7="szBeamdog_BGEE"
8="szErrorBeamdog_PSTEE"
9="szErrorBeamdog_IWD2EE"
10="szErrorBeamdog_IWDEE"
[Size]
4=0,0,0,0,0
5=0,0,0,0,59
2=0,0,0,0,1433
1=0,0,0,0,17367
5=0,0,0,0,6051
2=0,0,0,0,5121
1=0,0,0,0,16241
[RADebugBP]
2=
1=
Expand All @@ -111,7 +111,7 @@ MilestoneOnTime=2
MilestoneOnDate=0
MilestoneOnDateWhen=1
MilestoneOnDateStatus=0
MilestoneOnDateDate=11
MilestoneOnDateDate=12
MilestoneOnDateTimeYear=2019
MilestoneOnDateTimeMonth=9
MilestoneOnDateTimeDate=1
Expand All @@ -135,10 +135,10 @@ ProductVer2Range=0
ProductVer3Range=0
ProductVer4Range=0
[PTimer]
PTimer=15559771
PTimer=20792248
[Collapse]
2=
1=276824192,,
1=536871040,8,
5=
4=
[GroupExpand]
Expand Down
9 changes: 0 additions & 9 deletions IEex/IEexConsole.asm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ ReadFromPipe PROTO
.DATA
szBackslash DB "\",0

hLogFile DD 0

gConsoleStartedMode DD 0

dwBytesRead DD 0
Expand All @@ -20,9 +18,6 @@ BytesLeftThisMessage DD 0

szLogFile DB MAX_PATH DUP (0)

szParameter1Buffer DB MAX_PATH DUP (0)
CmdLineParameters DB 512 DUP (0)

PIPEBUFFER DB 4096 DUP (0) ;4096 DUP (0) - modified to 1 char as console output was cutting off/lagging until it 'filled' buffer size


Expand Down Expand Up @@ -209,10 +204,6 @@ ReadFromPipe PROC
ret
.ENDIF
.IF hLogFile != 0
Invoke WriteFile, hLogFile, Addr PIPEBUFFER, dwRead, Addr dwWritten, NULL
.ENDIF
Invoke WriteFile, hParentStdOut, Addr PIPEBUFFER, dwRead, Addr dwWritten, NULL
mov bSuccess, eax
.IF bSuccess == FALSE
Expand Down
8 changes: 4 additions & 4 deletions IEex/Res/IEexVer.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define VERINF1 1
VERINF1 VERSIONINFO
FILEVERSION 1,0,0,7
PRODUCTVERSION 1,0,0,7
FILEVERSION 1,0,0,8
PRODUCTVERSION 1,0,0,8
FILEOS 0x00000004
FILETYPE 0x00000001
BEGIN
Expand All @@ -10,14 +10,14 @@ BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "fearless\0"
VALUE "FileVersion", "1.0.0.7\0"
VALUE "FileVersion", "1.0.0.8\0"
VALUE "FileDescription", "IEex loader\0"
VALUE "InternalName", "IEex.exe\0"
VALUE "LegalCopyright", "fearless\0"
VALUE "LegalTrademarks", "fearless\0"
VALUE "OriginalFilename", "IEex.exe\0"
VALUE "ProductName", "IEex.exe\0"
VALUE "ProductVersion", "1.0.0.7\0"
VALUE "ProductVersion", "1.0.0.8\0"
END
END
BLOCK "VarFileInfo"
Expand Down
4 changes: 0 additions & 4 deletions IEexDLL/IEex.asm
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ IEexInitDll PROC USES EBX
Invoke IEexInitGlobals
.IF eax == FALSE
Invoke TerminateProcess, hIEGameProcess, NULL
ret ; error occured - probably lua.dll not found/loaded
.ENDIF
Expand Down Expand Up @@ -154,7 +153,6 @@ IEexInitDll PROC USES EBX
Invoke LogClose
.ENDIF
ENDIF
Invoke TerminateProcess, hIEGameProcess, NULL
ret ; Exit EEexInitDll
.ENDIF
.ELSE ; IMAGE_DOS_SIGNATURE Failed
Expand All @@ -165,7 +163,6 @@ IEexInitDll PROC USES EBX
Invoke LogClose
.ENDIF
ENDIF
Invoke TerminateProcess, hIEGameProcess, NULL
ret ; Exit IEexInitDll
.ENDIF
.ELSE ; GetModuleInformation Failed
Expand All @@ -176,7 +173,6 @@ IEexInitDll PROC USES EBX
Invoke LogClose
.ENDIF
ENDIF
Invoke TerminateProcess, hIEGameProcess, NULL
ret ; Exit IEexInitDll
.ENDIF
;--------------------------------------------------------------------------
Expand Down
Binary file modified IEexDLL/IEex.dll
Binary file not shown.
Loading

0 comments on commit a01e4f1

Please sign in to comment.