Zydis  v2.0.2
String.h File Reference
#include <Zydis/CommonTypes.h>
#include <Zydis/Status.h>
#include <Zydis/Internal/LibC.h>
Include dependency graph for String.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ZydisString_
 Defines the ZydisString struct. More...
 
struct  ZydisStaticString_
 Defines the ZydisStaticString struct. More...
 

Macros

#define ZYDIS_MAKE_STRING(string)    { (char*)string, sizeof(string) - 1, sizeof(string) - 1 }
 Creates a ZydisString struct from a static C-string. More...
 
#define ZYDIS_MAKE_STATIC_STRING(string)    { string, sizeof(string) - 1 }
 Creates a ZydisStaticString from a static C-string. More...
 

Typedefs

typedef struct ZydisString_ ZydisString
 Defines the ZydisString struct. More...
 
typedef struct ZydisStaticString_ ZydisStaticString
 Defines the ZydisStaticString struct. More...
 
typedef ZydisU8 ZydisLetterCase
 Defines the ZydisLetterCase datatype. More...
 

Enumerations

enum  ZydisLetterCases { ZYDIS_LETTER_CASE_DEFAULT , ZYDIS_LETTER_CASE_LOWER , ZYDIS_LETTER_CASE_UPPER , ZYDIS_LETTER_CASE_MAX_VALUE = ZYDIS_LETTER_CASE_UPPER }
 Values that represent letter cases. More...
 

Functions

ZYDIS_EXPORT ZydisStatus ZydisStringInit (ZydisString *string, char *text)
 Initializes a ZydisString struct with a C-string. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringFinalize (ZydisString *string)
 Finalizes a ZydisString struct by adding a terminating zero byte. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppend (ZydisString *string, const ZydisString *text)
 Appends a ZydisString to another ZydisString. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendEx (ZydisString *string, const ZydisString *text, ZydisLetterCase letterCase)
 Appends a ZydisString to another ZydisString, converting it to the specified letter-case. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendC (ZydisString *string, const char *text)
 Appends the given C-string to a ZydisString. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendExC (ZydisString *string, const char *text, ZydisLetterCase letterCase)
 Appends the given C-string to a ZydisString, converting it to the specified letter-case. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendStatic (ZydisString *string, const ZydisStaticString *text, ZydisLetterCase letterCase)
 Appends the given 'ZydisStaticString' to a ZydisString. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendExStatic (ZydisString *string, const ZydisStaticString *text, ZydisLetterCase letterCase)
 Appends the given 'ZydisStaticString' to a ZydisString, converting it to the specified letter-case. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendDecU (ZydisString *string, ZydisU64 value, ZydisU8 paddingLength)
 Formats the given unsigned ordinal value to its decimal text-representation and appends it to the string. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendDecS (ZydisString *string, ZydisI64 value, ZydisU8 paddingLength)
 Formats the given signed ordinal value to its decimal text-representation and appends it to the string. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendHexU (ZydisString *string, ZydisU64 value, ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString *prefix, const ZydisString *suffix)
 Formats the given unsigned ordinal value to its hexadecimal text-representation and appends it to the string. More...
 
ZYDIS_EXPORT ZydisStatus ZydisStringAppendHexS (ZydisString *string, ZydisI64 value, ZydisU8 paddingLength, ZydisBool uppercase, const ZydisString *prefix, const ZydisString *suffix)
 Formats the given signed ordinal value to its hexadecimal text-representation and appends it to the string. More...
 

Macro Definition Documentation

◆ ZYDIS_MAKE_STATIC_STRING

#define ZYDIS_MAKE_STATIC_STRING (   string)     { string, sizeof(string) - 1 }

Creates a ZydisStaticString from a static C-string.

Parameters
stringThe C-string constant.

◆ ZYDIS_MAKE_STRING

#define ZYDIS_MAKE_STRING (   string)     { (char*)string, sizeof(string) - 1, sizeof(string) - 1 }

Creates a ZydisString struct from a static C-string.

Parameters
stringThe C-string constant.

Typedef Documentation

◆ ZydisLetterCase

Defines the ZydisLetterCase datatype.

◆ ZydisStaticString

Defines the ZydisStaticString struct.

This more compact struct is mainly used for internal string-tables to save up some bytes.

◆ ZydisString

typedef struct ZydisString_ ZydisString

Defines the ZydisString struct.

Enumeration Type Documentation

◆ ZydisLetterCases

Values that represent letter cases.

Enumerator
ZYDIS_LETTER_CASE_DEFAULT 

Uses the given text "as is".

ZYDIS_LETTER_CASE_LOWER 

Converts the given text to lowercase letters.

ZYDIS_LETTER_CASE_UPPER 

Converts the given text to uppercase letters.

ZYDIS_LETTER_CASE_MAX_VALUE 

Maximum value of this enum.

Function Documentation

◆ ZydisStringAppend()

ZYDIS_EXPORT ZydisStatus ZydisStringAppend ( ZydisString string,
const ZydisString text 
)

Appends a ZydisString to another ZydisString.

Parameters
stringThe string to append to.
textThe string to append.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given text.

◆ ZydisStringAppendC()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendC ( ZydisString string,
const char *  text 
)

Appends the given C-string to a ZydisString.

Parameters
stringThe string to append to.
textThe C-string to append.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given text.

◆ ZydisStringAppendDecS()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendDecS ( ZydisString string,
ZydisI64  value,
ZydisU8  paddingLength 
)

Formats the given signed ordinal value to its decimal text-representation and appends it to the string.

Parameters
stringA pointer to the string.
valueThe value.
paddingLengthPadds the converted value with leading zeros, if the number of chars is less than the paddingLength (the sign char is ignored).
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given value.

The string-buffer pointer is increased by the number of chars written, if the call was successfull.

◆ ZydisStringAppendDecU()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendDecU ( ZydisString string,
ZydisU64  value,
ZydisU8  paddingLength 
)

Formats the given unsigned ordinal value to its decimal text-representation and appends it to the string.

Parameters
stringA pointer to the string.
valueThe value.
paddingLengthPadds the converted value with leading zeros, if the number of chars is less than the paddingLength.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given value.

The string-buffer pointer is increased by the number of chars written, if the call was successfull.

◆ ZydisStringAppendEx()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendEx ( ZydisString string,
const ZydisString text,
ZydisLetterCase  letterCase 
)

Appends a ZydisString to another ZydisString, converting it to the specified letter-case.

Parameters
stringThe string to append to.
textThe string to append.
letterCaseThe letter case to use.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given text.

◆ ZydisStringAppendExC()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendExC ( ZydisString string,
const char *  text,
ZydisLetterCase  letterCase 
)

Appends the given C-string to a ZydisString, converting it to the specified letter-case.

Parameters
stringThe string to append to.
textThe C-string to append.
letterCaseThe letter case to use.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given text.

◆ ZydisStringAppendExStatic()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendExStatic ( ZydisString string,
const ZydisStaticString text,
ZydisLetterCase  letterCase 
)

Appends the given 'ZydisStaticString' to a ZydisString, converting it to the specified letter-case.

Parameters
stringThe string to append to.
textThe static-string to append.
letterCaseThe letter case to use.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given text.

◆ ZydisStringAppendHexS()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendHexS ( ZydisString string,
ZydisI64  value,
ZydisU8  paddingLength,
ZydisBool  uppercase,
const ZydisString prefix,
const ZydisString suffix 
)

Formats the given signed ordinal value to its hexadecimal text-representation and appends it to the string.

Parameters
stringA pointer to the string.
valueThe value.
paddingLengthPadds the converted value with leading zeros, if the number of chars is less than the paddingLength (the sign char is ignored).
uppercaseSet TRUE to print the hexadecimal value in uppercase letters instead of lowercase ones.
prefixThe string to use as prefix or NULL, if not needed.
suffixThe string to use as suffix or NULL, if not needed.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given value.

The string-buffer pointer is increased by the number of chars written, if the call was successfull.

◆ ZydisStringAppendHexU()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendHexU ( ZydisString string,
ZydisU64  value,
ZydisU8  paddingLength,
ZydisBool  uppercase,
const ZydisString prefix,
const ZydisString suffix 
)

Formats the given unsigned ordinal value to its hexadecimal text-representation and appends it to the string.

Parameters
stringA pointer to the string.
valueThe value.
paddingLengthPadds the converted value with leading zeros, if the number of chars is less than the paddingLength.
uppercaseSet TRUE to print the hexadecimal value in uppercase letters instead of lowercase ones.
prefixThe string to use as prefix or NULL, if not needed.
suffixThe string to use as suffix or NULL, if not needed.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given value.

The string-buffer pointer is increased by the number of chars written, if the call was successfull.

◆ ZydisStringAppendStatic()

ZYDIS_EXPORT ZydisStatus ZydisStringAppendStatic ( ZydisString string,
const ZydisStaticString text,
ZydisLetterCase  letterCase 
)

Appends the given 'ZydisStaticString' to a ZydisString.

Parameters
stringThe string to append to.
textThe static-string to append.
Returns
ZYDIS_STATUS_SUCCESS, if the function succeeded, or ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE, if the size of the buffer was not sufficient to append the given text.

◆ ZydisStringFinalize()

ZYDIS_EXPORT ZydisStatus ZydisStringFinalize ( ZydisString string)

Finalizes a ZydisString struct by adding a terminating zero byte.

Parameters
stringThe string to finalize.
Returns
A zydis status code.

◆ ZydisStringInit()

ZYDIS_EXPORT ZydisStatus ZydisStringInit ( ZydisString string,
char *  text 
)

Initializes a ZydisString struct with a C-string.

Parameters
stringThe string to initialize.
textThe C-string constant.
Returns
A zydis status code.