Zydis v4.1.1

Loading...
Searching...
No Matches
String.h File Reference

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 <Zycore/Defines.h>`
`#include <Zycore/Status.h>`
`#include <Zycore/Vector.h>`

Go to the source code of this file.

## Macros
#define | ZYDIS_STRING_ASSERT_NULLTERMINATION(string)
| Checks for a terminating '\0' character at the end of the string data.
#define | ZYDIS_STRING_NULLTERMINATE(string)
| Writes a terminating '\0' character at the end of the string data.

## Typedefs
typedef enum ZydisLetterCase_ | ZydisLetterCase
| Defines the ZydisLetterCase enum.

## 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.
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.
ZYAN_INLINE ZyanStatus | ZydisStringAppendShort (ZyanString *destination, const ZydisShortString *source)
| Appends the content of the source short-string to the end of the destination 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.
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.
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.
ZyanStatus | ZydisStringAppendHexU (ZyanString *string, ZyanU64 value, ZyanU8 padding_length, ZyanBool force_leading_number, 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.
ZYAN_INLINE ZyanStatus | ZydisStringAppendHexS (ZyanString *string, ZyanI64 value, ZyanU8 padding_length, ZyanBool force_leading_number, 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.

## Detailed Description

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.

## Macro Definition Documentation

## ◆ ZYDIS_STRING_ASSERT_NULLTERMINATION

#define ZYDIS_STRING_ASSERT_NULLTERMINATION | ( |  | string | ) |

Value:
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.

## ◆ ZYDIS_STRING_NULLTERMINATE

#define ZYDIS_STRING_NULLTERMINATE | ( |  | string | ) |

Value:
*(char*)((ZyanU8*)(string)->vector.data + (string)->vector.size - 1) = '\0';

Writes a terminating '\0' character at the end of the string data.

## Typedef Documentation

## ◆ ZydisLetterCase

typedef enum ZydisLetterCase_ ZydisLetterCase

Defines the ZydisLetterCase enum.

## Enumeration Type Documentation

## ◆ ZydisLetterCase_

enum ZydisLetterCase_

Defines the ZydisLetterCase enum.

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.
ZYDIS_LETTER_CASE_REQUIRED_BITS | The minimum number of bits required to represent all values of this enum.

## Function Documentation

## ◆ ZydisStringAppend()

ZYAN_INLINE ZyanStatus ZydisStringAppend | ( | ZyanString * | destination,
|  | const ZyanStringView * | source )

Appends the content of the source string to the end of the destination string.

Parameters

  destination | The destination string.
  source | The source string.

Returns
  A zyan status code.

## ◆ ZydisStringAppendCase()

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.

Parameters

  destination | The destination string.
  source | The source string.
  letter_case | The desired letter-case.

Returns
  A zyan status code.

## ◆ ZydisStringAppendDecS()

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.

Parameters

  string | A pointer to the ZyanString instance.
  value | The value to append.
  padding_length | Padds the converted value with leading zeros, if the number of chars is less than the padding_length.
  force_sign | Enable this option to print 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.

Returns
  A zyan status code.

This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString instance.

## ◆ ZydisStringAppendDecU()

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.

Parameters

  string | A pointer to the ZyanString instance.
  value | The value to append.
  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.

Returns
  A zyan status code.

This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString instance.

## ◆ ZydisStringAppendHexS()

ZYAN_INLINE ZyanStatus ZydisStringAppendHexS | ( | ZyanString * | string,
|  | ZyanI64 | value,
|  | ZyanU8 | padding_length,
|  | ZyanBool | force_leading_number,
|  | 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.

Parameters

  string | A pointer to the ZyanString instance.
  value | The value to append.
  padding_length | Padds the converted value with leading zeros, if the number of chars is less than the padding_length (the sign char does not count).
  force_leading_number | Enable this option to prepend a leading 0, if the first character is non-numeric.
  uppercase | Enable this option to use uppercase letters ('A'-'F') instead of lowercase ones ('a'-'f').
  force_sign | Enable this option to print 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.

Returns
  A zyan status code.

This function will fail if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString instance.

## ◆ ZydisStringAppendHexU()

ZyanStatus ZydisStringAppendHexU | ( | ZyanString * | string,
|  | ZyanU64 | value,
|  | ZyanU8 | padding_length,
|  | ZyanBool | force_leading_number,
|  | 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.

Parameters

  string | A pointer to the ZyanString instance.
  value | The value to append.
  padding_length | Pads the converted value with leading zeros if the number of chars is less than the padding_length.
  force_leading_number | Enable this option to prepend a leading 0 if the first character is non-numeric.
  uppercase | Enable this option 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.

Returns
  A zyan status code.

This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString instance.

## ◆ ZydisStringAppendShort()

ZYAN_INLINE ZyanStatus ZydisStringAppendShort | ( | ZyanString * | destination,
|  | const ZydisShortString * | source )

Appends the content of the source short-string to the end of the destination string.

Parameters

  destination | The destination string.
  source | The source string.

Returns
  A zyan status code.

## ◆ ZydisStringAppendShortCase()

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.

Parameters

  destination | The destination string.
  source | The source string.
  letter_case | The desired letter-case.

Returns
  A zyan status code.