Ejemplo n.º 1
0
        internal unsafe Win32ResourceDirectory(PEReader pe, byte *pRoot, int offset, Win32ResourceName name)
        {
            var p = (IMAGE_RESOURCE_DIRECTORY *)(pRoot + offset);

            Characteristics      = p->Characteristics;
            TimeDateStamp        = p->TimeDateStamp;
            MajorVersion         = p->MajorVersion;
            MinorVersion         = p->MinorVersion;
            NumberOfNamedEntries = p->NumberOfNamedEntries;
            NumberOfIdEntries    = p->NumberOfIdEntries;

            Name        = name;
            Directories = new List <Win32ResourceDirectory>();
            Datas       = new List <Win32ResourceData>();
            var pEntries = (IMAGE_RESOURCE_DIRECTORY_ENTRY *)(p + 1);
            int total    = NumberOfNamedEntries + NumberOfIdEntries;

            for (int i = 0; i < total; i++)
            {
                var pEntry = pEntries + i;
                name = new Win32ResourceName(pRoot, pEntry);
                if ((pEntry->OffsetToData & 0x80000000) == 0)
                {
                    Datas.Add(new Win32ResourceData(pe, pRoot, (int)pEntry->OffsetToData, name));
                }
                else
                {
                    Directories.Add(new Win32ResourceDirectory(pe, pRoot, (int)(pEntry->OffsetToData & 0x7FFFFFFF), name));
                }
            }
        }
Ejemplo n.º 2
0
 public Win32ResourceDirectory FindDirectory(Win32ResourceName name)
 {
     foreach (var directory in Directories)
     {
         if (directory.Name == name)
         {
             return(directory);
         }
     }
     return(null);
 }