added basic support for compilation as a shared library

This commit is contained in:
Ende! 2015-03-16 13:44:18 +01:00
parent f71edda552
commit 6f0bfdbb06
7 changed files with 109 additions and 60 deletions

View File

@ -33,8 +33,11 @@
#ifndef _VDE_VXDISASSEMBLERUTILSC_H_ #ifndef _VDE_VXDISASSEMBLERUTILSC_H_
#define _VDE_VXDISASSEMBLERUTILSC_H_ #define _VDE_VXDISASSEMBLERUTILSC_H_
#include <stdint.h>
#include "VXDisassemblerTypesC.h" #include "VXDisassemblerTypesC.h"
#include "VXInternalConfig.h"
#include <stdint.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
@ -53,7 +56,9 @@ typedef struct _VXContextDescriptor
* @param operand The operand. * @param operand The operand.
* @return The absolute target address. * @return The absolute target address.
*/ */
uint64_t VXCalcAbsoluteTarget(const VXInstructionInfo *info, const VXOperandInfo *operand); VX_EXPORT uint64_t VXCalcAbsoluteTarget(
const VXInstructionInfo *info,
const VXOperandInfo *operand);
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -53,7 +53,7 @@ typedef struct _VXBaseDataSourceContext { VXContextDescriptor d; } VXBaseDataSou
* @param ctx The context to release. * @param ctx The context to release.
* The context may no longer be used after it was released. * The context may no longer be used after it was released.
*/ */
void VXBaseDataSource_Release( VX_EXPORT void VXBaseDataSource_Release(
VXBaseDataSourceContext *ctx); VXBaseDataSourceContext *ctx);
/** /**
@ -65,7 +65,7 @@ void VXBaseDataSource_Release(
* field of the @c info parameter for error flags. Possible error values are * field of the @c info parameter for error flags. Possible error values are
* @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH. * @c IF_ERROR_END_OF_INPUT or @c IF_ERROR_LENGTH.
*/ */
uint8_t VXBaseDataSource_InputPeek( VX_EXPORT uint8_t VXBaseDataSource_InputPeek(
VXBaseDataSourceContext *ctx, VXBaseDataSourceContext *ctx,
VXInstructionInfo *info); VXInstructionInfo *info);
@ -80,28 +80,28 @@ uint8_t VXBaseDataSource_InputPeek(
* parameter. This function also appends the new byte to to @c data field of the @c info * parameter. This function also appends the new byte to to @c data field of the @c info
* parameter. * parameter.
*/ */
uint8_t VXBaseDataSource_InputNext8( VX_EXPORT uint8_t VXBaseDataSource_InputNext8(
VXBaseDataSourceContext *ctx, VXBaseDataSourceContext *ctx,
VXInstructionInfo *info); VXInstructionInfo *info);
/** /**
* @copydoc VXBaseDataSource_InputNext8 * @copydoc VXBaseDataSource_InputNext8
*/ */
uint16_t VXBaseDataSource_InputNext16( VX_EXPORT uint16_t VXBaseDataSource_InputNext16(
VXBaseDataSourceContext *ctx, VXBaseDataSourceContext *ctx,
VXInstructionInfo *info); VXInstructionInfo *info);
/** /**
* @copydoc VXBaseDataSource_InputNext8 * @copydoc VXBaseDataSource_InputNext8
*/ */
uint32_t VXBaseDataSource_InputNext32( VX_EXPORT uint32_t VXBaseDataSource_InputNext32(
VXBaseDataSourceContext *ctx, VXBaseDataSourceContext *ctx,
VXInstructionInfo *info); VXInstructionInfo *info);
/** /**
* @copydoc VXBaseDataSource_InputNext8 * @copydoc VXBaseDataSource_InputNext8
*/ */
uint64_t VXBaseDataSource_InputNext64( VX_EXPORT uint64_t VXBaseDataSource_InputNext64(
VXBaseDataSourceContext *ctx, VXBaseDataSourceContext *ctx,
VXInstructionInfo *info); VXInstructionInfo *info);
@ -112,7 +112,7 @@ uint64_t VXBaseDataSource_InputNext64(
* The current input byte is set everytime the @c inputPeek or @c inputNext method is called. * The current input byte is set everytime the @c inputPeek or @c inputNext method is called.
*/ */
// TODO: check long descr // TODO: check long descr
uint8_t VXBaseDataSource_InputCurrent( VX_EXPORT uint8_t VXBaseDataSource_InputCurrent(
const VXBaseDataSourceContext *ctx); const VXBaseDataSourceContext *ctx);
/** /**
@ -120,7 +120,7 @@ uint8_t VXBaseDataSource_InputCurrent(
* @param ctx The data soruce context. * @param ctx The data soruce context.
* @return @c true if end of input, @c false if not. * @return @c true if end of input, @c false if not.
*/ */
bool VXBaseDataSource_IsEndOfInput( VX_EXPORT bool VXBaseDataSource_IsEndOfInput(
const VXBaseDataSourceContext *ctx); const VXBaseDataSourceContext *ctx);
/** /**
@ -128,7 +128,7 @@ bool VXBaseDataSource_IsEndOfInput(
* @param ctx The data soruce context. * @param ctx The data soruce context.
* @return The current input position. * @return The current input position.
*/ */
uint64_t VXBaseDataSource_GetPosition( VX_EXPORT uint64_t VXBaseDataSource_GetPosition(
const VXBaseDataSourceContext *ctx); const VXBaseDataSourceContext *ctx);
/** /**
@ -137,7 +137,7 @@ uint64_t VXBaseDataSource_GetPosition(
* @param position The new input position. * @param position The new input position.
* @return @c false if the new position exceeds the maximum input length. * @return @c false if the new position exceeds the maximum input length.
*/ */
bool VXBaseDataSource_SetPosition( VX_EXPORT bool VXBaseDataSource_SetPosition(
VXBaseDataSourceContext *ctx, VXBaseDataSourceContext *ctx,
uint64_t position); uint64_t position);
@ -151,7 +151,7 @@ bool VXBaseDataSource_SetPosition(
* @see VXBaseDataSource_Release * @see VXBaseDataSource_Release
*/ */
// TODO: verify return value // TODO: verify return value
VXBaseDataSourceContext* VXMemoryDataSource_Create( VX_EXPORT VXBaseDataSourceContext* VXMemoryDataSource_Create(
const void* buffer, const void* buffer,
size_t bufferLen); size_t bufferLen);
@ -190,7 +190,7 @@ typedef struct _VXInstructionDecoderContext
* @see VXInstructionDecoder_Release * @see VXInstructionDecoder_Release
*/ */
// TODO: verify return value // TODO: verify return value
VXInstructionDecoderContext* VXInstructionDecoder_Create(void); VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_Create(void);
/** /**
* @brief Creates an instruction decoder. * @brief Creates an instruction decoder.
@ -201,7 +201,7 @@ VXInstructionDecoderContext* VXInstructionDecoder_Create(void);
* @return @c NULL if it fails, else an instruction decoder context. * @return @c NULL if it fails, else an instruction decoder context.
* @see VXInstructionDecoder_Release * @see VXInstructionDecoder_Release
*/ */
VXInstructionDecoderContext* VXInstructionDecoder_CreateEx( VX_EXPORT VXInstructionDecoderContext* VXInstructionDecoder_CreateEx(
VXBaseDataSourceContext *input, VXBaseDataSourceContext *input,
VXDisassemblerMode disassemblerMode, VXDisassemblerMode disassemblerMode,
VXInstructionSetVendor preferredVendor, VXInstructionSetVendor preferredVendor,
@ -211,7 +211,7 @@ VXInstructionDecoderContext* VXInstructionDecoder_CreateEx(
* @brief Releases an instruction decoder. * @brief Releases an instruction decoder.
* @param ctx The context of the instruction decoder to release. * @param ctx The context of the instruction decoder to release.
*/ */
void VXInstructionDecoder_Release( VX_EXPORT void VXInstructionDecoder_Release(
VXInstructionDecoderContext *ctx); VXInstructionDecoderContext *ctx);
/** /**
@ -223,7 +223,7 @@ void VXInstructionDecoder_Release(
* length. In all other cases (valid and invalid instructions) the return value is * length. In all other cases (valid and invalid instructions) the return value is
* @c true. * @c true.
*/ */
bool VXInstructionDecoder_DecodeInstruction( VX_EXPORT bool VXInstructionDecoder_DecodeInstruction(
VXInstructionDecoderContext *ctx, VXInstructionDecoderContext *ctx,
VXInstructionInfo *info); VXInstructionInfo *info);
@ -232,7 +232,7 @@ bool VXInstructionDecoder_DecodeInstruction(
* @param ctx The instruction decoder context. * @param ctx The instruction decoder context.
* @return The context of the data source. * @return The context of the data source.
*/ */
VXBaseDataSourceContext* VXInstructionDecoder_GetDataSource( VX_EXPORT VXBaseDataSourceContext* VXInstructionDecoder_GetDataSource(
const VXInstructionDecoderContext *ctx); const VXInstructionDecoderContext *ctx);
/** /**
@ -240,7 +240,7 @@ VXBaseDataSourceContext* VXInstructionDecoder_GetDataSource(
* @param ctx The instruction decoder context. * @param ctx The instruction decoder context.
* @param input The context of the new input data source. * @param input The context of the new input data source.
*/ */
void VXInstructionDecoder_SetDataSource( VX_EXPORT void VXInstructionDecoder_SetDataSource(
VXInstructionDecoderContext *ctx, VXInstructionDecoderContext *ctx,
VXBaseDataSourceContext *input); VXBaseDataSourceContext *input);
@ -249,7 +249,7 @@ void VXInstructionDecoder_SetDataSource(
* @param ctx The instruction decoder context. * @param ctx The instruction decoder context.
* @return The current disassembler mode. * @return The current disassembler mode.
*/ */
VXDisassemblerMode VXInstructionDecoder_GetDisassemblerMode( VX_EXPORT VXDisassemblerMode VXInstructionDecoder_GetDisassemblerMode(
const VXInstructionDecoderContext *ctx); const VXInstructionDecoderContext *ctx);
/** /**
@ -257,7 +257,7 @@ VXDisassemblerMode VXInstructionDecoder_GetDisassemblerMode(
* @param ctx The instruction decoder context. * @param ctx The instruction decoder context.
* @param disassemblerMode The new disassembler mode. * @param disassemblerMode The new disassembler mode.
*/ */
void VXInstructionDecoder_SetDisassemblerMode( VX_EXPORT void VXInstructionDecoder_SetDisassemblerMode(
VXInstructionDecoderContext *ctx, VXInstructionDecoderContext *ctx,
VXDisassemblerMode disassemblerMode); VXDisassemblerMode disassemblerMode);
@ -266,7 +266,7 @@ void VXInstructionDecoder_SetDisassemblerMode(
* @param ctx The instruction decoder context. * @param ctx The instruction decoder context.
* @return The preferred instruction-set vendor. * @return The preferred instruction-set vendor.
*/ */
VXInstructionSetVendor VXInstructionDecoder_GetPreferredVendor( VX_EXPORT VXInstructionSetVendor VXInstructionDecoder_GetPreferredVendor(
const VXInstructionDecoderContext *ctx); const VXInstructionDecoderContext *ctx);
/** /**
@ -274,7 +274,7 @@ VXInstructionSetVendor VXInstructionDecoder_GetPreferredVendor(
* @param ctx The instruction decoder context. * @param ctx The instruction decoder context.
* @param preferredVendor The new preferred instruction-set vendor. * @param preferredVendor The new preferred instruction-set vendor.
*/ */
void VXInstructionDecoder_SetPreferredVendor( VX_EXPORT void VXInstructionDecoder_SetPreferredVendor(
VXInstructionDecoderContext *ctx, VXInstructionDecoderContext *ctx,
VXInstructionSetVendor preferredVendor); VXInstructionSetVendor preferredVendor);
@ -283,7 +283,7 @@ void VXInstructionDecoder_SetPreferredVendor(
* @param ctx The instruction decoder context. * @param ctx The instruction decoder context.
* @return The current instruction pointer. * @return The current instruction pointer.
*/ */
uint64_t VXInstructionDecoder_GetInstructionPointer( VX_EXPORT uint64_t VXInstructionDecoder_GetInstructionPointer(
const VXInstructionDecoderContext *ctx); const VXInstructionDecoderContext *ctx);
/** /**
@ -291,7 +291,7 @@ uint64_t VXInstructionDecoder_GetInstructionPointer(
* @param ctx The instruction decoder context. * @param ctx The instruction decoder context.
* @param instructionPointer The new instruction pointer. * @param instructionPointer The new instruction pointer.
*/ */
void VXInstructionDecoder_SetInstructionPointer( VX_EXPORT void VXInstructionDecoder_SetInstructionPointer(
VXInstructionDecoderContext *ctx, VXInstructionDecoderContext *ctx,
uint64_t instructionPointer); uint64_t instructionPointer);

View File

@ -53,7 +53,7 @@ typedef struct _VXBaseSymbolResolverContext
* @param ctx The context of the symbol resolver to free. * @param ctx The context of the symbol resolver to free.
* The context may no longer used after it was released. * The context may no longer used after it was released.
*/ */
void VXBaseSymbolResolver_Release( VX_EXPORT void VXBaseSymbolResolver_Release(
VXBaseSymbolResolverContext *ctx); VXBaseSymbolResolverContext *ctx);
/** /**
@ -65,7 +65,7 @@ void VXBaseSymbolResolver_Release(
* the base address of the symbol. * the base address of the symbol.
* @return The name of the symbol if the symbol was found, else @c NULL. * @return The name of the symbol if the symbol was found, else @c NULL.
*/ */
const char* VXBaseSymbolResolver_ResolveSymbol( VX_EXPORT const char* VXBaseSymbolResolver_ResolveSymbol(
VXBaseSymbolResolverContext *ctx, VXBaseSymbolResolverContext *ctx,
const VXInstructionInfo *info, const VXInstructionInfo *info,
uint64_t address, uint64_t address,
@ -86,7 +86,7 @@ typedef const char* (*VXCustomSymbolResolver_ResolveSymbolCallback)(
* May also be @c NULL. * May also be @c NULL.
* @return @c NULL if it fails, else a symbol resolver context. * @return @c NULL if it fails, else a symbol resolver context.
*/ */
VXBaseSymbolResolverContext* VXCustomSymbolResolver_Create( VX_EXPORT VXBaseSymbolResolverContext* VXCustomSymbolResolver_Create(
VXCustomSymbolResolver_ResolveSymbolCallback resolverCb, VXCustomSymbolResolver_ResolveSymbolCallback resolverCb,
void *userData); void *userData);
@ -104,7 +104,7 @@ typedef struct _VXBaseInstructionFormatterContext
* @return Pointer to the formatted instruction string. This pointer remains valid until * @return Pointer to the formatted instruction string. This pointer remains valid until
* this function is called again or the context is released. * this function is called again or the context is released.
*/ */
const char* VXBaseInstructionFormatter_FormatInstruction( VX_EXPORT const char* VXBaseInstructionFormatter_FormatInstruction(
VXBaseInstructionFormatterContext *ctx, VXBaseInstructionFormatterContext *ctx,
const VXInstructionInfo *info); const VXInstructionInfo *info);
@ -113,7 +113,7 @@ const char* VXBaseInstructionFormatter_FormatInstruction(
* @param ctx The instruction formatter context. * @param ctx The instruction formatter context.
* @return Pointer to the current symbol resolver or @c NULL if no symbol resolver is used. * @return Pointer to the current symbol resolver or @c NULL if no symbol resolver is used.
*/ */
VXBaseSymbolResolverContext* VXBaseInstructionFormatter_GetSymbolResolver( VX_EXPORT VXBaseSymbolResolverContext* VXBaseInstructionFormatter_GetSymbolResolver(
const VXBaseInstructionFormatterContext *ctx); const VXBaseInstructionFormatterContext *ctx);
/** /**
@ -122,7 +122,7 @@ VXBaseSymbolResolverContext* VXBaseInstructionFormatter_GetSymbolResolver(
* @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol * @param symbolResolver Pointer to a symbol resolver instance or @c NULL, if no smybol
* resolver should be used. * resolver should be used.
*/ */
void VXBaseInstructionFormatter_SetSymbolResolver( VX_EXPORT void VXBaseInstructionFormatter_SetSymbolResolver(
VXBaseInstructionFormatterContext *ctx, VXBaseInstructionFormatterContext *ctx,
VXBaseSymbolResolverContext *resolver); VXBaseSymbolResolverContext *resolver);
@ -131,7 +131,7 @@ void VXBaseInstructionFormatter_SetSymbolResolver(
* @param ctx The context of the instruction formatter to release. * @param ctx The context of the instruction formatter to release.
* The context may no longer used after it has been released. * The context may no longer used after it has been released.
*/ */
void VXBaseInstructionFormatter_Release( VX_EXPORT void VXBaseInstructionFormatter_Release(
VXBaseInstructionFormatterContext *ctx); VXBaseInstructionFormatterContext *ctx);
/* VXIntelInstructionFormatter ================================================================ */ /* VXIntelInstructionFormatter ================================================================ */
@ -141,7 +141,7 @@ void VXBaseInstructionFormatter_Release(
* @return @c NULL if it fails, else an Intel instruction formatter context. * @return @c NULL if it fails, else an Intel instruction formatter context.
* @see VXBaseInstructionFormatter_Release * @see VXBaseInstructionFormatter_Release
*/ */
VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_Create(void); VX_EXPORT VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_Create(void);
/** /**
* @brief Creates an Intel-syntax instruction formatter. * @brief Creates an Intel-syntax instruction formatter.
@ -149,7 +149,7 @@ VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_Create(void);
* @return @c NULL if it fails, else an Intel instruction formatter context. * @return @c NULL if it fails, else an Intel instruction formatter context.
* @see VXBaseInstructionFormatter_Release * @see VXBaseInstructionFormatter_Release
*/ */
VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_CreateEx( VX_EXPORT VXBaseInstructionFormatterContext* VXIntelInstructionFormatter_CreateEx(
VXBaseSymbolResolverContext *resolver); VXBaseSymbolResolverContext *resolver);
/* ============================================================================================= */ /* ============================================================================================= */

View File

@ -0,0 +1,44 @@
/**************************************************************************************************
Verteron Disassembler Engine
Version 1.0
Remarks : Freeware, Copyright must be included
Original Author : athre0z
Modifications :
Last change : 16. March 2015
* 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 _VDE_VXINTERNALCONFIG_H_
#define _VDE_VXINTERNALCONFIG_H_
#ifdef _MSC_VER
# define VX_INLINE __inline
#else
# define VX_INLINE inline
#endif
#define VX_EXPORT
#endif /* _VDE_VXINTERNALCONFIG_H_ */

View File

@ -35,6 +35,7 @@
#include "VXInstructionDecoderC.h" #include "VXInstructionDecoderC.h"
#include "VXInstructionFormatterC.h" #include "VXInstructionFormatterC.h"
#include "VXInternalConfig.h"
#include <assert.h> #include <assert.h>
@ -56,9 +57,7 @@ typedef enum _VXTypeId
/* Context conversion helpers ================================================================== */ /* Context conversion helpers ================================================================== */
// TODO: don't use __inline VX_INLINE struct _VXBaseDataSource* VXBaseDataSource_thiz(
__inline struct _VXBaseDataSource* VXBaseDataSource_thiz(
VXBaseDataSourceContext *ctx) VXBaseDataSourceContext *ctx)
{ {
assert(ctx->d.type == TYPE_BASEDATASOURCE assert(ctx->d.type == TYPE_BASEDATASOURCE
@ -66,7 +65,7 @@ __inline struct _VXBaseDataSource* VXBaseDataSource_thiz(
return (struct _VXBaseDataSource*)ctx->d.ptr; return (struct _VXBaseDataSource*)ctx->d.ptr;
} }
__inline const struct _VXBaseDataSource* VXBaseDataSource_cthiz( VX_INLINE const struct _VXBaseDataSource* VXBaseDataSource_cthiz(
const VXBaseDataSourceContext *ctx) const VXBaseDataSourceContext *ctx)
{ {
assert(ctx->d.type == TYPE_BASEDATASOURCE assert(ctx->d.type == TYPE_BASEDATASOURCE
@ -74,35 +73,35 @@ __inline const struct _VXBaseDataSource* VXBaseDataSource_cthiz(
return (const struct _VXBaseDataSource*)ctx->d.ptr; return (const struct _VXBaseDataSource*)ctx->d.ptr;
} }
__inline struct _VXMemoryDataSource* VXMemoryDataSource_thiz( VX_INLINE struct _VXMemoryDataSource* VXMemoryDataSource_thiz(
VXBaseDataSourceContext *ctx) VXBaseDataSourceContext *ctx)
{ {
assert(ctx->d.type == TYPE_MEMORYDATASOURCE); assert(ctx->d.type == TYPE_MEMORYDATASOURCE);
return (struct _VXMemoryDataSource*)ctx->d.ptr; return (struct _VXMemoryDataSource*)ctx->d.ptr;
} }
__inline const struct _VXMemoryDataSource* VXMemoryDataSource_cthiz( VX_INLINE const struct _VXMemoryDataSource* VXMemoryDataSource_cthiz(
const VXBaseDataSourceContext *ctx) const VXBaseDataSourceContext *ctx)
{ {
assert(ctx->d.type == TYPE_MEMORYDATASOURCE); assert(ctx->d.type == TYPE_MEMORYDATASOURCE);
return (const struct _VXMemoryDataSource*)ctx->d.ptr; return (const struct _VXMemoryDataSource*)ctx->d.ptr;
} }
__inline struct _VXInstructionDecoder* VXInstructionDecoder_thiz( VX_INLINE struct _VXInstructionDecoder* VXInstructionDecoder_thiz(
VXInstructionDecoderContext *ctx) VXInstructionDecoderContext *ctx)
{ {
assert(ctx->d.type == TYPE_INSTRUCTIONDECODER); assert(ctx->d.type == TYPE_INSTRUCTIONDECODER);
return (struct _VXInstructionDecoder*)ctx->d.ptr; return (struct _VXInstructionDecoder*)ctx->d.ptr;
} }
__inline const struct _VXInstructionDecoder* VXInstructionDecoder_cthiz( VX_INLINE const struct _VXInstructionDecoder* VXInstructionDecoder_cthiz(
const VXInstructionDecoderContext *ctx) const VXInstructionDecoderContext *ctx)
{ {
assert(ctx->d.type == TYPE_INSTRUCTIONDECODER); assert(ctx->d.type == TYPE_INSTRUCTIONDECODER);
return (const struct _VXInstructionDecoder*)ctx->d.ptr; return (const struct _VXInstructionDecoder*)ctx->d.ptr;
} }
__inline struct _VXBaseSymbolResolver* VXBaseSymbolResolver_thiz( VX_INLINE struct _VXBaseSymbolResolver* VXBaseSymbolResolver_thiz(
VXBaseSymbolResolverContext *ctx) VXBaseSymbolResolverContext *ctx)
{ {
assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER
@ -110,7 +109,7 @@ __inline struct _VXBaseSymbolResolver* VXBaseSymbolResolver_thiz(
return (struct _VXBaseSymbolResolver*)ctx->d.ptr; return (struct _VXBaseSymbolResolver*)ctx->d.ptr;
} }
__inline const struct _VXBaseSymbolResolver* VXBaseSymbolResolver_cthiz( VX_INLINE const struct _VXBaseSymbolResolver* VXBaseSymbolResolver_cthiz(
const VXBaseSymbolResolverContext *ctx) const VXBaseSymbolResolverContext *ctx)
{ {
assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER
@ -118,21 +117,21 @@ __inline const struct _VXBaseSymbolResolver* VXBaseSymbolResolver_cthiz(
return (const struct _VXBaseSymbolResolver*)ctx->d.ptr; return (const struct _VXBaseSymbolResolver*)ctx->d.ptr;
} }
__inline struct _VXCustomSymbolResolver* VXCustomSymbolResolver_thiz( VX_INLINE struct _VXCustomSymbolResolver* VXCustomSymbolResolver_thiz(
VXBaseSymbolResolverContext *ctx) VXBaseSymbolResolverContext *ctx)
{ {
assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER); assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (struct _VXCustomSymbolResolver*)ctx->d.ptr; return (struct _VXCustomSymbolResolver*)ctx->d.ptr;
} }
__inline const struct _VXCustomSymbolResolver* VXCustomSymbolResolver_cthiz( VX_INLINE const struct _VXCustomSymbolResolver* VXCustomSymbolResolver_cthiz(
const VXBaseSymbolResolverContext *ctx) const VXBaseSymbolResolverContext *ctx)
{ {
assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER); assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
return (const struct _VXCustomSymbolResolver*)ctx->d.ptr; return (const struct _VXCustomSymbolResolver*)ctx->d.ptr;
} }
__inline struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_thiz( VX_INLINE struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_thiz(
VXBaseInstructionFormatterContext *ctx) VXBaseInstructionFormatterContext *ctx)
{ {
assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER
@ -140,7 +139,7 @@ __inline struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_thiz(
return (struct _VXBaseInstructionFormatter*)ctx->d.ptr; return (struct _VXBaseInstructionFormatter*)ctx->d.ptr;
} }
__inline const struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_cthiz( VX_INLINE const struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_cthiz(
const VXBaseInstructionFormatterContext *ctx) const VXBaseInstructionFormatterContext *ctx)
{ {
assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER
@ -148,14 +147,14 @@ __inline const struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_ct
return (const struct _VXBaseInstructionFormatter*)ctx->d.ptr; return (const struct _VXBaseInstructionFormatter*)ctx->d.ptr;
} }
__inline struct _VXIntelInstructionFormatter* VXIntelInstructionFormatter_thiz( VX_INLINE struct _VXIntelInstructionFormatter* VXIntelInstructionFormatter_thiz(
VXBaseInstructionFormatterContext *ctx) VXBaseInstructionFormatterContext *ctx)
{ {
assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER); assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER);
return (struct _VXIntelInstructionFormatter*)ctx->d.ptr; return (struct _VXIntelInstructionFormatter*)ctx->d.ptr;
} }
__inline const struct _VXIntelInstructionFormatter* VXIntelInstructionFormatter_cthiz( VX_INLINE const struct _VXIntelInstructionFormatter* VXIntelInstructionFormatter_cthiz(
const VXBaseInstructionFormatterContext *ctx) const VXBaseInstructionFormatterContext *ctx)
{ {
assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER); assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER);

View File

@ -168,7 +168,7 @@ extern const char* vxInstrMnemonicStrings[];
* @param node The node. * @param node The node.
* @return The type of the specified opcode tree node. * @return The type of the specified opcode tree node.
*/ */
__inline VXOpcodeTreeNodeType VXGetOpcodeNodeType(VXOpcodeTreeNode node) VX_INLINE VXOpcodeTreeNodeType VXGetOpcodeNodeType(VXOpcodeTreeNode node)
{ {
return (VXOpcodeTreeNodeType)((node >> 12) & 0x0F); return (VXOpcodeTreeNodeType)((node >> 12) & 0x0F);
} }
@ -178,7 +178,7 @@ __inline VXOpcodeTreeNodeType VXGetOpcodeNodeType(VXOpcodeTreeNode node)
* @param node The node. * @param node The node.
* @return The value of the specified opcode tree node. * @return The value of the specified opcode tree node.
*/ */
__inline uint16_t VXGetOpcodeNodeValue(VXOpcodeTreeNode node) VX_INLINE uint16_t VXGetOpcodeNodeValue(VXOpcodeTreeNode node)
{ {
return (node & 0x0FFF); return (node & 0x0FFF);
} }
@ -187,7 +187,7 @@ __inline uint16_t VXGetOpcodeNodeValue(VXOpcodeTreeNode node)
* @brief Returns the root node of the opcode tree. * @brief Returns the root node of the opcode tree.
* @return The root node of the opcode tree. * @return The root node of the opcode tree.
*/ */
__inline VXOpcodeTreeNode VXGetOpcodeTreeRoot() VX_INLINE VXOpcodeTreeNode VXGetOpcodeTreeRoot()
{ {
return 0x1000; return 0x1000;
} }
@ -198,7 +198,7 @@ __inline VXOpcodeTreeNode VXGetOpcodeTreeRoot()
* @param index The index of the child node to retrieve. * @param index The index of the child node to retrieve.
* @return The specified child node. * @return The specified child node.
*/ */
__inline VXOpcodeTreeNode VXGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_t index) VX_INLINE VXOpcodeTreeNode VXGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_t index)
{ {
VXOpcodeTreeNodeType nodeType = VXGetOpcodeNodeType(parent); VXOpcodeTreeNodeType nodeType = VXGetOpcodeNodeType(parent);
uint16_t tableIndex = VXGetOpcodeNodeValue(parent); uint16_t tableIndex = VXGetOpcodeNodeValue(parent);
@ -257,7 +257,7 @@ __inline VXOpcodeTreeNode VXGetOpcodeTreeChild(VXOpcodeTreeNode parent, uint16_t
* @param node The instruction definition node. * @param node The instruction definition node.
* @return Pointer to the instruction definition. * @return Pointer to the instruction definition.
*/ */
__inline const VXInstructionDefinition* VXGetInstructionDefinition(VXOpcodeTreeNode node) VX_INLINE const VXInstructionDefinition* VXGetInstructionDefinition(VXOpcodeTreeNode node)
{ {
assert(VXGetOpcodeNodeType(node) == OTNT_INSTRUCTION_DEFINITION); assert(VXGetOpcodeNodeType(node) == OTNT_INSTRUCTION_DEFINITION);
return &vxInstrDefinitions[node & 0x0FFF]; return &vxInstrDefinitions[node & 0x0FFF];
@ -268,7 +268,7 @@ __inline const VXInstructionDefinition* VXGetInstructionDefinition(VXOpcodeTreeN
* @param mnemonic The mnemonic. * @param mnemonic The mnemonic.
* @return The instruction mnemonic string. * @return The instruction mnemonic string.
*/ */
__inline const char* VXGetInstructionMnemonicString(VXInstructionMnemonic mnemonic) VX_INLINE const char* VXGetInstructionMnemonicString(VXInstructionMnemonic mnemonic)
{ {
return vxInstrMnemonicStrings[(uint16_t)mnemonic]; return vxInstrMnemonicStrings[(uint16_t)mnemonic];
} }
@ -278,7 +278,7 @@ __inline const char* VXGetInstructionMnemonicString(VXInstructionMnemonic mnemon
* @param operandSize The defined operand size. * @param operandSize The defined operand size.
* @return The the numeric value for the simple operand size definition. * @return The the numeric value for the simple operand size definition.
*/ */
__inline uint16_t VXGetSimpleOperandSize(VXDefinedOperandSize operandSize) VX_INLINE uint16_t VXGetSimpleOperandSize(VXDefinedOperandSize operandSize)
{ {
static const uint16_t operandSizes[8] = static const uint16_t operandSizes[8] =
{ {
@ -295,7 +295,7 @@ __inline uint16_t VXGetSimpleOperandSize(VXDefinedOperandSize operandSize)
* @param operandSize The defined operand size. * @param operandSize The defined operand size.
* @return The memory-size part of the operand size definition. * @return The memory-size part of the operand size definition.
*/ */
__inline VXDefinedOperandSize VXGetComplexOperandMemSize(VXDefinedOperandSize operandSize) VX_INLINE VXDefinedOperandSize VXGetComplexOperandMemSize(VXDefinedOperandSize operandSize)
{ {
return (VXDefinedOperandSize)(operandSize & 0x0F); return (VXDefinedOperandSize)(operandSize & 0x0F);
} }
@ -305,7 +305,7 @@ __inline VXDefinedOperandSize VXGetComplexOperandMemSize(VXDefinedOperandSize op
* @param operandSize The defined operand size. * @param operandSize The defined operand size.
* @return The register-size part of the operand size definition. * @return The register-size part of the operand size definition.
*/ */
__inline VXDefinedOperandSize VXGetComplexOperandRegSize(VXDefinedOperandSize operandSize) VX_INLINE VXDefinedOperandSize VXGetComplexOperandRegSize(VXDefinedOperandSize operandSize)
{ {
return (VXDefinedOperandSize)((operandSize >> 4) & 0x0F); return (VXDefinedOperandSize)((operandSize >> 4) & 0x0F);
} }

View File

@ -46,7 +46,8 @@ if (BUILD_C_BINDINGS)
"Bindings/C/VXInstructionFormatterC.h" "Bindings/C/VXInstructionFormatterC.h"
"Bindings/C/VXOpcodeTableC.h" "Bindings/C/VXOpcodeTableC.h"
"Bindings/C/VXOpcodeTableInternalC.h" "Bindings/C/VXOpcodeTableInternalC.h"
"Bindings/C/VXInternalHelpersC.h") "Bindings/C/VXInternalHelpersC.h"
"Bindings/C/VXInternalConfig.h")
set(vdec_sources set(vdec_sources
"Bindings/C/VXDisassemblerUtilsC.c" "Bindings/C/VXDisassemblerUtilsC.c"
"Bindings/C/VXInstructionFormatterC.c" "Bindings/C/VXInstructionFormatterC.c"