本文整理汇总了C#中Pointer.IncrementWithWrapping方法的典型用法代码示例。如果您正苦于以下问题:C# Pointer.IncrementWithWrapping方法的具体用法?C# Pointer.IncrementWithWrapping怎么用?C# Pointer.IncrementWithWrapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pointer
的用法示例。
在下文中一共展示了Pointer.IncrementWithWrapping方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AnalyzeFlowInstruction
/// <summary>
/// Analyzes an instruction and returns a xref if the instruction is
/// one of the branch/call/jump instructions. Note that the 'no-jump'
/// branch of a conditional jump instruction is not returned. The
/// caller must manually create such a xref if needed.
/// </summary>
/// <param name="instruction">The instruction to analyze.</param>
/// <returns>XRef if the instruction is a b/c/j instruction;
/// null otherwise.</returns>
/// TBD: address wrapping if IP is above 0xFFFF is not handled. It should be.
private XRef AnalyzeFlowInstruction(Pointer start, Instruction instruction)
{
Operation op = instruction.Operation;
// Find the type of branch/call/jump instruction being processed.
//
// Note: If the instruction is a conditional jump, we assume that
// the condition may be true or false, so that both "jump" and
// "no jump" is a reachable branch. If the code is malformed such
// that either branch will never be executed, the analysis may not
// work correctly.
//
// Note: If the instruction is a function call, we assume that the
// subroutine being called will return. If the subroutine never
// returns the analysis may not work correctly.
XRefType bcjType;
switch (op)
{
case Operation.JO:
case Operation.JNO:
case Operation.JB:
case Operation.JAE:
case Operation.JE:
case Operation.JNE:
case Operation.JBE:
case Operation.JA:
case Operation.JS:
case Operation.JNS:
case Operation.JP:
case Operation.JNP:
case Operation.JL:
case Operation.JGE:
case Operation.JLE:
case Operation.JG:
case Operation.JCXZ:
case Operation.LOOP:
case Operation.LOOPZ:
case Operation.LOOPNZ:
bcjType = XRefType.ConditionalJump;
break;
case Operation.JMP:
bcjType = XRefType.NearJump;
break;
case Operation.JMPF:
bcjType = XRefType.FarJump;
break;
case Operation.CALL:
bcjType = XRefType.NearCall;
break;
case Operation.CALLF:
bcjType = XRefType.FarCall;
break;
default:
// Not a b/c/j instruction; do nothing.
return null;
}
// Create a cross-reference depending on the type of operand.
if (instruction.Operands[0] is RelativeOperand) // near jump/call to relative address
{
RelativeOperand opr = (RelativeOperand)instruction.Operands[0];
return new XRef(
type: bcjType,
source: start,
target: start.IncrementWithWrapping(instruction.EncodedLength + opr.Offset.Value)
);
}
if (instruction.Operands[0] is PointerOperand) // far jump/call to absolute address
{
PointerOperand opr = (PointerOperand)instruction.Operands[0];
return new XRef(
type: bcjType,
source: start,
target: new Pointer(opr.Segment.Value, (UInt16)opr.Offset.Value)
);
}
if (instruction.Operands[0] is MemoryOperand) // indirect jump/call
{
MemoryOperand opr = (MemoryOperand)instruction.Operands[0];
// Handle static near jump table. We recognize a jump table
// heuristically if the instruction looks like the following:
//
//.........这里部分代码省略.........