-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNativeInvoker.cpp
More file actions
42 lines (28 loc) · 823 Bytes
/
NativeInvoker.cpp
File metadata and controls
42 lines (28 loc) · 823 Bytes
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
//NativeInvoker.cpp
#include "stdafx.h"
static NativeManagerContext g_context;
static UINT64 g_hash;
void(*scrNativeCallContext::SetVectorResults)(scrNativeCallContext*) = nullptr;
void nativeInit(UINT64 hash) {
g_context.Reset();
g_hash = hash;
}
void nativePush64(UINT64 value) {
g_context.Push(value);
}
uint64_t * nativeCall() {
auto fn = Hooking::GetNativeHandler(g_hash);
if (fn != 0) {
static void* exceptionAddress;
__try
{
fn(&g_context);
scrNativeCallContext::SetVectorResults(&g_context);
}
__except (exceptionAddress = (GetExceptionInformation())->ExceptionRecord->ExceptionAddress, EXCEPTION_EXECUTE_HANDLER)
{
Log::Error("executing native 0x%016llx at address %p.", g_hash, exceptionAddress);
}
}
return reinterpret_cast<uint64_t*>(g_context.GetResultPointer());
}