private void WriteGlobalVariable(StructureField field) { var name = program.NamingPolicy.GlobalName(field); var addr = Address.Ptr32((uint)field.Offset); //$BUG: this is completely wrong; field.Offsets should be as wide as the platform permits. try { tw.WriteDeclaration(field.DataType, name); if (program.SegmentMap.IsValidAddress(addr)) { formatter.Write(" = "); this.rdr = program.CreateImageReader(program.Architecture, addr); field.DataType.Accept(this); } } catch (Exception ex) { var dc = services.RequireService <DecompilerEventListener>(); dc.Error( dc.CreateAddressNavigator(program, addr), ex, "Failed to write global variable {0}.", name); } formatter.Terminate(";"); }
public void WriteGlobalVariable(Address address, DataType dataType, string name, Formatter formatter) { this.formatter = formatter; this.codeFormatter = new CodeFormatter(formatter); this.tw = new TypeReferenceFormatter(formatter); this.globals = new StructureType(); this.queue = new Queue <StructureField>(globals.Fields); try { tw.WriteDeclaration(dataType, name); if (program.SegmentMap.IsValidAddress(address)) { formatter.Write(" = "); this.rdr = program.CreateImageReader(program.Architecture, address); dataType.Accept(this); } } catch (Exception ex) { var dc = services.RequireService <DecompilerEventListener>(); dc.Error( dc.CreateAddressNavigator(program, address), ex, "Failed to write global variable {0}.", name); } formatter.Terminate(";"); }
public void WriteGlobals(Formatter formatter) { this.codeFormatter = new CodeFormatter(formatter); var tw = new TypeReferenceFormatter(formatter, true); this.globals = (StructureType)((EquivalenceClass)((Pointer)program.Globals.TypeVariable.DataType).Pointee).DataType; foreach (var field in globals.Fields) { var name = string.Format("g_{0:X}", field.Name); var addr = Address.Ptr32((uint)field.Offset); //$BUG: this is completely wrong; offsets should be as wide as the platform permits. try { tw.WriteDeclaration(field.DataType, name); if (program.Image.IsValidAddress(addr)) { formatter.Write(" = "); this.rdr = program.CreateImageReader(addr); field.DataType.Accept(this); } } catch (Exception ex) { var dc = services.RequireService <DecompilerEventListener>(); dc.Error( dc.CreateAddressNavigator(program, addr), ex, string.Format("Failed to write global variable {0}.", name)); } formatter.Terminate(";"); } }
public void VisitAssignment(Assignment a) { writer.Indent(); if (a.Dst != null) { a.Dst.Accept(this); writer.Write(" = "); } a.Src.Accept(this); if (a.IsAlias) { writer.Write(" (alias)"); } writer.Terminate(); }
public override void Terminate() { WritePrefix(); w.Terminate(); }