Module: wine Branch: master Commit: a95e0708245a4972ee4e28f4811dddfe16e3c206 URL: http://source.winehq.org/git/wine.git/?a=commit;h=a95e0708245a4972ee4e28f481...
Author: Paul Vriens Paul.Vriens.Wine@gmail.com Date: Tue Jan 5 09:32:36 2010 +0100
kernel32: Add a stubbed GetConsoleProcessList().
---
dlls/kernel32/console.c | 16 ++++++++++ dlls/kernel32/kernel32.spec | 2 +- dlls/kernel32/tests/console.c | 67 +++++++++++++++++++++++++++++++++++++++-- 3 files changed, 81 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/console.c b/dlls/kernel32/console.c index 42344af..4aa0b44 100644 --- a/dlls/kernel32/console.c +++ b/dlls/kernel32/console.c @@ -2690,3 +2690,19 @@ DWORD WINAPI GetConsoleAliasW(LPWSTR lpSource, LPWSTR lpTargetBuffer, SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return 0; } + +/****************************************************************** + * GetConsoleProcessList (KERNEL32.@) + */ +DWORD WINAPI GetConsoleProcessList(LPDWORD processlist, DWORD processcount) +{ + FIXME("(%p,%d): stub\n", processlist, processcount); + + if (!processlist || processcount < 1) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + return 0; +} diff --git a/dlls/kernel32/kernel32.spec b/dlls/kernel32/kernel32.spec index 720a5fd..3b772ba 100644 --- a/dlls/kernel32/kernel32.spec +++ b/dlls/kernel32/kernel32.spec @@ -478,7 +478,7 @@ @ stdcall GetConsoleMode(long ptr) @ stub GetConsoleNlsMode @ stdcall GetConsoleOutputCP() -# @ stub GetConsoleProcessList +@ stdcall GetConsoleProcessList(ptr long) @ stdcall GetConsoleScreenBufferInfo(long ptr) # @ stub GetConsoleSelectionInfo @ stdcall GetConsoleTitleA(ptr long) diff --git a/dlls/kernel32/tests/console.c b/dlls/kernel32/tests/console.c index 33eab26..ace4744 100644 --- a/dlls/kernel32/tests/console.c +++ b/dlls/kernel32/tests/console.c @@ -24,6 +24,7 @@ #include <stdio.h>
static BOOL (WINAPI *pGetConsoleInputExeNameA)(DWORD, LPSTR); +static DWORD (WINAPI *pGetConsoleProcessList)(LPDWORD, DWORD); static BOOL (WINAPI *pSetConsoleInputExeNameA)(LPCSTR);
/* DEFAULT_ATTRIB is used for all initial filling of the console. @@ -63,6 +64,7 @@ static void init_function_pointers(void)
hKernel32 = GetModuleHandleA("kernel32.dll"); KERNEL32_GET_PROC(GetConsoleInputExeNameA); + KERNEL32_GET_PROC(GetConsoleProcessList); KERNEL32_GET_PROC(SetConsoleInputExeNameA);
#undef KERNEL32_GET_PROC @@ -926,6 +928,66 @@ static void test_GetSetConsoleInputExeName(void) ok(!lstrcmpA(buffer, input_exe), "got %s expected %s\n", buffer, input_exe); }
+static void test_GetConsoleProcessList(void) +{ + DWORD ret, *list = NULL; + + if (!pGetConsoleProcessList) + { + win_skip("GetConsoleProcessList is not available\n"); + return; + } + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(NULL, 0); + ok(ret == 0, "Expected failure\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", + GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(NULL, 1); + ok(ret == 0, "Expected failure\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", + GetLastError()); + + /* We should only have 1 process but only for these specific unit tests as + * we created our own console. An AttachConsole(ATTACH_PARENT_PROCESS) would + * give us two processes for example. + */ + list = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD)); + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(list, 0); + ok(ret == 0, "Expected failure\n"); + ok(GetLastError() == ERROR_INVALID_PARAMETER, + "Expected ERROR_INVALID_PARAMETER, got %d\n", + GetLastError()); + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(list, 1); + todo_wine + ok(ret == 1, "Expected 1, got %d\n", ret); + + HeapFree(GetProcessHeap(), 0, list); + + list = HeapAlloc(GetProcessHeap(), 0, ret * sizeof(DWORD)); + + SetLastError(0xdeadbeef); + ret = pGetConsoleProcessList(list, ret); + todo_wine + ok(ret == 1, "Expected 1, got %d\n", ret); + + if (ret == 1) + { + DWORD pid = GetCurrentProcessId(); + ok(list[0] == pid, "Expected %d, got %d\n", pid, list[0]); + } + + HeapFree(GetProcessHeap(), 0, list); +} + START_TEST(console) { HANDLE hConIn, hConOut; @@ -971,10 +1033,9 @@ START_TEST(console) /* still to be done: access rights & access on objects */
if (!pGetConsoleInputExeNameA || !pSetConsoleInputExeNameA) - { win_skip("GetConsoleInputExeNameA and/or SetConsoleInputExeNameA is not available\n"); - return; - } else test_GetSetConsoleInputExeName(); + + test_GetConsoleProcessList(); }