Skip to content

Commit

Permalink
111
Browse files Browse the repository at this point in the history
  • Loading branch information
hzqst committed Oct 8, 2024
1 parent 98bad19 commit deb2f9e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 25 deletions.
48 changes: 30 additions & 18 deletions asext/meta_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,34 +196,46 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME /* now */,
LOG_MESSAGE(PLID, "555");

FILL_FROM_SIGNATURED_CALLER_FROM_END(server, CASDocumentation_RegisterObjectType, -1);
LOG_MESSAGE(PLID, "666");
FILL_FROM_SIGNATURED_CALLER_FROM_END(server, CASDocumentation_RegisterObjectProperty, -8);
LOG_MESSAGE(PLID, "777");
LOG_MESSAGE(PLID, "CASDocumentation_RegisterObjectType found at %p", g_pfn_CASDocumentation_RegisterObjectType);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CASDocumentation_RegisterObjectProperty, 0);
LOG_MESSAGE(PLID, "CASDocumentation_RegisterObjectProperty found at %p", g_pfn_CASDocumentation_RegisterObjectProperty);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CASDocumentation_RegisterGlobalProperty, 9);
LOG_MESSAGE(PLID, "888");
LOG_MESSAGE(PLID, "CASDocumentation_RegisterGlobalProperty found at %p", g_pfn_CASDocumentation_RegisterGlobalProperty);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CASDocumentation_RegisterObjectMethod, 0);
LOG_MESSAGE(PLID, "999");
LOG_MESSAGE(PLID, "CASDocumentation_RegisterObjectMethod found at %p", g_pfn_CASDocumentation_RegisterObjectMethod);

FILL_FROM_SIGNATURED_CALLER_FROM_END(server, CASDocumentation_RegisterObjectBehaviour, -1);
LOG_MESSAGE(PLID, "000");
LOG_MESSAGE(PLID, "CASDocumentation_RegisterObjectBehaviour found at %p", g_pfn_CASDocumentation_RegisterObjectBehaviour);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CASDocumentation_RegisterFuncDef, 0);
LOG_MESSAGE(PLID, "1111");
LOG_MESSAGE(PLID, "CASDocumentation_RegisterFuncDef found at %p", g_pfn_CASDocumentation_RegisterFuncDef);

FILL_FROM_SIGNATURED_CALLER_FROM_END(server, CASDocumentation_RegisterEnum, -13);
LOG_MESSAGE(PLID, "2222");
LOG_MESSAGE(PLID, "CASDocumentation_RegisterEnum found at %p", g_pfn_CASDocumentation_RegisterEnum);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CASDocumentation_RegisterEnumValue, 7);
LOG_MESSAGE(PLID, "3333");
LOG_MESSAGE(PLID, "CASDocumentation_RegisterEnumValue found at %p", g_pfn_CASDocumentation_RegisterEnumValue);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CASDirectoryList_CreateDirectory, 0);
LOG_MESSAGE(PLID, "4444");
LOG_MESSAGE(PLID, "CASDirectoryList_CreateDirectory found at %p", g_pfn_CASDirectoryList_CreateDirectory);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CASFunction_Create, 0);
LOG_MESSAGE(PLID, "5555");
LOG_MESSAGE(PLID, "CASFunction_Create found at %p", g_pfn_CASFunction_Create);

FILL_FROM_SIGNATURED_CALLER_FROM_END(server, CASBaseCallable_Call, -8);
LOG_MESSAGE(PLID, "6666");
LOG_MESSAGE(PLID, "CASBaseCallable_Call found at %p", g_pfn_CASBaseCallable_Call);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CASRefCountedBaseClass_InternalRelease, 3);
LOG_MESSAGE(PLID, "7777");
LOG_MESSAGE(PLID, "CASRefCountedBaseClass_InternalRelease found at %p", g_pfn_CASRefCountedBaseClass_InternalRelease);

FILL_FROM_SIGNATURED_CALLER_FROM_START(server, CScriptAny_Release, 0);
LOG_MESSAGE(PLID, "8888");
FILL_FROM_SIGNATURED_CALLER_FROM_END(server, CScriptArray_Release, -8);
LOG_MESSAGE(PLID, "CScriptAny_Release found at %p", g_pfn_CScriptAny_Release);

LOG_MESSAGE(PLID, "CScriptArray_Release found!");
FILL_FROM_SIGNATURED_CALLER_FROM_END(server, CScriptArray_Release, -8);
LOG_MESSAGE(PLID, "CScriptArray_Release found at %p", g_pfn_CScriptArray_Release);

char pattern_CASHook_VCall[] = "\x83\xEC\x2A\xE8\x2A\x2A\x2A\x2A\x81\x2A\x2A\x2A\x2A\x2A\x8B\x2A\x24\x2A\x8B\x2A\x2A\x2A\x2A\x00\x85\x2A\x74\x2A\x0F\x2A\x2A\x06";
auto CASHook_VCall = (char *)LOCATE_FROM_SIGNATURE(server, pattern_CASHook_VCall);
Expand All @@ -232,7 +244,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME /* now */,
LOG_ERROR(PLID, "CHook_VCall not found!");
return FALSE;
}
LOG_MESSAGE(PLID, "CASHook_VCall at %p!", CASHook_VCall);
LOG_MESSAGE(PLID, "CASHook_VCall found at %p!", CASHook_VCall);

//__x86_get_pc_thunk_
auto pic_chunk_call = CASHook_VCall + 3;
Expand All @@ -242,7 +254,7 @@ C_DLLEXPORT int Meta_Attach(PLUG_LOADTIME /* now */,
auto mov_ebp_addr = CASHook_VCall + 18;
g_pServerManager = (decltype(g_pServerManager))(got_plt + *(int*)(mov_ebp_addr + 2));

LOG_MESSAGE(PLID, "g_pServerManager at %p!", g_pServerManager);
LOG_MESSAGE(PLID, "g_pServerManager found at %p!", g_pServerManager);

}
else
Expand Down
2 changes: 1 addition & 1 deletion asext/signatures.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#define CASDocumentation_RegisterObjectType_Signature "\xC7\x44\x24\x2A\x01\x00\x04\x00\xC7\x44\x24\x2A\x00\x00\x00\x00\x8D\x2A\x2A\x2A\x2A\x2A\x89\x2A\x2A\x2A\x8D\x2A\x2A\x2A\x2A\x2A\x89\x2A\x2A\x2A\x8B\x2A\x2A\x2A\x2A\x00\x00\x89\x04\x24\xE8"
#define CASDocumentation_RegisterObjectType_Symbol "_ZN16CASDocumentation18RegisterObjectTypeEPKcS1_im"

#define CASDocumentation_RegisterObjectProperty_Signature "\x6A\x04\x8D\x2A\x2A\x2A\x2A\x2A\x2A\x8B\x2A\x2A\x2A\x2A\x2A\x2A\x8D\x2A\x2A\x2A\x2A\x2A\x2A\x2A\xE8\x2A\x2A\x2A\x2A\x83\xC4\x14"
#define CASDocumentation_RegisterObjectProperty_Signature "\xE8\x2A\x2A\x2A\x2A\xC7\x44\x24\x2A\x44\x02\x00\x00"
#define CASDocumentation_RegisterObjectProperty_Symbol "_ZN16CASDocumentation22RegisterObjectPropertyEPKcS1_S1_i"

#define CASDocumentation_RegisterGlobalProperty_Signature "\x8B\x2A\x2A\x2A\x89\x04\x24\x89\x2A\xE8\x2A\x2A\x2A\x2A\x83\xC4\x5C\x2A\x2A\x2A\x2A\xC3"
Expand Down
8 changes: 2 additions & 6 deletions metamod/signatures_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

#define PRIVATE_FUNCTION_EXTERN(name) extern fn##name g_pfn_##name; extern fn##name g_call_original_##name;

#ifdef _WIN32

#define LOCATE_FROM_SIGNATURE(dll, sig) gpMetaUtilFuncs->pfnSearchPattern(dll##Base, gpMetaUtilFuncs->pfnGetImageSize(dll##Base), sig, sizeof(sig) - 1)
#define LOCATE_FROM_SIGNATURE_FROM_FUNCTION(func, size, sig) gpMetaUtilFuncs->pfnSearchPattern(func, size, sig, sizeof(sig) - 1)
#define LOCATE_FROM_SYMBOL(dll, sym) gpMetaUtilFuncs->pfnGetProcAddress(dll##Handle, sym)

#ifdef _WIN32

#define ENGINE_DLL_NAME "hw.dll"

#else
Expand All @@ -25,10 +25,6 @@
#define _ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
#endif

#define LOCATE_FROM_SIGNATURE(dll, sig) gpMetaUtilFuncs->pfnSearchPattern(dll##Base, gpMetaUtilFuncs->pfnGetImageSize(dll##Base), sig, sizeof(sig) - 1)
#define LOCATE_FROM_SIGNATURE_FROM_FUNCTION(func, size, sig) gpMetaUtilFuncs->pfnSearchPattern(func, size, sig, sizeof(sig) - 1)
#define LOCATE_FROM_SYMBOL(dll, sym) gpMetaUtilFuncs->pfnGetProcAddress(dll##Handle, sym)

#define ENGINE_DLL_NAME "hw.so"

#endif
Expand Down

0 comments on commit deb2f9e

Please sign in to comment.