forked from KolibriOS/kolibrios
Added source files C--.
git-svn-id: svn://kolibrios.org@6446 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
197
programs/develop/cmm/outle.cpp
Normal file
197
programs/develop/cmm/outle.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
#include "tok.h"
|
||||
|
||||
#include "le.h"
|
||||
|
||||
|
||||
|
||||
#define _OUTLE_
|
||||
|
||||
|
||||
|
||||
unsigned short swapshort(unsigned int var)
|
||||
|
||||
{
|
||||
|
||||
unsigned short h,l;
|
||||
|
||||
l=var>>8;
|
||||
|
||||
h=var<<8;
|
||||
|
||||
return l|h;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int MakeBin32()
|
||||
|
||||
{
|
||||
|
||||
hout=CreateOutPut(outext,"wb");
|
||||
|
||||
if(fwrite(output,outptr,1,hout)!=1){
|
||||
|
||||
ErrWrite();
|
||||
|
||||
fclose(hout);
|
||||
|
||||
hout=NULL;
|
||||
|
||||
return(-1);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
unsigned int EntryParamStr()
|
||||
|
||||
{
|
||||
|
||||
ITOK btok;
|
||||
|
||||
int bb=tk_id;
|
||||
|
||||
unsigned char *buf=(unsigned char *)"__bufcomstr";
|
||||
|
||||
btok.number=0;
|
||||
|
||||
searchtree(&btok,&bb,buf);
|
||||
|
||||
if(bb==tk_id)btok.number=0;
|
||||
|
||||
else{
|
||||
|
||||
btok.number+=outptrdata;
|
||||
|
||||
if((outptrdata%2)==1)btok.number++; /* alignment of entire post data block manditory */
|
||||
|
||||
}
|
||||
|
||||
return btok.number;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int MakeMEOS()
|
||||
|
||||
{
|
||||
|
||||
MEOSheader hdr;
|
||||
|
||||
hout=CreateOutPut(outext,"wb");
|
||||
|
||||
strcpy((char *)hdr.sign,"MENUET01");
|
||||
|
||||
hdr.vers=1;
|
||||
|
||||
hdr.start=EntryPoint();
|
||||
|
||||
hdr.size=outptr;
|
||||
|
||||
hdr.alloc_mem=Align(outptr+postsize+stacksize,16);
|
||||
|
||||
hdr.esp=hdr.alloc_mem-4;
|
||||
|
||||
hdr.I_Param=EntryParamStr();
|
||||
|
||||
hdr.I_Icon=0;
|
||||
|
||||
memcpy(output+startptr,&hdr,sizeof(MEOSheader));
|
||||
|
||||
if(fwrite(output,outptr,1,hout)!=1){
|
||||
|
||||
ErrWrite();
|
||||
|
||||
fclose(hout);
|
||||
|
||||
hout=NULL;
|
||||
|
||||
return(-1);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
int MakeLE()
|
||||
|
||||
{
|
||||
|
||||
LE_Header hdr;
|
||||
|
||||
Object_Table ot[2];
|
||||
|
||||
Page_Map_Table *pmt;
|
||||
|
||||
unsigned int i;
|
||||
|
||||
int headerofs;
|
||||
|
||||
int headsize=sizeof(LE_Header);
|
||||
|
||||
unsigned long *fpto;
|
||||
|
||||
int sizeb;
|
||||
|
||||
CreatStub(stubfile);
|
||||
|
||||
memset(&hdr,0,sizeof(LE_Header));
|
||||
|
||||
#ifdef _WC_
|
||||
|
||||
hdr.Signature='EL';
|
||||
|
||||
#else
|
||||
|
||||
hdr.Signature='LE';
|
||||
|
||||
#endif
|
||||
|
||||
hdr.CPU_Type=i80386;
|
||||
|
||||
hdr.Target_OS=1;
|
||||
|
||||
hdr.Type_Flags=0x200;
|
||||
|
||||
hdr.Number_Of_Memory_Pages=outptr/0x1000+1;
|
||||
|
||||
hdr.Initial_CS=1;
|
||||
|
||||
hdr.Initial_EI=EntryPoint();
|
||||
|
||||
hdr.Initial_SS=2;
|
||||
|
||||
hdr.Initial_ESP=stacksize;
|
||||
|
||||
hdr.Memory_Page_Size=0x1000;
|
||||
|
||||
hdr.Bytes_On_Last_Page=outptr%0x1000;
|
||||
|
||||
hdr.Object_Table_Offset=sizeof(LE_Header);
|
||||
|
||||
hdr.Object_Table_Entries=2;
|
||||
|
||||
headerofs=ftell(hout);
|
||||
|
||||
if(fwrite(&hdr,sizeof(LE_Header),1,hout)!=1){
|
||||
|
||||
errwrite:
|
||||
|
||||
ErrWrite();
|
||||
|
||||
fclose(hout);
|
||||
|
||||
hout=NULL;
|
||||
|
||||
return(-1);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user