Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook ProcessEvent #5

Closed
rkr35 opened this issue Jun 24, 2020 · 0 comments · Fixed by #8
Closed

Hook ProcessEvent #5

rkr35 opened this issue Jun 24, 2020 · 0 comments · Fixed by #8
Labels
enhancement New feature or request

Comments

@rkr35
Copy link
Owner

rkr35 commented Jun 24, 2020

I believe the following is the beginning of ProcessEvent:

0115D9F0 | 55 | push ebp |
0115D9F1 | 8BEC | mov ebp,esp |
0115D9F3 | 6A FF | push FFFFFFFF |
0115D9F5 | 68 B8E4FD01 | push borderlandspresequel.1FDE4B8 |  
0115D9FA | 64:A1 00000000 | mov eax,dword ptr fs:[0] |  
0115DA00 | 50 | push eax |  
0115DA01 | 83EC 50 | sub esp,50 |  
0115DA04 | A1 E0834902 | mov eax,dword ptr ds:[24983E0] |  
0115DA09 | 33C5 | xor eax,ebp |  
0115DA0B | 8945 F0 | mov dword ptr ss:[ebp-10],eax |  
0115DA0E | 53 | push ebx |  
0115DA0F | 56 | push esi |  
0115DA10 | 57 | push edi |  
0115DA11 | 50 | push eax |  
0115DA12 | 8D45 F4 | lea eax,dword ptr ss:[ebp-C] |  
0115DA15 | 64:A3 00000000 | mov dword ptr fs:[0],eax |  
0115DA1B | 8BF1 | mov esi,ecx |  
0115DA1D | 8975 EC | mov dword ptr ss:[ebp-14],esi |  
0115DA20 | 8B7D 08 | mov edi,dword ptr ss:[ebp+8] |  
0115DA23 | F787 80000000 02040000 | test dword ptr ds:[edi+80],402 |  

And here's one of the call sites:

mov esi,dword ptr ds:[ebx] ; Get pointer to first vtable entry of UObject.
push 0
lea edx,dword ptr ss:[ebp+8]
push edx
push 0
push eax
push ecx
mov ecx,ebx
movss dword ptr ss:[ebp+8],xmm0
call borderlandspresequel.10A0920
mov edx,dword ptr ds:[esi+E8] ; Index into vtable to get address of ProcessEvent
push eax
mov ecx,ebx ; ecx = ebx = this pointer = UObject we're calling ProcessEvent on
call edx ; Call ProcessEvent

The [esi+E8] suggests that the vtable index for ProcessEvent is 0xE8 / 4 = 58.

I'm assuming our detoured function will need to use the fastcall calling convention and ignore edx as the second parameter since Rust doesn't have a stable thiscall calling convention I could use in this scenario. Otherwise, I'm not sure how we would access the this pointer (which is the UObject that is calling ProcessEvent as a member function) that the game will store in ecx.

@rkr35 rkr35 added the enhancement New feature or request label Jun 24, 2020
@rkr35 rkr35 changed the title Create signature for ProcessEvent Hook ProcessEvent Jun 26, 2020
@rkr35 rkr35 mentioned this issue Jun 28, 2020
@rkr35 rkr35 closed this as completed in #8 Jun 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant