示例#1
0
 public ResourceDirectory(JLibrary.PortableExecutable.PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root) : base(owner, entry, named, root)
 {
     if (!owner.Read <IMAGE_RESOURCE_DIRECTORY>((long)(root + (entry.SubdirectoryRva ^ 0x80000000)), SeekOrigin.Begin, out this._base))
     {
         throw owner.GetLastError();
     }
 }
示例#2
0
 public ResourceFile(JLibrary.PortableExecutable.PortableExecutable owner, IMAGE_RESOURCE_DIRECTORY_ENTRY entry, bool named, uint root) : base(owner, entry, named, root)
 {
     if (!owner.Read <IMAGE_RESOURCE_DATA_ENTRY>((long)(base._root + entry.DataEntryRva), SeekOrigin.Begin, out this._base))
     {
         throw owner.GetLastError();
     }
 }
示例#3
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;
 }
示例#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);
            }
        }