Zydis
master
|
Implements the ZydisFormatterToken
type and provides functions to use it.
More...
#include <Zycore/String.h>
#include <Zycore/Types.h>
#include <Zydis/Defines.h>
#include <Zydis/Status.h>
Go to the source code of this file.
Data Structures | |
struct | ZydisFormatterToken_ |
Defines the ZydisFormatterToken struct. More... | |
struct | ZydisFormatterBuffer_ |
Defines the ZydisFormatterBuffer struct. More... | |
Macros | |
#define | ZYDIS_TOKEN_INVALID 0x00 |
#define | ZYDIS_TOKEN_WHITESPACE 0x01 |
A whitespace character. More... | |
#define | ZYDIS_TOKEN_DELIMITER 0x02 |
A delimiter character (like ‘’,', ':', '+', '-', '*'`). More... | |
#define | ZYDIS_TOKEN_PARENTHESIS_OPEN 0x03 |
An opening parenthesis character (like ‘’(', '[', '{'`). More... | |
#define | ZYDIS_TOKEN_PARENTHESIS_CLOSE 0x04 |
A closing parenthesis character (like ‘’)', ']', '}'`). More... | |
#define | ZYDIS_TOKEN_PREFIX 0x05 |
A prefix literal (like "LOCK" , "REP" ). More... | |
#define | ZYDIS_TOKEN_MNEMONIC 0x06 |
A mnemonic literal (like "MOV" , "VCMPPSD" , "LCALL" ). More... | |
#define | ZYDIS_TOKEN_REGISTER 0x07 |
A register literal (like "RAX" , "DS" , "%ECX" ). More... | |
#define | ZYDIS_TOKEN_ADDRESS_ABS 0x08 |
An absolute address literal (like 0x00400000 ). More... | |
#define | ZYDIS_TOKEN_ADDRESS_REL 0x09 |
A relative address literal (like -0x100 ). More... | |
#define | ZYDIS_TOKEN_DISPLACEMENT 0x0A |
A displacement literal (like 0xFFFFFFFF , -0x100 , +0x1234 ). More... | |
#define | ZYDIS_TOKEN_IMMEDIATE 0x0B |
An immediate literal (like 0xC0 , -0x1234 , $0x0000 ). More... | |
#define | ZYDIS_TOKEN_TYPECAST 0x0C |
A typecast literal (like DWORD PTR ). More... | |
#define | ZYDIS_TOKEN_DECORATOR 0x0D |
A decorator literal (like "Z" , "1TO4" ). More... | |
#define | ZYDIS_TOKEN_SYMBOL 0x0E |
A symbol literal. More... | |
#define | ZYDIS_TOKEN_USER 0x80 |
The base for user-defined token types. More... | |
Typedefs | |
typedef ZyanU8 | ZydisTokenType |
Defines the ZydisTokenType data-type. More... | |
typedef struct ZydisFormatterToken_ | ZydisFormatterToken |
Defines the ZydisFormatterToken struct. More... | |
typedef const ZydisFormatterToken | ZydisFormatterTokenConst |
Defines the ZydisFormatterTokenConst data-type. More... | |
typedef struct ZydisFormatterBuffer_ | ZydisFormatterBuffer |
Defines the ZydisFormatterBuffer struct. More... | |
Functions | |
ZYDIS_EXPORT ZyanStatus | ZydisFormatterTokenGetValue (const ZydisFormatterToken *token, ZydisTokenType *type, ZyanConstCharPointer *value) |
Returns the type and the string value of the given token . More... | |
ZYDIS_EXPORT ZyanStatus | ZydisFormatterTokenNext (ZydisFormatterTokenConst **token) |
Obtains the next token linked to the passed one. More... | |
ZYDIS_EXPORT ZyanStatus | ZydisFormatterBufferGetToken (const ZydisFormatterBuffer *buffer, ZydisFormatterTokenConst **token) |
Returns the current (most recently added) token. More... | |
ZYDIS_EXPORT ZyanStatus | ZydisFormatterBufferGetString (ZydisFormatterBuffer *buffer, ZyanString **string) |
Returns the ZyanString instance associated with the given buffer. More... | |
ZYDIS_EXPORT ZyanStatus | ZydisFormatterBufferAppend (ZydisFormatterBuffer *buffer, ZydisTokenType type) |
Appends a new token to the buffer . More... | |
ZYDIS_EXPORT ZyanStatus | ZydisFormatterBufferRemember (const ZydisFormatterBuffer *buffer, ZyanUPointer *state) |
Returns a snapshot of the buffer-state. More... | |
ZYDIS_EXPORT ZyanStatus | ZydisFormatterBufferRestore (ZydisFormatterBuffer *buffer, ZyanUPointer state) |
Restores a previously saved buffer-state. More... | |
Implements the ZydisFormatterToken
type and provides functions to use it.
#define ZYDIS_TOKEN_ADDRESS_ABS 0x08 |
An absolute address literal (like 0x00400000
).
#define ZYDIS_TOKEN_ADDRESS_REL 0x09 |
A relative address literal (like -0x100
).
#define ZYDIS_TOKEN_DECORATOR 0x0D |
A decorator literal (like "Z"
, "1TO4"
).
#define ZYDIS_TOKEN_DELIMITER 0x02 |
A delimiter character (like ‘’,',
':',
'+',
'-',
'*'`).
#define ZYDIS_TOKEN_DISPLACEMENT 0x0A |
A displacement literal (like 0xFFFFFFFF
, -0x100
, +0x1234
).
#define ZYDIS_TOKEN_IMMEDIATE 0x0B |
An immediate literal (like 0xC0
, -0x1234
, $0x0000
).
#define ZYDIS_TOKEN_INVALID 0x00 |
#define ZYDIS_TOKEN_MNEMONIC 0x06 |
A mnemonic literal (like "MOV"
, "VCMPPSD"
, "LCALL"
).
#define ZYDIS_TOKEN_PARENTHESIS_CLOSE 0x04 |
A closing parenthesis character (like ‘’)',
']',
'}'`).
#define ZYDIS_TOKEN_PARENTHESIS_OPEN 0x03 |
An opening parenthesis character (like ‘’(',
'[',
'{'`).
#define ZYDIS_TOKEN_PREFIX 0x05 |
A prefix literal (like "LOCK"
, "REP"
).
#define ZYDIS_TOKEN_REGISTER 0x07 |
A register literal (like "RAX"
, "DS"
, "%ECX"
).
#define ZYDIS_TOKEN_SYMBOL 0x0E |
A symbol literal.
#define ZYDIS_TOKEN_TYPECAST 0x0C |
A typecast literal (like DWORD PTR
).
#define ZYDIS_TOKEN_USER 0x80 |
The base for user-defined token types.
#define ZYDIS_TOKEN_WHITESPACE 0x01 |
A whitespace character.
typedef struct ZydisFormatterBuffer_ ZydisFormatterBuffer |
Defines the ZydisFormatterBuffer
struct.
All fields in this struct should be considered as "private". Any changes may lead to unexpected behavior.
typedef struct ZydisFormatterToken_ ZydisFormatterToken |
Defines the ZydisFormatterToken
struct.
All fields in this struct should be considered as "private". Any changes may lead to unexpected behavior.
typedef const ZydisFormatterToken ZydisFormatterTokenConst |
Defines the ZydisFormatterTokenConst
data-type.
typedef ZyanU8 ZydisTokenType |
Defines the ZydisTokenType
data-type.
ZYDIS_EXPORT ZyanStatus ZydisFormatterBufferAppend | ( | ZydisFormatterBuffer * | buffer, |
ZydisTokenType | type | ||
) |
Appends a new token to the buffer
.
buffer | A pointer to the ZydisFormatterBuffer struct. |
type | The type of the new token. |
Note that the ZyanString
instance returned by ZydisFormatterBufferGetString
will automatically be updated by calling this function.
ZYDIS_EXPORT ZyanStatus ZydisFormatterBufferGetString | ( | ZydisFormatterBuffer * | buffer, |
ZyanString ** | string | ||
) |
Returns the ZyanString
instance associated with the given buffer.
buffer | A pointer to the ZydisFormatterBuffer struct. |
string | Receives a pointer to the ZyanString instance associated with the given buffer. |
This function returns ZYAN_STATUS_INVALID_OPERATION
, if the buffer does not contain at least one token.
The returned string always refers to the literal value of the current (most recently added) token and will remain valid until the buffer is destroyed.
ZYDIS_EXPORT ZyanStatus ZydisFormatterBufferGetToken | ( | const ZydisFormatterBuffer * | buffer, |
ZydisFormatterTokenConst ** | token | ||
) |
Returns the current (most recently added) token.
buffer | A pointer to the ZydisFormatterBuffer struct. |
token | Receives a pointer to the current token. |
This function returns ZYAN_STATUS_INVALID_OPERATION
, if the buffer does not contain at least one token.
ZYDIS_EXPORT ZyanStatus ZydisFormatterBufferRemember | ( | const ZydisFormatterBuffer * | buffer, |
ZyanUPointer * | state | ||
) |
Returns a snapshot of the buffer-state.
buffer | A pointer to the ZydisFormatterBuffer struct. |
state | Receives a snapshot of the buffer-state. |
Note that the buffer-state is saved inside the buffer itself and thus becomes invalid as soon as the buffer gets overwritten or destroyed.
ZYDIS_EXPORT ZyanStatus ZydisFormatterBufferRestore | ( | ZydisFormatterBuffer * | buffer, |
ZyanUPointer | state | ||
) |
Restores a previously saved buffer-state.
buffer | A pointer to the ZydisFormatterBuffer struct. |
state | The buffer-state to restore. |
All tokens added after obtaining the given state
snapshot will be removed. This function does NOT restore any string content.
Note that the ZyanString
instance returned by ZydisFormatterBufferGetString
will automatically be updated by calling this function.
ZYDIS_EXPORT ZyanStatus ZydisFormatterTokenGetValue | ( | const ZydisFormatterToken * | token, |
ZydisTokenType * | type, | ||
ZyanConstCharPointer * | value | ||
) |
Returns the type
and the string value
of the given token
.
token | A pointer to the ZydisFormatterToken struct. |
type | Receives the token type. |
value | Receives a pointer to the string value of the token. |
ZYDIS_EXPORT ZyanStatus ZydisFormatterTokenNext | ( | ZydisFormatterTokenConst ** | token | ) |
Obtains the next token
linked to the passed one.
token | Receives a pointer to the next ZydisFormatterToken struct linked to the passed one. |