mirror of
https://github.com/reactos/reactos.git
synced 2024-11-27 05:23:33 +08:00
This commit was generated by cvs2svn to compensate for changes in r39,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=40
This commit is contained in:
parent
ffc37c2cfd
commit
40473b6aba
@ -215,6 +215,7 @@ enum
|
||||
FILE_DEVICE_WAVE_IN,
|
||||
FILE_DEVICE_WAVE_OUT,
|
||||
FILE_DEVICE_8042_PORT,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
|
||||
/*
|
||||
* Values beyond this are reserved for ISVs
|
||||
@ -298,4 +299,9 @@ enum
|
||||
FILE_DOES_NOT_EXIST,
|
||||
};
|
||||
|
||||
#define IRP_MN_USER_FS_REQUEST 0x00
|
||||
#define IRP_MN_MOUNT_VOLUME 0x01
|
||||
#define IRP_MN_VERIFY_VOLUME 0x02
|
||||
#define IRP_MN_LOAD_FILE_SYSTEM 0x03
|
||||
|
||||
#endif
|
||||
|
@ -521,3 +521,5 @@ IN ULONG Length,
|
||||
OUT PVOID FileInformation,
|
||||
OUT PULONG ReturnedLength
|
||||
);
|
||||
VOID IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject);
|
||||
PDEVICE_OBJECT IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject);
|
||||
|
@ -75,51 +75,38 @@ typedef struct _IO_TIMER
|
||||
KDPC dpc;
|
||||
} IO_TIMER, *PIO_TIMER;
|
||||
|
||||
typedef struct _IO_SECURITY_CONTEXT
|
||||
{
|
||||
PSECURITY_QUALITY_OF_SERVICE SecurityQos;
|
||||
PACCESS_STATE AccessState;
|
||||
ACCESS_MASK DesiredAccess;
|
||||
ULONG FullCreateOptions;
|
||||
} IO_SECURITY_CONTEXT, *PIO_SECURITY_CONTEXT;
|
||||
|
||||
/*
|
||||
* PURPOSE: IRP stack location
|
||||
*/
|
||||
typedef struct _IO_STACK_LOCATION
|
||||
{
|
||||
/*
|
||||
* Type of request
|
||||
*/
|
||||
UCHAR MajorFunction;
|
||||
|
||||
/*
|
||||
* Further information about request type
|
||||
*/
|
||||
UCHAR MinorFunction;
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
UCHAR Flags;
|
||||
|
||||
/*
|
||||
* FUNCTION: Various flags including for the io completion routine
|
||||
*/
|
||||
UCHAR MinorFunction;
|
||||
UCHAR Flags;
|
||||
UCHAR Control;
|
||||
|
||||
/*
|
||||
* Parameters for request
|
||||
*/
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
/*
|
||||
* Number of bytes to be transferrred
|
||||
*/
|
||||
PIO_SECURITY_CONTEXT SecurityContext;
|
||||
ULONG Options;
|
||||
USHORT FileAttributes;
|
||||
USHORT ShareAccess;
|
||||
ULONG EaLength;
|
||||
} Create;
|
||||
struct
|
||||
{
|
||||
ULONG Length;
|
||||
|
||||
/*
|
||||
* Possibly used to sort incoming request (to be documented)
|
||||
*/
|
||||
ULONG Key;
|
||||
|
||||
/*
|
||||
* Optional starting offset for read
|
||||
*/
|
||||
LARGE_INTEGER ByteOffset;
|
||||
} Read;
|
||||
struct
|
||||
@ -135,26 +122,18 @@ typedef struct _IO_STACK_LOCATION
|
||||
ULONG IoControlCode;
|
||||
PVOID Type3InputBuffer;
|
||||
} DeviceIoControl;
|
||||
|
||||
struct
|
||||
{
|
||||
struct _VPB* Vpb;
|
||||
struct _DEVICE_OBJECT* DeviceObject;
|
||||
} Mount;
|
||||
} Parameters;
|
||||
|
||||
/*
|
||||
* PURPOSE: Completion routine
|
||||
* NOTE: If this is the nth stack location (where the 1st is passed to the
|
||||
* highest level driver) then this is the completion routine set by
|
||||
* the (n-1)th driver
|
||||
*/
|
||||
PIO_COMPLETION_ROUTINE CompletionRoutine;
|
||||
PVOID CompletionContext;
|
||||
|
||||
/*
|
||||
* Driver created device object representing the target device
|
||||
*/
|
||||
struct _DEVICE_OBJECT* DeviceObject;
|
||||
|
||||
/*
|
||||
* File object (if any) associated with DeviceObject
|
||||
*/
|
||||
struct _FILE_OBJECT* FileObject;
|
||||
} IO_STACK_LOCATION, *PIO_STACK_LOCATION;
|
||||
|
||||
@ -295,10 +274,15 @@ typedef struct _IRP
|
||||
KAPC Apc;
|
||||
ULONG CompletionKey;
|
||||
} Tail;
|
||||
ULONG CurrentLocation;
|
||||
CHAR StackCount;
|
||||
CHAR CurrentLocation;
|
||||
IO_STACK_LOCATION Stack[1];
|
||||
} IRP, *PIRP;
|
||||
|
||||
#define VPB_MOUNTED 0x00000001
|
||||
#define VPB_LOCKED 0x00000002
|
||||
#define VPB_PERSISTENT 0x00000004
|
||||
#define VPB_REMOVE_PENDING 0x00000008
|
||||
|
||||
typedef struct _VPB
|
||||
{
|
||||
@ -377,9 +361,6 @@ typedef struct _DRIVER_EXTENSION
|
||||
|
||||
typedef struct _DRIVER_OBJECT
|
||||
{
|
||||
/*
|
||||
* PURPOSE: Magic values for debugging
|
||||
*/
|
||||
CSHORT Type;
|
||||
CSHORT Size;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
|
@ -37,10 +37,10 @@ extern "C"
|
||||
#include <ddk/ketypes.h>
|
||||
#include <ddk/obtypes.h>
|
||||
#include <ddk/mmtypes.h>
|
||||
#include <ddk/setypes.h>
|
||||
#include <ddk/iotypes.h>
|
||||
#include <ddk/extypes.h>
|
||||
#include <ddk/pstypes.h>
|
||||
#include <ddk/setypes.h>
|
||||
#include <ddk/ioctrl.h>
|
||||
#include <internal/hal/ddk.h>
|
||||
|
||||
|
@ -44,4 +44,4 @@ NTSTATUS ObReferenceObjectByPointer(PVOID Object,
|
||||
KPROCESSOR_MODE AccessMode);
|
||||
|
||||
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
PVOID* Object);
|
||||
PVOID* Object, PWSTR* UnparsedSection);
|
||||
|
@ -9,6 +9,7 @@ typedef struct _OBJECT_HANDLE_INFORMATION {
|
||||
|
||||
struct _OBJECT;
|
||||
|
||||
|
||||
typedef struct _OBJECT_TYPE
|
||||
{
|
||||
/*
|
||||
@ -132,15 +133,11 @@ typedef struct _OBJECT
|
||||
|
||||
} OBJECT_HEADER, *POBJECT_HEADER;
|
||||
|
||||
/*
|
||||
* PURPOSE: Defines an object
|
||||
*/
|
||||
typedef struct _OBJECT_ATTRIBUTES
|
||||
{
|
||||
ULONG Length;
|
||||
HANDLE RootDirectory;
|
||||
PUNICODE_STRING ObjectName;
|
||||
ULONG Attributes;
|
||||
PVOID SecurityDescriptor;
|
||||
PVOID SecurityQualityOfService;
|
||||
typedef struct _OBJECT_ATTRIBUTES {
|
||||
ULONG Length;
|
||||
HANDLE RootDirectory;
|
||||
PUNICODE_STRING ObjectName;
|
||||
ULONG Attributes;
|
||||
SECURITY_DESCRIPTOR *SecurityDescriptor;
|
||||
SECURITY_QUALITY_OF_SERVICE *SecurityQualityOfService;
|
||||
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
|
||||
|
@ -8,7 +8,11 @@
|
||||
* 29/08/98: ACCESS_TOKEN definition from Boudewijn Dekker
|
||||
*/
|
||||
|
||||
#ifndef __INCLUDE_DDK_SETYPES_H
|
||||
#define __INCLUDE_DDK_SETYPES_H
|
||||
|
||||
typedef ULONG ACCESS_MODE, *PACCESS_MODE;
|
||||
typedef SECURITY_QUALITY_OF_SERVICE* PSECURITY_QUALITY_OF_SERVICE;
|
||||
|
||||
typedef struct _SECURITY_SUBJECT_CONTEXT
|
||||
{
|
||||
@ -39,3 +43,5 @@ typedef struct _ACCESS_TOKEN {
|
||||
PVOID AuditData;
|
||||
UCHAR VariablePart[0];
|
||||
} ACCESS_TOKEN, *PACCESS_TOKEN;
|
||||
|
||||
#endif
|
||||
|
@ -153,7 +153,12 @@ enum
|
||||
// STATUS_WRONG_VOLUME,
|
||||
STATUS_FS_DRIVER_REQUIRED,
|
||||
STATUS_NOT_SUPPORTED = 9999,
|
||||
STATUS_DISK_OPERATION_FAILED
|
||||
STATUS_DISK_OPERATION_FAILED,
|
||||
|
||||
/*
|
||||
* Reactos codes
|
||||
*/
|
||||
STATUS_FS_QUERY_REQUIRED,
|
||||
};
|
||||
|
||||
#endif /* __INCLUDE_DDK_STATUS_H */
|
||||
|
@ -16,6 +16,13 @@
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
typedef struct _OBJDIR_INFORMATION {
|
||||
UNICODE_STRING ObjectName;
|
||||
UNICODE_STRING ObjectTypeName; // Directory, Device ...
|
||||
UCHAR Data[0];
|
||||
} OBJDIR_INFORMATION, *POBJDIR_INFORMATION;
|
||||
|
||||
|
||||
/*
|
||||
* FUNCTION: Closes an object handle
|
||||
* ARGUMENTS:
|
||||
@ -177,6 +184,14 @@ NTSTATUS ZwOpenKey(PHANDLE KeyHandle, ACCESS_MASK DesiredAccess,
|
||||
NTSTATUS ZwOpenSection(PHANDLE KeyHandle, ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||
|
||||
NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
|
||||
OUT POBJDIR_INFORMATION DirObjInformation,
|
||||
IN ULONG BufferLength,
|
||||
IN BOOLEAN GetNextIndex,
|
||||
IN BOOLEAN IgnoreInputIndex,
|
||||
IN OUT PULONG ObjectIndex,
|
||||
OUT PULONG DataWritten OPTIONAL);
|
||||
|
||||
/*
|
||||
* FUNCTION: Returns information about an open file
|
||||
* ARGUMENTS:
|
||||
@ -196,29 +211,20 @@ NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
|
||||
|
||||
|
||||
|
||||
NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||
HANDLE EventHandle,
|
||||
PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PLARGE_INTEGER ByteOffset,
|
||||
PULONG Key);
|
||||
|
||||
|
||||
|
||||
#if KERNEL_SUPPORTS_OBJECT_ATTRIBUTES_CORRECTLY
|
||||
typedef struct _OBJECT_ATTRIBUTES {
|
||||
ULONG Length;
|
||||
HANDLE RootDirectory;
|
||||
PUNICODE_STRING ObjectName;
|
||||
ULONG Attributes;
|
||||
SECURITY_DESCRIPTOR *SecurityDescriptor;
|
||||
SECURITY_QUALITY_OF_SERVICE *SecurityQualityOfService;
|
||||
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/*
|
||||
#if IOTYPES_DIDNT_DECLARE_THIS
|
||||
typedef struct _IO_STATUS_BLOCK {
|
||||
NTSTATUS Status;
|
||||
ULONG Information;
|
||||
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
|
||||
#endif
|
||||
*/
|
||||
|
||||
#define NtCurrentProcess() ( (HANDLE) 0xFFFFFFFF )
|
||||
#define NtCurrentThread() ( (HANDLE) 0xFFFFFFFE )
|
||||
|
||||
@ -879,12 +885,6 @@ typedef union _FILE_SEGMENT_ELEMENT {
|
||||
|
||||
// directory information
|
||||
|
||||
typedef struct _OBJDIR_INFORMATION {
|
||||
UNICODE_STRING ObjectName;
|
||||
UNICODE_STRING ObjectTypeName; // Directory, Device ...
|
||||
UCHAR Data[0];
|
||||
} OBJDIR_INFORMATION, *POBJDIR_INFORMATION;
|
||||
|
||||
|
||||
typedef struct _FILE_DIRECTORY_INFORMATION {
|
||||
ULONG NextEntryOffset;
|
||||
|
@ -16,6 +16,13 @@
|
||||
#ifndef __INTERNAL_DEBUG
|
||||
#define __INTERNAL_DEBUG
|
||||
|
||||
|
||||
#ifndef NDEBUG
|
||||
#define DPRINT1(x) DbgPrint(x)
|
||||
#else
|
||||
#define DPRINT1(x)
|
||||
#endif
|
||||
|
||||
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
@ -26,6 +26,8 @@ enum
|
||||
|
||||
typedef struct
|
||||
{
|
||||
CSHORT Type;
|
||||
CSHORT Size;
|
||||
FILE_OBJECT* File;
|
||||
} SECTION_OBJECT;
|
||||
|
||||
@ -36,10 +38,15 @@ typedef struct
|
||||
ULONG Length;
|
||||
ULONG Attributes;
|
||||
LIST_ENTRY Entry;
|
||||
ULONG LockCount;
|
||||
union
|
||||
{
|
||||
SECTION_OBJECT* Section;
|
||||
} d;
|
||||
struct
|
||||
{
|
||||
SECTION_OBJECT* Section;
|
||||
ULONG ViewOffset;
|
||||
} SectionData;
|
||||
} Data;
|
||||
} MEMORY_AREA;
|
||||
|
||||
|
||||
@ -85,16 +92,6 @@ asmlinkage unsigned int get_free_page(void);
|
||||
*/
|
||||
asmlinkage void free_page(unsigned int physical_base, unsigned int nr);
|
||||
|
||||
/*
|
||||
* FUNCTION: Returns the physical address mapped by a given virtual address
|
||||
* ARGUMENTS:
|
||||
* vaddr = virtual address to query
|
||||
* RETURNS: The physical address if present in memory
|
||||
* Zero if paged out or invalid
|
||||
* NOTE: This doesn't do any synchronization
|
||||
*/
|
||||
unsigned int get_page_physical_address(unsigned int vaddr);
|
||||
|
||||
void mark_page_not_writable(unsigned int vaddr);
|
||||
|
||||
void VirtualInit(boot_param* bp);
|
||||
|
@ -8,7 +8,8 @@ typedef struct
|
||||
/*
|
||||
*
|
||||
*/
|
||||
{
|
||||
{
|
||||
unsigned int nsyms;
|
||||
unsigned int text_base;
|
||||
unsigned int data_base;
|
||||
unsigned int bss_base;
|
||||
|
@ -9,9 +9,9 @@
|
||||
#ifndef __VERSION_H
|
||||
#define __VERSION_H
|
||||
|
||||
#define KERNEL_VERSION "0.0.10"
|
||||
#define KERNEL_VERSION "0.0.11"
|
||||
#define KERNEL_MAJOR_VERSION 0
|
||||
#define KERNEL_MINOR_VERSION 0
|
||||
#define KERNEL_PATCH_LEVEL 10
|
||||
#define KERNEL_PATCH_LEVEL 11
|
||||
|
||||
#endif
|
||||
|
@ -158,6 +158,7 @@ IoRaiseHardError
|
||||
IoRaiseInformationalHardError
|
||||
IoReadPartitionTable
|
||||
IoRegisterDriverReinitialization
|
||||
IoRegisterFileSystem
|
||||
IoRegisterShutdownNotification
|
||||
IoReleaseCancelSpinLock
|
||||
IoRemoveShareAccess
|
||||
@ -375,3 +376,4 @@ ZwSetValueKey
|
||||
ZwUnmapViewOfSection
|
||||
ZwWriteFile
|
||||
sprintf
|
||||
wcschr
|
||||
|
@ -137,7 +137,7 @@ asmlinkage void exception_handler(unsigned int edi,
|
||||
*/
|
||||
printk("Exception: %d(%x)\n",type,error_code&0xffff);
|
||||
printk("CS:EIP %x:%x\n",cs&0xffff,eip);
|
||||
for(;;);
|
||||
// for(;;);
|
||||
printk("EAX: %.8x EBX: %.8x ECX: %.8x\n",eax,ebx,ecx);
|
||||
printk("EDX: %.8x EBP: %.8x ESI: %.8x\n",edx,ebp,esi);
|
||||
printk("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
#define BOCHS_LOGGER_PORT (0x3ed)
|
||||
|
||||
/*
|
||||
* PURPOSE: Current cursor position
|
||||
*/
|
||||
@ -120,7 +122,9 @@ static void putchar(char c)
|
||||
char* address;
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
|
||||
outb_p(BOCHS_LOGGER_PORT,c);
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case '\n':
|
||||
@ -268,7 +272,7 @@ ULONG DbgPrint(PCH Format, ...)
|
||||
: "m" (eflags));
|
||||
}
|
||||
|
||||
void InitConsole(boot_param* bp)
|
||||
void HalInitConsole(boot_param* bp)
|
||||
/*
|
||||
* FUNCTION: Initalize the console
|
||||
* ARGUMENTS:
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/psmgr.h>
|
||||
#include <internal/ps.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/hal.h>
|
||||
#include <internal/hal/segment.h>
|
||||
|
@ -12,9 +12,10 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/iomgr.h>
|
||||
#include <internal/ob.h>
|
||||
#include <internal/io.h>
|
||||
#include <internal/string.h>
|
||||
#include <wstring.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
@ -48,7 +49,7 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||
* FileAttributes = Attributes to create the file with
|
||||
* ShareAccess = Type of shared access the caller would like to the file
|
||||
* CreateDisposition = Specifies what to do, depending on whether the
|
||||
* file already existings
|
||||
* file already exists
|
||||
* CreateOptions = Options for creating a new file
|
||||
* EaBuffer = Undocumented
|
||||
* EaLength = Undocumented
|
||||
@ -85,47 +86,112 @@ NTSTATUS ZwOpenFile(PHANDLE FileHandle,
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIO_STACK_LOCATION StackLoc;
|
||||
PWSTR Remainder;
|
||||
|
||||
DPRINT("ZwOpenFile(FileHandle %x, ObjectAttributes %x, "
|
||||
"ObjectAttributes->ObjectName->Buffer %w)\n",FileHandle,
|
||||
ObjectAttributes,ObjectAttributes->ObjectName->Buffer);
|
||||
|
||||
assert_irql(PASSIVE_LEVEL);
|
||||
|
||||
*FileHandle=0;
|
||||
|
||||
Status = ObOpenObjectByName(ObjectAttributes,&Object);
|
||||
DPRINT("Object %x Status %x\n",Object,Status);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DeviceObject = (PDEVICE_OBJECT)Object;
|
||||
|
||||
FileObject = ObGenericCreateObject(FileHandle,0,NULL,OBJTYP_FILE);
|
||||
DPRINT("FileObject %x DeviceObject %x\n",FileObject,DeviceObject);
|
||||
memset(FileObject,0,sizeof(FILE_OBJECT));
|
||||
|
||||
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Remainder);
|
||||
|
||||
if (Status != STATUS_SUCCESS && Status != STATUS_FS_QUERY_REQUIRED)
|
||||
{
|
||||
DPRINT("%s() = Failed to find object\n",__FUNCTION__);
|
||||
ObDeleteHandle(*FileHandle);
|
||||
*FileHandle=0;
|
||||
ExFreePool(FileObject);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
|
||||
DeviceObject = (PDEVICE_OBJECT)Object;
|
||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||
DPRINT("DeviceObject %x\n",DeviceObject);
|
||||
|
||||
if (Status == STATUS_SUCCESS)
|
||||
{
|
||||
CHECKPOINT;
|
||||
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
|
||||
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
||||
ObjectAttributes->Length);
|
||||
RtlCopyUnicodeString(&(FileObject->FileName),
|
||||
ObjectAttributes->ObjectName);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECKPOINT;
|
||||
if (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM &&
|
||||
DeviceObject->DeviceType != FILE_DEVICE_DISK)
|
||||
{
|
||||
ObDeleteHandle(*FileHandle);
|
||||
*FileHandle=0;
|
||||
ExFreePool(FileObject);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
|
||||
{
|
||||
Status = IoTryToMountStorageDevice(DeviceObject);
|
||||
if (Status!=STATUS_SUCCESS)
|
||||
{
|
||||
ObDeleteHandle(*FileHandle);
|
||||
*FileHandle=0;
|
||||
ExFreePool(FileObject);
|
||||
return(Status);
|
||||
}
|
||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||
}
|
||||
DPRINT("Remainder %w\n",Remainder);
|
||||
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
||||
wstrlen(Remainder));
|
||||
RtlInitUnicodeString(&(FileObject->FileName),Remainder);
|
||||
DPRINT("FileObject->FileName.Buffer %x %w\n",
|
||||
FileObject->FileName.Buffer,FileObject->FileName.Buffer);
|
||||
}
|
||||
CHECKPOINT;
|
||||
|
||||
FileObject->DeviceObject=DeviceObject;
|
||||
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
|
||||
FileObject->Vpb=DeviceObject->Vpb;
|
||||
|
||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||
|
||||
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
|
||||
if (Irp==NULL)
|
||||
{
|
||||
ObDeleteHandle(*FileHandle);
|
||||
*FileHandle=0;
|
||||
ExFreePool(FileObject);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
StackLoc = IoGetNextIrpStackLocation(Irp);
|
||||
DPRINT("StackLoc %x\n",StackLoc);
|
||||
StackLoc->MajorFunction = IRP_MJ_CREATE;
|
||||
StackLoc->MinorFunction = 0;
|
||||
StackLoc->Flags = 0;
|
||||
StackLoc->Control = 0;
|
||||
StackLoc->DeviceObject = DeviceObject;
|
||||
StackLoc->FileObject=FileObject;
|
||||
DPRINT("DeviceObject %x\n",DeviceObject);
|
||||
DPRINT("DeviceObject->DriverObject %x\n",DeviceObject->DriverObject);
|
||||
IoCallDriver(DeviceObject,Irp);
|
||||
Status = IoCallDriver(DeviceObject,Irp);
|
||||
if (Status==STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||
Status = IoStatusBlock->Status;
|
||||
}
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
if (Status!=STATUS_SUCCESS)
|
||||
{
|
||||
ObDeleteHandle(*FileHandle);
|
||||
*FileHandle=0;
|
||||
ExFreePool(FileObject);
|
||||
}
|
||||
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,8 +12,8 @@
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/iomgr.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/io.h>
|
||||
#include <internal/ob.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
#define NDEBUG
|
||||
@ -60,10 +60,31 @@ VOID IoDetachDevice(PDEVICE_OBJECT TargetDevice)
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
PDEVICE_OBJECT IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
PDEVICE_OBJECT Current = DeviceObject;
|
||||
|
||||
DPRINT("IoGetAttachDevice(DeviceObject %x)\n",DeviceObject);
|
||||
|
||||
while (Current->AttachedDevice!=NULL)
|
||||
{
|
||||
Current = Current->AttachedDevice;
|
||||
DPRINT("Current %x\n",Current);
|
||||
}
|
||||
return(Current);
|
||||
}
|
||||
|
||||
PDEVICE_OBJECT IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice,
|
||||
PDEVICE_OBJECT TargetDevice)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
PDEVICE_OBJECT AttachedDevice = IoGetAttachedDevice(TargetDevice);
|
||||
|
||||
DPRINT("IoAttachDeviceToDeviceStack(SourceDevice %x, TargetDevice %x)\n",
|
||||
SourceDevice,TargetDevice);
|
||||
|
||||
AttachedDevice->AttachedDevice = SourceDevice;
|
||||
SourceDevice->StackSize = AttachedDevice->StackSize + 1;
|
||||
return(AttachedDevice);
|
||||
}
|
||||
|
||||
VOID IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
|
||||
@ -153,11 +174,25 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||
OBJECT_ATTRIBUTES dev_attr;
|
||||
HANDLE devh;
|
||||
|
||||
DPRINT("IoCreateDevice(DriverObject %x, DeviceName %w)\n",DriverObject,
|
||||
DeviceName->Buffer);
|
||||
|
||||
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
|
||||
dev = ObGenericCreateObject(&devh,0,&dev_attr,OBJTYP_DEVICE);
|
||||
if (DeviceName!=NULL)
|
||||
{
|
||||
DPRINT("IoCreateDevice(DriverObject %x, DeviceName %w)\n",DriverObject,
|
||||
DeviceName->Buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("IoCreateDevice(DriverObject %x)\n",DriverObject);
|
||||
}
|
||||
|
||||
if (DeviceName!=NULL)
|
||||
{
|
||||
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
|
||||
dev = ObGenericCreateObject(&devh,0,&dev_attr,OBJTYP_DEVICE);
|
||||
}
|
||||
else
|
||||
{
|
||||
dev = ObGenericCreateObject(&devh,0,NULL,OBJTYP_DEVICE);
|
||||
}
|
||||
|
||||
*DeviceObject=NULL;
|
||||
|
||||
@ -191,11 +226,17 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||
}
|
||||
|
||||
dev->AttachedDevice=NULL;
|
||||
dev->DeviceType=DeviceType;
|
||||
dev->StackSize=1;
|
||||
dev->AlignmentRequirement=1;
|
||||
KeInitializeDeviceQueue(&dev->DeviceQueue);
|
||||
|
||||
if (dev->DeviceType==FILE_DEVICE_DISK)
|
||||
{
|
||||
IoAttachVpb(dev);
|
||||
}
|
||||
|
||||
*DeviceObject=dev;
|
||||
DPRINT("dev->DriverObject %x\n",dev->DriverObject);
|
||||
|
||||
|
@ -11,7 +11,9 @@
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/io.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* TYPES *******************************************************************/
|
||||
@ -35,9 +37,30 @@ VOID IoInitFileSystemImplementation(VOID)
|
||||
KeInitializeSpinLock(&FileSystemListLock);
|
||||
}
|
||||
|
||||
NTSTATUS IoAskFileSystemToMountDevice(PDEVICE_OBJECT DeviceObject)
|
||||
NTSTATUS IoAskFileSystemToMountDevice(PDEVICE_OBJECT DeviceObject,
|
||||
PDEVICE_OBJECT DeviceToMount)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
PIRP Irp;
|
||||
KEVENT Event;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("IoAskFileSystemToMountDevice(DeviceObject %x, DeviceToMount %x)\n",
|
||||
DeviceObject,DeviceToMount);
|
||||
|
||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||
Irp = IoBuildFilesystemControlRequest(IRP_MN_MOUNT_VOLUME,
|
||||
DeviceObject,
|
||||
&Event,
|
||||
&IoStatusBlock,
|
||||
DeviceToMount);
|
||||
Status = IoCallDriver(DeviceObject,Irp);
|
||||
if (Status==STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||
Status = IoStatusBlock.Status;
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS IoAskFileSystemToLoad(PDEVICE_OBJECT DeviceObject)
|
||||
@ -58,12 +81,15 @@ NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject)
|
||||
FILE_SYSTEM_OBJECT* current;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("IoTryToMountStorageDevice(DeviceObject %x)\n",DeviceObject);
|
||||
|
||||
KeAcquireSpinLock(&FileSystemListLock,&oldlvl);
|
||||
current_entry = FileSystemListHead.Flink;
|
||||
while (current_entry!=NULL)
|
||||
while (current_entry!=(&FileSystemListHead))
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry,FILE_SYSTEM_OBJECT,Entry);
|
||||
Status = IoAskFileSystemToMountDevice(DeviceObject);
|
||||
Status = IoAskFileSystemToMountDevice(current->DeviceObject,
|
||||
DeviceObject);
|
||||
switch (Status)
|
||||
{
|
||||
case STATUS_FS_DRIVER_REQUIRED:
|
||||
@ -90,6 +116,8 @@ VOID IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
FILE_SYSTEM_OBJECT* fs;
|
||||
|
||||
DPRINT("IoRegisterFileSystem(DeviceObject %x)\n",DeviceObject);
|
||||
|
||||
fs=ExAllocatePool(NonPagedPool,sizeof(FILE_SYSTEM_OBJECT));
|
||||
assert(fs!=NULL);
|
||||
|
||||
@ -103,10 +131,12 @@ VOID IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||
KIRQL oldlvl;
|
||||
PLIST_ENTRY current_entry;
|
||||
FILE_SYSTEM_OBJECT* current;
|
||||
|
||||
DPRINT("IoUnregisterFileSystem(DeviceObject %x)\n",DeviceObject);
|
||||
|
||||
KeAcquireSpinLock(&FileSystemListLock,&oldlvl);
|
||||
current_entry = FileSystemListHead.Flink;
|
||||
while (current_entry!=NULL)
|
||||
while (current_entry!=(&FileSystemListHead))
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry,FILE_SYSTEM_OBJECT,Entry);
|
||||
if (current->DeviceObject == DeviceObject)
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/ob.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
@ -66,28 +66,28 @@ VOID IoInit(VOID)
|
||||
/*
|
||||
* Register iomgr types
|
||||
*/
|
||||
CHECKPOINT;
|
||||
RtlInitAnsiString(&astring,"Device");
|
||||
CHECKPOINT;
|
||||
RtlAnsiStringToUnicodeString(&DeviceObjectType.TypeName,&astring,TRUE);
|
||||
CHECKPOINT;
|
||||
ObRegisterType(OBJTYP_DEVICE,&DeviceObjectType);
|
||||
CHECKPOINT;
|
||||
|
||||
RtlInitAnsiString(&astring,"File");
|
||||
RtlAnsiStringToUnicodeString(&FileObjectType.TypeName,&astring,TRUE);
|
||||
ObRegisterType(OBJTYP_FILE,&FileObjectType);
|
||||
CHECKPOINT;
|
||||
|
||||
/*
|
||||
* Create the device directory
|
||||
*/
|
||||
RtlInitAnsiString(&astring,"\\Device");
|
||||
CHECKPOINT;
|
||||
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
|
||||
CHECKPOINT;
|
||||
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
|
||||
CHECKPOINT;
|
||||
ZwCreateDirectoryObject(&handle,0,&attr);
|
||||
CHECKPOINT;
|
||||
|
||||
RtlInitAnsiString(&astring,"\\??");
|
||||
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
|
||||
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
|
||||
ZwCreateDirectoryObject(&handle,0,&attr);
|
||||
|
||||
IoInitCancelHandling();
|
||||
IoInitSymbolicLinkImplementation();
|
||||
IoInitFileSystemImplementation();
|
||||
}
|
||||
|
@ -11,22 +11,27 @@
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ob.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PVOID Target;
|
||||
} SYMBOLIC_LINK_OBJECT;
|
||||
CSHORT Type;
|
||||
CSHORT Size;
|
||||
UNICODE_STRING TargetName;
|
||||
OBJECT_ATTRIBUTES Target;
|
||||
} SYMLNK_OBJECT, *PSYMLNK_OBJECT;
|
||||
|
||||
OBJECT_TYPE SymlinkObjectType = {{NULL,0,0},
|
||||
0,
|
||||
0,
|
||||
ULONG_MAX,
|
||||
ULONG_MAX,
|
||||
sizeof(SYMBOLIC_LINK_OBJECT),
|
||||
sizeof(SYMLNK_OBJECT),
|
||||
0,
|
||||
NULL,
|
||||
NULL,
|
||||
@ -40,9 +45,65 @@ OBJECT_TYPE SymlinkObjectType = {{NULL,0,0},
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS ZwOpenSymbolicLinkObject(OUT PHANDLE LinkHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PVOID Object;
|
||||
PWSTR Ignored;
|
||||
|
||||
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Ignored);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
*LinkHandle = ObAddHandle(Object);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS ZwQuerySymbolicLinkObject(IN HANDLE LinkHandle,
|
||||
IN OUT PUNICODE_STRING LinkTarget,
|
||||
OUT PULONG ReturnedLength OPTIONAL)
|
||||
{
|
||||
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(LinkHandle);
|
||||
PSYMLNK_OBJECT SymlinkObject = (PSYMLNK_OBJECT)hdr;
|
||||
|
||||
if (hdr==NULL)
|
||||
{
|
||||
return(STATUS_INVALID_HANDLE);
|
||||
}
|
||||
|
||||
RtlCopyUnicodeString(LinkTarget,SymlinkObject->Target.ObjectName);
|
||||
if (ReturnedLength!=NULL)
|
||||
{
|
||||
*ReturnedLength=SymlinkObject->Target.Length;
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
POBJECT IoOpenSymlink(POBJECT _Symlink)
|
||||
{
|
||||
PVOID Result;
|
||||
PSYMLNK_OBJECT Symlink = (PSYMLNK_OBJECT)_Symlink;
|
||||
PWSTR Ignored;
|
||||
|
||||
DPRINT("IoOpenSymlink(_Symlink %x)\n",Symlink);
|
||||
|
||||
DPRINT("Target %w\n",Symlink->Target.ObjectName->Buffer);
|
||||
|
||||
ObOpenObjectByName(&(Symlink->Target),&Result,&Ignored);
|
||||
return(Result);
|
||||
}
|
||||
|
||||
VOID IoInitSymbolicLinkImplementation(VOID)
|
||||
{
|
||||
ANSI_STRING astring;
|
||||
|
||||
RtlInitAnsiString(&astring,"Symbolic Link");
|
||||
RtlAnsiStringToUnicodeString(&SymlinkObjectType.TypeName,&astring,TRUE);
|
||||
ObRegisterType(OBJTYP_SYMLNK,&SymlinkObjectType);
|
||||
}
|
||||
|
||||
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
||||
@ -54,7 +115,31 @@ NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
||||
NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
||||
PUNICODE_STRING DeviceName)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE SymbolicLinkHandle;
|
||||
PSYMLNK_OBJECT SymbolicLink;
|
||||
PUNICODE_STRING TargetName;
|
||||
|
||||
DPRINT("IoCreateSymbolicLink(SymbolicLinkName %w, DeviceName %w)\n",
|
||||
SymbolicLinkName->Buffer,DeviceName->Buffer);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,SymbolicLinkName,0,NULL,NULL);
|
||||
SymbolicLink = ObGenericCreateObject(&SymbolicLinkHandle,0,
|
||||
&ObjectAttributes,OBJTYP_SYMLNK);
|
||||
if (SymbolicLink == NULL)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
SymbolicLink->TargetName.Buffer = ExAllocatePool(NonPagedPool,
|
||||
((wstrlen(DeviceName->Buffer)+1)*2));
|
||||
SymbolicLink->TargetName.MaximumLength = wstrlen(DeviceName->Buffer);
|
||||
SymbolicLink->TargetName.Length = 0;
|
||||
RtlCopyUnicodeString(&(SymbolicLink->TargetName),DeviceName);
|
||||
DPRINT("DeviceName %w\n",SymbolicLink->TargetName.Buffer);
|
||||
InitializeObjectAttributes(&(SymbolicLink->Target),
|
||||
&(SymbolicLink->TargetName),0,NULL,NULL);
|
||||
DPRINT("%s() = STATUS_SUCCESS\n",__FUNCTION__);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS IoDeleteSymbolicLink(PUNICODE_STRING DeviceName)
|
||||
|
@ -159,6 +159,7 @@ void IoRaiseHardError(void);
|
||||
void IoRaiseInformationalHardError(void);
|
||||
void IoReadPartitionTable(void);
|
||||
void IoRegisterDriverReinitialization(void);
|
||||
void IoRegisterFileSystem(void);
|
||||
void IoRegisterShutdownNotification(void);
|
||||
void IoReleaseCancelSpinLock(void);
|
||||
void IoRemoveShareAccess(void);
|
||||
@ -376,6 +377,7 @@ void ZwSetValueKey(void);
|
||||
void ZwUnmapViewOfSection(void);
|
||||
void ZwWriteFile(void);
|
||||
void sprintf(void);
|
||||
void wcschr(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@ -531,6 +533,7 @@ export symbol_table[]={
|
||||
{"_IoRaiseInformationalHardError",(unsigned int)IoRaiseInformationalHardError},
|
||||
{"_IoReadPartitionTable",(unsigned int)IoReadPartitionTable},
|
||||
{"_IoRegisterDriverReinitialization",(unsigned int)IoRegisterDriverReinitialization},
|
||||
{"_IoRegisterFileSystem",(unsigned int)IoRegisterFileSystem},
|
||||
{"_IoRegisterShutdownNotification",(unsigned int)IoRegisterShutdownNotification},
|
||||
{"_IoReleaseCancelSpinLock",(unsigned int)IoReleaseCancelSpinLock},
|
||||
{"_IoRemoveShareAccess",(unsigned int)IoRemoveShareAccess},
|
||||
@ -748,5 +751,6 @@ export symbol_table[]={
|
||||
{"_ZwUnmapViewOfSection",(unsigned int)ZwUnmapViewOfSection},
|
||||
{"_ZwWriteFile",(unsigned int)ZwWriteFile},
|
||||
{"_sprintf",(unsigned int)sprintf},
|
||||
{"_wcschr",(unsigned int)wcschr},
|
||||
{NULL,NULL},
|
||||
};
|
||||
|
@ -44,7 +44,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
||||
* range described by the MDL
|
||||
*/
|
||||
{
|
||||
PVOID base;
|
||||
PVOID base = NULL;
|
||||
unsigned int i;
|
||||
ULONG* mdl_pages=NULL;
|
||||
MEMORY_AREA* Result;
|
||||
@ -59,6 +59,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
||||
Mdl->ByteCount,
|
||||
0,
|
||||
&Result);
|
||||
CHECKPOINT;
|
||||
mdl_pages = (ULONG *)(Mdl + 1);
|
||||
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE); i++)
|
||||
{
|
||||
|
@ -39,7 +39,7 @@ PVOID MmAllocateSection(ULONG Length)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
CHECKPOINT;
|
||||
DPRINT("Result %x\n",Result);
|
||||
Attributes = PA_WRITE | PA_READ | PA_EXECUTE | PA_SYSTEM;
|
||||
for (i=0;i<=(Length/PAGESIZE);i++)
|
||||
{
|
||||
|
@ -59,12 +59,12 @@ void VirtualInit(boot_param* bp)
|
||||
* Setup the system area descriptor list
|
||||
*/
|
||||
BaseAddress = KERNEL_BASE;
|
||||
Length = ((ULONG)&etext) - KERNEL_BASE;
|
||||
Length = PAGE_ROUND_UP(((ULONG)&etext)) - KERNEL_BASE;
|
||||
ParamLength = ParamLength - Length;
|
||||
MmCreateMemoryArea(KernelMode,MEMORY_AREA_SYSTEM,&BaseAddress,
|
||||
Length,0,&kernel_text_desc);
|
||||
|
||||
Length = ((ULONG)&end) - ((ULONG)&etext);
|
||||
Length = PAGE_ROUND_UP(((ULONG)&end)) - PAGE_ROUND_UP(((ULONG)&etext));
|
||||
ParamLength = ParamLength - Length;
|
||||
DPRINT("Length %x\n",Length);
|
||||
BaseAddress = PAGE_ROUND_UP(((ULONG)&etext));
|
||||
@ -113,18 +113,26 @@ asmlinkage int page_fault_handler(unsigned int edi,
|
||||
{
|
||||
KPROCESSOR_MODE FaultMode;
|
||||
MEMORY_AREA* MemoryArea;
|
||||
KIRQL oldlvl;
|
||||
ULONG stat;
|
||||
|
||||
/*
|
||||
* Get the address for the page fault
|
||||
*/
|
||||
unsigned int cr2;
|
||||
__asm__("movl %%cr2,%0\n\t" : "=d" (cr2));
|
||||
DPRINT("Page fault at address %x with eip %x\n",cr2,eip);
|
||||
for(;;);
|
||||
DbgPrint("Page fault at address %x with eip %x\n",cr2,eip);
|
||||
|
||||
cr2 = PAGE_ROUND_DOWN(cr2);
|
||||
|
||||
assert_irql(DISPATCH_LEVEL);
|
||||
if (KeGetCurrentIrql()!=PASSIVE_LEVEL)
|
||||
{
|
||||
DbgPrint("Recursive page fault detected\n");
|
||||
KeBugCheck(0);
|
||||
for(;;);
|
||||
}
|
||||
|
||||
KeRaiseIrql(DISPATCH_LEVEL,&oldlvl);
|
||||
|
||||
/*
|
||||
* Find the memory area for the faulting address
|
||||
@ -156,12 +164,21 @@ asmlinkage int page_fault_handler(unsigned int edi,
|
||||
switch (MemoryArea->Type)
|
||||
{
|
||||
case MEMORY_AREA_SYSTEM:
|
||||
return(0);
|
||||
stat = 0;
|
||||
break;
|
||||
|
||||
case MEMORY_AREA_SECTION_VIEW:
|
||||
return(MmSectionHandleFault(MemoryArea,cr2));
|
||||
stat = MmSectionHandleFault(MemoryArea,cr2);
|
||||
|
||||
default:
|
||||
stat = 0;
|
||||
break;
|
||||
}
|
||||
return(0);
|
||||
if (stat)
|
||||
{
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
return(stat);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/ob.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
#define NDEBUG
|
||||
@ -26,7 +26,7 @@
|
||||
typedef struct
|
||||
{
|
||||
PVOID obj;
|
||||
} HANDLE_REP;
|
||||
} HANDLE_REP, *PHANDLE_REP;
|
||||
|
||||
#define HANDLE_BLOCK_ENTRIES ((PAGESIZE-sizeof(LIST_ENTRY))/sizeof(HANDLE_REP))
|
||||
|
||||
@ -89,10 +89,33 @@ VOID ObjInitializeHandleTable(HANDLE parent)
|
||||
* parent = Parent process (or NULL if this is the first process)
|
||||
*/
|
||||
{
|
||||
DPRINT("ObjInitializeHandleTable(parent %x)\n",parent);
|
||||
|
||||
InitializeListHead(&handle_list_head);
|
||||
KeInitializeSpinLock(&handle_list_lock);
|
||||
}
|
||||
|
||||
static PHANDLE_REP ObTranslateHandle(HANDLE* h)
|
||||
{
|
||||
PLIST_ENTRY current = handle_list_head.Flink;
|
||||
unsigned int handle = ((unsigned int)h) - 1;
|
||||
unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
|
||||
HANDLE_BLOCK* blk = NULL;
|
||||
unsigned int i;
|
||||
|
||||
for (i=0;i<count;i++)
|
||||
{
|
||||
current = current->Flink;
|
||||
if (current==(&handle_list_head))
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
blk = (HANDLE_BLOCK *)current;
|
||||
return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
|
||||
}
|
||||
|
||||
PVOID ObGetObjectByHandle(HANDLE h)
|
||||
/*
|
||||
* FUNCTION: Translate a handle to the corresponding object
|
||||
@ -101,23 +124,20 @@ PVOID ObGetObjectByHandle(HANDLE h)
|
||||
* RETURNS: The object
|
||||
*/
|
||||
{
|
||||
LIST_ENTRY* current = handle_list_head.Flink;
|
||||
unsigned int handle = ((unsigned int)h) - 1;
|
||||
unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
|
||||
HANDLE_BLOCK* blk = NULL;
|
||||
unsigned int i;
|
||||
DPRINT("ObGetObjectByHandle(h %x)\n",h);
|
||||
|
||||
for (i=0;i<count;i++)
|
||||
if (h==NULL)
|
||||
{
|
||||
current = current->Flink;
|
||||
if (current==NULL)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
blk = (HANDLE_BLOCK *)current;
|
||||
return(blk->handles[handle%HANDLE_BLOCK_ENTRIES].obj);
|
||||
return(ObTranslateHandle(h)->obj);
|
||||
}
|
||||
|
||||
VOID ObDeleteHandle(HANDLE Handle)
|
||||
{
|
||||
PHANDLE_REP Rep = ObTranslateHandle(Handle);
|
||||
Rep->obj=NULL;
|
||||
}
|
||||
|
||||
HANDLE ObAddHandle(PVOID obj)
|
||||
@ -134,13 +154,13 @@ HANDLE ObAddHandle(PVOID obj)
|
||||
unsigned int i;
|
||||
HANDLE_BLOCK* new_blk = NULL;
|
||||
|
||||
DPRINT("ObAddHandle(obj %)\n",obj);
|
||||
DPRINT("ObAddHandle(obj %x)\n",obj);
|
||||
|
||||
/*
|
||||
* Scan through the currently allocated handle blocks looking for a free
|
||||
* slot
|
||||
*/
|
||||
while (current!=NULL)
|
||||
while (current!=(&handle_list_head))
|
||||
{
|
||||
HANDLE_BLOCK* blk = (HANDLE_BLOCK *)current;
|
||||
|
||||
|
@ -13,7 +13,8 @@
|
||||
#include <windows.h>
|
||||
#include <wstring.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/ob.h>
|
||||
#include <internal/io.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
#define NDEBUG
|
||||
@ -64,19 +65,23 @@ NTSTATUS ZwOpenDirectoryObject(PHANDLE DirectoryHandle,
|
||||
{
|
||||
PVOID Object;
|
||||
NTSTATUS Status;
|
||||
PWSTR Ignored;
|
||||
|
||||
Status = ObOpenObjectByName(ObjectAttributes,&Object);
|
||||
*DirectoryHandle = 0;
|
||||
|
||||
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Ignored);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (BODY_TO_HEADER(Object)->Type!=OBJTYP_DIRECTORY)
|
||||
{
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
*DirectoryHandle = ObAddHandle(Object);
|
||||
CHECKPOINT;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
@ -106,19 +111,24 @@ NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
|
||||
* RETURNS: Status
|
||||
*/
|
||||
{
|
||||
POBJECT_HEADER hdr = ObGetObjectByHandle(DirObjHandle);
|
||||
PDIRECTORY_OBJECT dir = (PDIRECTORY_OBJECT)(HEADER_TO_BODY(hdr));
|
||||
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(DirObjHandle);
|
||||
PDIRECTORY_OBJECT dir = (PDIRECTORY_OBJECT)hdr;
|
||||
ULONG EntriesToRead;
|
||||
PLIST_ENTRY current_entry;
|
||||
POBJECT_HEADER current;
|
||||
ULONG i=0;
|
||||
ULONG EntriesToSkip;
|
||||
|
||||
DPRINT("ZwQueryDirectoryObject(DirObjHandle %x)\n",DirObjHandle);
|
||||
DPRINT("dir %x namespc_root %x\n",dir,HEADER_TO_BODY(&(namespc_root.hdr)));
|
||||
|
||||
assert_irql(PASSIVE_LEVEL);
|
||||
|
||||
EntriesToRead = BufferLength / sizeof(OBJDIR_INFORMATION);
|
||||
*DataWritten = 0;
|
||||
|
||||
DPRINT("EntriesToRead %d\n",EntriesToRead);
|
||||
|
||||
current_entry = dir->head.Flink;
|
||||
|
||||
/*
|
||||
@ -126,6 +136,8 @@ NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
|
||||
*/
|
||||
if (!IgnoreInputIndex)
|
||||
{
|
||||
CHECKPOINT;
|
||||
|
||||
EntriesToSkip = *ObjectIndex;
|
||||
while ( i<EntriesToSkip && current_entry!=NULL)
|
||||
{
|
||||
@ -133,29 +145,40 @@ NTSTATUS ZwQueryDirectoryObject(IN HANDLE DirObjHandle,
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT("DirObjInformation %x\n",DirObjInformation);
|
||||
|
||||
/*
|
||||
* Read the maximum entries possible into the buffer
|
||||
*/
|
||||
while ( i<EntriesToRead && current_entry!=NULL)
|
||||
while ( i<EntriesToRead && current_entry!=(&(dir->head)))
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry,OBJECT_HEADER,entry);
|
||||
DPRINT("Scanning %w\n",current->name.Buffer);
|
||||
DirObjInformation[i].ObjectName.Buffer =
|
||||
ExAllocatePool(NonPagedPool,current->name.Length);
|
||||
DirObjInformation[i].ObjectName.Length = current->name.Length;
|
||||
DirObjInformation[i].ObjectName.MaximumLength = current->name.Length;
|
||||
DPRINT("DirObjInformation[i].ObjectName.Buffer %x\n",
|
||||
DirObjInformation[i].ObjectName.Buffer);
|
||||
RtlCopyUnicodeString(&DirObjInformation[i].ObjectName,
|
||||
&(current->name));
|
||||
i++;
|
||||
current_entry = current_entry->Flink;
|
||||
(*DataWritten) = (*DataWritten) + sizeof(OBJDIR_INFORMATION);
|
||||
CHECKPOINT;
|
||||
}
|
||||
CHECKPOINT;
|
||||
|
||||
/*
|
||||
* Optionally, count the number of entries in the directory
|
||||
*/
|
||||
if (!GetNextIndex)
|
||||
if (GetNextIndex)
|
||||
{
|
||||
*ObjectIndex=i;
|
||||
}
|
||||
else
|
||||
{
|
||||
while ( current_entry!=NULL )
|
||||
while ( current_entry!=(&(dir->head)) )
|
||||
{
|
||||
current_entry=current_entry->Flink;
|
||||
i++;
|
||||
@ -179,22 +202,22 @@ NTSTATUS ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||
}
|
||||
|
||||
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
PVOID* Object)
|
||||
PVOID* Object, PWSTR* UnparsedSection)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("ObOpenObjectByName(ObjectAttributes %x, Object %x)\n",
|
||||
ObjectAttributes,Object);
|
||||
DPRINT("ObjectAttributes = {ObjectName %x ObjectName->Buffer %w}\n",
|
||||
ObjectAttributes->ObjectName,ObjectAttributes->ObjectName->Buffer);
|
||||
|
||||
*Object = ObLookupObject(ObjectAttributes->RootDirectory,
|
||||
ObjectAttributes->ObjectName->Buffer);
|
||||
*Object = NULL;
|
||||
Status = ObLookupObject(ObjectAttributes->RootDirectory,
|
||||
ObjectAttributes->ObjectName->Buffer,
|
||||
Object,
|
||||
UnparsedSection);
|
||||
DPRINT("*Object %x\n",*Object);
|
||||
if ((*Object)==NULL)
|
||||
{
|
||||
return(STATUS_NO_SUCH_FILE);
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
void ObInit(void)
|
||||
@ -284,30 +307,34 @@ static PVOID ObDirLookup(PDIRECTORY_OBJECT dir, PWSTR name)
|
||||
* NULL otherwise
|
||||
*/
|
||||
{
|
||||
LIST_ENTRY* current = ((PDIRECTORY_OBJECT)dir)->head.Flink;
|
||||
LIST_ENTRY* current = dir->head.Flink;
|
||||
POBJECT_HEADER current_obj;
|
||||
|
||||
DPRINT("ObDirLookup(dir %x, name %w)\n",dir,name);
|
||||
|
||||
if (name[0]==0)
|
||||
{
|
||||
return(BODY_TO_HEADER(dir));
|
||||
return(dir);
|
||||
}
|
||||
if (name[0]=='.'&&name[1]==0)
|
||||
{
|
||||
return(BODY_TO_HEADER(dir));
|
||||
return(dir);
|
||||
}
|
||||
if (name[0]=='.'&&name[1]=='.'&&name[2]==0)
|
||||
{
|
||||
return(BODY_TO_HEADER(BODY_TO_HEADER(dir)->Parent));
|
||||
return(BODY_TO_HEADER(dir)->Parent);
|
||||
}
|
||||
while (current!=(&((PDIRECTORY_OBJECT)dir)->head))
|
||||
while (current!=(&(dir->head)))
|
||||
{
|
||||
current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,entry);
|
||||
DPRINT("Scanning %w\n",current_obj->name.Buffer);
|
||||
if ( wcscmp(current_obj->name.Buffer, name)==0)
|
||||
{
|
||||
return(current_obj);
|
||||
return(HEADER_TO_BODY(current_obj));
|
||||
}
|
||||
current = current->Flink;
|
||||
}
|
||||
DPRINT("%s() = NULL\n",__FUNCTION__);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -323,11 +350,6 @@ VOID ObCreateEntry(PDIRECTORY_OBJECT parent,POBJECT_HEADER Object)
|
||||
{
|
||||
DPRINT("ObjCreateEntry(%x,%x,%x,%w)\n",parent,Object,Object->name.Buffer,
|
||||
Object->name.Buffer);
|
||||
DPRINT("root type %d\n",namespc_root.hdr.Type);
|
||||
DPRINT("%x\n",&(namespc_root.hdr.Type));
|
||||
DPRINT("type %x\n",&(parent->Type));
|
||||
DPRINT("type %x\n",&(BODY_TO_HEADER(parent)->Type));
|
||||
DPRINT("type %d\n",parent->Type);
|
||||
assert(parent->Type == OBJTYP_DIRECTORY);
|
||||
|
||||
/*
|
||||
@ -336,7 +358,8 @@ VOID ObCreateEntry(PDIRECTORY_OBJECT parent,POBJECT_HEADER Object)
|
||||
InsertTailList(&parent->head,&Object->entry);
|
||||
}
|
||||
|
||||
PVOID ObLookupObject(HANDLE rooth, PWSTR string)
|
||||
NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
|
||||
PWSTR* UnparsedSection)
|
||||
/*
|
||||
* FUNCTION: Lookup an object within the system namespc
|
||||
* ARGUMENTS:
|
||||
@ -349,17 +372,23 @@ PVOID ObLookupObject(HANDLE rooth, PWSTR string)
|
||||
PWSTR current;
|
||||
PWSTR next;
|
||||
PDIRECTORY_OBJECT current_dir = NULL;
|
||||
POBJECT_HEADER current_hdr;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("root %x string %w\n",rooth,string);
|
||||
DPRINT("ObLookupObject(rootdir %x, string %x, string %w, Object %x, "
|
||||
"UnparsedSection %x)\n",rootdir,string,string,Object,
|
||||
UnparsedSection);
|
||||
|
||||
|
||||
if (rooth==NULL)
|
||||
*UnparsedSection = NULL;
|
||||
*Object = NULL;
|
||||
|
||||
if (rootdir==NULL)
|
||||
{
|
||||
current_dir = HEADER_TO_BODY(&(namespc_root.hdr));
|
||||
}
|
||||
else
|
||||
{
|
||||
ObReferenceObjectByHandle(rooth,DIRECTORY_TRAVERSE,NULL,
|
||||
ObReferenceObjectByHandle(rootdir,DIRECTORY_TRAVERSE,NULL,
|
||||
UserMode,(PVOID*)¤t_dir,NULL);
|
||||
}
|
||||
|
||||
@ -368,74 +397,90 @@ PVOID ObLookupObject(HANDLE rooth, PWSTR string)
|
||||
*/
|
||||
if (string[0]==0)
|
||||
{
|
||||
DPRINT("current_dir %x\n",current_dir);
|
||||
DPRINT("type %d\n",current_dir->Type);
|
||||
return(current_dir);
|
||||
*Object=current_dir;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
DPRINT("string = %w\n",string);
|
||||
|
||||
if (string[0]!='\\')
|
||||
{
|
||||
DbgPrint("(%s:%d) Non absolute pathname passed to %s\n",__FILE__,
|
||||
__LINE__,__FUNCTION__);
|
||||
return(NULL);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
current = string+1;
|
||||
DPRINT("current %w\n",current);
|
||||
next = wcschr(string+1,'\\');
|
||||
if (next!=NULL)
|
||||
{
|
||||
*next=0;
|
||||
}
|
||||
DPRINT("next %x\n",next);
|
||||
next = &string[0];
|
||||
current = next+1;
|
||||
|
||||
while (next!=NULL)
|
||||
{
|
||||
DPRINT("Scanning %w next %w current %x\n",current,next+1,
|
||||
current_dir);
|
||||
|
||||
/*
|
||||
* Check the current object is a directory
|
||||
*/
|
||||
if (current_dir->Type!=OBJTYP_DIRECTORY)
|
||||
{
|
||||
DbgPrint("(%s:%d) Bad path component\n",__FILE__,
|
||||
__LINE__);
|
||||
ExFreePool(string);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup the next component of the path in the directory
|
||||
*/
|
||||
current_hdr=(PDIRECTORY_OBJECT)ObDirLookup(current_dir,current);
|
||||
if (current_hdr==NULL)
|
||||
{
|
||||
DbgPrint("(%s:%d) Path component not found\n",__FILE__,
|
||||
__LINE__);
|
||||
ExFreePool(string);
|
||||
return(NULL);
|
||||
}
|
||||
current_dir = HEADER_TO_BODY(current_hdr);
|
||||
|
||||
while (next!=NULL && current_dir->Type==OBJTYP_DIRECTORY)
|
||||
{
|
||||
*next = '\\';
|
||||
current = next+1;
|
||||
next = wcschr(next+1,'\\');
|
||||
if (next!=NULL)
|
||||
{
|
||||
*next=0;
|
||||
}
|
||||
|
||||
DPRINT("current %w current[5] %x next %x ",current,current[5],next);
|
||||
if (next!=NULL)
|
||||
{
|
||||
DPRINT("(next+1) %w",next+1);
|
||||
}
|
||||
DPRINT("\n",0);
|
||||
|
||||
current_dir=(PDIRECTORY_OBJECT)ObDirLookup(current_dir,current);
|
||||
if (current_dir==NULL)
|
||||
{
|
||||
DbgPrint("(%s:%d) Path component not found\n",__FILE__,
|
||||
__LINE__);
|
||||
ExFreePool(string);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
DPRINT("current_dir %x\n",current_dir);
|
||||
DPRINT("current_dir->Type %d OBJTYP_SYMLNK %d OBJTYP_DIRECTORY %d\n",
|
||||
current_dir->Type,OBJTYP_SYMLNK,OBJTYP_DIRECTORY);
|
||||
DPRINT("&(current_dir->Type) %x\n",&(current_dir->Type));
|
||||
if (current_dir->Type==OBJTYP_SYMLNK)
|
||||
{
|
||||
current_dir = IoOpenSymlink(current_dir);
|
||||
}
|
||||
|
||||
}
|
||||
DPRINT("next %x\n",next);
|
||||
DPRINT("current %x current %w\n",current,current);
|
||||
if (next==NULL)
|
||||
{
|
||||
if (current_dir==NULL)
|
||||
{
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECKPOINT;
|
||||
*next = '\\';
|
||||
*UnparsedSection = next;
|
||||
switch(current_dir->Type)
|
||||
{
|
||||
case OBJTYP_DEVICE:
|
||||
CHECKPOINT;
|
||||
Status = STATUS_FS_QUERY_REQUIRED;
|
||||
break;
|
||||
|
||||
default:
|
||||
current_dir = NULL;
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CHECKPOINT;
|
||||
*Object = current_dir;
|
||||
|
||||
DPRINT("current_dir %x current %x\n",current_dir,current);
|
||||
DPRINT("current %w\n",current);
|
||||
current_hdr = ObDirLookup(current_dir,current);
|
||||
if (current_hdr==NULL)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
DPRINT("Returning %x %x\n",current_hdr,HEADER_TO_BODY(current_hdr));
|
||||
return(HEADER_TO_BODY(current_hdr));
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/ob.h>
|
||||
#include <wstring.h>
|
||||
|
||||
#define NDEBUG
|
||||
@ -41,9 +41,10 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
|
||||
PWSTR path;
|
||||
PWSTR name;
|
||||
PDIRECTORY_OBJECT parent;
|
||||
PWSTR Ignored;
|
||||
|
||||
DPRINT("ObGenericCreateObject(Handle %x, DesiredAccess %x,"
|
||||
"ObjectAttributes %x, Type %x)\n",Handle,DesiredAccess,ObjectAttributes,
|
||||
"ObjectAttributes %x, Type %d)\n",Handle,DesiredAccess,ObjectAttributes,
|
||||
Type);
|
||||
|
||||
/*
|
||||
@ -96,8 +97,9 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
|
||||
name=name+1;
|
||||
}
|
||||
|
||||
hdr->Parent = ObLookupObject(ObjectAttributes->RootDirectory,path);
|
||||
|
||||
ObLookupObject(ObjectAttributes->RootDirectory,path,
|
||||
&hdr->Parent,&Ignored);
|
||||
|
||||
/*
|
||||
* Initialize the object header
|
||||
*/
|
||||
@ -168,6 +170,9 @@ VOID ObInitializeObjectHeader(CSHORT id, PWSTR name,
|
||||
RtlInitUnicodeString(&obj->name,name);
|
||||
DPRINT("name %w\n",obj->name.Buffer);
|
||||
}
|
||||
DPRINT("obj->Type %d\n",obj->Type);
|
||||
DPRINT("obj %x\n",obj);
|
||||
DPRINT("&(obj->Type) %x\n",&(obj->Type));
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
@ -21,10 +22,14 @@ HANDLE SystemProcessHandle = NULL;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID PsInitProcessManagment(VOID)
|
||||
{
|
||||
InitializeListHead(&(SystemProcess.Pcb.MemoryAreaList));
|
||||
}
|
||||
|
||||
PKPROCESS KeGetCurrentProcess(VOID)
|
||||
{
|
||||
return(NULL);
|
||||
// return(&(PsGetCurrentProcess()->Pcb));
|
||||
return(&(PsGetCurrentProcess()->Pcb));
|
||||
}
|
||||
|
||||
struct _EPROCESS* PsGetCurrentProcess(VOID)
|
||||
@ -32,6 +37,7 @@ struct _EPROCESS* PsGetCurrentProcess(VOID)
|
||||
* FUNCTION: Returns a pointer to the current process
|
||||
*/
|
||||
{
|
||||
DPRINT("PsGetCurrentProcess() = %x\n",PsGetCurrentThread()->ThreadsProcess);
|
||||
return(PsGetCurrentThread()->ThreadsProcess);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: kernel/psmgr/psmgr.c
|
||||
* FILE: ntoskrnl/ps/psmgr.c
|
||||
* PURPOSE: Process managment
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
*/
|
||||
@ -10,13 +10,14 @@
|
||||
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/psmgr.h>
|
||||
#include <internal/ps.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID PsInit(VOID)
|
||||
{
|
||||
ObjInitializeHandleTable(NULL);
|
||||
PsInitProcessManagment();
|
||||
PsInitThreadManagment();
|
||||
PsInitIdleThread();
|
||||
}
|
||||
|
@ -21,10 +21,10 @@
|
||||
#include <windows.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/objmgr.h>
|
||||
#include <internal/ob.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/hal.h>
|
||||
#include <internal/psmgr.h>
|
||||
#include <internal/ps.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
@ -150,7 +150,7 @@ void PsDispatchThread(void)
|
||||
if (current->ThreadState == THREAD_STATE_RUNNABLE &&
|
||||
current != (PKTHREAD)CurrentThread)
|
||||
{
|
||||
DPRINT("Scheduling this one %x\n",current);
|
||||
DPRINT("Scheduling this one %x\n",current);
|
||||
CurrentThread = current;
|
||||
CurrentThread->Tcb.ThreadState = THREAD_STATE_RUNNING;
|
||||
KeReleaseSpinLock(&ThreadListLock,irql);
|
||||
|
@ -22,6 +22,15 @@
|
||||
|
||||
#define Aa_Difference 'A'-'a';
|
||||
|
||||
PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest,
|
||||
PUNICODE_STRING Src)
|
||||
{
|
||||
if (Dest==NULL)
|
||||
{
|
||||
Dest=ExAllocatePool(NonPagedPool,sizeof(UNICODE_STRING));
|
||||
}
|
||||
}
|
||||
|
||||
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
@ -44,7 +53,7 @@ NTSTATUS RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||
unsigned long i;
|
||||
|
||||
if(AllocateDestinationString==TRUE) {
|
||||
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1);
|
||||
DestinationString->Buffer=ExAllocatePool(NonPagedPool, (SourceString->Length+1)*2);
|
||||
DestinationString->MaximumLength=SourceString->Length;
|
||||
};
|
||||
|
||||
|
@ -222,10 +222,25 @@ int vsprintf(char *buf, const char *fmt, va_list args)
|
||||
case 'w':
|
||||
sw = va_arg(args,short int *);
|
||||
// DPRINT("L %x\n",sw);
|
||||
while ((*sw)!=0)
|
||||
if (sw==NULL)
|
||||
{
|
||||
*str++ = (char)(*sw++);
|
||||
// CHECKPOINT;
|
||||
s = "<NULL>";
|
||||
while ((*s)!=0)
|
||||
{
|
||||
*str++ = *s++;
|
||||
}
|
||||
// CHECKPOINT;
|
||||
// DbgPrint("str %x\n",str);
|
||||
}
|
||||
else
|
||||
{
|
||||
while ((*sw)!=0)
|
||||
{
|
||||
*str++ = (char)(*sw++);
|
||||
}
|
||||
}
|
||||
// CHECKPOINT;
|
||||
continue;
|
||||
|
||||
case 's':
|
||||
|
@ -18,16 +18,15 @@
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
#include <in.h>
|
||||
|
||||
int ShellChangeDir(char* args);
|
||||
int ShellListDir(char* args);
|
||||
VOID TstReadLineInit(VOID);
|
||||
VOID TstReadLine(ULONG Length, PCHAR Buffer);
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
static HANDLE CurrentDirHandle;
|
||||
static UNICODE_STRING CurrentDirName;
|
||||
static HANDLE KeyboardHandle;
|
||||
static HANDLE CurrentDirHandle = NULL;
|
||||
static UNICODE_STRING CurrentDirName = {NULL,0,0};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -50,22 +49,28 @@ int ShellChangeDir(char* args)
|
||||
|
||||
int ShellListDir(char* args)
|
||||
{
|
||||
OBJDIR_INFORMATION DirObj[50];
|
||||
ULONG Idx;
|
||||
ULONG Length;
|
||||
ULONG i;
|
||||
|
||||
ZwQueryDirectoryObject(CurrentDirHandle,
|
||||
&(DirObj[0]),
|
||||
sizeof(DirObj),
|
||||
TRUE,
|
||||
TRUE,
|
||||
&Idx,
|
||||
&Length);
|
||||
|
||||
for (i=0;i<(Length/sizeof(OBJDIR_INFORMATION));i++)
|
||||
{
|
||||
DbgPrint("Scanning %w\n",DirObj[i].ObjectName.Buffer);
|
||||
}
|
||||
}
|
||||
|
||||
VOID ShellDisplayPrompt()
|
||||
{
|
||||
printk("%w# ",CurrentDirName->Buffer);
|
||||
}
|
||||
|
||||
VOID ShellGetCommand(char* cmd)
|
||||
{
|
||||
do
|
||||
{
|
||||
ZwReadFile(hfile,NULL,NULL,NULL,NULL,cmd,1,0,0);
|
||||
printk("%c",*cmd);
|
||||
cmd++;
|
||||
} while((*cmd)!='\n');
|
||||
*cmd=0;
|
||||
printk("%w# ",CurrentDirName.Buffer);
|
||||
}
|
||||
|
||||
VOID ShellProcessCommand(char* cmd)
|
||||
@ -88,6 +93,7 @@ NTSTATUS TstShell(VOID)
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
char cmd[255];
|
||||
|
||||
|
||||
RtlInitAnsiString(&astr,"\\");
|
||||
RtlAnsiStringToUnicodeString(&CurrentDirName,&astr,TRUE);
|
||||
|
||||
@ -95,17 +101,14 @@ NTSTATUS TstShell(VOID)
|
||||
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
||||
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
||||
ZwOpenDirectoryObject(&CurrentDirHandle,0,&attr);
|
||||
|
||||
RtlInitAnsiString(&afilename,"\\Device\\Keyboard");
|
||||
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
||||
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
||||
ZwOpenFile(&KeyboardHandle,0,&attr,NULL,0,0);
|
||||
|
||||
|
||||
TstReadLineInit();
|
||||
|
||||
for(;;)
|
||||
{
|
||||
ShellDisplayPrompt();
|
||||
ShellGetCommand(cmd);
|
||||
TstReadLine(255,cmd);
|
||||
ShellProcessCommand(cmd);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ endif
|
||||
DEFINES = -DCHECKED_BUILD -DWIN32_LEAN_AND_MEAN -DDBG
|
||||
CC = $(PREFIX)gcc
|
||||
NATIVE_CC = gcc
|
||||
CFLAGS = -O2 -I../../include -I../include -fno-builtin $(DEFINES) -Wall -Wstrict-prototypes
|
||||
CFLAGS = -O2 -I../../../include -I../../include -I../include -fno-builtin $(DEFINES) -Wall -Wstrict-prototypes
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
NASM = nasm
|
||||
NFLAGS = -i../include/ -f$(NASM_FORMAT)
|
||||
|
Loading…
Reference in New Issue
Block a user