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