You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

98 lines
2.9 KiB

#ifndef __NATIVE_CODE_H
#define __NATIVE_CODE_H
#include "Windas.h"
#include "XedWrap.h"
#include "Code.h"
struct _NATIVE_CODE_BLOCK;
struct _NATIVE_CODE_LINK;
typedef BOOL(*FN_INST_ASM_OP)(_NATIVE_CODE_LINK* Link, PUCHAR ToMutate, PVOID Context);
typedef struct _NATIVE_CODE_LINK
{
_NATIVE_CODE_LINK* Next;
_NATIVE_CODE_LINK* Prev;
_NATIVE_CODE_BLOCK* Block;
3 years ago
UINT Flags;
UINT Label;
PUCHAR RawData;
3 years ago
UINT RawDataSize;
XED_DECODED_INST XedInstruction;
STDVECTOR<STDPAIR<FN_INST_ASM_OP, PVOID>> AsmOperations;
_NATIVE_CODE_LINK();
3 years ago
_NATIVE_CODE_LINK(UINT LabelId, _NATIVE_CODE_BLOCK* B);
_NATIVE_CODE_LINK(UINT F, PVOID Rd, UINT Rds, BOOL Decode = FALSE);
~_NATIVE_CODE_LINK();
}NATIVE_CODE_LINK, *PNATIVE_CODE_LINK;
typedef struct _NATIVE_CODE_BLOCK
{
3 years ago
PNATIVE_CODE_LINK Start;
PNATIVE_CODE_LINK End;
3 years ago
STDVECTOR<UINT> LabelIds;
_NATIVE_CODE_BLOCK();
3 years ago
}NATIVE_CODE_BLOCK, *PNATIVE_CODE_BLOCK;
VOID NcAppendToBlock(PNATIVE_CODE_BLOCK Block, PNATIVE_CODE_LINK Link);
VOID NcPrependToBlock(PNATIVE_CODE_BLOCK Block, PNATIVE_CODE_LINK Link);
VOID NcInsertLinkAfter(PNATIVE_CODE_LINK Link1, PNATIVE_CODE_LINK Link2);
VOID NcInsertLinkBefore(PNATIVE_CODE_LINK Link1, PNATIVE_CODE_LINK Link2);
VOID NcUnlink(PNATIVE_CODE_LINK Link);
3 years ago
UINT NcCountInstructions(PNATIVE_CODE_BLOCK Block, BOOL CountCombinedAsOne = FALSE);
3 years ago
UINT NcCalcBlockSizeInBytes(PNATIVE_CODE_BLOCK Block);
3 years ago
3 years ago
VOID NcChangeLabelId(PNATIVE_CODE_BLOCK Block1, UINT Original, UINT New);
3 years ago
3 years ago
UINT NcGenUnusedLabelId(PNATIVE_CODE_BLOCK Block);
3 years ago
VOID NcFixLabelsForBlocks(PNATIVE_CODE_BLOCK Block1, PNATIVE_CODE_BLOCK Block2);
3 years ago
BOOL NcInsertBlockAfter(PNATIVE_CODE_LINK Link, PNATIVE_CODE_BLOCK Block, BOOL FixLabels = TRUE);
3 years ago
BOOL NcInsertBlockBefore(PNATIVE_CODE_LINK Link, PNATIVE_CODE_BLOCK Block, BOOL FixLabels = TRUE);
3 years ago
BOOL NcInsertBlockStartToEnd(PNATIVE_CODE_LINK Start, PNATIVE_CODE_LINK End, PNATIVE_CODE_BLOCK NewBlock);
BOOL NcCreateLabels(PNATIVE_CODE_BLOCK Block);
PNATIVE_CODE_LINK NcValidateJmp(PNATIVE_CODE_LINK Link, INT32 Delta);
3 years ago
PNATIVE_CODE_LINK NcDeepCopyLink(PNATIVE_CODE_LINK Link);
BOOL NcDeepCopyPartialBlock(PNATIVE_CODE_LINK Start, PNATIVE_CODE_LINK End, PNATIVE_CODE_BLOCK Block);
BOOL NcDeepCopyBlock(PNATIVE_CODE_BLOCK Block, PNATIVE_CODE_BLOCK BlockCopy);
BOOL NcPromoteRelJmpTo32(PNATIVE_CODE_LINK Link);
BOOL NcPromoteAllRelJmpTo32(PNATIVE_CODE_BLOCK Block);
3 years ago
BOOL NcGetDeltaToLabel(PNATIVE_CODE_LINK Link, PINT32 DeltaOut);
3 years ago
BOOL NcGetDeltaToRandomLabel(PNATIVE_CODE_LINK Link, PINT32 DeltaOut);
3 years ago
BOOL NcFixRelJmps(PNATIVE_CODE_BLOCK Block);
3 years ago
BOOL NcHasIllegalInstructions(PNATIVE_CODE_BLOCK Block);
3 years ago
BOOL NcDisassemble(PNATIVE_CODE_BLOCK Block, PVOID Buffer, UINT BufferSize);
3 years ago
PVOID NcAssemble(PNATIVE_CODE_BLOCK Block, PUINT OutSize);
3 years ago
PVOID NcAssembleEx(PNATIVE_CODE_BLOCK Block, PUINT OutSize);
VOID NcDeleteBlock(PNATIVE_CODE_BLOCK Block);
3 years ago
VOID NcDebugPrint(PNATIVE_CODE_BLOCK Block);
VOID NcPrintBlockCode(PNATIVE_CODE_BLOCK Block);
#endif