debug_printf("%s\n",FindData.cFileName);
} while(FindNextFile(shandle,&FindData));
debug_printf("\n %d files\n %d directories\n\n",nFile,nRep);
+ FindClose(shandle);
}
void ExecuteType(char* cmdline)
debug_printf("%c",c);
c = 0;
}
+ CloseHandle(FileHandle);
}
int ExecuteProcess(char* name, char* cmdline)
break;
}
-
+ IoCompleteRequest(Irp, Status);
// DPRINT("Status %d\n",Status);
return(Status);
}
NTSTATUS IoPrepareIrpBuffer(PIRP Irp,
PDEVICE_OBJECT DeviceObject,
PVOID Buffer,
- PVOID Length)
+ ULONG Length,
+ ULONG MajorFunction)
/*
* FUNCTION: Prepares the buffer to be used for an IRP
*/
{
- Irp->UserBuffer = (LPVOID)Buffer;
- if (DeviceObject->Flags&DO_BUFFERED_IO)
+ Irp->UserBuffer = Buffer;
+ if (DeviceObject->Flags & DO_BUFFERED_IO)
{
- DPRINT("Doing buffer i/o\n",0);
+ DPRINT("Doing buffer i/o\n");
Irp->AssociatedIrp.SystemBuffer = (PVOID)
- ExAllocatePool(NonPagedPool,Length);
+ ExAllocatePool(NonPagedPool,Length);
if (Irp->AssociatedIrp.SystemBuffer==NULL)
{
- return(STATUS_UNSUCCESSFUL);
+ IoFreeIrp(Irp);
+ return(NULL);
}
+ /* FIXME: should copy buffer in on other ops */
+ if (MajorFunction == IRP_MJ_WRITE)
+ {
+ RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Buffer, Length);
+ }
}
- if (DeviceObject->Flags&DO_DIRECT_IO)
+ if (DeviceObject->Flags & DO_DIRECT_IO)
{
- DPRINT("Doing direct i/o\n",0);
+ DPRINT("Doing direct i/o\n");
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
- MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
+ if (MajorFunction == IRP_MJ_READ)
+ {
+ MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
+ }
+ else
+ {
+ MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoReadAccess);
+ }
Irp->UserBuffer = NULL;
Irp->AssociatedIrp.SystemBuffer = NULL;
- }
+ }
return(STATUS_SUCCESS);
}
return(NULL);
}
- Irp->UserBuffer = (LPVOID)Buffer;
Irp->UserEvent = Event;
Irp->UserIosb = IoStatusBlock;
- if (DeviceObject->Flags & DO_BUFFERED_IO)
- {
- DPRINT("Doing buffer i/o\n");
- Irp->AssociatedIrp.SystemBuffer = (PVOID)
- ExAllocatePool(NonPagedPool,Length);
- if (Irp->AssociatedIrp.SystemBuffer==NULL)
- {
- IoFreeIrp(Irp);
- return(NULL);
- }
- /* FIXME: should copy buffer in on other ops */
- if (MajorFunction == IRP_MJ_WRITE)
- {
- RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Buffer, Length);
- }
- }
- if (DeviceObject->Flags & DO_DIRECT_IO)
- {
- DPRINT("Doing direct i/o\n");
-
- Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
- if (MajorFunction == IRP_MJ_READ)
- {
- MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
- }
- else
- {
- MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoReadAccess);
- }
- Irp->UserBuffer = NULL;
- Irp->AssociatedIrp.SystemBuffer = NULL;
- }
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->MajorFunction = MajorFunction;
StackPtr->DeviceObject = DeviceObject;
StackPtr->FileObject = NULL;
StackPtr->CompletionRoutine = NULL;
- StackPtr->Parameters.Write.Length = Length;
+
+ IoPrepareIrpBuffer(Irp,
+ DeviceObject,
+ Buffer,
+ Length,
+ MajorFunction);
+
if (MajorFunction == IRP_MJ_READ)
{
if (StartingOffset != NULL)
{
- DPRINT("StartingOffset:%ld:%ld\n",
- GET_LARGE_INTEGER_HIGH_PART(*StartingOffset),
- GET_LARGE_INTEGER_LOW_PART(*StartingOffset));
StackPtr->Parameters.Read.ByteOffset = *StartingOffset;
}
else
SET_LARGE_INTEGER_HIGH_PART(StackPtr->Parameters.Read.ByteOffset,
0);
}
+ StackPtr->Parameters.Read.Length = Length;
}
else
{
SET_LARGE_INTEGER_HIGH_PART(StackPtr->Parameters.Write.ByteOffset,
0);
}
+ StackPtr->Parameters.Write.Length = Length;
}
return(Irp);
PIO_STACK_LOCATION StackLoc;
PWSTR Remainder;
- DPRINT("ZwCreateFile(FileHandle %x, DesiredAccess %x, "
- "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %w)\n",
- FileHandle,DesiredAccess,ObjectAttributes,
- ObjectAttributes->ObjectName->Buffer);
+ DbgPrint("ZwCreateFile(FileHandle %x, DesiredAccess %x, "
+ "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %w)\n",
+ FileHandle,DesiredAccess,ObjectAttributes,
+ ObjectAttributes->ObjectName->Buffer);
assert_irql(PASSIVE_LEVEL);
*FileHandle=0;
- FileObject = ObGenericCreateObject(FileHandle,DesiredAccess,NULL,IoFileType);
+ FileObject = ObGenericCreateObject(FileHandle,
+ DesiredAccess,
+ NULL,
+ IoFileType);
memset(FileObject,0,sizeof(FILE_OBJECT));
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Remainder);
}
if (ReturnSingleEntry)
{
- DPRINT("Setting ReturingSingleEntry flag\n");
IoStack->Flags = IoStack->Flags | SL_RETURN_SINGLE_ENTRY;
- DPRINT("SL_RETURN_SINGLE_ENTRY %x\n",SL_RETURN_SINGLE_ENTRY);
- DPRINT("IoStack->Flags %x\n",IoStack->Flags);
}
if (((PFILE_DIRECTORY_INFORMATION)FileInformation)->FileIndex != 0)
{
return(&Irp->Stack[Irp->CurrentLocation-1]);
}
-NTSTATUS IoCallDriver(PDEVICE_OBJECT DevObject, PIRP irp)
+NTSTATUS IoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP Irp)
/*
* FUNCTION: Sends an IRP to the next lower driver
*/
{
NTSTATUS Status;
- PDRIVER_OBJECT drv = DevObject->DriverObject;
- IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(irp);
+ PDRIVER_OBJECT DriverObject = DeviceObject->DriverObject;
+ PIO_STACK_LOCATION param = IoGetNextIrpStackLocation(Irp);
- DPRINT("Deviceobject %x\n",DevObject);
- DPRINT("Irp %x\n",irp);
-
- irp->Tail.Overlay.CurrentStackLocation--;
- irp->CurrentLocation--;
-
- DPRINT("Io stack address %x\n",param);
- DPRINT("Function %d Routine %x\n",param->MajorFunction,
- drv->MajorFunction[param->MajorFunction]);
+ Irp->Tail.Overlay.CurrentStackLocation--;
+ Irp->CurrentLocation--;
- Status = drv->MajorFunction[param->MajorFunction](DevObject,irp);
+ Status = DriverObject->MajorFunction[param->MajorFunction](DeviceObject,
+ Irp);
return Status;
}
*/
{
PIRP Irp;
-
+
+#if 0
DbgPrint("IoAllocateIrp(StackSize %d ChargeQuota %d)\n",
StackSize,
ChargeQuota);
KeDumpStackFrames(0,8);
+#endif
if (ChargeQuota)
{
NTSTATUS Status;
DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d)\n",
- Irp,PriorityBoost);
+ Irp,PriorityBoost);
for (i=0;i<Irp->StackCount;i++)
{
- DPRINT("&Irp->Stack[%d].CompletionRoutine %08lx\n",
- i,
- Irp->Stack[i].CompletionRoutine);
if (Irp->Stack[i].CompletionRoutine != NULL)
{
Status = Irp->Stack[i].CompletionRoutine(
return;
}
}
- DPRINT("Irp->Stack[%d].Control %08lx\n", i, Irp->Stack[i].Control);
if (Irp->Stack[i].Control & SL_PENDING_RETURNED)
{
- DPRINT("Setting PendingReturned flag\n");
Irp->PendingReturned = TRUE;
}
}
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/rw.c
* PURPOSE: Implements read/write APIs
- * PROGRAMMER: David Welch (welch@mcmail.com)
+ * PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* 30/05/98: Created
*/
NULL);
if (Status != STATUS_SUCCESS)
{
- DPRINT("ZwReadFile() =");
-// DbgPrintErrorMessage(Status);
return(Status);
}
- assert(FileObject != NULL);
if (ByteOffset==NULL)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
return(IoStatusBlock->Status);
}
+ ObDereferenceObject(FileObject);
return(Status);
}
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
StackPtr = IoGetNextIrpStackLocation(Irp);
StackPtr->FileObject = FileObject;
- StackPtr->Parameters.Write.Length = Length;
- if (ByteOffset!=NULL)
- {
- StackPtr->Parameters.Write.ByteOffset = *ByteOffset;
- }
- else
- {
- SET_LARGE_INTEGER_LOW_PART(StackPtr->Parameters.Write.ByteOffset, 0);
- SET_LARGE_INTEGER_HIGH_PART(StackPtr->Parameters.Write.ByteOffset, 0);
- }
if (Key!=NULL)
{
StackPtr->Parameters.Write.Key = *Key;
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = Irp->IoStatus.Status;
}
-
+ ObDereferenceObject(FileObject);
+
return(Status);
}
}
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,ticks);
memset(str, 0, sizeof(str));
- sprintf(str,"%.8u %.8u",EiNrUsedBlocks,KiTimerTicks);
+ sprintf(str,"%.8u %.8u",EiNrUsedBlocks,EiFreeNonPagedPool);
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool);
// sprintf(str,"%.8u %.8u",PiNrThreads,KiTimerTicks);
for (i=0;i<17;i++)
PIMAGE_NT_HEADERS NTHeaders;
PMODULE Module;
LARGE_INTEGER SectionOffset;
-
+ HANDLE SectionHandle;
+
/* Allocate memory for headers */
Module = HEADER_TO_BODY(ModuleHandle);
if (Module == NULL)
#define VALIDATE_POOL
#endif
-#if 1
+#if 0
#define POOL_TRACE(args...) do { DbgPrint(args); } while(0);
#else
#define POOL_TRACE(args...)
NULL);
if (Status != STATUS_SUCCESS)
{
- DbgPrint("ZwFreeVirtualMemory() = %x\n",Status);
return(Status);
}
return(STATUS_UNSUCCESSFUL);
}
- if (FreeType == MEM_RELEASE)
+ switch (FreeType)
{
+ case MEM_RELEASE:
if (MemoryArea->BaseAddress != (*BaseAddress))
{
return(STATUS_UNSUCCESSFUL);
0,
TRUE);
return(STATUS_SUCCESS);
+
+ case MEM_DECOMMIT:
+ MmSplitMemoryArea(PsGetCurrentProcess(),
+ MemoryArea,
+ *BaseAddress,
+ *RegionSize,
+ MEMORY_AREA_RESERVE,
+ MemoryArea->Attributes);
+ return(STATUS_SUCCESS);
}
- UNIMPLEMENTED;
+ return(STATUS_NOT_IMPLEMENTED);
}
NTSTATUS STDCALL NtLockVirtualMemory(HANDLE ProcessHandle,
InsertTailList(&parent->head,&Object->Entry);
}
-NTSTATUS
-ObLookupObject(HANDLE rootdir,
- PWSTR string,
- PVOID* Object,
- PWSTR* UnparsedSection,
- ULONG Attributes)
+NTSTATUS ObLookupObject(HANDLE rootdir,
+ PWSTR string,
+ PVOID* Object,
+ PWSTR* UnparsedSection,
+ ULONG Attributes)
/*
* FUNCTION: Lookup an object within the system namespc
* ARGUMENTS:
current_dir = BODY_TO_HEADER(current_dir)->ObjectType->
Parse(current_dir,
UnparsedSection);
- Status = (current_dir != NULL) ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
+ Status = (current_dir != NULL) ? STATUS_SUCCESS :
+ STATUS_UNSUCCESSFUL;
}
else
{