load shfolder.dll before the script is executed to avoid any usage effects

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5198 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2007-07-12 19:15:50 +00:00
parent 161ac2adf2
commit edd3c299f7
2 changed files with 23 additions and 5 deletions

View file

@ -52,6 +52,8 @@ char *ValidateTempDir()
return my_GetTempFileName(state_language, state_temp_dir);
}
void *g_SHGetFolderPath;
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam, int nCmdShow)
{
int ret = 0;
@ -74,6 +76,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInst,LPSTR lpszCmdParam,
}
#endif
// load shfolder.dll before any script code is executed to avoid
// weird situations where SetOutPath or even the extraction of
// shfolder.dll will cause unexpected behavior.
//
// this also prevents the following:
//
// SetOutPath "C:\Program Files\NSIS" # maybe read from reg
// File shfolder.dll
// Delete $PROGRAMFILES\shfolder.dll # can't be deleted, as the
// # new shfolder.dll is used
// # to find its own path.
g_SHGetFolderPath = myGetProcAddress(MGA_SHGetFolderPathA);
{
// workaround for bug #1008632
// http://sourceforge.net/tracker/index.php?func=detail&aid=1008632&group_id=22049&atid=373085

View file

@ -597,6 +597,7 @@ const char SYSREGKEY[] = "Software\\Microsoft\\Windows\\CurrentVersion";
const char QUICKLAUNCH[] = "\\Microsoft\\Internet Explorer\\Quick Launch";
typedef HRESULT (__stdcall * PFNSHGETFOLDERPATHA)(HWND, int, HANDLE, DWORD, LPSTR);
extern void *g_SHGetFolderPath;
// Based on Dave Laundon's simplified process_string
char * NSISCALL GetNSISString(char *outbuf, int strtab)
@ -628,9 +629,6 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
int x = 2;
// Use SHGetFolderPath when shfolder.dll is available
PFNSHGETFOLDERPATHA pSHGetFolderPath = (PFNSHGETFOLDERPATHA) myGetProcAddress(MGA_SHGetFolderPathA);
if (g_exec_flags.all_user_var)
{
x = 4;
@ -656,8 +654,13 @@ char * NSISCALL GetNSISString(char *outbuf, int strtab)
while (x--)
{
if (pSHGetFolderPath) {
if (!pSHGetFolderPath(g_hwnd, fldrs[x], NULL, SHGFP_TYPE_CURRENT, out)) break;
if (g_SHGetFolderPath)
{
PFNSHGETFOLDERPATHA SHGetFolderPathFunc = (PFNSHGETFOLDERPATHA) g_SHGetFolderPath;
if (!SHGetFolderPathFunc(g_hwnd, fldrs[x], NULL, SHGFP_TYPE_CURRENT, out))
{
break;
}
}
if (!SHGetSpecialFolderLocation(g_hwnd, fldrs[x], &idl))