2019-11-14 21:45:31 +03:00
|
|
|
|
#include "tok.h"
#include "coff.h"
#define _OUTPE_
/* -----------------------------------------------------------------------
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> PE <20><>ଠ<EFBFBD><E0ACA0>
------------------------------------------------------------------------ */
#define SIZESTUB 96
#define STRVERS 0x20 //ᬥ饭<E1ACA5><E9A5AD> ⥪<><E2A5AA><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>ᨨ
unsigned char stub[]={0x4D,0x5A,0x50,0x00,0x02,0x00,0x00,0x00,
0x04,0x00,0x0F,0x00,0xFF,0xFF,0x00,0x00,
0xB8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x40,0x00,0x1A,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x60,0x00,0x00,0x00,
0xBA,0x0E,0x00,0x0E,0x1F,0xB4,0x09,0xCD,
0x21,0xB8,0x01,0x4C,0xCD,0x21,0x46,0x6F,
0x72,0x20,0x57,0x69,0x6E,0x33,0x32,0x20,
0x6F,0x6E,0x6C,0x79,0x21,0x0D,0x0A,0x24};
#define SIZESTUB2 12
char stub2[]={0x4D,0x5A,0x53,0x50,0x48,0x49,0x4E,0x58,
0x20,0x43,0x2D,0x2D};
unsigned int numdll,numapi;
unsigned char FixUpTable=FALSE; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᮧ<><E1AEA7><EFBFBD><EFBFBD><EFBFBD> ⠡<><E2A0A1><EFBFBD><EFBFBD> Fix UP for Windows
unsigned char WinMonoBlock=TRUE;
int numexport=0;
unsigned long ImageBase=0x400000;
unsigned long vsizeheader=0x1000; //<2F><><EFBFBD><EFBFBD>㠫<EFBFBD><E3A0AB><EFBFBD><EFBFBD> ࠧ<><E0A0A7><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
unsigned long FILEALIGN=0;//512; // <20><>ࠢ<EFBFBD><E0A0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᥪ権 <20> 䠩<><E4A0A9>
int filingzerope;
struct listexport *lexport=NULL;
static unsigned long sizestub;
static unsigned long numrs=1;
unsigned long Align(unsigned long size,unsigned long val)
{
if(val<2)return size;
val--;
return (size+val)&(~val);
}
/*
#include <conio.h>
void PrintMem(void *mem)
{
unsigned char *m,*n;
int i,j;
m=(unsigned char *)mem;
for(i=0;i<192;){
n=m;
for(j=0;j<16;j++,i++){
printf("%02X ",*m);
m++;
}
for(j=0;j<16;j++){
char c=*n;
n++;
if(c<0x20||c>0x7e)c='.';
putch(c);
}
puts("");
}
}
void CheckMem()
{
if(listdll!=NULL){ //<2F><><EFBFBD><EFBFBD> api-<2D><><EFBFBD><EFBFBD>
DLLLIST *newdll=listdll; //<2F><>砫<EFBFBD> ᯨ᪠ DLL
APIPROC *listapi=newdll->list;
idrec *rec=listapi->recapi;
PrintMem(rec);
}
} */
void AddJmpApi()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD> api <20><><EFBFBD>楤<EFBFBD><E6A5A4>
//<>४<EFBFBD><E0A5AA><EFBFBD><E0AEA2><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> ⠡<><E2A0A1><EFBFBD><EFBFBD> <20><>६<EFBFBD>饭<EFBFBD><E9A5AD>
alignersize+=AlignCD(CS,4);
if(listdll!=NULL){ //<2F><><EFBFBD><EFBFBD> api-<2D><><EFBFBD><EFBFBD>
DLLLIST *newdll=listdll; //<2F><>砫<EFBFBD> ᯨ᪠ DLL
numdll=numapi=0;
for(APIPROC *listapi=newdll->list;;){
unsigned short numapiprocdll=0; //<2F><> <20>ᯮ<EFBFBD><E1AFAE><EFBFBD>㥬<EFBFBD><E3A5AC> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD> <20><><EFBFBD>楤<EFBFBD><E6A5A4>
for(short i=0;i<newdll->num;i++){ //<2F><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD>楤<EFBFBD><E6A5A4><EFBFBD>
idrec *rec=(listapi+i)->recapi;
unsigned int idnum=rec->recnumber; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>䨪<EFBFBD><E4A8AA><EFBFBD><EFBFBD> ᯨ᪠
char useapi=FALSE; //䫠<> <20>ᯮ<EFBFBD>짮<EFBFBD><ECA7AE><EFBFBD><EFBFBD><EFBFBD>
for(unsigned int j=0;j<posts;j++){ //<2F><><EFBFBD><EFBFBD><EFBFBD> <20>ᯮ<EFBFBD>짮<EFBFBD><ECA7AE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>楤<EFBFBD><E6A5A4><EFBFBD>
if((postbuf+j)->num==idnum){
if((postbuf+j)->type==CALL_32){ //<2F><>諨
useapi=API_JMP; //䫠<> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
unsigned long hold=outptr-((postbuf+j)->loc+4); //<2F><><EFBFBD><EFBFBD><EFBFBD>ﭨ<EFBFBD> <20><> <20>맮<EFBFBD><EBA7AE>
*(long *)&output[(postbuf+j)->loc]=hold; //<2F><><EFBFBD>ࠢ<EFBFBD><E0A0A2><EFBFBD>
}
else if((postbuf+j)->type==CALL_32I){
useapi=API_FAST; //䫠<> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
numrel++;
}
}
}
if(useapi==API_JMP){ // <20><><EFBFBD>楤<EFBFBD><E6A5A4><EFBFBD> <20><><EFBFBD>뢠<EFBFBD><EBA2A0><EFBFBD><EFBFBD>
*(short *)&output[outptr]=0x25ff; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> JMP
outptr+=2;
rec->recnumber=outptr; //⥯<><E2A5AF><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>. <20><>窠 <20>室<EFBFBD>
AddReloc(CS); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20> ⠡<> <20><>६<EFBFBD>饭<EFBFBD><E9A5AD>
*(long *)&output[outptr]=0; //<2F><><EFBFBD><EFBFBD><EFBFBD> <20>맮<EFBFBD><EBA7AE>
outptr+=4;
numapi++; //<2F><>饥 <20><> <20>ᯮ<EFBFBD>짮<EFBFBD><ECA7AE><EFBFBD><EFBFBD><EFBFBD> api-<2D><><EFBFBD>楤<EFBFBD><E6A5A4>
numapiprocdll++; //<2F><> <20>ᯮ<EFBFBD>짮<EFBFBD><ECA7AE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>楤<EFBFBD><E6A5A4> <20> <20>⮩ DLL
}
else if(useapi==API_FAST){
numapi++; //<2F><>饥 <20><> <20>ᯮ<EFBFBD>짮<EFBFBD><ECA7AE><EFBFBD><EFBFBD><EFBFBD> api-<2D><><EFBFBD>楤<EFBFBD><E6A5A4>
numapiprocdll++; //<2F><> <20>ᯮ<EFBFBD>짮<EFBFBD><ECA7AE><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>楤<EFBFBD><E6A5A4> <20> <20>⮩ DLL
}
rec->recrm=useapi; //⨯ <20>맮<EFBFBD><EBA7AE> api; 0 - not used
if(rec->newid!=NULL){
free(rec->newid); //ᯨ᮪ <20><>ࠬ<EFBFBD><E0A0AC> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20>㦥<EFBFBD>
rec->newid=NULL;
}
}
newdll->num=numapiprocdll; //<2F><><EFBFBD>ࠢ<EFBFBD><E0A0A2><EFBFBD> <20><> ॠ<>쭮 <20>ᯮ<EFBFBD><E1AFAE><EFBFBD> <20><><EFBFBD>楤<EFBFBD><E6A5A4>
if(numapiprocdll==0){ //<2F> <20>⮩ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD> <20><> <20>ᯮ<EFBFBD><E1AFAE><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD>
|