From ef22aef632e2d66d1c9a786c4cb2943fcfb8e7f6 Mon Sep 17 00:00:00 2001 From: flobernd Date: Fri, 23 Feb 2018 01:34:06 +0100 Subject: [PATCH] Exported `ZydisString*` functions --- examples/FormatterHooks.c | 2 +- examples/ZydisPerfTest.c | 8 ++++---- include/Zydis/Formatter.h | 4 ++-- include/Zydis/String.h | 32 ++++++++++++++++---------------- 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/FormatterHooks.c b/examples/FormatterHooks.c index d6edd0f..9469ede 100644 --- a/examples/FormatterHooks.c +++ b/examples/FormatterHooks.c @@ -138,7 +138,7 @@ ZydisFormatterFunc defaultPrintMnemonic; static ZydisStatus ZydisFormatterPrintMnemonic(const ZydisFormatter* formatter, ZydisString* string, const ZydisDecodedInstruction* instruction, ZydisCustomUserData* userData) { - // We use the user-data to pass data to the @c ZydisFormatterFormatOperandImm function. + // We use the user-data to pass data to the @c ZydisFormatterFormatOperandImm function userData->ommitImmediate = ZYDIS_TRUE; // Rewrite the instruction-mnemonic for the given instructions diff --git a/examples/ZydisPerfTest.c b/examples/ZydisPerfTest.c index 841e4e9..3a74ac9 100644 --- a/examples/ZydisPerfTest.c +++ b/examples/ZydisPerfTest.c @@ -245,7 +245,7 @@ void generateTestData(FILE* file, uint8_t encoding) { data[i] = rand() % 256; } - uint8_t offset = rand() % (ZYDIS_MAX_INSTRUCTION_LENGTH - 2); + const uint8_t offset = rand() % (ZYDIS_MAX_INSTRUCTION_LENGTH - 2); switch (encoding) { case 0: @@ -302,7 +302,7 @@ void generateTestData(FILE* file, uint8_t encoding) fwrite(&instruction.data[0], 1, instruction.length, file); ++count; - uint8_t p = (uint8_t)((double)count / 100000 * 100); + const uint8_t p = (uint8_t)((double)count / 100000 * 100); if (last < p) { last = p; @@ -367,7 +367,7 @@ int main(int argc, char** argv) { FILE* file; - size_t len = strlen(directory); + const size_t len = strlen(directory); char buf[1024]; strncpy(&buf[0], directory, sizeof(buf) - 1); if (generate) @@ -390,7 +390,7 @@ int main(int argc, char** argv) } else { fseek(file, 0L, SEEK_END); - long length = ftell(file); + const long length = ftell(file); void* buffer = malloc(length); if (!buffer) { diff --git a/include/Zydis/Formatter.h b/include/Zydis/Formatter.h index d4fc980..474a257 100644 --- a/include/Zydis/Formatter.h +++ b/include/Zydis/Formatter.h @@ -553,7 +553,7 @@ typedef ZydisStatus (*ZydisFormatterAddressFunc)(const ZydisFormatter* formatter * @param string A pointer to the string. * @param instruction A pointer to the `ZydisDecodedInstruction` struct. * @param operand A pointer to the `ZydisDecodedOperand` struct. - * @param type The decorator type. + * @param decorator The decorator type. * @param userData A pointer to user-defined data. * * @return Returning a status code other than `ZYDIS_STATUS_SUCCESS` will immediately cause the @@ -564,7 +564,7 @@ typedef ZydisStatus (*ZydisFormatterAddressFunc)(const ZydisFormatter* formatter */ typedef ZydisStatus (*ZydisFormatterDecoratorFunc)(const ZydisFormatter* formatter, ZydisString* string, const ZydisDecodedInstruction* instruction, - const ZydisDecodedOperand* operand, ZydisDecoratorType type, void* userData); + const ZydisDecodedOperand* operand, ZydisDecoratorType decorator, void* userData); /* ---------------------------------------------------------------------------------------------- */ /* Formatter struct */ diff --git a/include/Zydis/String.h b/include/Zydis/String.h index 2bad113..14afd98 100644 --- a/include/Zydis/String.h +++ b/include/Zydis/String.h @@ -156,19 +156,19 @@ enum ZydisLetterCases * @brief Initializes a `ZydisString` struct with a C-string. * * @param string The string to initialize. - * @param value The C-string constant. + * @param text The C-string constant. * * @return A zydis status code. */ -ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit(ZydisString* string, char* value) +ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit(ZydisString* string, char* text) { - if (!string || !value) + if (!string || !text) { return ZYDIS_STATUS_INVALID_PARAMETER; } - const ZydisUSize length = ZydisStrLen(value); - string->buffer = value; + const ZydisUSize length = ZydisStrLen(text); + string->buffer = text; string->length = length; string->capacity = length; @@ -182,7 +182,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit(ZydisString* string, ch * * @return A zydis status code. */ -ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringFinalize(ZydisString* string) +ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringFinalize(ZydisString* string) { if (!string) { @@ -211,7 +211,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringFinalize(ZydisString* string * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * sufficient to append the given @c text. */ -ZYDIS_NO_EXPORT ZydisStatus ZydisStringAppendEx(ZydisString* string, const ZydisString* text, +ZYDIS_EXPORT ZydisStatus ZydisStringAppendEx(ZydisString* string, const ZydisString* text, ZydisLetterCase letterCase); /** @@ -226,7 +226,7 @@ ZYDIS_NO_EXPORT ZydisStatus ZydisStringAppendEx(ZydisString* string, const Zydis * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * sufficient to append the given @c text. */ -ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExC(ZydisString* string, +ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExC(ZydisString* string, const char* text, ZydisLetterCase letterCase) { ZydisString other; @@ -247,7 +247,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExC(ZydisString* strin * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * sufficient to append the given @c text. */ -ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExStatic(ZydisString* string, +ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExStatic(ZydisString* string, const ZydisStaticString* text, ZydisLetterCase letterCase) { if (!text || !text->buffer) @@ -272,7 +272,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExStatic(ZydisString* * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * sufficient to append the given @c text. */ -ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppend(ZydisString* string, +ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppend(ZydisString* string, const ZydisString* text) { return ZydisStringAppendEx(string, text, ZYDIS_LETTER_CASE_DEFAULT); @@ -288,7 +288,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppend(ZydisString* string, * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * sufficient to append the given @c text. */ -ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendC(ZydisString* string, const char* text) +ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendC(ZydisString* string, const char* text) { ZydisString other; ZYDIS_CHECK(ZydisStringInit(&other, (char*)text)); @@ -306,7 +306,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendC(ZydisString* string, * @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not * sufficient to append the given @c text. */ -ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* string, +ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* string, const ZydisStaticString* text, ZydisLetterCase letterCase) { if (!text || !text->buffer) @@ -341,7 +341,7 @@ ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* st * The string-buffer pointer is increased by the number of chars written, if the call was * successfull. */ -ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value, +ZYDIS_EXPORT ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength); /** @@ -360,7 +360,7 @@ ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecU(ZydisString* string, ZydisU64 value, * The string-buffer pointer is increased by the number of chars written, if the call was * successfull. */ -ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value, +ZYDIS_EXPORT ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value, ZydisU8 paddingLength); /** @@ -383,7 +383,7 @@ ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecS(ZydisString* string, ZydisI64 value, * The string-buffer pointer is increased by the number of chars written, if the call was * successfull. */ -ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value, +ZYDIS_EXPORT ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value, ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix, const ZydisString* suffix); @@ -407,7 +407,7 @@ ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexU(ZydisString* string, ZydisU64 value, * The string-buffer pointer is increased by the number of chars written, if the call was * successfull. */ -ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexS(ZydisString* string, ZydisI64 value, +ZYDIS_EXPORT ZydisStatus ZydisPrintHexS(ZydisString* string, ZydisI64 value, ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix, const ZydisString* suffix);