Optimize assembly payloads

This commit is contained in:
mkrsym1 2023-06-26 12:25:44 +03:00
parent 851ebb5b9a
commit 33f7dd89a9
2 changed files with 5 additions and 16 deletions

View File

@ -18,8 +18,7 @@ main: ; Replacement entry point
mov rcx, rsi ; kernel32.dll mov rcx, rsi ; kernel32.dll
lea rdx, [rel s_LoadLibraryA] lea rdx, [rel s_LoadLibraryA]
mov rax, rdi ; *GetProcAddress call rdi ; rax = *LoadLibraryA
call rax ; rax = *LoadLibraryA
lea rcx, [rel dllPath] lea rcx, [rel dllPath]
call rax ; LoadLibraryA(dllPath) call rax ; LoadLibraryA(dllPath)
@ -27,8 +26,7 @@ main: ; Replacement entry point
mov rcx, rsi ; kernel32.dll mov rcx, rsi ; kernel32.dll
lea rdx, [rel s_GetModuleHandleA] lea rdx, [rel s_GetModuleHandleA]
mov rax, rdi ; *GetProcAddress call rdi ; rax = *GetModuleHandle
call rax ; rax = *GetModuleHandle
mov r12, rax mov r12, rax
mov rcx, 0 mov rcx, 0
@ -37,21 +35,18 @@ main: ; Replacement entry point
mov rcx, rsi ; kernel32.dll mov rcx, rsi ; kernel32.dll
lea rdx, [rel s_GetCommandLineW] lea rdx, [rel s_GetCommandLineW]
mov rax, rdi ; *GetProcAddress call rdi ; rax = *GetCommandLineW
call rax ; rax = *GetCommandLineW
call rax ; rax = command line call rax ; rax = command line
mov r14, rax mov r14, rax
lea rcx, [rel s_UnityPlayer.dll] lea rcx, [rel s_UnityPlayer.dll]
mov rax, r12 ; *GetModuleHandleA call r12 ; rax = UnityPlayer.dll
call rax ; rax = UnityPlayer.dll
mov rcx, rax mov rcx, rax
lea rdx, [rel s_UnityMain] lea rdx, [rel s_UnityMain]
mov rax, rdi ; *GetProcAddress call rdi ; rax = *UnityMain
call rax ; rax = *UnityMain
mov rcx, r13 ; .exe base address mov rcx, r13 ; .exe base address
mov rdx, 0 ; hPrevInstance - 0 mov rdx, 0 ; hPrevInstance - 0

View File

@ -2,8 +2,6 @@ BITS 64
main: ; Replacement entry point main: ; Replacement entry point
push rsi push rsi
push rdi
sub rsp, 8h
call GetKernel32ModuleHandle call GetKernel32ModuleHandle
@ -11,20 +9,16 @@ main: ; Replacement entry point
mov rcx, rax mov rcx, rax
call GetAddressOf_GetProcAddress call GetAddressOf_GetProcAddress
mov rdi, rax ; *GetProcAddress
mov rcx, rsi ; kernel32.dll mov rcx, rsi ; kernel32.dll
lea rdx, [rel s_LoadLibraryA] lea rdx, [rel s_LoadLibraryA]
mov rax, rdi ; *GetProcAddress
call rax ; rax = *LoadLibraryA call rax ; rax = *LoadLibraryA
lea rcx, [rel dllPath] lea rcx, [rel dllPath]
call rax ; LoadLibraryA(dllPath) call rax ; LoadLibraryA(dllPath)
add rsp, 8h
pop rdi
pop rsi pop rsi
ret ret