parent
f7b351fdb7
commit
71da702d2f
@ -0,0 +1,4 @@
|
||||
.CODE
|
||||
|
||||
|
||||
END
|
@ -1,9 +1,10 @@
|
||||
#ifndef __CODE_H
|
||||
#define __CODE_H
|
||||
|
||||
#define CODE_FLAG_IS_LABEL (1<<0)
|
||||
#define CODE_FLAG_IS_REL_JMP (1<<1)
|
||||
#define CODE_FLAG_IS_INST (1<<2)
|
||||
#define CODE_FLAG_DO_NOT_DIVIDE (1<<3)
|
||||
#define CODE_FLAG_IS_LABEL (1<<0)
|
||||
#define CODE_FLAG_IS_REL_JMP (1<<1)
|
||||
#define CODE_FLAG_IS_INST (1<<2)
|
||||
#define CODE_FLAG_DO_NOT_DIVIDE (1<<3)
|
||||
#define CODE_FLAG_IS_OBFUSCATED (1<<4)
|
||||
|
||||
#endif
|
@ -0,0 +1,446 @@
|
||||
#include "Jit.h"
|
||||
#include "RipXorInst.h"
|
||||
#include "RipAndInst.h"
|
||||
#include "RipOrInst.h"
|
||||
#include "RipMovInst.h"
|
||||
|
||||
|
||||
BOOL JitEmitPushfqInst(PNATIVE_CODE_BLOCK Block)
|
||||
{
|
||||
UCHAR RawData[] = { 0x9C };
|
||||
PNATIVE_CODE_LINK Link = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST, RawData, 1);
|
||||
XedDecode(&Link->XedInstruction, Link->RawData, 1);
|
||||
NcAppendToBlock(Block, Link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL JitEmitPopfqInst(PNATIVE_CODE_BLOCK Block)
|
||||
{
|
||||
UCHAR RawData[] = { 0x9D };
|
||||
PNATIVE_CODE_LINK Link = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST, RawData, 1);
|
||||
XedDecode(&Link->XedInstruction, Link->RawData, 1);
|
||||
NcAppendToBlock(Block, Link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL JitCheckFlagCollisions(CONST XED_FLAG_SET* FlagsRead, XED_FLAG_SET Ledger)
|
||||
{
|
||||
return ((FlagsRead->s.zf && FlagsRead->s.zf == Ledger.s.zf) ||
|
||||
(FlagsRead->s.sf && FlagsRead->s.sf == Ledger.s.sf) ||
|
||||
(FlagsRead->s.pf && FlagsRead->s.pf == Ledger.s.pf) ||
|
||||
(FlagsRead->s.of && FlagsRead->s.of == Ledger.s.of) ||
|
||||
(FlagsRead->s.cf && FlagsRead->s.cf == Ledger.s.cf) ||
|
||||
(FlagsRead->s.af && FlagsRead->s.af == Ledger.s.af)
|
||||
);
|
||||
}
|
||||
|
||||
VOID JitUpdateConFlagsLedger(CONST XED_FLAG_SET* FlagsWritten, XED_FLAG_SET* Ledger)
|
||||
{
|
||||
if (FlagsWritten->s.zf)
|
||||
Ledger->s.zf = FALSE;
|
||||
if (FlagsWritten->s.sf)
|
||||
Ledger->s.sf = FALSE;
|
||||
if (FlagsWritten->s.pf)
|
||||
Ledger->s.pf = FALSE;
|
||||
if (FlagsWritten->s.of)
|
||||
Ledger->s.of = FALSE;
|
||||
if (FlagsWritten->s.cf)
|
||||
Ledger->s.cf = FALSE;
|
||||
if (FlagsWritten->s.af)
|
||||
Ledger->s.af = FALSE;
|
||||
}
|
||||
|
||||
BOOL JitDoesInstOverriteConditionFlags(PNATIVE_CODE_LINK Link)
|
||||
{
|
||||
CONST XED_SIMPLE_FLAG* SimpleFlags = XedDecodedInstGetRflagsInfo(&Link->XedInstruction);
|
||||
CONST XED_FLAG_SET* FlagsWritten = XedSimpleFlagGetWrittenFlagSet(SimpleFlags);
|
||||
CONST XED_FLAG_SET* FlagsUndefined = XedSimpleFlagGetUndefinedFlagSet(SimpleFlags);
|
||||
|
||||
return (FlagsWritten->s.zf &&
|
||||
FlagsWritten->s.sf &&
|
||||
FlagsWritten->s.pf &&
|
||||
FlagsWritten->s.of &&
|
||||
FlagsWritten->s.cf &&
|
||||
FlagsUndefined->s.af
|
||||
);
|
||||
}
|
||||
|
||||
BOOL JitAreFlagsClobberedBeforeUse(PNATIVE_CODE_LINK Link)
|
||||
{
|
||||
XED_FLAG_SET Ledger;
|
||||
Ledger.s.zf = TRUE;
|
||||
Ledger.s.sf = TRUE;
|
||||
Ledger.s.pf = TRUE;
|
||||
Ledger.s.of = TRUE;
|
||||
Ledger.s.cf = TRUE;
|
||||
Ledger.s.af = TRUE;
|
||||
|
||||
for (PNATIVE_CODE_LINK T = Link->Next; T; T = T->Next)
|
||||
{
|
||||
if (T->Flags & CODE_FLAG_IS_LABEL)
|
||||
continue;
|
||||
|
||||
CONST XED_SIMPLE_FLAG* SimpleFlags = XedDecodedInstGetRflagsInfo(&T->XedInstruction);
|
||||
CONST XED_FLAG_SET* FlagsRead = XedSimpleFlagGetReadFlagSet(SimpleFlags);
|
||||
CONST XED_FLAG_SET* FlagsWritten = XedSimpleFlagGetWrittenFlagSet(SimpleFlags);
|
||||
|
||||
if (JitCheckFlagCollisions(FlagsRead, Ledger))
|
||||
return FALSE;
|
||||
|
||||
JitUpdateConFlagsLedger(FlagsWritten, &Ledger);
|
||||
|
||||
if (Ledger.flat == 0)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
VOID JitMutateInstForXor(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA JitData)
|
||||
{
|
||||
ULONG FourByte = Link->RawDataSize / 4;
|
||||
ULONG TwoByte = (Link->RawDataSize - (FourByte * 4)) / 2;
|
||||
ULONG OneByte = (Link->RawDataSize - (FourByte * 4) - (TwoByte * 2));
|
||||
|
||||
PUCHAR Buffer = Link->RawData;
|
||||
while (FourByte)
|
||||
{
|
||||
*(PULONG)Buffer ^= JitData->Data[2 - FourByte];
|
||||
Buffer += 4;
|
||||
FourByte--;
|
||||
}
|
||||
|
||||
if (TwoByte)
|
||||
{
|
||||
*(PUSHORT)Buffer ^= (USHORT)JitData->Data[3];
|
||||
Buffer += 2;
|
||||
}
|
||||
|
||||
if (OneByte)
|
||||
*(PUCHAR)Buffer ^= (UCHAR)JitData->Data[3];
|
||||
|
||||
}
|
||||
|
||||
VOID JitMutateInstForOr(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA XorData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
VOID JitMutateInstForAnd(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA XorData)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PNATIVE_CODE_BLOCK JitEmitPreRipMov(PNATIVE_CODE_LINK Link, INT32 Delta)
|
||||
{
|
||||
ULONG FourByte = Link->RawDataSize / 4;
|
||||
ULONG TwoByte = (Link->RawDataSize - (FourByte * 4)) / 2;
|
||||
ULONG OneByte = (Link->RawDataSize - (FourByte * 4) - (TwoByte * 2));
|
||||
|
||||
PNATIVE_CODE_BLOCK Block = new NATIVE_CODE_BLOCK;
|
||||
|
||||
Block->Start = Block->End = new NATIVE_CODE_LINK;
|
||||
PUCHAR DataOffset = Link->RawData;
|
||||
ULONG Count = FourByte;
|
||||
while (Count)
|
||||
{
|
||||
//Account for remaining MOVs
|
||||
INT32 RipDelta = (((Count - 1) * DWORD_MOV_INST_LENGTH) + (TwoByte * WORD_MOV_INST_LENGTH) + (OneByte * BYTE_MOV_INST_LENGTH));
|
||||
//Account for already MOVd instructions
|
||||
RipDelta += ((FourByte - Count) * 4);
|
||||
RipDelta += Delta;
|
||||
//Add the actual instruction
|
||||
printf("%p IS THE DATAOFFSET\n", DataOffset);
|
||||
system("pause");
|
||||
if (!JitEmitRipRelativeMovD(Block, RipDelta, DataOffset))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
DataOffset += 4;
|
||||
--Count;
|
||||
}
|
||||
|
||||
if (TwoByte)
|
||||
{
|
||||
INT32 RipDelta = (OneByte * BYTE_MOV_INST_LENGTH);
|
||||
RipDelta += (FourByte * 4);
|
||||
RipDelta += Delta;
|
||||
if (!JitEmitRipRelativeMovW(Block, RipDelta, DataOffset))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
DataOffset += 2;
|
||||
}
|
||||
|
||||
if (OneByte)
|
||||
{
|
||||
INT32 RipDelta = 0;
|
||||
RipDelta += (FourByte * 4) + (TwoByte * 2);
|
||||
RipDelta += Delta;
|
||||
if (!JitEmitRipRelativeMovB(Block, RipDelta, DataOffset))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PNATIVE_CODE_LINK StartLink = Block->Start;
|
||||
Block->Start = Block->Start->Next;
|
||||
if (Block->Start)
|
||||
Block->Start->Prev = NULL;
|
||||
delete StartLink;
|
||||
|
||||
return Block;
|
||||
}
|
||||
|
||||
PNATIVE_CODE_BLOCK JitEmitPostRipMov(PNATIVE_CODE_LINK Link, INT32 Delta)
|
||||
{
|
||||
ULONG FourByte = Link->RawDataSize / 4;
|
||||
ULONG TwoByte = (Link->RawDataSize - (FourByte * 4)) / 2;
|
||||
ULONG OneByte = (Link->RawDataSize - (FourByte * 4) - (TwoByte * 2));
|
||||
|
||||
PNATIVE_CODE_BLOCK Block = new NATIVE_CODE_BLOCK;
|
||||
|
||||
Block->Start = Block->End = new NATIVE_CODE_LINK;
|
||||
ULONG ZeroValue = 0;
|
||||
ULONG Count = FourByte;
|
||||
while (Count)
|
||||
{
|
||||
INT32 RipDelta = Link->RawDataSize - ((FourByte - Count) * 4);
|
||||
RipDelta += (FourByte - (Count - 1)) * DWORD_MOV_INST_LENGTH;
|
||||
RipDelta *= (-1);
|
||||
RipDelta += Delta;
|
||||
if (!JitEmitRipRelativeMovD(Block, RipDelta, (PUCHAR)&ZeroValue))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
--Count;
|
||||
}
|
||||
|
||||
if (TwoByte)
|
||||
{
|
||||
INT32 RipDelta = Link->RawDataSize - (FourByte * 4);
|
||||
RipDelta += (FourByte * DWORD_MOV_INST_LENGTH);
|
||||
RipDelta += WORD_MOV_INST_LENGTH;
|
||||
RipDelta *= (-1);
|
||||
RipDelta += Delta;
|
||||
if (!JitEmitRipRelativeMovW(Block, RipDelta, (PUCHAR)&ZeroValue))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (OneByte)
|
||||
{
|
||||
INT32 RipDelta = Link->RawDataSize - (FourByte * 4) - (TwoByte * 2);
|
||||
RipDelta += (FourByte * DWORD_MOV_INST_LENGTH);
|
||||
RipDelta += WORD_MOV_INST_LENGTH;
|
||||
RipDelta += BYTE_MOV_INST_LENGTH;
|
||||
RipDelta *= (-1);
|
||||
RipDelta += Delta;
|
||||
if (!JitEmitRipRelativeMovB(Block, RipDelta, (PUCHAR)&ZeroValue))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PNATIVE_CODE_LINK StartLink = Block->Start;
|
||||
Block->Start = Block->Start->Next;
|
||||
if (Block->Start)
|
||||
Block->Start->Prev = NULL;
|
||||
delete StartLink;
|
||||
|
||||
return Block;
|
||||
}
|
||||
|
||||
BOOL JitiEmitWrapperD(ULONG OpType, PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
switch (OpType)
|
||||
{
|
||||
case JIT_BITWISE_XOR: return JitEmitRipRelativeXorD(Block, RipDelta, Value);
|
||||
case JIT_BITWISE_AND: return JitEmitRipRelativeAndD(Block, RipDelta, Value);
|
||||
case JIT_BITWISE_OR: return JitEmitRipRelativeOrD(Block, RipDelta, Value);
|
||||
}
|
||||
}
|
||||
BOOL JitiEmitWrapperW(ULONG OpType, PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
switch (OpType)
|
||||
{
|
||||
case JIT_BITWISE_XOR: return JitEmitRipRelativeXorW(Block, RipDelta, Value);
|
||||
case JIT_BITWISE_AND: return JitEmitRipRelativeAndW(Block, RipDelta, Value);
|
||||
case JIT_BITWISE_OR: return JitEmitRipRelativeOrW(Block, RipDelta, Value);
|
||||
}
|
||||
}
|
||||
BOOL JitiEmitWrapperB(ULONG OpType, PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
switch (OpType)
|
||||
{
|
||||
case JIT_BITWISE_XOR: return JitEmitRipRelativeXorB(Block, RipDelta, Value);
|
||||
case JIT_BITWISE_AND: return JitEmitRipRelativeAndB(Block, RipDelta, Value);
|
||||
case JIT_BITWISE_OR: return JitEmitRipRelativeOrB(Block, RipDelta, Value);
|
||||
}
|
||||
}
|
||||
|
||||
PNATIVE_CODE_BLOCK JitEmitPreRipBitwiseOp(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA JitData, ULONG OpType, BOOL SaveFlags, INT32 Delta)
|
||||
{
|
||||
ULONG FourByte = Link->RawDataSize / 4;
|
||||
ULONG TwoByte = (Link->RawDataSize - (FourByte * 4)) / 2;
|
||||
ULONG OneByte = (Link->RawDataSize - (FourByte * 4) - (TwoByte * 2));
|
||||
|
||||
PNATIVE_CODE_BLOCK Block = new NATIVE_CODE_BLOCK;
|
||||
if (!Block)
|
||||
return NULL;
|
||||
|
||||
if (SaveFlags && !JitEmitPushfqInst(Block))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ULONG Count = FourByte;
|
||||
while (Count)
|
||||
{
|
||||
INT32 RipDelta = (((Count - 1) * DWORD_RIP_INST_LENGTH) + (TwoByte * WORD_RIP_INST_LENGTH) + (OneByte * BYTE_RIP_INST_LENGTH));
|
||||
if (SaveFlags)
|
||||
RipDelta += 1;
|
||||
RipDelta += ((FourByte - Count) * 4);
|
||||
RipDelta += Delta;
|
||||
if (!JitiEmitWrapperD(OpType, Block, RipDelta, JitData->Data[FourByte - Count]))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
--Count;
|
||||
}
|
||||
|
||||
if (TwoByte)
|
||||
{
|
||||
INT32 RipDelta = (OneByte * BYTE_RIP_INST_LENGTH);
|
||||
if (SaveFlags)
|
||||
RipDelta += 1;
|
||||
RipDelta += (FourByte * 4);
|
||||
RipDelta += Delta;
|
||||
if (!JitiEmitWrapperW(OpType, Block, RipDelta, JitData->Data[3]))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (OneByte)
|
||||
{
|
||||
INT32 RipDelta = 0;
|
||||
if (SaveFlags)
|
||||
RipDelta += 1;
|
||||
RipDelta += (FourByte * 4) + (TwoByte * 2);
|
||||
RipDelta += Delta;
|
||||
if (!JitiEmitWrapperB(OpType, Block, RipDelta, JitData->Data[4]))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (SaveFlags && !JitEmitPopfqInst(Block))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Block;
|
||||
}
|
||||
|
||||
PNATIVE_CODE_BLOCK JitEmitPostRipBitwiseOp(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA JitData, ULONG OpType, BOOL SaveFlags, INT32 Delta)
|
||||
{
|
||||
ULONG FourByte = Link->RawDataSize / 4;
|
||||
ULONG TwoByte = (Link->RawDataSize - (FourByte * 4)) / 2;
|
||||
ULONG OneByte = (Link->RawDataSize - (FourByte * 4) - (TwoByte * 2));
|
||||
|
||||
PNATIVE_CODE_BLOCK Block = new NATIVE_CODE_BLOCK;
|
||||
if (!Block)
|
||||
return NULL;
|
||||
|
||||
if (SaveFlags && !JitEmitPushfqInst(Block))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ULONG Count = FourByte;
|
||||
while (Count)
|
||||
{
|
||||
INT32 RipDelta = Link->RawDataSize - ((FourByte - Count) * 4);
|
||||
if (SaveFlags)
|
||||
RipDelta += 1;
|
||||
RipDelta += (FourByte - (Count - 1)) * DWORD_RIP_INST_LENGTH;
|
||||
RipDelta *= (-1);
|
||||
RipDelta += Delta;
|
||||
if (!JitiEmitWrapperD(OpType, Block, RipDelta, JitData->Data[FourByte - Count]))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
--Count;
|
||||
}
|
||||
|
||||
if (TwoByte)
|
||||
{
|
||||
INT32 RipDelta = Link->RawDataSize - (FourByte * 4);
|
||||
if (SaveFlags)
|
||||
RipDelta += 1;
|
||||
RipDelta += (FourByte * DWORD_RIP_INST_LENGTH);
|
||||
RipDelta += WORD_RIP_INST_LENGTH;
|
||||
RipDelta *= (-1);
|
||||
RipDelta += Delta;
|
||||
if (!JitiEmitWrapperW(OpType, Block, RipDelta, JitData->Data[3]))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (OneByte)
|
||||
{
|
||||
INT32 RipDelta = Link->RawDataSize - (FourByte * 4) - (TwoByte * 2);
|
||||
if (SaveFlags)
|
||||
RipDelta += 1;
|
||||
RipDelta += (FourByte * DWORD_RIP_INST_LENGTH);
|
||||
RipDelta += WORD_RIP_INST_LENGTH;
|
||||
RipDelta += BYTE_RIP_INST_LENGTH;
|
||||
RipDelta *= (-1);
|
||||
RipDelta += Delta;
|
||||
if (!JitiEmitWrapperB(OpType, Block, RipDelta, JitData->Data[4]))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (SaveFlags && !JitEmitPopfqInst(Block))
|
||||
{
|
||||
NcDeleteBlock(Block);
|
||||
delete Block;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return Block;
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
#ifndef __JIT_H
|
||||
#define __JIT_H
|
||||
|
||||
#include "Windas.h"
|
||||
#include "XedWrap.h"
|
||||
#include "NativeCode.h"
|
||||
|
||||
#define DWORD_RIP_INST_LENGTH 10
|
||||
#define WORD_RIP_INST_LENGTH 9
|
||||
#define BYTE_RIP_INST_LENGTH 7
|
||||
|
||||
#define DWORD_MOV_INST_LENGTH 10
|
||||
#define WORD_MOV_INST_LENGTH 9
|
||||
#define BYTE_MOV_INST_LENGTH 7
|
||||
|
||||
#define JIT_BITWISE_XOR 0
|
||||
#define JIT_BITWISE_AND 1
|
||||
#define JIT_BITWISE_OR 2
|
||||
|
||||
typedef struct _JIT_BITWISE_DATA
|
||||
{
|
||||
ULONG Data[5];
|
||||
}JIT_BITWISE_DATA, *PJIT_BITWISE_DATA;
|
||||
|
||||
BOOL JitEmitPushfqInst(PNATIVE_CODE_BLOCK Block);
|
||||
|
||||
BOOL JitEmitPopfqInst(PNATIVE_CODE_BLOCK Block);
|
||||
|
||||
BOOL JitCheckFlagCollisions(CONST XED_FLAG_SET* FlagsRead, XED_FLAG_SET Ledger);
|
||||
|
||||
VOID JitUpdateConFlagsLedger(CONST XED_FLAG_SET* FlagsWritten, XED_FLAG_SET* Ledger);
|
||||
|
||||
BOOL JitDoesInstOverriteConditionFlags(PNATIVE_CODE_LINK Link);
|
||||
|
||||
BOOL JitAreFlagsClobberedBeforeUse(PNATIVE_CODE_LINK Link);
|
||||
|
||||
VOID JitMutateInstForXor(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA XorData);
|
||||
|
||||
VOID JitMutateInstForOr(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA XorData);
|
||||
|
||||
VOID JitMutateInstForAnd(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA XorData);
|
||||
|
||||
PNATIVE_CODE_BLOCK JitEmitPreRipMov(PNATIVE_CODE_LINK Link, INT32 Delta = 0);
|
||||
|
||||
PNATIVE_CODE_BLOCK JitEmitPostRipMov(PNATIVE_CODE_LINK Link, INT32 Delta = 0);
|
||||
|
||||
PNATIVE_CODE_BLOCK JitEmitPreRipBitwiseOp(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA JitData, ULONG OpType, BOOL SaveFlags = TRUE, INT32 Delta = 0);
|
||||
|
||||
PNATIVE_CODE_BLOCK JitEmitPostRipBitwiseOp(PNATIVE_CODE_LINK Link, PJIT_BITWISE_DATA JitData, ULONG OpType, BOOL SaveFlags = TRUE, INT32 Delta = 0);
|
||||
|
||||
#endif
|
@ -0,0 +1,38 @@
|
||||
#include "RipAndInst.h"
|
||||
|
||||
BOOL JitEmitRipRelativeAndD(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
UCHAR RawData[] = { 0x81, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
PNATIVE_CODE_LINK Link = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST | CODE_FLAG_DO_NOT_DIVIDE, RawData, sizeof(RawData));
|
||||
*(PINT32)&Link->RawData[2] = RipDelta;
|
||||
*(PULONG)&Link->RawData[6] = Value;
|
||||
XedDecode(&Link->XedInstruction, Link->RawData, Link->RawDataSize);
|
||||
NcAppendToBlock(Block, Link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL JitEmitRipRelativeAndW(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
UCHAR RawData[] = { 0x66, 0x83, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
PNATIVE_CODE_LINK Link = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST | CODE_FLAG_DO_NOT_DIVIDE, RawData, sizeof(RawData));
|
||||
*(PINT32)&Link->RawData[3] = RipDelta;
|
||||
*(PUSHORT)&Link->RawData[7] = (USHORT)Value;
|
||||
XedDecode(&Link->XedInstruction, Link->RawData, Link->RawDataSize);
|
||||
NcAppendToBlock(Block, Link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL JitEmitRipRelativeAndB(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
UCHAR RawData[] = { 0x80, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
PNATIVE_CODE_LINK Link = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST | CODE_FLAG_DO_NOT_DIVIDE, RawData, sizeof(RawData));
|
||||
*(PINT32)&Link->RawData[2] = RipDelta;
|
||||
*(PUCHAR)&Link->RawData[6] = (UCHAR)Value;
|
||||
XedDecode(&Link->XedInstruction, Link->RawData, Link->RawDataSize);
|
||||
NcAppendToBlock(Block, Link);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
#ifndef __RIP_AND_INST_H
|
||||
#define __RIP_AND_INST_H
|
||||
|
||||
#include "Windas.h"
|
||||
#include "XedWrap.h"
|
||||
#include "NativeCode.h"
|
||||
|
||||
BOOL JitEmitRipRelativeAndD(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value);
|
||||
|
||||
BOOL JitEmitRipRelativeAndW(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value);
|
||||
|
||||
BOOL JitEmitRipRelativeAndB(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value);
|
||||
|
||||
|
||||
|
||||
#endif
|
@ -0,0 +1,38 @@
|
||||
#include "RipOrInst.h"
|
||||
|
||||
BOOL JitEmitRipRelativeOrD(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
UCHAR RawData[] = { 0x81, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
PNATIVE_CODE_LINK Link = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST | CODE_FLAG_DO_NOT_DIVIDE, RawData, sizeof(RawData));
|
||||
*(PINT32)&Link->RawData[2] = RipDelta;
|
||||
*(PULONG)&Link->RawData[6] = Value;
|
||||
XedDecode(&Link->XedInstruction, Link->RawData, Link->RawDataSize);
|
||||
NcAppendToBlock(Block, Link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL JitEmitRipRelativeOrW(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
UCHAR RawData[] = { 0x66, 0x83, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
PNATIVE_CODE_LINK Link = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST | CODE_FLAG_DO_NOT_DIVIDE, RawData, sizeof(RawData));
|
||||
*(PINT32)&Link->RawData[3] = RipDelta;
|
||||
*(PUSHORT)&Link->RawData[7] = (USHORT)Value;
|
||||
XedDecode(&Link->XedInstruction, Link->RawData, Link->RawDataSize);
|
||||
NcAppendToBlock(Block, Link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL JitEmitRipRelativeOrB(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value)
|
||||
{
|
||||
UCHAR RawData[] = { 0x80, 0x0D, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
PNATIVE_CODE_LINK Link = new NATIVE_CODE_LINK(CODE_FLAG_IS_INST | CODE_FLAG_DO_NOT_DIVIDE, RawData, sizeof(RawData));
|
||||
*(PINT32)&Link->RawData[2] = RipDelta;
|
||||
*(PUCHAR)&Link->RawData[6] = (UCHAR)Value;
|
||||
XedDecode(&Link->XedInstruction, Link->RawData, Link->RawDataSize);
|
||||
NcAppendToBlock(Block, Link);
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -0,0 +1,16 @@
|
||||
#ifndef __RIP_OR_INST_H
|
||||
#define __RIP_OR_INST_H
|
||||
|
||||
#include "Windas.h"
|
||||
#include "XedWrap.h"
|
||||
#include "NativeCode.h"
|
||||
|
||||
BOOL JitEmitRipRelativeOrD(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value);
|
||||
|
||||
BOOL JitEmitRipRelativeOrW(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value);
|
||||
|
||||
BOOL JitEmitRipRelativeOrB(PNATIVE_CODE_BLOCK Block, INT32 RipDelta, ULONG Value);
|
||||
|
||||
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,8 @@
|
||||
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.27.29111.0
|
||||
|
||||
include listing.inc
|
||||
|
||||
INCLUDELIB MSVCRTD
|
||||
INCLUDELIB OLDNAMES
|
||||
|
||||
END
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Loading…
Reference in new issue