2015-03-16 06:28:54 +08:00
|
|
|
/**************************************************************************************************
|
|
|
|
|
|
|
|
Verteron Disassembler Engine
|
|
|
|
Version 1.0
|
|
|
|
|
|
|
|
Remarks : Freeware, Copyright must be included
|
|
|
|
|
|
|
|
Original Author : athre0z
|
|
|
|
Modifications :
|
|
|
|
|
2015-03-20 00:13:37 +08:00
|
|
|
Last change : 19. March 2015
|
2015-03-16 06:28:54 +08:00
|
|
|
|
|
|
|
* 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_VXINTERNALHELPERS_H_
|
|
|
|
#define _VDE_VXINTERNALHELPERS_H_
|
|
|
|
|
2015-03-16 23:37:15 +08:00
|
|
|
#include "VXInstructionDecoder.h"
|
|
|
|
#include "VXInstructionFormatter.h"
|
2015-03-16 20:44:18 +08:00
|
|
|
#include "VXInternalConfig.h"
|
2015-03-16 06:28:54 +08:00
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
/* Types IDs =================================================================================== */
|
|
|
|
|
|
|
|
typedef enum _VXTypeId
|
|
|
|
{
|
|
|
|
TYPE_BASEDATASOURCE,
|
|
|
|
TYPE_MEMORYDATASOURCE,
|
2015-03-20 00:13:37 +08:00
|
|
|
TYPE_CUSTOMDATASOURCE,
|
2015-03-16 06:28:54 +08:00
|
|
|
TYPE_INSTRUCTIONDECODER,
|
|
|
|
TYPE_BASESYMBOLRESOLVER,
|
2015-03-16 07:09:31 +08:00
|
|
|
TYPE_CUSTOMSYMBOLRESOLVER,
|
2015-03-16 06:28:54 +08:00
|
|
|
TYPE_BASEINSTRUCTIONFORMATTER,
|
|
|
|
TYPE_INTELINSTRUCTIONFORMATTER,
|
2015-03-20 04:05:14 +08:00
|
|
|
TYPE_CUSTOMINSTRUCTIONFORMATTER,
|
2015-03-16 06:28:54 +08:00
|
|
|
} VXTypeId;
|
|
|
|
|
|
|
|
/* Context conversion helpers ================================================================== */
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE struct _VXBaseDataSource* VXBaseDataSource_thiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
VXBaseDataSourceContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_BASEDATASOURCE
|
2015-03-20 00:13:37 +08:00
|
|
|
|| ctx->d.type == TYPE_MEMORYDATASOURCE
|
|
|
|
|| ctx->d.type == TYPE_CUSTOMDATASOURCE);
|
2015-03-16 06:28:54 +08:00
|
|
|
return (struct _VXBaseDataSource*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE const struct _VXBaseDataSource* VXBaseDataSource_cthiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
const VXBaseDataSourceContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_BASEDATASOURCE
|
2015-03-20 00:13:37 +08:00
|
|
|
|| ctx->d.type == TYPE_MEMORYDATASOURCE
|
|
|
|
|| ctx->d.type == TYPE_CUSTOMDATASOURCE);
|
2015-03-16 06:28:54 +08:00
|
|
|
return (const struct _VXBaseDataSource*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE struct _VXMemoryDataSource* VXMemoryDataSource_thiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
VXBaseDataSourceContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_MEMORYDATASOURCE);
|
|
|
|
return (struct _VXMemoryDataSource*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE const struct _VXMemoryDataSource* VXMemoryDataSource_cthiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
const VXBaseDataSourceContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_MEMORYDATASOURCE);
|
|
|
|
return (const struct _VXMemoryDataSource*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-20 00:13:37 +08:00
|
|
|
VX_INLINE struct _VXCustomDataSource* VXCustomDataSource_thiz(
|
|
|
|
VXBaseDataSourceContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_CUSTOMDATASOURCE);
|
|
|
|
return (struct _VXCustomDataSource*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
VX_INLINE const struct _VXCustomDataSource* VXCustomDataSource_cthiz(
|
|
|
|
const VXBaseDataSourceContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_CUSTOMDATASOURCE);
|
|
|
|
return (const struct _VXCustomDataSource*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE struct _VXInstructionDecoder* VXInstructionDecoder_thiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
VXInstructionDecoderContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_INSTRUCTIONDECODER);
|
|
|
|
return (struct _VXInstructionDecoder*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE const struct _VXInstructionDecoder* VXInstructionDecoder_cthiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
const VXInstructionDecoderContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_INSTRUCTIONDECODER);
|
|
|
|
return (const struct _VXInstructionDecoder*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE struct _VXBaseSymbolResolver* VXBaseSymbolResolver_thiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
VXBaseSymbolResolverContext *ctx)
|
|
|
|
{
|
2015-03-16 07:09:31 +08:00
|
|
|
assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER
|
|
|
|
|| ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
|
2015-03-16 06:28:54 +08:00
|
|
|
return (struct _VXBaseSymbolResolver*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE const struct _VXBaseSymbolResolver* VXBaseSymbolResolver_cthiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
const VXBaseSymbolResolverContext *ctx)
|
|
|
|
{
|
2015-03-16 07:09:31 +08:00
|
|
|
assert(ctx->d.type == TYPE_BASESYMBOLRESOLVER
|
|
|
|
|| ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
|
2015-03-16 06:28:54 +08:00
|
|
|
return (const struct _VXBaseSymbolResolver*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE struct _VXCustomSymbolResolver* VXCustomSymbolResolver_thiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
VXBaseSymbolResolverContext *ctx)
|
|
|
|
{
|
2015-03-16 07:09:31 +08:00
|
|
|
assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
|
|
|
|
return (struct _VXCustomSymbolResolver*)ctx->d.ptr;
|
2015-03-16 06:28:54 +08:00
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE const struct _VXCustomSymbolResolver* VXCustomSymbolResolver_cthiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
const VXBaseSymbolResolverContext *ctx)
|
|
|
|
{
|
2015-03-16 07:09:31 +08:00
|
|
|
assert(ctx->d.type == TYPE_CUSTOMSYMBOLRESOLVER);
|
|
|
|
return (const struct _VXCustomSymbolResolver*)ctx->d.ptr;
|
2015-03-16 06:28:54 +08:00
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_thiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
VXBaseInstructionFormatterContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER
|
2015-03-20 04:05:14 +08:00
|
|
|
|| ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER
|
|
|
|
|| ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
|
2015-03-16 06:28:54 +08:00
|
|
|
return (struct _VXBaseInstructionFormatter*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE const struct _VXBaseInstructionFormatter* VXBaseInstructionFormatter_cthiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
const VXBaseInstructionFormatterContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_BASEINSTRUCTIONFORMATTER
|
2015-03-20 04:05:14 +08:00
|
|
|
|| ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER
|
|
|
|
|| ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
|
2015-03-16 06:28:54 +08:00
|
|
|
return (const struct _VXBaseInstructionFormatter*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE struct _VXIntelInstructionFormatter* VXIntelInstructionFormatter_thiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
VXBaseInstructionFormatterContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER);
|
|
|
|
return (struct _VXIntelInstructionFormatter*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 20:44:18 +08:00
|
|
|
VX_INLINE const struct _VXIntelInstructionFormatter* VXIntelInstructionFormatter_cthiz(
|
2015-03-16 06:28:54 +08:00
|
|
|
const VXBaseInstructionFormatterContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_INTELINSTRUCTIONFORMATTER);
|
|
|
|
return (const struct _VXIntelInstructionFormatter*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-20 04:05:14 +08:00
|
|
|
VX_INLINE struct _VXCustomInstructionFormatter* VXCustomInstructionFormatter_thiz(
|
|
|
|
VXBaseInstructionFormatterContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
|
|
|
|
return (struct _VXCustomInstructionFormatter*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
VX_INLINE const struct _VXCustomInstructionFormatter* VXCustomInstructionFormatter_cthiz(
|
|
|
|
const VXBaseInstructionFormatterContext *ctx)
|
|
|
|
{
|
|
|
|
assert(ctx->d.type == TYPE_CUSTOMINSTRUCTIONFORMATTER);
|
|
|
|
return (struct _VXCustomInstructionFormatter*)ctx->d.ptr;
|
|
|
|
}
|
|
|
|
|
2015-03-16 06:28:54 +08:00
|
|
|
/* ============================================================================================= */
|
|
|
|
|
|
|
|
#endif /* _VDE_VXINTERNALHELPERS_H_ */
|