-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Abc Dr
committed
Jan 8, 2024
1 parent
456dcc9
commit 2d41207
Showing
15 changed files
with
26 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
#pragma once | ||
#include "progdefs.h" | ||
|
||
typedef struct hookitem_s { | ||
hook_t* pHook; | ||
void* pfnCall; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,93 +1,12 @@ | ||
#pragma once | ||
|
||
#define IMPORT_FUNCTION_DEFINE(name) fn##name name; | ||
|
||
#define IMPORT_FUNCTION_EXTERN(name) extern fn##name name; | ||
|
||
#define PRIVATE_FUNCTION_DEFINE(name) fn##name g_pfn_##name; fn##name g_call_original_##name; | ||
|
||
#define PRIVATE_FUNCTION_EXTERN(name) extern fn##name g_pfn_##name; extern fn##name g_call_original_##name; | ||
#include "signatures_template.h" | ||
|
||
#ifdef _WIN32 | ||
|
||
#define LOCATE_FROM_SIGNATURE(dll, sig) gpMetaUtilFuncs->pfnSearchPattern(dll##Base, gpMetaUtilFuncs->pfnGetImageSize(dll##Base), sig, sizeof(sig) - 1) | ||
|
||
#define SC_SERVER_DUMMYVAR int dummy = 0; | ||
#define SERVER_DLL_NAME "server.dll" | ||
#else | ||
|
||
#ifndef _ARRAYSIZE | ||
#define _ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0])) | ||
#endif | ||
|
||
#define LOCATE_FROM_SIGNATURE(dll, sig) DLSYM(dll##Handle, sig) | ||
|
||
#define ENGINE_DLL_NAME "hw.so" | ||
#define SC_SERVER_DUMMYVAR | ||
#define SERVER_DLL_NAME "server.so" | ||
|
||
#endif | ||
|
||
#define IMPORT_FUNCTION_DLSYM(dll, name) name = (decltype(name))DLSYM((DLHANDLE)dll##Handle, #name);\ | ||
if (!name)\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to get " #name " from " #dll " dll !");\ | ||
return FALSE;\ | ||
} | ||
|
||
#define FILL_FROM_SIGNATURE(dll, name) g_pfn_##name = g_call_original_##name = (decltype(g_pfn_##name))LOCATE_FROM_SIGNATURE(dll, name##_Signature);\ | ||
if (!g_pfn_##name)\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to locate " #name " from " #dll " dll !");\ | ||
return FALSE;\ | ||
} | ||
|
||
#define FILL_FROM_SIGNATURED_CALLER_FROM_START(dll, name, offset) auto Caller_of_##name = (char *)LOCATE_FROM_SIGNATURE(dll, name##_Signature);\ | ||
if (!Caller_of_##name)\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to locate Caller of " #name " from " #dll " dll !");\ | ||
return FALSE;\ | ||
}\ | ||
g_pfn_##name = g_call_original_##name = (decltype(g_pfn_##name))gpMetaUtilFuncs->pfnGetNextCallAddr(Caller_of_##name + (offset), 1);\ | ||
if (!gpMetaUtilFuncs->pfnIsAddressInModuleRange((void *)g_pfn_##name, dll##Base))\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to locate " #name " from " #dll " dll !"); \ | ||
return FALSE; \ | ||
} | ||
|
||
#define FILL_FROM_SIGNATURED_CALLER_FROM_END(dll, name, offset) auto Caller_of_##name = (char *)LOCATE_FROM_SIGNATURE(dll, name##_Signature);\ | ||
if (!Caller_of_##name)\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to locate Caller of " #name " from " #dll " dll !");\ | ||
return FALSE;\ | ||
}\ | ||
g_pfn_##name = g_call_original_##name = (decltype(g_pfn_##name))gpMetaUtilFuncs->pfnGetNextCallAddr(Caller_of_##name + (sizeof(name##_Signature) - 1) + (offset), 1);\ | ||
if (!gpMetaUtilFuncs->pfnIsAddressInModuleRange((void *)g_pfn_##name, dll##Base))\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to locate " #name " from " #dll " dll !"); \ | ||
return FALSE; \ | ||
} | ||
|
||
#define VAR_FROM_SIGNATURE(dll, name) name = (decltype(name))LOCATE_FROM_SIGNATURE(dll, name##_Signature);\ | ||
if (!name)\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to locate " #name " from " #dll " dll !");\ | ||
return FALSE;\ | ||
} | ||
|
||
#define VAR_FROM_SIGNATURE_FROM_START(dll, name, offset) auto name##_Temp = (char *)LOCATE_FROM_SIGNATURE(dll, name##_Signature);\ | ||
if (!name##_Temp)\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to locate " #name " from " #dll " dll !");\ | ||
return FALSE;\ | ||
}\ | ||
name = *(decltype(name) *)(name##_Temp + offset); | ||
|
||
#define VAR_FROM_SIGNATURE_FROM_END(dll, name, offset) auto name##_Temp = (char *)LOCATE_FROM_SIGNATURE(dll, name##_Signature);\ | ||
if (!name##_Temp)\ | ||
{\ | ||
LOG_ERROR(PLID, "Failed to locate " #name " from " #dll " dll !");\ | ||
return FALSE;\ | ||
}\ | ||
name = *(decltype(name) *)(name##_Temp + (sizeof(name##_Signature) - 1) + offset); | ||
|
||
#define INSTALL_INLINEHOOK(name) g_phook_##name = gpMetaUtilFuncs->pfnInlineHook((void*)g_pfn_##name, (void*)New##name, (void**)&g_call_original_##name, true) | ||
#define UNINSTALL_HOOK(name) if(g_phook_##name) {gpMetaUtilFuncs->pfnUnHook(g_phook_##name); g_phook_##name = NULL;} | ||
|
||
#define FILL_AND_HOOK(dll, name) FILL_FROM_SIGNATURE(dll, name);INSTALL_INLINEHOOK(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters