Commit 76037ffb authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

kernelbase: Support PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE.

parent 36663d9a
...@@ -3957,9 +3957,14 @@ static DWORD WINAPI read_pipe_proc( void *handle ) ...@@ -3957,9 +3957,14 @@ static DWORD WINAPI read_pipe_proc( void *handle )
static void test_pseudo_console(void) static void test_pseudo_console(void)
{ {
STARTUPINFOEXA startup = {{ sizeof(startup) }};
HANDLE console_pipe, console_pipe2, thread; HANDLE console_pipe, console_pipe2, thread;
char **argv, cmdline[MAX_PATH];
PROCESS_INFORMATION info;
HPCON pseudo_console; HPCON pseudo_console;
SIZE_T attr_size;
COORD size; COORD size;
BOOL ret;
HRESULT hres; HRESULT hres;
if (!pCreatePseudoConsole) if (!pCreatePseudoConsole)
...@@ -3995,6 +4000,22 @@ static void test_pseudo_console(void) ...@@ -3995,6 +4000,22 @@ static void test_pseudo_console(void)
ok(hres == S_OK, "CreatePseudoConsole failed: %08x\n", hres); ok(hres == S_OK, "CreatePseudoConsole failed: %08x\n", hres);
CloseHandle(console_pipe2); CloseHandle(console_pipe2);
InitializeProcThreadAttributeList(NULL, 1, 0, &attr_size);
startup.lpAttributeList = HeapAlloc(GetProcessHeap(), 0, attr_size);
InitializeProcThreadAttributeList(startup.lpAttributeList, 1, 0, &attr_size);
UpdateProcThreadAttribute(startup.lpAttributeList, 0, PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, pseudo_console,
sizeof(pseudo_console), NULL, NULL);
winetest_get_mainargs(&argv);
sprintf(cmdline, "\"%s\" %s --pseudo-console", argv[0], argv[1]);
ret = CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, EXTENDED_STARTUPINFO_PRESENT, NULL, NULL, &startup.StartupInfo, &info);
ok(ret, "CreateProcessW failed: %u\n", GetLastError());
CloseHandle(info.hThread);
HeapFree(GetProcessHeap(), 0, startup.lpAttributeList);
wait_child_process(info.hProcess);
CloseHandle(info.hProcess);
pClosePseudoConsole(pseudo_console); pClosePseudoConsole(pseudo_console);
} }
...@@ -4003,6 +4024,7 @@ START_TEST(console) ...@@ -4003,6 +4024,7 @@ START_TEST(console)
HANDLE hConIn, hConOut; HANDLE hConIn, hConOut;
BOOL ret, test_current; BOOL ret, test_current;
CONSOLE_SCREEN_BUFFER_INFO sbi; CONSOLE_SCREEN_BUFFER_INFO sbi;
BOOL using_pseudo_console;
DWORD size; DWORD size;
char **argv; char **argv;
int argc; int argc;
...@@ -4026,8 +4048,9 @@ START_TEST(console) ...@@ -4026,8 +4048,9 @@ START_TEST(console)
} }
test_current = argc >= 3 && !strcmp(argv[2], "--current"); test_current = argc >= 3 && !strcmp(argv[2], "--current");
using_pseudo_console = argc >= 3 && !strcmp(argv[2], "--pseudo-console");
if (!test_current) if (!test_current && !using_pseudo_console)
{ {
static const char font_name[] = "Lucida Console"; static const char font_name[] = "Lucida Console";
HKEY console_key; HKEY console_key;
...@@ -4093,6 +4116,19 @@ START_TEST(console) ...@@ -4093,6 +4116,19 @@ START_TEST(console)
ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n"); ok(hConIn != INVALID_HANDLE_VALUE, "Opening ConIn\n");
ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n"); ok(hConOut != INVALID_HANDLE_VALUE, "Opening ConOut\n");
if (using_pseudo_console)
{
DWORD mode;
ret = GetConsoleMode(hConIn, &mode);
ok(ret, "GetConsoleMode failed: %u\n", GetLastError());
todo_wine
ok(mode == (ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_MOUSE_INPUT |
ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE | ENABLE_EXTENDED_FLAGS | ENABLE_AUTO_POSITION),
"mode = %x\n", mode);
return;
}
ret = GetConsoleScreenBufferInfo(hConOut, &sbi); ret = GetConsoleScreenBufferInfo(hConOut, &sbi);
ok(ret, "Getting sb info\n"); ok(ret, "Getting sb info\n");
if (!ret) return; if (!ret) return;
......
...@@ -3887,6 +3887,18 @@ static void test_ProcThreadAttributeList(void) ...@@ -3887,6 +3887,18 @@ static void test_ProcThreadAttributeList(void)
expect_list.count++; expect_list.count++;
} }
ret = pUpdateProcThreadAttribute(&list, 0, PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE, handles, sizeof(PROCESSOR_NUMBER), NULL, NULL);
ok(ret || broken(GetLastError() == ERROR_NOT_SUPPORTED), "got %d gle %d\n", ret, GetLastError());
if (ret)
{
unsigned int i = expect_list.count++;
expect_list.mask |= 1 << ProcThreadAttributePseudoConsole;
expect_list.attrs[i].attr = PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE;
expect_list.attrs[i].size = sizeof(HPCON);
expect_list.attrs[i].value = handles;
}
ok(!memcmp(&list, &expect_list, size), "mismatch\n"); ok(!memcmp(&list, &expect_list, size), "mismatch\n");
pDeleteProcThreadAttributeList(&list); pDeleteProcThreadAttributeList(&list);
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winnls.h" #include "winnls.h"
#include "wincontypes.h"
#include "winternl.h" #include "winternl.h"
#include "kernelbase.h" #include "kernelbase.h"
...@@ -568,6 +569,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR ...@@ -568,6 +569,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessInternalW( HANDLE token, const WCHAR
handle_list = &attrs->attrs[i]; handle_list = &attrs->attrs[i];
TRACE("PROC_THREAD_ATTRIBUTE_HANDLE_LIST handle count %Iu.\n", attrs->attrs[i].size / sizeof(HANDLE)); TRACE("PROC_THREAD_ATTRIBUTE_HANDLE_LIST handle count %Iu.\n", attrs->attrs[i].size / sizeof(HANDLE));
break; break;
case PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE:
{
struct pseudo_console *console = attrs->attrs[i].value;
TRACE( "PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE %p reference %p\n",
console, console->reference );
params->ConsoleHandle = console->reference;
break;
}
default: default:
FIXME("Unsupported attribute %#Ix.\n", attrs->attrs[i].attr); FIXME("Unsupported attribute %#Ix.\n", attrs->attrs[i].attr);
break; break;
...@@ -1730,6 +1739,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH UpdateProcThreadAttribute( struct _PROC_THREAD_ATT ...@@ -1730,6 +1739,14 @@ BOOL WINAPI DECLSPEC_HOTPATCH UpdateProcThreadAttribute( struct _PROC_THREAD_ATT
} }
break; break;
case PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE:
if (size != sizeof(HPCON))
{
SetLastError( ERROR_BAD_LENGTH );
return FALSE;
}
break;
default: default:
SetLastError( ERROR_NOT_SUPPORTED ); SetLastError( ERROR_NOT_SUPPORTED );
FIXME( "Unhandled attribute %lu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER ); FIXME( "Unhandled attribute %lu\n", attr & PROC_THREAD_ATTRIBUTE_NUMBER );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment