/* Construct a Logon Script that will cause the LogonEventHandler to be executed\r
* under in the logon session \r
*/\r
+\r
+#define RUNDLL32_CMDLINE "rundll32.exe kfwlogon.dll,LogonEventHandler "\r
VOID \r
ConfigureLogonScript(LPWSTR *lpLogonScript, char * filename) {\r
DWORD dwLogonScriptLen;\r
if (!filename)\r
return;\r
\r
- dwLogonScriptLen = strlen("rundll32.exe kfwlogon.dll,LogonEventHandler ") + strlen(filename) + 1;\r
+ dwLogonScriptLen = strlen(RUNDLL32_CMDLINE) + strlen(filename) + 2;\r
lpTemp = (LPSTR) malloc(dwLogonScriptLen); \r
if (!lpTemp)\r
return;\r
\r
- _snprintf(lpTemp, dwLogonScriptLen, \r
- "rundll32.exe kfwlogon.dll,LogonEventHandler %s",\r
- filename);\r
+ _snprintf(lpTemp, dwLogonScriptLen, "%s%s", RUNDLL32_CMDLINE, filename);\r
\r
SetLastError(0);\r
- dwLogonScriptLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpTemp, strlen(lpTemp), NULL, 0);\r
+ dwLogonScriptLen = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpTemp, -1, NULL, 0);\r
DebugEvent("ConfigureLogonScript %s requires %d bytes gle=0x%x", lpTemp, dwLogonScriptLen, GetLastError());\r
\r
lpScript = LocalAlloc(LMEM_ZEROINIT, dwLogonScriptLen * 2);\r
if (lpScript) {\r
- if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpTemp, strlen(lpTemp), \r
- lpScript, 2 * dwLogonScriptLen))\r
+ if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, lpTemp, -1, lpScript, 2 * dwLogonScriptLen))\r
*lpLogonScript = lpScript;\r
else {\r
DebugEvent("ConfigureLogonScript - MultiByteToWideChar failed gle = 0x%x", GetLastError());\r
_snprintf(commandline, sizeof(commandline), "kfwcpcc.exe \"%s\"", lpszCmdLine);\r
\r
GetStartupInfo(&startupinfo);\r
- if (CreateProcess( "kfwcpcc.exe",\r
+ SetLastError(0);\r
+ if (CreateProcess( NULL,\r
commandline,\r
NULL,\r
NULL,\r
CloseHandle(procinfo.hThread);\r
CloseHandle(procinfo.hProcess);\r
} else {\r
- DebugEvent0("KFW_Logon_Event - CreateProcessFailed");\r
+ DebugEvent("KFW_Logon_Event - CreateProcessFailed \"%s\" GLE 0x%x", \r
+ commandline, GetLastError());\r
+ DebugEvent("KFW_Logon_Event PATH %s", getenv("PATH"));\r
}\r
\r
DeleteFile(lpszCmdLine);\r