mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-19 05:12:45 +03:00
6bd5a354f5
git-svn-id: svn://kolibrios.org@6446 a494cfbc-eb01-0410-851d-a64ba20cac60
547 lines
11 KiB
C
547 lines
11 KiB
C
#include <stdio.h>
|
||
#include <sys/stat.h>
|
||
|
||
typedef struct _BIT_{
|
||
unsigned int siz:8;
|
||
unsigned int ofs:24;
|
||
}BIT;
|
||
|
||
struct _PROCINFO_
|
||
{
|
||
char *buf; // ¤à¥á ⥪áâ ¯à®æ¥¤ãàë
|
||
void *classteg; // ¤à¥á ⥣ , £¤¥ ®¯à¥¤¥«¥ ¯à®æ¥¤ãà
|
||
unsigned int warn:1;
|
||
unsigned int speed:1;
|
||
unsigned int lst:1;
|
||
unsigned int typestring:2;
|
||
unsigned int inlinest:1;
|
||
unsigned int code32:1;
|
||
unsigned int align:1;
|
||
unsigned int acycle:1;
|
||
unsigned int idasm:1;
|
||
unsigned int opnum:1;
|
||
unsigned int de:1;
|
||
unsigned int ostring:1;
|
||
unsigned int uselea:1;
|
||
unsigned int regoverstack:1;
|
||
unsigned int sizeacycle;
|
||
char chip;
|
||
};
|
||
|
||
struct idrec
|
||
{
|
||
union{
|
||
struct idrec *left;
|
||
struct localrec *next;
|
||
};
|
||
struct idrec *right; //¯à¥¤ë¤ãé ¨ á«¥¤ãîé § ¯¨áì
|
||
char recid[IDLENGTH]; //¨¬ï
|
||
unsigned int flag;
|
||
char *newid; //¡«®ª á ¤ 묨, ¤«ï áâàãªâãà ¤à¥á ⥣ ,¤«ï ¯à®æ¥¤ãà ¯ à ¬¥âàë
|
||
int rectok; //⨯
|
||
int recrm; //¤«ï áâàãªâãà ç¨á«® ª®¯¨©
|
||
int recsegm;
|
||
int recpost;
|
||
int recsize;
|
||
int recsib;
|
||
int line; //®¬¥à «¨¨¨
|
||
int file; //ä ©«
|
||
int count; //áç¥â稪 ¨á¯®«ì§®¢ ¨ï
|
||
unsigned short type;
|
||
unsigned short npointr;
|
||
union{
|
||
char *sbuf; //㪠§ â¥«ì ¡«®ª ¨á室®£® ⥪áâ
|
||
_PROCINFO_ *pinfo;
|
||
};
|
||
union{
|
||
long recnumber;
|
||
long long reclnumber;
|
||
double recdnumber;
|
||
float recfnumber;
|
||
};
|
||
};
|
||
|
||
struct localinfo
|
||
{
|
||
int usedfirst;
|
||
int usedlast;
|
||
int start;
|
||
int end;
|
||
int level;
|
||
int count;
|
||
};
|
||
|
||
struct localrec
|
||
{
|
||
/* struct localrec *next;
|
||
int localtok;
|
||
unsigned short type;
|
||
unsigned short npointr;
|
||
union{
|
||
unsigned int localnumber;
|
||
idrec *rec;
|
||
};
|
||
int locsize;
|
||
char localid[IDLENGTH];
|
||
unsigned char fuse; //ä« £ ¨á¯®«ì§®¢ ¨ï
|
||
unsigned char flag; //ä« £ static*/
|
||
idrec rec;
|
||
localinfo li;
|
||
unsigned char fuse; //ä« £ ¨á¯®«ì§®¢ ¨ï
|
||
};
|
||
|
||
#define INITBPPAR 1 //¨¨æ¨ «¨§ æ¨ï BP ¯®á«¥ ¯ à ¬¥â஢
|
||
#define INITBPLOC 2 //¨¨æ¨ «¨§ æ¨ï BP ¯®á«¥ «®ª «ìëå
|
||
#define INITBPENTER 4
|
||
#define INITBPADDESP 8
|
||
|
||
struct HEADLOC
|
||
{
|
||
int type; //⨯ § £®«®¢ª
|
||
unsigned int ofs; // ¤à¥á § 票ï
|
||
unsigned int num; //¢¥«¨ç¨ § 票ï
|
||
};
|
||
|
||
struct treelocalrec
|
||
{
|
||
treelocalrec *next;
|
||
localrec *lrec;
|
||
int initbp;
|
||
int level;
|
||
unsigned int addesp;
|
||
int endline;
|
||
};
|
||
|
||
typedef struct _ITOK_
|
||
{
|
||
int rm;
|
||
int segm;
|
||
int post;
|
||
int sib;
|
||
union{
|
||
long number;
|
||
long long lnumber;
|
||
double dnumber;
|
||
float fnumber;
|
||
};
|
||
union{
|
||
int size;
|
||
BIT bit;
|
||
};
|
||
unsigned short type;
|
||
unsigned short npointr;
|
||
union{
|
||
idrec *rec;
|
||
localrec *locrec;
|
||
};
|
||
char name[IDLENGTH];
|
||
unsigned int flag;
|
||
}ITOK;
|
||
|
||
struct elementteg
|
||
{
|
||
union{
|
||
void *nteg; // ¤à¥á ⥣ ¢«®¦¥®© áâàãªâãàë
|
||
idrec *rec;
|
||
};
|
||
int tok;
|
||
union{
|
||
unsigned int numel; //ç¨á«® í«¥¬¥â®¢ í⮣® ⨯
|
||
BIT bit;
|
||
};
|
||
unsigned int ofs; //ᬥ饨¥ ®â ç « áâàãªâãàë
|
||
char name[IDLENGTH];
|
||
};
|
||
|
||
struct structteg
|
||
{
|
||
struct structteg *left; //á«¥¤ãî騩 ⥣
|
||
struct structteg *right; //á«¥¤ãî騩 ⥣
|
||
unsigned int size; //à §¬¥à ⥣
|
||
unsigned int numoper; //ç¨á«® ®¯¥à ¤®¢ áâàãªâãàë
|
||
struct elementteg *baza; // ¤à¥á á ®¯¨á ¨¥¬ í«¥¬¥â®¢ ⥣
|
||
unsigned int flag;
|
||
char name[IDLENGTH];
|
||
};
|
||
|
||
struct listexport
|
||
{
|
||
long address;
|
||
char name[IDLENGTH];
|
||
};
|
||
|
||
typedef struct _IOFS_
|
||
{
|
||
unsigned int ofs;
|
||
unsigned int line; //®¬¥à «¨¨¨
|
||
unsigned int file; //ä ©«
|
||
unsigned char dataseg;
|
||
}IOFS;
|
||
|
||
typedef struct _UNDEFOFF_
|
||
{
|
||
struct _UNDEFOFF_ *next;
|
||
IOFS *pos; //¡ãä¥à á ¤à¥á ¬¨ ®âªã¤ áá뫪¨
|
||
int num; //ç¨á«® ááë«®ª íâã ¬¥âªã
|
||
char name[IDLENGTH];
|
||
}UNDEFOFF;
|
||
|
||
typedef struct _LISTCOM_
|
||
{
|
||
char name[IDLENGTH];
|
||
}LISTCOM;
|
||
|
||
typedef struct _SINFO_
|
||
{
|
||
char *bufstr;
|
||
int size;
|
||
}SINFO;
|
||
|
||
//áâàãªâãà ᯨ᪠api-¯à®æ¥¤ãà
|
||
typedef struct _APIPROC_
|
||
{
|
||
struct idrec *recapi;
|
||
}APIPROC;
|
||
|
||
//
|
||
typedef struct _DLLLIST_
|
||
{
|
||
struct _DLLLIST_ *next; //á«¥¤ãîé ï DLL
|
||
struct _APIPROC_ *list; //ᯨ᮪ ¯à®æ¥¤ãà
|
||
unsigned short num; //ç¨á«® ¯à®æ¥¤ãà
|
||
char name[IDLENGTH]; //¨¬ï DLL
|
||
}DLLLIST;
|
||
|
||
typedef struct _PE_HEADER_
|
||
{
|
||
long sign; //ᨣ âãà - ¢á¥£¤ 'PE'
|
||
short cpu; //¬¨ ⨯ CPU - ¢á¥£¤ 0x14C
|
||
short numobj; //ç¨á«® ¢å®¤®¢ ¢ â ¡«¨æã ®¡ê¥ªâ®¢
|
||
long date_time; //¤ â ¬®¤¨ä¨ª 樨 «¨ª¥à®¬
|
||
long pCOFF;
|
||
long COFFsize;
|
||
short NTheadsize; //à §¬¥à § £®«®¢ª PE ®â MAGIC - ¢á¥£¤ 0xE0
|
||
short flags;
|
||
short Magic; // § 票¥ ¯à£à ¬¬ë
|
||
short LinkVer; //¢¥àá¨ï «¨ª¥à
|
||
long sizecode;
|
||
long sizeinitdata;
|
||
long sizeuninitdata;
|
||
long EntryRVA; // ¤à¥á ®â®á¨â IMAGE BASE ¯® ª®â®à®¬ã ¯¥à¥¤ ¥âáï ã¯à ¢«¥¨¥
|
||
long basecode; //RVA ᥪæ¨ï, ª®â®à ï ᮤ¥à¦¨â ¯à®£à ¬¬ë© ª®¤
|
||
long basedata; //RVA ᥪæ¨ï,ᮤ¥à¦ é ï ¤ ë¥
|
||
long ImageBase; //¢¨àâã «ìë© ç «ìë© ¤à¥á § £à㧪¨ ¯à®£à ¬¬ë
|
||
long objAlig; //¢ëà ¢¨¢ ¨¥ ¯à®£à ¬¬ëå ᥪ権
|
||
long fileAlig; //‚ëà ¢¨¢ ¨¥ ᥪ権 ¢ ä ©«¥
|
||
long OSver; //®¬¥à ¢¥àᨨ ®¯¥à á¨áâ¥¬ë ¥®¡å ¯à®£à ¬¬¥
|
||
long userver;
|
||
long SubSysVer;
|
||
long rez;
|
||
long imagesize; //à §¬¥à ¢ ¡ ©â å § £à㦠¥¬®£® ®¡à § á § £®«®¢ª ¬¨ ¢ëà ¢¥ë©
|
||
long headsize; //à §¬ ¢á¥å § £®«®¢ª®¢ stub+PE+objtabl
|
||
long checksum;
|
||
short SubSys; //®¯¥à 樮 ï á¨áâ ¥®¡å ¤«ï § ¯ãáª
|
||
short DLLflag;
|
||
long stackRezSize;
|
||
long stackComSize;
|
||
long heapRezSize;
|
||
long heapComSize;
|
||
long loaderFlag;
|
||
long numRVA; //¢á¥£¤ 10
|
||
long exportRVA;
|
||
long exportSize;
|
||
long importRVA;
|
||
long importSize;
|
||
long resourRVA;
|
||
long resourSize;
|
||
long exceptRVA;
|
||
long exceptSize;
|
||
long securRVA;
|
||
long securSize;
|
||
long fixupRVA;
|
||
long fixupSize;
|
||
long debugRVA;
|
||
long debugSize;
|
||
long descripRVA;
|
||
long descripSize;
|
||
long machinRVA;
|
||
long machinSize;
|
||
long tlsRVA;
|
||
long tlsSize;
|
||
long loadConfRVA;
|
||
long loadConfSize;
|
||
long rez2[2];
|
||
long iatRVA;
|
||
long iatSize;
|
||
long rez3[6];
|
||
}PE_HEADER;
|
||
|
||
typedef struct _OBJECT_ENTRY_
|
||
{
|
||
char name[8];
|
||
long vsize;
|
||
long sectionRVA;
|
||
long psize;
|
||
long pOffset;
|
||
unsigned long PointerToRelocations;
|
||
unsigned long PointerToLinenumbers;
|
||
unsigned short NumberOfRelocations;
|
||
unsigned short NumberOfLinenumbers;
|
||
long flags;
|
||
}OBJECT_ENTRY;
|
||
|
||
typedef struct _EXPORT_TABLE_
|
||
{
|
||
unsigned long Flags;
|
||
unsigned long Time;
|
||
unsigned short Version[2];
|
||
unsigned long NameRVA;
|
||
unsigned long OriginalBase;
|
||
unsigned long NumFunc;
|
||
unsigned long NumName;
|
||
unsigned long AddressRVA;
|
||
unsigned long NamePRVA;
|
||
unsigned long OrdinalRVA;
|
||
}EXPORT_TABLE;
|
||
|
||
struct ftime {
|
||
unsigned ft_tsec:5; /* ¤¢¥ ᥪã¤ë */
|
||
unsigned ft_min:6; /* ¬¨ãâë */
|
||
unsigned ft_hour:5; /* ç áë */
|
||
unsigned ft_day:5; /* ¤¥ì */
|
||
unsigned ft_month:4; /* ¬¥áïæ */
|
||
unsigned ft_year:7; /* £®¤-1980 */
|
||
};
|
||
|
||
|
||
typedef struct _STRING_LIST_
|
||
{
|
||
void *next; //á«¥¤ãîé ï áâàãªâãà
|
||
unsigned int len; //¤«¨ áâப¨
|
||
unsigned int ofs; // ¤à¥á ¢ ¢ë室®¬ ä ©«¥
|
||
unsigned char type; //⨯ â¥à¬¨ â®à
|
||
unsigned char plase; //£¤¥ ᥩç á áâப - post or data
|
||
}STRING_LIST;
|
||
|
||
struct FILEINFO
|
||
{
|
||
char *filename;
|
||
int numdline;
|
||
idrec *stlist;
|
||
union{
|
||
struct ftime time;
|
||
unsigned short lineidx[2];
|
||
};
|
||
};
|
||
|
||
struct EWAR{
|
||
FILE *file;
|
||
char *name;
|
||
};
|
||
|
||
typedef struct _ICOMP_
|
||
{
|
||
unsigned int type;
|
||
unsigned int loc;
|
||
unsigned int use_cxz;
|
||
}ICOMP;
|
||
|
||
typedef struct _RETLIST_
|
||
{
|
||
unsigned int line;
|
||
unsigned int loc;
|
||
unsigned int type;
|
||
// int use;
|
||
}RETLIST;
|
||
|
||
enum{
|
||
singlcase,startmulti,endmulti};
|
||
|
||
typedef struct _ISW_
|
||
{
|
||
unsigned char type;
|
||
unsigned int postcase;
|
||
unsigned long value;
|
||
}ISW;
|
||
|
||
struct postinfo
|
||
{
|
||
unsigned int loc;
|
||
unsigned int num;
|
||
unsigned short type;
|
||
unsigned short line;
|
||
unsigned short file;
|
||
|
||
};
|
||
|
||
typedef struct _EXE_DOS_HEADER_
|
||
{
|
||
unsigned short sign;
|
||
unsigned short numlastbyte;
|
||
unsigned short numpage;
|
||
unsigned short numreloc;
|
||
unsigned short headsize;
|
||
unsigned short minmem;
|
||
unsigned short maxmem;
|
||
unsigned short initSS;
|
||
unsigned short initSP;
|
||
unsigned short checksum;
|
||
unsigned short initIP;
|
||
unsigned short initCS;
|
||
unsigned short ofsreloc;
|
||
unsigned short overlay;
|
||
unsigned long fullsize;
|
||
}EXE_DOS_HEADER;
|
||
|
||
typedef struct _FSWI_
|
||
{
|
||
ISW *info;
|
||
int sizetab; //ç¨á«® í«¥¬¥â®¢
|
||
int type; //à §à冷áâì
|
||
int numcase; //ç¨á«® ¨á¯®«ì§ã¥¬ëå í«¥¬¥â®¢
|
||
int defal; //§ 票¥ ¯® 㬮«ç ¨î.
|
||
int ptb; // ¤à¥á 㪠§ ⥫ï íâã â ¡«¨æã ¢ ¡«®ª¥ ª®¤
|
||
int ptv; // ¤à¥á â ¢«¨æë ¢¥«¨ç¨
|
||
int mode; //⨯ switch
|
||
int razr; //à §à冷áâì ¢¥«¨ç¨
|
||
}FSWI;
|
||
|
||
struct paraminfo
|
||
{
|
||
unsigned int ofspar;
|
||
unsigned char type[8];
|
||
};
|
||
|
||
struct MEOSheader
|
||
{
|
||
unsigned char sign[8];
|
||
unsigned long vers;
|
||
unsigned long start;
|
||
unsigned long size;
|
||
unsigned long alloc_mem;
|
||
unsigned long esp;
|
||
unsigned long I_Param;
|
||
unsigned long I_Icon;
|
||
};
|
||
|
||
#ifdef OPTVARCONST
|
||
|
||
struct LVIC{
|
||
idrec *rec;
|
||
// int blocks;
|
||
int typevar;
|
||
int contype; //⨯ ᮤ¥à¦¨¬®£®
|
||
union{
|
||
long number;
|
||
long long lnumber;
|
||
double dnumber;
|
||
float fnumber;
|
||
};
|
||
};
|
||
|
||
struct BLVIC
|
||
{
|
||
int sizevic;
|
||
LVIC *listvic;
|
||
};
|
||
|
||
#endif
|
||
|
||
#define SIZEIDREG 256
|
||
#define NOINREG 8
|
||
#define SKIPREG 9
|
||
|
||
struct REGEQVAR
|
||
{
|
||
REGEQVAR *next;
|
||
char name[IDLENGTH];
|
||
unsigned char razr;
|
||
};
|
||
|
||
struct REGISTERSTAT
|
||
{
|
||
union{
|
||
REGEQVAR *next;
|
||
#ifdef OPTVARCONST
|
||
BLVIC *bakvic;
|
||
#endif
|
||
};
|
||
union{
|
||
char id[SIZEIDREG];
|
||
void *stringpar;
|
||
unsigned long number;
|
||
};
|
||
unsigned char type;
|
||
unsigned char razr;
|
||
};
|
||
|
||
struct SAVEREG
|
||
{
|
||
unsigned int size; //à §¬¥à ¯ ¬ï⨠¤«ï ॣ¨áâ஢
|
||
unsigned char all; //¢á¥ ॣ¨áâàë
|
||
unsigned char reg[8]; //ª àâ ॣ¨áâ஢
|
||
};
|
||
|
||
struct SAVEPAR
|
||
{
|
||
unsigned char ooptimizespeed;
|
||
unsigned char owarning;
|
||
unsigned char odbg;
|
||
unsigned char odosstring;
|
||
unsigned char ouseinline;
|
||
unsigned char oam32; // ०¨¬ 32 ¡¨â®© ¤à¥á 樨
|
||
unsigned char oalignword;
|
||
unsigned char oAlignCycle; //¢ëà ¢¨¢ âì ç « 横«®¢
|
||
unsigned char oidasm; // áᥬ¡«¥àë¥ ¨áâàãªæ¨¨ áç¨â âì ¨¤¥â¨ä¨ª â®à ¬¨
|
||
int ooptnumber;
|
||
int odivexpand;
|
||
unsigned char ooptstr; //®¯â¨¬¨§ æ¨ï áâப®¢ëå ª®áâ â
|
||
unsigned char ochip;
|
||
int oaligncycle;
|
||
unsigned char ouselea;
|
||
unsigned char oregoverstack;
|
||
};
|
||
|
||
struct COM_MOD
|
||
{
|
||
COM_MOD *next;
|
||
unsigned char *input; /* dynamic input buffer */
|
||
unsigned int endinptr; /* end index of input array */
|
||
unsigned int inptr; /* index in input buffer */
|
||
unsigned int inptr2; /* index in input buffer */
|
||
unsigned int linenumber;
|
||
unsigned int currentfileinfo;
|
||
int numparamdef; //ç¨á«® ¯ à ¬¥â஢ ¢ ⥪ã饬 define
|
||
char *declareparamdef; //ᯨ᮪ ®¡ê¥ëå ¯ à ¬¥â஢ define
|
||
char *paramdef; //ᯨ᮪ ®¢ëå ¯ à ¬¥â஢
|
||
int freze; //ä« £ § ¯à¥é¥¨ï 㤠«¥¨ï áâàãªâãàë
|
||
};
|
||
|
||
struct LISTRELOC {
|
||
unsigned int val;
|
||
};
|
||
|
||
struct LISTFLOAT
|
||
{
|
||
union{
|
||
float fnum;
|
||
double dnum;
|
||
unsigned long num[2];
|
||
};
|
||
int type;
|
||
unsigned int ofs;
|
||
};
|
||
|
||
struct LILV
|
||
{
|
||
unsigned int ofs;
|
||
int size;
|
||
localrec *rec;
|
||
};
|
||
|
||
struct WARNACT
|
||
{
|
||
void (*fwarn)(char *str,unsigned int line,unsigned int file);
|
||
unsigned char usewarn;
|
||
};
|