2016-05-26 03:25:48 +08:00
|
|
|
/***************************************************************************************************
|
|
|
|
|
2016-12-05 09:24:01 +08:00
|
|
|
Zyan Disassembler Library (Zydis)
|
2016-05-26 03:25:48 +08:00
|
|
|
|
|
|
|
Original Author : Florian Bernd
|
|
|
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
|
|
|
|
***************************************************************************************************/
|
|
|
|
|
|
|
|
#ifndef ZYDIS_STATUS_H
|
|
|
|
#define ZYDIS_STATUS_H
|
|
|
|
|
2016-12-05 09:24:01 +08:00
|
|
|
#include <Zydis/Types.h>
|
2016-05-26 03:25:48 +08:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* ============================================================================================== */
|
|
|
|
/* Enums and types */
|
|
|
|
/* ============================================================================================== */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Defines the @c ZydisStatus datatype.
|
|
|
|
*/
|
|
|
|
typedef uint32_t ZydisStatus;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Values that represent a zydis status-codes.
|
|
|
|
*/
|
|
|
|
enum ZydisStatusCode
|
|
|
|
{
|
2016-12-05 09:24:01 +08:00
|
|
|
/* ------------------------------------------------------------------------------------------ */
|
|
|
|
/* General */
|
|
|
|
/* ------------------------------------------------------------------------------------------ */
|
|
|
|
|
2016-05-26 03:25:48 +08:00
|
|
|
/**
|
|
|
|
* @brief The operation completed successfully.
|
|
|
|
*/
|
2016-12-05 09:24:01 +08:00
|
|
|
ZYDIS_STATUS_SUCCESS = 0x00000000,
|
2016-05-26 03:25:48 +08:00
|
|
|
/**
|
|
|
|
* @brief An invalid parameter was passed to a function.
|
|
|
|
*/
|
2016-12-05 09:24:01 +08:00
|
|
|
ZYDIS_STATUS_INVALID_PARAMETER,
|
2016-05-26 03:25:48 +08:00
|
|
|
/**
|
|
|
|
* @brief An attempt was made to perform an invalid operation.
|
|
|
|
*/
|
2016-12-05 09:24:01 +08:00
|
|
|
ZYDIS_STATUS_INVALID_OPERATION,
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------ */
|
|
|
|
/* Decoder */
|
|
|
|
/* ------------------------------------------------------------------------------------------ */
|
|
|
|
|
2016-05-26 03:25:48 +08:00
|
|
|
/**
|
|
|
|
* @brief An attempt was made to read data from an input data-source that has no more data
|
|
|
|
* available.
|
|
|
|
*/
|
2016-12-05 09:24:01 +08:00
|
|
|
ZYDIS_STATUS_NO_MORE_DATA,
|
|
|
|
/**
|
|
|
|
* @brief An general error occured while decoding the current instruction. The instruction
|
|
|
|
* might be undefined.
|
|
|
|
*/
|
|
|
|
ZYDIS_STATUS_DECODING_ERROR,
|
|
|
|
/**
|
|
|
|
* @brief The instruction exceeded the maximum length of 15 bytes.
|
|
|
|
*/
|
|
|
|
ZYDIS_STATUS_INSTRUCTION_TOO_LONG,
|
|
|
|
/**
|
|
|
|
* @brief The instruction encoded an invalid register.
|
|
|
|
*/
|
|
|
|
ZYDIS_STATUS_INVALID_REGISTER,
|
|
|
|
/**
|
|
|
|
* @brief A lock-prefix (F0) was found while decoding an instruction that does not support
|
|
|
|
* locking.
|
|
|
|
*/
|
|
|
|
ZYDIS_STATUS_ILLEGAL_LOCK,
|
2016-05-26 03:25:48 +08:00
|
|
|
/**
|
2017-01-13 02:37:57 +08:00
|
|
|
* @brief A legacy-prefix (F2, F3, 66) was found while decoding a XOP/VEX/EVEX instruction.
|
2016-05-26 03:25:48 +08:00
|
|
|
*/
|
2016-12-05 09:24:01 +08:00
|
|
|
ZYDIS_STATUS_ILLEGAL_LEGACY_PFX,
|
|
|
|
/**
|
2017-01-13 02:37:57 +08:00
|
|
|
* @brief A rex-prefix was found while decoding a XOP/VEX/EVEX instruction.
|
2016-12-05 09:24:01 +08:00
|
|
|
*/
|
|
|
|
ZYDIS_STATUS_ILLEGAL_REX,
|
|
|
|
/**
|
2017-01-13 02:37:57 +08:00
|
|
|
* @brief An invalid opcode-map value was found while decoding a XOP/VEX/EVEX-prefix.
|
2016-12-05 09:24:01 +08:00
|
|
|
*/
|
|
|
|
ZYDIS_STATUS_INVALID_MAP,
|
|
|
|
/**
|
2017-01-13 02:37:57 +08:00
|
|
|
* @brief An error occured while decoding the EVEX-prefix.
|
2016-12-05 09:24:01 +08:00
|
|
|
*/
|
|
|
|
ZYDIS_STATUS_MALFORMED_EVEX,
|
|
|
|
// TODO:
|
2017-01-11 18:20:24 +08:00
|
|
|
ZYDIS_STATUS_INVALID_MASK,
|
2016-12-05 09:24:01 +08:00
|
|
|
ZYDIS_STATUS_INVALID_VSIB,
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------ */
|
|
|
|
/* Formatter */
|
|
|
|
/* ------------------------------------------------------------------------------------------ */
|
|
|
|
|
2016-05-26 03:25:48 +08:00
|
|
|
/**
|
|
|
|
* @brief A buffer passed to a function was too small to complete the requested operation.
|
|
|
|
*/
|
2016-12-05 09:24:01 +08:00
|
|
|
ZYDIS_STATUS_INSUFFICIENT_BUFFER_SIZE,
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------------------------ */
|
|
|
|
/* Misc */
|
|
|
|
/* ------------------------------------------------------------------------------------------ */
|
|
|
|
|
2016-11-24 17:57:23 +08:00
|
|
|
/**
|
|
|
|
* @brief The base value for user-defined status codes.
|
|
|
|
*/
|
2016-12-05 09:24:01 +08:00
|
|
|
ZYDIS_STATUS_USER = 0x10000000
|
2016-05-26 03:25:48 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ============================================================================================== */
|
|
|
|
/* Macros */
|
|
|
|
/* ============================================================================================== */
|
|
|
|
|
|
|
|
/**
|
2016-12-05 09:24:01 +08:00
|
|
|
* @brief Checks if a zydis operation was successfull.
|
2016-05-26 03:25:48 +08:00
|
|
|
*
|
2016-12-05 09:24:01 +08:00
|
|
|
* @param status The zydis status-code to check.
|
2016-05-26 03:25:48 +08:00
|
|
|
*/
|
|
|
|
#define ZYDIS_SUCCESS(status) (status == ZYDIS_STATUS_SUCCESS)
|
|
|
|
|
2017-01-12 00:29:26 +08:00
|
|
|
/**
|
|
|
|
* @brief Checks if a zydis operation was successfull and returns the status-code, if not.
|
|
|
|
*
|
|
|
|
* @param status The zydis status-code to check.
|
|
|
|
*/
|
|
|
|
#define ZYDIS_CHECK(status) \
|
|
|
|
{ \
|
|
|
|
ZydisStatus s = status; \
|
|
|
|
if (!ZYDIS_SUCCESS(s)) \
|
|
|
|
{ \
|
|
|
|
return s; \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
2016-05-26 03:25:48 +08:00
|
|
|
/* ============================================================================================== */
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* ZYDIS_STATUS_H */
|