Esempio n. 1
0
        public override Program Load(Address addrLoad)
        {
            BinHexDecoder dec = new BinHexDecoder(new StringReader(Encoding.ASCII.GetString(RawImage)));
            IEnumerator<byte> stm = dec.GetBytes().GetEnumerator();
            BinHexHeader hdr = LoadBinHexHeader(stm);
            byte[] dataFork = LoadFork(hdr.DataForkLength, stm);
            byte[] rsrcFork = LoadFork(hdr.ResourceForkLength, stm);

            var arch = new M68kArchitecture();
            var platform = new MacOSClassic(Services, arch);
            if (hdr.FileType == "PACT")
            {
                Cpt.CompactProArchive archive = new Cpt.CompactProArchive();
                List<ArchiveDirectoryEntry> items = archive.Load(new MemoryStream(dataFork));
                IArchiveBrowserService abSvc = Services.GetService<IArchiveBrowserService>();
                if (abSvc != null)
                {
                    var selectedFile = abSvc.UserSelectFileFromArchive(items);
                    if (selectedFile != null)
                    {
                        var image = selectedFile.GetBytes();
                        this.rsrcFork = new ResourceFork(image, arch);
                        this.image = new LoadedImage(addrLoad, image);
                        this.imageMap = new ImageMap(addrLoad, image.Length);
                        return new Program(this.image, this.imageMap, arch, platform);
                    }
                }
            }

            var li = new LoadedImage(addrLoad, dataFork);
            return new Program(li, li.CreateImageMap(), arch, platform);
        }
Esempio n. 2
0
 public Project(object key, string number, string name)
     : base(key)
 {
     this.number = number;
     this.name = name;
     this.address = null;
     this.owner = null;
     this.constructionAdministrator = null;
     this.principal = null;
     this.contractDate = null;
     this.estimatedStartDate = null;
     this.estimatedCompletionDate = null;
     this.currentCompletionDate = null;
     this.actualCompletionDate = null;
     this.contingencyAllowanceAmount = 0;
     this.testingAllowanceAmount = 0;
     this.utilityAllowanceAmount = 0;
     this.originalConstructionCost = 0;
     this.totalChangeOrderDays = 0;
     this.adjustedConstructionCost = 0;
     this.totalChangeOrdersAmount = 0;
     this.totalSquareFeet = 0;
     this.percentComplete = 0;
     this.remarks = string.Empty;
     this.aeChangeOrderAmount = 0;
     this.contractReason = string.Empty;
     this.agencyApplicationNumber = string.Empty;
     this.agencyFileNumber = string.Empty;
     this.segment = null;
     this.allowances = new List<Allowance>();
 }
Esempio n. 3
0
 public DisassemblyTextModel(Program program)
 {
     if (program == null)
         throw new ArgumentNullException("program");
     this.program = program;
     this.position = program.Image.BaseAddress;
 }
Esempio n. 4
0
		public override RelocationResults Relocate(Address addrLoad)
		{
			ImageMap imageMap = imgLoadedMap;
			ImageReader rdr = new LeImageReader(exe.RawImage, (uint) exe.e_lfaRelocations);
            var relocations = new RelocationDictionary();
			int i = exe.e_cRelocations;
			while (i != 0)
			{
				uint offset = rdr.ReadLeUInt16();
				ushort segOffset = rdr.ReadLeUInt16();
				offset += segOffset * 0x0010u;

				ushort seg = (ushort) (imgLoaded.ReadLeUInt16(offset) + addrLoad.Selector);
				imgLoaded.WriteLeUInt16(offset, seg);
				relocations.AddSegmentReference(offset, seg);

				imageMap.AddSegment(Address.SegPtr(seg, 0), seg.ToString("X4"), AccessMode.ReadWriteExecute);
				--i;
			}
		
			// Found the start address.

			Address addrStart = Address.SegPtr((ushort)(exe.e_cs + addrLoad.Selector), exe.e_ip);
			imageMap.AddSegment(Address.SegPtr(addrStart.Selector, 0), addrStart.Selector.ToString("X4"), AccessMode.ReadWriteExecute);
            return new RelocationResults(
                new List<EntryPoint> { new EntryPoint(addrStart, arch.CreateProcessorState()) },
                relocations);
		}
Esempio n. 5
0
		public void Test()
		{
			int id = -1;
			
			using (ISession s = OpenSession())
			{
				var address1 = new Address("60", "EH3 8BE");
				var address2 = new Address("2", "EH6 6JA");
				s.Save(address1);
				s.Save(address2);
				
				var person1 = new Person("'lil old me");
				person1.AddPercentageToFeeMatrix(0, .20m);
				person1.AddPercentageToFeeMatrix(50, .15m);
				person1.AddPercentageToFeeMatrix(100, .1m);
				person1.RegisterChangeOfAddress(new DateTime(2005, 4, 15), address1);
				person1.RegisterChangeOfAddress(new DateTime(2007, 5, 29), address2);
				
				s.Save(person1);
				s.Flush();
				
				id = person1.Id;
			}
			
			using (ISession s = OpenSession())
			{
				var person1 = s.Load<Person>(id);
				person1.RegisterChangeOfAddress(new DateTime(2008, 3, 23), new Address("8", "SS7 1TT"));
				s.Save(person1);
				s.Flush();
			}
		}
Esempio n. 6
0
        public async Task CreateProviderAsync(ProviderDto provider, Phone phone, Address address)
        {
            try
            {
                var dbPhone = await CreatePhone(phone);
                var addressId = await CreateAddress(address);
                var user = await DbContext.GetUserByEmailAsync(provider.Email);
                var dbProvider = new Provider
                {
                    DateOfBirth = provider.DateOfBirth,
                    Specialty = provider.Specialty,
                    Sex = provider.Sex,
                    LicenseNumber = provider.LicenseNumber,
                    AddressId = addressId,
                    Address = address,
                    Phone = new List<Phone> { dbPhone },
                    User = user,
                    UserId = user?.Id,
                };

                await DbContext.CreateProviderAsync(dbProvider);
            }
            catch (DbEntityValidationException ex)
            {

            }
        }
 public void Unsubscribe(Type eventType, Address publisherAddress)
 {
     using (var channel = ConnectionManager.GetAdministrationConnection().CreateModel())
     {
         RoutingTopology.TeardownSubscription(channel, eventType, EndpointQueueName);
     }
 }
        public PayExAddress(string orderRef)
        {
            OrderRef = orderRef;

            BillingAddress = new Address();
            ShippingAddress = new Address();
        }
Esempio n. 9
0
        /// <summary>
        /// Gets or sets the <see cref="IEnumerable{Join}"/> with the specified address.
        /// </summary>
        /// <param name="address">The address.</param>
        /// <returns>IEnumerable&lt;Join&gt;.</returns>
        public IEnumerable<Join> this[Address address]
        {
            get
            {
                List<Join> value;
                if (_joins.TryGetValue(address, out value))
                {
                    return value;
                }
                else
                {
                    return CreateEmptyJoinList();
                }
            }
            set
            {
                List<Join> matchingJoins;
                if (!_joins.TryGetValue(address, out matchingJoins))
                {
                    matchingJoins = new List<Join>();
                    _joins[address] = matchingJoins;
                }

                matchingJoins.AddRange(value);
            }
        }
Esempio n. 10
0
        public PyBuildValueFormatParser(
            Program program,
            Address addrInstr,
            string format,
            IServiceProvider services)
        {
            this.ArgumentTypes = new List<DataType>();
            this.format = format;
            var platform = program.Platform;
            this.pointerSize = platform.PointerType.Size;

            var wordSize = platform.Architecture.WordWidth.Size;
            var longSize = platform.GetByteSizeFromCBasicType(
                CBasicType.Long);
            var longLongSize = platform.GetByteSizeFromCBasicType(
                CBasicType.LongLong);
            var doubleSize = platform.GetByteSizeFromCBasicType(
                CBasicType.Double);

            dtInt = Integer(wordSize);
            dtUInt = UInteger(wordSize);
            dtLong = Integer(longSize);
            dtULong = UInteger(longSize);
            dtLongLong = Integer(longLongSize);
            dtULongLong = UInteger(longLongSize);
            dtDouble = Real(doubleSize);
            ptrChar = Ptr(PrimitiveType.Char);
            ptrVoid = Ptr(VoidType.Instance);

            dtPySize = UInteger(pointerSize);
            ptrPyObject = Ptr(Ref("PyObject"));
            ptrPyUnicode = Ptr(Ref("Py_UNICODE"));
            ptrPyComplex = Ptr(Ref("Py_complex"));
            ptrPyConverter = Ptr(new CodeType());
        }
Esempio n. 11
0
        public IEnumerable<Address> RetrieveByCustomerId(int customerId)
        {
            var addressList = new List<Address>();

            var address = new Address(1)
            {
                AddressType = 1,
                StreetLine1 = "Bad End",
                StreetLine2 = "Bagshot row",
                City = "Hobbiton",
                State = "Shire",
                Country = "Middle Earth",
                PostalCode = "144"
            };
            addressList.Add(address);

            address = new Address(2)
            {
                AddressType = 2,
                StreetLine1 = "Green Dragon",
                City = "Bywater",
                State = "Shire",
                Country = "Middle Earth",
                PostalCode = "144"
            };

            addressList.Add(address);

            return addressList;
        }
    /// <summary>
    /// Constructor
    /// </summary>
    public CreateJoinForm(Peer peerObject, Address addressObject, ConnectWizard connectionWizard)
    {
        //
        // Required for Windows Form Designer support
        //
        InitializeComponent();
        peer = peerObject;
        this.connectionWizard = connectionWizard;
        this.Text = connectionWizard.SampleName + " - " + this.Text;
        deviceAddress = addressObject;

        //Set up the event handlers
        peer.FindHostResponse += new FindHostResponseEventHandler(FindHostResponseMessage);
        peer.ConnectComplete += new ConnectCompleteEventHandler(ConnectResult);
        peer.AsyncOperationComplete += new AsyncOperationCompleteEventHandler(CancelAsync);

        //Set up our timer
        updateListTimer = new System.Timers.Timer(300); // A 300 ms interval
        updateListTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.UpdateTimer);
        updateListTimer.SynchronizingObject = this;
        updateListTimer.Start();
        //Set up our connect timer
        connectTimer = new System.Timers.Timer(100); // A 100ms interval
        connectTimer.Elapsed += new System.Timers.ElapsedEventHandler(this.ConnectTimer);
        connectTimer.SynchronizingObject = this;
        // Set up our connect event
        connectEvent = new ManualResetEvent(false);
    }
Esempio n. 13
0
        static void Main(string[] args)
        {
            using (ShopContext ctx = new ShopContext())
            {
                Address a = new Address
                {
                    AddressLine1 = "Somewhere 1",
                    AddressLine2 = "At some floor",
                    City = "SomeCity",
                    ZipCode = "1111AA"
                };

                Customer c = new Customer()
                {
                    FirstName = "Willamar",
                    LastName = "Fernandes",
                    BillingAddress = a,
                    ShippingAddress = a
                };

                ctx.Customers.Add(c);
                ctx.SaveChanges();
            }

        }
Esempio n. 14
0
        // Precondition:  None
        // Postcondition: Small list of Parcels is created and displayed
        static void Main(string[] args)
        {
            Address a1 = new Address("John Smith", "123 Any St.", "Apt. 45",
                "Louisville", "KY", 40202); // Test Address 1
            Address a2 = new Address("Jane Doe", "987 Main St.", "",
                "Beverly Hills", "CA", 90210); // Test Address 2
            Address a3 = new Address("James Kirk", "654 Roddenberry Way", "Suite 321",
                "El Paso", "TX", 79901); // Test Address 3
            Address a4 = new Address("John Crichton", "678 Pau Place", "Apt. 7",
                "Portland", "ME", 04101); // Test Address 4

            Letter l1 = new Letter(a1, a3, 1.50M); // Test Letter 1
            Letter l2 = new Letter(a2, a4, 1.25M); // Test Letter 2
            Letter l3 = new Letter(a4, a1, 1.75M); // Test Letter 3

            List<Parcel> parcels = new List<Parcel>(); // Test list of parcels

            // Add test data to list
            parcels.Add(l1);
            parcels.Add(l2);
            parcels.Add(l3);

            // Display data
            Console.WriteLine("Program 0 - List of Parcels\n\n");

            foreach (Parcel p in parcels)
            {
                Console.WriteLine(p);
                Console.WriteLine("--------------------");
            }
        }
Esempio n. 15
0
 protected AddressOperand(Address a, PrimitiveType type)
     : base(type)
 {
     if (a == null)
         throw new ArgumentNullException("a");
     Address = a;
 }
        public async Task<ActionResult> Register() {

            var pcats = CURTAPI.GetParentCategoriesAsync();
            await Task.WhenAll(new Task[] { pcats });
            ViewBag.parent_cats = await pcats;

            List<Country> countries = UDF.GetCountries();

            Customer cust = new Customer();
            Address billing = new Address();
            Address shipping = new Address();
            bool same = true;
            try {
                cust = (Customer)TempData["customer"];
                billing = (Address)TempData["billing"];
                shipping = (Address)TempData["customer"];
                same = (bool)TempData["same"];
            } catch (Exception) { }

            ViewBag.cust = cust;
            ViewBag.billing = billing;
            ViewBag.shipping = shipping;
            ViewBag.same = same;
            ViewBag.countries = countries;
            ViewBag.error = TempData["error"];
            return View();
        }
Esempio n. 17
0
        static void Main(string[] args)
        {
            /*
             * Rules
             *
             * External entities are only mapped one way (either to or from)
             * Data entities are mapped both ways
             **/

            AutoMapper.Mapper.AddProfile<MapperProfile>();

            // External Entites
            var addressExternalEntity = new AddressExternalEntity { Id = 1, Line1 = "Line1", Line2 = "Line2", Line3 = "Line3" };
            AutoMapper.Mapper.Map<AddressExternalEntity, Address>(addressExternalEntity);

            var personExternalEntity = new PersonExternalEntity {Id = 10, Name = "Bob"};
            AutoMapper.Mapper.Map<PersonExternalEntity, Person>(personExternalEntity);

            var personStatusResponse = new PersonStatusResponse {PersonId = 324};
            AutoMapper.Mapper.Map<PersonStatusResponse, PersonStatusResponseExternalEntity>(personStatusResponse);

            // Data Entities
            var address = new Address { Id = 1, Line1 = "Line1", Line2 = "Line2", Line3 = "Line3" };
            var addressDataEntity = AutoMapper.Mapper.Map<Address, AddressDataEntity>(address);
            address = AutoMapper.Mapper.Map<AddressDataEntity, Address>(addressDataEntity);

            var person = new Person { Id = 10, Name = "Bob" };
            var personDataEntity = AutoMapper.Mapper.Map<Person, PersonDataEntity>(person);
            person = AutoMapper.Mapper.Map<PersonDataEntity, Person>(personDataEntity);

            Console.ReadKey();
        }
Esempio n. 18
0
 public Person()
 {
     Adresse = new Address();
     Telefon = new PhoneNumber();
     Rights = new Rights();
     ID = Guid.NewGuid();
 }
Esempio n. 19
0
 public Cmd_EditSignature(IServiceProvider services, Program program, Procedure procedure, Address addr)
     : base(services)
 {
     this.program = program;
     this.procedure = procedure;
     this.address = addr;
 }
Esempio n. 20
0
        public static void SetGeographicalLocation(Address address)
        {
            Contract.Requires(address != null);
            var rooturl = "http://maps.google.com/maps/api/geocode/xml?address=";
            var tailurl = "&sensor=false";
            var appendedString = new StringBuilder();
            if (!string.IsNullOrWhiteSpace(address.StreetAddress))
            {
                appendedString.Append(address.StreetAddress.Trim().Replace("  ", " ").Replace(" ", "+"));
            }
            CleanAndAppendAddressPart(appendedString, address.Suburb);
            CleanAndAppendAddressPart(appendedString, address.City);
            CleanAndAppendAddressPart(appendedString, address.Provence);
            CleanAndAppendAddressPart(appendedString, address.PostCode);
            CleanAndAppendAddressPart(appendedString, address.Country);

            appendedString.Insert(0, rooturl);
            appendedString.Append(tailurl);
            var url = appendedString.ToString();
            var xmldata = XDocument.Load(url);
            var response = xmldata.Element("GeocodeResponse");
            if (response.Element("status").Value.ToUpperInvariant() != "OK")
                return;
            var location = response.Element("result").Element("geometry").Element("location");

            var latitude = decimal.Parse(location.Element("lat").Value);
            var longitude = decimal.Parse(location.Element("lng").Value);
            address.AddEstimatedGeoLocation(latitude, longitude);
            //$lat = $xmldata.GeocodeResponse.result.geometry.location.lat
            //$lng = $xmldata.GeocodeResponse.result.geometry.location.lng
            //return @{ "Lat" = $lat; "Long" = $lng; "StreetAddress" = $StreetAddress; "City" = $City; "State" = $State; "Zip" = $Zip}
        }
Esempio n. 21
0
        protected void RunTest(string sourceFile, string outputFile, Address addrBase)
        {
            Program program;
            using (var rdr = new StreamReader(FileUnitTester.MapTestPath(sourceFile)))
            {
                program = asm.Assemble(addrBase, rdr);
            }
            foreach (var item in asm.ImportReferences)
            {
                program.ImportReferences.Add(item.Key, item.Value);
            }

            using (FileUnitTester fut = new FileUnitTester(outputFile))
            {
                Dumper dumper = new Dumper(program.Architecture);
                dumper.ShowAddresses = true;
                dumper.ShowCodeBytes = true;
                dumper.DumpData(program.Image, program.Image.BaseAddress, program.Image.Length, fut.TextWriter);
                fut.TextWriter.WriteLine();
                dumper.DumpAssembler(program.Image, program.Image.BaseAddress, program.Image.BaseAddress + (uint)program.Image.Length, fut.TextWriter);
                if (program.ImportReferences.Count > 0)
                {
                    foreach (var de in program.ImportReferences.OrderBy(d => d.Key))
                    {
                        fut.TextWriter.WriteLine("{0:X8}: {1}", de.Key, de.Value);
                    }
                }
                fut.AssertFilesEqual();
            }
        }
Esempio n. 22
0
		private void AddExportedEntryPoints(Address addrLoad, ImageMap imageMap, List<EntryPoint> entryPoints)
		{
			ImageReader rdr = imgLoaded.CreateLeReader(rvaExportTable);
			rdr.ReadLeUInt32();	// Characteristics
			rdr.ReadLeUInt32(); // timestamp
			rdr.ReadLeUInt32();	// version.
			rdr.ReadLeUInt32();	// binary name.
			rdr.ReadLeUInt32();	// base ordinal
			int nExports = rdr.ReadLeInt32();
			int nNames = rdr.ReadLeInt32();
			if (nExports != nNames)
				throw new BadImageFormatException("Unexpected discrepancy in PE image.");
			uint rvaApfn = rdr.ReadLeUInt32();
			uint rvaNames = rdr.ReadLeUInt32();

			ImageReader rdrAddrs = imgLoaded.CreateLeReader(rvaApfn);
			ImageReader rdrNames = imgLoaded.CreateLeReader(rvaNames);
			for (int i = 0; i < nNames; ++i)
			{
                EntryPoint ep = LoadEntryPoint(addrLoad, rdrAddrs, rdrNames);
				if (imageMap.IsExecutableAddress(ep.Address))
				{
					entryPoints.Add(ep);
				}
			}
		}
 /// <summary>
 /// Create a new CustomerBlob object.
 /// </summary>
 /// <param name="ID">Initial value of ID.</param>
 /// <param name="address">Initial value of Address.</param>
 public static CustomerBlob CreateCustomerBlob(int ID, Address address)
 {
     CustomerBlob customer = new CustomerBlob();
     customer.ID = ID;
     customer.Address = global::System.Data.Objects.DataClasses.StructuralObject.VerifyComplexObjectIsNotNull(address, "Address");
     return customer;
 }
Esempio n. 24
0
        public void Create(Address? address, int peerLimit, int channelLimit, uint incomingBandwidth, uint outgoingBandwidth)
        {
            if (_host != null)
            {
                throw new InvalidOperationException("Already created.");
            }
            if (peerLimit < 0 || peerLimit > Native.ENET_PROTOCOL_MAXIMUM_PEER_ID)
            {
                throw new ArgumentOutOfRangeException("peerLimit");
            }
            CheckChannelLimit(channelLimit);

            if (address != null)
            {
                var nativeAddress = address.Value.NativeData;
                _host = Native.enet_host_create(ref nativeAddress, (IntPtr) peerLimit,
                                                (IntPtr) channelLimit, incomingBandwidth, outgoingBandwidth);
            }
            else
            {
                _host = Native.enet_host_create(null, (IntPtr) peerLimit,
                                                (IntPtr) channelLimit, incomingBandwidth, outgoingBandwidth);
            }
            if (_host == null)
            {
                throw new ENetException(0, "Host creation call failed.");
            }
        }
 public void CreateQueueIfNecessary(Address address, string account)
 {
     foreach (var creator in queueCreators)
     {
         creator.RegisterProjectionsFor(address, account);
     }
 }
Esempio n. 26
0
 public void PassInPrecreatedAddress_GetsDataCorrectly()
 {
     Address bkAddress = CreateCustomer().Address;
     var vm = new AddressVM(bkAddress);
     var toCopy = new Address {HouseNumber = vm.HouseNumber, AddressBody = vm.AddressBody, Postcode = vm.Postcode, PhoneNumber = vm.PhoneNumber, ProofOfAddressPath = vm.ProofOfAddressPath};
     Assert.IsTrue(toCopy.HasMatchingState(bkAddress));
 }
        public void ShippingEdits(object s, RepeaterCommandEventArgs e)
        {
            Address address = new Address();
              Guid selectedAddress = new Guid(e.CommandArgument.ToString());
              _user = new WebProfile().GetProfile(ddlCustomer.SelectedValue);
              address = _user.AddressCollection.Find(delegate(Address addressToFind) {
            return addressToFind.AddressId == selectedAddress && addressToFind.AddressType == AddressType.ShippingAddress;
              });

              if (address.AddressId != Guid.Empty) {
            if (e.CommandName == "Edit") {
              //Do the edit
              pnlBillingAddresses.Visible = false;
              pnlShippingAddresses.Visible = false;
              pnlEditAddress.Visible = true;
              LoadEditPanel(address);
              tcMyAccount.ActiveTab = tpAddresses;
            }
            if (e.CommandName == "Delete") {
              _user.AddressCollection.Remove(address);
              _user.Save();
              LoadAddresses();
              tcMyAccount.ActiveTab = tpAddresses;
            }
              }
        }
Esempio n. 28
0
    protected void lbBasicAuth_Click(object sender, EventArgs e)
    {
        string merchantId = ConfigurationManager.AppSettings["MerchantID"];
        string account = ConfigurationManager.AppSettings["Account"];
        string sharedSecret = ConfigurationManager.AppSettings["SharedSecret"];

        Merchant merchant = new Merchant(merchantId, account, sharedSecret);
        Order order = new Order("GBP", 999);
        //working
        CreditCard card = new CreditCard("MC", "5425232820001308", "0118", "Phil McCracken", "123", 1);
        //invalid
        //CreditCard card = new CreditCard("MC", "1234123412341234", "0118", "Phil McCracken", "123", 1);
        Address address = new Address("", "", "", "", "", "", "", "");
        PhoneNumbers numbers = new PhoneNumbers("", "", "", "");
        Payer payer = new Payer("Business", "test", "", "Phil", "McCracken", "", address, numbers, "", new ArrayList());

        string timestamp = Common.GenerateTimestamp();

        string autoSettle = "1";

        RealAuthTransactionResponse resp = RealAuthorisation.Auth(merchant, order, card, autoSettle, timestamp);

        lblErrorCode.Text = resp.ResultCode.ToString();
        lblResult.Text = resp.ResultMessage;
    }
 public ContractorAddressChanged(Guid id, DateTime eventTime,string einNumber,Address oldAddress,Address newAddress)
     : base(id, eventTime)
 {
     EinNumber = einNumber;
     OldAddress = oldAddress;
     NewAddress = newAddress;
 }
Esempio n. 30
0
		protected Program RewriteFile(string relativePath, Address addrBase)
		{
            sc = new ServiceContainer();
            var config = new FakeDecompilerConfiguration();
            var eventListener = new FakeDecompilerEventListener();
            sc.AddService<IConfigurationService>(config);
            sc.AddService<DecompilerHost>(new FakeDecompilerHost());
            sc.AddService<DecompilerEventListener>(eventListener);
            sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
            ILoader ldr = new Loader(sc);
            var program = ldr.AssembleExecutable(
                FileUnitTester.MapTestPath(relativePath),
                new X86TextAssembler(sc, new X86ArchitectureReal()),
                addrBase);
            program.Platform = new DefaultPlatform(sc, program.Architecture);
            var ep = new ImageSymbol(program.SegmentMap.BaseAddress);
            var project = new Project { Programs = { program } };
            var scan = new Scanner(
                program,
                new ImportResolver(project, program, eventListener),
                sc);
			scan.EnqueueImageSymbol(ep, true);
			scan.ScanImage();

            var importResolver = new ImportResolver(project, program, eventListener);
            var dfa = new DataFlowAnalysis(program, importResolver, eventListener);
			dfa.AnalyzeProgram();
            return program;
		}
Esempio n. 31
0
 public bool TryParseAddress(string txtAddress, out Address addr)
 {
     return(Address.TryParse32(txtAddress, out addr));
 }
Esempio n. 32
0
        public void Bwslc_Slices()
        {
            // This test is derived from a m68k binary which originally looked like this:

            //  cmpi.b #$17,d0
            //  bhi $0010F010
            //
            //  moveq #$00,d1
            //  move.b d0,d1
            //  add.w d1,d1
            //  move.w (06,pc,d1),d1
            //  jmp.l (pc,d1)

            // The code introduces a lot of SLICEs, which must be dealt with appropriately.

            var W8  = PrimitiveType.Byte;
            var W16 = PrimitiveType.Word16;
            var W32 = PrimitiveType.Word32;
            var I16 = PrimitiveType.Int16;
            var I32 = PrimitiveType.Int32;

            arch = new Reko.Arch.M68k.M68kArchitecture(sc, "m68k");
            var d0    = Reg("d0");
            var d1    = Reg("d1");
            var v2    = binder.CreateTemporary("v2", W8);
            var v3    = binder.CreateTemporary("v3", W8);
            var v4    = binder.CreateTemporary("v4", W16);
            var v5    = binder.CreateTemporary("v5", PrimitiveType.Word16);
            var CVZNX = Cc("CVZNX");
            var CVZN  = Cc("CVZN");
            var CZ    = Cc("CZ");

            var b = Given_Block(0x00100000);

            Given_Instrs(b, m =>
            {
                m.Assign(v2, m.ISub(m.Slice(PrimitiveType.Byte, d0, 0), 0x17));
                m.Assign(CVZN, m.Cond(v2));
            });
            Given_Instrs(b, m =>
            {
                m.Branch(m.Test(ConditionCode.UGT, CZ), Address.Ptr32(0x00100040), InstrClass.ConditionalTransfer);
            });

            var b2 = Given_Block(0x00100008);

            Given_Instrs(b2, m => {
                m.Assign(d1, m.Word32(0));
                m.Assign(CVZN, m.Cond(d1));
            });
            Given_Instrs(b2, m =>
            {
                m.Assign(v3, m.Slice(v3.DataType, d0, 0));
                m.Assign(d1, m.Dpb(d1, v3, 0));
                m.Assign(CVZN, m.Cond(v3));
            });
            Given_Instrs(b2, m =>
            {
                m.Assign(v4, m.IAdd(m.Slice(v4.DataType, d1, 0), m.Slice(v4.DataType, d1, 0)));
                m.Assign(d1, m.Dpb(d1, v4, 0));
                m.Assign(CVZNX, m.Cond(v4));
            });
            Given_Instrs(b2, m =>
            {
                m.Assign(v5, m.Mem16(m.IAdd(m.Word32(0x0010EC32), m.Convert(m.Slice(W16, d1, 0), W16, W32))));
                m.Assign(d1, m.Dpb(d1, v5, 0));
                m.Assign(CVZN, m.Cond(v5));
            });
            Given_Instrs(b2, m => {
                m.Goto(m.IAdd(m.Word32(0x0010EC30), m.Convert(m.Slice(I16, d1, 0), I16, I32)));
            });

            graph.Nodes.Add(b);
            graph.Nodes.Add(b2);
            graph.AddEdge(b, b2);

            var bwslc = new BackwardSlicer(host, b2, processorState);

            Assert.IsTrue(bwslc.Start(b2, 10, Target(b2)));
            while (bwslc.Step())
            {
                ;
            }
            Assert.AreEqual(2, bwslc.Live.Count);
            Console.WriteLine(bwslc.JumpTableFormat.ToString());
            Assert.AreEqual("CONVERT(Mem0[CONVERT(SLICE(SEQ(d1, d0) * 2<32>, word16, 0), word16, word32) + 0x10EC32<32>:word16], word16, int32) + 0x10EC30<32>", bwslc.JumpTableFormat.ToString());
            Assert.AreEqual("d0", bwslc.JumpTableIndex.ToString());
            Assert.AreEqual("SLICE(d0, byte, 0)", bwslc.JumpTableIndexToUse.ToString(), "Expression to use when indexing");
            Assert.AreEqual("1[0,17]", bwslc.JumpTableIndexInterval.ToString());
        }
Esempio n. 33
0
        public void Bwslc_RepMovsd()
        {
            // Original i386 code:
            // shr ecx,02
            // and edx,03
            // cmp ecx,08
            // jc 00002000
            // rep movsd
            // jmp dword ptr[007862E8 + edx * 4]

            arch = new Reko.Arch.X86.X86ArchitectureReal(sc, "x86-real-16");
            var ecx  = binder.EnsureRegister(arch.GetRegister("ecx"));
            var edx  = binder.EnsureRegister(arch.GetRegister("edx"));
            var esi  = binder.EnsureRegister(arch.GetRegister("esi"));
            var edi  = binder.EnsureRegister(arch.GetRegister("edi"));
            var C    = binder.EnsureFlagGroup(arch.GetFlagGroup("C"));
            var SZO  = binder.EnsureFlagGroup(arch.GetFlagGroup("SZO"));
            var SCZO = binder.EnsureFlagGroup(arch.GetFlagGroup("SCZO"));
            var tmp  = binder.CreateTemporary(ecx.DataType);

            var b = Given_Block(0x1000);

            Given_Instrs(b, m => { m.Assign(ecx, m.Shr(ecx, 2)); m.Assign(SCZO, m.Cond(ecx)); });
            Given_Instrs(b, m => { m.Assign(edx, m.And(edx, 3)); m.Assign(SZO, m.Cond(edx)); m.Assign(C, Constant.False()); });
            Given_Instrs(b, m => { m.Assign(SCZO, m.Cond(m.ISub(ecx, 8))); });
            Given_Instrs(b, m => { m.Branch(m.Test(ConditionCode.ULT, C), Address.Ptr32(0x2000), InstrClass.ConditionalTransfer); });

            var b2 = Given_Block(0x1008);

            Given_Instrs(b2, m => {
                m.BranchInMiddleOfInstruction(m.Eq0(ecx), Address.Ptr32(0x1010), InstrClass.ConditionalTransfer);
                m.Assign(tmp, m.Mem32(esi));
                m.Assign(m.Mem32(edi), tmp);
                m.Assign(esi, m.IAdd(esi, 4));
                m.Assign(edi, m.IAdd(edi, 4));
                m.Assign(ecx, m.ISub(ecx, 1));
                m.Goto(Address.Ptr32(0x1008));
            });

            var b3 = Given_Block(0x1010);

            Given_Instrs(b3, m => {
                m.Goto(m.Mem32(m.IAdd(m.IMul(edx, 4), 0x00123400)));
            });

            graph.Nodes.Add(b);
            graph.Nodes.Add(b2);
            graph.Nodes.Add(b3);
            graph.AddEdge(b, b2);
            graph.AddEdge(b2, b3);
            graph.AddEdge(b2, b2);

            var bwslc = new BackwardSlicer(host, b3, processorState);

            Assert.IsTrue(bwslc.Start(b3, -1, Target(b3)));   // indirect jump
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.IsTrue(bwslc.Step());
            Assert.False(bwslc.Step());     // edx &= 3
            Assert.AreEqual("Mem0[(edx & 3<32>) * 4<32> + 0x123400<32>:word32]", bwslc.JumpTableFormat.ToString());
            Assert.AreEqual("1[0,3]", bwslc.JumpTableIndexInterval.ToString());
        }
Esempio n. 34
0
 public CombinationSlotState(Address address, int unlockStage) : base(address)
 {
     UnlockStage = unlockStage;
 }
Esempio n. 35
0
 public override void SetInstructionPointer(Address addr)
 {
 }
Esempio n. 36
0
 public bool TryRead(MemoryArea mem, Address addr, PrimitiveType dt, out Constant value)
 {
     return(mem.TryReadLe(addr, dt, out value));
 }
Esempio n. 37
0
 public Address MakeSegmentedAddress(Constant seg, Constant offset)
 {
     return(Address.SegPtr(seg.ToUInt16(), offset.ToUInt16()));
 }
Esempio n. 38
0
 public List <RtlInstruction> InlineCall(Address addr, Address addrContinuation, EndianImageReader rdr, IStorageBinder binder)
 {
     return(null);
 }
Esempio n. 39
0
 public EndianImageReader CreateImageReader(MemoryArea image, Address addrBegin, Address addrEnd)
 {
     return(new LeImageReader(image, addrBegin, addrEnd));
 }
Esempio n. 40
0
 public Address MakeAddressFromConstant(Constant c)
 {
     return(Address.Ptr32(c.ToUInt32()));
 }
Esempio n. 41
0
        internal static Address LocalAddressForRemote(
            IDictionary<string, HashSet<ProtocolTransportAddressPair>> transportMapping, Address remote)
        {
            HashSet<ProtocolTransportAddressPair> transports;

            if (transportMapping.TryGetValue(remote.Protocol, out transports))
            {
                ProtocolTransportAddressPair[] responsibleTransports =
                    transports.Where(t => t.ProtocolTransport.IsResponsibleFor(remote)).ToArray();
                if (responsibleTransports.Length == 0)
                {
                    throw new RemoteTransportException(
                        "No transport is responsible for address:[" + remote + "] although protocol [" + remote.Protocol +
                        "] is available." +
                        " Make sure at least one transport is configured to be responsible for the address.",
                        null);
                }
                if (responsibleTransports.Length == 1)
                {
                    return responsibleTransports.First().Address;
                }
                throw new RemoteTransportException(
                    "Multiple transports are available for [" + remote + ": " +
                    string.Join(",", responsibleTransports.Select(t => t.ToString())) + "] " +
                    "Remoting cannot decide which transport to use to reach the remote system. Change your configuration " +
                    "so that only one transport is responsible for the address.",
                    null);
            }

            throw new RemoteTransportException(
                "No transport is loaded for protocol: [" + remote.Protocol + "], available protocols: [" +
                string.Join(",", transportMapping.Keys.Select(t => t.ToString())) + "]", null);
        }
Esempio n. 42
0
 public ImageWriter CreateImageWriter(MemoryArea mem, Address addr)
 {
     return(new LeImageWriter(mem, addr));
 }
Esempio n. 43
0
        /// <summary>
        /// Start assumes that it cannot be followed by another Start() without having a Shutdown() first
        /// </summary>
        public override void Start()
        {
            if (_endpointManager == null)
            {
                _log.Info("Starting remoting");
                _endpointManager =
                System.SystemActorOf(RARP.For(System).ConfigureDispatcher(
                    Props.Create(() => new EndpointManager(System.Settings.Config, _log)).WithDeploy(Deploy.Local)),
                    EndpointManagerName);

                try
                {
                    var addressPromise = new TaskCompletionSource<IList<ProtocolTransportAddressPair>>();

                    // tells the EndpointManager to start all transports and bind them to listenable addresses, and then set the results
                    // of this promise to include them.
                    _endpointManager.Tell(new EndpointManager.Listen(addressPromise)); 

                    addressPromise.Task.Wait(Provider.RemoteSettings.StartupTimeout);
                    var akkaProtocolTransports = addressPromise.Task.Result;
                    if(akkaProtocolTransports.Count==0)
                        throw new ConfigurationException(@"No transports enabled under ""akka.remote.enabled-transports""");
                    _addresses = new HashSet<Address>(akkaProtocolTransports.Select(a => a.Address));

                    IEnumerable<IGrouping<string, ProtocolTransportAddressPair>> tmp =
                        akkaProtocolTransports.GroupBy(t => t.ProtocolTransport.SchemeIdentifier);
                    _transportMapping = new Dictionary<string, HashSet<ProtocolTransportAddressPair>>();
                    foreach (var g in tmp)
                    {
                        var set = new HashSet<ProtocolTransportAddressPair>(g);
                        _transportMapping.Add(g.Key, set);
                    }

                    _defaultAddress = akkaProtocolTransports.Head().Address;
                    _addresses = new HashSet<Address>(akkaProtocolTransports.Select(x => x.Address));

                    _log.Info("Remoting started; listening on addresses : [{0}]", string.Join(",", _addresses.Select(x => x.ToString())));

                    _endpointManager.Tell(new EndpointManager.StartupFinished());
                    _eventPublisher.NotifyListeners(new RemotingListenEvent(_addresses.ToList()));

                }
                catch (TaskCanceledException ex)
                {
                    NotifyError("Startup was cancelled due to timeout", ex);
                    throw;
                }
                catch (TimeoutException ex)
                {
                    NotifyError("Startup timed out", ex);
                    throw;
                }
                catch (Exception ex)
                {
                    NotifyError("Startup failed", ex);
                    throw;
                }
            }
            else
            {
                _log.Warning("Remoting was already started. Ignoring start attempt.");
            }
        }
Esempio n. 44
0
 /// <summary>
 /// URL-encodes an actor <see cref="Address"/>. Used when generating the names
 /// of some system remote actors.
 /// </summary>
 public static string Encode(Address address)
 {
     return HttpUtility.UrlEncode(address.ToString(), Encoding.UTF8);
 }
Esempio n. 45
0
 public ProtocolTransportAddressPair(AkkaProtocolTransport protocolTransport, Address address)
 {
     ProtocolTransport = protocolTransport;
     Address           = address;
 }
Esempio n. 46
0
 public override Address LocalAddressForRemote(Address remote)
 {
     return Remoting.LocalAddressForRemote(_transportMapping, remote);
 }
Esempio n. 47
0
 public AssociateUnderlyingRefuseUid(Address remoteAddress, TaskCompletionSource <AssociationHandle> statusCompletionSource, int?refuseUid = null)
 {
     RefuseUid = refuseUid;
     StatusCompletionSource = statusCompletionSource;
     RemoteAddress          = remoteAddress;
 }
Esempio n. 48
0
 public OutboundUnassociated(Address remoteAddress, TaskCompletionSource <AssociationHandle> statusCompletionSource, Transport transport)
 {
     Transport = transport;
     StatusCompletionSource = statusCompletionSource;
     RemoteAddress          = remoteAddress;
 }
Esempio n. 49
0
 /// <summary>
 /// <see cref="Props"/> used when creating OUTBOUND associations to remote endpoints.
 ///
 /// These <see cref="Props"/> create outbound <see cref="ProtocolStateActor"/> instances,
 /// which begin a state of
 /// </summary>
 /// <param name="handshakeInfo"></param>
 /// <param name="remoteAddress"></param>
 /// <param name="statusCompletionSource"></param>
 /// <param name="transport"></param>
 /// <param name="settings"></param>
 /// <param name="codec"></param>
 /// <param name="failureDetector"></param>
 /// <param name="refuseUid"></param>
 /// <returns></returns>
 public static Props OutboundProps(HandshakeInfo handshakeInfo, Address remoteAddress,
                                   TaskCompletionSource <AssociationHandle> statusCompletionSource,
                                   Transport transport, AkkaProtocolSettings settings, AkkaPduCodec codec, FailureDetector failureDetector, int?refuseUid = null)
 {
     return(Props.Create(() => new ProtocolStateActor(handshakeInfo, remoteAddress, statusCompletionSource, transport, settings, codec, failureDetector, refuseUid)));
 }
Esempio n. 50
0
 public HandshakeInfo(Address origin, int uid)
 {
     Origin = origin;
     Uid    = uid;
 }
Esempio n. 51
0
 public override RelocationResults Relocate(Program program, Address addrLoad)
 {
     return(new RelocationResults(new List <ImageSymbol>(), new SortedList <Address, ImageSymbol>()));
 }
Esempio n. 52
0
 private string ActorNameFor(Address remoteAddress)
 {
     return(string.Format("akkaProtocol-{0}-{1}", AddressUrlEncoder.Encode(remoteAddress), NextId()));
 }
Esempio n. 53
0
 protected override void SetState(IDictionary <string, object> state)
 {
     this.LastCreatedAddress = state.Get <Address>("LastCreatedAddress");
     base.SetState(state);
 }
Esempio n. 54
0
 protected override void LoadPlainValueInternal(IImmutableDictionary <string, IValue> plainValue)
 {
     productId           = plainValue["productId"].ToGuid();
     sellerAvatarAddress = plainValue["sellerAvatarAddress"].ToAddress();
 }
Esempio n. 55
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="listenAddress">TBD</param>
 /// <param name="upstreamListener">TBD</param>
 public ListenUnderlying(Address listenAddress, Task <IAssociationEventListener> upstreamListener)
 {
     UpstreamListener = upstreamListener;
     ListenAddress    = listenAddress;
 }
Esempio n. 56
0
 public XbeSection(XbeSectionHeader hdr)
 {
     SectionHeader  = hdr;
     VirtualAddress = Address.Ptr32(SectionHeader.VirtualAddress);
     NameAddress    = Address.Ptr32(SectionHeader.SectionNameAddress);
 }
Esempio n. 57
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="remote">TBD</param>
 /// <returns>TBD</returns>
 public override bool IsResponsibleFor(Address remote)
 {
     return(WrappedTransport.IsResponsibleFor(remote));
 }
Esempio n. 58
0
 /// <inheritdoc/>
 protected override void InterceptAssociate(Address remoteAddress, TaskCompletionSource <AssociationHandle> statusPromise)
 {
     manager.Tell(new AssociateUnderlying(remoteAddress, statusPromise));
 }
Esempio n. 59
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="remoteAddress">TBD</param>
 /// <param name="statusPromise">TBD</param>
 protected abstract void InterceptAssociate(Address remoteAddress,
                                            TaskCompletionSource <AssociationHandle> statusPromise);
Esempio n. 60
0
 /// <summary>
 /// TBD
 /// </summary>
 /// <param name="remoteAddress">TBD</param>
 /// <param name="statusPromise">TBD</param>
 public AssociateUnderlying(Address remoteAddress, TaskCompletionSource <AssociationHandle> statusPromise)
 {
     RemoteAddress = remoteAddress;
     StatusPromise = statusPromise;
 }