| 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 |
|
| 27 |
/** |
| 28 |
* @file |
| 29 |
* Master include file. Includes everything else. |
| 30 |
*/ |
| 31 |
|
| 32 |
#ifndef ZYDIS_H |
| 33 |
#define ZYDIS_H |
| 34 |
|
| 35 |
#include "zydis/Zycore/Defines.h" |
| 36 |
#include "zydis/Zycore/Types.h" |
| 37 |
|
| 38 |
#if !defined(ZYDIS_DISABLE_DECODER) |
| 39 |
# include "zydis/Zydis/Decoder.h" |
| 40 |
# include "zydis/Zydis/DecoderTypes.h" |
| 41 |
#endif |
| 42 |
|
| 43 |
#if !defined(ZYDIS_DISABLE_ENCODER) |
| 44 |
# include "zydis/Zydis/Encoder.h" |
| 45 |
#endif |
| 46 |
|
| 47 |
#if !defined(ZYDIS_DISABLE_FORMATTER) |
| 48 |
# include "zydis/Zydis/Formatter.h" |
| 49 |
#endif |
| 50 |
|
| 51 |
#if !defined(ZYDIS_DISABLE_SEGMENT) |
| 52 |
# include "zydis/Zydis/Segment.h" |
| 53 |
#endif |
| 54 |
|
| 55 |
#if !defined(ZYDIS_DISABLE_DECODER) && !defined(ZYDIS_DISABLE_FORMATTER) |
| 56 |
# include "zydis/Zydis/Disassembler.h" |
| 57 |
#endif |
| 58 |
|
| 59 |
#include "zydis/Zydis/MetaInfo.h" |
| 60 |
#include "zydis/Zydis/Mnemonic.h" |
| 61 |
#include "zydis/Zydis/Register.h" |
| 62 |
#include "zydis/Zydis/SharedTypes.h" |
| 63 |
#include "zydis/Zydis/Status.h" |
| 64 |
#include "zydis/Zydis/Utils.h" |
| 65 |
|
| 66 |
#ifdef __cplusplus |
| 67 |
extern "C" { |
| 68 |
#endif |
| 69 |
|
| 70 |
/** |
| 71 |
* @addtogroup version Version |
| 72 |
* |
| 73 |
* Functions for checking the library version and build options. |
| 74 |
* |
| 75 |
* @{ |
| 76 |
*/ |
| 77 |
|
| 78 |
/* ============================================================================================== */ |
| 79 |
/* Macros */ |
| 80 |
/* ============================================================================================== */ |
| 81 |
|
| 82 |
/* ---------------------------------------------------------------------------------------------- */ |
| 83 |
/* Constants */ |
| 84 |
/* ---------------------------------------------------------------------------------------------- */ |
| 85 |
|
| 86 |
/** |
| 87 |
* A macro that defines the zydis version. |
| 88 |
*/ |
| 89 |
#define ZYDIS_VERSION (ZyanU64)0x0004000100000000 |
| 90 |
|
| 91 |
/* ---------------------------------------------------------------------------------------------- */ |
| 92 |
/* Helper macros */ |
| 93 |
/* ---------------------------------------------------------------------------------------------- */ |
| 94 |
|
| 95 |
/** |
| 96 |
* Extracts the major-part of the zydis version. |
| 97 |
* |
| 98 |
* @param version The zydis version value |
| 99 |
*/ |
| 100 |
#define ZYDIS_VERSION_MAJOR(version) (ZyanU16)(((version) & 0xFFFF000000000000) >> 48) |
| 101 |
|
| 102 |
/** |
| 103 |
* Extracts the minor-part of the zydis version. |
| 104 |
* |
| 105 |
* @param version The zydis version value |
| 106 |
*/ |
| 107 |
#define ZYDIS_VERSION_MINOR(version) (ZyanU16)(((version) & 0x0000FFFF00000000) >> 32) |
| 108 |
|
| 109 |
/** |
| 110 |
* Extracts the patch-part of the zydis version. |
| 111 |
* |
| 112 |
* @param version The zydis version value |
| 113 |
*/ |
| 114 |
#define ZYDIS_VERSION_PATCH(version) (ZyanU16)(((version) & 0x00000000FFFF0000) >> 16) |
| 115 |
|
| 116 |
/** |
| 117 |
* Extracts the build-part of the zydis version. |
| 118 |
* |
| 119 |
* @param version The zydis version value |
| 120 |
*/ |
| 121 |
#define ZYDIS_VERSION_BUILD(version) (ZyanU16)((version) & 0x000000000000FFFF) |
| 122 |
|
| 123 |
/* ---------------------------------------------------------------------------------------------- */ |
| 124 |
|
| 125 |
/* ============================================================================================== */ |
| 126 |
/* Enums and types */ |
| 127 |
/* ============================================================================================== */ |
| 128 |
|
| 129 |
/** |
| 130 |
* Defines the `ZydisFeature` enum. |
| 131 |
*/ |
| 132 |
typedef enum ZydisFeature_ |
| 133 |
{ |
| 134 |
ZYDIS_FEATURE_DECODER, |
| 135 |
ZYDIS_FEATURE_ENCODER, |
| 136 |
ZYDIS_FEATURE_FORMATTER, |
| 137 |
ZYDIS_FEATURE_AVX512, |
| 138 |
ZYDIS_FEATURE_KNC, |
| 139 |
ZYDIS_FEATURE_SEGMENT, |
| 140 |
|
| 141 |
/** |
| 142 |
* Maximum value of this enum. |
| 143 |
*/ |
| 144 |
ZYDIS_FEATURE_MAX_VALUE = ZYDIS_FEATURE_SEGMENT, |
| 145 |
/** |
| 146 |
* The minimum number of bits required to represent all values of this enum. |
| 147 |
*/ |
| 148 |
ZYDIS_FEATURE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_FEATURE_MAX_VALUE) |
| 149 |
} ZydisFeature; |
| 150 |
|
| 151 |
/* ============================================================================================== */ |
| 152 |
/* Exported functions */ |
| 153 |
/* ============================================================================================== */ |
| 154 |
|
| 155 |
/** |
| 156 |
* Returns the zydis version. |
| 157 |
* |
| 158 |
* @return The zydis version. |
| 159 |
* |
| 160 |
* Use the macros provided in this file to extract the major, minor, patch and build part from the |
| 161 |
* returned version value. |
| 162 |
*/ |
| 163 |
ZYDIS_EXPORT ZyanU64 ZydisGetVersion(void); |
| 164 |
|
| 165 |
/** |
| 166 |
* Checks, if the specified feature is enabled in the current zydis library instance. |
| 167 |
* |
| 168 |
* @param feature The feature. |
| 169 |
* |
| 170 |
* @return `ZYAN_STATUS_TRUE` if the feature is enabled, `ZYAN_STATUS_FALSE` if not. Another |
| 171 |
* zyan status code, if an error occured. |
| 172 |
*/ |
| 173 |
ZYDIS_EXPORT ZyanStatus ZydisIsFeatureEnabled(ZydisFeature feature); |
| 174 |
|
| 175 |
/* ============================================================================================== */ |
| 176 |
|
| 177 |
/** |
| 178 |
* @} |
| 179 |
*/ |
| 180 |
|
| 181 |
#ifdef __cplusplus |
| 182 |
} |
| 183 |
#endif |
| 184 |
|
| 185 |
#endif /* ZYDIS_H */ |