Zydis  v2.0.0-beta1
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_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit (ZydisString *string, char *value)
 Initializes a ZydisString struct with a C-string. More...
 
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringFinalize (ZydisString *string)
 Finalizes a ZydisString struct by adding a terminating zero byte. More...
 
ZYDIS_NO_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_NO_EXPORT ZYDIS_INLINE 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_NO_EXPORT ZYDIS_INLINE 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_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppend (ZydisString *string, const ZydisString *text)
 Appends a ZydisString to another ZydisString. More...
 
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendC (ZydisString *string, const char *text)
 Appends the given C-string to a ZydisString. More...
 
ZYDIS_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringAppendStatic (ZydisString *string, const ZydisStaticString *text, ZydisLetterCase letterCase)
 Appends the given 'ZydisStaticString' to a ZydisString. More...
 
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecU (ZydisString *string, ZydisU64 value, ZydisU8 paddingLength)
 Formats the given unsigned ordinal value to its decimal text-representation and
appends it to s. More...
 
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecS (ZydisString *string, ZydisI64 value, ZydisU8 paddingLength)
 Formats the given signed ordinal value to its decimal text-representation and
appends it to s. More...
 
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexU (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 buffer. More...
 
ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexS (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 buffer. 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

◆ ZydisPrintDecS()

ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecS ( ZydisString string,
ZydisI64  value,
ZydisU8  paddingLength 
)

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

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.

◆ ZydisPrintDecU()

ZYDIS_NO_EXPORT ZydisStatus ZydisPrintDecU ( ZydisString string,
ZydisU64  value,
ZydisU8  paddingLength 
)

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

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.

◆ ZydisPrintHexS()

ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexS ( 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 buffer.

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.

◆ ZydisPrintHexU()

ZYDIS_NO_EXPORT ZydisStatus ZydisPrintHexU ( 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 buffer.

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.

◆ ZydisStringAppend()

ZYDIS_NO_EXPORT ZYDIS_INLINE 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_NO_EXPORT ZYDIS_INLINE 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.

◆ ZydisStringAppendEx()

ZYDIS_NO_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_NO_EXPORT ZYDIS_INLINE 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_NO_EXPORT ZYDIS_INLINE 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.

◆ ZydisStringAppendStatic()

ZYDIS_NO_EXPORT ZYDIS_INLINE 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_NO_EXPORT ZYDIS_INLINE 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_NO_EXPORT ZYDIS_INLINE ZydisStatus ZydisStringInit ( ZydisString string,
char *  value 
)

Initializes a ZydisString struct with a C-string.

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