2017-12-02 03:40:56 +08:00
|
|
|
|
/***************************************************************************************************
|
|
|
|
|
|
|
|
|
|
Zyan Disassembler Library (Zydis)
|
|
|
|
|
|
2017-12-02 13:36:12 +08:00
|
|
|
|
Original Author : Florian Bernd, Joel H<EFBFBD>ner
|
2017-12-02 03:40:56 +08:00
|
|
|
|
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
|
|
|
|
|
***************************************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef ZYDIS_STRING_H
|
|
|
|
|
#define ZYDIS_STRING_H
|
|
|
|
|
|
|
|
|
|
#include <Zydis/CommonTypes.h>
|
2017-12-02 13:36:12 +08:00
|
|
|
|
#include <Zydis/Status.h>
|
|
|
|
|
#include <Zydis/Internal/LibC.h>
|
2017-12-02 03:40:56 +08:00
|
|
|
|
|
|
|
|
|
/* ============================================================================================== */
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/* Enums and types */
|
2017-12-02 03:40:56 +08:00
|
|
|
|
/* ============================================================================================== */
|
|
|
|
|
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
/* String */
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Defines the `ZydisString` struct.
|
|
|
|
|
*/
|
2017-12-02 03:40:56 +08:00
|
|
|
|
typedef struct ZydisString_
|
|
|
|
|
{
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief The buffer that contains the actual string (0-termination is optional!).
|
|
|
|
|
*/
|
|
|
|
|
char *buffer;
|
|
|
|
|
/**
|
2017-12-03 06:46:05 +08:00
|
|
|
|
* @brief The length of the string (without 0-termination).
|
2017-12-02 13:36:12 +08:00
|
|
|
|
*/
|
2017-12-02 03:40:56 +08:00
|
|
|
|
ZydisUSize length;
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief The total buffer capacity.
|
|
|
|
|
*/
|
|
|
|
|
ZydisUSize capacity;
|
2017-12-02 03:40:56 +08:00
|
|
|
|
} ZydisString;
|
|
|
|
|
|
2017-12-03 06:46:05 +08:00
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
/* Static string */
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Defines the `ZydisStaticString` struct.
|
|
|
|
|
*
|
|
|
|
|
* This more compact struct is mainly used for internal string-tables to save up some bytes.
|
|
|
|
|
*/
|
|
|
|
|
typedef struct ZydisStaticString_
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* @brief The buffer that contains the actual string (0-termination is optional!).
|
|
|
|
|
*/
|
|
|
|
|
const char* buffer;
|
|
|
|
|
/**
|
|
|
|
|
* @brief The length of the string (without 0-termination).
|
|
|
|
|
*/
|
|
|
|
|
ZydisU8 length;
|
|
|
|
|
} ZydisStaticString;
|
|
|
|
|
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
/* Letter Case */
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Defines the `ZydisLetterCase` datatype.
|
|
|
|
|
*/
|
|
|
|
|
typedef ZydisU8 ZydisLetterCase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Values that represent letter cases.
|
|
|
|
|
*/
|
|
|
|
|
enum ZydisLetterCases
|
|
|
|
|
{
|
|
|
|
|
/**
|
2017-12-03 00:50:34 +08:00
|
|
|
|
* @brief Uses the given text "as is".
|
2017-12-02 13:36:12 +08:00
|
|
|
|
*/
|
|
|
|
|
ZYDIS_LETTER_CASE_DEFAULT,
|
|
|
|
|
/**
|
|
|
|
|
* @brief Converts the given text to lowercase letters.
|
|
|
|
|
*/
|
|
|
|
|
ZYDIS_LETTER_CASE_LOWER,
|
|
|
|
|
/**
|
|
|
|
|
* @brief Converts the given text to uppercase letters.
|
|
|
|
|
*/
|
|
|
|
|
ZYDIS_LETTER_CASE_UPPER,
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Maximum value of this enum.
|
|
|
|
|
*/
|
|
|
|
|
ZYDIS_LETTER_CASE_MAX_VALUE = ZYDIS_LETTER_CASE_UPPER
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/* ============================================================================================== */
|
|
|
|
|
/* Macros */
|
|
|
|
|
/* ============================================================================================== */
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
/* Helper Macros */
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
2017-12-02 14:05:29 +08:00
|
|
|
|
* @brief Creates a `ZydisString` struct from a static C-string.
|
2017-12-02 13:36:12 +08:00
|
|
|
|
*
|
|
|
|
|
* @param string The C-string constant.
|
|
|
|
|
*/
|
|
|
|
|
#define ZYDIS_MAKE_STRING(string) \
|
|
|
|
|
{ (char*)string, sizeof(string) - 1, sizeof(string) - 1 }
|
|
|
|
|
|
2017-12-03 06:46:05 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Creates a `ZydisStaticString` from a static C-string.
|
|
|
|
|
*
|
|
|
|
|
* @param string The C-string constant.
|
|
|
|
|
*/
|
|
|
|
|
#define ZYDIS_MAKE_STATIC_STRING(string) \
|
|
|
|
|
{ string, sizeof(string) - 1 }
|
|
|
|
|
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/* ============================================================================================== */
|
|
|
|
|
/* Functions */
|
|
|
|
|
/* ============================================================================================== */
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
/* Basic Operations */
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Initializes a `ZydisString` struct with a C-string.
|
|
|
|
|
*
|
|
|
|
|
* @param string The string to initialize.
|
2018-02-23 08:34:06 +08:00
|
|
|
|
* @param text The C-string constant.
|
2017-12-02 13:36:12 +08:00
|
|
|
|
*
|
|
|
|
|
* @return A zydis status code.
|
|
|
|
|
*/
|
2018-02-23 08:34:06 +08:00
|
|
|
|
ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit(ZydisString* string, char* text)
|
2017-12-02 13:36:12 +08:00
|
|
|
|
{
|
2018-02-23 08:34:06 +08:00
|
|
|
|
if (!string || !text)
|
2017-12-02 13:36:12 +08:00
|
|
|
|
{
|
|
|
|
|
return ZYDIS_STATUS_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-23 08:34:06 +08:00
|
|
|
|
const ZydisUSize length = ZydisStrLen(text);
|
|
|
|
|
string->buffer = text;
|
2017-12-03 00:50:34 +08:00
|
|
|
|
string->length = length;
|
|
|
|
|
string->capacity = length;
|
2017-12-02 13:36:12 +08:00
|
|
|
|
|
|
|
|
|
return ZYDIS_STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-03 06:46:05 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Finalizes a `ZydisString` struct by adding a terminating zero byte.
|
|
|
|
|
*
|
|
|
|
|
* @param string The string to finalize.
|
|
|
|
|
*
|
|
|
|
|
* @return A zydis status code.
|
|
|
|
|
*/
|
2018-02-23 08:34:06 +08:00
|
|
|
|
ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringFinalize(ZydisString* string)
|
2017-12-03 06:46:05 +08:00
|
|
|
|
{
|
|
|
|
|
if (!string)
|
|
|
|
|
{
|
|
|
|
|
return ZYDIS_STATUS_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
if (string->length >= string->capacity)
|
|
|
|
|
{
|
|
|
|
|
return ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string->buffer[string->length] = 0;
|
|
|
|
|
return ZYDIS_STATUS_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
2017-12-03 00:50:34 +08:00
|
|
|
|
* @brief Appends a `ZydisString` to another `ZydisString`, converting it to the specified
|
2017-12-02 13:36:12 +08:00
|
|
|
|
* letter-case.
|
|
|
|
|
*
|
|
|
|
|
* @param string The string to append to.
|
|
|
|
|
* @param text The string to append.
|
|
|
|
|
* @param letterCase The letter case to use.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c text.
|
|
|
|
|
*/
|
2018-02-23 08:34:06 +08:00
|
|
|
|
ZYDIS_EXPORT ZydisStatus ZydisStringAppendEx(ZydisString* string, const ZydisString* text,
|
2017-12-02 13:36:12 +08:00
|
|
|
|
ZydisLetterCase letterCase);
|
|
|
|
|
|
|
|
|
|
/**
|
2017-12-03 00:50:34 +08:00
|
|
|
|
* @brief Appends the given C-string to a `ZydisString`, converting it to the specified
|
2017-12-02 13:36:12 +08:00
|
|
|
|
* letter-case.
|
|
|
|
|
*
|
|
|
|
|
* @param string The string to append to.
|
|
|
|
|
* @param text The C-string to append.
|
|
|
|
|
* @param letterCase The letter case to use.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c text.
|
|
|
|
|
*/
|
2018-02-23 08:34:06 +08:00
|
|
|
|
ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExC(ZydisString* string,
|
2017-12-02 13:36:12 +08:00
|
|
|
|
const char* text, ZydisLetterCase letterCase)
|
|
|
|
|
{
|
|
|
|
|
ZydisString other;
|
|
|
|
|
ZYDIS_CHECK(ZydisStringInit(&other, (char*)text));
|
|
|
|
|
|
|
|
|
|
return ZydisStringAppendEx(string, &other, letterCase);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-03 06:46:05 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Appends the given 'ZydisStaticString' to a `ZydisString`, converting it to the
|
|
|
|
|
* specified letter-case.
|
|
|
|
|
*
|
|
|
|
|
* @param string The string to append to.
|
|
|
|
|
* @param text The static-string to append.
|
|
|
|
|
* @param letterCase The letter case to use.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c text.
|
|
|
|
|
*/
|
2018-02-23 08:34:06 +08:00
|
|
|
|
ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendExStatic(ZydisString* string,
|
2017-12-03 06:46:05 +08:00
|
|
|
|
const ZydisStaticString* text, ZydisLetterCase letterCase)
|
|
|
|
|
{
|
|
|
|
|
if (!text || !text->buffer)
|
|
|
|
|
{
|
|
|
|
|
return ZYDIS_STATUS_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ZydisString other;
|
|
|
|
|
other.buffer = (char*)text->buffer;
|
|
|
|
|
other.length = text->length;
|
|
|
|
|
|
|
|
|
|
return ZydisStringAppendEx(string, &other, letterCase);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Appends a `ZydisString` to another `ZydisString`.
|
|
|
|
|
*
|
|
|
|
|
* @param string The string to append to.
|
|
|
|
|
* @param text The string to append.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c text.
|
|
|
|
|
*/
|
2018-02-23 08:34:06 +08:00
|
|
|
|
ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppend(ZydisString* string,
|
2017-12-02 13:36:12 +08:00
|
|
|
|
const ZydisString* text)
|
|
|
|
|
{
|
|
|
|
|
return ZydisStringAppendEx(string, text, ZYDIS_LETTER_CASE_DEFAULT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Appends the given C-string to a `ZydisString`.
|
|
|
|
|
*
|
|
|
|
|
* @param string The string to append to.
|
|
|
|
|
* @param text The C-string to append.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c text.
|
|
|
|
|
*/
|
2018-02-23 08:34:06 +08:00
|
|
|
|
ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendC(ZydisString* string, const char* text)
|
2017-12-02 13:36:12 +08:00
|
|
|
|
{
|
|
|
|
|
ZydisString other;
|
|
|
|
|
ZYDIS_CHECK(ZydisStringInit(&other, (char*)text));
|
|
|
|
|
|
2017-12-02 14:05:29 +08:00
|
|
|
|
return ZydisStringAppendEx(string, &other, ZYDIS_LETTER_CASE_DEFAULT);
|
2017-12-02 13:36:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
2017-12-03 06:46:05 +08:00
|
|
|
|
/**
|
|
|
|
|
* @brief Appends the given 'ZydisStaticString' to a `ZydisString`.
|
|
|
|
|
*
|
|
|
|
|
* @param string The string to append to.
|
|
|
|
|
* @param text The static-string to append.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c text.
|
|
|
|
|
*/
|
2018-02-23 08:34:06 +08:00
|
|
|
|
ZYDIS_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic(ZydisString* string,
|
2017-12-03 06:46:05 +08:00
|
|
|
|
const ZydisStaticString* text, ZydisLetterCase letterCase)
|
|
|
|
|
{
|
|
|
|
|
if (!text || !text->buffer)
|
|
|
|
|
{
|
|
|
|
|
return ZYDIS_STATUS_INVALID_PARAMETER;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ZydisString other;
|
|
|
|
|
other.buffer = (char*)text->buffer;
|
|
|
|
|
other.length = text->length;
|
|
|
|
|
|
|
|
|
|
return ZydisStringAppendEx(string, &other, letterCase);
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-02 13:36:12 +08:00
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
/* Formatting */
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Formats the given unsigned ordinal @c value to its decimal text-representation and
|
2018-02-23 09:23:45 +08:00
|
|
|
|
* appends it to the @c string.
|
2017-12-02 13:36:12 +08:00
|
|
|
|
*
|
|
|
|
|
* @param string A pointer to the string.
|
|
|
|
|
* @param value The value.
|
|
|
|
|
* @param paddingLength Padds the converted value with leading zeros, if the number of chars is
|
|
|
|
|
* less than the @c paddingLength.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c value.
|
|
|
|
|
*
|
|
|
|
|
* The string-buffer pointer is increased by the number of chars written, if the call was
|
|
|
|
|
* successfull.
|
|
|
|
|
*/
|
2018-02-23 09:23:45 +08:00
|
|
|
|
ZYDIS_EXPORT ZydisStatus ZydisStringAppendDecU(ZydisString* string, ZydisU64 value,
|
2017-12-02 13:36:12 +08:00
|
|
|
|
ZydisU8 paddingLength);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Formats the given signed ordinal @c value to its decimal text-representation and
|
2018-02-23 09:23:45 +08:00
|
|
|
|
* appends it to the @c string.
|
2017-12-02 13:36:12 +08:00
|
|
|
|
*
|
|
|
|
|
* @param string A pointer to the string.
|
|
|
|
|
* @param value The value.
|
|
|
|
|
* @param paddingLength Padds the converted value with leading zeros, if the number of chars is
|
|
|
|
|
* less than the @c paddingLength (the sign char is ignored).
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c value.
|
|
|
|
|
*
|
|
|
|
|
* The string-buffer pointer is increased by the number of chars written, if the call was
|
|
|
|
|
* successfull.
|
|
|
|
|
*/
|
2018-02-23 09:23:45 +08:00
|
|
|
|
ZYDIS_EXPORT ZydisStatus ZydisStringAppendDecS(ZydisString* string, ZydisI64 value,
|
2017-12-02 13:36:12 +08:00
|
|
|
|
ZydisU8 paddingLength);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Formats the given unsigned ordinal @c value to its hexadecimal text-representation and
|
2018-02-23 09:23:45 +08:00
|
|
|
|
* appends it to the @c string.
|
2017-12-02 13:36:12 +08:00
|
|
|
|
*
|
|
|
|
|
* @param string A pointer to the string.
|
|
|
|
|
* @param value The value.
|
|
|
|
|
* @param paddingLength Padds the converted value with leading zeros, if the number of chars is
|
|
|
|
|
* less than the @c paddingLength.
|
|
|
|
|
* @param uppercase Set @c TRUE to print the hexadecimal value in uppercase letters instead
|
|
|
|
|
* of lowercase ones.
|
|
|
|
|
* @param prefix The string to use as prefix or `NULL`, if not needed.
|
|
|
|
|
* @param suffix The string to use as suffix or `NULL`, if not needed.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c value.
|
|
|
|
|
*
|
|
|
|
|
* The string-buffer pointer is increased by the number of chars written, if the call was
|
|
|
|
|
* successfull.
|
|
|
|
|
*/
|
2018-02-23 09:23:45 +08:00
|
|
|
|
ZYDIS_EXPORT ZydisStatus ZydisStringAppendHexU(ZydisString* string, ZydisU64 value,
|
2017-12-02 13:36:12 +08:00
|
|
|
|
ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix,
|
|
|
|
|
const ZydisString* suffix);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Formats the given signed ordinal @c value to its hexadecimal text-representation and
|
2018-02-23 09:23:45 +08:00
|
|
|
|
* appends it to the @c string.
|
2017-12-02 13:36:12 +08:00
|
|
|
|
*
|
|
|
|
|
* @param string A pointer to the string.
|
|
|
|
|
* @param value The value.
|
|
|
|
|
* @param paddingLength Padds the converted value with leading zeros, if the number of chars is
|
|
|
|
|
* less than the @c paddingLength (the sign char is ignored).
|
|
|
|
|
* @param uppercase Set @c TRUE to print the hexadecimal value in uppercase letters instead
|
|
|
|
|
* of lowercase ones.
|
|
|
|
|
* @param prefix The string to use as prefix or `NULL`, if not needed.
|
|
|
|
|
* @param suffix The string to use as suffix or `NULL`, if not needed.
|
|
|
|
|
*
|
|
|
|
|
* @return @c ZYDIS_STATUS_SUCCESS, if the function succeeded, or
|
|
|
|
|
* @c ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not
|
|
|
|
|
* sufficient to append the given @c value.
|
|
|
|
|
*
|
|
|
|
|
* The string-buffer pointer is increased by the number of chars written, if the call was
|
|
|
|
|
* successfull.
|
|
|
|
|
*/
|
2018-02-23 09:23:45 +08:00
|
|
|
|
ZYDIS_EXPORT ZydisStatus ZydisStringAppendHexS(ZydisString* string, ZydisI64 value,
|
2017-12-02 13:36:12 +08:00
|
|
|
|
ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString* prefix,
|
|
|
|
|
const ZydisString* suffix);
|
|
|
|
|
|
|
|
|
|
/* ---------------------------------------------------------------------------------------------- */
|
|
|
|
|
|
2017-12-02 03:40:56 +08:00
|
|
|
|
/* ============================================================================================== */
|
|
|
|
|
|
|
|
|
|
#endif // ZYDIS_STRING_H
|