From b365b775c9386eff37c929670450a1a1c2b32d05 Mon Sep 17 00:00:00 2001 From: Peace-Maker Date: Sat, 27 Jan 2018 17:24:02 +0100 Subject: [PATCH] Fix linux build --- DynamicHooks/asm.cpp | 14 +++++++------- DynamicHooks/hook.cpp | 3 ++- dynhooks_sourcepawn.cpp | 16 ++++++++-------- signatures.cpp | 2 +- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/DynamicHooks/asm.cpp b/DynamicHooks/asm.cpp index 2969b8b..baf813d 100644 --- a/DynamicHooks/asm.cpp +++ b/DynamicHooks/asm.cpp @@ -193,9 +193,9 @@ int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) { else if(!twoByte) { if((opcode & 0xC4) == 0x00 || - (opcode & 0xF4) == 0x60 && ((opcode & 0x0A) == 0x02 || (opcode & 0x09) == 0x09) || + ((opcode & 0xF4) == 0x60 && ((opcode & 0x0A) == 0x02 || (opcode & 0x09) == 0x09)) || (opcode & 0xF0) == 0x80 || - (opcode & 0xF8) == 0xC0 && (opcode & 0x0E) != 0x02 || + ((opcode & 0xF8) == 0xC0 && (opcode & 0x0E) != 0x02) || (opcode & 0xFC) == 0xD0 || (opcode & 0xF6) == 0xF6) { @@ -206,11 +206,11 @@ int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) { } else { - if((opcode & 0xF0) == 0x00 && (opcode & 0x0F) >= 0x04 && (opcode & 0x0D) != 0x0D || + if(((opcode & 0xF0) == 0x00 && (opcode & 0x0F) >= 0x04 && (opcode & 0x0D) != 0x0D) || (opcode & 0xF0) == 0x30 || opcode == 0x77 || (opcode & 0xF0) == 0x80 || - (opcode & 0xF0) == 0xA0 && (opcode & 0x07) <= 0x02 || + ((opcode & 0xF0) == 0xA0 && (opcode & 0x07) <= 0x02) || (opcode & 0xF8) == 0xC8) { // No mod R/M byte @@ -286,7 +286,7 @@ int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) { (opcode & 0xFE) == 0xD4 || // AAD/AAM (opcode & 0xF8) == 0xE0 || // LOOP/JCXZ opcode == 0xEB || - opcode == 0xF6 && (modRM & 0x30) == 0x00) // TEST + (opcode == 0xF6 && (modRM & 0x30) == 0x00)) // TEST { if (dest) *dest++ = *func++; @@ -311,7 +311,7 @@ int copy_bytes(unsigned char *func, unsigned char* dest, int required_len) { (opcode & 0xFC) == 0xA0 || (opcode & 0xEE) == 0xA8 || opcode == 0xC7 || - opcode == 0xF7 && (modRM & 0x30) == 0x00) + (opcode == 0xF7 && (modRM & 0x30) == 0x00)) { if (dest) { //Fix CALL/JMP offset @@ -406,7 +406,7 @@ void* eval_jump(void* src) { else if (addr[0] == OP_JMP_BYTE) { addr = &addr[OP_JMP_BYTE_SIZE] + *(char*)&addr[1]; //mangled 32bit jump? - if (addr[0] = OP_JMP) { + if (addr[0] == OP_JMP) { addr = addr + *(int*)&addr[1]; } return addr; diff --git a/DynamicHooks/hook.cpp b/DynamicHooks/hook.cpp index edc11f8..c3afc08 100644 --- a/DynamicHooks/hook.cpp +++ b/DynamicHooks/hook.cpp @@ -95,7 +95,8 @@ CHook::~CHook() copy_bytes((unsigned char *) m_pTrampoline, (unsigned char *) m_pFunc, JMP_SIZE); // Free the trampoline array - delete [] m_pTrampoline; + unsigned char* pTrampoline = (unsigned char *)m_pTrampoline; + delete [] pTrampoline; // Free the asm bridge and new return address smutils->GetScriptingEngine()->FreePageMemory(m_pBridge); diff --git a/dynhooks_sourcepawn.cpp b/dynhooks_sourcepawn.cpp index fd7782e..0a334ba 100644 --- a/dynhooks_sourcepawn.cpp +++ b/dynhooks_sourcepawn.cpp @@ -266,7 +266,7 @@ ReturnAction_t HandleDetour(HookType_t hookType, CHook* pDetour) int argNum = pDetour->m_pCallingConvention->m_vecArgTypes.length(); ReturnAction_t finalRet = ReturnAction_Ignored; - ke::AutoPtr finalRetBuf(new uint8_t[pDetour->m_pCallingConvention->m_returnType.size]); + ke::AutoPtr finalRetBuf(new uint8_t[pDetour->m_pCallingConvention->m_returnType.size]); // Call all the plugin functions.. for (size_t i = 0; i < wrappers->length(); i++) @@ -274,7 +274,7 @@ ReturnAction_t HandleDetour(HookType_t hookType, CHook* pDetour) CDynamicHooksSourcePawn *pWrapper = wrappers->at(i); IPluginFunction *pCallback = pWrapper->plugin_callback; ReturnAction_t tempRet = ReturnAction_Ignored; - ke::AutoPtr tempRetBuf(new uint8_t[pDetour->m_pCallingConvention->m_returnType.size]); + ke::AutoPtr tempRetBuf(new uint8_t[pDetour->m_pCallingConvention->m_returnType.size]); // Find the this pointer. if (pWrapper->callConv == CallConv_THISCALL && pWrapper->thisType != ThisPointer_Ignore) @@ -349,7 +349,7 @@ ReturnAction_t HandleDetour(HookType_t hookType, CHook* pDetour) { if (pWrapper->returnType == ReturnType_String || pWrapper->returnType == ReturnType_Int || pWrapper->returnType == ReturnType_Bool) { - tempRetBuf = *(void **)returnStruct->newResult; + tempRetBuf = *(uint8_t **)returnStruct->newResult; } else if (pWrapper->returnType == ReturnType_Float) { @@ -357,7 +357,7 @@ ReturnAction_t HandleDetour(HookType_t hookType, CHook* pDetour) } else { - tempRetBuf = returnStruct->newResult; + tempRetBuf = (uint8_t *)returnStruct->newResult; } } else //Throw an error if no override was set @@ -378,7 +378,7 @@ ReturnAction_t HandleDetour(HookType_t hookType, CHook* pDetour) tempRet = ReturnAction_Override; if (pWrapper->returnType == ReturnType_String || pWrapper->returnType == ReturnType_Int || pWrapper->returnType == ReturnType_Bool) { - tempRetBuf = *(void **)returnStruct->newResult; + tempRetBuf = *(uint8_t **)returnStruct->newResult; } else if (pWrapper->returnType == ReturnType_Float) { @@ -386,7 +386,7 @@ ReturnAction_t HandleDetour(HookType_t hookType, CHook* pDetour) } else { - tempRetBuf = returnStruct->newResult; + tempRetBuf = (uint8_t *)returnStruct->newResult; } } else //Throw an error if no override was set @@ -404,7 +404,7 @@ ReturnAction_t HandleDetour(HookType_t hookType, CHook* pDetour) tempRet = ReturnAction_Supercede; if (pWrapper->returnType == ReturnType_String || pWrapper->returnType == ReturnType_Int || pWrapper->returnType == ReturnType_Bool) { - tempRetBuf = *(void **)returnStruct->newResult; + tempRetBuf = *(uint8_t **)returnStruct->newResult; } else if (pWrapper->returnType == ReturnType_Float) { @@ -412,7 +412,7 @@ ReturnAction_t HandleDetour(HookType_t hookType, CHook* pDetour) } else { - tempRetBuf = returnStruct->newResult; + tempRetBuf = (uint8_t *)returnStruct->newResult; } } else //Throw an error if no override was set diff --git a/signatures.cpp b/signatures.cpp index 1229cbb..0bf0c1c 100644 --- a/signatures.cpp +++ b/signatures.cpp @@ -270,7 +270,7 @@ SMCResult SignatureGameConfig::ReadSMC_KeyValue(const SMCStates *states, const c } else if (!strcmp(key, "flags")) { - size_t flags; + size_t flags = 0; if (strstr(value, "byval")) flags |= PASSFLAG_BYVAL; else if (strstr(value, "byref"))