fix ML64 related errors, add detours.lib

This commit is contained in:
ApfelTeeSaft
2026-05-06 14:27:45 +02:00
parent 1266ef369b
commit f19bb204f9
24 changed files with 187 additions and 90 deletions
+2
View File
@@ -1,2 +1,4 @@
# Auto detect text files and perform LF normalization
* text=auto
*.bat text eol=crlf
+35 -3
View File
@@ -4,13 +4,32 @@ setlocal EnableDelayedExpansion
set CONFIG=%1
if "%CONFIG%"=="" set CONFIG=Release
if defined VCINSTALLDIR goto :env_ready
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" set "VSWHERE=%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
if not exist "%VSWHERE%" (
echo ERROR: vswhere.exe not found..
exit /b 1
)
for /f "usebackq delims=" %%P in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VS_PATH=%%P"
if not defined VS_PATH (
echo ERROR: No Visual Studio installation with VC tools found.
exit /b 1
)
call "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" x64 >nul 2>&1
if errorlevel 1 (
echo ERROR: vcvarsall.bat failed.
exit /b 1
)
:env_ready
set OUTDIR=.\output\bin\%CONFIG%
set OBJDIR=.\output\obj\%CONFIG%
if not exist "%OUTDIR%" mkdir "%OUTDIR%"
if not exist "%OBJDIR%" mkdir "%OBJDIR%"
set ML_FLAGS=/nologo /W3 /WX /c /Cx /Zi /Fo"%OBJDIR%\\"
set ML_FLAGS=/nologo /W3 /WX /c /Cx /Zi /Fo"%OBJDIR%\\" /I .
if /I "%CONFIG%"=="Debug" (
set ML_FLAGS=%ML_FLAGS% /DDEBUG
) else (
@@ -23,7 +42,20 @@ set LINK_FLAGS=%LINK_FLAGS% /OUT:"%OUTDIR%\raider.dll"
set LINK_FLAGS=%LINK_FLAGS% /PDB:"%OUTDIR%\raider.pdb"
set LINK_FLAGS=%LINK_FLAGS% /IMPLIB:"%OUTDIR%\raider.lib"
set LIBS=kernel32.lib user32.lib detours.lib
set "DETOURS_LIBPATH="
if exist ".\lib\detours.lib" set "DETOURS_LIBPATH=.\lib"
if not defined DETOURS_LIBPATH if exist "%VCPKG_ROOT%\packages\detours_x64-windows\lib\detours.lib" set "DETOURS_LIBPATH=%VCPKG_ROOT%\packages\detours_x64-windows\lib"
if not defined DETOURS_LIBPATH if exist "%VCPKG_ROOT%\packages\detours_x64-windows-static\lib\detours.lib" set "DETOURS_LIBPATH=%VCPKG_ROOT%\packages\detours_x64-windows-static\lib"
if not defined DETOURS_LIBPATH if exist "%VCPKG_INSTALLED_DIR%\x64-windows\lib\detours.lib" set "DETOURS_LIBPATH=%VCPKG_INSTALLED_DIR%\x64-windows\lib"
if not defined DETOURS_LIBPATH (
echo.
echo ERROR: detours.lib not found. Are you stupid?
echo.
exit /b 1
)
set LINK_FLAGS=%LINK_FLAGS% /LIBPATH:"%DETOURS_LIBPATH%"
set LIBS=kernel32.lib user32.lib msvcrt.lib ucrt.lib vcruntime.lib legacy_stdio_definitions.lib detours.lib
set ASM_FILES=^
raider.asm ^
@@ -79,7 +111,7 @@ for %%F in (%ASM_FILES%) do (
if !ERRORS! GTR 0 (
echo.
echo BUILD FAILED: !ERRORS! file(s) failed to assemble.
echo BUILD FAILED: !ERRORS! files failed to assemble.
exit /b 1
)
+4 -1
View File
@@ -1,4 +1,7 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
EXTERNDEF GMB_Current :QWORD
EXTERNDEF GameModeBase_New :PROC
GMB_Teams EQU 000h
GMB_OnPlayerJoined EQU 020h
+9 -12
View File
@@ -1,4 +1,4 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
; GMB struct offsets
GMB_Teams EQU 000h
@@ -145,6 +145,7 @@ szLogDeath DB "[GAMEMODE] Player killed", 0
.data?
; Globally exported current game mode struct pointer
PUBLIC GMB_Current
GMB_Current QWORD ?
; UFunction caches
@@ -1097,7 +1098,7 @@ GameModeBase_Respawn PROC
push rbp
push rsi
push rdi
sub rsp, 28h
sub rsp, 38h
mov rbx, rcx ; RBX = PC
mov rbp, rdx ; RBP = RespawnPos* (may be 0)
@@ -1146,18 +1147,14 @@ GameModeBase_Respawn PROC
test rax, rax
jz @@equip_pickaxe
; ActivateSlot params: {EFortQuickBars(1), pad(3), Slot(4), Delay(4), bUpdate(1)}
xor edi, edi
mov QWORD PTR [rsp + 20h], rdi ; InQuickBar=0, pad=0, Slot=0 cleared
mov DWORD PTR [rsp + 24h], edi ; ActivateDelay = 0.0f
mov BYTE PTR [rsp + 28h], 0
; byte [20]=QuickBar(0), [21..23]=pad, [24..27]=Slot(0), [28..2B]=Delay(0), [2C]=bUpdate(1)
; ActivateSlot params layout (13 bytes total):
; byte [20]=QuickBar(0), [21..23]=pad, [24..27]=Slot(0),
; [28..2B]=ActivateDelay(0.0f), [2C]=bUpdatePreviousFocusedSlot(1)
xor eax, eax
mov QWORD PTR [rsp + 20h], rax
mov QWORD PTR [rsp + 28h], rax
mov QWORD PTR [rsp + 20h], rax ; QuickBar=0, pad=0, Slot=0
mov QWORD PTR [rsp + 28h], rax ; ActivateDelay=0.0f, RetBuf=0
mov BYTE PTR [rsp + 2Ch], 1 ; bUpdatePreviousFocusedSlot = true
mov rcx, rbx
mov rdx, rax ; RAX still 0 from mov above? No need separate
mov rdx, QWORD PTR [pFn_ActivateSlot]
lea r8, [rsp + 20h]
call QWORD PTR [ProcessEvent]
@@ -1179,7 +1176,7 @@ GameModeBase_Respawn PROC
call Inventory_EquipInventoryItem
@@done_resp:
add rsp, 28h
add rsp, 38h
pop rdi
pop rsi
pop rbp
+4 -1
View File
@@ -1,4 +1,7 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
EXTERNDEF GMB_Current :QWORD
EXTERNDEF GameModeBase_New :PROC
GMB_Teams EQU 000h
GMB_OnPlayerJoined EQU 020h
+4 -1
View File
@@ -1,4 +1,7 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
EXTERNDEF GMB_Current :QWORD
EXTERNDEF GameModeBase_New :PROC
; GMB struct offsets
GMB_Teams EQU 000h
+4 -1
View File
@@ -1,4 +1,7 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
EXTERNDEF GMB_Current :QWORD
EXTERNDEF GameModeBase_New :PROC
GMB_Teams EQU 000h
GMB_OnPlayerJoined EQU 020h
+4 -1
View File
@@ -1,4 +1,7 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
EXTERNDEF GMB_Current :QWORD
EXTERNDEF GameModeBase_New :PROC
GMB_Teams EQU 000h
GMB_OnPlayerJoined EQU 020h
+3 -2
View File
@@ -1,4 +1,6 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
EXTERNDEF GameModeLateGame_InitializeGameplay :PROC
; SDK offsets - AFortGameStateAthena
AGSA_WarmupCountdownEndTime EQU 14F4h
@@ -529,7 +531,6 @@ GUI_Tick PROC
jae @@end_gui ; done iterating
; Get PlayerState pointer = PlayerArray.Data[i] (array of pointers)
movzx rax, eax
mov rax, QWORD PTR [rdi + rax*8]
test rax, rax
jz @@player_next
+14 -3
View File
@@ -29,23 +29,29 @@ EXTERNDEF Native_LocalPlayer_SpawnPlayActor :QWORD
; Native::GC
EXTERNDEF Native_GC_CollectGarbage :QWORD
; Native::AbilitySystemComponent
EXTERNDEF Native_AbilitySystemComponent_GiveAbility :QWORD
EXTERNDEF Native_AbilitySystemComponent_FindAbilitySpecFromHandle :QWORD
EXTERNDEF Native_AbilitySystemComponent_InternalTryActivateAbility :QWORD
EXTERNDEF Native_AbilitySystemComponent_GiveAbility :QWORD
EXTERNDEF Native_AbilitySystemComponent_FindAbilitySpecFromHandle :QWORD
EXTERNDEF Native_AbilitySystemComponent_InternalTryActivateAbility :QWORD
EXTERNDEF Native_AbilitySystemComponent_MarkAbilitySpecDirty :QWORD
; Native::NetDriver
EXTERNDEF Native_NetDriver_TickFlush :QWORD
EXTERNDEF Native_NetDriver_InitListen :QWORD
; Native::ReplicationDriver
EXTERNDEF Native_ReplicationDriver_ServerReplicateActors :QWORD
; Native::NetConnection
EXTERNDEF Native_NetConnection_ReceiveNetGUIDBunch :QWORD
EXTERNDEF Native_NetConnection_ReceiveFString :QWORD
EXTERNDEF Native_NetConnection_ReceiveUniqueIdRepl :QWORD
; Native::OnlineSession
EXTERNDEF Native_OnlineSession_KickPlayer :QWORD
; Native::OnlineBeacon
EXTERNDEF Native_OnlineBeacon_NotifyAcceptingConnection :QWORD
EXTERNDEF Native_OnlineBeacon_PauseBeaconRequests :QWORD
; Native::OnlineBeaconHost
EXTERNDEF Native_OnlineBeaconHost_NotifyAcceptingConnection :QWORD
EXTERNDEF Native_OnlineBeaconHost_InitHost :QWORD
EXTERNDEF Native_OnlineBeaconHost_PauseBeaconRequests :QWORD
EXTERNDEF Native_OnlineBeaconHost_NotifyControlMessage :QWORD
; Native::World
EXTERNDEF Native_World_NotifyControlMessage :QWORD
EXTERNDEF Native_World_WelcomePlayer :QWORD
@@ -79,6 +85,10 @@ EXTERNDEF Pat_WorldNotifyCtrl :BYTE
EXTERNDEF Pat_SpawnPlayActor :BYTE
EXTERNDEF Pat_WorldNotifyAccept :BYTE
EXTERNDEF Pat_GetNetMode :BYTE
EXTERNDEF Pat_GiveAbility :BYTE
EXTERNDEF Pat_InternalTryActivate :BYTE
EXTERNDEF Pat_MarkAbilitySpecDirty :BYTE
EXTERNDEF Pat_FindAbilitySpecFromHandle:BYTE
EXTERNDEF Pat_GiveAbility :BYTE
EXTERNDEF Pat_InternalTryActivate :BYTE
EXTERNDEF Pat_MarkAbilitySpecDirty:BYTE
@@ -148,6 +158,7 @@ EXTERNDEF TArray_FreeArray :PROC ; (arr:PTR TArrayHeader)
; sdk/sdk_classes.asm - FString helpers
EXTERNDEF FString_FromWideChar :PROC ; (out:PTR TArrayHeader, wstr:PTR WORD)
EXTERNDEF FString_Free :PROC ; (str:PTR TArrayHeader)
EXTERNDEF ProcessEvent_Call :PROC ; (obj:QWORD, fn:QWORD, params:QWORD)
; sdk/sdk_fort.asm - Fortnite-specific helpers
EXTERNDEF FortHelper_GetAbilitySystemComponent :PROC ; (pawn:QWORD) -> QWORD
BIN
View File
Binary file not shown.
+1 -1
View File
@@ -1,4 +1,4 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
EXTRN printf :PROC
EXTRN GetLocalTime :PROC ; VOID WINAPI GetLocalTime(LPSYSTEMTIME)
+1 -1
View File
@@ -1,4 +1,4 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
; UAbilitySystemComponent: ActivatableAbilities(+0x470) + Items TArray (+0xB0)
ASC_ITEMS_DATA EQU 0520h
+1 -1
View File
@@ -1,4 +1,4 @@
INCLUDE ..\include\master.inc
INCLUDE include\master.inc
; UWorld field offsets
UWORLD_NetDriver EQU 038h
+1 -1
View File
@@ -1,4 +1,4 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
; AFortPlayerController offsets
PC_WorldInventory EQU 1ED8h
+1 -1
View File
@@ -1,4 +1,4 @@
INCLUDE ..\include\master.inc
INCLUDE include\master.inc
; AFortPickup field offsets
AFPICKUP_bReplicates EQU 0082h ; AActor::bReplicates bitfield (byte bit6)
+1 -1
View File
@@ -1,4 +1,4 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
; Team struct offsets
TEAM_maxTeamSize EQU 000h
+7
View File
@@ -231,6 +231,13 @@ Native_InitializeAll PROC
call Utils_FindPattern
mov QWORD PTR [Native_AbilitySystemComponent_InternalTryActivateAbility], rax
; FindAbilitySpecFromHandle (direct)
lea rcx, Pat_FindAbilitySpecFromHandle
xor edx, edx
xor r8d, r8d
call Utils_FindPattern
mov QWORD PTR [Native_AbilitySystemComponent_FindAbilitySpecFromHandle], rax
; MarkAbilitySpecDirty (direct)
lea rcx, Pat_MarkAbilitySpecDirty
xor edx, edx
+33 -3
View File
@@ -1,3 +1,32 @@
PUBLIC Pat_FNameToString
PUBLIC Pat_GObjects
PUBLIC Pat_Free
PUBLIC Pat_Malloc
PUBLIC Pat_Realloc
PUBLIC Pat_ReceiveFString
PUBLIC Pat_ReceiveUniqueIdRepl
PUBLIC Pat_TickFlush
PUBLIC Pat_PauseBeaconRequests
PUBLIC Pat_BeaconNotifyAccept
PUBLIC Pat_InitHost
PUBLIC Pat_BeaconNotifyCtrl
PUBLIC Pat_WelcomePlayer
PUBLIC Pat_WorldNotifyCtrl
PUBLIC Pat_SpawnPlayActor
PUBLIC Pat_WorldNotifyAccept
PUBLIC Pat_GetNetMode
PUBLIC Pat_GiveAbility
PUBLIC Pat_InternalTryActivate
PUBLIC Pat_MarkAbilitySpecDirty
PUBLIC Pat_FindAbilitySpecFromHandle
PUBLIC Pat_LocalPlayerSpawnPA
PUBLIC Pat_GetPlayerViewPoint
PUBLIC Pat_KickPlayer
PUBLIC Pat_InitListen
PUBLIC Pat_PostRender
PUBLIC Pat_CollectGarbage
PUBLIC Pat_NetDebug
.const
; Core UE4 globals
@@ -28,9 +57,10 @@ Pat_WorldNotifyAccept DB "40 55 48 83 EC 50 48 8B 41 10 48 8B E9 48 83 78 ? ?
Pat_GetNetMode DB "48 89 5C 24 ? 57 48 83 EC 20 48 8B 01 48 8B D9 FF 90 ? ? ? ? 4C 8B 83 ? ? ? ? 48 8B F8 33 C0 48 C7 44 24", 0
; Ability System
Pat_GiveAbility DB "48 89 5C 24 ? 56 57 41 56 48 83 EC 20 83 B9 ? ? ? ? ? 49 8B F0 4C 8B F2 48 8B D9 7E 61", 0
Pat_InternalTryActivate DB "4C 89 4C 24 ? 4C 89 44 24 ? 89 54 24 10 55 53 56 57 41 54 41 57 48 8D AC 24", 0
Pat_MarkAbilitySpecDirty DB "48 89 5C 24 ? 57 48 83 EC 20 80 B9 ? ? ? ? ? 48 8B FA 48 8B D9 75 4A C6 81", 0
Pat_GiveAbility DB "48 89 5C 24 ? 56 57 41 56 48 83 EC 20 83 B9 ? ? ? ? ? 49 8B F0 4C 8B F2 48 8B D9 7E 61", 0
Pat_InternalTryActivate DB "4C 89 4C 24 ? 4C 89 44 24 ? 89 54 24 10 55 53 56 57 41 54 41 57 48 8D AC 24", 0
Pat_MarkAbilitySpecDirty DB "48 89 5C 24 ? 57 48 83 EC 20 80 B9 ? ? ? ? ? 48 8B FA 48 8B D9 75 4A C6 81", 0
Pat_FindAbilitySpecFromHandle DB "48 89 5C 24 ? 48 89 6C 24 ? 56 57 41 56 48 83 EC 20 83 B9 ? ? ? ? ? 48 8B EA 4C 8B F1 8B F2 7E 47", 0
; Player
Pat_LocalPlayerSpawnPA DB "40 55 53 56 57 41 56 41 57 48 8D 6C 24 ? 48 81 EC ? ? ? ? 48 8B 05 ? ? ? ? 48 33 C4 48 89 45 40 48 8B D9 4D 8B F1 49 8B C9 4D 8B F8 48 8B F2", 0
+15 -15
View File
@@ -32,8 +32,8 @@ TArray_Num ENDP
TArray_GetByIndex PROC
; RCX = arr, EDX = idx, R8D = elem_size
mov rax, QWORD PTR [rcx] ; rax = Data
movsx rdx, edx ; sign-extend idx to 64-bit
movsx r8, r8d ; sign-extend elem_size
movsxd rdx, edx ; sign-extend idx to 64-bit
movsxd r8, r8d ; sign-extend elem_size
imul rdx, r8 ; rdx = idx * elem_size
add rax, rdx ; rax = Data + offset
ret
@@ -55,7 +55,7 @@ TArray_Add PROC
mov rbx, rcx ; rbx = arr
mov rsi, rdx ; rsi = elem
movsx r12, r8d ; r12 = elem_size (sign-extended)
movsxd r12, r8d ; r12 = elem_size (sign-extended)
; Check if Count < Max (space available without realloc)
mov ecx, DWORD PTR [rbx + 8] ; ecx = Count
@@ -78,7 +78,7 @@ TArray_Add PROC
@@copy_elem:
; rdi = &arr->Data[Count] = Data + Count*elem_size
mov rdi, QWORD PTR [rbx] ; rdi = Data
movsx rax, ecx ; rax = Count (from ecx, set above)
movsxd rax, ecx ; rax = Count (from ecx, set above)
imul rax, r12 ; rax = Count * elem_size
add rdi, rax ; rdi = destination slot
@@ -115,13 +115,13 @@ TArray_RemoveAt PROC
; Wait: entry 8, push×4 = 8 mod 16 (even pushes restore parity). 8-mod-16 - 40(=8) = 0
mov rbx, rcx ; rbx = arr
movsx rsi, edx ; rsi = idx (64-bit)
movsx rdi, r8d ; rdi = elem_size
movsxd rsi, edx ; rsi = idx (64-bit)
movsxd rdi, r8d ; rdi = elem_size
mov ecx, DWORD PTR [rbx + 8] ; ecx = Count
test ecx, ecx
jz @@done
movsx rcx, ecx ; rcx = Count (64-bit)
movsxd rcx, ecx ; rcx = Count (64-bit)
cmp rsi, rcx
jge @@done ; idx >= Count: no-op
@@ -161,7 +161,7 @@ TArray_RemoveSingle PROC
mov rbx, rcx ; rbx = arr
mov ecx, DWORD PTR [rbx + 8] ; ecx = Count
movsx rax, edx ; rax = idx
movsxd rax, edx ; rax = idx
xor eax, eax ; default return = false
cmp edx, DWORD PTR [rbx + 8]
@@ -366,7 +366,7 @@ SDK_GetObjectByIndex PROC
test rax, rax
jz @@null
mov rax, QWORD PTR [rax] ; rax = Objects (uint8_t*)
movsx rcx, ecx ; sign-extend index
movsxd rcx, ecx ; sign-extend index
imul rcx, rcx, 24 ; offset = index * 24
mov rax, QWORD PTR [rax + rcx] ; rax = *(UObject**)(Objects + offset)
ret
@@ -394,7 +394,7 @@ UObject_GetNameBuf PROC
mov rbx, rcx ; rbx = obj
mov rdi, rdx ; rdi = outBuf
movsx r12, r8d ; r12 = maxLen
movsxd r12, r8d ; r12 = maxLen
; Null guard
test rbx, rbx
@@ -547,7 +547,7 @@ UObject_GetFullName PROC
mov rbx, rcx ; rbx = obj
mov rdi, rdx ; rdi = outBuf
movsx r12, r8d ; r12 = maxLen
movsxd r12, r8d ; r12 = maxLen
; Start with empty outBuf
test rdi, rdi
@@ -589,7 +589,7 @@ UObject_GetFullName PROC
cmp r13d, 8
jge @@outers_done
; outer_ptrs[r13] = rax
movsx rcx, r13d
movsxd rcx, r13d
mov QWORD PTR [rsp + 32 + rcx*8], rax
inc r13d
mov rax, QWORD PTR [rax + 20h] ; rax = outer->Outer
@@ -603,7 +603,7 @@ UObject_GetFullName PROC
@@outer_loop:
dec esi
movsx rcx, esi
movsxd rcx, esi
mov rax, QWORD PTR [rsp + 32 + rcx*8] ; outer_ptrs[i]
mov rcx, rax
lea rdx, szNameBuf
@@ -678,7 +678,7 @@ SDK_FindObject PROC
; obj = GObjects->Objects[esi * 24]
mov rax, QWORD PTR [rbx] ; rax = Objects ptr
movsx rcx, esi
movsxd rcx, esi
imul rcx, rcx, 24
mov rax, QWORD PTR [rax + rcx] ; rax = UObject*
inc esi
@@ -746,7 +746,7 @@ SDK_FindClass PROC
jge @@not_found
mov rax, QWORD PTR [rbx]
movsx rcx, esi
movsxd rcx, esi
imul rcx, rcx, 24
mov rax, QWORD PTR [rax + rcx]
inc esi
+2 -3
View File
@@ -599,7 +599,7 @@ PEHOOK_ServerTryActivateAbility PROC
; Abilities_TryActivateAbility(ASC, Handle*, InputPressed, PredKey*, null)
mov rcx, rbx
lea rdx, [rsi] ; &Params->Handle (at offset 0)
mov rdx, rsi ; &Params->Handle (at offset 0, same address as Params)
movzx r8d, BYTE PTR [rsi + 8] ; InputPressed (bool at +8)
lea r9, [rsi + 10h] ; &Params->PredictionKey (at +0x10)
call Abilities_TryActivateAbility
@@ -628,7 +628,7 @@ PEHOOK_ServerTryActivateAbilityWithEventData PROC
mov rsi, rdx
mov rcx, rbx
lea rdx, [rsi]
mov rdx, rsi ; same address as Params base
movzx r8d, BYTE PTR [rsi + 8]
lea r9, [rsi + 10h]
; 5th arg: &EventData at [rsi + 28h]
@@ -1094,7 +1094,6 @@ PEHOOK_ServerEditBuildingActor PROC
xor esi, esi
test rax, rax
jz @SEBA_no_loc
xor esi, esi
mov DWORD PTR [rsp + 20h], esi ; X = 0
mov DWORD PTR [rsp + 24h], esi ; Y = 0
mov DWORD PTR [rsp + 28h], esi ; Z = 0
+7 -7
View File
@@ -49,7 +49,7 @@ Utils_FindPattern PROC
mov r13, rax ; r13 = base address
; IMAGE_DOS_HEADER.e_lfanew is a DWORD at [base + 0x3C]
movsx rbx, DWORD PTR [r13 + 3Ch] ; rbx = e_lfanew
movsxd rbx, DWORD PTR [r13 + 3Ch] ; rbx = e_lfanew
add rbx, r13 ; rbx = IMAGE_NT_HEADERS64*
; IMAGE_NT_HEADERS64: Signature(4) + FileHeader(20) = 0x18 to OptionalHeader
; IMAGE_OPTIONAL_HEADER64.SizeOfImage: DWORD at OptionalHeader+0x38 -> NtHdrs+0x50
@@ -90,7 +90,7 @@ Utils_FindPattern PROC
lea rdx, [rsp + 560] ; arg2: &endptr
mov r8d, 16 ; arg3: base
call strtoul ; EAX = byte value
movsx r14, eax ; zero-extend byte to 64-bit (safe: 0..255)
movsxd r14, eax ; zero-extend byte to 64-bit (safe: 0..255)
mov DWORD PTR [rsp + 32 + rsi*4], r14d ; pat_ints[rsi] = byte value
inc esi
mov r12, QWORD PTR [rsp + 560] ; r12 = endptr (now points at space/end)
@@ -126,13 +126,13 @@ Utils_FindPattern PROC
jge @@found ; all bytes matched
; Load pat_ints[j] (int32: -1 or byte 0..255)
movsx rdi, r9d
movsxd rdi, r9d
mov eax, DWORD PTR [rbx + rdi*4] ; eax = pat_ints[j]
cmp eax, -1
je @@wildcard ; skip wildcard byte
; Compare scan byte: base[i+j] vs pat_ints[j]
movsx rdi, esi ; rdi = i
movsxd rdi, esi ; rdi = i
add rdi, r9 ; rdi = i + j
movzx edx, BYTE PTR [r13 + rdi] ; edx = scan byte
cmp edx, eax
@@ -148,15 +148,15 @@ Utils_FindPattern PROC
@@found:
; Compute match address = base + i
movsx rax, esi
movsxd rax, esi
add rax, r13
cmp DWORD PTR [rsp + 548], 0
je @@done
; address = address + offset + 4 + *(int32*)(address + offset)
movsx rcx, DWORD PTR [rsp + 552] ; rcx = offset
movsx rdx, DWORD PTR [rax + rcx] ; rdx = *(int32*)(address + offset)
movsxd rcx, DWORD PTR [rsp + 552] ; rcx = offset
movsxd rdx, DWORD PTR [rax + rcx] ; rdx = *(int32*)(address + offset)
lea rax, [rax + rcx + 4] ; rax = address + offset + 4
add rax, rdx ; rax += displacement
jmp @@done
+11 -13
View File
@@ -1,4 +1,4 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
; DrawList field offsets
DL_type EQU 000h
@@ -62,12 +62,10 @@ KDT_OUT_CLR_A EQU 05Ch ; = 0.30f
; Immediate float constants (IEEE 754)
F_0_0 EQU 000000000h ; 0.0f
F_0_5 EQU 03F000000h ; 0.5f
F_1_0 EQU 03F800000h ; 1.0f
F_5_0 EQU 040A00000h ; 5.0f
F_10_0 EQU 041200000h ; 10.0f
F_12_5 EQU 041480000h ; 12.5f
F_25_0 EQU 041C80000h ; 25.0f
F_0_30 EQU 03E99999Ah ; 0.30f (outline alpha)
.const
@@ -695,7 +693,7 @@ ZeroGUI_Begin PROC
mov ecx, DWORD PTR [rbp+0]
mov edx, DWORD PTR [rbp+4]
mov r8d, esi
mov r9d, F_25_0 ; h = 25.0f
mov r9d, 041C80000h ; h = 25.0f
lea rax, [clr_Win_Hdr]
mov QWORD PTR [rsp+20h], rax
call ZeroGUI__DrawFilledRect
@@ -799,13 +797,13 @@ ZeroGUI_Button PROC
mov QWORD PTR [rsp+20h], rax ; 5th arg - correct slot
call ZeroGUI__DrawFilledRect
mov BYTE PTR [ZG_hover_element], 1
jmp @@draw_text
jmp ZGB_draw_text
@@draw_idle:
lea rax, [clr_Btn_Idle]
mov QWORD PTR [rsp+20h], rax ; 5th arg - correct slot
call ZeroGUI__DrawFilledRect
@@draw_text:
ZGB_draw_text:
; if !sameLine: offset_y += sizeY + 10
movzx eax, BYTE PTR [ZG_sameLine]
test al, al
@@ -845,8 +843,8 @@ ZeroGUI_Button PROC
mov DWORD PTR [ZG_last_elem_X], eax
mov eax, DWORD PTR [rsp+34h]
mov DWORD PTR [ZG_last_elem_Y], eax
movd DWORD PTR [ZG_last_size_X], ebp
movd DWORD PTR [ZG_last_size_Y], esi
mov DWORD PTR [ZG_last_size_X], ebp
mov DWORD PTR [ZG_last_size_Y], esi
; Set first_element_pos if not yet set (first_elem_X == 0.0f)
movss xmm0, DWORD PTR [ZG_first_elem_X]
@@ -932,13 +930,13 @@ ZeroGUI_ButtonTab PROC
jmp @@tab_text
@@tab_not_active:
test BYTE PTR [rsp+38h], 1
jz @@tab_idle
jz ZGBTab_idle
lea rax, [clr_Btn_Hover]
mov QWORD PTR [rsp+20h], rax ; 5th arg
call ZeroGUI__DrawFilledRect
mov BYTE PTR [ZG_hover_element], 1
jmp @@tab_text
@@tab_idle:
ZGBTab_idle:
lea rax, [clr_Btn_Idle]
mov QWORD PTR [rsp+20h], rax ; 5th arg
call ZeroGUI__DrawFilledRect
@@ -980,8 +978,8 @@ ZeroGUI_ButtonTab PROC
mov DWORD PTR [ZG_last_elem_X], eax
mov eax, DWORD PTR [rsp+34h]
mov DWORD PTR [ZG_last_elem_Y], eax
movd DWORD PTR [ZG_last_size_X], ebp
movd DWORD PTR [ZG_last_size_Y], esi
mov DWORD PTR [ZG_last_size_X], ebp
mov DWORD PTR [ZG_last_size_Y], esi
movss xmm0, DWORD PTR [ZG_first_elem_X]
xorps xmm1, xmm1
@@ -1047,7 +1045,7 @@ ZeroGUI_Text PROC
test al, al
jnz @@text_skip_adv
movss xmm0, DWORD PTR [ZG_offset_y]
mov eax, F_25_0
mov eax, 041C80000h ; 25.0f
movd xmm1, eax
mov eax, F_10_0
movd xmm2, eax
+23 -18
View File
@@ -1,4 +1,4 @@
INCLUDE asm\include\master.inc
INCLUDE include\master.inc
.data?
@@ -51,31 +51,34 @@ ZeroInput_IsMouseClicked PROC
sub rsp, 28h
; Check mouseDown[button]
movzx rax, ecx ; button index (zero-extend to 64-bit)
movzx eax, BYTE PTR [ZI_mouseDown + rax]
mov eax, ecx ; button index (zero-extends rax)
lea rcx, [ZI_mouseDown] ; RIP-relative base → rcx
movzx eax, BYTE PTR [rcx + rax] ; mouseDown[button]
test al, al
jz @@clear_already ; not pressed -> clear + return false
; mouseDown[button] is set - check mouseDownAlready[element_id]
movzx rcx, edx ; element_id -> index (zero-extend)
movzx eax, BYTE PTR [ZI_mouseDownAlready + rcx]
mov ecx, edx ; element_id (zero-extends rcx)
lea rax, [ZI_mouseDownAlready] ; RIP-relative base → rax
movzx eax, BYTE PTR [rax + rcx] ; mouseDownAlready[element_id]
test al, al
jnz @@check_repeat ; already marked -> check repeat
; First press: set mouseDownAlready[element_id] = true, return true
mov BYTE PTR [ZI_mouseDownAlready + rcx], 1
lea rax, [ZI_mouseDownAlready]
mov BYTE PTR [rax + rcx], 1
mov al, 1
jmp @@done
@@check_repeat:
; Already pressed: return repeat flag
movzx eax, r8b ; AL = repeat
movzx eax, r8b ; AL = repeat flag
jmp @@done
@@clear_already:
; Mouse is not down: clear mouseDownAlready[element_id]
movzx rcx, edx
mov BYTE PTR [ZI_mouseDownAlready + rcx], 0
mov ecx, edx ; element_id (zero-extends rcx)
lea rax, [ZI_mouseDownAlready]
mov BYTE PTR [rax + rcx], 0
xor al, al
@@done:
add rsp, 28h
@@ -92,27 +95,29 @@ ZeroInput_IsMouseClicked ENDP
ZeroInput_IsKeyPressed PROC
sub rsp, 28h
movzx rax, ecx ; key index
movzx eax, BYTE PTR [ZI_keysDown + rax]
mov r9d, ecx ; save key index (zero-extends r9)
lea rcx, [ZI_keysDown] ; RIP-relative base → rcx
movzx eax, BYTE PTR [rcx + r9] ; keysDown[key]
test al, al
jz @@clear_already
movzx rcx, ecx
movzx eax, BYTE PTR [ZI_keysDownAlready + rcx]
lea rax, [ZI_keysDownAlready] ; RIP-relative base → rax
movzx eax, BYTE PTR [rax + r9] ; keysDownAlready[key]
test al, al
jnz @@check_repeat
mov BYTE PTR [ZI_keysDownAlready + rcx], 1
lea rax, [ZI_keysDownAlready]
mov BYTE PTR [rax + r9], 1
mov al, 1
jmp @@done
@@check_repeat:
movzx eax, dl ; AL = repeat
movzx eax, dl ; AL = repeat flag
jmp @@done
@@clear_already:
movzx rcx, ecx
mov BYTE PTR [ZI_keysDownAlready + rcx], 0
lea rax, [ZI_keysDownAlready]
mov BYTE PTR [rax + r9], 0
xor al, al
@@done:
add rsp, 28h