edited my post today!
@mpoffo
im ok with thatm heres the src if some wants to have a look, written in fasm:
Code:
format PE64 GUI 5.0 at 140000000h
entry start
include 'D:\FASM\INCLUDE\win64a.inc'
;------------------------------------------------------------------------------------
section '.text' code readable executable
;------------------------------------------------------------------------------------
Int3
Int3
Int3
start:
sub rsp,8h ; Make stack qword aligned
call aspect_fix_Init
call Start_threads
call WinMain
exit:
invoke ExitProcess,0
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc WinMain
;------------------------------------------------------------------------------------
invoke GetModuleHandle,0
mov [wc.hInstance],rax
invoke LoadIcon,[wc.hInstance],500
mov [wc.hIcon],rax
invoke LoadCursor,0,IDC_ARROW
mov [wc.hCursor],rax
invoke RegisterClassEx,wc
invoke CreateWindowEx,0,class,title,WS_VISIBLE+WS_TILED+WS_MINIMIZEBOX+WS_SYSMENU ,128,128,462,260,0,0,[wc.hInstance],NULL
msg_loop:
invoke GetMessage,msg,NULL,0,0
.if eax < 1
ret
.endif
.if eax <> 1
jmp msg_loop
.endif
invoke TranslateMessage,msg
invoke DispatchMessage,msg
jmp msg_loop
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc WindowProc hwnd:DWORD,uMsg:DWORD,wParam:QWORD,lParam:QWORD
;------------------------------------------------------------------------------------
mov [hwnd],ecx
mov [uMsg],edx
mov [wParam],r8
mov [lParam],r9
.if [uMsg] = WM_CREATE
invoke CreateWindowEx,WS_EX_STATICEDGE,statClass,0,WS_CHILD+WS_VISIBLE+SS_BITMAP,0,0,462,260,[hwnd],0,[wc.hInstance],NULL
mov [hStatImage], eax
invoke LoadBitmap,[wc.hInstance],750
mov [hBmp], eax
invoke SendMessage,[hStatImage],STM_SETIMAGE,IMAGE_BITMAP,[hBmp]
.endif
.if [uMsg] = WM_DESTROY
invoke PostQuitMessage,0
xor eax,eax
ret
.endif
.if [uMsg] = WM_HOTKEY
;disable hotkey if AutoMode is set to 1 in .ini!
.if [pAutoEnable] = 0
call Hotkey_Action
.endif
xor eax,eax
inc eax
ret
.endif
.if [rkey] = 0
invoke RegisterHotKey,[hwnd],1,0,VK_END
mov [rkey],1
.endif
invoke DefWindowProc,[hwnd],[uMsg],[wParam],[lParam]
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc Hotkey_Action
;------------------------------------------------------------------------------------
.if [patch_Offset] <> 0
invoke ReadProcessMemory, [hProcess],[patch_Offset],addr rBuffer,04h,[lpNumberOfBytesRead]
;enable
;-------------------
.if dword [rBuffer] = 03FE38E39h ;16:9
invoke WriteProcessMemory,[hProcess],[patch_Offset],addr pAspect,04h,[lpNumberOfBytesWritten] ;set 21:9 aspect
ret
.endif
;disable
;-------------------
.if dword [rBuffer] = 040155558h ;21:9
invoke WriteProcessMemory,[hProcess],[patch_Offset],addr pAspect_disable,04h,[lpNumberOfBytesWritten] ;set 16:9 aspect
ret
.endif
.endif
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc Automatic_Action
;------------------------------------------------------------------------------------
_waitAutomatic:
.while [patch_Offset] <> 0
.if [pAutoEnable] = 1
MemLoop:
invoke GetExitCodeProcess,[hProcess],addr lpExitCode
.while [lpExitCode] = STILL_ACTIVE
invoke ReadProcessMemory, [hProcess],[patch_Offset],addr rBuffer,04h,[lpNumberOfBytesRead]
enable_:
.if [rBuffer] = 03FE38E39h ;16:9
invoke WriteProcessMemory,[hProcess],[patch_Offset],addr pAspect,04h,[lpNumberOfBytesWritten] ;set 21:9 aspect
invoke Sleep,1000h
.endif
jmp MemLoop
.endw
.endif
ret
.endw
jmp _waitAutomatic
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc _OpenProcess
;------------------------------------------------------------------------------------
.while [hProcess] = 0
invoke CreateToolhelp32Snapshot,TH32CS_SNAPPROCESS,0
.if eax <> INVALID_HANDLE_VALUE
mov dword [hProcessSnap],eax
mov rax,sizeof.PROCESSENTRY32
mov dword [pe32.dwSize],eax
invoke Process32First,[hProcessSnap],addr pe32
.if eax <> 0
_check:
lea rcx,[pe32.szExeFile]
invoke lstrcmp,rcx,ProcName
.if eax = 0
invoke OpenProcess,PROCESS_ALL_ACCESS, 0, [pe32.th32ProcessID]
mov [hProcess],eax
.checkmp: ; prevents modul not loaded yet
invoke CreateToolhelp32Snapshot,TH32CS_SNAPMODULE,[pe32.th32ProcessID]
mov dword [hModuleSnap],eax
mov rax,sizeof.MODULEENTRY32
mov dword [me32.dwSize],eax
invoke Module32First,[hModuleSnap],addr me32
cmp eax,0
je .checkmp
mov rax,[me32.modBaseAddr]
mov [baseAddy],rax
invoke CloseHandle,[hModuleSnap]
invoke CloseHandle,[hProcessSnap]
ret
.endif
lea rcx,[pe32.szExeFile]
invoke lstrcmp,rcx,ProcName2
.if eax = 0
invoke OpenProcess,PROCESS_ALL_ACCESS, 0, [pe32.th32ProcessID]
mov [hProcess],eax
.checksp: ; prevents modul not loaded yet
invoke CreateToolhelp32Snapshot,TH32CS_SNAPMODULE,[pe32.th32ProcessID]
mov dword [hModuleSnap],eax
mov rax,sizeof.MODULEENTRY32
mov dword [me32.dwSize],eax
invoke Module32First,[hModuleSnap],addr me32
cmp eax,0
je .checksp
mov rax,[me32.modBaseAddr]
mov [baseAddy],rax
invoke CloseHandle,[hModuleSnap]
invoke CloseHandle,[hProcessSnap]
ret
.endif
invoke Process32Next,[hProcessSnap],addr pe32
.if eax <> 0
jmp _check
.endif
.endif
.endif
invoke CloseHandle,[hProcessSnap]
.endw
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc search_Offset
;------------------------------------------------------------------------------------
_wait_search_Offset:
.while [baseAddy] <> 0
mov rax,[baseAddy]
add rax,1000h
mov [StartAddy],rax
mov rax,[baseAddy]
add rax,3Ch
mov [PEsig],rax
xor rax,rax
mov rax,[PEsig]
invoke ReadProcessMemory,[hProcess],[PEsig],addr PEOffset,04h,[lpNumberOfBytesRead]
mov rax,[PEOffset]
mov rcx,[baseAddy]
add rax,rcx
add rax,1Ch
invoke ReadProcessMemory,[hProcess],rax,addr codeSize,04h,[lpNumberOfBytesRead]
mov rax,[StartAddy]
xor ecx,ecx
mov ecx,dword[codeSize]
add rax,rcx
mov [EndAddy],rax
push rsi
mov rsi,[EndAddy]
.while [StartAddy] < rsi
mov rdx,[StartAddy]
invoke ReadProcessMemory,[hProcess],rdx,addr CodePart1,04h,[lpNumberOfBytesRead]
.if [CodePart1] = 02474290Fh;0F297424h
mov rax,[StartAddy]
add rax,08h
invoke ReadProcessMemory,[hProcess],rax,addr CodePart2,04h,[lpNumberOfBytesRead]
.if [CodePart2] = 0D100FF3h;0F30F100Dh
;code is found!
mov rax,[StartAddy]
add rax,08h
invoke ReadProcessMemory,[hProcess],rax,addr Patch_rva,08h,[lpNumberOfBytesRead]
xor rax,rax
mov rax,[Patch_rva+4]
mov rcx,[StartAddy]
add rax,rcx
add rax,10h
mov [patch_Offset],rax
pop rsi
ret
.endif
.endif
mov rax,[StartAddy]
add rax,1h
mov [StartAddy],rax
.endw
;error no offset found!
pop rsi
invoke MessageBoxA,[hStatImage],addr lpText,addr lpCaption,MB_ICONERROR
.endw
jmp _wait_search_Offset
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc Start_threads
;------------------------------------------------------------------------------------
xor r8,r8
lea r8,[_OpenProcess]
invoke CreateThread,0,0,r8,0,0
xor r8,r8
lea r8,[search_Offset]
invoke CreateThread,0,0,r8,0,0
xor r8,r8
lea r8,[Automatic_Action]
invoke CreateThread,0,0,r8,0,0
;wait for exit:
xor r8,r8
lea r8,[_TerminateProcess]
invoke CreateThread,0,0,r8,0,0
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc _TerminateProcess
;------------------------------------------------------------------------------------
_waitterminate:
.while [hProcess] <> 0
done:
.if [pAutoClose] = 1
Qloop:
invoke GetExitCodeProcess,[hProcess],addr lpExitCode
.while [lpExitCode] = STILL_ACTIVE
invoke Sleep,01h
jmp Qloop
.endw
invoke CloseHandle,[hProcess]
invoke ExitProcess,lpExitCode
.endif
.endw
jmp _waitterminate
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc GetPath
;------------------------------------------------------------------------------------
invoke GetModuleHandle,0
mov rcx,rax
lea rax,[Standard_Buffer]
invoke GetModuleFileName,rcx,rax,01000h
invoke PathRemoveFileSpecA,Standard_Buffer
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc ZEROBUFFER
;------------------------------------------------------------------------------------
push rdi
push rsi
;zero buffer!
lea rcx,[Standard_Buffer]
mov rdi,rcx ;write to
lea rsi,[ZERO] ;read from
MOV ECX,0ffh ;size
REP MOVS BYTE[rdi],BYTE[rsi]
pop rsi
pop rdi
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
Int3
Int3
Int3
;------------------------------------------------------------------------------------
proc aspect_fix_Init
;------------------------------------------------------------------------------------
; lea r8,[_OpenProcess]
; invoke CreateThread,0,0,r8,0,0
fastcall ZEROBUFFER
fastcall GetPath
invoke lstrcat,Standard_Buffer,lpFileName
invoke GetPrivateProfileInt,lpAppName,lpAutoClose ,0,Standard_Buffer
mov [pAutoClose],al
invoke GetPrivateProfileInt,lpAppName,lpAutoEnable ,0,Standard_Buffer
mov [pAutoEnable],al
ret
;------------------------------------------------------------------------------------
endp
;------------------------------------------------------------------------------------
;------------------------------------------------------------------------------------
section '.rdata' data readable
;------------------------------------------------------------------------------------
data import
library kernel32,'KERNEL32.DLL',user32,'USER32.DLL',Shlwapi,'Shlwapi.dll'
import Shlwapi,PathRemoveFileSpecA,'PathRemoveFileSpecA'
import MessageBoxA,MessageBoxA,'MessageBoxA'
include 'api\kernel32.inc'
include 'api\user32.inc'
end data
;------------------------------------------------------------------------------------
section '.data' data readable writeable
;------------------------------------------------------------------------------------
;Data directives:
;-------------------
;db Define Byte, allocates 1 byte
;dw Define Word, allocates 2 bytes
;dd Define Doubleword, allocates 4 bytes
;dq Define Quadword, allocates 8 bytes
;rb Reserve Byte
;rw Reserve Word
;rd Reserve Doubleword
;rq Reserve Quadword
struct PROCESSENTRY32
dwSize dd ?
cntUsage dd ?
th32ProcessID dd ?
rd 1 ;ULONG_PTR
th32DefaultHeapID dq ?
th32ModuleID dd ?
cntThreads dd ?
th32ParentProcessID dd ?
pcPriClassBase dd ?
dwFlags dd ?
szExeFile db MAX_PATH dup (?)
ends
pe32 PROCESSENTRY32 <>
struct MODULEENTRY32
dwSize dd ?
th32ModuleID dd ?
th32ProcessID dd ?
GlblcntUsage dd ?
ProccntUsage dd ?
rd 1 ;BYTE
modBaseAddr dq ?
modBaseSize dd ?
hModule dd ?
szModule db 256h dup (?)
szExePath db MAX_PATH dup (?)
ends ;
me32 MODULEENTRY32 <>
wc WNDCLASSEX sizeof.WNDCLASSEX,0,WindowProc,0,0,NULL,0,NULL,COLOR_BTNFACE+1,NULL,class,NULL
msg MSG
TH32CS_SNAPPROCESS = 2
TH32CS_SNAPMODULE = 8
VK_END = 023h ;
Standard_Buffer rd 0100h
ZERO rd 00FFh
title db "COD-AW Aspect Ratio Fix",0
class db "CODAW_ARF_64",0
ProcName db "s1_mp64_ship.exe",0
ProcName2 db "s1_sp64_ship.exe",0
statClass db "STATIC",0
lpFileName db "\aspect_fix.ini",0
lpAppName db "Settings",0
lpAutoEnable db "Auto",0
lpAutoClose db "CloseOnExit",0
lpText db "Error, Offset not found!",0
lpCaption db "Search-Error",0
pAspect dd 040155558h; 21:9
pAspect_disable dd 03FE38E39h; 16:9
;pOffset dq 014107BF90h ;
patch_Offset dq ?
rBuffer dd ?
hProcessSnap dd ?
hModuleSnap dd ?
hProcess dd ?
hStatImage dd ?
hBmp dd ?
lpNumberOfBytesWritten dq ?
lpNumberOfBytesRead dq ?
lpExitCode dd ?
rkey db ?
init db ?
sThread db ?
pAutoClose db ?
pAutoEnable db ?
baseAddy dq ?
StartAddy dq ?
PEsig dq ?
PEOffset dq ?
codeSize dd ?
EndAddy dq ?
CodePart1 dd ?
CodePart2 dd ?
CodePart3 dd ?
Patch_rva dq ?
;------------------------------------------------------------------------------------
section '.rsrc' resource data readable
;------------------------------------------------------------------------------------
; resource directory
directory RT_ICON,icons,\
RT_GROUP_ICON,group_icons,\
RT_BITMAP,bitmaps,\
RT_VERSION,versions
; resource subdirectories
resource icons,\
1,LANG_NEUTRAL,icon_data
resource group_icons,\
500,LANG_NEUTRAL,main_icon
resource bitmaps,\
750,LANG_NEUTRAL,bitmap_data
resource versions,\
1,LANG_NEUTRAL,version
icon main_icon,icon_data,'aspect_fix.ico'
bitmap bitmap_data,'BITMAP.BMP'
versioninfo version,VOS__WINDOWS32,VFT_APP,VFT2_UNKNOWN,LANG_ENGLISH+SUBLANG_DEFAULT,0,\
'FileDescription','COD-AW Aspect Ratio Fix',\
'LegalCopyright','No rights reserved.',\
'FileVersion','1.0',\
'ProductVersion','1.0',\
'OriginalFilename','aspect_fix.exe'
;patch notes
;3FAAAAAB = 1.3 / 4:3
;3FCCCCCD = 1.6 / 16:10
;3FE38E39 = 1.7 / 16:9
;MP:
;Address Hex dump Command Comments
;0001_401C37F4 0F297424 20 MOVAPS DQWORD PTR [RSP+20],XMM6 ; FLOAT 0.0, 0.0, 0.0, 0.1000000
;0001_401C37F9 0F28F1 MOVAPS XMM6,XMM1
;0001_401C37FC F30F100D 8C87EB00 MOVSS XMM1,DWORD PTR [REL 1_4107BF90] ; FLOAT 1.777778 (CONST 16./9)
;SP:
;Address Hex dump Command Comments
;0001_40113B16 0F297424 20 MOVAPS DQWORD PTR [RSP+20],XMM6 ; FLOAT 0.0, 0.0, 0.0, 0.0
;0001_40113B1B 0F28F1 MOVAPS XMM6,XMM1
;0001_40113B1E F30F100D BA31B4 MOVSS XMM1,DWORD PTR [REL 1_40C56CE0] ; FLOAT 1.777778 (CONST 16./9)
;pattern
;0001_401C37F4 F1280F20_2474290F
;0001_401C37FC 00EB878C_0D100FF3 0F297424 20 0F28F1