mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-15 20:37:42 +01:00
Changes to Dalamud Boot DLL so that it works in WINE (#1111)
* Changes to Dalamud Boot DLL so that it works in WINE * Make asm clearer
This commit is contained in:
parent
386e5f245c
commit
0cc28fb39d
7 changed files with 235 additions and 182 deletions
82
Dalamud.Boot/rewrite_entrypoint_thunks.asm
Normal file
82
Dalamud.Boot/rewrite_entrypoint_thunks.asm
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
PUBLIC EntryPointReplacement
|
||||
PUBLIC RewrittenEntryPoint_Standalone
|
||||
PUBLIC RewrittenEntryPoint
|
||||
|
||||
; 06 and 07 are invalid opcodes
|
||||
; CC is int3 = bp
|
||||
; using 0CCCCCCCCCCCCCCCCh as function terminator
|
||||
; using 00606060606060606h as placeholders
|
||||
|
||||
TERMINATOR = 0CCCCCCCCCCCCCCCCh
|
||||
PLACEHOLDER = 00606060606060606h
|
||||
|
||||
.code
|
||||
|
||||
EntryPointReplacement PROC
|
||||
start:
|
||||
; rsp % 0x10 = 0x08
|
||||
lea rax, [start]
|
||||
push rax
|
||||
|
||||
; rsp % 0x10 = 0x00
|
||||
mov rax, PLACEHOLDER
|
||||
|
||||
; this calls RewrittenEntryPoint_Standalone
|
||||
jmp rax
|
||||
|
||||
dq TERMINATOR
|
||||
EntryPointReplacement ENDP
|
||||
|
||||
RewrittenEntryPoint_Standalone PROC
|
||||
start:
|
||||
; stack is aligned to 0x10; see above
|
||||
sub rsp, 20h
|
||||
lea rcx, [embeddedData]
|
||||
add rcx, qword ptr [nNethostOffset]
|
||||
call qword ptr [pfnLoadLibraryW]
|
||||
|
||||
lea rcx, [embeddedData]
|
||||
add rcx, qword ptr [nDalamudOffset]
|
||||
call qword ptr [pfnLoadLibraryW]
|
||||
|
||||
mov rcx, rax
|
||||
lea rdx, [pcszEntryPointName]
|
||||
call qword ptr [pfnGetProcAddress]
|
||||
|
||||
mov rcx, qword ptr [pRewrittenEntryPointParameters]
|
||||
; this calls RewrittenEntryPoint
|
||||
jmp rax
|
||||
|
||||
pfnLoadLibraryW:
|
||||
dq PLACEHOLDER
|
||||
|
||||
pfnGetProcAddress:
|
||||
dq PLACEHOLDER
|
||||
|
||||
pRewrittenEntryPointParameters:
|
||||
dq PLACEHOLDER
|
||||
|
||||
nNethostOffset:
|
||||
dq PLACEHOLDER
|
||||
|
||||
nDalamudOffset:
|
||||
dq PLACEHOLDER
|
||||
|
||||
pcszEntryPointName:
|
||||
db "RewrittenEntryPoint", 0
|
||||
|
||||
embeddedData:
|
||||
|
||||
dq TERMINATOR
|
||||
RewrittenEntryPoint_Standalone ENDP
|
||||
|
||||
EXTERN RewrittenEntryPoint_AdjustedStack :PROC
|
||||
|
||||
RewrittenEntryPoint PROC
|
||||
; stack is aligned to 0x10; see above
|
||||
call RewrittenEntryPoint_AdjustedStack
|
||||
add rsp, 20h
|
||||
ret
|
||||
RewrittenEntryPoint ENDP
|
||||
|
||||
END
|
||||
Loading…
Add table
Add a link
Reference in a new issue