Revision: 6121
http://nsis.svn.sourceforge.net/nsis/?rev=6121&view=rev
Author: anders_k
Date: 2010-08-19 21:10:30 +0000 (Thu, 19 Aug 2010)
Log Message:
-----------
Try FOLDERID_LocalAppDataLow\Temp as last ValidateTempDir() attempt for Low IL aka Protected IE
Modified Paths:
--------------
NSIS/trunk/Source/exehead/Main.c
NSIS/trunk/Source/exehead/util.c
NSIS/trunk/Source/exehead/util.h
Modified: NSIS/trunk/Source/exehead/Main.c
===================================================================
--- NSIS/trunk/Source/exehead/Main.c 2010-08-08 12:32:24 UTC (rev 6120)
+++ NSIS/trunk/Source/exehead/Main.c 2010-08-19 21:10:30 UTC (rev 6121)
@@ -174,11 +174,47 @@
GetTempPath(NSIS_MAX_STRLEN, state_temp_dir);
if (!ValidateTempDir())
{
+ LPTSTR tstrslashtemp = _T("\\Temp");
GetWindowsDirectory(state_temp_dir, NSIS_MAX_STRLEN - 5); // leave space for \Temp
- mystrcat(state_temp_dir, _T("\\Temp"));
+ mystrcat(state_temp_dir, tstrslashtemp);
if (!ValidateTempDir())
{
- goto end;
+ const int myKF_FLAG_CREATE=0x00008000;
+ const GUID myFOLDERID_LocalAppDataLow={0xA520A1A4,0x1780,0x4FF6,{0xBD,0x18,0x16,0x73,0x43,0xC5,0xAF,0x16}};
+ void* pfnSHGetKnownFolderPath=myGetProcAddress(MGA_SHGetKnownFolderPath);
+ WCHAR* localapplow;
+ HRESULT hr = E_NOTIMPL;
+ if (pfnSHGetKnownFolderPath)
+ {
+ // There does not seem to be a API to get the low temp dir directly, so we build the path on our own
+ hr = ((HRESULT(WINAPI*)(void*,DWORD,HANDLE,WCHAR**))pfnSHGetKnownFolderPath)((void*)&myFOLDERID_LocalAppDataLow, myKF_FLAG_CREATE, NULL, &localapplow);
+ }
+ if (S_OK == hr)
+ {
+#ifdef _UNICODE
+ if (mystrlen(localapplow) < NSIS_MAX_STRLEN - 5)
+ {
+ addtrailingslash(state_temp_dir);
+ mystrcat(state_temp_dir, &tstrslashtemp[1]);
+ }
+#else
+ if (lstrlenW(localapplow) < NSIS_MAX_STRLEN - 5)
+ {
+ BOOL useddefchar=FALSE;
+ WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, localapplow, -1, state_temp_dir, NSIS_MAX_STRLEN, NULL, &useddefchar);
+ if (!useddefchar)
+ {
+ addtrailingslash(state_temp_dir);
+ mystrcat(state_temp_dir, &tstrslashtemp[1]);
+ }
+ }
+#endif
+ CoTaskMemFree(localapplow);
+ }
+ if (!ValidateTempDir())
+ {
+ goto end;
+ }
}
}
DeleteFile(state_language);
Modified: NSIS/trunk/Source/exehead/util.c
===================================================================
--- NSIS/trunk/Source/exehead/util.c 2010-08-08 12:32:24 UTC (rev 6120)
+++ NSIS/trunk/Source/exehead/util.c 2010-08-19 21:10:30 UTC (rev 6121)
@@ -1005,7 +1005,8 @@
{"ADVAPI32", "AdjustTokenPrivileges"},
{"KERNEL32", "GetUserDefaultUILanguage"},
{"SHLWAPI", "SHAutoComplete"},
- {"SHFOLDER", "SHGetFolderPathW"}
+ {"SHFOLDER", "SHGetFolderPathW"},
+ {"SHELL32", "SHGetKnownFolderPath"}
};
#else
struct MGA_FUNC MGA_FUNCS[] = {
@@ -1017,7 +1018,8 @@
{"ADVAPI32", "AdjustTokenPrivileges"},
{"KERNEL32", "GetUserDefaultUILanguage"},
{"SHLWAPI", "SHAutoComplete"},
- {"SHFOLDER", "SHGetFolderPathA"}
+ {"SHFOLDER", "SHGetFolderPathA"},
+ {"SHELL32", "SHGetKnownFolderPath"}
};
#endif
Modified: NSIS/trunk/Source/exehead/util.h
===================================================================
--- NSIS/trunk/Source/exehead/util.h 2010-08-08 12:32:24 UTC (rev 6120)
+++ NSIS/trunk/Source/exehead/util.h 2010-08-19 21:10:30 UTC (rev 6121)
@@ -118,7 +118,8 @@
MGA_AdjustTokenPrivileges,
MGA_GetUserDefaultUILanguage,
MGA_SHAutoComplete,
- MGA_SHGetFolderPath
+ MGA_SHGetFolderPath,
+ MGA_SHGetKnownFolderPath
};
void * NSISCALL myGetProcAddress(const enum myGetProcAddressFunctions func);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|