-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript_export.pas
More file actions
97 lines (74 loc) · 2.38 KB
/
Copy pathscript_export.pas
File metadata and controls
97 lines (74 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
unit script_export;
interface
uses BaseGameData;
function Init(dwFlags:cardinal):boolean;
implementation
const
CUIGameCustom__HideActorMenu_offset:cardinal=$47f120; //<NONPORTABLE>//
var
CUIGameCustom__ShowActorMenu_adapter_ptr:pointer;
CUIGameCustom__SwitchActorMenuState_ptr:pointer;
procedure CUIGameCustom__SwitchActorMenuState(); stdcall; //<NONPORTABLE>//
//todo: use structs!!
asm
mov eax, [ecx+$30] //CUISimpleWindow
cmp [eax+04], 0 //CUISimpleWindow.m_bShowMe
jne @shown
jmp CUIGameCustom__ShowActorMenu_adapter_ptr
@shown:
mov eax, xrgame_addr
add eax, CUIGameCustom__HideActorMenu_offset
jmp eax
end;
procedure CUIGameCustom__ShowActorMenu_adapter(); stdcall;
const
CUIGameCustom__ShowActorMenu_offset:cardinal=$47f060; //<NONPORTABLE>//
asm
mov eax, xrgame_addr
add eax, CUIGameCustom__ShowActorMenu_offset
mov ebx, ecx //ShowActorMenu òðåáóåò this â ebx, à ó íàñ îí ñåé÷àñ â ecx
jmp eax
end;
procedure CUIGameCustom__script_extension_Patch(); stdcall;
const
registrator_offset:cardinal=$480DE6; //<NONPORTABLE>//
ShowActorMenu_name:PChar = 'ShowActorMenu';
SwitchActorMenu_name:PChar = 'SwitchActorMenu';
asm
/////////////////////////////////////////////////////////////
push ecx //save ECX from modifying by registrator
push 0
push CUIGameCustom__ShowActorMenu_adapter_ptr
push ShowActorMenu_name
push eax //class_<T>*
mov ecx, xrgame_addr
add ecx, registrator_offset
call ecx
push 0
push CUIGameCustom__SwitchActorMenuState_ptr
push SwitchActorMenu_name
push eax //class_<T>*
mov ecx, xrgame_addr
add ecx, registrator_offset
call ecx
pop ecx //Restore initial ECX
/////////////////////////////////////////////////////////////
//Original code
mov ecx, eax
xor eax, eax
lea edi, [ebp-$0C]
end;
function Init(dwFlags:cardinal):boolean;
var
addr:cardinal;
begin
result:=false;
if dwFlags and FLG_PATCH_GAME >0 then begin
CUIGameCustom__ShowActorMenu_adapter_ptr:=@CUIGameCustom__ShowActorMenu_adapter;
CUIGameCustom__SwitchActorMenuState_ptr:=@CUIGameCustom__SwitchActorMenuState;
addr:=xrGame_addr+$480BC7; //<NONPORTABLE>//
if not WriteJump(addr, cardinal(@CUIGameCustom__script_extension_Patch), 7, true) then exit;
end;
result:=true;
end;
end.