From 0001910df80de4c429e74908dca68ff1d0232677 Mon Sep 17 00:00:00 2001 From: justin1014 Date: Sat, 21 Sep 2002 07:05:31 +0000 Subject: [PATCH] more updates yay git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@1109 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/exehead/Main.c | 15 +++++---------- Source/exehead/fileform.c | 12 +++++------- Source/exehead/fileform.h | 2 +- Source/exehead/lang.h | 8 ++++++-- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index d35858d4..d93bf1ab 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -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; diff --git a/Source/exehead/fileform.c b/Source/exehead/fileform.c index 579bb672..05d6001a 100644 --- a/Source/exehead/fileform.c +++ b/Source/exehead/fileform.c @@ -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) diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index 4885069c..b2cfc759 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -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; diff --git a/Source/exehead/lang.h b/Source/exehead/lang.h index dbc7f67e..69ae15d8 100644 --- a/Source/exehead/lang.h +++ b/Source/exehead/lang.h @@ -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"