public ResourceFile(PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root) : base(owner, entry, named, root)
 {
     if (!owner.Read <IMAGE_RESOURCE_DATA_ENTRY>((long)((ulong)(this._root + entry.DataEntryRva)), SeekOrigin.Begin, out this._base))
     {
         throw owner.GetLastError();
     }
 }
 public ResourceDirectory(PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root) : base(owner, entry, named, root)
 {
     if (!owner.Read <IMAGE_RESOURCE_DIRECTORY>((long)((ulong)(root + (entry.SubdirectoryRva ^ 2147483648u))), SeekOrigin.Begin, out this._base))
     {
         throw owner.GetLastError();
     }
 }
 public ResourceDirectory(PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root)
     : base(owner, entry, named, root)
 {
     if (!owner.Read(root + (entry.SubdirectoryRva ^ 0x80000000), System.IO.SeekOrigin.Begin, out this._base))
     {
         throw owner.GetLastError();
     }
 }
Exemple #4
0
        public ResourceWalker(JLibrary.PortableExecutable.PortableExecutable image)
        {
            IMAGE_DATA_DIRECTORY image_data_directory = image.NTHeader.OptionalHeader.DataDirectory[2];
            uint root = 0;

            if ((image_data_directory.VirtualAddress > 0) && (image_data_directory.Size > 0))
            {
                IMAGE_RESOURCE_DIRECTORY image_resource_directory;
                if (!image.Read <IMAGE_RESOURCE_DIRECTORY>((long)(root = image.GetPtrFromRVA(image_data_directory.VirtualAddress)), SeekOrigin.Begin, out image_resource_directory))
                {
                    throw image.GetLastError();
                }
                IMAGE_RESOURCE_DIRECTORY_ENTRY entry = new IMAGE_RESOURCE_DIRECTORY_ENTRY {
                    SubdirectoryRva = 0x80000000
                };
                this.Root = new ResourceDirectory(image, entry, false, root);
            }
        }
            public ResourceObject(PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root)
            {
                this._owner = owner;
                this._entry = entry;
                this.IsNamedResource = named;
                if (named)
                {
                    ushort len = 0;
                    if (owner.Read(root + (entry.NameRva & 0x7FFFFFFF), System.IO.SeekOrigin.Begin, out len))
                    {
                        byte[] unicodeBuffer = new byte[len << 1]; //each unicode character is 2 bytes wide
                        if (owner.Read(0, System.IO.SeekOrigin.Current, unicodeBuffer))
                            this._name = Encoding.Unicode.GetString(unicodeBuffer);
                    }

                    if (_name == null)
                        throw owner.GetLastError();
                }
                this._root = root;
            }
 public ResourceObject(PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root)
 {
     this._owner          = owner;
     this._entry          = entry;
     this.IsNamedResource = named;
     if (named)
     {
         ushort num = 0;
         if (owner.Read <ushort>((long)((ulong)(root + (entry.NameRva & 2147483647u))), SeekOrigin.Begin, out num))
         {
             byte[] array = new byte[(int)num << 1];
             if (owner.Read(0L, SeekOrigin.Current, array))
             {
                 this._name = Encoding.Unicode.GetString(array);
             }
         }
         if (this._name == null)
         {
             throw owner.GetLastError();
         }
     }
     this._root = root;
 }
Exemple #7
0
 public ResourceObject(JLibrary.PortableExecutable.PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root)
 {
     this._owner          = owner;
     this._entry          = entry;
     this.IsNamedResource = named;
     if (named)
     {
         ushort result = 0;
         if (owner.Read <ushort>((long)(root + (entry.NameRva & 0x7fffffff)), SeekOrigin.Begin, out result))
         {
             byte[] buffer = new byte[result << 1];
             if (owner.Read(0L, SeekOrigin.Current, buffer))
             {
                 this._name = Encoding.Unicode.GetString(buffer);
             }
         }
         if (this._name == null)
         {
             throw owner.GetLastError();
         }
     }
     this._root = root;
 }
            public ResourceObject(PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root)
            {
                this._owner          = owner;
                this._entry          = entry;
                this.IsNamedResource = named;
                if (named)
                {
                    ushort len = 0;
                    if (owner.Read(root + (entry.NameRva & 0x7FFFFFFF), System.IO.SeekOrigin.Begin, out len))
                    {
                        byte[] unicodeBuffer = new byte[len << 1]; //each unicode character is 2 bytes wide
                        if (owner.Read(0, System.IO.SeekOrigin.Current, unicodeBuffer))
                        {
                            this._name = Encoding.Unicode.GetString(unicodeBuffer);
                        }
                    }

                    if (_name == null)
                    {
                        throw owner.GetLastError();
                    }
                }
                this._root = root;
            }
 public ResourceFile(PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root)
     : base(owner, entry, named, root)
 {
     if (!owner.Read(_root + entry.DataEntryRva, System.IO.SeekOrigin.Begin, out this._base))
         throw owner.GetLastError();
 }
 public ResourceDirectory(PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root)
     : base(owner, entry, named, root)
 {
     if (!owner.Read(root + (entry.SubdirectoryRva ^ 0x80000000), System.IO.SeekOrigin.Begin, out this._base))
         throw owner.GetLastError();
 }