Example #1
0
        bool CheckMcKeyRva(MyPEImage peImage, uint newXorKey)
        {
            xorKey = newXorKey;
            uint rva = GetMcKeyRva();

            return((rva & 0xFFF) == 0 && peImage.FindSection((RVA)rva) != null);
        }
Example #2
0
        static EncryptionVersion GetHeaderOffsetAndVersion(MyPEImage peImage, out uint headerOffset)
        {
            headerOffset = 0;

            var version = GetVersion(peImage, headerOffset);

            if (version != EncryptionVersion.Unknown)
            {
                return(version);
            }

            var section = peImage.FindSection(".rsrc");

            if (section != null)
            {
                version = GetHeaderOffsetAndVersion(section, peImage, out headerOffset);
                if (version != EncryptionVersion.Unknown)
                {
                    return(version);
                }
            }

            foreach (var section2 in peImage.Sections)
            {
                version = GetHeaderOffsetAndVersion(section2, peImage, out headerOffset);
                if (version != EncryptionVersion.Unknown)
                {
                    return(version);
                }
            }

            return(EncryptionVersion.Unknown);
        }
Example #3
0
        static ImageSectionHeader GetLastOf(MyPEImage peImage, string[] sections)
        {
            ImageSectionHeader sect = null;

            foreach (var name in sections)
            {
                var sect2 = peImage.FindSection(name);
                if (sect2 == null)
                {
                    continue;
                }
                if (sect == null || sect2.VirtualAddress > sect.VirtualAddress)
                {
                    sect = sect2;
                }
            }
            return(sect);
        }
Example #4
0
		static ImageSectionHeader GetLastOf(MyPEImage peImage, string[] sections) {
			ImageSectionHeader sect = null;
			foreach (var name in sections) {
				var sect2 = peImage.FindSection(name);
				if (sect2 == null)
					continue;
				if (sect == null || sect2.VirtualAddress > sect.VirtualAddress)
					sect = sect2;
			}
			return sect;
		}
Example #5
0
		static EncryptionVersion GetHeaderOffsetAndVersion(MyPEImage peImage, out uint headerOffset) {
			headerOffset = 0;

			var version = GetVersion(peImage, headerOffset);
			if (version != EncryptionVersion.Unknown)
				return version;

			var section = peImage.FindSection(".rsrc");
			if (section != null) {
				version = GetHeaderOffsetAndVersion(section, peImage, out headerOffset);
				if (version != EncryptionVersion.Unknown)
					return version;
			}

			foreach (var section2 in peImage.Sections) {
				version = GetHeaderOffsetAndVersion(section2, peImage, out headerOffset);
				if (version != EncryptionVersion.Unknown)
					return version;
			}

			return EncryptionVersion.Unknown;
		}
Example #6
0
		bool CheckMcKeyRva(MyPEImage peImage, uint newXorKey) {
			xorKey = newXorKey;
			uint rva = GetMcKeyRva();
			return (rva & 0xFFF) == 0 && peImage.FindSection((RVA)rva) != null;
		}