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

Commit

Permalink
Tidy up EEex.exe loader by removing command line parameter for log fi…
Browse files Browse the repository at this point in the history
…le - this is handled in EEex.dll now.

Added a check to verify if EE game executable is 32bit or 64bit and to display an error message if 64bit is detected (which would require a 64bit version of EEex.exe loader and 64bit version of EEex.dll)
  • Loading branch information
mrfearless committed Sep 9, 2019
1 parent 74e82d8 commit 84b203b
Show file tree
Hide file tree
Showing 13 changed files with 297 additions and 342 deletions.
380 changes: 203 additions & 177 deletions EEex/EEex.asm

Large diffs are not rendered by default.

Binary file modified EEex/EEex.exe
Binary file not shown.
49 changes: 45 additions & 4 deletions EEex/EEex.inc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ includelib version.lib
;------------------------------------------------------------------------------
; EEex Prototypes
;------------------------------------------------------------------------------
ProcessCmdLine PROTO
WinMain PROTO :DWORD, :DWORD, :DWORD, :DWORD
EnumWindowsProc PROTO :DWORD, :DWORD
CheckFileVersion PROTO :DWORD, :DWORD
InjectDLL PROTO :DWORD, :DWORD

DisplayErrorMessage PROTO :DWORD, :DWORD
LogMessage PROTO :DWORD
IsEEGame64bit PROTO :DWORD


IFNDEF LANGANDCODEPAGE
Expand All @@ -35,16 +33,53 @@ LANGANDCODEPAGE STRUCT
LANGANDCODEPAGE ENDS
ENDIF

IFNDEF IMAGE_DOS_HEADER
IMAGE_DOS_HEADER STRUCT
e_magic WORD ?
e_cblp WORD ?
e_cp WORD ?
e_crlc WORD ?
e_cparhdr WORD ?
e_minalloc WORD ?
e_maxalloc WORD ?
e_ss WORD ?
e_sp WORD ?
e_csum WORD ?
e_ip WORD ?
e_cs WORD ?
e_lfarlc WORD ?
e_ovno WORD ?
e_res WORD 4 dup(?)
e_oemid WORD ?
e_oeminfo WORD ?
e_res2 WORD 10 dup(?)
e_lfanew DWORD ?
IMAGE_DOS_HEADER ENDS
ENDIF

IFNDEF IMAGE_NT_HEADERS
IMAGE_NT_HEADERS STRUCT
Signature DWORD ?
FileHeader IMAGE_FILE_HEADER <>
OptionalHeader IMAGE_OPTIONAL_HEADER32 <>
IMAGE_NT_HEADERS ENDS
ENDIF

.CONST
EEEX_ALIGN TEXTEQU <ALIGN 16>

MZ_SIGNATURE EQU 5A4Dh ; ZM - 'MZ'
PE_SIGNATURE EQU 4550h ; EP - 'PE'
IMAGE_NT_OPTIONAL_HDR32_MAGIC EQU 010Bh ; The file is an executable image.
IMAGE_NT_OPTIONAL_HDR64_MAGIC EQU 020Bh ; The file is an executable image.

.DATA
;------------------------------------------------------------------------------
; EEex Initialized Data
;------------------------------------------------------------------------------
AppName DB "EEex loader",0
szAppName DB "[EEex loader]",0
szAppVersion DB " v1.0.0.18",0
szAppVersion DB " v1.0.0.19",0
szEEexLoaderByfearless DB "EEex loader by fearless: github.com/mrfearless/EEexLoader",0
szEEexByBubb DB "EEex by Bubb: github.com/Bubb13/EEex",0
szCRLF DB 13,10,0
Expand Down Expand Up @@ -108,6 +143,12 @@ szErrorGetVersionSize DB "CheckFileVersion: GetFileVersionInfoSizeA failed.",0
szErrorHeap DB "CheckFileVersion: GetProcessHeap failed.",0
szErrorHeapAlloc DB "CheckFileVersion: HeapAlloc failed.",0

; EE Game 64bit Error Messages:
szErrorEEGame64invalid DB "The Beamdog Enhanced Edition game executable doesn't appear to be valid. ",0
szErrorEEGame64error DB "Cant open the Beamdog Enhanced Edition game executable. ",0
szErrorEEGame64yes DB "The Beamdog Enhanced Edition game executable is 64bit! Please use the 64bit EEex loader. ",0
szErrorEEGame64no DB "Detected 32bit Beamdog Enhanced Edition game executable. ",0

; InjectDLL Error Messages:
szErrorVirtualAllocEx DB "InjectDLL: VirtualAllocEx failed. ",0
szErrorWriteProcessMem DB "InjectDLL: WriteProcessMemory failed. ",0
Expand Down
24 changes: 12 additions & 12 deletions EEex/EEex.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.18
PV=1.0.0.18
FV=1.0.0.19
PV=1.0.0.19
VerOS=0x00000004
VerFT=0x00000001
VerLNG=0x00000409
VerCHS=0x000004B0
ProductVersion=1.0.0.18
ProductVersion=1.0.0.19
ProductName=EEex.exe
OriginalFilename=EEex.exe
LegalTrademarks=fearless
LegalCopyright=fearless
InternalName=EEex.exe
FileDescription=EEex loader
FileVersion=1.0.0.18
FileVersion=1.0.0.19
CompanyName=fearless
[Group]
Group=Assembly,Resources,Misc
Expand Down Expand Up @@ -99,16 +99,16 @@ AutoLoad=2,1,4,3,5
10="dwFileVerInfoSize"
[Size]
4=0,0,0,0,0
5=0,0,0,0,8701
5=0,0,0,0,3793
3=0,0,0,0,19
1=0,0,0,0,24328
2=0,0,0,0,1503
1=0,0,0,0,465
2=0,0,0,0,6113
[Collapse]
3=
1=557842689,,524288
2=
1=1342193664,16,,
2=56
4=
5=6466048
5=174848
[VersionControl]
Settings=1279
Milestones=129
Expand All @@ -119,7 +119,7 @@ MilestoneOnTime=2
MilestoneOnDate=0
MilestoneOnDateWhen=1
MilestoneOnDateStatus=0
MilestoneOnDateDate=6
MilestoneOnDateDate=9
MilestoneOnDateTimeYear=2019
MilestoneOnDateTimeMonth=1
MilestoneOnDateTimeDate=26
Expand All @@ -143,7 +143,7 @@ ProductVer2Range=0
ProductVer3Range=0
ProductVer4Range=0
[PTimer]
PTimer=72276867
PTimer=84372529
[GroupExpand]
GroupExpand=1,0,1,0
[BookMark]
Expand Down
113 changes: 1 addition & 112 deletions EEex/EEexConsole.asm
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
GetCommandLine EQU <GetCommandLineA>

ConsoleParseCmdLine PROTO :DWORD
ConsoleCmdLineParam PROTO :DWORD,:DWORD,:DWORD,:DWORD
ConsoleClearScreen PROTO
ConsoleText PROTO :DWORD
ConsoleText PROTO :DWORD
ConsoleStarted PROTO
ConsoleAttach PROTO
ConsoleSendEnterKey PROTO
Expand Down Expand Up @@ -39,113 +35,6 @@ hChildStd_IN_Wr DD ?

.CODE

EEEX_ALIGN
;------------------------------------------------------------------------------
; Command-line parser for console applications
; http://masm32.com/board/index.php?topic=2598.msg27628#msg27628
; Coded by Vortex
; Returns no of parameters parsed and stored in the dwParametersArray
;------------------------------------------------------------------------------
ConsoleParseCmdLine PROC USES EBX EDI ESI dwParametersArray:DWORD

invoke GetCommandLine
lea edx,[eax-1]
xor eax,eax
mov esi,dwParametersArray
lea edi,[esi+256]
mov ch,32
mov bl,9

scan:

inc edx
mov cl,BYTE PTR [edx]
test cl,cl
jz finish
cmp cl,32
je scan
cmp cl,9
je scan
inc eax
mov DWORD PTR [esi],edi
add esi,4

restart:

mov cl,BYTE PTR [edx]
test cl,cl
jne @f
mov BYTE PTR [edi],cl
ret
@@:
cmp cl,ch
je end_of_line
cmp cl,bl
je end_of_line
cmp cl,34
jne @f
xor ch,32
xor bl,9
jmp next_char
@@:
mov BYTE PTR [edi],cl
inc edi

next_char:

inc edx
jmp restart

end_of_line:

mov BYTE PTR [edi],0
inc edi
jmp scan

finish:

ret

ConsoleParseCmdLine ENDP

EEEX_ALIGN
;------------------------------------------------------------------------------
; ConsoleCmdLineParam by fearless - fetch parameter by index from cmd line that
; was parsed via ConsoleParseCmdLine and stored in an array buffer
;
; Returns -1 if dwParametersArray is empty
; Returns 0 if parameter required is invalid
; Returns > 0 if parameter was fetched, on return lpszReturnedParameter will
; contain the string value of the parameter and eax contains the
; length of the parameter's string.
;------------------------------------------------------------------------------
ConsoleCmdLineParam PROC USES EBX ESI dwParametersArray:DWORD, dwParameterToFetch:DWORD, dwTotalParameters:DWORD, lpszReturnedParameter:DWORD
.IF dwParametersArray == 0
mov eax, -1
ret
.ENDIF
mov eax, dwParameterToFetch
.IF eax > dwTotalParameters ; for safety we require total params so we dont go over and crash
mov ebx, [lpszReturnedParameter]
mov byte ptr [ebx], 0h
mov eax, 0
ret
.ENDIF
mov esi, dwParametersArray
mov ebx, 4
mul ebx ; eax contains the no of parameter we want offset for
add esi, eax ; Now at offset for parameters string

.IF lpszReturnedParameter != NULL
Invoke lstrcpyn, lpszReturnedParameter, DWORD PTR [esi], MAX_PATH
Invoke lstrlen, lpszReturnedParameter ; Get length of parameter. >0 = success
.ELSE
mov eax, 0
.ENDIF
ret
ConsoleCmdLineParam endp

EEEX_ALIGN
;------------------------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions EEex/Res/EEexVer.rc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#define VERINF1 1
VERINF1 VERSIONINFO
FILEVERSION 1,0,0,18
PRODUCTVERSION 1,0,0,18
FILEVERSION 1,0,0,19
PRODUCTVERSION 1,0,0,19
FILEOS 0x00000004
FILETYPE 0x00000001
BEGIN
Expand All @@ -10,14 +10,14 @@ BEGIN
BLOCK "040904B0"
BEGIN
VALUE "CompanyName", "fearless\0"
VALUE "FileVersion", "1.0.0.18\0"
VALUE "FileVersion", "1.0.0.19\0"
VALUE "FileDescription", "EEex loader\0"
VALUE "InternalName", "EEex.exe\0"
VALUE "LegalCopyright", "fearless\0"
VALUE "LegalTrademarks", "fearless\0"
VALUE "OriginalFilename", "EEex.exe\0"
VALUE "ProductName", "EEex.exe\0"
VALUE "ProductVersion", "1.0.0.18\0"
VALUE "ProductVersion", "1.0.0.19\0"
END
END
BLOCK "VarFileInfo"
Expand Down
Binary file modified EEexDLL/EEex.dll
Binary file not shown.

0 comments on commit 84b203b

Please sign in to comment.