summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Input.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/Input.cc b/lib/Input.cc
index 4f87599..6c7815f 100644
--- a/lib/Input.cc
+++ b/lib/Input.cc
@@ -203,14 +203,49 @@ Archive::Archive(Handle * hand, int atype) :
create();
}
+#pragma pack(1)
+
+struct PEsection_t {
+ char name[8];
+ Uint32 VSize, VAdd, SizeOf, Pointer, PTRelocs, PTLNs;
+ Uint16 NR, NLN;
+ Uint32 Chars;
+};
+
void Archive::create() throw (GeneralException) {
char buffer[1024];
int len;
+ Uint32 sig, ptr, maxptr = 0, startptr;
+ Uint16 sections;
+ PEsection_t PEsection;
size_t size;
FileTree * p = &filetree, * t;
String ifname;
+ int i;
switch(type) {
+ case ARCHIVE_EXECUTABLE:
+ startptr = archive->tell();
+ sig = archive->readU32();
+ if ((sig & 0xffff) == 0x5a4d) { /* MZ */
+ archive->seek(56, SEEK_CUR);
+ sig = archive->readU32();
+ archive->seek(sig - 64, SEEK_CUR);
+ sig = archive->readU32();
+ if (sig != 0x4550)
+ throw GeneralException(_("Archive: file is not a PE."));
+ archive->seek(2, SEEK_CUR);
+ sections = archive->readU16();
+ archive->seek(240, SEEK_CUR);
+ for (i = 0; i < sections; i++) {
+ archive->read(&PEsection, sizeof(PEsection));
+ printm(M_INFO, "Section: %s\n", PEsection.name);
+ ptr = PEsection.Pointer + PEsection.SizeOf;
+ if (ptr > maxptr)
+ maxptr = ptr;
+ }
+ archive->seek(startptr - archive->tell() + maxptr, SEEK_CUR);
+ }
case ARCHIVE_BUILTIN:
archive->read(buffer, 4);
if (*((Uint32 *)buffer) != BUILTIN_SIG)