Fixed a bug in ZYDIS_CHECK that caused functions to run more than once on certain conditions

This commit is contained in:
flobernd 2017-01-11 17:29:26 +01:00
parent 9804bf1d3e
commit 5af25eee4b
3 changed files with 15 additions and 28 deletions

View File

@ -141,6 +141,20 @@ enum ZydisStatusCode
*/
#define ZYDIS_SUCCESS(status) (status == ZYDIS_STATUS_SUCCESS)
/**
* @brief Checks if a zydis operation was successfull and returns the status-code, if not.
*
* @param status The zydis status-code to check.
*/
#define ZYDIS_CHECK(status) \
{ \
ZydisStatus s = status; \
if (!ZYDIS_SUCCESS(s)) \
{ \
return s; \
} \
}
/* ============================================================================================== */
#ifdef __cplusplus

View File

@ -29,20 +29,6 @@
#include <Zydis/Decoder.h>
#include <Zydis/Internal/InstructionTable.h>
/* ============================================================================================== */
/* Internal macros */
/* ============================================================================================== */
/* ---------------------------------------------------------------------------------------------- */
/* Helper macros */
/* ---------------------------------------------------------------------------------------------- */
#define ZYDIS_CHECK(status) \
if (status != ZYDIS_STATUS_SUCCESS) \
{ \
return status; \
}
/* ============================================================================================== */
/* Internal functions */
/* ============================================================================================== */
@ -2291,6 +2277,7 @@ ZydisStatus ZydisDecoderInitInstructionDecoder(ZydisInstructionDecoder* decoder,
decoder->disassemblerMode = disassemblerMode;
decoder->input.buffer = NULL;
decoder->input.bufferLen = 0;
decoder->instructionPointer = 0;
return ZYDIS_STATUS_SUCCESS;
}

View File

@ -32,20 +32,6 @@
#include <Zydis/Formatter.h>
#include <Zydis/Utils.h>
/* ============================================================================================== */
/* Internal macros */
/* ============================================================================================== */
/* ---------------------------------------------------------------------------------------------- */
/* Helper macros */
/* ---------------------------------------------------------------------------------------------- */
#define ZYDIS_CHECK(status) \
if (status != ZYDIS_STATUS_SUCCESS) \
{ \
return status; \
}
/* ============================================================================================== */
/* String formatting */
/* ============================================================================================== */