60 bytes saved.
zlib exehead is now 35.5K. git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1172 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
parent
9ebe478bba
commit
83a4213bfb
4 changed files with 31 additions and 19 deletions
|
@ -164,7 +164,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
static char temp[512];
|
||||
DWORD l=left;
|
||||
if (l > 512) l=512;
|
||||
if (!ReadFile(g_db_hFile,temp,l,&l,NULL))
|
||||
if (!ReadSelfFile(temp,l,&l))
|
||||
{
|
||||
m_Err=_LANG_INVALIDCRC;
|
||||
#if defined(NSIS_CONFIG_CRC_SUPPORT) && defined(NSIS_CONFIG_VISIBLE_SUPPORT)
|
||||
|
@ -256,15 +256,15 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
|
|||
{
|
||||
DWORD l;
|
||||
int fcrc;
|
||||
SetFilePointer(g_db_hFile,m_pos,NULL,FILE_BEGIN);
|
||||
if (!ReadFile(g_db_hFile,&fcrc,4,&l,NULL) || crc != fcrc)
|
||||
SetSelfFilePointer(m_pos,FILE_BEGIN);
|
||||
if (!ReadSelfFile(&fcrc,4,&l) || crc != fcrc)
|
||||
{
|
||||
m_Err=_LANG_INVALIDCRC;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
#endif//NSIS_CONFIG_CRC_SUPPORT
|
||||
SetFilePointer(g_db_hFile,g_filehdrsize,NULL,FILE_BEGIN);
|
||||
SetSelfFilePointer(g_filehdrsize,FILE_BEGIN);
|
||||
|
||||
m_Err=loadHeaders();
|
||||
}
|
||||
|
|
|
@ -1355,8 +1355,8 @@ static int NSISCALL ExecuteEntry(entry *entry_)
|
|||
if (filebuf)
|
||||
{
|
||||
int fixoffs=0;
|
||||
SetFilePointer(g_db_hFile,0,NULL,FILE_BEGIN);
|
||||
ReadFile(g_db_hFile,(char*)filebuf,g_filehdrsize,&l,NULL);
|
||||
SetSelfFilePointer(0,FILE_BEGIN);
|
||||
ReadSelfFile((char*)filebuf,g_filehdrsize,&l);
|
||||
if (g_inst_header->uninstdata_offset != -1)
|
||||
{
|
||||
// Changed by Amir Szekely 11th July 2002
|
||||
|
|
|
@ -55,7 +55,7 @@ const char * NSISCALL loadHeaders(void)
|
|||
void *data;
|
||||
firstheader h;
|
||||
|
||||
if (!ReadFile(g_db_hFile,(LPVOID)&h,sizeof(h),&r,NULL) || r != sizeof(h) || !isheader(&h)) return _LANG_INVALIDCRC;
|
||||
if (!ReadSelfFile((LPVOID)&h,sizeof(h),&r) || r != sizeof(h) || !isheader(&h)) return _LANG_INVALIDCRC;
|
||||
|
||||
data=(void*)my_GlobalAlloc(h.length_of_header);
|
||||
|
||||
|
@ -75,7 +75,7 @@ const char * NSISCALL loadHeaders(void)
|
|||
return _LANG_ERRORWRITINGTEMP;
|
||||
}
|
||||
}
|
||||
dbd_srcpos=SetFilePointer(g_db_hFile,0,NULL,FILE_CURRENT);
|
||||
dbd_srcpos=SetSelfFilePointer(0,FILE_CURRENT);
|
||||
dbd_fulllen=dbd_srcpos-sizeof(h)+h.length_of_all_following_data-((h.flags&FH_FLAGS_CRC)?4:0);
|
||||
#endif
|
||||
#endif
|
||||
|
@ -87,7 +87,7 @@ const char * NSISCALL loadHeaders(void)
|
|||
}
|
||||
|
||||
#if !defined(NSIS_COMPRESS_WHOLE) || !defined(NSIS_CONFIG_COMPRESSION_SUPPORT)
|
||||
g_db_offset=SetFilePointer(g_db_hFile,0,NULL,FILE_CURRENT);
|
||||
g_db_offset=SetSelfFilePointer(0,FILE_CURRENT);
|
||||
#else
|
||||
g_db_offset=dbd_pos;
|
||||
#endif
|
||||
|
@ -137,7 +137,7 @@ static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int out
|
|||
if (offset>=0)
|
||||
{
|
||||
/*
|
||||
int lp=SetFilePointer(g_db_hFile,0,NULL,FILE_CURRENT);
|
||||
int lp=SetSelfFilePointer(0,FILE_CURRENT);
|
||||
if (lp > g_db_offset+offset)
|
||||
{
|
||||
char buf[1023];
|
||||
|
@ -145,10 +145,10 @@ static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int out
|
|||
MessageBox(NULL,buf,"seeking back",MB_OK);
|
||||
}
|
||||
*/
|
||||
SetFilePointer(g_db_hFile,g_db_offset+offset,NULL,FILE_BEGIN);
|
||||
SetSelfFilePointer(g_db_offset+offset,FILE_BEGIN);
|
||||
}
|
||||
|
||||
if (!ReadFile(g_db_hFile,(LPVOID)&input_len,sizeof(int),&r,NULL)) return -3;
|
||||
if (!ReadSelfFile((LPVOID)&input_len,sizeof(int),&r)) return -3;
|
||||
|
||||
#ifdef NSIS_CONFIG_COMPRESSION_SUPPORT
|
||||
else if (input_len & 0x80000000) // compressed
|
||||
|
@ -161,7 +161,7 @@ static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int out
|
|||
DWORD r;
|
||||
int err;
|
||||
|
||||
if (!ReadFile(g_db_hFile,(LPVOID)inbuffer,min(input_len,IBUFSIZE),&r,NULL)) return -3;
|
||||
if (!ReadSelfFile((LPVOID)inbuffer,min(input_len,IBUFSIZE),&r)) return -3;
|
||||
|
||||
g_inflate_stream.next_in = inbuffer;
|
||||
g_inflate_stream.avail_in = r;
|
||||
|
@ -205,7 +205,7 @@ static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int out
|
|||
while (input_len > 0)
|
||||
{
|
||||
DWORD t;
|
||||
if (!ReadFile(g_db_hFile,(LPVOID)inbuffer,min(input_len,outbuffer_len),&r,NULL)) return -3;
|
||||
if (!ReadSelfFile((LPVOID)inbuffer,min(input_len,outbuffer_len),&r)) return -3;
|
||||
if (!WriteFile(hFileOut,inbuffer,r,&t,NULL) || r!=t) return -2;
|
||||
retval+=r;
|
||||
input_len-=r;
|
||||
|
@ -213,7 +213,7 @@ static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int out
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!ReadFile(g_db_hFile,(LPVOID)outbuf,min(input_len,outbuflen),&r,NULL)) return -3;
|
||||
if (!ReadSelfFile((LPVOID)outbuf,min(input_len,outbuflen),&r)) return -3;
|
||||
retval=r;
|
||||
}
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ static int NSISCALL __ensuredata(int amount)
|
|||
int needed=amount-(dbd_size-dbd_pos);
|
||||
if (needed>0)
|
||||
{
|
||||
SetFilePointer(g_db_hFile,dbd_srcpos,NULL,FILE_BEGIN);
|
||||
SetSelfFilePointer(dbd_srcpos,FILE_BEGIN);
|
||||
SetFilePointer(dbd_hFile,dbd_size,NULL,FILE_BEGIN);
|
||||
m_length=needed;
|
||||
m_pos=0;
|
||||
|
@ -242,7 +242,7 @@ static int NSISCALL __ensuredata(int amount)
|
|||
{
|
||||
int err;
|
||||
DWORD or;
|
||||
if (!ReadFile(g_db_hFile,(LPVOID)_inbuffer,min(IBUFSIZE,dbd_fulllen-dbd_srcpos),&or,NULL)) return -1;
|
||||
if (!ReadSelfFile((LPVOID)_inbuffer,min(IBUFSIZE,dbd_fulllen-dbd_srcpos),&or)) return -1;
|
||||
dbd_srcpos+=or;
|
||||
g_inflate_stream.next_in=_inbuffer;
|
||||
g_inflate_stream.avail_in=or;
|
||||
|
@ -350,3 +350,13 @@ int NSISCALL GetCompressedDataFromDataBlockToMemory(int offset, char *out, int o
|
|||
{
|
||||
return _dodecomp(offset,NULL,out,out_len);
|
||||
}
|
||||
|
||||
BOOL NSISCALL ReadSelfFile(LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead)
|
||||
{
|
||||
return ReadFile(g_db_hFile,lpBuffer,nNumberOfBytesToRead,lpNumberOfBytesRead,NULL);
|
||||
}
|
||||
|
||||
DWORD NSISCALL SetSelfFilePointer(LONG lDistanceToMove, DWORD dwMoveMethod)
|
||||
{
|
||||
return SetFilePointer(g_db_hFile,lDistanceToMove,NULL,dwMoveMethod);
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ enum
|
|||
#ifdef NSIS_SUPPORT_FILE
|
||||
EW_EXTRACTFILE, // File to extract: 5,[overwriteflag, output filename, compressed filedata, filedatetimelow, filedatetimehigh]
|
||||
// overwriteflag: 0x1 = no. 0x0=force, 0x2=try, 0x3=if date is newer
|
||||
#endif
|
||||
#endif
|
||||
#ifdef NSIS_SUPPORT_DELETE
|
||||
EW_DELETEFILE, // Delete File: 2, [filename, rebootok]
|
||||
#endif
|
||||
|
@ -393,7 +393,7 @@ typedef struct
|
|||
// Adds the ability to make the inner text show up in a dialog item in the outer dialog.
|
||||
/*
|
||||
Useless
|
||||
|
||||
|
||||
WORD space_avail_id;
|
||||
WORD space_req_id;
|
||||
WORD dir_subtext_id;
|
||||
|
@ -478,6 +478,8 @@ extern int g_quit_flag;
|
|||
const char * NSISCALL GetStringFromStringTab(int offs);
|
||||
int NSISCALL GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut);
|
||||
int NSISCALL GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len);
|
||||
BOOL NSISCALL ReadSelfFile(LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead);
|
||||
DWORD NSISCALL SetSelfFilePointer(LONG lDistanceToMove, DWORD dwMoveMethod);
|
||||
|
||||
// $0..$9, $INSTDIR, etc are encoded as ASCII bytes starting from this value.
|
||||
#ifdef NSIS_CONFIG_PLUGIN_SUPPORT
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue