Zydis  v2.0.0-alpha2
Decoder.h File Reference

Functions for decoding instructions. More...

#include <Zydis/CommonTypes.h>
#include <Zydis/DecoderTypes.h>
#include <Zydis/Defines.h>
#include <Zydis/Status.h>
Include dependency graph for Decoder.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ZydisDecoder_
 Defines the ZydisDecoder struct. More...
 

Typedefs

typedef uint8_t ZydisDecodeGranularity
 Defines the ZydisDecodeGranularity datatype. More...
 
typedef struct ZydisDecoder_ ZydisDecoder
 Defines the ZydisDecoder struct. More...
 

Enumerations

enum  ZydisDecodeGranularities { ZYDIS_DECODE_GRANULARITY_DEFAULT , ZYDIS_DECODE_GRANULARITY_MINIMAL , ZYDIS_DECODE_GRANULARITY_FULL , ZYDIS_DECODE_GRANULARITY_MAX_VALUE = ZYDIS_DECODE_GRANULARITY_FULL }
 Decoder modes defining how granular the instruction should be decoded. More...
 

Functions

ZYDIS_EXPORT ZydisStatus ZydisDecoderInit (ZydisDecoder *decoder, ZydisMachineMode machineMode, ZydisAddressWidth addressWidth)
 Initializes the given ZydisDecoder instance. More...
 
ZYDIS_EXPORT ZydisStatus ZydisDecoderInitEx (ZydisDecoder *decoder, ZydisMachineMode machineMode, ZydisAddressWidth addressWidth, ZydisDecodeGranularity granularity)
 Initializes the given ZydisDecoder instance. More...
 
ZYDIS_EXPORT ZydisStatus ZydisDecoderDecodeBuffer (const ZydisDecoder *decoder, const void *buffer, size_t bufferLen, uint64_t instructionPointer, ZydisDecodedInstruction *instruction)
 Decodes the instruction in the given input buffer. More...
 

Detailed Description

Functions for decoding instructions.

Typedef Documentation

◆ ZydisDecodeGranularity

typedef uint8_t ZydisDecodeGranularity

Defines the ZydisDecodeGranularity datatype.

◆ ZydisDecoder

typedef struct ZydisDecoder_ ZydisDecoder

Defines the ZydisDecoder struct.

Enumeration Type Documentation

◆ ZydisDecodeGranularities

Decoder modes defining how granular the instruction should be decoded.

Enumerator
ZYDIS_DECODE_GRANULARITY_DEFAULT 

Defaults to ZYDIS_DECODE_GRANULARITY_FULL.

ZYDIS_DECODE_GRANULARITY_MINIMAL 

Minimal instruction decoding without semantic analysis.

This mode provides access to the mnemonic, the instruction-length, the effective operand-size, the effective address-width, some attributes (e.g. ZYDIS_ATTRIB_IS_RELATIVE) and all of the information in the raw field of the ZydisDecodedInstruction struct.

Operands, most attributes and other specific information (like AVX info) are not accessible in this mode.

ZYDIS_DECODE_GRANULARITY_FULL 

Full physical and semantic instruction-decoding.

ZYDIS_DECODE_GRANULARITY_MAX_VALUE 

Maximum value of this enum.

Function Documentation

◆ ZydisDecoderDecodeBuffer()

ZYDIS_EXPORT ZydisStatus ZydisDecoderDecodeBuffer ( const ZydisDecoder decoder,
const void *  buffer,
size_t  bufferLen,
uint64_t  instructionPointer,
ZydisDecodedInstruction instruction 
)

Decodes the instruction in the given input buffer.

Parameters
decoderA pointer to the ZydisDecoder instance.
bufferA pointer to the input buffer.
bufferLenThe length of the input buffer.
instructionPointerThe instruction-pointer.
instructionA pointer to the ZydisDecodedInstruction struct, that receives the details about the decoded instruction.
Returns
A zydis status code.

◆ ZydisDecoderInit()

ZYDIS_EXPORT ZydisStatus ZydisDecoderInit ( ZydisDecoder decoder,
ZydisMachineMode  machineMode,
ZydisAddressWidth  addressWidth 
)

Initializes the given ZydisDecoder instance.

Parameters
decoderA pointer to the ZydisDecoder instance.
machineModeThe machine mode.
addressWidthThe address width.
Returns
A zydis status code.

◆ ZydisDecoderInitEx()

ZYDIS_EXPORT ZydisStatus ZydisDecoderInitEx ( ZydisDecoder decoder,
ZydisMachineMode  machineMode,
ZydisAddressWidth  addressWidth,
ZydisDecodeGranularity  granularity 
)

Initializes the given ZydisDecoder instance.

Parameters
decoderA pointer to the ZydisDecoder instance.
machineModeThe machine mode.
addressWidthThe address width.
granularityThe decode granularity.
Returns
A zydis status code.