implemented RFE #1778973 - nsExec & ExecDos - Support DisableX64FSRedirection feature

also fixed bug #1889317

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@5542 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2008-02-16 18:30:47 +00:00
parent efebf6bedd
commit 8fba6791ad

View file

@ -82,20 +82,39 @@ BOOL WINAPI DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
#define CHAR4_TO_DWORD(a,b,c,d) (((DWORD)CHAR2_TO_WORD(a,b))|(CHAR2_TO_WORD(c,d)<<16))
#endif
BOOL IsWOW64() {
typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
BOOL wow64;
LPFN_ISWOW64PROCESS fnIsWow64Process;
fnIsWow64Process = (LPFN_ISWOW64PROCESS) GetProcAddress(
GetModuleHandle("kernel32"), "IsWow64Process");
if (fnIsWow64Process != NULL) {
if (fnIsWow64Process(GetCurrentProcess(), &wow64)) {
return wow64;
}
}
return FALSE;
}
void ExecScript(int log) {
char szRet[128] = "";
char *pExec;
int nComSpecSize;
char meDLLPath[MAX_PATH];
char *p;
char *executor;
char *g_exec;
char *pExec;
unsigned int g_to;
BOOL bOEM;
if (IsWOW64()) {
char *p;
int nComSpecSize;
nComSpecSize = GetModuleFileName(g_hInst, meDLLPath, MAX_PATH) + 2; // 2 chars for quotes
p = meDLLPath + nComSpecSize - 2; // point p at null char of meDLLPath
g_exec = (char *)GlobalAlloc(GPTR, sizeof(char)*g_stringsize+nComSpecSize+2); // 1 for space, 1 for null
p = meDLLPath + nComSpecSize - 2; // point p at null char of meDLLPath
*g_exec = '"';
executor = g_exec + 1;
@ -140,6 +159,16 @@ void ExecScript(int log) {
lstrcat(g_exec, "\"");
// add space
pExec = g_exec + lstrlen(g_exec);
*pExec = ' ';
pExec++;
} else {
executor = NULL;
g_exec = (char *)GlobalAlloc(GPTR, sizeof(char)*g_stringsize+1); // 1 for null
pExec = g_exec;
}
g_to = 0; // default is no timeout
bOEM = FALSE; // default is no OEM->ANSI conversion
@ -147,11 +176,6 @@ void ExecScript(int log) {
if (g_hwndParent)
g_hwndList = FindWindowEx(FindWindowEx(g_hwndParent,NULL,"#32770",NULL),NULL,"SysListView32",NULL);
// add space
pExec = g_exec + lstrlen(g_exec);
*pExec = ' ';
pExec++;
params:
popstring(pExec);
if (my_strstr(pExec, "/TIMEOUT=") == pExec) {
@ -170,7 +194,7 @@ params:
{
pushstring("error");
*(pExec-2) = '\0'; // skip space and quote
DeleteFile(executor);
if (executor) DeleteFile(executor);
GlobalFree(g_exec);
return;
}
@ -326,7 +350,7 @@ done:
CloseHandle(newstdin);
CloseHandle(read_stdin);
*(pExec-2) = '\0'; // skip space and quote
DeleteFile(executor);
if (executor) DeleteFile(executor);
GlobalFree(g_exec);
if (log) {
GlobalUnlock(hUnusedBuf);