- Start of fixing CreateProcess's problems. Implemented the console
creation as it should be done (not quite, but much closer to design then
before). There are still some problems (input/output handle
inconsitencies), I am currently working on these issues;
- Some debug header cleanup.
- Use the proper debug macros in some of the network code, shuts up a
lot of spam when debugging for those modules wasn't enabled.
Modified: trunk/reactos/drivers/net/afd/afd/select.c
Modified: trunk/reactos/drivers/net/dd/ne2000/ne2000/8390.c
Deleted: trunk/reactos/drivers/net/wshtcpip/debug.h
Modified: trunk/reactos/drivers/net/wshtcpip/wshtcpip.c
Modified: trunk/reactos/drivers/net/wshtcpip/wshtcpip.h
Modified: trunk/reactos/include/subsys/csrss/csrss.h
Modified: trunk/reactos/lib/kernel32/misc/console.c
Modified: trunk/reactos/lib/kernel32/misc/dllmain.c
Modified: trunk/reactos/lib/kernel32/process/create.c
Modified: trunk/reactos/subsys/csrss/api/process.c
Modified: trunk/reactos/subsys/csrss/win32csr/conio.c
Modified: trunk/reactos/subsys/system/dhcp/include/debug.h
Modified: trunk/reactos/subsys/system/dhcp/util.c
_____
Modified: trunk/reactos/drivers/net/afd/afd/select.c
--- trunk/reactos/drivers/net/afd/afd/select.c 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/drivers/net/afd/afd/select.c 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -13,6 +13,7 @@
#include "debug.h"
VOID PrintEvents( ULONG Events ) {
+#if DBG
char *events_list[] = { "AFD_EVENT_RECEIVE",
"AFD_EVENT_OOB_RECEIVE",
"AFD_EVENT_SEND",
@@ -28,7 +29,8 @@
int i;
for( i = 0; events_list[i]; i++ )
- if( Events & (1 << i) ) DbgPrint("%s ", events_list[i] );
+ if( Events & (1 << i) ) AFD_DbgPrint(MID_TRACE,("%s ",
events_list[i] ));
+#endif
}
VOID CopyBackStatus( PAFD_HANDLE HandleArray,
@@ -224,11 +226,9 @@
PollReq->Handles[i].Status = AFD_EVENT_CLOSE;
Signalled++;
} else {
-#ifdef DBG
- DbgPrint("AFD: Select Events: ");
+ AFD_DbgPrint(MID_TRACE, ("AFD: Select Events: "));
PrintEvents( PollReq->Handles[i].Events );
- DbgPrint("\n");
-#endif
+ AFD_DbgPrint(MID_TRACE,("\n"));
PollReq->Handles[i].Status =
PollReq->Handles[i].Events & FCB->PollState;
_____
Modified: trunk/reactos/drivers/net/dd/ne2000/ne2000/8390.c
--- trunk/reactos/drivers/net/dd/ne2000/ne2000/8390.c 2005-07-28
03:10:35 UTC (rev 16825)
+++ trunk/reactos/drivers/net/dd/ne2000/ne2000/8390.c 2005-07-28
04:12:43 UTC (rev 16826)
@@ -68,7 +68,7 @@
/* first try the supplied value */
if(ProbeAddressForNIC(Adapter->IoBaseAddress))
{
- NDIS_DbgPrint(MIN_TRACE, ("Found adapter at 0x%x\n",
Adapter->IoBaseAddress));
+ NDIS_DbgPrint(MID_TRACE, ("Found adapter at 0x%x\n",
Adapter->IoBaseAddress));
return TRUE;
}
@@ -77,7 +77,7 @@
{
if(ProbeAddressForNIC(ProbeAddressList[i]))
{
- NDIS_DbgPrint(MIN_TRACE, ("Found adapter at address
0x%x\n", ProbeAddressList[i]));
+ NDIS_DbgPrint(MID_TRACE, ("Found adapter at address
0x%x\n", ProbeAddressList[i]));
Adapter->IoBaseAddress = ProbeAddressList[i];
return TRUE;
}
@@ -905,7 +905,7 @@
IndicateLength + DRIVER_HEADER_SIZE);
NDIS_DbgPrint(MID_TRACE, ("Indicating (%d) bytes.\n",
IndicateLength));
- DbgPrint("ne2000!NICIndicatePacket: Indicating (%d) bytes.\n",
IndicateLength);
+ NDIS_DbgPrint(MID_TRACE, ("ne2000!NICIndicatePacket: Indicating
(%d) bytes.\n", IndicateLength));
#if 0
NDIS_DbgPrint(MAX_TRACE, ("FRAME:\n"));
_____
Deleted: trunk/reactos/drivers/net/wshtcpip/debug.h
--- trunk/reactos/drivers/net/wshtcpip/debug.h 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/drivers/net/wshtcpip/debug.h 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -1,69 +0,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS WinSock Helper DLL for TCP/IP
- * FILE: include/debug.h
- * PURPOSE: Debugging support macros
- * DEFINES: DBG - Enable debug output
- * NASSERT - Disable assertions
- */
-#ifndef __DEBUG_H
-#define __DEBUG_H
-
-#define NORMAL_MASK 0x000000FF
-#define SPECIAL_MASK 0xFFFFFF00
-#define MIN_TRACE 0x00000001
-#define MID_TRACE 0x00000002
-#define MAX_TRACE 0x00000003
-
-#define DEBUG_ULTRA 0xFFFFFFFF
-
-#ifdef DBG
-
-extern DWORD DebugTraceLevel;
-
-#define WSH_DbgPrint(_t_, _x_) \
- if (((DebugTraceLevel & NORMAL_MASK) >= _t_) || \
- ((DebugTraceLevel & _t_) > NORMAL_MASK)) { \
- DbgPrint("(%hS:%d)(%hS) ", __FILE__, __LINE__, __FUNCTION__); \
- DbgPrint _x_; \
- }
-
-/* this belongs in ndis.h */
-#if 0
-#ifdef ASSERT
-#undef ASSERT
-#endif
-
-#ifdef NASSERT
-#define ASSERT(x)
-#else /* NASSERT */
-#define ASSERT(x) if (!(x)) { WSH_DbgPrint(MIN_TRACE, ("Assertion "#x"
failed at %s:%d\n", __FILE__, __LINE__)); ExitProcess(0); }
-#endif /* NASSERT */
-#endif
-
-#else /* DBG */
-
-#define WSH_DbgPrint(_t_, _x_)
-
-/*#define ASSERT(x)*/
-
-#endif /* DBG */
-
-
-#undef assert
-#define assert(x) ASSERT(x)
-#define assert_irql(x) ASSERT_IRQL(x)
-
-
-#define UNIMPLEMENTED \
- WSH_DbgPrint(MIN_TRACE, ("(%s:%d)(%s) is unimplemented, \
- please try again later.\n", __FILE__, __LINE__, __FUNCTION__));
-
-#define CHECKPOINT \
- WSH_DbgPrint(MIN_TRACE, ("\n"));
-
-#define CP CHECKPOINT
-
-#endif /* __DEBUG_H */
-
-/* EOF */
_____
Modified: trunk/reactos/drivers/net/wshtcpip/wshtcpip.c
--- trunk/reactos/drivers/net/wshtcpip/wshtcpip.c 2005-07-28
03:10:35 UTC (rev 16825)
+++ trunk/reactos/drivers/net/wshtcpip/wshtcpip.c 2005-07-28
04:12:43 UTC (rev 16826)
@@ -8,25 +8,16 @@
* CSH 01/09-2000 Created
*/
#include <wshtcpip.h>
+#define NDEBUG
+#include <debug.h>
-#ifdef DBG
-
-/* See debug.h for debug/trace constants */
-DWORD DebugTraceLevel = MAX_TRACE;
-
-#endif /* DBG */
-
-/* To make the linker happy */
-VOID STDCALL KeBugCheck (ULONG BugCheckCode) {}
-
-
BOOL
EXPORT
DllMain(HANDLE hInstDll,
ULONG dwReason,
PVOID Reserved)
{
- WSH_DbgPrint(MIN_TRACE, ("DllMain of wshtcpip.dll\n"));
+ DPRINT("DllMain of wshtcpip.dll\n");
switch (dwReason) {
case DLL_PROCESS_ATTACH:
@@ -291,7 +282,7 @@
UNICODE_STRING RawDeviceName =
RTL_CONSTANT_STRING(DD_RAW_IP_DEVICE_NAME);
NTSTATUS Status;
- WSH_DbgPrint(MAX_TRACE, ("\n"));
+ DPRINT("");
switch (*SocketType) {
case SOCK_STREAM:
_____
Modified: trunk/reactos/drivers/net/wshtcpip/wshtcpip.h
--- trunk/reactos/drivers/net/wshtcpip/wshtcpip.h 2005-07-28
03:10:35 UTC (rev 16825)
+++ trunk/reactos/drivers/net/wshtcpip/wshtcpip.h 2005-07-28
04:12:43 UTC (rev 16826)
@@ -9,8 +9,6 @@
#include <ddk/ntddk.h>
#include <wsahelp.h>
-#include <windows.h>
-#include <debug.h>
#define EXPORT STDCALL
_____
Modified: trunk/reactos/include/subsys/csrss/csrss.h
--- trunk/reactos/include/subsys/csrss/csrss.h 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/include/subsys/csrss/csrss.h 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -33,10 +33,6 @@
{
HANDLE NewProcessId;
ULONG Flags;
- PCONTROLDISPATCHER CtrlDispatcher;
- HANDLE Console;
- HANDLE InputHandle;
- HANDLE OutputHandle;
} CSRSS_CREATE_PROCESS, *PCSRSS_CREATE_PROCESS;
typedef struct
@@ -75,6 +71,7 @@
typedef struct
{
PCONTROLDISPATCHER CtrlDispatcher;
+ BOOL ConsoleNeeded;
HANDLE Console;
HANDLE InputHandle;
HANDLE OutputHandle;
_____
Modified: trunk/reactos/lib/kernel32/misc/console.c
--- trunk/reactos/lib/kernel32/misc/console.c 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/lib/kernel32/misc/console.c 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -1341,6 +1341,7 @@
}
Request.Data.AllocConsoleRequest.CtrlDispatcher =
ConsoleControlDispatcher;
+ Request.Data.AllocConsoleRequest.ConsoleNeeded = TRUE;
CsrRequest = MAKE_CSR_API(ALLOC_CONSOLE, CSR_CONSOLE);
Status = CsrClientCallServer( &Request, NULL, CsrRequest, sizeof(
CSR_API_MESSAGE ) );
_____
Modified: trunk/reactos/lib/kernel32/misc/dllmain.c
--- trunk/reactos/lib/kernel32/misc/dllmain.c 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/lib/kernel32/misc/dllmain.c 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -37,10 +37,18 @@
RTL_CRITICAL_SECTION ConsoleLock;
extern BOOL WINAPI DefaultConsoleCtrlHandler(DWORD Event);
+extern __declspec(noreturn) VOID CALLBACK
ConsoleControlDispatcher(DWORD CodeAndFlag);
extern BOOL FASTCALL NlsInit();
extern VOID FASTCALL NlsUninit();
+HANDLE
+STDCALL
+DuplicateConsoleHandle(HANDLE hConsole,
+ DWORD dwDesiredAccess,
+ BOOL bInheritHandle,
+ DWORD dwOptions);
+
/* FUNCTIONS
*****************************************************************/
static NTSTATUS
@@ -75,7 +83,106 @@
return STATUS_SUCCESS;
}
+BOOL
+STDCALL
+BasepInitConsole(VOID)
+{
+ CSR_API_MESSAGE Request;
+ ULONG CsrRequest;
+ NTSTATUS Status;
+ PRTL_USER_PROCESS_PARAMETERS Parameters =
NtCurrentPeb()->ProcessParameters;
+ WCHAR lpTest[MAX_PATH];
+ GetModuleFileNameW(NULL, lpTest, MAX_PATH);
+ DPRINT1("BasepInitConsole for : %S\n", lpTest);
+ DPRINT1("Our current console handles are: %lx, %lx, %lx\n",
+ Parameters->ConsoleHandle, Parameters->StandardInput,
+ Parameters->StandardOutput);
+
+ /* We have nothing to do if this isn't a console app... */
+ if
(RtlImageNtHeader(GetModuleHandle(NULL))->OptionalHeader.Subsystem !=
+ IMAGE_SUBSYSTEM_WINDOWS_CUI)
+ {
+ DPRINT1("Image is not a console application\n");
+ Parameters->ConsoleHandle = NULL;
+ return TRUE;
+ }
+
+ /* Assume one is needed */
+ Request.Data.AllocConsoleRequest.ConsoleNeeded = TRUE;
+
+ /* Handle the special flags given to us by
BasepInitializeEnvironment */
+ if (Parameters->ConsoleHandle == HANDLE_DETACHED_PROCESS)
+ {
+ /* No console to create */
+ DPRINT1("No console to create\n");
+ Parameters->ConsoleHandle = NULL;
+ Request.Data.AllocConsoleRequest.ConsoleNeeded = FALSE;
+ }
+ else if (Parameters->ConsoleHandle == HANDLE_CREATE_NEW_CONSOLE)
+ {
+ /* We'll get the real one soon */
+ DPRINT1("Creating new console\n");
+ Parameters->ConsoleHandle = NULL;
+ }
+ else if (Parameters->ConsoleHandle == HANDLE_CREATE_NO_WINDOW)
+ {
+ /* We'll get the real one soon */
+ DPRINT1("NOT SUPPORTED: HANDLE_CREATE_NO_WINDOW\n");
+ Parameters->ConsoleHandle = NULL;
+ }
+ else
+ {
+ DPRINT1("Using existing console: %x\n",
Parameters->ConsoleHandle);
+ }
+
+ /* Initialize Console Ctrl Handler */
+ RtlInitializeCriticalSection(&ConsoleLock);
+ SetConsoleCtrlHandler(DefaultConsoleCtrlHandler, TRUE);
+
+ /* Now use the proper console handle */
+ Request.Data.AllocConsoleRequest.Console =
Parameters->ConsoleHandle;
+
+ /*
+ * Normally, we should be connecting to the Console CSR Server...
+ * but we don't have one yet, so we will instead simply send a
create
+ * console message to the Base Server. When we finally have a
Console
+ * Server, this code should be changed to send connection data
instead.
+ *
+ * Also note that this connection should be made for any console
app, even
+ * in the case above where -we- return.
+ */
+ CsrRequest = MAKE_CSR_API(ALLOC_CONSOLE, CSR_CONSOLE);
+ Request.Data.AllocConsoleRequest.CtrlDispatcher =
ConsoleControlDispatcher;
+ Status = CsrClientCallServer(&Request,
+ NULL,
+ CsrRequest,
+ sizeof(CSR_API_MESSAGE));
+ if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status))
+ {
+ DPRINT1("CSR Failed to give us a console\n");
+ /* We're lying here, so at least the process can load... */
+ return TRUE;
+ }
+
+ /* We got the handles, let's set them */
+ Parameters->ConsoleHandle =
Request.Data.AllocConsoleRequest.Console;
+ SetStdHandle(STD_INPUT_HANDLE,
Request.Data.AllocConsoleRequest.InputHandle);
+ SetStdHandle(STD_OUTPUT_HANDLE,
Request.Data.AllocConsoleRequest.OutputHandle);
+ SetStdHandle(STD_ERROR_HANDLE,
+
DuplicateConsoleHandle(Request.Data.AllocConsoleRequest.OutputHandle,
+ 0,
+ TRUE,
+ DUPLICATE_SAME_ACCESS));
+
+ DPRINT1("Console setup: %lx, %lx, %lx\n",
+ Request.Data.AllocConsoleRequest.Console,
+ Request.Data.AllocConsoleRequest.InputHandle,
+ Request.Data.AllocConsoleRequest.OutputHandle);
+ return TRUE;
+}
+
+
BOOL STDCALL
DllMain(HANDLE hDll,
DWORD dwReason,
@@ -148,11 +255,13 @@
return FALSE;
}
- /* Initialize console ctrl handler */
- RtlInitializeCriticalSection(&ConsoleLock);
- SetConsoleCtrlHandler(DefaultConsoleCtrlHandler, TRUE);
+ /* Initialize Console Support */
+ if (!BasepInitConsole())
+ {
+ DPRINT1("Failure to set up console\n");
+ return FALSE;
+ }
-
/* Insert more dll attach stuff here! */
DllInitialized = TRUE;
_____
Modified: trunk/reactos/lib/kernel32/process/create.c
--- trunk/reactos/lib/kernel32/process/create.c 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/lib/kernel32/process/create.c 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -80,36 +80,18 @@
NTSTATUS
STDCALL
BasepNotifyCsrOfCreation(ULONG dwCreationFlags,
- IN HANDLE ProcessId,
- IN ULONG SubsystemType,
- OUT PHANDLE ConsoleHandle,
- OUT PHANDLE InputHandle,
- OUT PHANDLE OutputHandle)
+ IN HANDLE ProcessId)
{
ULONG Request = CREATE_PROCESS;
CSR_API_MESSAGE CsrRequest;
NTSTATUS Status;
- DPRINT("BasepNotifyCsrOfCreation\n");
-
- /* Some hacks (heck, this whole API is a hack) */
- if (SubsystemType == IMAGE_SUBSYSTEM_WINDOWS_GUI)
- {
- dwCreationFlags = (dwCreationFlags &~ CREATE_NEW_CONSOLE) |
- DETACHED_PROCESS;
- }
- else if (SubsystemType == IMAGE_SUBSYSTEM_WINDOWS_CUI)
- {
- dwCreationFlags |= CREATE_NEW_CONSOLE;
- }
-
+ DPRINT1("BasepNotifyCsrOfCreation: Process: %lx, Flags %lx\n",
+ ProcessId, dwCreationFlags);
+
/* Fill out the request */
CsrRequest.Data.CreateProcessRequest.NewProcessId = ProcessId;
CsrRequest.Data.CreateProcessRequest.Flags = dwCreationFlags;
- CsrRequest.Data.CreateProcessRequest.CtrlDispatcher =
ConsoleControlDispatcher;
- CsrRequest.Data.CreateProcessRequest.InputHandle = 0;
- CsrRequest.Data.CreateProcessRequest.OutputHandle = 0;
- CsrRequest.Data.CreateProcessRequest.Console = 0;
/* Call CSR */
Status = CsrClientCallServer(&CsrRequest,
@@ -121,11 +103,6 @@
DPRINT1("Failed to tell csrss about new process\n");
return CsrRequest.Status;
}
- /* Return Handles */
- *ConsoleHandle = CsrRequest.Data.CreateProcessRequest.Console;
- *InputHandle = CsrRequest.Data.CreateProcessRequest.InputHandle;
- *OutputHandle = CsrRequest.Data.CreateProcessRequest.OutputHandle;
- DPRINT("CSR Created: %lx %lx\n", *InputHandle, *OutputHandle);
/* REturn Success */
return STATUS_SUCCESS;
@@ -356,9 +333,7 @@
LPVOID Environment,
LPSTARTUPINFOW StartupInfo,
DWORD CreationFlags,
- BOOL InheritHandles,
- HANDLE hInput,
- HANDLE hOutput)
+ BOOL InheritHandles)
{
WCHAR FullPath[MAX_PATH];
LPWSTR Remaining;
@@ -570,14 +545,6 @@
PPF_PROFILE_SERVER : 0;
ProcessParameters->Flags |=
(NtCurrentPeb()->ProcessParameters->Flags &
PPF_DISABLE_HEAP_CHECKS);
-
- /*
- * FIXME: Our console init stuff is messy. See my comment in
kernel32's
- * DllMain.
- */
- if (!ProcessParameters->StandardInput)
ProcessParameters->StandardInput = hInput;
- if (!ProcessParameters->StandardOutput)
ProcessParameters->StandardOutput = hOutput;
- if (!ProcessParameters->StandardError)
ProcessParameters->StandardError = hOutput;
/* Write the Parameter Block */
Status = NtWriteVirtualMemory(ProcessHandle,
@@ -780,7 +747,6 @@
ULONG RetVal;
UINT Error;
BOOLEAN SearchDone = FALSE;
- HANDLE hConsole, hInput, hOutput;
CLIENT_ID ClientId;
PPEB OurPeb = NtCurrentPeb();
PPEB RemotePeb;
@@ -1316,21 +1282,6 @@
&ProcessBasicInfo,
sizeof(ProcessBasicInfo),
NULL);
-
- /* Notify CSRSS */
- Status = BasepNotifyCsrOfCreation(dwCreationFlags,
-
(HANDLE)ProcessBasicInfo.UniqueProcessId,
- SectionImageInfo.SubsystemType,
- &hConsole,
- &hInput,
- &hOutput);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("CSR Notification Failed");
- SetLastErrorByStatus(Status);
- return FALSE;
- }
/* Create Process Environment */
RemotePeb = ProcessBasicInfo.PebBaseAddress;
@@ -1343,9 +1294,7 @@
lpEnvironment,
lpStartupInfo,
dwCreationFlags,
- bInheritHandles,
- hInput,
- hOutput);
+ bInheritHandles);
if (!NT_SUCCESS(Status))
{
DPRINT1("Could not initialize Process Environment\n");
@@ -1400,7 +1349,19 @@
DPRINT1("Could not create Initial Thread\n");
return FALSE;
}
+
+ /* Notify CSRSS */
+ Status = BasepNotifyCsrOfCreation(dwCreationFlags,
+
(HANDLE)ProcessBasicInfo.UniqueProcessId);
+
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR Notification Failed");
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+
if (!(dwCreationFlags & CREATE_SUSPENDED))
{
NtResumeThread(hThread, &Dummy);
_____
Modified: trunk/reactos/subsys/csrss/api/process.c
--- trunk/reactos/subsys/csrss/api/process.c 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/subsys/csrss/api/process.c 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -192,8 +192,6 @@
CSR_API(CsrCreateProcess)
{
PCSRSS_PROCESS_DATA NewProcessData;
- NTSTATUS Status;
- CSR_API_MESSAGE ApiRequest;
Request->Header.DataSize = sizeof(CSR_API_MESSAGE) -
LPC_MESSAGE_BASE_SIZE;
Request->Header.MessageSize = sizeof(CSR_API_MESSAGE);
@@ -209,57 +207,6 @@
NewProcessData->ShutdownLevel = 0x280;
NewProcessData->ShutdownFlags = 0;
- if (Request->Data.CreateProcessRequest.Flags & DETACHED_PROCESS)
- {
- NewProcessData->Console = NULL;
- }
- else if (Request->Data.CreateProcessRequest.Flags &
CREATE_NEW_CONSOLE)
- {
- ApiRequest.Type = ALLOC_CONSOLE;
- ApiRequest.Header.DataSize = sizeof(CSRSS_ALLOC_CONSOLE);
- ApiRequest.Header.MessageSize = LPC_MESSAGE_BASE_SIZE +
sizeof(CSRSS_ALLOC_CONSOLE);
- ApiRequest.Data.AllocConsoleRequest.CtrlDispatcher =
Request->Data.CreateProcessRequest.CtrlDispatcher;
-
- CsrApiCallHandler(NewProcessData, &ApiRequest);
-
- Request->Status = ApiRequest.Status;
- if (! NT_SUCCESS(Request->Status))
- {
-
CsrFreeProcessData(Request->Data.CreateProcessRequest.NewProcessId);
- return Request->Status;
- }
- Request->Data.CreateProcessRequest.InputHandle =
ApiRequest.Data.AllocConsoleRequest.InputHandle;
- Request->Data.CreateProcessRequest.OutputHandle =
ApiRequest.Data.AllocConsoleRequest.OutputHandle;
- }
- else
- {
- NewProcessData->Console = ProcessData->Console;
- InterlockedIncrement(
&(ProcessData->Console->Header.ReferenceCount) );
- CsrInsertObject(NewProcessData,
- &Request->Data.CreateProcessRequest.InputHandle,
- (Object_t *)NewProcessData->Console);
- RtlEnterCriticalSection(&ProcessDataLock );
- CsrInsertObject( NewProcessData,
- &Request->Data.CreateProcessRequest.OutputHandle,
- &(NewProcessData->Console->ActiveBuffer->Header) );
-
- RtlLeaveCriticalSection(&ProcessDataLock);
- Status = NtDuplicateObject( NtCurrentProcess(),
NewProcessData->Console->ActiveEvent, NewProcessData->Process,
&NewProcessData->ConsoleEvent, SYNCHRONIZE, FALSE, 0 );
- if( !NT_SUCCESS( Status ) )
- {
- DbgPrint( "CSR: NtDuplicateObject() failed: %x\n", Status );
- CsrFreeProcessData( NewProcessData->ProcessId );
- Request->Status = Status;
- return Status;
- }
- NewProcessData->CtrlDispatcher =
Request->Data.CreateProcessRequest.CtrlDispatcher;
- RtlEnterCriticalSection(&ProcessDataLock );
- InsertHeadList(&NewProcessData->Console->ProcessList,
&NewProcessData->ProcessEntry);
- RtlLeaveCriticalSection(&ProcessDataLock);
- }
-
- Request->Data.CreateProcessRequest.Console =
NewProcessData->Console;
-
Request->Status = STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
_____
Modified: trunk/reactos/subsys/csrss/win32csr/conio.c
--- trunk/reactos/subsys/csrss/win32csr/conio.c 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/subsys/csrss/win32csr/conio.c 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -223,75 +223,124 @@
CSR_API(CsrAllocConsole)
{
- PCSRSS_CONSOLE Console;
- NTSTATUS Status;
+ PCSRSS_CONSOLE Console;
+ NTSTATUS Status;
- DPRINT("CsrAllocConsole\n");
+ DPRINT1("CsrAllocConsole\n");
- Request->Header.MessageSize = sizeof(CSR_API_MESSAGE);
- Request->Header.DataSize = sizeof(CSR_API_MESSAGE) -
LPC_MESSAGE_BASE_SIZE;
+ Request->Header.MessageSize = sizeof(CSR_API_MESSAGE);
+ Request->Header.DataSize = sizeof(CSR_API_MESSAGE) -
LPC_MESSAGE_BASE_SIZE;
- if (ProcessData == NULL)
+ if (ProcessData == NULL)
{
- return Request->Status = STATUS_INVALID_PARAMETER;
+ DPRINT1("No process data\n");
+ return Request->Status = STATUS_INVALID_PARAMETER;
}
- if (ProcessData->Console)
+ if (ProcessData->Console)
{
- Request->Status = STATUS_INVALID_PARAMETER;
- return STATUS_INVALID_PARAMETER;
+ DPRINT1("Process already has a console\n");
+ Request->Status = STATUS_INVALID_PARAMETER;
+ return STATUS_INVALID_PARAMETER;
}
- Request->Status = STATUS_SUCCESS;
- Console = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_CONSOLE));
- if (NULL == Console)
+ /* Assume success */
+ Request->Status = STATUS_SUCCESS;
+
+ /* If we don't need a console, then get out of here */
+ if (!Request->Data.AllocConsoleRequest.ConsoleNotNeeded)
{
- Request->Status = STATUS_NO_MEMORY;
- return STATUS_NO_MEMORY;
+ DPRINT1("No console needed\n");
+ return STATUS_SUCCESS;
}
- Request->Status = CsrInitConsole(Console);
- if (! NT_SUCCESS(Request->Status))
+
+ /* If we already have one, then don't create a new one... */
+ if (!Request->Data.AllocConsoleRequest.Console)
{
- HeapFree(Win32CsrApiHeap, 0, Console);
- return Request->Status;
+ /* Allocate a console structure */
+ Console = HeapAlloc(Win32CsrApiHeap, 0, sizeof(CSRSS_CONSOLE));
+ if (NULL == Console)
+ {
+ DPRINT1("Not enough memory for console\n");
+ Request->Status = STATUS_NO_MEMORY;
+ return STATUS_NO_MEMORY;
+ }
+
+ /* Initialize the Console */
+ Request->Status = CsrInitConsole(Console);
+ if (!NT_SUCCESS(Request->Status))
+ {
+ DPRINT1("Console init failed\n");
+ HeapFree(Win32CsrApiHeap, 0, Console);
+ return Request->Status;
+ }
}
- ProcessData->Console = Console;
- Request->Data.AllocConsoleRequest.Console = Console;
+ else
+ {
+ /* Reuse our current console */
+ Console = Request->Data.AllocConsoleRequest.Console;
+ }
- /* add a reference count because the process is tied to the console
*/
- Console->Header.ReferenceCount++;
- Status = Win32CsrInsertObject(ProcessData,
&Request->Data.AllocConsoleRequest.InputHandle, &Console->Header);
- if (! NT_SUCCESS(Status))
+ /* Set the Process Console */
+ ProcessData->Console = Console;
+
+ /* Return it to the caller */
+ Request->Data.AllocConsoleRequest.Console = Console;
+
+ /* Add a reference count because the process is tied to the console
*/
+ Console->Header.ReferenceCount++;
+
+ /* Insert the Objects */
+ Status = Win32CsrInsertObject(ProcessData,
+
&Request->Data.AllocConsoleRequest.InputHandle,
+ &Console->Header);
+ if (! NT_SUCCESS(Status))
{
- ConioDeleteConsole((Object_t *) Console);
- ProcessData->Console = 0;
- return Request->Status = Status;
+ DPRINT1("Failed to insert object\n");
+ ConioDeleteConsole((Object_t *) Console);
+ ProcessData->Console = 0;
+ return Request->Status = Status;
}
- Status = Win32CsrInsertObject(ProcessData,
&Request->Data.AllocConsoleRequest.OutputHandle,
&Console->ActiveBuffer->Header);
- if (!NT_SUCCESS(Status))
+ Status = Win32CsrInsertObject(ProcessData,
+
&Request->Data.AllocConsoleRequest.OutputHandle,
+ &Console->ActiveBuffer->Header);
+ if (!NT_SUCCESS(Status))
{
- Console->Header.ReferenceCount--;
- Win32CsrReleaseObject(ProcessData,
Request->Data.AllocConsoleRequest.InputHandle);
- ProcessData->Console = 0;
- return Request->Status = Status;
+ DPRINT1("Failed to insert object\n");
+ Console->Header.ReferenceCount--;
+ Win32CsrReleaseObject(ProcessData,
+
Request->Data.AllocConsoleRequest.InputHandle);
+ ProcessData->Console = 0;
+ return Request->Status = Status;
}
- if (! DuplicateHandle(GetCurrentProcess(),
ProcessData->Console->ActiveEvent,
- ProcessData->Process,
&ProcessData->ConsoleEvent, EVENT_ALL_ACCESS, FALSE, 0))
+ /* Duplicate the Event */
+ if (!DuplicateHandle(GetCurrentProcess(),
+ ProcessData->Console->ActiveEvent,
+ ProcessData->Process,
+ &ProcessData->ConsoleEvent,
+ EVENT_ALL_ACCESS,
+ FALSE,
+ 0))
{
- DPRINT1("DuplicateHandle() failed: %d\n", GetLastError);
- Console->Header.ReferenceCount--;
- Win32CsrReleaseObject(ProcessData,
Request->Data.AllocConsoleRequest.OutputHandle);
- Win32CsrReleaseObject(ProcessData,
Request->Data.AllocConsoleRequest.InputHandle);
- ProcessData->Console = 0;
- Request->Status = Status;
- return Status;
+ DPRINT1("DuplicateHandle() failed: %d\n", GetLastError);
+ Console->Header.ReferenceCount--;
+ Win32CsrReleaseObject(ProcessData,
+
Request->Data.AllocConsoleRequest.OutputHandle);
+ Win32CsrReleaseObject(ProcessData,
+
Request->Data.AllocConsoleRequest.InputHandle);
+ ProcessData->Console = 0;
+ Request->Status = Status;
+ return Status;
}
- ProcessData->CtrlDispatcher =
Request->Data.AllocConsoleRequest.CtrlDispatcher;
- DPRINT("CSRSS:CtrlDispatcher address: %x\n",
ProcessData->CtrlDispatcher);
- InsertHeadList(&ProcessData->Console->ProcessList,
&ProcessData->ProcessEntry);
- return STATUS_SUCCESS;
+ /* Set the Ctrl Dispatcher */
+ ProcessData->CtrlDispatcher =
Request->Data.AllocConsoleRequest.CtrlDispatcher;
+ DPRINT1("CSRSS:CtrlDispatcher address: %x\n",
ProcessData->CtrlDispatcher);
+
+ /* Insert into the list */
+ InsertHeadList(&ProcessData->Console->ProcessList,
&ProcessData->ProcessEntry);
+ return STATUS_SUCCESS;
}
CSR_API(CsrFreeConsole)
_____
Modified: trunk/reactos/subsys/system/dhcp/include/debug.h
--- trunk/reactos/subsys/system/dhcp/include/debug.h 2005-07-28
03:10:35 UTC (rev 16825)
+++ trunk/reactos/subsys/system/dhcp/include/debug.h 2005-07-28
04:12:43 UTC (rev 16826)
@@ -42,43 +42,12 @@
#endif /* _MSC_VER */
-#define ASSERT_IRQL(x) ASSERT(KeGetCurrentIrql() <= (x))
-
#else /* DBG */
#define DH_DbgPrint(_t_, _x_)
#endif /* DBG */
-
-#define assert(x) ASSERT(x)
-#define assert_irql(x) ASSERT_IRQL(x)
-
-
-#ifdef _MSC_VER
-
-#define UNIMPLEMENTED \
- TI_DbgPrint(MIN_TRACE, ("The function at %s:%d is unimplemented, \
- but come back another day.\n", __FILE__, __LINE__));
-
-#else /* _MSC_VER */
-
-#define UNIMPLEMENTED \
- TI_DbgPrint(MIN_TRACE, ("(%s:%d)(%s) is unimplemented, \
- but come back another day.\n", __FILE__, __LINE__,
__FUNCTION__));
-
-#endif /* _MSC_VER */
-
-
-#define CHECKPOINT \
- do { TI_DbgPrint(DEBUG_CHECK, ("(%s:%d)\n", __FILE__, __LINE__)); }
while(0);
-
-#define CP CHECKPOINT
-
-#define ASSERT_KM_POINTER(_x) \
- ASSERT(((PVOID)_x) != (PVOID)0xcccccccc); \
- ASSERT(((PVOID)_x) >= (PVOID)0x80000000);
-
#endif /* __DEBUG_H */
/* EOF */
_____
Modified: trunk/reactos/subsys/system/dhcp/util.c
--- trunk/reactos/subsys/system/dhcp/util.c 2005-07-28 03:10:35 UTC
(rev 16825)
+++ trunk/reactos/subsys/system/dhcp/util.c 2005-07-28 04:12:43 UTC
(rev 16826)
@@ -1,4 +1,5 @@
#include <stdarg.h>
+#include <reactos/debug.h>
#include "rosdhcp.h"
char *piaddr( struct iaddr addr ) {
@@ -15,7 +16,7 @@
ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
- DbgPrint("NOTE: %s\n", buf);
+ DPRINT("NOTE: %s\n", buf);
return ret;
}
@@ -28,7 +29,7 @@
ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
- DbgPrint("DEBUG: %s\n", buf);
+ DPRINT("DEBUG: %s\n", buf);
return ret;
}
@@ -41,7 +42,7 @@
ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
- DbgPrint("WARN: %s\n", buf);
+ DPRINT("WARN: %s\n", buf);
return ret;
}
@@ -54,7 +55,7 @@
ret = vsnprintf( buf, sizeof(buf), format, arg_begin );
- DbgPrint("WARNING: %s\n", buf);
+ DPRINT("WARNING: %s\n", buf);
return ret;
}
@@ -66,7 +67,7 @@
vsnprintf( buf, sizeof(buf), format, arg_begin );
- DbgPrint("ERROR: %s\n", buf);
+ DPRINT1("ERROR: %s\n", buf);
}
int16_t getShort( unsigned char *data ) {