Why does RunDLL32 launch end early in Windows 7?

On Windows XP and Vista, I can run this code:

STARTUPINFO si;
PROCESS_INFORMATION pi;
BOOL bResult = FALSE;

ZeroMemory(&pi, sizeof(pi));

ZeroMemory(&si, sizeof(si));

si.cb = sizeof(STARTUPINFO);
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;

bResult = CreateProcess(NULL, 
                        "rundll32.exe shell32.dll,Control_RunDLL modem.cpl", 
                        NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, 
                        &si, &pi);

if (bResult)
{
    WaitForSingleObject(pi.hProcess, INFINITE);
    CloseHandle(pi.hProcess);
    CloseHandle(pi.hThread);
}

and it works as I would expect, i.e. WaitForSingleObject does not return until the user closes the modem control panel window.

In Windows 7, the same code, WaitForSingleObject returns immediately (with a return code of 0, indicating that the object signaled the requested state).

Similarly, if I take it on the command line, on XP and Vista I can run

start /wait rundll32.exe shell32.dll,Control_RunDLL modem.cpl

and it does not return command line control until the control panel window is closed, but in Windows 7 it will immediately return.

RunDll32? , MS RunDll32 Windows 7 UAC, , . , , , , , , , rundll32.

? , .

+3
1

, - : , , Microsoft Tech Support.

, RunDll32 ( ), - , , WaitForSingleObject() .

, - , CPLApplet, : http://support.microsoft.com/kb/232536

, 32- 64- Windows ( , "" ). WOW64 RunDLL 64- , , 64- 32- , ,

:

Win 7 64 bit: call CPLApplet via CreateProcess in 64-bit executable
Win 7 32 bit: call CPLApplet within my installer
XP / Vista 64 bit: turn off WOW64 redirection, use RunDll32
XP / Vista 32 bit: use RunDll32
+3

Source: https://habr.com/ru/post/1735965/


All Articles