summaryrefslogtreecommitdiff
path: root/Source/exehead
diff options
context:
space:
mode:
Diffstat (limited to 'Source/exehead')
-rwxr-xr-xSource/exehead/Main.c115
-rwxr-xr-xSource/exehead/Ui.c65
-rwxr-xr-xSource/exehead/afxres.h16
-rwxr-xr-xSource/exehead/bgbg.c16
-rwxr-xr-xSource/exehead/components.c16
-rwxr-xr-xSource/exehead/components.h16
-rwxr-xr-xSource/exehead/config.h16
-rwxr-xr-xSource/exehead/exec.c52
-rwxr-xr-xSource/exehead/exec.h16
-rwxr-xr-xSource/exehead/fileform.c38
-rwxr-xr-xSource/exehead/fileform.h24
-rwxr-xr-xSource/exehead/lang.h16
-rwxr-xr-xSource/exehead/state.h16
-rwxr-xr-xSource/exehead/ui.h17
-rwxr-xr-xSource/exehead/util.c118
-rwxr-xr-xSource/exehead/util.h18
16 files changed, 381 insertions, 194 deletions
diff --git a/Source/exehead/Main.c b/Source/exehead/Main.c
index fa61105..3630a18 100755
--- a/Source/exehead/Main.c
+++ b/Source/exehead/Main.c
@@ -1,35 +1,18 @@
-/*
-
- Nullsoft Scriptable Install System (NSIS)
- main.c - executable header main code
-
- Copyright (C) 1999-2006 Nullsoft, Inc.
-
- This license applies to everything in the NSIS package, except where otherwise noted.
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- This is the zlib/libpng license, which is approved by opensource.org.
-
- Portions Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler (zlib).
- Portions Copyright (C) 1996-2002 Julian R Seward (bzip2).
- Portions Copyright (C) 1999-2003 Igor Pavlov (lzma).
-
-*/
+/*
+ * main.c: executable header main code
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
#include "../Platform.h"
#include <shlobj.h>
@@ -65,8 +48,8 @@ char *ValidateTempDir()
return NULL;
addtrailingslash(state_temp_dir);
CreateDirectory(state_temp_dir, NULL);
- // state_command_line is used as a temp var here
- return my_GetTempFileName(state_command_line, state_temp_dir);
+ // state_language is used as a temp var here
+ return my_GetTempFileName(state_language, state_temp_dir);
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, int nCmdShow)
@@ -112,18 +95,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
mystrcpy(g_caption,_LANG_GENERIC_ERROR);
- GetTempPath(NSIS_MAX_STRLEN, state_temp_dir);
- if (!ValidateTempDir())
- {
- GetWindowsDirectory(state_temp_dir, NSIS_MAX_STRLEN - 5); // leave space for \Temp
- mystrcat(state_temp_dir, "\\Temp");
- if (!ValidateTempDir())
- {
- goto end;
- }
- }
- DeleteFile(state_command_line);
-
mystrcpy(state_command_line, GetCommandLine());
#ifdef NSIS_CONFIG_VISIBLE_SUPPORT
@@ -169,7 +140,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
if (*(LPDWORD)(cmdline-2) == CHAR4_TO_DWORD(' ', '/', 'D','='))
{
- cmdline[-2]=0; // keep this from being passed to uninstaller if necessary
+ *(LPDWORD)(cmdline-2)=0; // keep this from being passed to uninstaller if necessary
mystrcpy(state_install_directory,cmdline+2);
break; // /D= must always be last
}
@@ -182,6 +153,18 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
cmdline++;
}
+ GetTempPath(NSIS_MAX_STRLEN, state_temp_dir);
+ if (!ValidateTempDir())
+ {
+ GetWindowsDirectory(state_temp_dir, NSIS_MAX_STRLEN - 5); // leave space for \Temp
+ mystrcat(state_temp_dir, "\\Temp");
+ if (!ValidateTempDir())
+ {
+ goto end;
+ }
+ }
+ DeleteFile(state_language);
+
m_Err = loadHeaders(cl_flags);
if (m_Err) goto end;
@@ -214,44 +197,42 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
else
{
int x;
+ char s[] = "Au_.exe";
- mystrcat(state_temp_dir,"~nsu.tmp\\");
+ mystrcat(state_temp_dir,"~nsu.tmp");
CreateDirectory(state_temp_dir,NULL);
+ if (!state_install_directory[0])
+ mystrcpy(state_install_directory,state_exe_directory);
+
+ mystrcpy(g_usrvars[0], realcmds);
+ mystrcpy(g_usrvars[1], s);
+
for (x = 0; x < 26; x ++)
{
- static char s[]="Au_.exe";
- static char buf2[NSIS_MAX_STRLEN*2];
+ static char buf2[NSIS_MAX_STRLEN];
static char ibuf[NSIS_MAX_STRLEN];
- *(LPWORD)buf2=CHAR2_TO_WORD('\"',0);
- mystrcat(buf2,state_temp_dir);
- mystrcat(buf2,s);
+ GetNSISString(buf2,g_header->str_uninstchild); // $TEMP\$1
- DeleteFile(buf2+1); // clean up after all the other ones if they are there
+ DeleteFile(buf2); // clean up after all the other ones if they are there
if (m_Err) // not done yet
{
// get current name
- int l=GetModuleFileName(g_hInstance,ibuf,sizeof(ibuf));
- // check if it is ?Au_.exe - if so, fuck it
+ int l=GetModuleFileName(NULL,ibuf,sizeof(ibuf));
+ // check if it is ?u_.exe - if so, fuck it
if (!lstrcmpi(ibuf+l-(sizeof(s)-2),s+1)) break;
// copy file
- if (CopyFile(ibuf,buf2+1,FALSE))
+ if (CopyFile(ibuf,buf2,TRUE))
{
HANDLE hProc;
#ifdef NSIS_SUPPORT_MOVEONREBOOT
- MoveFileOnReboot(buf2+1,NULL);
+ MoveFileOnReboot(buf2,NULL);
+ MoveFileOnReboot(state_temp_dir,NULL);
#endif
- if (state_install_directory[0]) mystrcpy(ibuf,state_install_directory);
- else trimslashtoend(ibuf);
- mystrcat(buf2,"\" ");
- mystrcat(buf2,realcmds);
- mystrcat(buf2," _?=");
- mystrcat(buf2,ibuf);
- // add a trailing backslash to make sure is_valid_instpath will not fail when it shouldn't
- addtrailingslash(buf2);
+ GetNSISString(buf2,g_header->str_uninstcmd); // '"$TEMP\$1" $0 _?=$INSTDIR\'
hProc=myCreateProcess(buf2,state_temp_dir);
if (hProc)
{
@@ -261,7 +242,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
}
}
}
- s[0]++;
+ g_usrvars[1][0]++;
}
goto end;
}
diff --git a/Source/exehead/Ui.c b/Source/exehead/Ui.c
index 4fdde15..9ead396 100755
--- a/Source/exehead/Ui.c
+++ b/Source/exehead/Ui.c
@@ -1,24 +1,18 @@
/*
-* Copyright (C) 1999-2006 Nullsoft, Inc.
-* Portions Copyright (C) 2002 Jeff Doozan
-*
-* This software is provided 'as-is', without any express or implied warranty.
-* In no event will the authors be held liable for any damages arising from the
-* use of this software.
-*
-* Permission is granted to anyone to use this software for any purpose, including
-* commercial applications, and to alter it and redistribute it freely, subject to
-* the following restrictions:
-*
-* 1. The origin of this software must not be misrepresented; you must not claim that
-* you wrote the original software. If you use this software in a product, an
-* acknowledgment in the product documentation would be appreciated but is not required.
-*
-* 2. Altered source versions must be plainly marked as such, and must not be
-* misrepresented as being the original software.
-*
-* 3. This notice may not be removed or altered from any source distribution.
-*/
+ * Ui.c
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft, Jeff Doozan and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
#include <windowsx.h>
#include <shlobj.h>
@@ -248,12 +242,14 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
}
else
{
+ static const char reg_9x_locale[] = "Control Panel\\Desktop\\ResourceLocale";
+ static const char reg_nt_locale_key[] = ".DEFAULT\\Control Panel\\International";
+ const char *reg_nt_locale_val = &reg_9x_locale[30]; // = "Locale" with opt
+
*(DWORD*)state_language = CHAR4_TO_DWORD('0', 'x', 0, 0);
{
// Windows 9x
- static const char reg_9x_locale[] = "Control Panel\\Desktop\\ResourceLocale";
-
myRegGetStr(HKEY_CURRENT_USER, reg_9x_locale, NULL, g_tmp);
}
@@ -261,9 +257,6 @@ FORCE_INLINE int NSISCALL ui_doinstall(void)
{
// Windows NT
// This key exists on 9x as well, so it's only read if ResourceLocale wasn't found
- static const char reg_nt_locale_key[] = ".DEFAULT\\Control Panel\\International";
- static const char reg_nt_locale_val[] = "Locale";
-
myRegGetStr(HKEY_USERS, reg_nt_locale_key, reg_nt_locale_val, g_tmp);
}
@@ -654,7 +647,7 @@ skipPage:
if (uMsg == WM_COMMAND)
{
int id = LOWORD(wParam);
- HWND hCtl = GetDlgItem(hwndDlg, id);
+ HWND hCtl = GetDlgItem(hwndDlg, id); // lParam might be NULL
if (hCtl)
{
SendMessage(hCtl, BM_SETSTATE, FALSE, 0);
@@ -958,11 +951,12 @@ static BOOL CALLBACK DirProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
if (idlist)
{
// free idlist
- FreePIDL(idlist);
+ CoTaskMemFree(idlist);
addtrailingslash(dir);
- if (g_header->install_directory_auto_append)
+ if (g_header->install_directory_auto_append &&
+ dir == state_install_directory) // only append to $INSTDIR (bug #1174184)
{
const char *post_str = ps_tmpbuf;
GetNSISStringTT(g_header->install_directory_auto_append);
@@ -1159,17 +1153,14 @@ int NSISCALL TreeGetSelectedSection(HWND tree, BOOL mouse)
}
static LONG oldTreeWndProc;
+static LPARAM last_selected_tree_item;
static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- static LPARAM last_item=-1;
if (uMsg == WM_CHAR && wParam == VK_SPACE) {
NotifyCurWnd(WM_TREEVIEW_KEYHACK);
return 0;
}
#if defined(NSIS_SUPPORT_CODECALLBACKS) && defined(NSIS_CONFIG_ENHANCEDUI_SUPPORT)
- if (uMsg == WM_DESTROY) {
- last_item=-1;
- }
#ifndef NSIS_CONFIG_COMPONENTPAGE_ALTERNATIVE
if (uMsg == WM_MOUSEMOVE) {
if (IsWindowVisible(hwnd)) {
@@ -1179,9 +1170,9 @@ static DWORD WINAPI newTreeWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM l
}
#endif
if (uMsg == WM_NOTIFY_SELCHANGE) {
- if (last_item != lParam)
+ if (last_selected_tree_item != lParam)
{
- last_item = lParam;
+ last_selected_tree_item = lParam;
mystrcpy(g_tmp, g_usrvars[0]);
@@ -1218,6 +1209,7 @@ static BOOL CALLBACK SelProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPar
hBMcheck1=LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_BITMAP1));
+ last_selected_tree_item=-1;
oldTreeWndProc=SetWindowLong(hwndTree1,GWL_WNDPROC,(long)newTreeWndProc);
hImageList = ImageList_Create(16,16, ILC_COLOR32|ILC_MASK, 6, 0);
@@ -1654,7 +1646,7 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
TPM_NONOTIFY|TPM_RETURNCMD,
pt.x,
pt.y,
- 0,linsthwnd,0))
+ 0,hwndDlg,0))
{
int i,total = 1; // 1 for the null char
LVITEM item;
@@ -1680,8 +1672,7 @@ static BOOL CALLBACK InstProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
i = 0;
do {
item.pszText = ptr;
- SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
- ptr += mystrlen(ptr);
+ ptr += SendMessage(linsthwnd,LVM_GETITEMTEXT,i,(LPARAM)&item);
*(WORD*)ptr = CHAR2_TO_WORD('\r','\n');
ptr+=2;
} while (++i < count);
diff --git a/Source/exehead/afxres.h b/Source/exehead/afxres.h
index 766cfa2..7a74b25 100755
--- a/Source/exehead/afxres.h
+++ b/Source/exehead/afxres.h
@@ -1,3 +1,19 @@
+/*
+ * afxres.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "../Platform.h"
#ifndef IDC_STATIC
diff --git a/Source/exehead/bgbg.c b/Source/exehead/bgbg.c
index c8c593d..9851f2b 100755
--- a/Source/exehead/bgbg.c
+++ b/Source/exehead/bgbg.c
@@ -1,3 +1,19 @@
+/*
+ * bgbg.c
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "../Platform.h"
#include "resource.h"
#include "config.h"
diff --git a/Source/exehead/components.c b/Source/exehead/components.c
index 068b309..8b494c4 100755
--- a/Source/exehead/components.c
+++ b/Source/exehead/components.c
@@ -1,3 +1,19 @@
+/*
+ * components.c
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "../Platform.h"
#include "config.h"
#include "ui.h"
diff --git a/Source/exehead/components.h b/Source/exehead/components.h
index d1773b0..35b78c6 100755
--- a/Source/exehead/components.h
+++ b/Source/exehead/components.h
@@ -1,3 +1,19 @@
+/*
+ * components.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#ifndef ___COMPONENTS_H___
#define ___COMPONENTS_H___
diff --git a/Source/exehead/config.h b/Source/exehead/config.h
index afb2967..03a2afd 100755
--- a/Source/exehead/config.h
+++ b/Source/exehead/config.h
@@ -1,3 +1,19 @@
+/*
+ * config.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#ifndef NSIS_CONFIG_H
#define NSIS_CONFIG_H
diff --git a/Source/exehead/exec.c b/Source/exehead/exec.c
index 503c618..00e7aa3 100755
--- a/Source/exehead/exec.c
+++ b/Source/exehead/exec.c
@@ -1,3 +1,19 @@
+/*
+ * exec.c
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "../Platform.h"
#include <shlobj.h>
#include <shellapi.h>
@@ -285,7 +301,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
{
char *p = skip_root(buf1);
char c = 'c';
- if (*buf1 && p)
+ if (p)
{
while (c)
{
@@ -439,8 +455,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
// remove read only flag if overwrite mode is on
if (!overwriteflag)
{
- int attr=GetFileAttributes(buf0);
- SetFileAttributes(buf0,attr&(~FILE_ATTRIBUTE_READONLY));
+ remove_ro_attr(buf0);
}
hOut=myOpenFile(buf0,GENERIC_WRITE,(overwriteflag==1)?CREATE_NEW:CREATE_ALWAYS);
if (hOut == INVALID_HANDLE_VALUE)
@@ -603,21 +618,11 @@ static int NSISCALL ExecuteEntry(entry *entry_)
{
char *p=var0;
char *buf0=GetStringFromParm(0x01);
- if (parm2)
+ if (!ExpandEnvironmentStrings(buf0,p,NSIS_MAX_STRLEN)
+ || (parm2 && !lstrcmp(buf0, p)))
{
- if (!GetEnvironmentVariable(buf0,p,NSIS_MAX_STRLEN))
- {
- exec_error++;
- *p=0;
- }
- }
- else
- {
- if (!ExpandEnvironmentStrings(buf0,p,NSIS_MAX_STRLEN))
- {
- exec_error++;
- *p=0;
- }
+ exec_error++;
+ *p=0;
}
p[NSIS_MAX_STRLEN-1]=0;
}
@@ -941,7 +946,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
if (parm4)
h=GetModuleHandle(buf1);
if (!h)
- h=LoadLibrary(buf1);
+ h=LoadLibraryEx(buf1, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (h)
{
FARPROC funke = GetProcAddress(h,buf0);
@@ -1205,11 +1210,19 @@ static int NSISCALL ExecuteEntry(entry *entry_)
LogData2Hex(binbuf, sizeof(binbuf), data, size);
log_printf5("WriteRegBin: \"%s\\%s\" \"%s\"=\"%s\"",rkn,buf1,buf0,binbuf);
}
+
if (size >= 0 && RegSetValueEx(hKey,buf0,0,rtype,data,size) == ERROR_SUCCESS)
+ {
exec_error--;
+ }
+ else
+ {
+ log_printf4("WriteReg: error writing into \"%s\\%s\" \"%s\"",rkn,buf1,buf0);
+ }
+
RegCloseKey(hKey);
}
- else { log_printf3("WriteReg: error creating key \"%s\\%s\"",buf3,buf1); }
+ else { log_printf3("WriteReg: error creating key \"%s\\%s\"",rkn,buf1); }
}
break;
case EW_READREGSTR: // read registry string
@@ -1429,6 +1442,7 @@ static int NSISCALL ExecuteEntry(entry *entry_)
}
validate_filename(buf1);
+ remove_ro_attr(buf1);
hFile=myOpenFile(buf1,GENERIC_WRITE,CREATE_ALWAYS);
if (hFile != INVALID_HANDLE_VALUE)
{
diff --git a/Source/exehead/exec.h b/Source/exehead/exec.h
index b6f2d10..dd9368b 100755
--- a/Source/exehead/exec.h
+++ b/Source/exehead/exec.h
@@ -1,3 +1,19 @@
+/*
+ * exec.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#ifndef _EXEC_H_
#define _EXEC_H_
diff --git a/Source/exehead/fileform.c b/Source/exehead/fileform.c
index 7967ab5..b0a03d0 100755
--- a/Source/exehead/fileform.c
+++ b/Source/exehead/fileform.c
@@ -1,3 +1,19 @@
+/*
+ * fileform.c
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "../Platform.h"
#include "fileform.h"
#include "util.h"
@@ -114,7 +130,7 @@ const char * NSISCALL loadHeaders(int cl_flags)
HANDLE db_hFile;
- GetModuleFileName(g_hInstance, state_exe_directory, NSIS_MAX_STRLEN);
+ GetModuleFileName(NULL, state_exe_directory, NSIS_MAX_STRLEN);
g_db_hFile = db_hFile = myOpenFile(state_exe_directory, GENERIC_READ, OPEN_EXISTING);
if (db_hFile == INVALID_HANDLE_VALUE)
@@ -150,15 +166,19 @@ const char * NSISCALL loadHeaders(int cl_flags)
h.nsinst[0] == FH_INT1
)
{
- if (h.length_of_all_following_data > left)
- return _LANG_INVALIDCRC;
-
g_filehdrsize = m_pos;
-#if defined(NSIS_CONFIG_CRC_SUPPORT) || (defined(NSIS_CONFIG_SILENT_SUPPORT) && defined(NSIS_CONFIG_VISIBLE_SUPPORT))
+#if defined(NSIS_CONFIG_CRC_SUPPORT) || defined(NSIS_CONFIG_SILENT_SUPPORT)
cl_flags |= h.flags;
#endif
+#ifdef NSIS_CONFIG_SILENT_SUPPORT
+ g_exec_flags.silent |= cl_flags & FH_FLAGS_SILENT;
+#endif
+
+ if (h.length_of_all_following_data > left)
+ return _LANG_INVALIDCRC;
+
#ifdef NSIS_CONFIG_CRC_SUPPORT
if ((cl_flags & FH_FLAGS_FORCE_CRC) == 0)
{
@@ -260,19 +280,11 @@ const char * NSISCALL loadHeaders(int cl_flags)
if (GetCompressedDataFromDataBlockToMemory(-1, data, h.length_of_header) != h.length_of_header)
{
- GlobalFree((HGLOBAL)data);
return _LANG_INVALIDCRC;
}
header = g_header = data;
-#ifdef NSIS_CONFIG_SILENT_SUPPORT
- if (cl_flags & FH_FLAGS_SILENT)
- header->flags |= CH_FLAGS_SILENT;
-
- g_exec_flags.silent = header->flags & (CH_FLAGS_SILENT | CH_FLAGS_SILENT_LOG);
-#endif
-
g_flags = header->flags;
#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
diff --git a/Source/exehead/fileform.h b/Source/exehead/fileform.h
index 0025303..6b82285 100755
--- a/Source/exehead/fileform.h
+++ b/Source/exehead/fileform.h
@@ -1,3 +1,19 @@
+/*
+ * fileform.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "config.h"
#include "../Platform.h"
@@ -313,6 +329,14 @@ typedef struct
int install_directory_ptr; // default install dir.
int install_directory_auto_append; // auto append part
+
+#ifdef NSIS_CONFIG_UNINSTALL_SUPPORT
+ int str_uninstchild;
+ int str_uninstcmd;
+#endif//NSIS_CONFIG_UNINSTALL_SUPPORT
+#ifdef NSIS_SUPPORT_MOVEONREBOOT
+ int str_wininit;
+#endif//NSIS_SUPPORT_MOVEONREBOOT
} header;
#ifdef NSIS_SUPPORT_CODECALLBACKS
diff --git a/Source/exehead/lang.h b/Source/exehead/lang.h
index 44b7839..db5b26b 100755
--- a/Source/exehead/lang.h
+++ b/Source/exehead/lang.h
@@ -1,3 +1,19 @@
+/*
+ * lang.c
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#ifndef _NSIS_LANG_H_
#define _NSIS_LANG_H_
diff --git a/Source/exehead/state.h b/Source/exehead/state.h
index db295b1..27657c1 100755
--- a/Source/exehead/state.h
+++ b/Source/exehead/state.h
@@ -1,3 +1,19 @@
+/*
+ * fileform.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "fileform.h"
extern NSIS_STRING g_usrvars[1];
diff --git a/Source/exehead/ui.h b/Source/exehead/ui.h
index 656959b..d863ee1 100755
--- a/Source/exehead/ui.h
+++ b/Source/exehead/ui.h
@@ -1,3 +1,20 @@
+/*
+ * ui.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
+
#ifndef _UI_H_
#define _UI_H_
diff --git a/Source/exehead/util.c b/Source/exehead/util.c
index 45c1281..212746c 100755
--- a/Source/exehead/util.c
+++ b/Source/exehead/util.c
@@ -1,3 +1,19 @@
+/*
+ * util.c
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "../Platform.h"
#include <shellapi.h>
#include "util.h"
@@ -33,17 +49,6 @@ NSIS_STRING g_usrvars[1] __attribute__((section (NSIS_VARS_SECTION)));
# endif
#endif
-void NSISCALL FreePIDL(LPITEMIDLIST idl)
-{
- IMalloc *m;
- SHGetMalloc(&m);
- if (m)
- {
- m->lpVtbl->Free(m, idl);
- m->lpVtbl->Release(m);
- }
-}
-
HANDLE NSISCALL myCreateProcess(char *cmd, char *dir)
{
DWORD d;
@@ -149,7 +154,7 @@ void NSISCALL myDelete(char *buf, int flags)
else
{
log_printf2("Delete: DeleteFile(\"%s\")",buf);
- SetFileAttributes(buf,fd.dwFileAttributes&(~FILE_ATTRIBUTE_READONLY));
+ remove_ro_attr(buf);
if (!DeleteFile(buf))
{
#ifdef NSIS_SUPPORT_MOVEONREBOOT
@@ -192,7 +197,7 @@ void NSISCALL myDelete(char *buf, int flags)
{
addtrailingslash(buf);
log_printf2("RMDir: RemoveDirectory(\"%s\")",buf);
- SetFileAttributes(buf,FILE_ATTRIBUTE_NORMAL);
+ remove_ro_attr(buf);
if (!RemoveDirectory(buf))
{
#ifdef NSIS_SUPPORT_MOVEONREBOOT
@@ -354,6 +359,13 @@ void NSISCALL mini_memcpy(void *out, const void *in, int len)
}
}
+void NSISCALL remove_ro_attr(char *file)
+{
+ int attr = GetFileAttributes(file);
+ if (attr != INVALID_FILE_ATTRIBUTES)
+ SetFileAttributes(file,attr&(~FILE_ATTRIBUTE_READONLY));
+}
+
HANDLE NSISCALL myOpenFile(const char *fn, DWORD da, DWORD cd)
{
int attr = GetFileAttributes(fn);
@@ -425,11 +437,8 @@ void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew)
return;
cchRenameLine = wsprintf(szRenameLine,"%s=%s\r\n",tmpbuf,wininit);
- GetWindowsDirectory(wininit, 1024-16);
- mystrcat(wininit, "\\wininit.ini");
- hfile = CreateFile(wininit,
- GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
+ GetNSISString(wininit, g_header->str_wininit);
+ hfile = myOpenFile(wininit, GENERIC_READ | GENERIC_WRITE, OPEN_ALWAYS);
if (hfile != INVALID_HANDLE_VALUE)
{
@@ -593,45 +602,13 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
if (nVarIdx == NS_SHELL_CODE)
{
- // NOTE 1: the code CSIDL_PRINTERS, is used for QUICKLAUNCH
- // NOTE 2: the code CSIDL_BITBUCKET is used for COMMONFILES
- // NOTE 3: the code CSIDL_CONTROLS is used for PROGRAMFILES
LPITEMIDLIST idl;
- char *append = 0;
-
- int x = 0;
- *out = 0;
+ int x = 2;
- if (fldrs[2] == CSIDL_PRINTERS) // QUICKLAUNCH
- {
- append = "\\Microsoft\\Internet Explorer\\Quick Launch";
- x = 2;
- }
- else if (fldrs[0] == CSIDL_PROGRAM_FILES_COMMON)
- {
- myRegGetStr(HKEY_LOCAL_MACHINE, SYSREGKEY, "CommonFilesDir", out);
- }
- else if (fldrs[0] == CSIDL_PROGRAM_FILES)
- {
- myRegGetStr(HKEY_LOCAL_MACHINE, SYSREGKEY, "ProgramFilesDir", out);
- if (!*out)
- mystrcpy(out, "C:\\Program Files");
- }
- else if (fldrs[0] == CSIDL_SYSTEM)
- {
- GetSystemDirectory(out, NSIS_MAX_STRLEN);
- }
- else if (fldrs[0] == CSIDL_WINDOWS)
- {
- GetWindowsDirectory(out, NSIS_MAX_STRLEN);
- }
-
- if (!*out)
+ if (g_exec_flags.all_user_var)
{
x = 4;
- if (!g_exec_flags.all_user_var)
- x = 2;
}
while (x--)
@@ -639,19 +616,46 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
if (!SHGetSpecialFolderLocation(g_hwnd, fldrs[x], &idl))
{
BOOL res = SHGetPathFromIDList(idl, out);
- FreePIDL(idl);
+ CoTaskMemFree(idl);
if (res)
{
break;
}
}
- else
- *out=0;
+ *out=0;
+ }
+
+ // resort to old registry methods, only when CSIDL failed
+ if (!*out)
+ {
+ if (fldrs[0] == CSIDL_PROGRAM_FILES_COMMON)
+ {
+ myRegGetStr(HKEY_LOCAL_MACHINE, SYSREGKEY, "CommonFilesDir", out);
+ }
+ else if (fldrs[0] == CSIDL_PROGRAM_FILES)
+ {
+ myRegGetStr(HKEY_LOCAL_MACHINE, SYSREGKEY, "ProgramFilesDir", out);
+ if (!*out)
+ mystrcpy(out, "C:\\Program Files");
+ }
+ else if (fldrs[0] == CSIDL_SYSTEM)
+ {
+ GetSystemDirectory(out, NSIS_MAX_STRLEN);
+ }
+ else if (fldrs[0] == CSIDL_WINDOWS)
+ {
+ GetWindowsDirectory(out, NSIS_MAX_STRLEN);
+ }
}
- if (*out && append)
+ if (*out)
{
- mystrcat(out, append);
+ // all users' version is CSIDL_APPDATA only for $QUICKLAUNCH
+ // for normal $APPDATA, it'd be CSIDL_APPDATA_COMMON
+ if (fldrs[2] == CSIDL_APPDATA)
+ {
+ mystrcat(out, "\\Microsoft\\Internet Explorer\\Quick Launch");
+ }
}
validate_filename(out);
diff --git a/Source/exehead/util.h b/Source/exehead/util.h
index 14c5af9..640c1d7 100755
--- a/Source/exehead/util.h
+++ b/Source/exehead/util.h
@@ -1,3 +1,19 @@
+/*
+ * util.h
+ *
+ * This file is a part of NSIS.
+ *
+ * Copyright (C) 1999-2007 Nullsoft and Contributors
+ *
+ * Licensed under the zlib/libpng license (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * Licence details can be found in the file COPYING.
+ *
+ * This software is provided 'as-is', without any express or implied
+ * warranty.
+ */
+
#include "../Platform.h"
#include "config.h"
#include <shlobj.h>
@@ -16,7 +32,6 @@ char * NSISCALL mystrcat(char *out, const char *concat);
char * NSISCALL mystrstr(char *a, char *b);
WIN32_FIND_DATA * NSISCALL file_exists(char *buf);
char * NSISCALL my_GetTempFileName(char *buf, const char *dir);
-void NSISCALL FreePIDL(LPITEMIDLIST idl);
//BOOL NSISCALL my_SetWindowText(HWND hWnd, const char *val);
#define my_SetWindowText SetWindowText
@@ -74,6 +89,7 @@ int NSISCALL is_valid_instpath(char *s);
void NSISCALL validate_filename(char *fn);
void NSISCALL MoveFileOnReboot(LPCTSTR pszExisting, LPCTSTR pszNew);
void NSISCALL mini_memcpy(void *out, const void *in, int len);
+void NSISCALL remove_ro_attr(char *file);
void * NSISCALL myGetProcAddress(char *dll, char *func);
void NSISCALL MessageLoop(UINT uCheckedMsg);