diff --git a/include/Zydis/CommonTypes.h b/include/Zydis/CommonTypes.h index dba3af4..9381cc3 100644 --- a/include/Zydis/CommonTypes.h +++ b/include/Zydis/CommonTypes.h @@ -75,6 +75,12 @@ # error "Unsupported word size." #endif +/* ============================================================================================== */ +/* NULL */ +/* ============================================================================================== */ + +#define ZYDIS_NULL ((void*)0) + /* ============================================================================================== */ /* Boolean */ /* ============================================================================================== */ diff --git a/src/Decoder.c b/src/Decoder.c index ee0e33b..28430f3 100644 --- a/src/Decoder.c +++ b/src/Decoder.c @@ -24,7 +24,6 @@ ***************************************************************************************************/ -#include #include #include #include @@ -4237,7 +4236,7 @@ static ZydisStatus ZydisDecodeInstruction(ZydisDecoderContext* context, // Iterate through the decoder tree const ZydisDecoderTreeNode* node = ZydisDecoderTreeGetRootNode(); - const ZydisDecoderTreeNode* temp = NULL; + const ZydisDecoderTreeNode* temp = ZYDIS_NULL; ZydisDecoderTreeNodeType nodeType; do { @@ -4250,7 +4249,7 @@ static ZydisStatus ZydisDecodeInstruction(ZydisDecoderContext* context, if (temp) { node = temp; - temp = NULL; + temp = ZYDIS_NULL; nodeType = ZYDIS_NODETYPE_FILTER_MANDATORY_PREFIX; if (context->mandatoryCandidate == 0x66) { diff --git a/src/FormatHelper.c b/src/FormatHelper.c index 863916b..213ddf9 100644 --- a/src/FormatHelper.c +++ b/src/FormatHelper.c @@ -24,8 +24,6 @@ ***************************************************************************************************/ -#include -#include #include #include @@ -408,7 +406,7 @@ ZydisStatus ZydisPrintHexS(char** buffer, ZydisUSize bufferLen, ZydisI64 value, ZYDIS_CHECK(ZydisPrintStr(buffer, bufEnd - *buffer, prefix, ZYDIS_LETTER_CASE_DEFAULT)); } return ZydisPrintHexU(buffer, bufEnd - *buffer, -value, paddingLength, uppercase, - NULL, suffix); + ZYDIS_NULL, suffix); } return ZydisPrintHexU(buffer, bufferLen, value, paddingLength, uppercase, prefix, suffix); } diff --git a/src/Formatter.c b/src/Formatter.c index 9c6e54d..75e9454 100644 --- a/src/Formatter.c +++ b/src/Formatter.c @@ -24,7 +24,6 @@ ***************************************************************************************************/ -#include #include #include #include @@ -475,7 +474,7 @@ static ZydisStatus ZydisFormatterPrintOperandSizeIntel(const ZydisFormatter* for } if (typecast) { - const char* str = NULL; + const char* str = ZYDIS_NULL; switch (typecast) { case 8: @@ -919,7 +918,7 @@ ZydisStatus ZydisFormatterInit(ZydisFormatter* formatter, ZydisFormatterStyle st formatter->immediateFormat = ZYDIS_IMM_FORMAT_HEX_UNSIGNED; formatter->hexUppercase = ZYDIS_TRUE; formatter->hexPrefix = "0x"; - formatter->hexSuffix = NULL; + formatter->hexSuffix = ZYDIS_NULL; formatter->hexPaddingAddress = 2; formatter->hexPaddingDisplacement = 2; formatter->hexPaddingImmediate = 2; @@ -1151,7 +1150,7 @@ ZydisStatus ZydisFormatterSetHook(ZydisFormatter* formatter, ZydisFormatterHookT ZydisStatus ZydisFormatterFormatInstruction(const ZydisFormatter* formatter, const ZydisDecodedInstruction* instruction, char* buffer, ZydisUSize bufferLen) { - return ZydisFormatterFormatInstructionEx(formatter, instruction, buffer, bufferLen, NULL); + return ZydisFormatterFormatInstructionEx(formatter, instruction, buffer, bufferLen, ZYDIS_NULL); } ZydisStatus ZydisFormatterFormatInstructionEx(const ZydisFormatter* formatter, diff --git a/src/LibC.h b/src/LibC.h index 9fa3b7a..8230208 100644 --- a/src/LibC.h +++ b/src/LibC.h @@ -36,6 +36,7 @@ /* LibC is available */ /* ============================================================================================== */ +# include # define ZydisMemoryCopy memcpy # define ZydisMemorySet memset # define ZydisStrLen strlen diff --git a/src/MetaInfo.c b/src/MetaInfo.c index 2f57038..853e9c8 100644 --- a/src/MetaInfo.c +++ b/src/MetaInfo.c @@ -42,7 +42,7 @@ const char* ZydisCategoryGetString(ZydisInstructionCategory category) { if (category > ZYDIS_ARRAY_SIZE(zydisInstructionCategoryStrings) - 1) { - return NULL; + return ZYDIS_NULL; } return zydisInstructionCategoryStrings[category]; } @@ -51,7 +51,7 @@ const char* ZydisISASetGetString(ZydisISASet isaSet) { if (isaSet > ZYDIS_ARRAY_SIZE(zydisISASetStrings) - 1) { - return NULL; + return ZYDIS_NULL; } return zydisISASetStrings[isaSet]; } @@ -60,7 +60,7 @@ const char* ZydisISAExtGetString(ZydisISAExt isaExt) { if (isaExt > ZYDIS_ARRAY_SIZE(zydisISAExtStrings) - 1) { - return NULL; + return ZYDIS_NULL; } return zydisISAExtStrings[isaExt]; } diff --git a/src/Mnemonic.c b/src/Mnemonic.c index 1feec10..7a11f90 100644 --- a/src/Mnemonic.c +++ b/src/Mnemonic.c @@ -40,7 +40,7 @@ const char* ZydisMnemonicGetString(ZydisMnemonic mnemonic) { if (mnemonic > ZYDIS_ARRAY_SIZE(zydisMnemonicStrings) - 1) { - return NULL; + return ZYDIS_NULL; } return zydisMnemonicStrings[mnemonic]; } diff --git a/src/Register.c b/src/Register.c index d2c2749..737e924 100644 --- a/src/Register.c +++ b/src/Register.c @@ -270,7 +270,7 @@ const char* ZydisRegisterGetString(ZydisRegister reg) { if (reg > (sizeof(registerStrings) / sizeof(registerStrings[0])) - 1) { - return NULL; + return ZYDIS_NULL; } return registerStrings[reg]; } diff --git a/src/SharedData.c b/src/SharedData.c index 80840d8..f7b3b3e 100644 --- a/src/SharedData.c +++ b/src/SharedData.c @@ -141,7 +141,7 @@ ZydisU8 ZydisGetOperandDefinitions(const ZydisInstructionDefinition* definition, { if (definition->operandCount == 0) { - *operand = NULL; + *operand = ZYDIS_NULL; return 0; } ZYDIS_ASSERT(definition->operandReference != 0xFFFF);