mirror of
https://gitlab.com/hashborgir/d2tweaks-rnd2k.git
synced 2025-10-13 16:34:22 -05:00
Stats display refactor using ini file done.
This commit is contained in:
61
vendor/D2Template/D2Template.h
vendored
61
vendor/D2Template/D2Template.h
vendored
@@ -60,51 +60,50 @@ extern DWORD DLLBASE_SGD2FREERES;
|
||||
|
||||
struct DLLBaseStrc
|
||||
{
|
||||
char* szName;
|
||||
DWORD dwAddress;
|
||||
char* szName;
|
||||
DWORD dwAddress;
|
||||
};
|
||||
|
||||
struct DLLPatchStrc
|
||||
{
|
||||
int nDLL;
|
||||
DWORD dwAddress;
|
||||
DWORD dwData;
|
||||
BOOL bRelative;
|
||||
size_t nPatchSize;
|
||||
int nDLL;
|
||||
DWORD dwAddress;
|
||||
DWORD dwData;
|
||||
BOOL bRelative;
|
||||
size_t nPatchSize;
|
||||
};
|
||||
|
||||
enum D2TEMPLATE_DLL_FILES
|
||||
{
|
||||
D2DLL_BINKW32,
|
||||
D2DLL_BNCLIENT,
|
||||
D2DLL_D2CLIENT,
|
||||
D2DLL_D2CMP,
|
||||
D2DLL_D2COMMON,
|
||||
D2DLL_D2DDRAW,
|
||||
D2DLL_D2DIRECT3D,
|
||||
D2DLL_D2GAME,
|
||||
D2DLL_D2GDI,
|
||||
D2DLL_D2GFX,
|
||||
D2DLL_D2GLIDE,
|
||||
D2DLL_D2LANG,
|
||||
D2DLL_D2LAUNCH,
|
||||
D2DLL_D2MCPCLIENT,
|
||||
D2DLL_D2MULTI,
|
||||
D2DLL_D2NET,
|
||||
D2DLL_D2SOUND,
|
||||
D2DLL_D2WIN,
|
||||
D2DLL_FOG,
|
||||
D2DLL_IJL11,
|
||||
D2DLL_SMACKW32,
|
||||
D2DLL_STORM,
|
||||
D2DLL_BINKW32,
|
||||
D2DLL_BNCLIENT,
|
||||
D2DLL_D2CLIENT,
|
||||
D2DLL_D2CMP,
|
||||
D2DLL_D2COMMON,
|
||||
D2DLL_D2DDRAW,
|
||||
D2DLL_D2DIRECT3D,
|
||||
D2DLL_D2GAME,
|
||||
D2DLL_D2GDI,
|
||||
D2DLL_D2GFX,
|
||||
D2DLL_D2GLIDE,
|
||||
D2DLL_D2LANG,
|
||||
D2DLL_D2LAUNCH,
|
||||
D2DLL_D2MCPCLIENT,
|
||||
D2DLL_D2MULTI,
|
||||
D2DLL_D2NET,
|
||||
D2DLL_D2SOUND,
|
||||
D2DLL_D2WIN,
|
||||
D2DLL_FOG,
|
||||
D2DLL_IJL11,
|
||||
D2DLL_SMACKW32,
|
||||
D2DLL_STORM,
|
||||
D2DLL_UTILITY,
|
||||
D2DLL_PLUGY,
|
||||
D2DLL_D2EXPRES,
|
||||
D2DLL_SGD2FREERES,
|
||||
D2DLL_INVALID
|
||||
D2DLL_INVALID
|
||||
};
|
||||
|
||||
|
||||
static DLLBaseStrc gptDllFiles[] =
|
||||
{
|
||||
{"Binkw32.dll", NULL},
|
||||
|
6
vendor/D2Template/D2TemplateConstants.h
vendored
6
vendor/D2Template/D2TemplateConstants.h
vendored
@@ -745,8 +745,8 @@
|
||||
// LNG_POR,// Portuguese
|
||||
// LNG_ITA,// Italian
|
||||
// LNG_JPN,// Japanese
|
||||
// LNG_KOR,// Korean
|
||||
// LNG_SIN,//
|
||||
// LNG_KOR,// Korean
|
||||
// LNG_SIN,//
|
||||
// LNG_CHI,// Chinese
|
||||
// LNG_POL,// Polish
|
||||
// LNG_RUS,// Russian
|
||||
@@ -1138,7 +1138,7 @@
|
||||
// DEXTERITY,
|
||||
// VITALITY,
|
||||
// ENERGY,
|
||||
// MAXMANA,
|
||||
// MAXMANA,
|
||||
// MAXMANA_PERCENT,
|
||||
// MAXHP,
|
||||
// MAXHP_PERCENT,
|
||||
|
2
vendor/D2Template/D2TemplateDataTables.h
vendored
2
vendor/D2Template/D2TemplateDataTables.h
vendored
@@ -48,7 +48,7 @@ struct D2MonstatsTXT;
|
||||
|
||||
struct D2MonstatsTXT
|
||||
{
|
||||
//...
|
||||
//...
|
||||
};
|
||||
|
||||
// end of file --------------------------------------------------------------
|
||||
|
2
vendor/D2Template/D2TemplatePacketDef.h
vendored
2
vendor/D2Template/D2TemplatePacketDef.h
vendored
@@ -21,7 +21,7 @@ struct D2GSPacketSrv03;
|
||||
|
||||
struct D2GSPacketClt01
|
||||
{
|
||||
//...
|
||||
//...
|
||||
};
|
||||
|
||||
// end of file --------------------------------------------------------------
|
||||
|
12
vendor/D2Template/D2TemplatePtrs.h
vendored
12
vendor/D2Template/D2TemplatePtrs.h
vendored
@@ -20,7 +20,7 @@
|
||||
|
||||
#define D2FUNC(DLL, NAME, RETURN, CONV, ARGS, OFFSET) typedef RETURN (CONV##* DLL##_##NAME##_t) ARGS; static DLL##_##NAME##_t DLL##_##NAME = (OFFSET < 0) ? ((DLL##_##NAME##_t)GetProcAddress((HMODULE)DLLBASE_##DLL, (LPCSTR)-(OFFSET))) : (DLL##_##NAME##_t)(DLLBASE_##DLL + OFFSET); ///
|
||||
#define D2VAR(DLL, NAME, TYPE, OFFSET) typedef TYPE DLL##_##NAME##_vt; static DLL##_##NAME##_vt * DLL##_##NAME = (DLL##_##NAME##_vt *)(DLLBASE_##DLL + OFFSET); ///
|
||||
#define D2PTR(DLL, NAME, OFFSET) static DWORD NAME = (DLLBASE_##DLL + OFFSET);
|
||||
#define D2PTR(DLL, NAME, OFFSET) static DWORD NAME = (DLLBASE_##DLL + OFFSET);
|
||||
|
||||
extern DWORD __fastcall GetDllOffset(char* ModuleName, DWORD BaseAddress, int Offset); ///
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -149,9 +149,9 @@ extern DWORD __fastcall GetDllOffset(char* ModuleName, DWORD BaseAddress, int Of
|
||||
//extern s_shifting shifting;
|
||||
//
|
||||
////#ifdef MSVC
|
||||
//#define FASTCALL __fastcall
|
||||
//#define FASTCALL __fastcall
|
||||
////#else
|
||||
////#define FASTCALL __msfastcall
|
||||
////#define FASTCALL __msfastcall
|
||||
////#endif
|
||||
//#define STDCALL __stdcall
|
||||
//#define FCT_ASM(N) __declspec(naked) void N() {__asm{
|
||||
@@ -216,7 +216,7 @@ extern DWORD __fastcall GetDllOffset(char* ModuleName, DWORD BaseAddress, int Of
|
||||
////6FAECD28 | 53 | push ebx | ebx == 0
|
||||
////6FAECD29 | 53 | push ebx | ebx == 0
|
||||
////6FAECD2A | BA 18000000 | mov edx, 18 |
|
||||
////6FAECD2F | B1 4F | mov cl, 4F |
|
||||
////6FAECD2F | B1 4F | mov cl, 4F |
|
||||
////6FAECD31 | 891D 505BBB6F | mov dword ptr ds:[6FBB5B50], ebx | ebx == 0
|
||||
////6FAECD37 | E8 A40CFCFF | call d2client.6FAAD9E0 |
|
||||
//D2FUNC(D2CLIENT, SendToServer7, void, __fastcall, (BYTE type, DWORD num, DWORD unk1, DWORD unk2), 0xD9E0)
|
||||
@@ -296,7 +296,7 @@ extern DWORD __fastcall GetDllOffset(char* ModuleName, DWORD BaseAddress, int Of
|
||||
//// 6FACBAF0 | A1 E419BB6F | mov eax, dword ptr ds:[D2Client.6FBB19E4] // 1.10
|
||||
//
|
||||
////020D90 6F620D90 10010 DRLG_GetLevelDefsRecord int nLevelNo
|
||||
////Unique fastcall (int nLevelNo) __fastcall DRLG_GetLevelDefsRecord(int nLevelNo)
|
||||
////Unique fastcall (int nLevelNo) __fastcall DRLG_GetLevelDefsRecord(int nLevelNo)
|
||||
////6F620D90 DRLG_GetLevelDefsRecord 6F620D90 __fastcall DRLG_GetLevelDefsRecord(int nLevelNo)
|
||||
//
|
||||
////6FAC5884 $+0x25884 | E8 C3910900 | call <JMP.&D2Common#10010> // 1.09 InitAutomapLayer
|
||||
@@ -326,7 +326,7 @@ extern DWORD __fastcall GetDllOffset(char* ModuleName, DWORD BaseAddress, int Of
|
||||
//#define D2FUNCPTR(DLL,NAME,t1,t2,OFFSET) typedef t1 DLL##_##NAME##_t t2; DLL##_##NAME##_t *DLL##_##NAME = (DLL##_##NAME##_t *)GetDllOffset(#DLL, DLLBASE_##DLL, OFFSET);
|
||||
//#define D2VARPTR(DLL,NAME,t1,OFFSET) typedef t1 DLL##_##NAME##_t; DLL##_##NAME##_t *p_##DLL##_##NAME = (DLL##_##NAME##_t *)GetDllOffset(#DLL, DLLBASE_##DLL, OFFSET);
|
||||
////#define D2ASMPTR(d1,v1,o1) DWORD d1##_##v1 = DLLOFFSET(d1,o1);
|
||||
////#define D2PTR(DLL, NAME, OFFSET) DWORD NAME __attribute__((weak)) = GetDllOffset(#DLL, DLLBASE_##DLL, OFFSET);
|
||||
////#define D2PTR(DLL, NAME, OFFSET) DWORD NAME __attribute__((weak)) = GetDllOffset(#DLL, DLLBASE_##DLL, OFFSET);
|
||||
////D2VAR(D2CLIENT, pDrlgAct, DrlgAct *, 0x6FBB0BE4)
|
||||
////D2VAR(D2CLIENT, pPlayerUnit, UnitAny *, 0x6FBC63F8)
|
||||
////
|
||||
|
68
vendor/D2Template/D2TemplateStructs.h
vendored
68
vendor/D2Template/D2TemplateStructs.h
vendored
@@ -1337,7 +1337,7 @@
|
||||
// DWORD dwMainIndex; //0x18
|
||||
// DWORD dwSubIndex; //0x1C
|
||||
// DWORD dwFrame; //0x20
|
||||
// BYTE _1a; //0x24 DT1's unknown_a ...
|
||||
// BYTE _1a; //0x24 DT1's unknown_a ...
|
||||
// BYTE _1c; //0x25
|
||||
// BYTE _1b; //0x26
|
||||
// BYTE _1d; //0x27
|
||||
@@ -1347,7 +1347,7 @@
|
||||
// DWORD _18; //0x44
|
||||
// DWORD dwDataPtr; //0x48 pointer to sub-block headers
|
||||
// DWORD dwSize; //0x4C length of the sub-blocks
|
||||
// DWORD dwSubBlocks; //0x50
|
||||
// DWORD dwSubBlocks; //0x50
|
||||
// DT1SubBlock* pBlocks; //0x54
|
||||
// char* szTileName; //0x58
|
||||
// DWORD **ptBlock; //0x5C <not sure - maybe its a struct>
|
||||
@@ -3209,7 +3209,7 @@
|
||||
// // UnitAny *pTargetUnit; //+58
|
||||
// //} *pPos; // +2c
|
||||
// DWORD _2b[11];
|
||||
// StatsList * ptStatsList; // 0x5C
|
||||
// StatsList * ptStatsList; // 0x5C
|
||||
// UnitInventory *pInventory; //+60
|
||||
// DWORD _4b[12];
|
||||
// DWORD nOwnerType; // +94
|
||||
@@ -3382,17 +3382,17 @@
|
||||
// char szAccountName[0x30];
|
||||
// char szCharName[0x18];
|
||||
// char szRealmName[0x18];
|
||||
// BYTE _2[0x102];//+E8
|
||||
// //BYTE nGameMode; //+1EA
|
||||
// BYTE _2[0x102];//+E8
|
||||
// //BYTE nGameMode; //+1EA
|
||||
// struct
|
||||
// {
|
||||
// BYTE nCharStat:2;
|
||||
// BYTE nHardcore:2;
|
||||
// BYTE _unk1:1;
|
||||
// BYTE nExpansion:1;
|
||||
// BYTE nLadder:2;
|
||||
// };//+1EA
|
||||
// BYTE nReadyAct; //+1EB quest info
|
||||
// BYTE nLadder:2;
|
||||
// };//+1EA
|
||||
// BYTE nReadyAct; //+1EB quest info
|
||||
// BYTE _3[0x3B];
|
||||
// char szServerVersion[24];//227 battle net gameversion
|
||||
// char szGamePassword[0x18];//+23F
|
||||
@@ -3453,16 +3453,16 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
////struct Stats {
|
||||
//// WORD Param;
|
||||
//// WORD StatID;
|
||||
//// DWORD Value;
|
||||
////};
|
||||
////struct Stats {
|
||||
//// WORD Param;
|
||||
//// WORD StatID;
|
||||
//// DWORD Value;
|
||||
////};
|
||||
//
|
||||
//struct StatsInfo {
|
||||
// Stats *pStats; // pointer to an array of Stats structs.
|
||||
// WORD nUsed; // how many Stats in array
|
||||
// WORD nSize; // size allocated in Stats
|
||||
// Stats *pStats; // pointer to an array of Stats structs.
|
||||
// WORD nUsed; // how many Stats in array
|
||||
// WORD nSize; // size allocated in Stats
|
||||
//};
|
||||
//
|
||||
//struct StatsList {
|
||||
@@ -3474,11 +3474,11 @@
|
||||
// DWORD _4; // 0x38
|
||||
// StatsList *pNext; // 0x3C
|
||||
//
|
||||
// StatsList *pSetList; // +40
|
||||
// StatsList *pSetList; // +40
|
||||
// DWORD _5;
|
||||
// StatsInfo sStats1; // +48
|
||||
// StatsInfo sStats2; // +50 unused ???
|
||||
// DWORD *ptStateFlags; //+58 - get with 10487(ptUnit,id) return ptUnit->ptStatsList->ptStateFlags[id/32]&(1<<(id%31))
|
||||
// StatsInfo sStats1; // +48
|
||||
// StatsInfo sStats2; // +50 unused ???
|
||||
// DWORD *ptStateFlags; //+58 - get with 10487(ptUnit,id) return ptUnit->ptStatsList->ptStateFlags[id/32]&(1<<(id%31))
|
||||
//};
|
||||
//
|
||||
//// end of file --------------------------------------------------------------
|
||||
@@ -3761,7 +3761,7 @@
|
||||
//// uint8_t uk4[0x08]; //+54
|
||||
//// stats* stats; //+5C
|
||||
//// uint8_t pad1[0x24];
|
||||
//// inventory* inventory; //+84 //+60
|
||||
//// inventory* inventory; //+84 //+60
|
||||
//// uint8_t uk5[0x1C]; //+64
|
||||
//// game* game; //+80
|
||||
//// uint8_t uk6[0x24]; //+84
|
||||
@@ -3892,9 +3892,9 @@
|
||||
////ITEMFLAG_FROMPLAYER = 0x01000000,
|
||||
////ITEMFLAG_RUNEuint16_t = 0x04000000
|
||||
////*/
|
||||
//// uint32_t guid1; //+1C Global Unique ID 1
|
||||
//// uint32_t guid2; //+20 Global Unique ID 2
|
||||
//// uint32_t guid3; //+24 Global Unique ID 3
|
||||
//// uint32_t guid1; //+1C Global Unique ID 1
|
||||
//// uint32_t guid2; //+20 Global Unique ID 2
|
||||
//// uint32_t guid3; //+24 Global Unique ID 3
|
||||
//// uint32_t unique_id; //+28
|
||||
//// uint8_t ilvl; //+2C
|
||||
//// uint8_t uk1[0x03]; //+2D
|
||||
@@ -3931,7 +3931,7 @@
|
||||
//// uint8_t item_data3; //+47 //D2Common10854 D2Common10853
|
||||
//// uint8_t p_ear_level; //+48
|
||||
//// uint8_t var_gfx; //+49
|
||||
//// char i_name[0x12]; //+4A //inscribed/ear name
|
||||
//// char i_name[0x12]; //+4A //inscribed/ear name
|
||||
//// inventory* inventory; //+5C
|
||||
//// unit* pt_prev_item; //+60
|
||||
//// unit* pt_next_item; //+64
|
||||
@@ -3973,18 +3973,18 @@
|
||||
//};
|
||||
//
|
||||
//struct player_data {
|
||||
// char name[0x10]; //+00 Player Name
|
||||
// void* pt_quest[3]; //+10 Quest Pointers for each difficulty
|
||||
// char name[0x10]; //+00 Player Name
|
||||
// void* pt_quest[3]; //+10 Quest Pointers for each difficulty
|
||||
// uint8_t uk1[0x18]; //+1C //before : 0x14
|
||||
// void* pt_arena_unit; //+34 ptArena for the Unit
|
||||
// void* pt_arena_unit; //+34 ptArena for the Unit
|
||||
// uint8_t uk2[0x4]; //+38 //before : 0x7
|
||||
// uint16_t mp_source_portal_unique_id; //+3C Source Portal Unique_ID
|
||||
// uint16_t mp_source_portal_unique_id; //+3C Source Portal Unique_ID
|
||||
// uint8_t uk3[0x2]; //+3E
|
||||
// uint16_t mp_dest_portal_unique_id; //+40 Destination Portal Unique_ID
|
||||
// uint8_t uk4[0x06]; //+42
|
||||
// uint8_t pt_object_un_id; //+48 Object UniqueID for TownPortals
|
||||
// uint8_t uk5[0x94B];//uk5[0x53]; //+49
|
||||
// net_client* net_client; //+9C ptClient
|
||||
// uint16_t mp_dest_portal_unique_id; //+40 Destination Portal Unique_ID
|
||||
// uint8_t uk4[0x06]; //+42
|
||||
// uint8_t pt_object_un_id; //+48 Object UniqueID for TownPortals
|
||||
// uint8_t uk5[0x94B];//uk5[0x53]; //+49
|
||||
// net_client* net_client; //+9C ptClient
|
||||
//};
|
||||
//
|
||||
//struct position {
|
||||
|
5
vendor/DllNotify/DllNotify.cpp
vendored
5
vendor/DllNotify/DllNotify.cpp
vendored
@@ -3,7 +3,7 @@
|
||||
|
||||
using namespace dllnotify;
|
||||
|
||||
DllNotify::DllNotify()
|
||||
DllNotify::DllNotify()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ BOOL DllNotify::Init_Dllnotify()
|
||||
return status == 0;
|
||||
}
|
||||
|
||||
|
||||
BOOL DllNotify::Uninit_Dllnotify()
|
||||
{
|
||||
NTSTATUS status = 1;
|
||||
@@ -77,4 +76,4 @@ BOOL DllNotify::Uninit_Dllnotify()
|
||||
}
|
||||
|
||||
return status == 0;
|
||||
}
|
||||
}
|
4
vendor/DllNotify/DllNotify.h
vendored
4
vendor/DllNotify/DllNotify.h
vendored
@@ -13,7 +13,7 @@ namespace dllnotify
|
||||
public:
|
||||
DllNotify();
|
||||
virtual ~DllNotify() noexcept {}
|
||||
|
||||
|
||||
typedef const UNICODE_STRING* PCUNICODE_STRING;
|
||||
|
||||
typedef struct _LDR_DLL_LOADED_NOTIFICATION_DATA {
|
||||
@@ -52,7 +52,6 @@ namespace dllnotify
|
||||
_Out_ PVOID* Cookie
|
||||
);
|
||||
|
||||
|
||||
typedef NTSTATUS(NTAPI* PLDR_UNREGISTER_DLL_NOTIFICATION)(
|
||||
_In_ PVOID Cookie
|
||||
);
|
||||
@@ -62,7 +61,6 @@ namespace dllnotify
|
||||
static bool is_d2expres();
|
||||
static bool is_sgd2freeres();
|
||||
|
||||
|
||||
private:
|
||||
static VOID CALLBACK LdrDllNotification(
|
||||
_In_ ULONG NotificationReason,
|
||||
|
13
vendor/minhook/include/MinHook.h
vendored
13
vendor/minhook/include/MinHook.h
vendored
@@ -29,12 +29,12 @@
|
||||
#pragma once
|
||||
|
||||
#if !(defined _M_IX86) && !(defined _M_X64) && !(defined __i386__) && !(defined __x86_64__)
|
||||
#error MinHook supports only x86 and x64 systems.
|
||||
#error MinHook supports only x86 and x64 systems.
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// MinHook Error Codes.
|
||||
// MinHook Error Codes.
|
||||
typedef enum MH_STATUS
|
||||
{
|
||||
// Unknown error. Should not be returned.
|
||||
@@ -108,7 +108,7 @@ extern "C" {
|
||||
// ppOriginal [out] A pointer to the trampoline function, which will be
|
||||
// used to call the original target function.
|
||||
// This parameter can be NULL.
|
||||
MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal);
|
||||
MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID* ppOriginal);
|
||||
|
||||
// Creates a Hook for the specified API function, in disabled state.
|
||||
// Parameters:
|
||||
@@ -122,7 +122,7 @@ extern "C" {
|
||||
// used to call the original target function.
|
||||
// This parameter can be NULL.
|
||||
MH_STATUS WINAPI MH_CreateHookApi(
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal);
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID* ppOriginal);
|
||||
|
||||
// Creates a Hook for the specified API function, in disabled state.
|
||||
// Parameters:
|
||||
@@ -139,7 +139,7 @@ extern "C" {
|
||||
// with other functions.
|
||||
// This parameter can be NULL.
|
||||
MH_STATUS WINAPI MH_CreateHookApiEx(
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal, LPVOID *ppTarget);
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID* ppOriginal, LPVOID* ppTarget);
|
||||
|
||||
// Removes an already created hook.
|
||||
// Parameters:
|
||||
@@ -178,9 +178,8 @@ extern "C" {
|
||||
MH_STATUS WINAPI MH_ApplyQueued(VOID);
|
||||
|
||||
// Translates the MH_STATUS to its get_name as a string.
|
||||
const char * WINAPI MH_StatusToString(MH_STATUS status);
|
||||
const char* WINAPI MH_StatusToString(MH_STATUS status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
10
vendor/minhook/src/buffer.c
vendored
10
vendor/minhook/src/buffer.c
vendored
@@ -29,7 +29,7 @@
|
||||
#include <windows.h>
|
||||
#include "buffer.h"
|
||||
|
||||
// Size of each memory block. (= page size of VirtualAlloc)
|
||||
// Size of each memory block. (= page size of VirtualAlloc)
|
||||
#define MEMORY_BLOCK_SIZE 0x1000
|
||||
|
||||
// Max range for seeking a memory block. (= 1024MB)
|
||||
@@ -44,18 +44,18 @@ typedef struct _MEMORY_SLOT
|
||||
{
|
||||
union
|
||||
{
|
||||
struct _MEMORY_SLOT *pNext;
|
||||
struct _MEMORY_SLOT* pNext;
|
||||
UINT8 buffer[MEMORY_SLOT_SIZE];
|
||||
};
|
||||
} MEMORY_SLOT, *PMEMORY_SLOT;
|
||||
} MEMORY_SLOT, * PMEMORY_SLOT;
|
||||
|
||||
// Memory block info. Placed at the head of each block.
|
||||
typedef struct _MEMORY_BLOCK
|
||||
{
|
||||
struct _MEMORY_BLOCK *pNext;
|
||||
struct _MEMORY_BLOCK* pNext;
|
||||
PMEMORY_SLOT pFree; // First element of the free slot list.
|
||||
UINT usedCount;
|
||||
} MEMORY_BLOCK, *PMEMORY_BLOCK;
|
||||
} MEMORY_BLOCK, * PMEMORY_BLOCK;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Global Variables:
|
||||
|
6
vendor/minhook/src/buffer.h
vendored
6
vendor/minhook/src/buffer.h
vendored
@@ -28,11 +28,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
// Size of each memory slot.
|
||||
// Size of each memory slot.
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
#define MEMORY_SLOT_SIZE 64
|
||||
#define MEMORY_SLOT_SIZE 64
|
||||
#else
|
||||
#define MEMORY_SLOT_SIZE 32
|
||||
#define MEMORY_SLOT_SIZE 32
|
||||
#endif
|
||||
|
||||
VOID InitializeBuffer(VOID);
|
||||
|
250
vendor/minhook/src/hde/hde32.c
vendored
250
vendor/minhook/src/hde/hde32.c
vendored
@@ -10,10 +10,10 @@
|
||||
#include "hde32.h"
|
||||
#include "table32.h"
|
||||
|
||||
unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
unsigned int hde32_disasm(const void* code, hde32s* hs)
|
||||
{
|
||||
uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0;
|
||||
uint8_t *ht = hde32_table, m_mod, m_reg, m_rm, disp_size = 0;
|
||||
uint8_t x, c, * p = (uint8_t*)code, cflags, opcode, pref = 0;
|
||||
uint8_t* ht = hde32_table, m_mod, m_reg, m_rm, disp_size = 0;
|
||||
|
||||
// Avoid using memset to reduce the footprint.
|
||||
#ifndef _MSC_VER
|
||||
@@ -24,35 +24,35 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
|
||||
for (x = 16; x; x--)
|
||||
switch (c = *p++) {
|
||||
case 0xf3:
|
||||
hs->p_rep = c;
|
||||
pref |= PRE_F3;
|
||||
break;
|
||||
case 0xf2:
|
||||
hs->p_rep = c;
|
||||
pref |= PRE_F2;
|
||||
break;
|
||||
case 0xf0:
|
||||
hs->p_lock = c;
|
||||
pref |= PRE_LOCK;
|
||||
break;
|
||||
case 0x26: case 0x2e: case 0x36:
|
||||
case 0x3e: case 0x64: case 0x65:
|
||||
hs->p_seg = c;
|
||||
pref |= PRE_SEG;
|
||||
break;
|
||||
case 0x66:
|
||||
hs->p_66 = c;
|
||||
pref |= PRE_66;
|
||||
break;
|
||||
case 0x67:
|
||||
hs->p_67 = c;
|
||||
pref |= PRE_67;
|
||||
break;
|
||||
default:
|
||||
goto pref_done;
|
||||
case 0xf3:
|
||||
hs->p_rep = c;
|
||||
pref |= PRE_F3;
|
||||
break;
|
||||
case 0xf2:
|
||||
hs->p_rep = c;
|
||||
pref |= PRE_F2;
|
||||
break;
|
||||
case 0xf0:
|
||||
hs->p_lock = c;
|
||||
pref |= PRE_LOCK;
|
||||
break;
|
||||
case 0x26: case 0x2e: case 0x36:
|
||||
case 0x3e: case 0x64: case 0x65:
|
||||
hs->p_seg = c;
|
||||
pref |= PRE_SEG;
|
||||
break;
|
||||
case 0x66:
|
||||
hs->p_66 = c;
|
||||
pref |= PRE_66;
|
||||
break;
|
||||
case 0x67:
|
||||
hs->p_67 = c;
|
||||
pref |= PRE_67;
|
||||
break;
|
||||
default:
|
||||
goto pref_done;
|
||||
}
|
||||
pref_done:
|
||||
pref_done:
|
||||
|
||||
hs->flags = (uint32_t)pref << 23;
|
||||
|
||||
@@ -62,7 +62,8 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
if ((hs->opcode = c) == 0x0f) {
|
||||
hs->opcode2 = c = *p++;
|
||||
ht += DELTA_OPCODES;
|
||||
} else if (c >= 0xa0 && c <= 0xa3) {
|
||||
}
|
||||
else if (c >= 0xa0 && c <= 0xa3) {
|
||||
if (pref & PRE_67)
|
||||
pref |= PRE_66;
|
||||
else
|
||||
@@ -82,7 +83,7 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
x = 0;
|
||||
if (cflags & C_GROUP) {
|
||||
uint16_t t;
|
||||
t = *(uint16_t *)(ht + (cflags & 0x7f));
|
||||
t = *(uint16_t*)(ht + (cflags & 0x7f));
|
||||
cflags = (uint8_t)t;
|
||||
x = (uint8_t)(t >> 8);
|
||||
}
|
||||
@@ -106,9 +107,10 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) {
|
||||
uint8_t t = opcode - 0xd9;
|
||||
if (m_mod == 3) {
|
||||
ht = hde32_table + DELTA_FPU_MODRM + t*8;
|
||||
ht = hde32_table + DELTA_FPU_MODRM + t * 8;
|
||||
t = ht[m_reg] << m_rm;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ht = hde32_table + DELTA_FPU_REG;
|
||||
t = ht[t] << m_reg;
|
||||
}
|
||||
@@ -119,12 +121,14 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
if (pref & PRE_LOCK) {
|
||||
if (m_mod == 3) {
|
||||
hs->flags |= F_ERROR | F_ERROR_LOCK;
|
||||
} else {
|
||||
uint8_t *table_end, op = opcode;
|
||||
}
|
||||
else {
|
||||
uint8_t* table_end, op = opcode;
|
||||
if (hs->opcode2) {
|
||||
ht = hde32_table + DELTA_OP2_LOCK_OK;
|
||||
table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ht = hde32_table + DELTA_OP_LOCK_OK;
|
||||
table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK;
|
||||
op &= -2;
|
||||
@@ -137,47 +141,49 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
break;
|
||||
}
|
||||
hs->flags |= F_ERROR | F_ERROR_LOCK;
|
||||
no_lock_error:
|
||||
no_lock_error:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (hs->opcode2) {
|
||||
switch (opcode) {
|
||||
case 0x20: case 0x22:
|
||||
m_mod = 3;
|
||||
if (m_reg > 4 || m_reg == 1)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x21: case 0x23:
|
||||
m_mod = 3;
|
||||
if (m_reg == 4 || m_reg == 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x20: case 0x22:
|
||||
m_mod = 3;
|
||||
if (m_reg > 4 || m_reg == 1)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x21: case 0x23:
|
||||
m_mod = 3;
|
||||
if (m_reg == 4 || m_reg == 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
switch (opcode) {
|
||||
case 0x8c:
|
||||
if (m_reg > 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x8e:
|
||||
if (m_reg == 1 || m_reg > 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x8c:
|
||||
if (m_reg > 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x8e:
|
||||
if (m_reg == 1 || m_reg > 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mod == 3) {
|
||||
uint8_t *table_end;
|
||||
uint8_t* table_end;
|
||||
if (hs->opcode2) {
|
||||
ht = hde32_table + DELTA_OP2_ONLY_MEM;
|
||||
table_end = ht + sizeof(hde32_table) - DELTA_OP2_ONLY_MEM;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ht = hde32_table + DELTA_OP_ONLY_MEM;
|
||||
table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM;
|
||||
}
|
||||
@@ -189,26 +195,28 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
break;
|
||||
}
|
||||
goto no_error_operand;
|
||||
} else if (hs->opcode2) {
|
||||
}
|
||||
else if (hs->opcode2) {
|
||||
switch (opcode) {
|
||||
case 0x50: case 0xd7: case 0xf7:
|
||||
if (pref & (PRE_NONE | PRE_66))
|
||||
goto error_operand;
|
||||
break;
|
||||
case 0xd6:
|
||||
if (pref & (PRE_F2 | PRE_F3))
|
||||
goto error_operand;
|
||||
break;
|
||||
case 0xc5:
|
||||
case 0x50: case 0xd7: case 0xf7:
|
||||
if (pref & (PRE_NONE | PRE_66))
|
||||
goto error_operand;
|
||||
break;
|
||||
case 0xd6:
|
||||
if (pref & (PRE_F2 | PRE_F3))
|
||||
goto error_operand;
|
||||
break;
|
||||
case 0xc5:
|
||||
goto error_operand;
|
||||
}
|
||||
goto no_error_operand;
|
||||
} else
|
||||
}
|
||||
else
|
||||
goto no_error_operand;
|
||||
|
||||
error_operand:
|
||||
error_operand:
|
||||
hs->flags |= F_ERROR | F_ERROR_OPERAND;
|
||||
no_error_operand:
|
||||
no_error_operand:
|
||||
|
||||
c = *p++;
|
||||
if (m_reg <= 1) {
|
||||
@@ -219,21 +227,22 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
}
|
||||
|
||||
switch (m_mod) {
|
||||
case 0:
|
||||
if (pref & PRE_67) {
|
||||
if (m_rm == 6)
|
||||
disp_size = 2;
|
||||
} else
|
||||
if (m_rm == 5)
|
||||
disp_size = 4;
|
||||
break;
|
||||
case 1:
|
||||
disp_size = 1;
|
||||
break;
|
||||
case 2:
|
||||
disp_size = 2;
|
||||
if (!(pref & PRE_67))
|
||||
disp_size <<= 1;
|
||||
case 0:
|
||||
if (pref & PRE_67) {
|
||||
if (m_rm == 6)
|
||||
disp_size = 2;
|
||||
}
|
||||
else
|
||||
if (m_rm == 5)
|
||||
disp_size = 4;
|
||||
break;
|
||||
case 1:
|
||||
disp_size = 1;
|
||||
break;
|
||||
case 2:
|
||||
disp_size = 2;
|
||||
if (!(pref & PRE_67))
|
||||
disp_size <<= 1;
|
||||
}
|
||||
|
||||
if (m_mod != 3 && m_rm == 4 && !(pref & PRE_67)) {
|
||||
@@ -248,27 +257,28 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
|
||||
p--;
|
||||
switch (disp_size) {
|
||||
case 1:
|
||||
hs->flags |= F_DISP8;
|
||||
hs->disp.disp8 = *p;
|
||||
break;
|
||||
case 2:
|
||||
hs->flags |= F_DISP16;
|
||||
hs->disp.disp16 = *(uint16_t *)p;
|
||||
break;
|
||||
case 4:
|
||||
hs->flags |= F_DISP32;
|
||||
hs->disp.disp32 = *(uint32_t *)p;
|
||||
case 1:
|
||||
hs->flags |= F_DISP8;
|
||||
hs->disp.disp8 = *p;
|
||||
break;
|
||||
case 2:
|
||||
hs->flags |= F_DISP16;
|
||||
hs->disp.disp16 = *(uint16_t*)p;
|
||||
break;
|
||||
case 4:
|
||||
hs->flags |= F_DISP32;
|
||||
hs->disp.disp32 = *(uint32_t*)p;
|
||||
}
|
||||
p += disp_size;
|
||||
} else if (pref & PRE_LOCK)
|
||||
}
|
||||
else if (pref & PRE_LOCK)
|
||||
hs->flags |= F_ERROR | F_ERROR_LOCK;
|
||||
|
||||
if (cflags & C_IMM_P66) {
|
||||
if (cflags & C_REL32) {
|
||||
if (pref & PRE_66) {
|
||||
hs->flags |= F_IMM16 | F_RELATIVE;
|
||||
hs->imm.imm16 = *(uint16_t *)p;
|
||||
hs->imm.imm16 = *(uint16_t*)p;
|
||||
p += 2;
|
||||
goto disasm_done;
|
||||
}
|
||||
@@ -276,11 +286,12 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
}
|
||||
if (pref & PRE_66) {
|
||||
hs->flags |= F_IMM16;
|
||||
hs->imm.imm16 = *(uint16_t *)p;
|
||||
hs->imm.imm16 = *(uint16_t*)p;
|
||||
p += 2;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
hs->flags |= F_IMM32;
|
||||
hs->imm.imm32 = *(uint32_t *)p;
|
||||
hs->imm.imm32 = *(uint32_t*)p;
|
||||
p += 4;
|
||||
}
|
||||
}
|
||||
@@ -288,13 +299,15 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
if (cflags & C_IMM16) {
|
||||
if (hs->flags & F_IMM32) {
|
||||
hs->flags |= F_IMM16;
|
||||
hs->disp.disp16 = *(uint16_t *)p;
|
||||
} else if (hs->flags & F_IMM16) {
|
||||
hs->disp.disp16 = *(uint16_t*)p;
|
||||
}
|
||||
else if (hs->flags & F_IMM16) {
|
||||
hs->flags |= F_2IMM16;
|
||||
hs->disp.disp16 = *(uint16_t *)p;
|
||||
} else {
|
||||
hs->disp.disp16 = *(uint16_t*)p;
|
||||
}
|
||||
else {
|
||||
hs->flags |= F_IMM16;
|
||||
hs->imm.imm16 = *(uint16_t *)p;
|
||||
hs->imm.imm16 = *(uint16_t*)p;
|
||||
}
|
||||
p += 2;
|
||||
}
|
||||
@@ -304,18 +317,19 @@ unsigned int hde32_disasm(const void *code, hde32s *hs)
|
||||
}
|
||||
|
||||
if (cflags & C_REL32) {
|
||||
rel32_ok:
|
||||
rel32_ok:
|
||||
hs->flags |= F_IMM32 | F_RELATIVE;
|
||||
hs->imm.imm32 = *(uint32_t *)p;
|
||||
hs->imm.imm32 = *(uint32_t*)p;
|
||||
p += 4;
|
||||
} else if (cflags & C_REL8) {
|
||||
}
|
||||
else if (cflags & C_REL8) {
|
||||
hs->flags |= F_IMM8 | F_RELATIVE;
|
||||
hs->imm.imm8 = *p++;
|
||||
}
|
||||
|
||||
disasm_done:
|
||||
disasm_done:
|
||||
|
||||
if ((hs->len = (uint8_t)(p-(uint8_t *)code)) > 15) {
|
||||
if ((hs->len = (uint8_t)(p - (uint8_t*)code)) > 15) {
|
||||
hs->flags |= F_ERROR | F_ERROR_LENGTH;
|
||||
hs->len = 15;
|
||||
}
|
||||
|
22
vendor/minhook/src/hde/hde32.h
vendored
22
vendor/minhook/src/hde/hde32.h
vendored
@@ -10,15 +10,15 @@
|
||||
#ifndef _HDE32_H_
|
||||
#define _HDE32_H_
|
||||
|
||||
/* stdint.h - C99 standard header
|
||||
* http://en.wikipedia.org/wiki/stdint.h
|
||||
*
|
||||
* if your compiler doesn't contain "stdint.h" header (for
|
||||
* example, Microsoft Visual C++), you can download file:
|
||||
* http://www.azillionmonkeys.com/qed/pstdint.h
|
||||
* and change next line to:
|
||||
* #include "pstdint.h"
|
||||
*/
|
||||
/* stdint.h - C99 standard header
|
||||
* http://en.wikipedia.org/wiki/stdint.h
|
||||
*
|
||||
* if your compiler doesn't contain "stdint.h" header (for
|
||||
* example, Microsoft Visual C++), you can download file:
|
||||
* http://www.azillionmonkeys.com/qed/pstdint.h
|
||||
* and change next line to:
|
||||
* #include "pstdint.h"
|
||||
*/
|
||||
#include "pstdint.h"
|
||||
|
||||
#define F_MODRM 0x00000001
|
||||
@@ -95,8 +95,8 @@ typedef struct {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* __cdecl */
|
||||
unsigned int hde32_disasm(const void *code, hde32s *hs);
|
||||
/* __cdecl */
|
||||
unsigned int hde32_disasm(const void* code, hde32s* hs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
248
vendor/minhook/src/hde/hde64.c
vendored
248
vendor/minhook/src/hde/hde64.c
vendored
@@ -10,10 +10,10 @@
|
||||
#include "hde64.h"
|
||||
#include "table64.h"
|
||||
|
||||
unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
unsigned int hde64_disasm(const void* code, hde64s* hs)
|
||||
{
|
||||
uint8_t x, c, *p = (uint8_t *)code, cflags, opcode, pref = 0;
|
||||
uint8_t *ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0;
|
||||
uint8_t x, c, * p = (uint8_t*)code, cflags, opcode, pref = 0;
|
||||
uint8_t* ht = hde64_table, m_mod, m_reg, m_rm, disp_size = 0;
|
||||
uint8_t op64 = 0;
|
||||
|
||||
// Avoid using memset to reduce the footprint.
|
||||
@@ -25,35 +25,35 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
|
||||
for (x = 16; x; x--)
|
||||
switch (c = *p++) {
|
||||
case 0xf3:
|
||||
hs->p_rep = c;
|
||||
pref |= PRE_F3;
|
||||
break;
|
||||
case 0xf2:
|
||||
hs->p_rep = c;
|
||||
pref |= PRE_F2;
|
||||
break;
|
||||
case 0xf0:
|
||||
hs->p_lock = c;
|
||||
pref |= PRE_LOCK;
|
||||
break;
|
||||
case 0x26: case 0x2e: case 0x36:
|
||||
case 0x3e: case 0x64: case 0x65:
|
||||
hs->p_seg = c;
|
||||
pref |= PRE_SEG;
|
||||
break;
|
||||
case 0x66:
|
||||
hs->p_66 = c;
|
||||
pref |= PRE_66;
|
||||
break;
|
||||
case 0x67:
|
||||
hs->p_67 = c;
|
||||
pref |= PRE_67;
|
||||
break;
|
||||
default:
|
||||
goto pref_done;
|
||||
case 0xf3:
|
||||
hs->p_rep = c;
|
||||
pref |= PRE_F3;
|
||||
break;
|
||||
case 0xf2:
|
||||
hs->p_rep = c;
|
||||
pref |= PRE_F2;
|
||||
break;
|
||||
case 0xf0:
|
||||
hs->p_lock = c;
|
||||
pref |= PRE_LOCK;
|
||||
break;
|
||||
case 0x26: case 0x2e: case 0x36:
|
||||
case 0x3e: case 0x64: case 0x65:
|
||||
hs->p_seg = c;
|
||||
pref |= PRE_SEG;
|
||||
break;
|
||||
case 0x66:
|
||||
hs->p_66 = c;
|
||||
pref |= PRE_66;
|
||||
break;
|
||||
case 0x67:
|
||||
hs->p_67 = c;
|
||||
pref |= PRE_67;
|
||||
break;
|
||||
default:
|
||||
goto pref_done;
|
||||
}
|
||||
pref_done:
|
||||
pref_done:
|
||||
|
||||
hs->flags = (uint32_t)pref << 23;
|
||||
|
||||
@@ -76,7 +76,8 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
if ((hs->opcode = c) == 0x0f) {
|
||||
hs->opcode2 = c = *p++;
|
||||
ht += DELTA_OPCODES;
|
||||
} else if (c >= 0xa0 && c <= 0xa3) {
|
||||
}
|
||||
else if (c >= 0xa0 && c <= 0xa3) {
|
||||
op64++;
|
||||
if (pref & PRE_67)
|
||||
pref |= PRE_66;
|
||||
@@ -88,7 +89,7 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
cflags = ht[ht[opcode / 4] + (opcode % 4)];
|
||||
|
||||
if (cflags == C_ERROR) {
|
||||
error_opcode:
|
||||
error_opcode:
|
||||
hs->flags |= F_ERROR | F_ERROR_OPCODE;
|
||||
cflags = 0;
|
||||
if ((opcode & -3) == 0x24)
|
||||
@@ -98,7 +99,7 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
x = 0;
|
||||
if (cflags & C_GROUP) {
|
||||
uint16_t t;
|
||||
t = *(uint16_t *)(ht + (cflags & 0x7f));
|
||||
t = *(uint16_t*)(ht + (cflags & 0x7f));
|
||||
cflags = (uint8_t)t;
|
||||
x = (uint8_t)(t >> 8);
|
||||
}
|
||||
@@ -122,9 +123,10 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
if (!hs->opcode2 && opcode >= 0xd9 && opcode <= 0xdf) {
|
||||
uint8_t t = opcode - 0xd9;
|
||||
if (m_mod == 3) {
|
||||
ht = hde64_table + DELTA_FPU_MODRM + t*8;
|
||||
ht = hde64_table + DELTA_FPU_MODRM + t * 8;
|
||||
t = ht[m_reg] << m_rm;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ht = hde64_table + DELTA_FPU_REG;
|
||||
t = ht[t] << m_reg;
|
||||
}
|
||||
@@ -135,12 +137,14 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
if (pref & PRE_LOCK) {
|
||||
if (m_mod == 3) {
|
||||
hs->flags |= F_ERROR | F_ERROR_LOCK;
|
||||
} else {
|
||||
uint8_t *table_end, op = opcode;
|
||||
}
|
||||
else {
|
||||
uint8_t* table_end, op = opcode;
|
||||
if (hs->opcode2) {
|
||||
ht = hde64_table + DELTA_OP2_LOCK_OK;
|
||||
table_end = ht + DELTA_OP_ONLY_MEM - DELTA_OP2_LOCK_OK;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ht = hde64_table + DELTA_OP_LOCK_OK;
|
||||
table_end = ht + DELTA_OP2_LOCK_OK - DELTA_OP_LOCK_OK;
|
||||
op &= -2;
|
||||
@@ -153,47 +157,49 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
break;
|
||||
}
|
||||
hs->flags |= F_ERROR | F_ERROR_LOCK;
|
||||
no_lock_error:
|
||||
no_lock_error:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
if (hs->opcode2) {
|
||||
switch (opcode) {
|
||||
case 0x20: case 0x22:
|
||||
m_mod = 3;
|
||||
if (m_reg > 4 || m_reg == 1)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x21: case 0x23:
|
||||
m_mod = 3;
|
||||
if (m_reg == 4 || m_reg == 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x20: case 0x22:
|
||||
m_mod = 3;
|
||||
if (m_reg > 4 || m_reg == 1)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x21: case 0x23:
|
||||
m_mod = 3;
|
||||
if (m_reg == 4 || m_reg == 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
switch (opcode) {
|
||||
case 0x8c:
|
||||
if (m_reg > 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x8e:
|
||||
if (m_reg == 1 || m_reg > 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x8c:
|
||||
if (m_reg > 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
case 0x8e:
|
||||
if (m_reg == 1 || m_reg > 5)
|
||||
goto error_operand;
|
||||
else
|
||||
goto no_error_operand;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mod == 3) {
|
||||
uint8_t *table_end;
|
||||
uint8_t* table_end;
|
||||
if (hs->opcode2) {
|
||||
ht = hde64_table + DELTA_OP2_ONLY_MEM;
|
||||
table_end = ht + sizeof(hde64_table) - DELTA_OP2_ONLY_MEM;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
ht = hde64_table + DELTA_OP_ONLY_MEM;
|
||||
table_end = ht + DELTA_OP2_ONLY_MEM - DELTA_OP_ONLY_MEM;
|
||||
}
|
||||
@@ -205,26 +211,28 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
break;
|
||||
}
|
||||
goto no_error_operand;
|
||||
} else if (hs->opcode2) {
|
||||
}
|
||||
else if (hs->opcode2) {
|
||||
switch (opcode) {
|
||||
case 0x50: case 0xd7: case 0xf7:
|
||||
if (pref & (PRE_NONE | PRE_66))
|
||||
goto error_operand;
|
||||
break;
|
||||
case 0xd6:
|
||||
if (pref & (PRE_F2 | PRE_F3))
|
||||
goto error_operand;
|
||||
break;
|
||||
case 0xc5:
|
||||
case 0x50: case 0xd7: case 0xf7:
|
||||
if (pref & (PRE_NONE | PRE_66))
|
||||
goto error_operand;
|
||||
break;
|
||||
case 0xd6:
|
||||
if (pref & (PRE_F2 | PRE_F3))
|
||||
goto error_operand;
|
||||
break;
|
||||
case 0xc5:
|
||||
goto error_operand;
|
||||
}
|
||||
goto no_error_operand;
|
||||
} else
|
||||
}
|
||||
else
|
||||
goto no_error_operand;
|
||||
|
||||
error_operand:
|
||||
error_operand:
|
||||
hs->flags |= F_ERROR | F_ERROR_OPERAND;
|
||||
no_error_operand:
|
||||
no_error_operand:
|
||||
|
||||
c = *p++;
|
||||
if (m_reg <= 1) {
|
||||
@@ -235,21 +243,22 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
}
|
||||
|
||||
switch (m_mod) {
|
||||
case 0:
|
||||
if (pref & PRE_67) {
|
||||
if (m_rm == 6)
|
||||
disp_size = 2;
|
||||
} else
|
||||
if (m_rm == 5)
|
||||
disp_size = 4;
|
||||
break;
|
||||
case 1:
|
||||
disp_size = 1;
|
||||
break;
|
||||
case 2:
|
||||
disp_size = 2;
|
||||
if (!(pref & PRE_67))
|
||||
disp_size <<= 1;
|
||||
case 0:
|
||||
if (pref & PRE_67) {
|
||||
if (m_rm == 6)
|
||||
disp_size = 2;
|
||||
}
|
||||
else
|
||||
if (m_rm == 5)
|
||||
disp_size = 4;
|
||||
break;
|
||||
case 1:
|
||||
disp_size = 1;
|
||||
break;
|
||||
case 2:
|
||||
disp_size = 2;
|
||||
if (!(pref & PRE_67))
|
||||
disp_size <<= 1;
|
||||
}
|
||||
|
||||
if (m_mod != 3 && m_rm == 4) {
|
||||
@@ -264,27 +273,28 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
|
||||
p--;
|
||||
switch (disp_size) {
|
||||
case 1:
|
||||
hs->flags |= F_DISP8;
|
||||
hs->disp.disp8 = *p;
|
||||
break;
|
||||
case 2:
|
||||
hs->flags |= F_DISP16;
|
||||
hs->disp.disp16 = *(uint16_t *)p;
|
||||
break;
|
||||
case 4:
|
||||
hs->flags |= F_DISP32;
|
||||
hs->disp.disp32 = *(uint32_t *)p;
|
||||
case 1:
|
||||
hs->flags |= F_DISP8;
|
||||
hs->disp.disp8 = *p;
|
||||
break;
|
||||
case 2:
|
||||
hs->flags |= F_DISP16;
|
||||
hs->disp.disp16 = *(uint16_t*)p;
|
||||
break;
|
||||
case 4:
|
||||
hs->flags |= F_DISP32;
|
||||
hs->disp.disp32 = *(uint32_t*)p;
|
||||
}
|
||||
p += disp_size;
|
||||
} else if (pref & PRE_LOCK)
|
||||
}
|
||||
else if (pref & PRE_LOCK)
|
||||
hs->flags |= F_ERROR | F_ERROR_LOCK;
|
||||
|
||||
if (cflags & C_IMM_P66) {
|
||||
if (cflags & C_REL32) {
|
||||
if (pref & PRE_66) {
|
||||
hs->flags |= F_IMM16 | F_RELATIVE;
|
||||
hs->imm.imm16 = *(uint16_t *)p;
|
||||
hs->imm.imm16 = *(uint16_t*)p;
|
||||
p += 2;
|
||||
goto disasm_done;
|
||||
}
|
||||
@@ -292,21 +302,22 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
}
|
||||
if (op64) {
|
||||
hs->flags |= F_IMM64;
|
||||
hs->imm.imm64 = *(uint64_t *)p;
|
||||
hs->imm.imm64 = *(uint64_t*)p;
|
||||
p += 8;
|
||||
} else if (!(pref & PRE_66)) {
|
||||
}
|
||||
else if (!(pref & PRE_66)) {
|
||||
hs->flags |= F_IMM32;
|
||||
hs->imm.imm32 = *(uint32_t *)p;
|
||||
hs->imm.imm32 = *(uint32_t*)p;
|
||||
p += 4;
|
||||
} else
|
||||
}
|
||||
else
|
||||
goto imm16_ok;
|
||||
}
|
||||
|
||||
|
||||
if (cflags & C_IMM16) {
|
||||
imm16_ok:
|
||||
imm16_ok:
|
||||
hs->flags |= F_IMM16;
|
||||
hs->imm.imm16 = *(uint16_t *)p;
|
||||
hs->imm.imm16 = *(uint16_t*)p;
|
||||
p += 2;
|
||||
}
|
||||
if (cflags & C_IMM8) {
|
||||
@@ -315,18 +326,19 @@ unsigned int hde64_disasm(const void *code, hde64s *hs)
|
||||
}
|
||||
|
||||
if (cflags & C_REL32) {
|
||||
rel32_ok:
|
||||
rel32_ok:
|
||||
hs->flags |= F_IMM32 | F_RELATIVE;
|
||||
hs->imm.imm32 = *(uint32_t *)p;
|
||||
hs->imm.imm32 = *(uint32_t*)p;
|
||||
p += 4;
|
||||
} else if (cflags & C_REL8) {
|
||||
}
|
||||
else if (cflags & C_REL8) {
|
||||
hs->flags |= F_IMM8 | F_RELATIVE;
|
||||
hs->imm.imm8 = *p++;
|
||||
}
|
||||
|
||||
disasm_done:
|
||||
disasm_done:
|
||||
|
||||
if ((hs->len = (uint8_t)(p-(uint8_t *)code)) > 15) {
|
||||
if ((hs->len = (uint8_t)(p - (uint8_t*)code)) > 15) {
|
||||
hs->flags |= F_ERROR | F_ERROR_LENGTH;
|
||||
hs->len = 15;
|
||||
}
|
||||
|
22
vendor/minhook/src/hde/hde64.h
vendored
22
vendor/minhook/src/hde/hde64.h
vendored
@@ -10,15 +10,15 @@
|
||||
#ifndef _HDE64_H_
|
||||
#define _HDE64_H_
|
||||
|
||||
/* stdint.h - C99 standard header
|
||||
* http://en.wikipedia.org/wiki/stdint.h
|
||||
*
|
||||
* if your compiler doesn't contain "stdint.h" header (for
|
||||
* example, Microsoft Visual C++), you can download file:
|
||||
* http://www.azillionmonkeys.com/qed/pstdint.h
|
||||
* and change next line to:
|
||||
* #include "pstdint.h"
|
||||
*/
|
||||
/* stdint.h - C99 standard header
|
||||
* http://en.wikipedia.org/wiki/stdint.h
|
||||
*
|
||||
* if your compiler doesn't contain "stdint.h" header (for
|
||||
* example, Microsoft Visual C++), you can download file:
|
||||
* http://www.azillionmonkeys.com/qed/pstdint.h
|
||||
* and change next line to:
|
||||
* #include "pstdint.h"
|
||||
*/
|
||||
#include "pstdint.h"
|
||||
|
||||
#define F_MODRM 0x00000001
|
||||
@@ -102,8 +102,8 @@ typedef struct {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* __cdecl */
|
||||
unsigned int hde64_disasm(const void *code, hde64s *hs);
|
||||
/* __cdecl */
|
||||
unsigned int hde64_disasm(const void* code, hde64s* hs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
2
vendor/minhook/src/hde/pstdint.h
vendored
2
vendor/minhook/src/hde/pstdint.h
vendored
@@ -28,7 +28,7 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
// Integer types for HDE.
|
||||
// Integer types for HDE.
|
||||
typedef INT8 int8_t;
|
||||
typedef INT16 int16_t;
|
||||
typedef INT32 int32_t;
|
||||
|
84
vendor/minhook/src/hook.c
vendored
84
vendor/minhook/src/hook.c
vendored
@@ -35,10 +35,10 @@
|
||||
#include "trampoline.h"
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
// Initial capacity of the HOOK_ENTRY buffer.
|
||||
// Initial capacity of the HOOK_ENTRY buffer.
|
||||
#define INITIAL_HOOK_CAPACITY 32
|
||||
|
||||
// Initial capacity of the thread IDs buffer.
|
||||
@@ -65,14 +65,14 @@ typedef struct _HOOK_ENTRY
|
||||
LPVOID pTrampoline; // Address of the trampoline function.
|
||||
UINT8 backup[8]; // Original prologue of the target function.
|
||||
|
||||
UINT8 patchAbove : 1; // Uses the hot patch area.
|
||||
UINT8 isEnabled : 1; // Enabled.
|
||||
UINT8 patchAbove : 1; // Uses the hot patch area.
|
||||
UINT8 isEnabled : 1; // Enabled.
|
||||
UINT8 queueEnable : 1; // Queued for enabling/disabling when != isEnabled.
|
||||
|
||||
UINT nIP : 4; // Count of the instruction boundaries.
|
||||
UINT8 oldIPs[8]; // Instruction boundaries of the target function.
|
||||
UINT8 newIPs[8]; // Instruction boundaries of the trampoline function.
|
||||
} HOOK_ENTRY, *PHOOK_ENTRY;
|
||||
} HOOK_ENTRY, * PHOOK_ENTRY;
|
||||
|
||||
// Suspended threads for Freeze()/Unfreeze().
|
||||
typedef struct _FROZEN_THREADS
|
||||
@@ -80,7 +80,7 @@ typedef struct _FROZEN_THREADS
|
||||
LPDWORD pItems; // Data heap
|
||||
UINT capacity; // Size of allocated data heap, items
|
||||
UINT size; // Actual number of data items
|
||||
} FROZEN_THREADS, *PFROZEN_THREADS;
|
||||
} FROZEN_THREADS, * PFROZEN_THREADS;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Global Variables:
|
||||
@@ -203,9 +203,9 @@ static void ProcessThreadIPs(HANDLE hThread, UINT pos, UINT action)
|
||||
|
||||
CONTEXT c;
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
DWORD64 *pIP = &c.Rip;
|
||||
DWORD64* pIP = &c.Rip;
|
||||
#else
|
||||
DWORD *pIP = &c.Eip;
|
||||
DWORD* pIP = &c.Eip;
|
||||
#endif
|
||||
UINT count;
|
||||
|
||||
@@ -306,9 +306,9 @@ static VOID EnumerateThreads(PFROZEN_THREADS pThreads)
|
||||
//-------------------------------------------------------------------------
|
||||
static VOID Freeze(PFROZEN_THREADS pThreads, UINT pos, UINT action)
|
||||
{
|
||||
pThreads->pItems = NULL;
|
||||
pThreads->pItems = NULL;
|
||||
pThreads->capacity = 0;
|
||||
pThreads->size = 0;
|
||||
pThreads->size = 0;
|
||||
EnumerateThreads(pThreads);
|
||||
|
||||
if (pThreads->pItems != NULL)
|
||||
@@ -352,13 +352,13 @@ static MH_STATUS EnableHookLL(UINT pos, BOOL enable)
|
||||
{
|
||||
PHOOK_ENTRY pHook = &g_hooks.pItems[pos];
|
||||
DWORD oldProtect;
|
||||
SIZE_T patchSize = sizeof(JMP_REL);
|
||||
SIZE_T patchSize = sizeof(JMP_REL);
|
||||
LPBYTE pPatchTarget = (LPBYTE)pHook->pTarget;
|
||||
|
||||
if (pHook->patchAbove)
|
||||
{
|
||||
pPatchTarget -= sizeof(JMP_REL);
|
||||
patchSize += sizeof(JMP_REL_SHORT);
|
||||
patchSize += sizeof(JMP_REL_SHORT);
|
||||
}
|
||||
|
||||
if (!VirtualProtect(pPatchTarget, patchSize, PAGE_EXECUTE_READWRITE, &oldProtect))
|
||||
@@ -390,7 +390,7 @@ static MH_STATUS EnableHookLL(UINT pos, BOOL enable)
|
||||
// Just-in-case measure.
|
||||
FlushInstructionCache(GetCurrentProcess(), pPatchTarget, patchSize);
|
||||
|
||||
pHook->isEnabled = enable;
|
||||
pHook->isEnabled = enable;
|
||||
pHook->queueEnable = enable;
|
||||
|
||||
return MH_OK;
|
||||
@@ -516,9 +516,9 @@ MH_STATUS WINAPI MH_Uninitialize(VOID)
|
||||
|
||||
g_hHeap = NULL;
|
||||
|
||||
g_hooks.pItems = NULL;
|
||||
g_hooks.pItems = NULL;
|
||||
g_hooks.capacity = 0;
|
||||
g_hooks.size = 0;
|
||||
g_hooks.size = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -532,7 +532,7 @@ MH_STATUS WINAPI MH_Uninitialize(VOID)
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOriginal)
|
||||
MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID* ppOriginal)
|
||||
{
|
||||
MH_STATUS status = MH_OK;
|
||||
|
||||
@@ -550,25 +550,25 @@ MH_STATUS WINAPI MH_CreateHook(LPVOID pTarget, LPVOID pDetour, LPVOID *ppOrigina
|
||||
{
|
||||
TRAMPOLINE ct;
|
||||
|
||||
ct.pTarget = pTarget;
|
||||
ct.pDetour = pDetour;
|
||||
ct.pTarget = pTarget;
|
||||
ct.pDetour = pDetour;
|
||||
ct.pTrampoline = pBuffer;
|
||||
if (CreateTrampolineFunction(&ct))
|
||||
{
|
||||
PHOOK_ENTRY pHook = AddHookEntry();
|
||||
if (pHook != NULL)
|
||||
{
|
||||
pHook->pTarget = ct.pTarget;
|
||||
pHook->pTarget = ct.pTarget;
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
pHook->pDetour = ct.pRelay;
|
||||
pHook->pDetour = ct.pRelay;
|
||||
#else
|
||||
pHook->pDetour = ct.pDetour;
|
||||
pHook->pDetour = ct.pDetour;
|
||||
#endif
|
||||
pHook->pTrampoline = ct.pTrampoline;
|
||||
pHook->patchAbove = ct.patchAbove;
|
||||
pHook->isEnabled = FALSE;
|
||||
pHook->patchAbove = ct.patchAbove;
|
||||
pHook->isEnabled = FALSE;
|
||||
pHook->queueEnable = FALSE;
|
||||
pHook->nIP = ct.nIP;
|
||||
pHook->nIP = ct.nIP;
|
||||
memcpy(pHook->oldIPs, ct.oldIPs, ARRAYSIZE(ct.oldIPs));
|
||||
memcpy(pHook->newIPs, ct.newIPs, ARRAYSIZE(ct.newIPs));
|
||||
|
||||
@@ -833,7 +833,7 @@ MH_STATUS WINAPI MH_ApplyQueued(VOID)
|
||||
//-------------------------------------------------------------------------
|
||||
MH_STATUS WINAPI MH_CreateHookApiEx(
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour,
|
||||
LPVOID *ppOriginal, LPVOID *ppTarget)
|
||||
LPVOID* ppOriginal, LPVOID* ppTarget)
|
||||
{
|
||||
HMODULE hModule;
|
||||
LPVOID pTarget;
|
||||
@@ -846,7 +846,7 @@ MH_STATUS WINAPI MH_CreateHookApiEx(
|
||||
if (pTarget == NULL)
|
||||
return MH_ERROR_FUNCTION_NOT_FOUND;
|
||||
|
||||
if(ppTarget != NULL)
|
||||
if (ppTarget != NULL)
|
||||
*ppTarget = pTarget;
|
||||
|
||||
return MH_CreateHook(pTarget, pDetour, ppOriginal);
|
||||
@@ -854,13 +854,13 @@ MH_STATUS WINAPI MH_CreateHookApiEx(
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
MH_STATUS WINAPI hookApi(
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID *ppOriginal)
|
||||
LPCWSTR pszModule, LPCSTR pszProcName, LPVOID pDetour, LPVOID* ppOriginal)
|
||||
{
|
||||
return MH_CreateHookApiEx(pszModule, pszProcName, pDetour, ppOriginal, NULL);
|
||||
return MH_CreateHookApiEx(pszModule, pszProcName, pDetour, ppOriginal, NULL);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
const char * WINAPI MH_StatusToString(MH_STATUS status)
|
||||
const char* WINAPI MH_StatusToString(MH_STATUS status)
|
||||
{
|
||||
#define MH_ST2STR(x) \
|
||||
case x: \
|
||||
@@ -868,19 +868,19 @@ const char * WINAPI MH_StatusToString(MH_STATUS status)
|
||||
|
||||
switch (status) {
|
||||
MH_ST2STR(MH_UNKNOWN)
|
||||
MH_ST2STR(MH_OK)
|
||||
MH_ST2STR(MH_ERROR_ALREADY_INITIALIZED)
|
||||
MH_ST2STR(MH_ERROR_NOT_INITIALIZED)
|
||||
MH_ST2STR(MH_ERROR_ALREADY_CREATED)
|
||||
MH_ST2STR(MH_ERROR_NOT_CREATED)
|
||||
MH_ST2STR(MH_ERROR_ENABLED)
|
||||
MH_ST2STR(MH_ERROR_DISABLED)
|
||||
MH_ST2STR(MH_ERROR_NOT_EXECUTABLE)
|
||||
MH_ST2STR(MH_ERROR_UNSUPPORTED_FUNCTION)
|
||||
MH_ST2STR(MH_ERROR_MEMORY_ALLOC)
|
||||
MH_ST2STR(MH_ERROR_MEMORY_PROTECT)
|
||||
MH_ST2STR(MH_ERROR_MODULE_NOT_FOUND)
|
||||
MH_ST2STR(MH_ERROR_FUNCTION_NOT_FOUND)
|
||||
MH_ST2STR(MH_OK)
|
||||
MH_ST2STR(MH_ERROR_ALREADY_INITIALIZED)
|
||||
MH_ST2STR(MH_ERROR_NOT_INITIALIZED)
|
||||
MH_ST2STR(MH_ERROR_ALREADY_CREATED)
|
||||
MH_ST2STR(MH_ERROR_NOT_CREATED)
|
||||
MH_ST2STR(MH_ERROR_ENABLED)
|
||||
MH_ST2STR(MH_ERROR_DISABLED)
|
||||
MH_ST2STR(MH_ERROR_NOT_EXECUTABLE)
|
||||
MH_ST2STR(MH_ERROR_UNSUPPORTED_FUNCTION)
|
||||
MH_ST2STR(MH_ERROR_MEMORY_ALLOC)
|
||||
MH_ST2STR(MH_ERROR_MEMORY_PROTECT)
|
||||
MH_ST2STR(MH_ERROR_MODULE_NOT_FOUND)
|
||||
MH_ST2STR(MH_ERROR_FUNCTION_NOT_FOUND)
|
||||
}
|
||||
|
||||
#undef MH_ST2STR
|
||||
|
33
vendor/minhook/src/trampoline.c
vendored
33
vendor/minhook/src/trampoline.c
vendored
@@ -29,17 +29,17 @@
|
||||
#include <windows.h>
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#define ARRAYSIZE(A) (sizeof(A)/sizeof((A)[0]))
|
||||
#endif
|
||||
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
#include "./hde/hde64.h"
|
||||
typedef hde64s HDE;
|
||||
#define HDE_DISASM(code, hs) hde64_disasm(code, hs)
|
||||
#include "./hde/hde64.h"
|
||||
typedef hde64s HDE;
|
||||
#define HDE_DISASM(code, hs) hde64_disasm(code, hs)
|
||||
#else
|
||||
#include "./hde/hde32.h"
|
||||
typedef hde32s HDE;
|
||||
#define HDE_DISASM(code, hs) hde32_disasm(code, hs)
|
||||
#include "./hde/hde32.h"
|
||||
typedef hde32s HDE;
|
||||
#define HDE_DISASM(code, hs) hde32_disasm(code, hs)
|
||||
#endif
|
||||
|
||||
#include "trampoline.h"
|
||||
@@ -47,9 +47,9 @@
|
||||
|
||||
// Maximum size of a trampoline function.
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
#define TRAMPOLINE_MAX_SIZE (MEMORY_SLOT_SIZE - sizeof(JMP_ABS))
|
||||
#define TRAMPOLINE_MAX_SIZE (MEMORY_SLOT_SIZE - sizeof(JMP_ABS))
|
||||
#else
|
||||
#define TRAMPOLINE_MAX_SIZE MEMORY_SLOT_SIZE
|
||||
#define TRAMPOLINE_MAX_SIZE MEMORY_SLOT_SIZE
|
||||
#endif
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -101,23 +101,23 @@ BOOL CreateTrampolineFunction(PTRAMPOLINE ct)
|
||||
};
|
||||
#endif
|
||||
|
||||
UINT8 oldPos = 0;
|
||||
UINT8 newPos = 0;
|
||||
ULONG_PTR jmpDest = 0; // Destination address of an internal jump.
|
||||
UINT8 oldPos = 0;
|
||||
UINT8 newPos = 0;
|
||||
ULONG_PTR jmpDest = 0; // Destination address of an internal jump.
|
||||
BOOL finished = FALSE; // Is the function completed?
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
UINT8 instBuf[16];
|
||||
#endif
|
||||
|
||||
ct->patchAbove = FALSE;
|
||||
ct->nIP = 0;
|
||||
ct->nIP = 0;
|
||||
|
||||
do
|
||||
{
|
||||
HDE hs;
|
||||
UINT copySize;
|
||||
LPVOID pCopySrc;
|
||||
ULONG_PTR pOldInst = (ULONG_PTR)ct->pTarget + oldPos;
|
||||
ULONG_PTR pOldInst = (ULONG_PTR)ct->pTarget + oldPos;
|
||||
ULONG_PTR pNewInst = (ULONG_PTR)ct->pTrampoline + newPos;
|
||||
|
||||
copySize = HDE_DISASM((LPVOID)pOldInst, &hs);
|
||||
@@ -238,7 +238,7 @@ BOOL CreateTrampolineFunction(PTRAMPOLINE ct)
|
||||
UINT8 cond = ((hs.opcode != 0x0F ? hs.opcode : hs.opcode2) & 0x0F);
|
||||
#if defined(_M_X64) || defined(__x86_64__)
|
||||
// Invert the condition in x64 mode to simplify the conditional jump logic.
|
||||
jcc.opcode = 0x71 ^ cond;
|
||||
jcc.opcode = 0x71 ^ cond;
|
||||
jcc.address = dest;
|
||||
#else
|
||||
jcc.opcode1 = 0x80 | cond;
|
||||
@@ -280,8 +280,7 @@ BOOL CreateTrampolineFunction(PTRAMPOLINE ct)
|
||||
#endif
|
||||
newPos += copySize;
|
||||
oldPos += hs.len;
|
||||
}
|
||||
while (!finished);
|
||||
} while (!finished);
|
||||
|
||||
// Is there enough place for a long jump?
|
||||
if (oldPos < sizeof(JMP_REL)
|
||||
|
12
vendor/minhook/src/trampoline.h
vendored
12
vendor/minhook/src/trampoline.h
vendored
@@ -30,21 +30,21 @@
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
// Structs for writing x86/x64 instructions.
|
||||
// Structs for writing x86/x64 instructions.
|
||||
|
||||
// 8-bit relative jump.
|
||||
// 8-bit relative jump.
|
||||
typedef struct _JMP_REL_SHORT
|
||||
{
|
||||
UINT8 opcode; // EB xx: JMP +2+xx
|
||||
UINT8 operand;
|
||||
} JMP_REL_SHORT, *PJMP_REL_SHORT;
|
||||
} JMP_REL_SHORT, * PJMP_REL_SHORT;
|
||||
|
||||
// 32-bit direct relative jump/call.
|
||||
typedef struct _JMP_REL
|
||||
{
|
||||
UINT8 opcode; // E9/E8 xxxxxxxx: JMP/CALL +5+xxxxxxxx
|
||||
UINT32 operand; // Relative destination address
|
||||
} JMP_REL, *PJMP_REL, CALL_REL;
|
||||
} JMP_REL, * PJMP_REL, CALL_REL;
|
||||
|
||||
// 64-bit indirect absolute jump.
|
||||
typedef struct _JMP_ABS
|
||||
@@ -53,7 +53,7 @@ typedef struct _JMP_ABS
|
||||
UINT8 opcode1;
|
||||
UINT32 dummy;
|
||||
UINT64 address; // Absolute destination address
|
||||
} JMP_ABS, *PJMP_ABS;
|
||||
} JMP_ABS, * PJMP_ABS;
|
||||
|
||||
// 64-bit indirect absolute call.
|
||||
typedef struct _CALL_ABS
|
||||
@@ -100,6 +100,6 @@ typedef struct _TRAMPOLINE
|
||||
UINT nIP; // [Out] Number of the instruction boundaries.
|
||||
UINT8 oldIPs[8]; // [Out] Instruction boundaries of the target function.
|
||||
UINT8 newIPs[8]; // [Out] Instruction boundaries of the trampoline function.
|
||||
} TRAMPOLINE, *PTRAMPOLINE;
|
||||
} TRAMPOLINE, * PTRAMPOLINE;
|
||||
|
||||
BOOL CreateTrampolineFunction(PTRAMPOLINE ct);
|
||||
|
Reference in New Issue
Block a user