summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorpixel <pixel>2003-10-10 02:58:57 +0000
committerpixel <pixel>2003-10-10 02:58:57 +0000
commit0c065d346b2555943540091651236ff802d720eb (patch)
tree3bb706bd42a26758660db509f1c672720d8bb6ac /lib
parentf6b0d98583b4b7465253e2416c6faf60ecc34627 (diff)
Adding support for NPAQ archives in (wow) PE files.
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)