Author: jmorlan
Date: Sun May 23 19:40:54 2010
New Revision: 47331
URL:
http://svn.reactos.org/svn/reactos?rev=47331&view=rev
Log:
[KERNEL32], [WIN32CSR] More fixes for console winetest
- BasepInitConsole: Initialize console input EXE name
- GetConsoleProcessList: Use capture buffer; only copy IDs if buffer has enough room for
all of them; return total number of processes.
Modified:
trunk/reactos/dll/win32/kernel32/include/kernel32.h
trunk/reactos/dll/win32/kernel32/misc/console.c
trunk/reactos/dll/win32/kernel32/misc/dllmain.c
trunk/reactos/include/reactos/subsys/csrss/csrss.h
trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Sun May 23 19:40:54
2010
@@ -84,6 +84,8 @@
DWORD dwDesiredAccess,
BOOL bInheritHandle,
DWORD dwShareMode);
+
+BOOL WINAPI SetConsoleInputExeNameW(LPCWSTR lpInputExeName);
PTEB GetTeb(VOID);
Modified: trunk/reactos/dll/win32/kernel32/misc/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/co…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] Sun May 23 19:40:54 2010
@@ -3753,7 +3753,8 @@
GetConsoleProcessList(LPDWORD lpdwProcessList,
DWORD dwProcessCount)
{
- PCSR_API_MESSAGE Request;
+ PCSR_CAPTURE_BUFFER CaptureBuffer;
+ CSR_API_MESSAGE Request;
ULONG CsrRequest;
ULONG nProcesses;
NTSTATUS Status;
@@ -3764,43 +3765,38 @@
return 0;
}
- Request = RtlAllocateHeap(RtlGetProcessHeap(),
- 0,
- max(sizeof(CSR_API_MESSAGE),
- CSR_API_MESSAGE_HEADER_SIZE(CSRSS_GET_PROCESS_LIST)
- + min (dwProcessCount, CSRSS_MAX_GET_PROCESS_LIST /
sizeof(DWORD)) * sizeof(DWORD)));
- if (Request == NULL)
+ CaptureBuffer = CsrAllocateCaptureBuffer(1, dwProcessCount * sizeof(DWORD));
+ if (CaptureBuffer == NULL)
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return FALSE;
}
CsrRequest = MAKE_CSR_API(GET_PROCESS_LIST, CSR_CONSOLE);
- Request->Data.GetProcessListRequest.nMaxIds = min (dwProcessCount,
CSRSS_MAX_GET_PROCESS_LIST / sizeof(DWORD));
-
- Status = CsrClientCallServer(Request,
- NULL,
+ Request.Data.GetProcessListRequest.nMaxIds = dwProcessCount;
+ CsrAllocateMessagePointer(CaptureBuffer,
+ dwProcessCount * sizeof(DWORD),
+
(PVOID*)&Request.Data.GetProcessListRequest.ProcessId);
+
+ Status = CsrClientCallServer(&Request,
+ CaptureBuffer,
CsrRequest,
- max(sizeof(CSR_API_MESSAGE),
- CSR_API_MESSAGE_HEADER_SIZE(CSRSS_GET_PROCESS_LIST)
- + Request->Data.GetProcessListRequest.nMaxIds *
sizeof(DWORD)));
- if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status))
- {
- RtlFreeHeap(RtlGetProcessHeap(), 0, Request);
+ sizeof(CSR_API_MESSAGE));
+ if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ {
SetLastErrorByStatus (Status);
nProcesses = 0;
}
else
{
- nProcesses = Request->Data.GetProcessListRequest.nProcessIdsCopied;
+ nProcesses = Request.Data.GetProcessListRequest.nProcessIdsTotal;
if (dwProcessCount >= nProcesses)
{
- memcpy(lpdwProcessList, Request->Data.GetProcessListRequest.ProcessId,
nProcesses * sizeof(DWORD));
+ memcpy(lpdwProcessList, Request.Data.GetProcessListRequest.ProcessId,
nProcesses * sizeof(DWORD));
}
}
- RtlFreeHeap(RtlGetProcessHeap(), 0, Request);
-
+ CsrFreeCaptureBuffer(CaptureBuffer);
return nProcesses;
}
Modified: trunk/reactos/dll/win32/kernel32/misc/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/dl…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/dllmain.c [iso-8859-1] Sun May 23 19:40:54 2010
@@ -130,6 +130,7 @@
NTSTATUS Status;
BOOLEAN NotConsole = FALSE;
PRTL_USER_PROCESS_PARAMETERS Parameters = NtCurrentPeb()->ProcessParameters;
+ LPCWSTR ExeName;
WCHAR lpTest[MAX_PATH];
GetModuleFileNameW(NULL, lpTest, MAX_PATH);
@@ -183,13 +184,17 @@
}
}
- /* Initialize Console Ctrl Handler */
+ /* Initialize Console Ctrl Handler and input EXE name */
ConsoleInitialized = TRUE;
RtlInitializeCriticalSection(&ConsoleLock);
NrAllocatedHandlers = 1;
NrCtrlHandlers = 1;
CtrlHandlers = InitialHandler;
CtrlHandlers[0] = DefaultConsoleCtrlHandler;
+
+ ExeName = wcsrchr(Parameters->ImagePathName.Buffer, L'\\');
+ if (ExeName)
+ SetConsoleInputExeNameW(ExeName + 1);
/* Now use the proper console handle */
Request.Data.AllocConsoleRequest.Console = Parameters->ConsoleHandle;
Modified: trunk/reactos/include/reactos/subsys/csrss/csrss.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/csr…
==============================================================================
--- trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] Sun May 23 19:40:54
2010
@@ -51,10 +51,9 @@
typedef struct
{
- ULONG nMaxIds;
- ULONG nProcessIdsCopied;
- ULONG nProcessIdsTotal;
- HANDLE ProcessId[0];
+ USHORT nMaxIds;
+ PDWORD ProcessId;
+ ULONG nProcessIdsTotal;
} CSRSS_GET_PROCESS_LIST, *PCSRSS_GET_PROCESS_LIST;
typedef struct
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Sun May 23 19:40:54
2010
@@ -2960,54 +2960,48 @@
CSR_API(CsrGetProcessList)
{
- PHANDLE Buffer;
+ PDWORD Buffer;
PCSRSS_CONSOLE Console;
PCSRSS_PROCESS_DATA current;
PLIST_ENTRY current_entry;
- ULONG nItems, nCopied, Length;
- NTSTATUS Status;
+ ULONG nItems = 0;
+ NTSTATUS Status;
+ ULONG_PTR Offset;
DPRINT("CsrGetProcessList\n");
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
+
Buffer = Request->Data.GetProcessListRequest.ProcessId;
- Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
- Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-
- nItems = nCopied = 0;
- Request->Data.GetProcessListRequest.nProcessIdsCopied = 0;
- Request->Data.GetProcessListRequest.nProcessIdsTotal = 0;
+ Offset = (PBYTE)Buffer - (PBYTE)ProcessData->CsrSectionViewBase;
+ if (Offset >= ProcessData->CsrSectionViewSize
+ || (Request->Data.GetProcessListRequest.nMaxIds * sizeof(DWORD)) >
(ProcessData->CsrSectionViewSize - Offset)
+ || Offset & (sizeof(DWORD) - 1))
+ {
+ return STATUS_ACCESS_VIOLATION;
+ }
Status = ConioConsoleFromProcessData(ProcessData, &Console);
if (! NT_SUCCESS(Status))
{
return Status;
}
-
- DPRINT1("Console_Api Ctrl-C\n");
for(current_entry = Console->ProcessList.Flink;
current_entry != &Console->ProcessList;
current_entry = current_entry->Flink)
{
current = CONTAINING_RECORD(current_entry, CSRSS_PROCESS_DATA, ProcessEntry);
- if(++nItems < Request->Data.GetProcessListRequest.nMaxIds)
- {
- *(Buffer++) = current->ProcessId;
- nCopied++;
+ if(++nItems <= Request->Data.GetProcessListRequest.nMaxIds)
+ {
+ *Buffer++ = (DWORD)current->ProcessId;
}
}
ConioUnlockConsole(Console);
- Request->Data.GetProcessListRequest.nProcessIdsCopied = nCopied;
Request->Data.GetProcessListRequest.nProcessIdsTotal = nItems;
-
- Length = CSR_API_MESSAGE_HEADER_SIZE(CSRSS_GET_PROCESS_LIST) + nCopied *
sizeof(HANDLE);
- if (Length > sizeof(CSR_API_MESSAGE))
- {
- Request->Header.u1.s1.TotalLength = Length;
- Request->Header.u1.s1.DataLength = Length - sizeof(PORT_MESSAGE);
- }
return STATUS_SUCCESS;
}