public DisplayModuleInfo(string ModuleName, PE Pe, ModuleSearchStrategy Location, ModuleFlag Flags = 0)
        {
            _Name     = ModuleName;
            _Filepath = Pe.Filepath;
            _Flags    = Flags;


            // Do not set this variables in order to
            // lessen memory allocations
            _Imports  = null;
            _Exports  = null;
            _Location = Location;

            _Info = new ModuleInfo()
            {
                Machine  = Pe.Properties.Machine,
                Magic    = Pe.Properties.Magic,
                Filesize = Pe.Properties.FileSize,

                ImageBase   = (UInt64)Pe.Properties.ImageBase,
                SizeOfImage = Pe.Properties.SizeOfImage,
                EntryPoint  = (UInt64)Pe.Properties.EntryPoint,

                Checksum        = Pe.Properties.Checksum,
                CorrectChecksum = Pe.Properties.CorrectChecksum,

                Subsystem        = Pe.Properties.Subsystem,
                SubsystemVersion = Pe.Properties.SubsystemVersion,

                Characteristics    = Pe.Properties.Characteristics,
                DllCharacteristics = Pe.Properties.DllCharacteristics,
            };

            AddNewEventHandler("FullPath", "FullPath", "ModuleName", this.GetPathDisplayName);
        }
        private void PopulateVersionInformation()
        {
            // Version information appears next to the QR finder pattern
            // See ISO/IEC 18004:2006(E), Sec. 6.10

            // Pattern only appears in QR code version 7 and greater
            if (Version < 7)
            {
                return;
            }

            // The version information is an 18-bit sequence: the 6-bit version number and a 12-bit error correction code
            uint versionInformation = _versionInformationEncodings[Version - 7];

            Debug.Assert(versionInformation >> 12 == Version);

            for (int i = 0; i < 18; i++)
            {
                ModuleFlag type = ModuleFlag.Reserved | ((((versionInformation >> i) & 0x2) != 0) ? ModuleFlag.Dark : ModuleFlag.Light);
                int        x    = i / 3;
                int        y    = Width - 11 + (i % 3);
                _modules.Set(x, y, type, overwrite: true); // upper-right
                _modules.Set(y, x, type, overwrite: true); // lower-left
            }
        }
Example #3
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ModuleFlag Flags = (ModuleFlag)value;

            // ext-ms api are considered optional
            if (((Flags & ModuleFlag.NotFound) != 0) && ((Flags & ModuleFlag.ApiSetExt) == 0))
            {
                return("Images/InvalidOverlay.png");
            }

            bool DelayLoadModule = (Flags & ModuleFlag.DelayLoad) != 0;

            if (DelayLoadModule)
            {
                return("Images/HourglassOverlay.png");
            }

            // How to handle delay-load + missing import?
            if ((Flags & ModuleFlag.MissingImports) != 0)
            {
                return("Images/InvalidOverlay.png");
            }

            bool ClrAssembly = (Flags & ModuleFlag.ClrReference) != 0;

            if (ClrAssembly)
            {
                return("Images/ReferenceOverlay.png");
            }

            return(null);
        }
Example #4
0
        public PE LoadImport(string ModuleName, DisplayModuleInfo CurrentModule = null, bool DelayLoad = false)
        {
            if (CurrentModule == null)
            {
                CurrentModule = this._SelectedModule;
            }

            Tuple <ModuleSearchStrategy, PE> ResolvedModule = BinaryCache.ResolveModule(
                this.Pe,
                ModuleName,
                this.SxsEntriesCache,
                this.CustomSearchFolders,
                this.WorkingDirectory
                );
            string ModuleFilepath = (ResolvedModule.Item2 != null) ? ResolvedModule.Item2.Filepath : null;

            ModuleCacheKey ModuleKey = new ModuleCacheKey(ModuleName, ModuleFilepath);

            if ((ModuleFilepath != null) && !this.ProcessedModulesCache.ContainsKey(ModuleKey))
            {
                ModuleFlag DelayLoadFlag = (DelayLoad) ? ModuleFlag.DelayLoad : 0;

                if (ResolvedModule.Item1 == ModuleSearchStrategy.ApiSetSchema)
                {
                    var ApiSetContractModule = new DisplayModuleInfo(
                        BinaryCache.LookupApiSetLibrary(ModuleName),
                        ResolvedModule.Item2,
                        ResolvedModule.Item1,
                        DelayLoadFlag & ModuleFlag.ApiSet
                        );
                    var NewModule = new ApiSetModuleInfo(ModuleName, ref ApiSetContractModule);
                    this.ProcessedModulesCache[ModuleKey] = NewModule;
                }
                else
                {
                    var NewModule = new DisplayModuleInfo(
                        ModuleName,
                        ResolvedModule.Item2,
                        ResolvedModule.Item1,
                        DelayLoadFlag
                        );
                    this.ProcessedModulesCache[ModuleKey] = NewModule;
                }

                // add it to the module list
                this.ModulesList.AddModule(this.ProcessedModulesCache[ModuleKey]);
            }

            return(ResolvedModule.Item2);
        }
 private void SetFlag(int row, int col, ModuleFlag flag, bool overwrite)
 {
     int blockNum, blockOffset;
     GetOffsets(row, col, out blockNum, out blockOffset);
     int leftShiftValue = 2 * blockOffset;
     byte newFlag = (byte)(((byte)flag & 0x3) << leftShiftValue);
     if (overwrite)
     {
         byte originalValue = _buffer[blockNum];
         byte originalValueMasked = (byte)(originalValue & ~(0x3 << leftShiftValue));
         byte newValue = (byte)(originalValueMasked | newFlag);
         _buffer[blockNum] = newValue;
     }
     else
     {
         _buffer[blockNum] |= newFlag;
     }
 }
        private void SetFlag(int row, int col, ModuleFlag flag, bool overwrite)
        {
            int blockNum, blockOffset;

            GetOffsets(row, col, out blockNum, out blockOffset);
            int  leftShiftValue = 2 * blockOffset;
            byte newFlag        = (byte)(((byte)flag & 0x3) << leftShiftValue);

            if (overwrite)
            {
                byte originalValue       = _buffer[blockNum];
                byte originalValueMasked = (byte)(originalValue & ~(0x3 << leftShiftValue));
                byte newValue            = (byte)(originalValueMasked | newFlag);
                _buffer[blockNum] = newValue;
            }
            else
            {
                _buffer[blockNum] |= newFlag;
            }
        }
Example #7
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            ModuleFlag Flags = (ModuleFlag)value;

            bool DelayLoadModule = (Flags & ModuleFlag.DelayLoad) != 0;

            if (DelayLoadModule)
            {
                return("Images/Hourglass.png");
            }

            bool ClrAssembly = (Flags & ModuleFlag.ClrReference) != 0;

            if (ClrAssembly)
            {
                return("Images/Reference.png");
            }

            return(null);
        }
        private void PopulateReservedModuleBits()
        {
            // This isn't the most efficient way to fill in the template, but it's only
            // performed once, then cached. So speed isn't a huge issue.

            // Fill in timing pattern in row 6 and col 6.
            // ISO/IEC 18004:2006(E), Sec. 5.3.4
            for (int i = 0; i < Width; i++)
            {
                ModuleFlag moduleFlag = ModuleFlag.Reserved | ((i % 2 == 0) ? ModuleFlag.Dark : ModuleFlag.Light);
                _modules.Set(i, 6, moduleFlag, overwrite: true);
                _modules.Set(6, i, moduleFlag, overwrite: true);
            }

            // Fill in the finder patterns (the "QR" patterns)
            PopulateFinderPatterns();

            // Fill in alignment patterns (the smaller "QR" patterns throughout the encoding region)
            PopulateAlignmentPatterns();

            // Fill in version information (next to the finder pattern)
            PopulateVersionInformation();
        }
 public void Set(int row, int col, ModuleFlag flag, bool overwrite = false)
 {
     CheckParameters(row, col);
     SetFlag(row, col, flag, overwrite);
 }
 public ModuleCacheKey(string _Name, string _Filepath, ModuleFlag _Flags = ModuleFlag.NoFlag)
 {
     Name     = _Name;
     Filepath = _Filepath;
     Flags    = _Flags;
 }
        private void ApplyFormatInformationEncodedBits(uint bits)
        {
            // See ISO/IEC 18004:2006(E), Sec. 6.9.1, Figure 25

            ModuleFlag b14 = GetTypeFromBitPosition(bits, 14);

            _modules.Set(8, 0, b14);
            _modules.Set(Width - 1, 8, b14);

            ModuleFlag b13 = GetTypeFromBitPosition(bits, 13);

            _modules.Set(8, 1, b13);
            _modules.Set(Width - 2, 8, b13);

            ModuleFlag b12 = GetTypeFromBitPosition(bits, 12);

            _modules.Set(8, 2, b12);
            _modules.Set(Width - 3, 8, b12);

            ModuleFlag b11 = GetTypeFromBitPosition(bits, 11);

            _modules.Set(8, 3, b11);
            _modules.Set(Width - 4, 8, b11);

            ModuleFlag b10 = GetTypeFromBitPosition(bits, 10);

            _modules.Set(8, 4, b10);
            _modules.Set(Width - 5, 8, b10);

            ModuleFlag b09 = GetTypeFromBitPosition(bits, 9);

            _modules.Set(8, 5, b09);
            _modules.Set(Width - 6, 8, b09);

            ModuleFlag b08 = GetTypeFromBitPosition(bits, 8);

            _modules.Set(8, 7, b08);
            _modules.Set(Width - 7, 8, b08);
            _modules.Set(Width - 8, 8, ModuleFlag.Dark); // dark module above bit 8 in bottom-left

            ModuleFlag b07 = GetTypeFromBitPosition(bits, 7);

            _modules.Set(8, 8, b07);
            _modules.Set(8, Width - 8, b07);

            ModuleFlag b06 = GetTypeFromBitPosition(bits, 6);

            _modules.Set(7, 8, b06);
            _modules.Set(8, Width - 7, b06);

            ModuleFlag b05 = GetTypeFromBitPosition(bits, 5);

            _modules.Set(5, 8, b05);
            _modules.Set(8, Width - 6, b05);

            ModuleFlag b04 = GetTypeFromBitPosition(bits, 4);

            _modules.Set(4, 8, b04);
            _modules.Set(8, Width - 5, b04);

            ModuleFlag b03 = GetTypeFromBitPosition(bits, 3);

            _modules.Set(3, 8, b03);
            _modules.Set(8, Width - 4, b03);

            ModuleFlag b02 = GetTypeFromBitPosition(bits, 2);

            _modules.Set(2, 8, b02);
            _modules.Set(8, Width - 3, b02);

            ModuleFlag b01 = GetTypeFromBitPosition(bits, 1);

            _modules.Set(1, 8, b01);
            _modules.Set(8, Width - 2, b01);

            ModuleFlag b00 = GetTypeFromBitPosition(bits, 0);

            _modules.Set(0, 8, b00);
            _modules.Set(8, Width - 1, b00);
        }
 private static void DrawRect(ModuleBlock modules, int row, int col, int width, int height, ModuleFlag type, bool xor = false)
 {
     for (int i = 0; i < height; i++)
     {
         for (int j = 0; j < width; j++)
         {
             modules.Set(row + i, col + j, type, !xor);
         }
     }
 }
 // Draws a square of the specified width whose top-left corner is at the specified coords
 private static void DrawSquare(ModuleBlock modules, int row, int col, int width, ModuleFlag type, bool xor = false)
 {
     DrawRect(modules, row, col, width, width, type, xor);
 }
 public void Set(int row, int col, ModuleFlag flag, bool overwrite = false)
 {
     CheckParameters(row, col);
     SetFlag(row, col, flag, overwrite);
 }
 private static void DrawRect(ModuleBlock modules, int row, int col, int width, int height, ModuleFlag type, bool xor = false)
 {
     for (int i = 0; i < height; i++)
     {
         for (int j = 0; j < width; j++)
         {
             modules.Set(row + i, col + j, type, !xor);
         }
     }
 }
 // Draws a square of the specified width whose top-left corner is at the specified coords
 private static void DrawSquare(ModuleBlock modules, int row, int col, int width, ModuleFlag type, bool xor = false)
 {
     DrawRect(modules, row, col, width, width, type, xor);
 }