summaryrefslogtreecommitdiff
path: root/thirdparty/mhook/disasm-lib
diff options
context:
space:
mode:
authorJose Fonseca <jfonseca@vmware.com>2016-09-03 10:17:38 +0100
committerJose Fonseca <jfonseca@vmware.com>2016-09-05 15:57:40 +0100
commitc71a5687e076550fb607f85a9ff041bda7afe4e9 (patch)
tree140f2c82c99d558d600f9a2393d821bc2859c8af /thirdparty/mhook/disasm-lib
parent6e1b4f89736c93e0069e60afd68852997c5bbd5a (diff)
mhook: Fix MinGW build.
Using https://github.com/SirAnthony/mhook as reference.
Diffstat (limited to 'thirdparty/mhook/disasm-lib')
-rw-r--r--thirdparty/mhook/disasm-lib/disasm.c2
-rw-r--r--thirdparty/mhook/disasm-lib/disasm.h3
-rw-r--r--thirdparty/mhook/disasm-lib/disasm_x86.c12
-rw-r--r--thirdparty/mhook/disasm-lib/disasm_x86.h22
4 files changed, 22 insertions, 17 deletions
diff --git a/thirdparty/mhook/disasm-lib/disasm.c b/thirdparty/mhook/disasm-lib/disasm.c
index 7e72baaa..7dd8fa3b 100644
--- a/thirdparty/mhook/disasm-lib/disasm.c
+++ b/thirdparty/mhook/disasm-lib/disasm.c
@@ -37,7 +37,7 @@ typedef struct _DISASM_ARG_INFO
//////////////////////////////////////////////////////////////////////
BOOL InitInstruction(INSTRUCTION *Instruction, DISASSEMBLER *Disassembler);
-struct _ARCHITECTURE_FORMAT *GetArchitectureFormat(ARCHITECTURE_TYPE Type);
+static struct _ARCHITECTURE_FORMAT *GetArchitectureFormat(ARCHITECTURE_TYPE Type);
//////////////////////////////////////////////////////////////////////
// Disassembler setup
diff --git a/thirdparty/mhook/disasm-lib/disasm.h b/thirdparty/mhook/disasm-lib/disasm.h
index 6e35ab72..4b8be071 100644
--- a/thirdparty/mhook/disasm-lib/disasm.h
+++ b/thirdparty/mhook/disasm-lib/disasm.h
@@ -25,6 +25,9 @@ typedef unsigned long U32;
typedef LONG64 S64;
typedef ULONG64 U64;
+// Forward declarations
+struct _INSTRUCTION;
+
#ifdef SPEEDY
// On Visual Studio 6, making the internal functions inline makes compiling take forever
#define INTERNAL static _inline
diff --git a/thirdparty/mhook/disasm-lib/disasm_x86.c b/thirdparty/mhook/disasm-lib/disasm_x86.c
index 26a5d764..005a3d1a 100644
--- a/thirdparty/mhook/disasm-lib/disasm_x86.c
+++ b/thirdparty/mhook/disasm-lib/disasm_x86.c
@@ -25,8 +25,10 @@
#include "disasm_x86_tables.h"
#ifdef _WIN64
+#ifdef _MSC_VER
#pragma warning(disable:4311 4312)
#endif
+#endif
////////////////////////////////////////////////////////////////////////
// Internal macros
@@ -130,7 +132,7 @@
{ \
if (!Instruction->AnomalyOccurred) \
{ \
- if (!SuppressErrors) printf("[0x%08I64X] ANOMALY: unexpected segment 0x%02X\n", VIRTUAL_ADDRESS, X86Instruction->Selector); \
+ if (!SuppressErrors) printf("[0x%08I64X] ANOMALY: unexpected segment 0x%02lX\n", VIRTUAL_ADDRESS, X86Instruction->Selector); \
Instruction->AnomalyOccurred = TRUE; \
} \
} \
@@ -1915,7 +1917,7 @@ HasSpecialExtension:
Instruction->AnomalyOccurred = TRUE;
break;
default:
- if (!SuppressErrors) printf("[0x%08I64X] ANOMALY: unexpected segment 0x%02X\n", VIRTUAL_ADDRESS, X86Instruction->Selector);
+ if (!SuppressErrors) printf("[0x%08I64X] ANOMALY: unexpected segment 0x%02lX\n", VIRTUAL_ADDRESS, X86Instruction->Selector);
Instruction->AnomalyOccurred = TRUE;
break;
}
@@ -2461,7 +2463,7 @@ HasSpecialExtension:
if (!Instruction->AnomalyOccurred &&
((X86Instruction->OperandSize != 2 && (Instruction->StackChange & 3)) || (Instruction->StackChange & 1)))
{
- if (!SuppressErrors) printf("[0x%08I64X] ANOMALY: \"%s\" has invalid stack change 0x%02X\n", VIRTUAL_ADDRESS, X86Opcode->Mnemonic, Instruction->StackChange);
+ if (!SuppressErrors) printf("[0x%08I64X] ANOMALY: \"%s\" has invalid stack change 0x%02lX\n", VIRTUAL_ADDRESS, X86Opcode->Mnemonic, Instruction->StackChange);
Instruction->AnomalyOccurred = TRUE;
}
}
@@ -3737,7 +3739,7 @@ INTERNAL U8 *SetOperands(INSTRUCTION *Instruction, U8 *Address, U32 Flags)
}
else if (X86Instruction->OperandSize == 2)
{
- if (!SuppressErrors) printf("[0x%08I64X] ERROR: AMODE_PR illegal in 16-bit mode (\"%s\")\n", VIRTUAL_ADDRESS, rex_modrm.rm, X86Instruction->Opcode.Mnemonic);
+ if (!SuppressErrors) printf("[0x%08I64X] ERROR: AMODE_PR illegal in 16-bit mode (\"%s\")\n", VIRTUAL_ADDRESS, X86Instruction->Opcode.Mnemonic);
goto abort;
}
if (!Decode) continue;
@@ -3764,7 +3766,7 @@ INTERNAL U8 *SetOperands(INSTRUCTION *Instruction, U8 *Address, U32 Flags)
}
else if (X86Instruction->OperandSize == 2)
{
- if (!SuppressErrors) printf("[0x%08I64X] ERROR: AMODE_VR illegal in 16-bit mode (\"%s\")\n", VIRTUAL_ADDRESS, rex_modrm.rm, X86Instruction->Opcode.Mnemonic);
+ if (!SuppressErrors) printf("[0x%08I64X] ERROR: AMODE_VR illegal in 16-bit mode (\"%s\")\n", VIRTUAL_ADDRESS, X86Instruction->Opcode.Mnemonic);
goto abort;
}
if (!Decode) continue;
diff --git a/thirdparty/mhook/disasm-lib/disasm_x86.h b/thirdparty/mhook/disasm-lib/disasm_x86.h
index e64a11f2..b8505029 100644
--- a/thirdparty/mhook/disasm-lib/disasm_x86.h
+++ b/thirdparty/mhook/disasm-lib/disasm_x86.h
@@ -94,33 +94,33 @@ extern "C" {
// NOTE: OPTYPES >= 0x80 reserved for registers (OP_REG+XX)
-#define OPTYPE_REG_AL OP_REG+0x01
-#define OPTYPE_REG_CL OP_REG+0x02
-#define OPTYPE_REG_AH OP_REG+0x03
-#define OPTYPE_REG_AX OP_REG+0x04
-#define OPTYPE_REG_DX OP_REG+0x05
-#define OPTYPE_REG_ECX OP_REG+0x06
-#define OPTYPE_REG8 OP_REG+0x07
+#define OPTYPE_REG_AL (OP_REG+0x01)
+#define OPTYPE_REG_CL (OP_REG+0x02)
+#define OPTYPE_REG_AH (OP_REG+0x03)
+#define OPTYPE_REG_AX (OP_REG+0x04)
+#define OPTYPE_REG_DX (OP_REG+0x05)
+#define OPTYPE_REG_ECX (OP_REG+0x06)
+#define OPTYPE_REG8 (OP_REG+0x07)
// If address size is 2, use BP
// If address size is 4, use EBP
// If address size is 8, use RBP
-#define OPTYPE_REG_xBP OP_REG+0x08
+#define OPTYPE_REG_xBP (OP_REG+0x08)
// If address size is 2, use BP
// If address size is 4, use EBP
// If address size is 8, use RBP
-#define OPTYPE_REG_xSP OP_REG+0x09
+#define OPTYPE_REG_xSP (OP_REG+0x09)
// If operand size is 2, take 8-bit register
// If operand size is 4, take 16-bit register
// If operand size is 8, take 32-bit register
-#define OPTYPE_REG_xAX_SMALL OP_REG+0x0a
+#define OPTYPE_REG_xAX_SMALL (OP_REG+0x0a)
// If operand size is 2, take 16-bit register
// If operand size is 4, take 32-bit register
// If operand size is 8, take 64-bit register
-#define OPTYPE_REG_xAX_BIG OP_REG+0x0b
+#define OPTYPE_REG_xAX_BIG (OP_REG+0x0b)
typedef enum _CPU_TYPE
{