more updates yay

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1109 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
justin1014 2002-09-21 07:05:31 +00:00
parent c7876af9fc
commit 0001910df8
4 changed files with 17 additions and 20 deletions

View file

@ -41,11 +41,6 @@ extern unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf,
#ifdef NSIS_COMPRESS_WHOLE
extern HANDLE dbd_hFile;
#endif
#ifdef NSIS_CONFIG_CRC_SUPPORT
static const char *g_crcinvalid=_LANG_INVALIDCRC;
#else
static const char *g_crcinvalid=_LANG_INVALIDINST;
#endif
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
static const char *g_errorcopyinginstall=_LANG_UNINSTINITERROR;
@ -170,7 +165,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
if (l > 512) l=512;
if (!ReadFile(g_db_hFile,temp,l,&l,NULL))
{
m_Err=g_crcinvalid;
m_Err=_LANG_INVALIDCRC;
#if defined(NSIS_CONFIG_CRC_SUPPORT) && defined(NSIS_CONFIG_VISIBLE_SUPPORT)
if (hwnd) DestroyWindow(hwnd);
#endif//NSIS_CONFIG_CRC_SUPPORT
@ -187,7 +182,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
g_filehdrsize=m_pos;
if (dbl > left)
{
m_Err=g_crcinvalid;
m_Err=_LANG_INVALIDCRC;
goto end;
}
#if defined(NSIS_CONFIG_SILENT_SUPPORT) && defined(NSIS_CONFIG_VISIBLE_SUPPORT)
@ -252,7 +247,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
if (hwnd) DestroyWindow(hwnd);
#endif//NSIS_CONFIG_CRC_SUPPORT
#endif//NSIS_CONFIG_VISIBLE_SUPPORT
if (!g_filehdrsize) m_Err=g_crcinvalid;
if (!g_filehdrsize) m_Err=_LANG_INVALIDCRC;
else
{
#ifdef NSIS_CONFIG_CRC_SUPPORT
@ -263,14 +258,14 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
SetFilePointer(g_db_hFile,m_pos,NULL,FILE_BEGIN);
if (!ReadFile(g_db_hFile,&fcrc,4,&l,NULL) || crc != fcrc)
{
m_Err=g_crcinvalid;
m_Err=_LANG_INVALIDCRC;
goto end;
}
}
#endif//NSIS_CONFIG_CRC_SUPPORT
SetFilePointer(g_db_hFile,g_filehdrsize,NULL,FILE_BEGIN);
if (loadHeaders()) m_Err=g_crcinvalid;
m_Err=loadHeaders();
}
if (m_Err) goto end;

View file

@ -13,7 +13,7 @@
#include "../bzip2/bzlib.h"
static int bz2_needreinit;
#define z_stream bz_stream
#define inflateInit(x) { if (BZ2_bzDecompressInit(x)<0) return -1; }
#define inflateInit(x) { if (BZ2_bzDecompressInit(x)<0) return _LANG_INVALIDCRC; }
#define inflate(x) BZ2_bzDecompress(x)
#define inflateReset(x) { if (bz2_needreinit) { BZ2_bzDecompressEnd(x); inflateInit(x); } bz2_needreinit=1; }
#define Z_OK BZ_OK
@ -49,13 +49,13 @@ int NSISCALL isheader(firstheader *h)
static z_stream g_inflate_stream;
#endif
int NSISCALL loadHeaders(void)
const char * NSISCALL loadHeaders(void)
{
DWORD r;
void *data;
firstheader h;
if (!ReadFile(g_db_hFile,(LPVOID)&h,sizeof(h),&r,NULL) || r != sizeof(h) || !isheader(&h)) return -1;
if (!ReadFile(g_db_hFile,(LPVOID)&h,sizeof(h),&r,NULL) || r != sizeof(h) || !isheader(&h)) return _LANG_INVALIDCRC;
data=(void*)my_GlobalAlloc(h.length_of_header);
@ -72,8 +72,7 @@ int NSISCALL loadHeaders(void)
dbd_hFile=CreateFile(fno,GENERIC_WRITE|GENERIC_READ,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_TEMPORARY|FILE_FLAG_DELETE_ON_CLOSE,NULL);
if (dbd_hFile == INVALID_HANDLE_VALUE)
{
my_MessageBox("Error writing temp file",MB_OK);
return -1;
return _LANG_ERRORWRITINGTEMP;
}
}
dbd_srcpos=SetFilePointer(g_db_hFile,0,NULL,FILE_CURRENT);
@ -83,9 +82,8 @@ int NSISCALL loadHeaders(void)
if (GetCompressedDataFromDataBlockToMemory(-1,data,h.length_of_header) != h.length_of_header)
{
my_MessageBox(_LANG_CANTOPENSELF,MB_OK);
GlobalFree((HGLOBAL)data);
return -1;
return _LANG_INVALIDCRC;
}
#if !defined(NSIS_COMPRESS_WHOLE) || !defined(NSIS_CONFIG_COMPRESSION_SUPPORT)

View file

@ -470,7 +470,7 @@ int NSISCALL isheader(firstheader *h); // returns 0 on not header, length_of_dat
// returns 0 on success
// on success, m_header will be set to a pointer that should eventually be GlobalFree()'d.
// (or m_uninstheader)
int NSISCALL loadHeaders(void);
const char * NSISCALL loadHeaders(void);
extern HANDLE g_db_hFile;
extern int g_quit_flag;

View file

@ -1,14 +1,18 @@
#ifndef _NSIS_LANG_H_
#define _NSIS_LANG_H_
// generic startup strings (these will never be overridable)
#ifdef NSIS_CONFIG_CRC_SUPPORT
#define _LANG_INVALIDCRC "Installer corrupted or incomplete.\r\n\r\n" \
"This could be the result of a failed download or corruption from a virus." \
"\r\n\r\nIf desperate, try the /NCRC command line switch (NOT recommended)"
#define _LANG_INVALIDINST "Installer corrupted.\r\n\r\n" \
#else
#define _LANG_INVALIDCRC "Installer corrupted.\r\n\r\n" \
"This could be the result of an incomplete download"
#endif
#define _LANG_ERRORWRITINGTEMP "Error writing temp file"
#define _LANG_UNINSTINITERROR "Error launching installer"