| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | exe files (was: music) |
Bill Birrell wrote in a message to Corbin Lemieux:
BB> Corbin, the best way to see what's in the header of an EXE file
BB> on Ms-Dos is to run exehdr.exe on it. This comes free with most of
BB> the Microsoft programming languages, so you probably have a copy
BB> somewhere.
This may also be of help:
/*
exinfo.c - displays information about executables
written by Tom Torfs (tomtorfs{at}mail.dma.be, 2:292/516{at}fidonet.org)
donated to the public domain, 1996-12-16
if you update this program, please send me a copy
identifies the following executable formats:
* DOS COM, DOS EXE, European MS-DOS 4.x new executable
* Windows segmented, linear
* Windows/386 segmented, linear
* Win32 (Win32s,Win95,WinNT)
* OS/2 segmented, linear, family app
* Borland OS services, HP 100LX/200LX
* PharLap, PharLap/286, PharLap/386, PharLap/OS/2, PharLap/Windows
identifies the following compilers/linkers: (these can only be
detected on uncompressed executables)
* Borland/Turbo C/C++
* Watcom C/C++
* TopSpeed C/C++
identifies the following executable compressors / sfx archives:
* PKZIP sfx, PKARC sfx
* ARJ sfx, RAR SFX, BSA sfx
* LHarc SFX, LHA SFX, LH SFX, LARC SFX
* LZEXE, PKLITE, DIET, TINYPROG
*/
#include
#include
#include
/* turn alignment off */
#if defined(__TURBOC__)
#pragma option -a-
#elif defined(__ZTC__)
#pragma ZTC align 1
#else
#pragma pack(1)
#endif
/* executable formats */
enum {FORM_UNKNOWN,
FORM_DOSCOM,FORM_DOSEXE,
FORM_DOS4SEGMENTED,FORM_DOS4LINEAR,
FORM_SEGMENTED,FORM_LINEAR,
FORM_WINSEGMENTED,FORM_WINLINEAR,
FORM_WIN386SEGMENTED,FORM_WIN386LINEAR,
FORM_WIN32,
FORM_OS2SEGMENTED,FORM_OS2LINEAR,FORM_OS2FAMILY,
FORM_BORLAND,FORM_HPLX,
FORM_PHARLAP,FORM_PHARLAP286,FORM_PHARLAP386,
FORM_PHARLAPOS2,FORM_PHARLAPWIN,
FORMATS};
/* compilers/linkers */
enum {COMP_UNKNOWN,
COMP_BORLANDC,COMP_WATCOMC,COMP_TOPSPEEDC,
COMP_TLINK,
COMPILERS};
/* executable packers */
enum {PACK_UNKNOWN,
PACK_PKZIPSFX,PACK_PKARCSFX,PACK_ARJSFX,PACK_RARSFX,
PACK_BSASFX,PACK_LHARCSFX,PACK_LHASFX,PACK_LHSFX,PACK_LARCSFX,
PACK_LZEXE,PACK_PKLITE,PACK_DIET,PACK_TINYPROG,
PACKERS};
const char *formatname[FORMATS]
= {"unknown",
"DOS COM","DOS EXE",
"European MS-DOS 4.x segmented","European MS-DOS 4.x
linear",
"segmented executable","linear executable",
"Windows segmented","Windows linear",
"Win386 segmented","Win386 linear",
"Win32",
"OS/2 segmented","OS/2 linear","OS/2 family app",
"Borland OS services","HP 100LX/200LX",
"PharLap","PharLap/286","PharLap/386",
"PharLap/OS/2","Pharlap/Windows"};
const char *compilername[COMPILERS]
= {"unknown",
"Borland/Turbo C/C++","Watcom
C/C++","TopSpeed C/C++",
"Borland TLINK"};
const char *packername[PACKERS]
= {"unknown/none",
"PKZIP SFX","PKARC SFX","ARJ
SFX","RAR SFX",
"BSA SFX","LHarc SFX","LHA
SFX","LH SFX","LARC SFX",
"LZEXE","PKLITE","DIET","TINYPROG"};
#define MAXPATTERNLEN 20
struct pattern {int compiler;
int patternlen; unsigned char pattern[MAXPATTERNLEN];};
#define PATTERNS 3
/* compiler patterns
0 is a wildcard (any value will match)
as soon as a match is found, the detection routine will abort,
so specific matches should come before more general ones */
static struct pattern patterns[PATTERNS]
= {
{ COMP_BORLANDC, 12, /* Borland C/C++ exe */
{0xBA,0,0,0x2E,0x89,0x16,0,0,0xB4,0x30,0xCD,0x21} },
{ COMP_BORLANDC, 12, /* Borland C/C++ com */
{0x8C,0xCA,0x2E,0x89,0x16,0,0,0xB4,0x30,0xCD,0x21} },
{ COMP_WATCOMC, 9, /* Watcom C/C++ exe/com */
{0xE9,0,0,'W','A','T','C','O','M'} }
};
static struct {char signature[2];
unsigned short lenmod512,lendiv512;
unsigned short fixups;
unsigned short headerpara,memminpara,memmaxpara;
unsigned short ss,sp;
unsigned short checksum;
unsigned short ip,cs;
unsigned short fixuptabofs;
unsigned short overlay;
} exeheader;
static struct {char signature[2];
unsigned char linkermajor,linkerminor;
unsigned short entryofs,entrylen;
unsigned long crc;
unsigned char progflags,appflags;
unsigned short datasegidx,localheapsize,stacksize;
unsigned short ip,cs;
unsigned short sp,ss;
unsigned short segcount,refcount,nonresnametablen;
unsigned short segtabofs,resourcetabofs,resnametabofs,
reftabofs,impnametabofs;
unsigned long nonresnametabofs;
unsigned short entrypointcount;
unsigned short alignment;
unsigned short resourcecount;
unsigned char targetos;
unsigned char exeflags;
unsigned short gangloadofs,gangloadlength;
unsigned short swapsize;
unsigned char winminor,winmajor;
} newheader;
static struct {char signature[2];
unsigned char byteorder,wordorder;
unsigned long formatlevel;
unsigned short cpu;
unsigned short targetos;
unsigned long modversion,modtype;
unsigned long mempages;
unsigned long csipobjnr,csipofs;
unsigned long ssspobjnr,ssspofs;
unsigned long mempagesize;
unsigned long lastpage;
unsigned long fixupsize,fixupchecksum;
unsigned long loadersize,loaderchecksum;
unsigned long objtabofs,objtabcount;
unsigned long objpagetabofs,objdatamapofs;
unsigned long resourcetabofs,resourcetabsize;
unsigned long resnametabofs,entrytabofs;
unsigned long directivetabofs,directivecount;
unsigned long fixuppagetabofs,fixuprecordtabofs;
unsigned long nametabofs,impcount,impnametabofs;
unsigned long checksumtabofs,datapageofs;
unsigned long preloadcount;
unsigned long nonresnametabofs,nonresnametabsize;
unsigned long nonresnametabchecksum;
unsigned long autodata;
unsigned long debugoffset,debuglength;
unsigned long preloadnumber,demandnumber;
unsigned long extraheap;
} linearheader;
static unsigned char buffer[MAXPATTERNLEN];
/* compare memory with wildcards */
static int maskcomp(const unsigned char *mem,
const unsigned char *mask,
int len)
{
for (; len>0; len--, mem++, mask++)
{
if (*mask!=0 && *mask!=*mem)
return 1;
}
return 0;
}
/* read a string from a file terminated by character term
s must be able to hold maxlen characters + the nul terminator
returns number of characters actually read */
static int freadstr(FILE *fp, unsigned char *s, int maxlen, unsigned char term)
{
int len = 0;
while (len * Origin: 80X86 BBS 32-15-24.62.32 V.34/V.FC (24h/24h) (2:292/516)SEEN-BY: 396/1 632/0 371 633/260 267 270 371 634/397 635/506 728 810 639/252 SEEN-BY: 670/218 @PATH: 292/516 106/1 396/1 633/260 635/506 728 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.