Subversion Repositories filter_foundry

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. #ifndef __RSRCSTRUCTS_H__
  2. #define __RSRCSTRUCTS_H__
  3.  
  4. // Structures found embedded in an EXE/DLL's resources
  5.  
  6. #define DWORD_ALIGN(i) (i = (i + 3) & ~3)
  7.  
  8. typedef struct {
  9.         DWORD Characteristics;
  10.         DWORD TimeDateStamp;
  11.         WORD  VersionMajor;
  12.         WORD  VersionMinor;
  13.         WORD  NumNameEntries;
  14.         WORD  NumIDEntries;
  15. } RSRCDIRTABLEHEAD;
  16.  
  17. typedef struct {
  18.         union {
  19.                 DWORD NameRVA;
  20.                 DWORD IntegerID;
  21.         };
  22.         union {
  23.                 DWORD DataEntryRVA;
  24.                 DWORD SubdirectoryRVA;
  25.         };
  26. } RSRCDIRENTRY;
  27.  
  28. typedef struct {
  29.         DWORD DataRVA;
  30.         DWORD Size;
  31.         DWORD Codepage;
  32.         DWORD Reserved;
  33. } RSRCDATAENTRY;
  34.  
  35.  
  36.  
  37.  
  38.  
  39. // Internal structures we use to maintain information about an EXE/DLL's loaded resources
  40.  
  41. typedef struct {
  42.         DWORD   Characteristics;
  43.         DWORD   TimeDateStamp;
  44.         WORD    VersionMajor;
  45.         WORD    VersionMinor;
  46. } RESOURCEINFO, *LPRESOURCEINFO;
  47.  
  48. #pragma pack(1)
  49. typedef struct StringHead {
  50.  
  51.         // To link the next StringHead in a linked list. Must be the first field!
  52.         struct StringHead       *Next;
  53.  
  54.         // Size of the string
  55.         DWORD                           Size;
  56.  
  57.         // The actual string is embedded here, so this struct's size can vary
  58.         WCHAR                           String[1];
  59.  
  60. } STRINGHEAD, *LPSTRINGHEAD;
  61. #pragma pack()
  62.  
  63. typedef struct Resource {
  64.  
  65.         // To link the next Resource in a linked list
  66.         struct Resource         *Next;
  67.  
  68.         // Information associated with this resource
  69.         LPBYTE                          Data;
  70.         DWORD                           DataSize;
  71.         DWORD                           Codepage;
  72.         DWORD                           Reserved;
  73.         WORD                            LanguageID;
  74. } RESOURCE, *LPRESOURCE;
  75.  
  76. // Holds info about each Named instance of a given Type of resource in the EXE/DLL
  77. typedef struct ResourceName {
  78.  
  79.         // To link the next RESOURCENAME in a linked list. Must be the first field!
  80.         struct ResourceName     *Next;
  81.  
  82.         // The resource Name string or number. Must be the second field!
  83.         union {
  84.         DWORD                           NameID;
  85.         LPWSTR                          NameString;
  86.         };
  87.  
  88.         // A linked list of the Language Resources for this Type/Name
  89.         LPRESOURCE                      Languages;
  90.  
  91.         // Information associated with this resource Type
  92.         DWORD                           Characteristics;
  93.         DWORD                           TimeDateStamp;
  94.         WORD                            VersionMajor;
  95.         WORD                            VersionMinor;
  96.  
  97. } RESOURCENAME, *LPRESOURCENAME;
  98.  
  99. // Holds info about each Type of resource in the EXE/DLL
  100. typedef struct ResourceType {
  101.  
  102.         // To link the next RESOURCETYPE in a linked list. Must be the first field!
  103.         struct ResourceType     *Next;
  104.  
  105.         // The resource Type string or number. Must be the second field!
  106.         union {
  107.         DWORD                           TypeID;
  108.         LPWSTR                          TypeString;
  109.         };
  110.  
  111.         // A linked list of the Named/ID'ed resources for this Type
  112.         LPRESOURCENAME          Names;
  113.  
  114.         // Information associated with this resource Type
  115.         DWORD                           Characteristics;
  116.         DWORD                           TimeDateStamp;
  117.         WORD                            VersionMajor;
  118.         WORD                            VersionMinor;
  119.  
  120. } RESOURCETYPE, *LPRESOURCETYPE;
  121.  
  122. // An internal structure we use to maintain information about an EXE/DLL's loaded resources
  123. typedef struct RsrcInfo {
  124.         // Handle to open file
  125.         HANDLE                          *File;
  126.  
  127.         // Byte offset within file to the resources
  128.         DWORD                           FilePtrToPEHdr;
  129.  
  130.         // To load the Section Header
  131.         IMAGE_SECTION_HEADER SectionHeader;
  132.  
  133.         // To load the PE Header
  134.         IMAGE_FILE_HEADER    PEHeader;
  135.  
  136.         // A linked list of the Named/ID'ed Types in the EXE/DLL
  137.         LPRESOURCETYPE          Types;
  138.  
  139.         // Information from the master RsrcDirTableHead in the EXE/DLL
  140.         DWORD                           Characteristics;
  141.         DWORD                           TimeDateStamp;
  142.         WORD                            VersionMajor;
  143.         WORD                            VersionMinor;
  144.  
  145.         // A linked list of strings
  146.         LPSTRINGHEAD            vtrStrings;
  147.  
  148. } RSRCINFO, *LPRSRCINFO;
  149.  
  150. // Used for get_time()
  151. typedef struct {
  152.         int tm_sec;     // Seconds [0 to 59]
  153.         int tm_min;     // Minutes [0 to 59]
  154.         int tm_hour;    // Hour [0 to 23, where 0 = Midnight]
  155.         int tm_mday;    // Day of the month [1 to 31]
  156.         int tm_mon;     // Months [0 to 11, where 0 = Jan]
  157.         int tm_year;    // Current Year - 1900
  158.         int tm_wday;    // Day of week [0 to 6 where 0 = Sunday]
  159.         int tm_yday;    // Day of the Year [0 to 365 where 0 = Jan 1]
  160.         int tm_isdst;   // Daylight Savings Time flag [0=none, 1=yes]
  161. } TM;
  162.  
  163. #define offsetof(s,m)   (size_t)&(((s *)0)->m)
  164.  
  165. #endif //__RSRCSTRUCTS_H__
  166.