Zydis
v3.2.1
|
Provides some internal, more performant, but unsafe helper functions for the ZyanString
data-type.
More...
#include <Zycore/LibC.h>
#include <Zycore/String.h>
#include <Zycore/Types.h>
#include <Zycore/Format.h>
#include <Zydis/ShortString.h>
#include <Zydis/Status.h>
Go to the source code of this file.
Macros | |
#define | ZYDIS_STRING_ASSERT_NULLTERMINATION(string) ZYAN_ASSERT(*(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) == '\0'); |
Checks for a terminating '\0' character at the end of the string data. More... | |
#define | ZYDIS_STRING_NULLTERMINATE(string) *(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) = '\0'; |
Writes a terminating '\0' character at the end of the string data. More... | |
Typedefs | |
typedef enum ZydisLetterCase_ | ZydisLetterCase |
Defines the ZydisLetterCase enum. More... | |
Enumerations | |
enum | ZydisLetterCase_ { ZYDIS_LETTER_CASE_DEFAULT , ZYDIS_LETTER_CASE_LOWER , ZYDIS_LETTER_CASE_UPPER , ZYDIS_LETTER_CASE_MAX_VALUE = ZYDIS_LETTER_CASE_UPPER , ZYDIS_LETTER_CASE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_LETTER_CASE_MAX_VALUE) } |
Defines the ZydisLetterCase enum. More... | |
Functions | |
ZYAN_INLINE ZyanStatus | ZydisStringAppend (ZyanString *destination, const ZyanStringView *source) |
Appends the content of the source string to the end of the destination string. More... | |
ZYAN_INLINE ZyanStatus | ZydisStringAppendCase (ZyanString *destination, const ZyanStringView *source, ZydisLetterCase letter_case) |
Appends the content of the source string to the end of the destination string, converting the characters to the specified letter-case. More... | |
ZYAN_INLINE ZyanStatus | ZydisStringAppendShort (ZyanString *destination, const ZydisShortString *source) |
Appends the content of the source short-string to the end of the destination string. More... | |
ZYAN_INLINE ZyanStatus | ZydisStringAppendShortCase (ZyanString *destination, const ZydisShortString *source, ZydisLetterCase letter_case) |
Appends the content of the source short-string to the end of the destination string, converting the characters to the specified letter-case. More... | |
ZyanStatus | ZydisStringAppendDecU (ZyanString *string, ZyanU64 value, ZyanU8 padding_length, const ZyanStringView *prefix, const ZyanStringView *suffix) |
Formats the given unsigned ordinal value to its decimal text-representation and appends it to the string . More... | |
ZYAN_INLINE ZyanStatus | ZydisStringAppendDecS (ZyanString *string, ZyanI64 value, ZyanU8 padding_length, ZyanBool force_sign, const ZyanStringView *prefix, const ZyanStringView *suffix) |
Formats the given signed ordinal value to its decimal text-representation and appends it to the string . More... | |
ZyanStatus | ZydisStringAppendHexU (ZyanString *string, ZyanU64 value, ZyanU8 padding_length, ZyanBool uppercase, const ZyanStringView *prefix, const ZyanStringView *suffix) |
Formats the given unsigned ordinal value to its hexadecimal text-representation and appends it to the string . More... | |
ZYAN_INLINE ZyanStatus | ZydisStringAppendHexS (ZyanString *string, ZyanI64 value, ZyanU8 padding_length, ZyanBool uppercase, ZyanBool force_sign, const ZyanStringView *prefix, const ZyanStringView *suffix) |
Formats the given signed ordinal value to its hexadecimal text-representation and appends it to the string . More... | |
Provides some internal, more performant, but unsafe helper functions for the ZyanString
data-type.
Most of these functions are very similar to the ones in Zycore/String.h
, but inlined and without optional overhead like parameter-validation checks, etc ...
The ZyanString
data-type is able to dynamically allocate memory on the heap, but as Zydis
is designed to be a non-'malloc'ing library, all functions in this file assume that the instances they are operating on are created with a user-defined static-buffer.
#define ZYDIS_STRING_ASSERT_NULLTERMINATION | ( | string | ) | ZYAN_ASSERT(*(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) == '\0'); |
Checks for a terminating '\0' character at the end of the string data.
#define ZYDIS_STRING_NULLTERMINATE | ( | string | ) | *(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) = '\0'; |
Writes a terminating '\0' character at the end of the string data.
typedef enum ZydisLetterCase_ ZydisLetterCase |
Defines the ZydisLetterCase
enum.
enum ZydisLetterCase_ |
Defines the ZydisLetterCase
enum.
ZYAN_INLINE ZyanStatus ZydisStringAppend | ( | ZyanString * | destination, |
const ZyanStringView * | source | ||
) |
Appends the content of the source string to the end of the destination string.
destination | The destination string. |
source | The source string. |
ZYAN_INLINE ZyanStatus ZydisStringAppendCase | ( | ZyanString * | destination, |
const ZyanStringView * | source, | ||
ZydisLetterCase | letter_case | ||
) |
Appends the content of the source string to the end of the destination string, converting the characters to the specified letter-case.
destination | The destination string. |
source | The source string. |
letter_case | The desired letter-case. |
ZYAN_INLINE ZyanStatus ZydisStringAppendDecS | ( | ZyanString * | string, |
ZyanI64 | value, | ||
ZyanU8 | padding_length, | ||
ZyanBool | force_sign, | ||
const ZyanStringView * | prefix, | ||
const ZyanStringView * | suffix | ||
) |
Formats the given signed ordinal value
to its decimal text-representation and appends it to the string
.
string | A pointer to the ZyanString instance. |
value | The value. |
padding_length | Padds the converted value with leading zeros, if the number of chars is less than the padding_length . |
force_sign | Set ZYAN_TRUE , to force printing of the + sign for positive numbers. |
prefix | The string to use as prefix or ZYAN_NULL , if not needed. |
suffix | The string to use as suffix or ZYAN_NULL , if not needed. |
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE
flag is set for the specified ZyanString
instance.
ZyanStatus ZydisStringAppendDecU | ( | ZyanString * | string, |
ZyanU64 | value, | ||
ZyanU8 | padding_length, | ||
const ZyanStringView * | prefix, | ||
const ZyanStringView * | suffix | ||
) |
Formats the given unsigned ordinal value
to its decimal text-representation and appends it to the string
.
string | A pointer to the ZyanString instance. |
value | The value. |
padding_length | Padds the converted value with leading zeros, if the number of chars is less than the padding_length . |
prefix | The string to use as prefix or ZYAN_NULL , if not needed. |
suffix | The string to use as suffix or ZYAN_NULL , if not needed. |
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE
flag is set for the specified ZyanString
instance.
ZYAN_INLINE ZyanStatus ZydisStringAppendHexS | ( | ZyanString * | string, |
ZyanI64 | value, | ||
ZyanU8 | padding_length, | ||
ZyanBool | uppercase, | ||
ZyanBool | force_sign, | ||
const ZyanStringView * | prefix, | ||
const ZyanStringView * | suffix | ||
) |
Formats the given signed ordinal value
to its hexadecimal text-representation and appends it to the string
.
string | A pointer to the string. |
value | The value. |
padding_length | Padds the converted value with leading zeros, if the number of chars is less than the padding_length (the sign char is ignored). |
uppercase | Set ZYAN_TRUE to print the hexadecimal value in uppercase letters instead of lowercase ones. |
force_sign | Set to ZYAN_TRUE , to force printing of the + sign for positive numbers. |
prefix | The string to use as prefix or NULL , if not needed. |
suffix | The string to use as suffix or NULL , if not needed. |
ZYAN_STATUS_SUCCESS
, if the function succeeded, or ZYAN_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 successful.
ZyanStatus ZydisStringAppendHexU | ( | ZyanString * | string, |
ZyanU64 | value, | ||
ZyanU8 | padding_length, | ||
ZyanBool | uppercase, | ||
const ZyanStringView * | prefix, | ||
const ZyanStringView * | suffix | ||
) |
Formats the given unsigned ordinal value
to its hexadecimal text-representation and appends it to the string
.
string | A pointer to the ZyanString instance. |
value | The value. |
padding_length | Padds the converted value with leading zeros, if the number of chars is less than the padding_length . |
uppercase | Set ZYAN_TRUE to use uppercase letters ('A'-'F') instead of lowercase ones ('a'-'f'). |
prefix | The string to use as prefix or ZYAN_NULL , if not needed. |
suffix | The string to use as suffix or ZYAN_NULL , if not needed. |
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE
flag is set for the specified ZyanString
instance.
ZYAN_INLINE ZyanStatus ZydisStringAppendShort | ( | ZyanString * | destination, |
const ZydisShortString * | source | ||
) |
Appends the content of the source short-string to the end of the destination string.
destination | The destination string. |
source | The source string. |
ZYAN_INLINE ZyanStatus ZydisStringAppendShortCase | ( | ZyanString * | destination, |
const ZydisShortString * | source, | ||
ZydisLetterCase | letter_case | ||
) |
Appends the content of the source short-string to the end of the destination string, converting the characters to the specified letter-case.
destination | The destination string. |
source | The source string. |
letter_case | The desired letter-case. |