public Expression ImportedGlobal(Address addrInstruction, PrimitiveType addrWidth, MemoryOperand mem) { if (mem != null && addrWidth == PrimitiveType.Word32 && mem.Base == RegisterStorage.None && mem.Index == RegisterStorage.None) { var id = host.GetImport(Address.Ptr32(mem.Offset.ToUInt32()), addrInstruction); return(id); } return(null); }
public Expression CreateMemoryAccess(X86Instruction instr, MemoryOperand mem, DataType dt, X86State state) { Expression expr = EffectiveAddressExpression(instr, mem, state); //$REVIEW: perhaps the code below could be moved to Scanner since it is arch-independent? if (expr is Address addrThunk) { var exg = host.GetImport(addrThunk, instr.Address); if (exg is ProcedureConstant) { return(exg); } else if (exg != null) { return(new UnaryExpression(Operator.AddrOf, dt, exg)); } var exp = host.GetImportedProcedure(arch, addrThunk, instr.Address); if (exp != null) { return(new ProcedureConstant(arch.PointerType, exp)); } } if (IsSegmentedAccessRequired || (mem.DefaultSegment != Registers.cs && mem.DefaultSegment != Registers.ds && mem.DefaultSegment != Registers.ss)) { Expression seg; if (mem.DefaultSegment == Registers.cs) { seg = Constant.Create(PrimitiveType.SegmentSelector, instr.Address.Selector.Value); } else { seg = AluRegister(mem.DefaultSegment); } return(new SegmentedAccess(MemoryIdentifier.GlobalMemory, seg, expr, dt)); } else { return(new MemoryAccess(MemoryIdentifier.GlobalMemory, expr, dt)); } }