Zydis  v2.0.0-alpha2
Decoder.h
Go to the documentation of this file.
1 /***************************************************************************************************
2 
3  Zyan Disassembler Library (Zydis)
4 
5  Original Author : Florian Bernd
6 
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all
15  * copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23  * SOFTWARE.
24 
25 ***************************************************************************************************/
26 
32 #ifndef ZYDIS_DECODER_H
33 #define ZYDIS_DECODER_H
34 
35 #include <Zydis/CommonTypes.h>
36 #include <Zydis/DecoderTypes.h>
37 #include <Zydis/Defines.h>
38 #include <Zydis/Status.h>
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /* ============================================================================================== */
45 /* Enums and types */
46 /* ============================================================================================== */
47 
51 typedef uint8_t ZydisDecodeGranularity;
52 
57 {
81 };
82 
86 typedef struct ZydisDecoder_
87 {
92 
93 /* ---------------------------------------------------------------------------------------------- */
94 
95 /* ============================================================================================== */
96 /* Exported functions */
97 /* ============================================================================================== */
98 
108 ZYDIS_EXPORT ZydisStatus ZydisDecoderInit(ZydisDecoder* decoder, ZydisMachineMode machineMode,
109  ZydisAddressWidth addressWidth);
110 
121 ZYDIS_EXPORT ZydisStatus ZydisDecoderInitEx(ZydisDecoder* decoder, ZydisMachineMode machineMode,
122  ZydisAddressWidth addressWidth, ZydisDecodeGranularity granularity);
123 
136 ZYDIS_EXPORT ZydisStatus ZydisDecoderDecodeBuffer(const ZydisDecoder* decoder,
137  const void* buffer, size_t bufferLen, uint64_t instructionPointer,
138  ZydisDecodedInstruction* instruction);
139 
140 /* ============================================================================================== */
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* ZYDIS_DECODER_H */
Includes and defines some default datatypes.
Defines the basic ZydisDecodedInstruction and ZydisDecodedOperand structs.
ZYDIS_EXPORT ZydisStatus ZydisDecoderInitEx(ZydisDecoder *decoder, ZydisMachineMode machineMode, ZydisAddressWidth addressWidth, ZydisDecodeGranularity granularity)
Initializes the given ZydisDecoder instance.
uint8_t ZydisDecodeGranularity
Defines the ZydisDecodeGranularity datatype.
Definition: Decoder.h:51
struct ZydisDecoder_ ZydisDecoder
Defines the ZydisDecoder struct.
ZydisDecodeGranularities
Decoder modes defining how granular the instruction should be decoded.
Definition: Decoder.h:57
@ ZYDIS_DECODE_GRANULARITY_MAX_VALUE
Maximum value of this enum.
Definition: Decoder.h:80
@ ZYDIS_DECODE_GRANULARITY_FULL
Full physical and semantic instruction-decoding.
Definition: Decoder.h:76
@ ZYDIS_DECODE_GRANULARITY_MINIMAL
Minimal instruction decoding without semantic analysis.
Definition: Decoder.h:72
@ ZYDIS_DECODE_GRANULARITY_DEFAULT
Defaults to ZYDIS_DECODE_GRANULARITY_FULL.
Definition: Decoder.h:61
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.
ZYDIS_EXPORT ZydisStatus ZydisDecoderInit(ZydisDecoder *decoder, ZydisMachineMode machineMode, ZydisAddressWidth addressWidth)
Initializes the given ZydisDecoder instance.
General helper and platform detection macros.
uint8_t ZydisMachineMode
Defines the ZydisMachineMode datatype.
Definition: SharedTypes.h:65
uint8_t ZydisAddressWidth
Defines the ZydisAddressWidth datatype.
Definition: SharedTypes.h:110
Status code definitions and check macros.
uint32_t ZydisStatus
Defines the ZydisStatus datatype.
Definition: Status.h:48
Defines the ZydisDecodedInstruction struct.
Definition: DecoderTypes.h:740
Defines the ZydisDecoder struct.
Definition: Decoder.h:87
ZydisDecodeGranularity granularity
Definition: Decoder.h:90
ZydisAddressWidth addressWidth
Definition: Decoder.h:89
ZydisMachineMode machineMode
Definition: Decoder.h:88