diff --git a/reactos/ntoskrnl/Makefile b/reactos/ntoskrnl/Makefile index 395c3482681..7d32cd09d33 100644 --- a/reactos/ntoskrnl/Makefile +++ b/reactos/ntoskrnl/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.39 2001/05/01 23:08:17 chorns Exp $ +# $Id: Makefile,v 1.40 2001/05/05 19:13:08 chorns Exp $ # # ReactOS Operating System # @@ -31,7 +31,8 @@ STRIP_FLAGS := -Wl,-s endif ifeq ($(KDBG), 1) -OBJECTS_KDBG := dbg/kdb.o dbg/kdb_keyboard.o dbg/i386/kdb_help.o +OBJECTS_KDBG := dbg/kdb.o dbg/kdb_keyboard.o dbg/rdebug.o \ + dbg/i386/kdb_help.o CONFIG += KDBG else OBJECTS_KDBG := diff --git a/reactos/ntoskrnl/dbg/kdb.c b/reactos/ntoskrnl/dbg/kdb.c index 6853ab73b47..69bd4bbf363 100644 --- a/reactos/ntoskrnl/dbg/kdb.c +++ b/reactos/ntoskrnl/dbg/kdb.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: kdb.c,v 1.4 2001/04/22 14:47:00 chorns Exp $ +/* $Id: kdb.c,v 1.5 2001/05/05 19:13:08 chorns Exp $ * * PROJECT: ReactOS kernel * FILE: ntoskrnl/dbg/kdb.c @@ -58,6 +58,12 @@ ULONG DbgProcessListCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf); ULONG DbgProcessHelpCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf); +ULONG +DbgShowFilesCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf); +ULONG +DbgEnableFileCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf); +ULONG +DbgDisableFileCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf); struct { @@ -73,6 +79,9 @@ struct {"bugcheck", "bugcheck", "Bugcheck the system", DbgBugCheckCommand}, {"bt", "bt [*frame-address]|[thread-id]","Do a backtrace", DbgBackTraceCommand}, {"plist", "plist", "Display processes in the system", DbgProcessListCommand}, + {"sfiles", "sfiles", "Show files that print debug prints", DbgShowFilesCommand}, + {"efile", "efile ", "Enable debug prints from file", DbgEnableFileCommand}, + {"dfile", "dfile ", "Disable debug prints from file", DbgDisableFileCommand}, {"help", "help", "Display help screen", DbgProcessHelpCommand}, {NULL, NULL, NULL} }; @@ -570,6 +579,39 @@ DbgBugCheckCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf) return(1); } +ULONG +DbgShowFilesCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf) +{ + DbgShowFiles(); + return(1); +} + +ULONG +DbgEnableFileCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf) +{ + if (Argc == 2) + { + if (strlen(Argv[1]) > 0) + { + DbgEnableFile(Argv[1]); + } + } + return(1); +} + +ULONG +DbgDisableFileCommand(ULONG Argc, PCH Argv[], PKTRAP_FRAME Tf) +{ + if (Argc == 2) + { + if (strlen(Argv[1]) > 0) + { + DbgDisableFile(Argv[1]); + } + } + return(1); +} + ULONG KdbDoCommand(PCH CommandLine, PKTRAP_FRAME Tf) { @@ -614,7 +656,7 @@ KdbMainLoop(PKTRAP_FRAME Tf) DbgPrint("\nEntered kernel debugger (type \"help\" for a list of commands)\n"); do { - DbgPrint("kdb:> "); + DbgPrint("\nkdb:> "); KdbGetCommand(Command); diff --git a/reactos/ntoskrnl/dbg/kdb.h b/reactos/ntoskrnl/dbg/kdb.h index c5c67f18855..570759ea109 100644 --- a/reactos/ntoskrnl/dbg/kdb.h +++ b/reactos/ntoskrnl/dbg/kdb.h @@ -2,3 +2,11 @@ ULONG KdbTryGetCharKeyboard(VOID); VOID KdbEnter(VOID); +VOID +DbgRDebugInit(VOID); +VOID +DbgShowFiles(VOID); +VOID +DbgEnableFile(PCH Filename); +VOID +DbgDisableFile(PCH Filename); diff --git a/reactos/ntoskrnl/dbg/rdebug.c b/reactos/ntoskrnl/dbg/rdebug.c new file mode 100644 index 00000000000..88edc3bbd06 --- /dev/null +++ b/reactos/ntoskrnl/dbg/rdebug.c @@ -0,0 +1,154 @@ +/* + * ReactOS kernel + * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: rdebug.c,v 1.1 2001/05/05 19:13:09 chorns Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS kernel + * FILE: ntoskrnl/dbg/rdebug.c + * PURPOSE: Runtime debugging support + * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net) + * UPDATE HISTORY: + * 01-05-2001 CSH Created + */ + +/* INCLUDES *****************************************************************/ + +#include + +#define NDEBUG +#include + +/* GLOBALS ******************************************************************/ + +typedef struct _RDEBUG_ENTRY { + LIST_ENTRY ListEntry; + CHAR Filename[MAX_PATH]; +} RDEBUG_ENTRY, *PRDEBUG_ENTRY; + +LIST_ENTRY RDebugListHead; +BOOLEAN RDebugInitialized = FALSE; + +/* FUNCTIONS ****************************************************************/ + +PRDEBUG_ENTRY +DbgpFind(PCH Filename) +{ + PLIST_ENTRY Current; + PRDEBUG_ENTRY Entry; + + Current = RDebugListHead.Flink; + while (Current != &RDebugListHead) + { + Entry = CONTAINING_RECORD(Current, RDEBUG_ENTRY, ListEntry); + + if (strcmp(Filename, Entry->Filename) == 0) + { + return Entry; + } + Current = Current->Flink; + } + + return(NULL); +} + +VOID +DbgRDebugInit(VOID) +{ + if (RDebugInitialized) + return; + + InitializeListHead(&RDebugListHead); + RDebugInitialized = TRUE; +} + +VOID +DbgShowFiles(VOID) +{ + PLIST_ENTRY Current; + PRDEBUG_ENTRY Entry; + ULONG Count; + + if (!RDebugInitialized) + return; + + Count = 0; + Current = RDebugListHead.Flink; + while (Current != &RDebugListHead) + { + Entry = CONTAINING_RECORD(Current, RDEBUG_ENTRY, ListEntry); + + DbgPrint(" %s\n", Entry->Filename); + Count++; + + Current = Current->Flink; + } + + if (Count == 1) + { + DbgPrint(" 1 file listed\n"); + } + else + { + DbgPrint(" %d files listed\n", Count); + } +} + +VOID +DbgEnableFile(PCH Filename) +{ + PRDEBUG_ENTRY Entry; + + if (!RDebugInitialized) + return; + + if (!DbgpFind(Filename)) + { + Entry = ExAllocatePool(NonPagedPool, sizeof(RDEBUG_ENTRY)); + assert(Entry); + RtlMoveMemory(Entry->Filename, Filename, strlen(Filename) + 1); + InsertTailList(&RDebugListHead, &Entry->ListEntry); + } +} + +VOID +DbgDisableFile(PCH Filename) +{ + PRDEBUG_ENTRY Entry; + + if (!RDebugInitialized) + return; + + Entry = DbgpFind(Filename); + + if (Entry) + { + RemoveEntryList(&Entry->ListEntry); + } +} + +BOOLEAN +DbgShouldPrint(PCH Filename) +{ + if (!RDebugInitialized) + return FALSE; + + return(DbgpFind(Filename) != NULL); +} + +/* EOF */ diff --git a/reactos/ntoskrnl/include/internal/dbg.h b/reactos/ntoskrnl/include/internal/dbg.h index 59df3057f74..87b3d1ec51b 100644 --- a/reactos/ntoskrnl/include/internal/dbg.h +++ b/reactos/ntoskrnl/include/internal/dbg.h @@ -13,5 +13,7 @@ VOID DbgkCreateThread(PVOID StartAddress); ULONG DbgkForwardException(EXCEPTION_RECORD Er, ULONG FirstChance); +BOOLEAN +DbgShouldPrint(PCH Filename); #endif /* __INCLUDE_INTERNAL_DBG_H */ diff --git a/reactos/ntoskrnl/include/internal/debug.h b/reactos/ntoskrnl/include/internal/debug.h index 2f5f76b256d..1a894926af9 100644 --- a/reactos/ntoskrnl/include/internal/debug.h +++ b/reactos/ntoskrnl/include/internal/debug.h @@ -20,13 +20,10 @@ #include #include +#include #define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0); -/* FIXME: should probably remove this later */ -#if !defined(CHECKED) && !defined(NDEBUG) -#define CHECKED -#endif #ifdef DBG @@ -50,29 +47,29 @@ #define DPRINT1(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); #define CHECKPOINT1 do { DbgPrint("%s:%d\n",__FILE__,__LINE__); } while(0); -extern unsigned int old_idt[256][2]; -//extern unsigned int idt; -extern unsigned int old_idt_valid; +#if defined(KDBG) && defined(NDEBUG) -#ifdef __NTOSKRNL__ -//#define DPRINT_CHECKS ExAllocatePool(NonPagedPool,0); assert(old_idt_valid || (!memcmp(old_idt,KiIdt,256*2))); -//#define DPRINT_CHECKS ExAllocatePool(NonPagedPool,0); -#define DPRINT_CHECKS -#else -#define DPRINT_CHECKS -#endif +#define DPRINT(args...) do { \ + if (DbgShouldPrint(__FILE__)) { \ + DbgPrint("(%s:%d) ",__FILE__,__LINE__); \ + DbgPrint(args); \ + } \ +} while(0); + +#define CHECKPOINT + +#else /* KDBG && NDEBUG */ #ifndef NDEBUG -#define OLD_DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0); -#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); DPRINT_CHECKS } while(0); +#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); } while(0); #define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0); -#else -//#define DPRINT(args...) do { DPRINT_CHECKS } while (0); +#else /* NDEBUG */ #define DPRINT(args...) -#define OLD_DPRINT(args...) #define CHECKPOINT #endif /* NDEBUG */ +#endif /* KDBG && NDEBUG */ + /* * FUNCTION: Assert a maximum value for the current irql * ARGUMENTS: diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index bbe9d3cb258..9ac5d550389 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -1,4 +1,4 @@ -/* $Id: device.c,v 1.27 2001/05/01 23:08:19 chorns Exp $ +/* $Id: device.c,v 1.28 2001/05/05 19:13:09 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -434,20 +434,20 @@ IopInitializeDriver(PDRIVER_INITIALIZE DriverEntry, ExFreePool(DriverObject); return(Status); } - else - { + } + else if (Fdo->DeviceType == FILE_DEVICE_ACPI) + { #ifdef ACPI - static BOOLEAN SystemPowerDeviceNodeCreated = FALSE; + static BOOLEAN SystemPowerDeviceNodeCreated = FALSE; - /* The system power device node is the first bus enumerator - device node created after the root device node */ - if (!SystemPowerDeviceNodeCreated) - { - PopSystemPowerDeviceNode = DeviceNode; - SystemPowerDeviceNodeCreated = TRUE; - } -#endif /* ACPI */ + /* The system power device node is the first bus enumerator + device node created after the root device node */ + if (!SystemPowerDeviceNodeCreated) + { + PopSystemPowerDeviceNode = DeviceNode; + SystemPowerDeviceNodeCreated = TRUE; } +#endif /* ACPI */ } ObDereferenceObject(Fdo); } diff --git a/reactos/ntoskrnl/io/fs.c b/reactos/ntoskrnl/io/fs.c index 053bd642500..42025abc944 100644 --- a/reactos/ntoskrnl/io/fs.c +++ b/reactos/ntoskrnl/io/fs.c @@ -1,4 +1,4 @@ -/* $Id: fs.c,v 1.16 2001/03/07 16:48:41 dwelch Exp $ +/* $Id: fs.c,v 1.17 2001/05/05 19:13:09 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -57,11 +57,11 @@ NtFsControlFile ( PIO_STACK_LOCATION StackPtr; KEVENT KEvent; - DPRINT("NtFsControlFile(DeviceHandle %x Event %x UserApcRoutine %x " - "UserApcContext %x IoStatusBlock %x IoControlCode %x " + DPRINT("NtFsControlFile(DeviceHandle %x EventHandle %x ApcRoutine %x " + "ApcContext %x IoStatusBlock %x IoControlCode %x " "InputBuffer %x InputBufferSize %x OutputBuffer %x " "OutputBufferSize %x)\n", - DeviceHandle,Event,UserApcRoutine,UserApcContext,IoStatusBlock, + DeviceHandle,EventHandle,ApcRoutine,ApcContext,IoStatusBlock, IoControlCode,InputBuffer,InputBufferSize,OutputBuffer, OutputBufferSize); diff --git a/reactos/ntoskrnl/kd/kdebug.c b/reactos/ntoskrnl/kd/kdebug.c index 164143ee935..63bc2331cfd 100644 --- a/reactos/ntoskrnl/kd/kdebug.c +++ b/reactos/ntoskrnl/kd/kdebug.c @@ -1,4 +1,4 @@ -/* $Id: kdebug.c,v 1.25 2001/04/26 14:26:22 phreak Exp $ +/* $Id: kdebug.c,v 1.26 2001/05/05 19:13:09 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -72,6 +72,12 @@ KdInitSystem ( ULONG Value; PCHAR p1, p2; +#ifdef KDBG + /* Initialize runtime debugging if available */ + DbgRDebugInit(); + +#endif + /* set debug port default values */ PortInfo.ComPort = DEFAULT_DEBUG_PORT; PortInfo.BaudRate = DEFAULT_DEBUG_BAUD_RATE; diff --git a/reactos/ntoskrnl/ke/i386/gdt.c b/reactos/ntoskrnl/ke/i386/gdt.c index 010af35db30..f0a052cba9e 100644 --- a/reactos/ntoskrnl/ke/i386/gdt.c +++ b/reactos/ntoskrnl/ke/i386/gdt.c @@ -169,10 +169,10 @@ KeSetBaseGdtSelector(ULONG Entry, ((((ULONG)Base) & 0xff000000) >> 16); DPRINT("%x %x %x %x\n", - KiGdt[Entry + 0], - KiGdt[Entry + 1], - KiGdt[Entry + 2], - KiGdt[Entry + 3]); + Gdt[Entry + 0], + Gdt[Entry + 1], + Gdt[Entry + 2], + Gdt[Entry + 3]); KeReleaseSpinLock(&GdtLock, oldIrql); } diff --git a/reactos/ntoskrnl/ldr/loader.c b/reactos/ntoskrnl/ldr/loader.c index 841660b8a36..55498804580 100644 --- a/reactos/ntoskrnl/ldr/loader.c +++ b/reactos/ntoskrnl/ldr/loader.c @@ -1,4 +1,4 @@ -/* $Id: loader.c,v 1.78 2001/05/05 15:19:14 ekohl Exp $ +/* $Id: loader.c,v 1.79 2001/05/05 19:13:09 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -668,7 +668,7 @@ VOID LdrLoadAutoConfigDrivers (VOID) * Minix filesystem driver */ LdrLoadAutoConfigDriver(L"minixfs.sys"); - + /* * Mailslot filesystem driver */ @@ -677,8 +677,8 @@ VOID LdrLoadAutoConfigDrivers (VOID) /* * Named pipe filesystem driver */ -// LdrLoadAutoConfigDriver(L"npfs.sys"); - + LdrLoadAutoConfigDriver(L"npfs.sys"); + /* * Networking */ diff --git a/reactos/ntoskrnl/mm/cont.c b/reactos/ntoskrnl/mm/cont.c index 0ac0dced9a3..473f62a5ecf 100644 --- a/reactos/ntoskrnl/mm/cont.c +++ b/reactos/ntoskrnl/mm/cont.c @@ -1,4 +1,4 @@ -/* $Id: cont.c,v 1.11 2001/03/26 04:38:39 phreak Exp $ +/* $Id: cont.c,v 1.12 2001/05/05 19:13:10 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -14,6 +14,7 @@ #include #include +#define NDEBUG #include /* FUNCTIONS *****************************************************************/ diff --git a/reactos/ntoskrnl/mm/kmap.c b/reactos/ntoskrnl/mm/kmap.c index d2bd23c3d75..f06428116c1 100644 --- a/reactos/ntoskrnl/mm/kmap.c +++ b/reactos/ntoskrnl/mm/kmap.c @@ -1,4 +1,4 @@ -/* $Id: kmap.c,v 1.9 2001/03/25 02:34:28 dwelch Exp $ +/* $Id: kmap.c,v 1.10 2001/05/05 19:13:10 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -161,8 +161,7 @@ MiAllocNonPagedPoolRegion(ULONG nr_pages) { set_bit(j%32,&AllocMap[j/32]); } - OLD_DPRINT("returning %x\n",(start*PAGESIZE) - +kernel_pool_base); + DPRINT("returning %x\n",((start*PAGESIZE)+NonPagedPoolBase)); return(((start*PAGESIZE)+NonPagedPoolBase)); } } diff --git a/reactos/ntoskrnl/mm/marea.c b/reactos/ntoskrnl/mm/marea.c index 22040a24655..51336420b86 100644 --- a/reactos/ntoskrnl/mm/marea.c +++ b/reactos/ntoskrnl/mm/marea.c @@ -302,7 +302,7 @@ MmFreeMemoryArea(PMADDRESS_SPACE AddressSpace, ULONG i; DPRINT("MmFreeMemoryArea(AddressSpace %x, BaseAddress %x, Length %x," - "FreePages %d)\n",AddressSpace,BaseAddress,Length,FreePages); + "FreePageContext %d)\n",AddressSpace,BaseAddress,Length,FreePageContext); MemoryArea = MmOpenMemoryAreaByAddress(AddressSpace, BaseAddress); diff --git a/reactos/ntoskrnl/mm/npool.c b/reactos/ntoskrnl/mm/npool.c index 81e1e564a36..7373d83c47d 100644 --- a/reactos/ntoskrnl/mm/npool.c +++ b/reactos/ntoskrnl/mm/npool.c @@ -1,4 +1,4 @@ -/* $Id: npool.c,v 1.45 2001/05/03 17:24:00 chorns Exp $ +/* $Id: npool.c,v 1.46 2001/05/05 19:13:10 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -688,8 +688,8 @@ static BLOCK_HDR* grow_kernel_pool(unsigned int size, ULONG Tag, PVOID Caller) int i; NTSTATUS Status; - OLD_DPRINT("growing heap for block size %d, ",size); - OLD_DPRINT("start %x\n",start); + DPRINT("growing heap for block size %d, ",size); + DPRINT("start %x\n",start); for (i=0;i(2*sizeof(BLOCK_HDR))) { used_blk = (struct _BLOCK_HDR *)start; - OLD_DPRINT("Creating block at %x\n",start); + DPRINT("Creating block at %x\n",start); used_blk->Magic = BLOCK_HDR_USED_MAGIC; used_blk->Size = size; add_to_used_list(used_blk); free_blk = (BLOCK_HDR *)(start + sizeof(BLOCK_HDR) + size); - OLD_DPRINT("Creating block at %x\n",free_blk); + DPRINT("Creating block at %x\n",free_blk); free_blk->Magic = BLOCK_HDR_FREE_MAGIC; free_blk->Size = (nr_pages * PAGESIZE) -((sizeof(BLOCK_HDR)*2) + size); add_to_free_list(free_blk); @@ -825,7 +825,7 @@ VOID STDCALL ExFreePool (PVOID block) assert(block); - OLD_DPRINT("(%s:%d) freeing block %x\n",__FILE__,__LINE__,blk); + DPRINT("freeing block %x\n",blk); POOL_TRACE("ExFreePool(block %x), size %d, caller %x\n",block,blk->size, ((PULONG)&block)[-1]); @@ -899,8 +899,8 @@ ExAllocateNonPagedPoolWithTag(ULONG Type, ULONG Size, ULONG Tag, PVOID Caller) current_entry = FreeBlockListHead.Flink; while (current_entry != &FreeBlockListHead) { - OLD_DPRINT("current %x size %x next %x\n",current,current->size, - current->next); + DPRINT("current %x size %x tag_next %x\n",current,current->Size, + current->tag_next); current = CONTAINING_RECORD(current_entry, BLOCK_HDR, ListEntry); if (current->Size >= Size && (best == NULL || current->Size < best->Size)) diff --git a/reactos/ntoskrnl/mm/virtual.c b/reactos/ntoskrnl/mm/virtual.c index d31dc4f41b1..25be88b3c13 100644 --- a/reactos/ntoskrnl/mm/virtual.c +++ b/reactos/ntoskrnl/mm/virtual.c @@ -1,4 +1,4 @@ -/* $Id: virtual.c,v 1.46 2001/04/04 22:21:31 dwelch Exp $ +/* $Id: virtual.c,v 1.47 2001/05/05 19:13:10 chorns Exp $ * * COPYRIGHT: See COPYING in the top directory * PROJECT: ReactOS kernel @@ -870,9 +870,9 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, PVOID PBaseAddress; ULONG PRegionSize; - DPRINT("NtAllocateVirtualMemory(ProcessHandle %x, *BaseAddress %x, " - "ZeroBits %d, *RegionSize %x, AllocationType %x, Protect %x)\n", - ProcessHandle,*BaseAddress,ZeroBits,*RegionSize,AllocationType, + DPRINT("NtAllocateVirtualMemory(*UBaseAddress %x, " + "ZeroBits %d, *URegionSize %x, AllocationType %x, Protect %x)\n", + *UBaseAddress,ZeroBits,*URegionSize,AllocationType, Protect); /* @@ -976,7 +976,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, InsertTailList(&MemoryArea->Data.VirtualMemoryData.SegmentListHead, &Segment->SegmentListEntry); - DPRINT("*BaseAddress %x\n",*BaseAddress); + DPRINT("*UBaseAddress %x\n",*UBaseAddress); if ((AllocationType & MEM_COMMIT) && ((Protect & PAGE_READWRITE) || (Protect & PAGE_EXECUTE_READWRITE))) @@ -1070,9 +1070,9 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle, PVOID BaseAddress; ULONG RegionSize; - DPRINT("NtFreeVirtualMemory(ProcessHandle %x, *BaseAddress %x, " - "*RegionSize %x, FreeType %x)\n",ProcessHandle,*BaseAddress, - *RegionSize,FreeType); + DPRINT("NtFreeVirtualMemory(ProcessHandle %x, *PBaseAddress %x, " + "*PRegionSize %x, FreeType %x)\n",ProcessHandle,*PBaseAddress, + *PRegionSize,FreeType); BaseAddress = (PVOID)PAGE_ROUND_DOWN((*PBaseAddress)); RegionSize = PAGE_ROUND_UP((*PBaseAddress) + (*PRegionSize)) - diff --git a/reactos/ntoskrnl/ob/handle.c b/reactos/ntoskrnl/ob/handle.c index 9656676dd03..9116caa2782 100644 --- a/reactos/ntoskrnl/ob/handle.c +++ b/reactos/ntoskrnl/ob/handle.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: handle.c,v 1.30 2001/03/20 16:09:44 dwelch Exp $ +/* $Id: handle.c,v 1.31 2001/05/05 19:13:10 chorns Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -403,7 +403,7 @@ NTSTATUS ObCreateHandle(PEPROCESS Process, * ARGUMENTS: * obj = Object body that the handle should refer to * RETURNS: The created handle - * NOTE: THe handle is valid only in the context of the current process + * NOTE: The handle is valid only in the context of the current process */ { LIST_ENTRY* current; @@ -412,19 +412,18 @@ NTSTATUS ObCreateHandle(PEPROCESS Process, HANDLE_BLOCK* new_blk = NULL; PHANDLE_TABLE HandleTable; KIRQL oldlvl; - + DPRINT("ObCreateHandle(Process %x, obj %x)\n",Process,ObjectBody); - + + assert(Process); + if (ObjectBody != NULL) { BODY_TO_HEADER(ObjectBody)->HandleCount++; } - HandleTable = &Process->HandleTable; - KeAcquireSpinLock(&HandleTable->ListLock, &oldlvl); current = HandleTable->ListHead.Flink; - /* * Scan through the currently allocated handle blocks looking for a free * slot @@ -452,14 +451,19 @@ NTSTATUS ObCreateHandle(PEPROCESS Process, handle = handle + HANDLE_BLOCK_ENTRIES; current = current->Flink; } - + /* * Add a new handle block to the end of the list */ new_blk = (HANDLE_BLOCK *)ExAllocatePoolWithTag(NonPagedPool,sizeof(HANDLE_BLOCK), TAG_HANDLE_TABLE); - memset(new_blk,0,sizeof(HANDLE_BLOCK)); + if (!new_blk) + { + *HandleReturn = (PHANDLE)NULL; + return(STATUS_INSUFFICIENT_RESOURCES); + } + RtlZeroMemory(new_blk,sizeof(HANDLE_BLOCK)); InsertTailList(&(Process->HandleTable.ListHead), &new_blk->entry); KeReleaseSpinLock(&HandleTable->ListLock, oldlvl);