public void SaveAll()
        {
            AdoEFUOW.ADoEFUow o = new AdoEFUOW.ADoEFUow();

            o.CustomerDal = CustomerDal;
            o.AddressDal  = AddressDal;
            o.PhoneDal    = PhoneDal;
            CustomerBase y = Factory <CustomerBase> .Create(cust.Type);

            y.Id           = cust.Id;
            y.CustomerName = cust.CustomerName;
            y.PhoneNumber  = cust.PhoneNumber;
            y.Address      = cust.Address;
            y.BillAmount   = cust.BillAmount;
            y.BillDate     = cust.BillDate;
            CustomerDal.AddInMemory(y);

            foreach (AddressPhone a in cust.Addresses)
            {
                AddressBase a1 = Factory <AddressBase> .Create("Address");

                a1.Address1 = a.Address1;
                AddressDal.AddInMemory((AddressBase)a);
                foreach (PhoneBase i in a.Phones)
                {
                    PhoneDal.AddInMemory((PhoneBase)i);
                }
            }
            o.Committ();
        }
Exemple #2
0
            private void ParseStreetType(string street, AddressBase address)
            {
                var matches = _regexCache.Get("streetType").Matches(street);

                switch (matches.Count)
                {
                case 1: {
                    var type = ParseStreetType(matches[0].Value);

                    if (type == StreetType.Highway && address.IsHighway)
                    {
                        break;
                    }

                    address.StreetType = type;

                    Street = Street.Remove(matches[0].Index, matches[0].Length);

                    break;
                }

                case 2: {
                    //case where address has two street types in the name
                    //5301 W Jacob Hill Cir 84081
                    address.StreetType = ParseStreetType(matches[1].Value);

                    Street = Street.Remove(matches[1].Index, matches[1].Length);

                    break;
                }
                }
            }
Exemple #3
0
        /// <summary>
        ///     Determines if the address is likely a reversal
        ///     case 1: (300 S 437 E) where the street name ends in 2,3,4,6,7,8,9
        ///     case 2: (350 S 435 E) where street name and house number both end in a 0 or 5
        /// </summary>
        /// <param name="address">The address.</param>
        /// <returns>locator_SwitchRoadandHouseNumber</returns>
        private IEnumerable <LocatorDetails> Reversal(AddressBase address)
        {
            if (address.IsReversal() || address.PossibleReversal())
            {
                var locators = new List <LocatorDetails>();

                AddressPermutations.ForEach(stuff => locators.AddRange(new[]
                {
                    new LocatorDetails
                    {
                        Url = string.Format("http://{0}", Host) +
                              string.Format("/arcgis/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                                            "GeocodeServer/findAddressCandidates?f=json&Street={0}&City={1}&outSR={2}",
                                            HttpUtility.UrlEncode(stuff.AddressInfo.ReversalAddress), stuff.Grid, stuff.WkId),
                        Name = "Centerlines.StatewideRoads"
                    },
                    new LocatorDetails
                    {
                        Url = string.Format("http://{0}", Host) +
                              string.Format("/arcgis/rest/services/Geolocators/Roads_AddressSystem_ACSALIAS/" +
                                            "GeocodeServer/findAddressCandidates?f=json&Street={0}&City={1}&outSR={2}",
                                            HttpUtility.UrlEncode(stuff.AddressInfo.ReversalAddress), stuff.Grid, stuff.WkId),
                        Name = "Centerlines.AddressCoordinateAlias"
                    }
                }));

                return(locators);
            }

            return(Enumerable.Empty <LocatorDetails>());
        }
Exemple #4
0
        public PE(DataProviderBase dataProvider, AddressBase addressSpace, ulong address)
        {
            _dataProvider            = dataProvider;
            _imageBaseVirtualAddress = address;
            _kernelAddressSpace      = addressSpace;
            int marker = 0;

            try
            {
                ulong alignedAddress = _imageBaseVirtualAddress & 0xfffffffff000;
                ulong pAddr          = _kernelAddressSpace.vtop(alignedAddress);
                if (pAddr == 0)
                {
                    throw new ArgumentException("Error mapping virtual address 0x" + alignedAddress.ToString("X08"));
                }
                byte[]   buffer       = dataProvider.ReadMemory(pAddr, 1);
                GCHandle pinnedPacket = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                _dosHeader = (IMAGE_DOS_HEADER)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(buffer, marker), typeof(IMAGE_DOS_HEADER));

                _valid  = (_dosHeader.e_magic == 0x5a4d);
                marker += (int)_dosHeader.e_lfanew;
                UInt32 ntHeadersSignature = BitConverter.ToUInt32(buffer, marker);
                if (ntHeadersSignature == 0x4550)
                {
                    marker     += 4;
                    _fileHeader = (IMAGE_FILE_HEADER)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(buffer, marker), typeof(IMAGE_FILE_HEADER));
                    marker     += Marshal.SizeOf(_fileHeader);

                    if (Is32BitHeader)
                    {
                        _optionalHeader32 = (IMAGE_OPTIONAL_HEADER32)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(buffer, marker), typeof(IMAGE_OPTIONAL_HEADER32));
                        marker           += Marshal.SizeOf(_optionalHeader32);
                    }
                    else
                    {
                        _optionalHeader64 = (IMAGE_OPTIONAL_HEADER64)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(buffer, marker), typeof(IMAGE_OPTIONAL_HEADER64));
                        marker           += Marshal.SizeOf(_optionalHeader64);
                    }
                    _imageSectionHeaders = new IMAGE_SECTION_HEADER[_fileHeader.NumberOfSections];
                    for (int headerNo = 0; headerNo < _imageSectionHeaders.Length; ++headerNo)
                    {
                        _imageSectionHeaders[headerNo] = (IMAGE_SECTION_HEADER)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(buffer, marker), typeof(IMAGE_SECTION_HEADER));
                        marker += Marshal.SizeOf(_imageSectionHeaders[0]);
                    }
                    ulong debugVAddr = Is32BitHeader ? _optionalHeader32.Debug.VirtualAddress + _imageBaseVirtualAddress : _optionalHeader64.Debug.VirtualAddress + _imageBaseVirtualAddress;
                    pinnedPacket.Free();
                    pAddr        = _kernelAddressSpace.vtop(debugVAddr, false);
                    buffer       = dataProvider.ReadMemory(pAddr & 0xfffffffff000, 2);
                    pinnedPacket = GCHandle.Alloc(buffer, GCHandleType.Pinned);
                    IMAGE_DEBUG_DIRECTORY idd = (IMAGE_DEBUG_DIRECTORY)Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(buffer, (int)(pAddr & 0xfff)), typeof(IMAGE_DEBUG_DIRECTORY));
                    _debugSectionOffset = idd.AddressOfRawData + _imageBaseVirtualAddress;
                    pinnedPacket.Free();
                }
                else
                {
                    pinnedPacket.Free();
                }
            }
            catch { }
        }
        public void Add(AddressBase obj)
        {
            AddressPhone i = new AddressPhone();

            i.Address1 = obj.Address1;
            cust.Addresses.Add(i);
        }
        protected void gvSavedPickupLocation_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            var gridView = (GridView)sender;

            if (e.Row.RowType == DataControlRowType.Header)
            {
                int cellIndex = -1;
                foreach (DataControlField field in gridView.Columns)
                {
                    e.Row.Cells[gridView.Columns.IndexOf(field)].CssClass = "headerstyle";

                    if (field.SortExpression == gridView.SortExpression)
                    {
                        cellIndex = gridView.Columns.IndexOf(field);
                    }
                }

                if (cellIndex > -1)
                {
                    //  this is a header row,
                    //  set the sort style
                    e.Row.Cells[cellIndex].CssClass =
                        gridView.SortDirection == SortDirection.Ascending
                            ? "sortascheaderstyle"
                            : "sortdescheaderstyle";
                }
            }
            else if (e.Row.RowType == DataControlRowType.DataRow)
            {
                bool   isXML       = true;
                string controlPath = getAddressControlPath(ref isXML);
                pickupLocationBase = createAddress(controlPath, isXML);

                int addressId = Convert.ToInt32(gvSavedPickupLocation.DataKeys[e.Row.RowIndex]["Id"]);

                var q = (from m in pickupLocations.Where(s => s.Id == addressId)
                         select m).First();

                pickupLocationBase.DataContext = q;

                if (getSelectedAddress(addressId).IsPrimary)
                {
                    e.Row.CssClass = "gdo-row-selected gdo-body-text";
                    e.Row.FindControl("Primary").Visible = true;
                }

                e.Row.Cells[3].Controls.Add((Control)pickupLocationBase);

                // Retrieve the LinkButton control from the last column.
                var deleteButton = (LinkButton)e.Row.Cells[4].Controls[3];

                // Set the LinkButton's CommandArgument property with the
                // row's index.
                deleteButton.CommandArgument = e.Row.RowIndex.ToString();

                var trigger1 = new AsyncPostBackTrigger();
                trigger1.ControlID = deleteButton.UniqueID;
                UpdatePanel2.Triggers.Add(trigger1);
            }
        }
Exemple #7
0
        static void Main(string[] args)
        {
            IDataLayer <CustomerBase> dalcust = FactoryDal <CustomerBase> .getDal("EfCustDal");

            IDataLayer <AddressBase> daladd = FactoryDal <AddressBase> .getDal("EfAddDal");

            IDataLayer <PhoneBase> dalphone = FactoryDal <PhoneBase> .getDal("EfPhoneDal");

            Mediator.Mediator obj = new Mediator.Mediator(dalcust, daladd, dalphone);
            CustomerBase      c   = Factory <CustomerBase> .Create("Customer");

            c.CustomerName = "tesy123";
            c.PhoneNumber  = "90909";
            c.BillDate     = Convert.ToDateTime("1/1/2010");
            c.Type         = "Customer";
            c.BillAmount   = 100;
            obj.Add(c);
            AddressBase a = Factory <AddressBase> .Create("Address");

            a.Address1 = "Mulund";
            obj.Add(a);
            PhoneBase p = Factory <PhoneBase> .Create("Phone");

            p.PhoneNumber = "222";
            obj.Add(p, 0);
            obj.SaveAll();
        }
Exemple #8
0
        protected void Overlay(string name)
        {
            string shorterVersion = name.TrimStart(new char[] { '_' });

            _is64          = (_profile.Architecture == "AMD64");
            _addressSpace  = _dataProvider.ActiveAddressSpace;
            _structureSize = (int)_profile.GetStructureSize(name);
            if (_structureSize == -1)
            {
                throw new ArgumentException("Error: Profile didn't contain a definition for " + name);
            }
            if (_virtualAddress == 0)
            {
                _buffer = _dataProvider.ReadPhysicalMemory(_physicalAddress, (uint)_structureSize);
            }
            else
            {
                _physicalAddress = _addressSpace.vtop(_virtualAddress);
                _buffer          = _dataProvider.ReadMemoryBlock(_virtualAddress, (uint)_structureSize);
            }
            if (_buffer == null)
            {
                throw new ArgumentException("Invallid address " + _virtualAddress.ToString("x12"));
            }
            var      dll         = _profile.GetStructureAssembly(name);
            Type     t           = dll.GetType("liveforensics." + shorterVersion);
            GCHandle pinedPacket = GCHandle.Alloc(_buffer, GCHandleType.Pinned);

            _members = Marshal.PtrToStructure(Marshal.UnsafeAddrOfPinnedArrayElement(_buffer, 0), t);
            pinedPacket.Free();
        }
Exemple #9
0
        /// <summary>
        /// You should normally be using the virtual address
        /// But when you do pool scans you'll only have a physical address
        /// So in that case expect a VA=0 and a valid PA
        /// </summary>
        /// <param name="profile"></param>
        /// <param name="dataProvider"></param>
        /// <param name="virtualAddress"></param>
        /// <param name="physicalAddress"></param>
        public ObjectHeader(Profile profile, DataProviderBase dataProvider, ulong virtualAddress = 0, ulong physicalAddress = 0) : base(profile, dataProvider, virtualAddress)
        {
            _physicalAddress = physicalAddress;
            if (virtualAddress == 0 && physicalAddress == 0)
            {
                throw new ArgumentException("Error - Offset is ZERO for _OBJECT_HEADER");
            }
            _is64          = (_profile.Architecture == "AMD64");
            _structureSize = (uint)_profile.GetStructureSize("_OBJECT_HEADER");
            if (_structureSize == -1)
            {
                throw new ArgumentException("Error - Profile didn't contain a definition for _OBJECT_HEADER");
            }
            AddressBase addressSpace = dataProvider.ActiveAddressSpace;

            if (virtualAddress == 0)
            {
                _buffer = _dataProvider.ReadPhysicalMemory(_physicalAddress, (uint)_structureSize);
            }
            else
            {
                _physicalAddress = addressSpace.vtop(_virtualAddress);
                _buffer          = _dataProvider.ReadMemoryBlock(_virtualAddress, (uint)_structureSize);
            }
            //Debug.WriteLine("PADDR: " + _physicalAddress.ToString("X08"));
            Initialise();
        }
Exemple #10
0
        public HeaderNameInfo(Profile profile, DataProviderBase dataProvider, ulong virtualAddress = 0, ulong physicalAddress = 0) : base(profile, dataProvider, virtualAddress)
        {
            _physicalAddress = physicalAddress;
            _is64            = (_profile.Architecture == "AMD64");
            _structureSize   = _profile.GetStructureSize("_OBJECT_HEADER_NAME_INFO");
            if (_structureSize == -1)
            {
                throw new ArgumentException("Error - Profile didn't contain a definition for _OBJECT_HEADER_NAME_INFO");
            }
            AddressBase addressSpace = dataProvider.ActiveAddressSpace;

            if (virtualAddress == 0)
            {
                _buffer = _dataProvider.ReadPhysicalMemory(_physicalAddress, (uint)_structureSize);
            }
            else
            {
                _physicalAddress = addressSpace.vtop(_virtualAddress);
                _buffer          = _dataProvider.ReadMemoryBlock(_virtualAddress, (uint)_structureSize);
            }
            _structure = _profile.GetEntries("_OBJECT_HEADER_NAME_INFO");
            Structure s = GetStructureMember("ReferenceCount");

            _referenceCount = BitConverter.ToUInt32(_buffer, (int)s.Offset);
            s = GetStructureMember("Name");
            if (s.EntryType == "_UNICODE_STRING")
            {
                UnicodeString us = new UnicodeString(_profile, _dataProvider, physicalAddress: _physicalAddress + s.Offset);
                _name = us.Name;
            }
            // TO DO Parse the Directory member of structure
        }
        private IEnumerable <LocatorDetails> Centerlines(AddressBase address)
        {
            var locators = new List <LocatorDetails>();

            if (address.IsReversal())
            {
                AddressPermutations.ForEach(stuff => locators.AddRange(new[]
                {
                    new LocatorDetails
                    {
                        Url = $"http://{Host}/arcgis/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                              $"GeocodeServer/findAddressCandidates?f=json&Street={HttpUtility.UrlEncode(stuff.Address)}" +
                              $"&City={stuff.Grid}&outSR={stuff.WkId}",
                        Name   = "Centerlines.StatewideRoads",
                        Weight = stuff.Weight
                    }
                }));

                return(locators);
            }

            AddressPermutations.ForEach(stuff => locators.AddRange(new[]
            {
                new LocatorDetails
                {
                    Url = $"http://{Host}/arcgis/rest/services/Geolocators/Roads_AddressSystem_STREET/" +
                          $"GeocodeServer/findAddressCandidates?f=json&Street={HttpUtility.UrlEncode(stuff.Address)}" +
                          $"&City={stuff.Grid}&outSR={stuff.WkId}",
                    Name   = "Centerlines.StatewideRoads",
                    Weight = stuff.Weight
                }
            }));

            return(locators);
        }
        public bool IsOneCharacterStreetName(AddressBase address, string candidate)
        {
            // is the street name empty if we remove the direction?
            var candidateRemoved = Street.Remove(Street.IndexOf(candidate, StringComparison.OrdinalIgnoreCase), candidate.Length).Trim();

            return(string.IsNullOrEmpty(candidateRemoved) && string.IsNullOrEmpty(address.StreetName));
        }
Exemple #13
0
        public DriverExtension(Profile profile, DataProviderBase dataProvider, ulong virtualAddress = 0, ulong physicalAddress = 0) : base(profile, dataProvider, virtualAddress)
        {
            _physicalAddress = physicalAddress;
            _is64            = (_profile.Architecture == "AMD64");
            AddressBase addressSpace = dataProvider.ActiveAddressSpace;

            if (virtualAddress != 0)
            {
                _physicalAddress = addressSpace.vtop(_virtualAddress);
            }
            if (_physicalAddress == 0)
            {
                throw new ArgumentException("Error - Address is ZERO for _DRIVER_EXTENSION");
            }
            _structureSize = (uint)_profile.GetStructureSize("_DRIVER_EXTENSION");
            if (_structureSize == -1)
            {
                throw new ArgumentException("Error - Profile didn't contain a definition for _DRIVER_EXTENSION");
            }
            // _physicalAddress = _dataProvider.ActiveAddressSpace.vtop(_virtualAddress, _dataProvider.IsLive);
            if (_virtualAddress == 0)
            {
                _buffer = _dataProvider.ReadPhysicalMemory(_physicalAddress, (uint)_structureSize);
            }
            else
            {
                _buffer = _dataProvider.ReadMemoryBlock(_virtualAddress, (uint)_structureSize);
            }
            _structure = _profile.GetEntries("_DRIVER_EXTENSION");
        }
Exemple #14
0
        protected List <LIST_ENTRY> FindAllLists(DataProviderBase dataProvider, LIST_ENTRY source)
        {
            List <LIST_ENTRY> results      = new List <LIST_ENTRY>();
            List <ulong>      seen         = new List <ulong>();
            List <LIST_ENTRY> stack        = new List <LIST_ENTRY>();
            AddressBase       addressSpace = dataProvider.ActiveAddressSpace;

            stack.Add(source);
            while (stack.Count > 0)
            {
                LIST_ENTRY item = stack[0];
                stack.RemoveAt(0);
                if (!seen.Contains(item.PhysicalAddress))
                {
                    seen.Add(item.PhysicalAddress);
                    results.Add(item);
                    ulong Blink = item.Blink;
                    if (Blink != 0)
                    {
                        ulong refr = addressSpace.vtop(Blink);
                        stack.Add(new LIST_ENTRY(dataProvider, item.Blink));
                    }
                    ulong Flink = item.Flink;
                    if (Flink != 0)
                    {
                        ulong refr = addressSpace.vtop(Flink);
                        stack.Add(new LIST_ENTRY(dataProvider, item.Flink));
                    }
                }
            }
            return(results);
        }
Exemple #15
0
 public void InsertAddressBase()
 {
     using (var context = new UNSModel())
     {
         var y = new AddressBase()
         {
             ID = Guid.NewGuid(), GUID = Guid.NewGuid()
         };
         var y1 = new AddressBase()
         {
             ID   = Guid.NewGuid(),
             GUID = Guid.NewGuid(),
             PREV = new List <AddressBase>()
             {
                 y
             },
             Code = new AddressCode()
             {
                 IFNSFL = "s", OKATO = "x", OKTMO = "z"
             },
             RootStatus = new AddressStatus()
             {
                 LIVESTATUS = true, OPERSTATUS = 1, REGIONCODE = "77"
             }
         };
         context.Set <AddressBase>().Add(y);
         context.Set <AddressBase>().Add(y1);
         context.SaveChanges();
         context.Set <AddressBase>().Remove(y);
         context.Set <AddressBase>().Remove(y1);
         context.SaveChanges();
     }
 }
Exemple #16
0
 public AccountOrderDetailResponse()
 {
     Items         = new List <CartItem>();
     ShippingInfo  = new AddressBase();
     BillingInfo   = new List <string>();
     PaymentMethod = new List <string>();
     Summary       = new CartSummaryBase();
 }
        public void AddDbAddress(Entity.AddressBase address)
        {
            AddressBase result = Utility.EFContextFactory.GetCurrentDbContext().Set <AddressBase>().Find(address.Code);

            if (result == null)
            {
                DataRepository.DB.Set <AddressBase>().Add(address);
            }
        }
        private void ReplaceHighway(string street, AddressBase address)
        {
            if (!App.RegularExpressions["highway"].IsMatch(street))
            {
                return;
            }

            Street            = App.RegularExpressions["highway"].Replace(street, "Highway");
            address.IsHighway = true;
        }
Exemple #19
0
            private void ReplaceHighway(string street, AddressBase address)
            {
                if (!_regexCache.Get("highway").IsMatch(street))
                {
                    return;
                }

                Street            = _regexCache.Get("highway").Replace(street, "Highway");
                address.IsHighway = true;
            }
        public int AddAddress(Entity.AddressBase address)
        {
            AddressBase result = Utility.EFContextFactory.GetCurrentDbContext().Set <AddressBase>().Find(address.Code);

            if (result == null)
            {
                return(DataRepository.Add <AddressBase>(address));
            }
            return(-1);
        }
Exemple #21
0
        private void Initialise()
        {
            _is64 = (_profile.Architecture == "AMD64");
            AddressBase addressSpace = _dataProvider.ActiveAddressSpace;

            if (_virtualAddress != 0)
            {
                _physicalAddress = addressSpace.vtop(_virtualAddress);
            }
            if (_physicalAddress == 0)
            {
                throw new ArgumentException("Error - Address is ZERO for _CM_KEY_BODY");
            }
            _structureSize = (uint)_profile.GetStructureSize("_CM_KEY_BODY");
            if (_structureSize == -1)
            {
                throw new ArgumentException("Error - Profile didn't contain a definition for _CM_KEY_BODY");
            }
            if (_virtualAddress == 0)
            {
                _buffer = _dataProvider.ReadPhysicalMemory(_physicalAddress, (uint)_structureSize);
            }
            else
            {
                _buffer = _dataProvider.ReadMemoryBlock(_virtualAddress, (uint)_structureSize);
            }
            if (_buffer == null)
            {
                return;
            }
            _structure = _profile.GetEntries("_CM_KEY_BODY");
            Structure s = GetStructureMember("KeyControlBlock");

            if (s.PointerType != "_CM_KEY_CONTROL_BLOCK")
            {
                return;
            }
            if (_is64)
            {
                ulong addr = BitConverter.ToUInt64(_buffer, (int)s.Offset) & 0xffffffffffff;
                _kcb = new KeyControlBlock(_profile, _dataProvider, addr);
                KeyControlBlock temp = _kcb;
                string          name = "";
                while (temp != null)
                {
                    name = temp.NameControlBlock.Name + "\\" + name;
                    temp = temp.Parent;
                }
                _name = name.TrimEnd(new char[] { '\\' });
            }
            else
            {
            }
        }
Exemple #22
0
 public void TestLoadKernelAddressSpace()
 {
     _kernelAddressSpace = new AddressSpacex64(_dataModel.DataProvider, "idle", 0x001AB000, true);
     Assert.IsNotNull(_kernelAddressSpace);
     Assert.IsTrue(_kernelAddressSpace.Dtb == 0x1ab000);
     Assert.IsNotNull(_kernelAddressSpace.MemoryMap);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords.Count == 0x8a29c);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].Flags == 0x400);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].IsSoftware);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].PhysicalAddress == 0xc000bf9c74200400);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].VirtualAddress == 0x0000b00065e04000);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].Size == 0x1000);
 }
Exemple #23
0
 public void TestLoadKernelAddressSpace()
 {
     _kernelAddressSpace = new AddressSpacex64(_dataModel.DataProvider, "idle", 0x1aa000, true);
     Assert.IsNotNull(_kernelAddressSpace);
     Assert.IsTrue(_kernelAddressSpace.Dtb == 0x1aa000);
     Assert.IsNotNull(_kernelAddressSpace.MemoryMap);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords.Count == 0x870e0);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].Flags == 0x901);
     Assert.IsFalse(_kernelAddressSpace.MemoryMap.MemoryRecords[4].IsSoftware);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].PhysicalAddress == 0x459000);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].VirtualAddress == 0xb0019c009000);
     Assert.IsTrue(_kernelAddressSpace.MemoryMap.MemoryRecords[4].Size == 0x1000);
 }
Exemple #24
0
 /// <summary>
 /// if coin type is changed, grey out the address until it is rerendered
 /// </summary>
 private void cboCoinType_SelectionChangeCommitted(object sender, EventArgs e)
 {
     txtBtcAddr.ForeColor = SystemColors.GrayText;
     // convert address when possible
     ChangeFlag++;
     try {
         AddressBase addr = new AddressBase(new AddressBase(txtBtcAddr.Text), AddressTypeByte);
         txtBtcAddr.Text = addr.AddressBase58;
     } catch (Exception) {
         // ignore
     } finally {
         ChangeFlag--;
     }
 }
Exemple #25
0
        public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            string strvalue = value as string;

            if (strvalue != null)
            {
                AddressBase addr = AddressBase.Factory(strvalue);
                return(addr);
            }
            else
            {
                return(new AddressBase());
            }
        }
Exemple #26
0
        // this will fail if the string runs off the end of the page
        // remember to set the dataProvider.ActiveAddressSpace before you call
        public UnicodeString(Profile profile, DataProviderBase dataProvider, ulong virtualAddress = 0, ulong physicalAddress = 0) : base(profile, dataProvider, virtualAddress)
        {
            _physicalAddress = physicalAddress;
            _is64            = (_profile.Architecture == "AMD64");
            _addressSpace    = dataProvider.ActiveAddressSpace;
            _structureSize   = (int)_profile.GetStructureSize("_UNICODE_STRING");
            if (_structureSize == -1)
            {
                throw new ArgumentException("Error - Profile didn't contain a definition for _OBJECT_TYPE");
            }
            //AddressBase addressSpace = dataProvider.ActiveAddressSpace;
            if (virtualAddress == 0)
            {
                _buffer = _dataProvider.ReadPhysicalMemory(_physicalAddress, (uint)_structureSize);
            }
            else
            {
                _physicalAddress = _addressSpace.vtop(_virtualAddress);
                _buffer          = _dataProvider.ReadMemoryBlock(_virtualAddress, (uint)_structureSize);
            }
            if (_buffer == null)
            {
                throw new ArgumentException("Invalid Address: " + virtualAddress.ToString("X08"));
            }
            _structure = _profile.GetEntries("_UNICODE_STRING");
            Structure s = GetStructureMember("Length");

            //int realOffset = (int)s.Offset + (int)(_physicalAddress & 0xfff);
            _length = BitConverter.ToUInt16(_buffer, (int)s.Offset);
            s       = GetStructureMember("MaximumLength");
            //realOffset = (int)s.Offset + (int)(_physicalAddress & 0xfff);
            _maximumLength = BitConverter.ToUInt16(_buffer, (int)s.Offset);
            s = GetStructureMember("Buffer");
            //realOffset = (int)s.Offset + (int)(_physicalAddress & 0xfff);
            if (_is64)
            {
                _pointerBuffer = BitConverter.ToUInt64(_buffer, (int)s.Offset) & 0xffffffffffff;
            }
            else
            {
                _pointerBuffer = BitConverter.ToUInt32(_buffer, (int)s.Offset) & 0xffffffff;
            }
            ulong pAddress = _addressSpace.vtop(_pointerBuffer);

            if (pAddress != 0)
            {
                byte[] nameBuffer = _dataProvider.ReadMemory(pAddress & 0xfffffffff000, 1);
                _name = Encoding.Unicode.GetString(nameBuffer, (int)(pAddress & 0xfff), (int)_length);
            }
        }
Exemple #27
0
        public async Task <SimpleResponseMessage> InvokeAsync(string service, string method, params object[] args)
        {
            AddressBase address = await this.addressProvider.AcquireAsync(this.server.AddressList);

            if (address == null)
            {
                throw new Exception("address not found");
            }

            Task <IChannel> clientChannelTask = currentClientChannelPool.AcquireAsync(address.CreateEndPoint);

            var requestMessage = BuildRequestMessage(service, method, args);

            IChannel clientChannel = await clientChannelTask;

            requestMessage.ContextID = clientChannel.Id.AsShortText();

            //响应结果接收task
            var tcs = new TaskCompletionSource <SimpleResponseMessage>();

            invokeResult.TryAdd(requestMessage.MessageID, tcs);

            clientChannel.WriteAndFlushAsync(requestMessage);

            //请求超时
            //var cts_request = new CancellationTokenSource();
            //Task requestTask = clientChannel.WriteAndFlushAsync(requestMessage);
            //if (!requestTask.Wait(server.ClientOptions.WriteTimeout, cts_request.Token))
            //{
            //    invokeResult.TryRemove(requestMessage.ContextID, out TaskCompletionSource<SimpleResponseMessage> _);
            //    cts_request.Cancel();
            //    throw new Exception("request timeout: MessageId: {requestMessage.MessageID}");
            //}

            //响应超时
            var cts_response = new CancellationTokenSource();

            if (!tcs.Task.Wait(server.ClientOptions.ReadTimeout, cts_response.Token))
            {
                invokeResult.TryRemove(requestMessage.MessageID, out TaskCompletionSource <SimpleResponseMessage> _);
                cts_response.Cancel();
                throw new Exception($"response timeout: MessageId: {requestMessage.MessageID}");
            }

            var result = await tcs.Task;

            invokeResult.TryRemove(requestMessage.MessageID, out TaskCompletionSource <SimpleResponseMessage> _);
            return(result);
        }
Exemple #28
0
        public static List <AddressBase> CreateAddressesLazy()
        {
            var addresses = new List <AddressBase>();

            for (int i = 0; i < 100; i++)
            {
                string iStr    = i.ToString();
                var    address = new AddressBase()
                {
                    City = "Miami" + iStr, Country = "USA"
                };
                addresses.Add(address);
            }
            return(addresses);
        }
Exemple #29
0
        public KeyControlBlock(Profile profile, DataProviderBase dataProvider, ulong virtualAddress = 0) : base(profile, dataProvider, virtualAddress)
        {
            _is64 = (_profile.Architecture == "AMD64");
            AddressBase addressSpace = _dataProvider.ActiveAddressSpace;

            if (_virtualAddress != 0)
            {
                _physicalAddress = addressSpace.vtop(_virtualAddress);
            }
            if (_physicalAddress == 0)
            {
                throw new ArgumentException("Error - Address is ZERO for _CM_KEY_CONTROL_BLOCK");
            }
            _structureSize = (uint)_profile.GetStructureSize("_CM_KEY_CONTROL_BLOCK");
            if (_structureSize == -1)
            {
                throw new ArgumentException("Error - Profile didn't contain a definition for _CM_KEY_CONTROL_BLOCK");
            }
            if (_virtualAddress == 0)
            {
                _buffer = _dataProvider.ReadPhysicalMemory(_physicalAddress, (uint)_structureSize);
            }
            else
            {
                _buffer = _dataProvider.ReadMemoryBlock(_virtualAddress, (uint)_structureSize);
            }
            _structure = _profile.GetEntries("_CM_KEY_CONTROL_BLOCK");
            Structure s = GetStructureMember("NameBlock");

            if (s == null)
            {
                return;
            }
            if (_is64)
            {
                ulong addr = BitConverter.ToUInt64(_buffer, (int)s.Offset) & 0xffffffffffff;
                _nameControlBlock = new CmNameControlBlock(_profile, _dataProvider, addr);
                s    = GetStructureMember("ParentKcb");
                addr = BitConverter.ToUInt64(_buffer, (int)s.Offset) & 0xffffffffffff;
                if (addr != 0)
                {
                    _parent = new KeyControlBlock(_profile, _dataProvider, addr);
                }
            }
            else
            {
            }
        }
Exemple #30
0
        async private Task <AddressBase> LoadKernelAddressSpace()
        {
            AddressBase addressSpace = null;
            await Task.Run(() =>
            {
                if (_profile.Architecture == "I386")
                {
                    addressSpace = new AddressSpacex86Pae(_dataProvider, "idle", _kernelDtb, true);
                }
                else
                {
                    addressSpace = new AddressSpacex64(_dataProvider, "idle", _kernelDtb, true);
                }
            });

            return(addressSpace);
        }