public unsafe DecodedResult(int maxInstructionCount) { MaxInstructionCount = maxInstructionCount; _instMem = new byte[maxInstructionCount*sizeof (DecodedInstructionStruct)]; _gch = GCHandle.Alloc(_instMem, GCHandleType.Pinned); _instructionsPointer = (DecodedInstructionStruct*) _gch.AddrOfPinnedObject(); }
private static unsafe void TestInstructionsUnmanaged(DecodedInstructionStruct *insts) { Assert.That(insts[0].Address.ToInt32(), Is.EqualTo(0x1000)); Assert.That(new String(insts[0].Mnemonic.Bytes), Is.EqualTo("RET")); Assert.That(insts[1].Address.ToInt32(), Is.EqualTo(0x1001)); Assert.That(new String(insts[1].Mnemonic.Bytes), Is.EqualTo("XOR")); Assert.That(insts[2].Address.ToInt32(), Is.EqualTo(0x1003)); Assert.That(new String(insts[2].Mnemonic.Bytes), Is.EqualTo("RET")); }
internal static unsafe DecodedInstruction FromUnsafe(DecodedInstructionStruct *inst) { return(new DecodedInstruction { Mnemonic = new String(inst->Mnemonic.Bytes), Operands = new String(inst->Operands.Bytes), Hex = new string(inst->InstructionHex.Bytes), Size = inst->Size, Offset = inst->Address }); }