From 34db30b2ce45d924c3de1112753f3ad16c4ac06c Mon Sep 17 00:00:00 2001 From: eccles Date: Mon, 19 Aug 2002 23:18:19 +0000 Subject: [PATCH] Instant saving of 0.5K - use of stdcall calling convention to reduce code overhead associated with managing the stack git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@694 212acab6-be3b-0410-9dea-997c60f758d6 --- Source/build.h | 12 +++---- Source/crc32.c | 2 +- Source/exehead/Main.c | 2 +- Source/exehead/Ui.c | 30 +++++++++--------- Source/exehead/bgbg.c | 2 +- Source/exehead/config.h | 24 +++++++++++--- Source/exehead/exec.c | 14 ++++----- Source/exehead/exec.h | 4 +-- Source/exehead/exehead-bzip2.dsp | 11 ++++++- Source/exehead/exehead-zlib.dsp | 11 ++++++- Source/exehead/fileform.c | 20 ++++++------ Source/exehead/fileform.h | 10 +++--- Source/exehead/ui.h | 10 ++++-- Source/exehead/util.c | 54 ++++++++++++++++---------------- Source/exehead/util.h | 50 ++++++++++++++--------------- Source/zlib/INFLATE.C | 6 ++-- Source/zlib/ZLIB.H | 10 +++--- 17 files changed, 154 insertions(+), 118 deletions(-) diff --git a/Source/build.h b/Source/build.h index 4bcbfb2e..8205b4ad 100644 --- a/Source/build.h +++ b/Source/build.h @@ -26,7 +26,7 @@ using namespace std; #ifdef NSIS_CONFIG_CRC_SUPPORT extern "C" { - unsigned long CRC32(unsigned long crc, const unsigned char *buf, unsigned int len); + unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len); }; #endif @@ -40,7 +40,7 @@ extern "C" #define IS_PS_ELSE(x) (( x ) >= PS_ELSE && ( x ) <= PS_ELSE_IF1) class CEXEBuild { - public: + public: CEXEBuild(); ~CEXEBuild(); @@ -60,7 +60,7 @@ class CEXEBuild { // it is as if they are concatenated) int process_script(FILE *fp, char *curfilename, int *lineptr); int process_oneline(char *line, char *curfilename, int lineptr); - + // you only get to call write_output once, so use it wisely. int write_output(void); @@ -160,7 +160,7 @@ class CEXEBuild { int has_called_write_output; char build_packname[1024], build_packcmd[1024]; - int build_overwrite, build_compress, build_crcchk, + int build_overwrite, build_compress, build_crcchk, build_datesave, build_optimize_datablock; header build_header; @@ -178,7 +178,7 @@ class CEXEBuild { StringList m_macro_entry; - int db_opt_save, db_comp_save, db_full_size, db_opt_save_u, + int db_opt_save, db_comp_save, db_full_size, db_opt_save_u, db_comp_save_u, db_full_size_u; int build_sections_req,build_sections_div; @@ -193,7 +193,7 @@ class CEXEBuild { StringList build_strlist,ubuild_strlist; MMapBuf build_datablock, ubuild_datablock; // use GrowBuf here instead of MMapBuf if you want - IGrowBuf *cur_datablock; + IGrowBuf *cur_datablock; unsigned char *header_data_new; int exeheader_size_new; diff --git a/Source/crc32.c b/Source/crc32.c index f6543665..06a4291e 100644 --- a/Source/crc32.c +++ b/Source/crc32.c @@ -2,7 +2,7 @@ #ifdef NSIS_CONFIG_CRC_SUPPORT // this is based on the (slow,small) CRC32 implementation from zlib. -unsigned long CRC32(unsigned long crc, const unsigned char *buf, unsigned int len) +unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len) { static unsigned long crc_table[256]; diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c index 223bc184..ec5c77fd 100644 --- a/Source/exehead/Main.c +++ b/Source/exehead/Main.c @@ -33,7 +33,7 @@ #include "ui.h" #include "lang.h" -extern unsigned long CRC32(unsigned long crc, const unsigned char *buf, unsigned int len); +extern unsigned long NSISCALL CRC32(unsigned long crc, const unsigned char *buf, unsigned int len); #if !defined(NSIS_CONFIG_VISIBLE_SUPPORT) && !defined(NSIS_CONFIG_SILENT_SUPPORT) #error One of NSIS_CONFIG_SILENT_SUPPORT or NSIS_CONFIG_VISIBLE_SUPPORT must be defined. diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c index e6470304..c2027cbb 100644 --- a/Source/exehead/Ui.c +++ b/Source/exehead/Ui.c @@ -83,7 +83,7 @@ static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l static DWORD WINAPI install_thread(LPVOID p); -HWND bgWnd_Init(HINSTANCE hInstance, char *title, int color1, int color2, int); +HWND NSISCALL bgWnd_Init(HINSTANCE hInstance, char *title, int color1, int color2, int); HWND insthwnd, insthwnd2,insthwndbutton; @@ -104,30 +104,30 @@ HWND m_curwnd; static int m_whichcfg; #ifdef NSIS_CONFIG_VISIBLE_SUPPORT -static BOOL SetDlgItemTextFromLang(HWND dlg, WORD id, langid_t lid) { +static BOOL NSISCALL SetDlgItemTextFromLang(HWND dlg, WORD id, langid_t lid) { return SetDlgItemText(dlg,id,STR(GetLangString(lid))); } -static BOOL SetUITextFromLang(HWND defhw, WORD def, WORD custom, langid_t lid) { - return SetDlgItemTextFromLang(custom?g_hwnd:defhw,custom?custom:def,lid); +static BOOL NSISCALL SetUITextFromLang(HWND defhw, WORD def, WORD custom, langid_t lid) { + return SetDlgItemTextFromLang(custom?g_hwnd:defhw,(WORD)(custom?custom:def),lid); } // no tab -static BOOL SetUITextNT(HWND defhw, WORD def, WORD custom, const char *text) { +static BOOL NSISCALL SetUITextNT(HWND defhw, WORD def, WORD custom, const char *text) { return SetDlgItemText(custom?g_hwnd:defhw,custom?custom:def,text); } -static UINT GetUIText(WORD def, WORD custom, char *str, int max_size) { +static UINT NSISCALL GetUIText(WORD def, WORD custom, char *str, int max_size) { return GetDlgItemText(custom?g_hwnd:m_curwnd,custom?custom:def,str,max_size); } -static HWND GetUIItem(HWND defhw, WORD def, WORD custom) { +static HWND NSISCALL GetUIItem(HWND defhw, WORD def, WORD custom) { return GetDlgItem(custom?g_hwnd:defhw,custom?custom:def); } #endif #ifdef NSIS_CONFIG_LOG -static void build_g_logfile() +void NSISCALL build_g_logfile() { addtrailingslash(mystrcpy(g_log_file,state_install_directory)); lstrcat(g_log_file,"install.log"); @@ -135,7 +135,7 @@ static void build_g_logfile() #endif #ifdef NSIS_CONFIG_COMPONENTPAGE -static void SetChildrenStates(HWND hWnd, TV_ITEM *pItem, int iState) { +static void NSISCALL SetChildrenStates(HWND hWnd, TV_ITEM *pItem, int iState) { HTREEITEM hItem; int l=0; @@ -165,7 +165,7 @@ static void SetChildrenStates(HWND hWnd, TV_ITEM *pItem, int iState) { } } -static void SetParentState(HWND hWnd, TV_ITEM *pItem) { +static void NSISCALL SetParentState(HWND hWnd, TV_ITEM *pItem) { HTREEITEM hItem; int iState = 0, iStatePrev = 0; @@ -204,7 +204,7 @@ static void SetParentState(HWND hWnd, TV_ITEM *pItem) { } -static void CheckTreeItem(HWND hWnd, TV_ITEM *pItem, int checked) { +static void NSISCALL CheckTreeItem(HWND hWnd, TV_ITEM *pItem, int checked) { HTREEITEM hItem = pItem->hItem; int l=0; @@ -227,7 +227,7 @@ static void CheckTreeItem(HWND hWnd, TV_ITEM *pItem, int checked) { #endif//NSIS_CONFIG_COMPONENTPAGE -int ui_doinstall(void) +int NSISCALL ui_doinstall(void) { g_autoclose=g_inst_cmnheader->misc_flags&1; #ifdef NSIS_CONFIG_UNINSTALL_SUPPORT @@ -641,7 +641,7 @@ static BOOL CALLBACK UninstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l #endif -static void inttosizestr(int kb, char *str) +static void NSISCALL inttosizestr(int kb, char *str) { str += mystrlen(str); if (kb < 1024) wsprintf(str,"%dKB",kb); @@ -1130,12 +1130,12 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar int ui_st_updateflag=0x3; -void update_status_text_from_lang(langid_t id, const char *text2) +void NSISCALL update_status_text_from_lang(langid_t id, const char *text2) { update_status_text(STR(GetLangString(id)), text2); } -void update_status_text(const char *text1, const char *text2) +void NSISCALL update_status_text(const char *text1, const char *text2) { static LVITEM new_item = {LVIF_TEXT,0,0,0,0,ps_tmpbuf}; RECT r; diff --git a/Source/exehead/bgbg.c b/Source/exehead/bgbg.c index 97fd6cf7..8bae6a93 100644 --- a/Source/exehead/bgbg.c +++ b/Source/exehead/bgbg.c @@ -62,7 +62,7 @@ static LRESULT CALLBACK BG_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l } -HWND bgWnd_Init(HINSTANCE hInstance, char *title, int color1, int color2, int color3) +HWND NSISCALL bgWnd_Init(HINSTANCE hInstance, char *title, int color1, int color2, int color3) { RECT vp; char classname[4]="_Nb"; diff --git a/Source/exehead/config.h b/Source/exehead/config.h index 109f498a..1d98008a 100644 --- a/Source/exehead/config.h +++ b/Source/exehead/config.h @@ -3,6 +3,22 @@ #ifndef APSTUDIO_INVOKED // keep msdev's resource editor from mangling the .rc file +// Added by Dave Laundon 19th August 2002 +// For all internal functions, use of stdcall calling convention moves the +// responsibility for tidying the stack to callee from caller, reducing the code +// involved considerably. Gives an instant saving of 0.5K. +// NB - the zlib and bzip2 portions have been given the same treatment, but with +// project compiler-options settings and/or project-wide defines. +// NB - safer for NSIS's routines to be defined explicitly to avoid problems +// calling DLL functions. +#if defined(_WIN32) && ((_MSC_VER >= 800) || defined(_STDCALL_SUPPORTED)) +#define NSISCALL __stdcall // Ordinary functions +#define NSISCALLV __cdecl // Variable-argument-list functions +#else +#define NSISCALL +#define NSISCALLV +#endif + // NSIS_MAX_STRLEN defines the maximum string length for internal variables // and stack entries. 1024 should be plenty, but if you are doing crazy registry // shit, you might want to bump it up. Generally it adds about 16-32x the memory, @@ -11,13 +27,13 @@ #define NSIS_MAX_STRLEN 1024 -// NSIS_MAX_INST_TYPES specified the maximum install types. +// NSIS_MAX_INST_TYPES specified the maximum install types. // note that this should not exceed 30, ever. #define NSIS_MAX_INST_TYPES 8 // NSIS_CONFIG_UNINSTALL_SUPPORT enables the uninstaller // support. Comment it out if your installers don't need -// uninstallers +// uninstallers // adds approximately 2kb. #define NSIS_CONFIG_UNINSTALL_SUPPORT @@ -66,7 +82,7 @@ // the expense of speed. not recommended. // #define NSIS_COMPRESS_BZIP2_SMALLMODE - // if NSIS_COMPRESS_BZIP2_LEVEL is defined, it overrides the default bzip2 + // if NSIS_COMPRESS_BZIP2_LEVEL is defined, it overrides the default bzip2 // compression window size of 9 (1-9 is valid) // 9 uses the most memory, but typically compresses best (recommended). // 1 uses the least memory, but typically compresses the worst. @@ -196,7 +212,7 @@ // temporary file name. // - Any parameters following the command will be pushed onto // the stack in left to right order. -// - The command will then be invoked in the dll as if +// - The command will then be invoked in the dll as if // "CallInstDLL dll command" had been invoked. // - When the installer exits any extracted temporary dlls will // be deleted. diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c index 895fd12d..13c461ac 100644 --- a/Source/exehead/exec.c +++ b/Source/exehead/exec.c @@ -39,7 +39,7 @@ char plugins_temp_dir[NSIS_MAX_STRLEN]=""; extern HWND m_curwnd; -static WIN32_FIND_DATA *file_exists(char *buf) +static WIN32_FIND_DATA * NSISCALL file_exists(char *buf) { HANDLE h; static WIN32_FIND_DATA fd; @@ -56,7 +56,7 @@ static WIN32_FIND_DATA *file_exists(char *buf) // based loosely on code from Tim Kosse // in win9x this isn't necessary (RegDeleteKey() can delete a tree of keys), // but in win2k you need to do this manually. -static LONG myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty) +static LONG NSISCALL myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty) { HKEY key; int retval=RegOpenKeyEx(thiskey,lpSubKey,0,KEY_ALL_ACCESS,&key); @@ -82,15 +82,15 @@ static LONG myRegDeleteKeyEx(HKEY thiskey, LPCTSTR lpSubKey, int onlyifempty) extern char g_all_user_var_flag; -static int ExecuteEntry(entry *entries, int pos); +static int NSISCALL ExecuteEntry(entry *entries, int pos); -static int resolveaddr(int v) +static int NSISCALL resolveaddr(int v) { if (v<0) return myatoi(g_usrvars[-(v+1)]); // if <0, that means we return v; } -int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress) +int NSISCALL ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress) { while (pos >= 0) { @@ -124,7 +124,7 @@ int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress) // returns EXEC_ERROR on error // returns 0, advance position by 1 // otherwise, returns new_position+1 -static int ExecuteEntry(entry *entries, int pos) +static int NSISCALL ExecuteEntry(entry *entries, int pos) { static char buf[NSIS_MAX_STRLEN],buf2[NSIS_MAX_STRLEN],buf3[NSIS_MAX_STRLEN],buf4[NSIS_MAX_STRLEN]; int *parms=entries[pos].offsets; @@ -1301,7 +1301,7 @@ static int ExecuteEntry(entry *entries, int pos) log_printf2("settings logging to %d",parms[1]); log_dolog=parms[1]; log_printf2("logging set to %d",parms[1]); - if (!g_log_file && log_dolg) build_g_logfile(); + if (!g_log_file && log_dolog) build_g_logfile(); } else { diff --git a/Source/exehead/exec.h b/Source/exehead/exec.h index cc4d7234..46ed4951 100644 --- a/Source/exehead/exec.h +++ b/Source/exehead/exec.h @@ -1,7 +1,7 @@ #ifndef _EXEC_H_ #define _EXEC_H_ -int ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress); // returns 0 on success +int NSISCALL ExecuteCodeSegment(entry *entries, int pos, HWND hwndProgress); // returns 0 on success -#endif//_EXEC_H_ \ No newline at end of file +#endif//_EXEC_H_ diff --git a/Source/exehead/exehead-bzip2.dsp b/Source/exehead/exehead-bzip2.dsp index 3fc0a9a4..7ea06eee 100644 --- a/Source/exehead/exehead-bzip2.dsp +++ b/Source/exehead/exehead-bzip2.dsp @@ -39,7 +39,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /Gd /W3 /GX /O1 /Oy /D "_WINDOWS" /D "EXEHEAD" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /D "NSIS_COMPRESS_USE_BZIP2" /FD /c +# ADD CPP /nologo /W3 /GX /O1 /Oy /D "_WINDOWS" /D "EXEHEAD" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /D "NSIS_COMPRESS_USE_BZIP2" /FD /c # SUBTRACT CPP /Fr /YX /Yc /Yu # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -96,22 +96,27 @@ SOURCE=..\zlib\Zlib.h # Begin Source File SOURCE=..\zlib\INFBLOCK.C +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\zlib\INFCODES.C +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\zlib\INFLATE.C +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\zlib\INFTREES.C +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\zlib\INFUTIL.C +# ADD CPP /Gz # End Source File # End Group # Begin Group "bzip2" @@ -120,6 +125,7 @@ SOURCE=..\zlib\INFUTIL.C # Begin Source File SOURCE=..\bzip2\bzlib.c +# ADD CPP /Gz # End Source File # Begin Source File @@ -132,14 +138,17 @@ SOURCE=..\bzip2\bzlib_private.h # Begin Source File SOURCE=..\bzip2\decompress.c +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\bzip2\huffman.c +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\bzip2\randtable.c +# ADD CPP /Gz # End Source File # End Group # Begin Source File diff --git a/Source/exehead/exehead-zlib.dsp b/Source/exehead/exehead-zlib.dsp index ac75bfe7..c3acf95e 100644 --- a/Source/exehead/exehead-zlib.dsp +++ b/Source/exehead/exehead-zlib.dsp @@ -39,7 +39,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /Gd /W3 /GX /O1 /Oy /D "_WINDOWS" /D "EXEHEAD" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /D "NSIS_COMPRESS_USE_ZLIB" /FD /c +# ADD CPP /nologo /W3 /GX /O1 /Oy /D "_WINDOWS" /D "EXEHEAD" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "WIN32_LEAN_AND_MEAN" /D "NSIS_COMPRESS_USE_ZLIB" /D ZEXPORT=__stdcall /FD /c # SUBTRACT CPP /Fr /YX /Yc /Yu # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -96,22 +96,27 @@ SOURCE=..\zlib\Zlib.h # Begin Source File SOURCE=..\zlib\INFBLOCK.C +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\zlib\INFCODES.C +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\zlib\INFLATE.C +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\zlib\INFTREES.C +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\zlib\INFUTIL.C +# ADD CPP /Gz # End Source File # End Group # Begin Group "bzip2" @@ -120,6 +125,7 @@ SOURCE=..\zlib\INFUTIL.C # Begin Source File SOURCE=..\bzip2\bzlib.c +# ADD CPP /Gz # End Source File # Begin Source File @@ -132,14 +138,17 @@ SOURCE=..\bzip2\bzlib_private.h # Begin Source File SOURCE=..\bzip2\decompress.c +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\bzip2\huffman.c +# ADD CPP /Gz # End Source File # Begin Source File SOURCE=..\bzip2\randtable.c +# ADD CPP /Gz # End Source File # End Group # Begin Source File diff --git a/Source/exehead/fileform.c b/Source/exehead/fileform.c index 457b9ca7..fc49053d 100644 --- a/Source/exehead/fileform.c +++ b/Source/exehead/fileform.c @@ -33,7 +33,7 @@ HANDLE dbd_hFile=INVALID_HANDLE_VALUE; static int dbd_size, dbd_pos, dbd_srcpos, dbd_fulllen; #endif//NSIS_COMPRESS_WHOLE -int isheader(firstheader *h) +int NSISCALL isheader(firstheader *h) { if ((h->flags & (~FH_FLAGS_MASK)) || h->siginfo != FH_SIG || @@ -48,7 +48,7 @@ int isheader(firstheader *h) static z_stream g_inflate_stream; #endif -int loadHeaders(void) +int NSISCALL loadHeaders(void) { DWORD r; void *data; @@ -70,7 +70,7 @@ int loadHeaders(void) GetTempPath(sizeof(fn),fn); GetTempFileName(fn,"nsi",0,fno); 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) + if (dbd_hFile == INVALID_HANDLE_VALUE) { my_MessageBox("Error writing temp file",MB_OK); return -1; @@ -111,7 +111,7 @@ int loadHeaders(void) return 0; } -const char *GetStringFromStringTab(int offs) +const char * NSISCALL GetStringFromStringTab(int offs) { if (offs < 0) return ""; return g_db_strtab+offs; @@ -124,7 +124,7 @@ const char *GetStringFromStringTab(int offs) #ifndef NSIS_COMPRESS_WHOLE -static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) +static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) { static char inbuffer[IBUFSIZE+OBUFSIZE]; char *outbuffer; @@ -135,7 +135,7 @@ static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) outbuffer = outbuf?outbuf:(inbuffer+IBUFSIZE); - if (offset>=0) + if (offset>=0) { /* int lp=SetFilePointer(g_db_hFile,0,NULL,FILE_CURRENT); @@ -224,7 +224,7 @@ static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) static char _inbuffer[IBUFSIZE]; static char _outbuffer[OBUFSIZE]; -static int __ensuredata(int amount) +static int NSISCALL __ensuredata(int amount) { int needed=amount-(dbd_size-dbd_pos); if (needed>0) @@ -270,7 +270,7 @@ static int __ensuredata(int amount) } -static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) +static int NSISCALL _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) { DWORD r; int input_len; @@ -312,12 +312,12 @@ static int _dodecomp(int offset, HANDLE hFileOut, char *outbuf, int outbuflen) #endif//NSIS_COMPRESS_WHOLE -int GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut) +int NSISCALL GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut) { return _dodecomp(offset,hFileOut,NULL,0); } -int GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len) +int NSISCALL GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len) { return _dodecomp(offset,NULL,out,out_len); } diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h index ad18904f..72c2ef1e 100644 --- a/Source/exehead/fileform.h +++ b/Source/exehead/fileform.h @@ -393,20 +393,20 @@ typedef struct // the following are only used/implemented in exehead, not makensis. -int isheader(firstheader *h); // returns 0 on not header, length_of_datablock on success +int NSISCALL isheader(firstheader *h); // returns 0 on not header, length_of_datablock on success // returns nonzero on error // returns 0 on success // on success, m_header will be set to a pointer that should eventually be GlobalFree()'d. // (or m_uninstheader) -int loadHeaders(void); +int NSISCALL loadHeaders(void); extern HANDLE g_db_hFile; extern int g_quit_flag; -const char *GetStringFromStringTab(int offs); -int GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut); -int GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len); +const char * NSISCALL GetStringFromStringTab(int offs); +int NSISCALL GetCompressedDataFromDataBlock(int offset, HANDLE hFileOut); +int NSISCALL GetCompressedDataFromDataBlockToMemory(int offset, char *out, int out_len); // $0..$9, $INSTDIR, etc are encoded as ASCII bytes starting from this value. #ifdef NSIS_CONFIG_PLUGIN_SUPPORT diff --git a/Source/exehead/ui.h b/Source/exehead/ui.h index f3a5437c..90d00042 100644 --- a/Source/exehead/ui.h +++ b/Source/exehead/ui.h @@ -7,9 +7,9 @@ extern common_strings *cur_common_strings_table; extern char *cur_install_strings_table; // installer_strings/uninstall_strings depending on installer type -int ui_doinstall(void); -void update_status_text_from_lang(langid_t id, const char *text2); -void update_status_text(const char *text1, const char *text2); +int NSISCALL ui_doinstall(void); +void NSISCALL update_status_text_from_lang(langid_t id, const char *text2); +void NSISCALL update_status_text(const char *text1, const char *text2); extern int ui_st_updateflag; extern char g_autoclose; @@ -25,4 +25,8 @@ extern entry *g_inst_entry; extern int g_is_uninstaller; #endif +#ifdef NSIS_CONFIG_LOG +void NSISCALL build_g_logfile(void); +#endif + #endif//_UI_H_ diff --git a/Source/exehead/util.c b/Source/exehead/util.c index 461597d4..58c71ebe 100644 --- a/Source/exehead/util.c +++ b/Source/exehead/util.c @@ -20,7 +20,7 @@ char g_usrvars[24][NSIS_MAX_STRLEN]; HANDLE g_hInstance; -HANDLE myCreateProcess(char *cmd, char *dir) +HANDLE NSISCALL myCreateProcess(char *cmd, char *dir) { PROCESS_INFORMATION ProcInfo={0,}; STARTUPINFO StartUp={sizeof(StartUp),}; @@ -30,12 +30,12 @@ HANDLE myCreateProcess(char *cmd, char *dir) return ProcInfo.hProcess; } -int my_MessageBox(const char *text, UINT type) { +int NSISCALL my_MessageBox(const char *text, UINT type) { return MessageBox(g_hwnd, text, g_caption, type); } #ifdef NSIS_SUPPORT_RMDIR -void doRMDir(char *buf, int recurse) +void NSISCALL doRMDir(char *buf, int recurse) { if (recurse && is_valid_instpath(buf)) { @@ -72,17 +72,17 @@ void doRMDir(char *buf, int recurse) } #endif//NSIS_SUPPORT_RMDIR -void addtrailingslash(char *str) +void NSISCALL addtrailingslash(char *str) { if (lastchar(str)!='\\') lstrcat(str,"\\"); } -char lastchar(const char *str) +char NSISCALL lastchar(const char *str) { return *CharPrev(str,str+mystrlen(str)); } -void trimslashtoend(char *buf) +void NSISCALL trimslashtoend(char *buf) { char *p=scanendslash(buf); if (pstate == Z_NULL) return Z_STREAM_ERROR; @@ -42,7 +42,7 @@ int inflateReset(z_streamp z) } -int inflateInit(z_streamp z) +int ZEXPORT inflateInit(z_streamp z) { int inflate_blocks_getssize(void); void inflate_blocks_init(z_streamp z,inflate_blocks_statef *s); @@ -57,7 +57,7 @@ int inflateInit(z_streamp z) } -int inflate(z_streamp z) +int ZEXPORT inflate(z_streamp z) { return inflate_blocks(&z->state->blocks, z, Z_OK); } diff --git a/Source/zlib/ZLIB.H b/Source/zlib/ZLIB.H index 83d0864c..522b95c5 100644 --- a/Source/zlib/ZLIB.H +++ b/Source/zlib/ZLIB.H @@ -1,6 +1,6 @@ /* - Note: this version of zlib has been hacked up quite a bit in order to reduce - the size of the EXE header and to remove what we didn't need. + Note: this version of zlib has been hacked up quite a bit in order to reduce + the size of the EXE header and to remove what we didn't need. For the complete real thing, go to: http://www.info-zip.org/pub/infozip/zlib/ @@ -115,7 +115,7 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); -int inflate(z_streamp z); +int ZEXPORT inflate(z_streamp z); ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, int level, @@ -126,7 +126,7 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -int inflateReset(z_streamp z); +int ZEXPORT inflateReset(z_streamp z); /* various hacks, don't look :) */ @@ -147,8 +147,6 @@ ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, #define deflateInit(strm, level) \ deflateInit_((strm), (level), "", sizeof(z_stream)) -extern int inflateInit(z_streamp z); - #ifdef __cplusplus }