Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HDESK hdReal;
- HDESK hdVirt;
- HWINSTA winStaReal;
- HWINSTA winStaVirt;
- int WINAPI main(int argc, char *argv[])
- {
- winStaReal = GetProcessWindowStation();
- hdReal = GetThreadDesktop(GetCurrentThreadId());
- winStaVirt = CreateWindowStationA("microsta2", 0, GENERIC_ALL, NULL);
- SetProcessWindowStation(winStaVirt);
- hdVirt = CreateDesktopA("microdesk2", 0, 0, DF_ALLOWOTHERACCOUNTHOOK, GENERIC_ALL, 0);
- SetProcessWindowStation(winStaReal);
- /*RunInVD(hdReal, hdVirt, "microdesk2", "C:\\Windows\\system32\\explorer.exe", NULL);
- SwitchDesktop(hdVirt);
- Sleep(1000 * 60);
- SwitchDesktop(hdReal);*/
- RunInVD(hdReal, hdVirt, "microdesk2", "J:\\temp\\WinVNC.exe", NULL);
- RunInVD(hdReal, hdVirt, "microdesk2", "J:\\temp\\WinVNC.exe", "-connect 127.0.0.1");
- CloseDesktop(hdVirt);
- CloseWindowStation(winStaVirt);
- getchar();
- return 0;
- }
- HANDLE RunInVD(HDESK real, HDESK vd, char *vdName, char *exe, char *args)
- {
- char *cmdLine;
- cmdLine = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(char)*(lstrlenA(exe)+lstrlenA(args)+3));
- lstrcpyA(cmdLine, exe);
- if (args != NULL)
- {
- lstrcatA(cmdLine, " ");
- lstrcatA(cmdLine, args);
- }
- PROCESS_INFORMATION pi;
- STARTUPINFO *si;
- si = (STARTUPINFO*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(STARTUPINFO));
- si->cb = sizeof(si);
- si->lpDesktop = (char*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(char)*lstrlenA(vdName)+1);
- lstrcpyA(si->lpDesktop, vdName);
- SetThreadDesktop(vd);
- CreateProcessA(NULL, cmdLine, NULL, NULL, TRUE, 0, NULL, NULL, si, &pi);
- SetThreadDesktop(real);
- if (si->lpDesktop != NULL) HeapFree(GetProcessHeap(), 0, si->lpDesktop);
- if (si != NULL) HeapFree(GetProcessHeap(), 0, si);
- HeapFree(GetProcessHeap(), 0, cmdLine);
- return pi.hProcess;
- }
Add Comment
Please, Sign In to add comment