mirror of
https://github.com/reactos/reactos.git
synced 2025-08-08 15:23:05 +00:00
Extensive changes to the objmgr
Some bug fixes svn path=/trunk/; revision=200
This commit is contained in:
parent
e999320cb5
commit
5ba4cc87c5
59 changed files with 1596 additions and 1482 deletions
|
@ -19,32 +19,10 @@ void debug_printf(char* fmt, ...)
|
||||||
|
|
||||||
void ExecuteCd(char* cmdline)
|
void ExecuteCd(char* cmdline)
|
||||||
{
|
{
|
||||||
UCHAR Buffer[255];
|
if (!SetCurrentDirectoryA(cmdline))
|
||||||
|
|
||||||
debug_printf("ExecuteCd(cmdline %s)\n",cmdline);
|
|
||||||
|
|
||||||
if (cmdline[0] != '\\' &&
|
|
||||||
cmdline[1] != ':')
|
|
||||||
{
|
{
|
||||||
GetCurrentDirectoryA(255,Buffer);
|
debug_printf("Invalid directory\n");
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
Buffer[0] = 0;
|
|
||||||
}
|
|
||||||
debug_printf("Buffer %s\n",Buffer);
|
|
||||||
|
|
||||||
lstrcatA(Buffer,cmdline);
|
|
||||||
|
|
||||||
debug_printf("Buffer %s\n",Buffer);
|
|
||||||
|
|
||||||
if (Buffer[lstrlenA(Buffer)-1] != '\\')
|
|
||||||
{
|
|
||||||
lstrcatA(Buffer,"\\");
|
|
||||||
}
|
|
||||||
debug_printf("Buffer %s\n",Buffer);
|
|
||||||
|
|
||||||
SetCurrentDirectoryA(Buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExecuteDir(char* cmdline)
|
void ExecuteDir(char* cmdline)
|
||||||
|
@ -136,7 +114,7 @@ void ExecuteCommand(char* line)
|
||||||
char* cmd;
|
char* cmd;
|
||||||
char* tail;
|
char* tail;
|
||||||
|
|
||||||
if (line[1] == ':' && line[2] == 0)
|
if (isalpha(line[0]) && line[1] == ':' && line[2] == 0)
|
||||||
{
|
{
|
||||||
line[2] = '\\';
|
line[2] = '\\';
|
||||||
line[3] = 0;
|
line[3] = 0;
|
||||||
|
@ -156,7 +134,6 @@ void ExecuteCommand(char* line)
|
||||||
}
|
}
|
||||||
cmd = line;
|
cmd = line;
|
||||||
|
|
||||||
// debug_printf("cmd '%s' tail '%s'\n",cmd,tail);
|
|
||||||
|
|
||||||
if (cmd==NULL)
|
if (cmd==NULL)
|
||||||
{
|
{
|
||||||
|
@ -196,11 +173,15 @@ void ReadLine(char* line)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ReadConsoleA(InputHandle,
|
if (!ReadConsoleA(InputHandle,
|
||||||
&KeyEvent,
|
&KeyEvent,
|
||||||
sizeof(KEY_EVENT_RECORD),
|
sizeof(KEY_EVENT_RECORD),
|
||||||
&Result,
|
&Result,
|
||||||
NULL);
|
NULL))
|
||||||
|
{
|
||||||
|
debug_printf("Failed to read from console\n");
|
||||||
|
for(;;);
|
||||||
|
}
|
||||||
if (KeyEvent.bKeyDown && KeyEvent.AsciiChar != 0)
|
if (KeyEvent.bKeyDown && KeyEvent.AsciiChar != 0)
|
||||||
{
|
{
|
||||||
debug_printf("%c", KeyEvent.AsciiChar);
|
debug_printf("%c", KeyEvent.AsciiChar);
|
||||||
|
|
|
@ -71,7 +71,6 @@ typedef DISK_GEOMETRY *PDISK_GEOMETRY;
|
||||||
|
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
#include <internal/kernel.h>
|
|
||||||
#include <internal/i386/io.h>
|
#include <internal/i386/io.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
#include <wstring.h>
|
#include <wstring.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
#include "ext2fs.h"
|
#include "ext2fs.h"
|
||||||
|
@ -29,15 +29,24 @@ NTSTATUS Ext2CloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
||||||
* FUNCTION: Closes a file
|
* FUNCTION: Closes a file
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
DPRINT("Ext2CloseFile(DeviceExt %x, FileObject %x)\n",
|
||||||
|
DeviceExt,FileObject);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS Ext2Close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
NTSTATUS Ext2Close(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION Stack;
|
||||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
PDEVICE_EXTENSION DeviceExtension;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("Ext2Close(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||||
|
|
||||||
|
Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
FileObject = Stack->FileObject;
|
||||||
|
DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
|
|
||||||
Status = Ext2CloseFile(DeviceExtension,FileObject);
|
Status = Ext2CloseFile(DeviceExtension,FileObject);
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
|
|
|
@ -758,9 +758,21 @@ NTSTATUS FsdCloseFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject)
|
||||||
{
|
{
|
||||||
PVfatFCB pFcb;
|
PVfatFCB pFcb;
|
||||||
PVfatCCB pCcb;
|
PVfatCCB pCcb;
|
||||||
|
|
||||||
|
DPRINT("FsdCloseFile(DeviceExt %x, FileObject %x)\n",
|
||||||
|
DeviceExt,FileObject);
|
||||||
|
|
||||||
//FIXME : update entry in directory ?
|
//FIXME : update entry in directory ?
|
||||||
pCcb = (PVfatCCB)(FileObject->FsContext2);
|
pCcb = (PVfatCCB)(FileObject->FsContext2);
|
||||||
|
|
||||||
|
DPRINT("pCcb %x\n",pCcb);
|
||||||
|
if (pCcb == NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
pFcb = pCcb->pFcb;
|
pFcb = pCcb->pFcb;
|
||||||
|
|
||||||
pFcb->RefCount--;
|
pFcb->RefCount--;
|
||||||
if(pFcb->RefCount<=0)
|
if(pFcb->RefCount<=0)
|
||||||
{
|
{
|
||||||
|
@ -1310,6 +1322,8 @@ NTSTATUS FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("FsdClose(DeviceObject %x, Irp %x)\n",DeviceObject, Irp);
|
||||||
|
|
||||||
Status = FsdCloseFile(DeviceExtension,FileObject);
|
Status = FsdCloseFile(DeviceExtension,FileObject);
|
||||||
|
|
||||||
Irp->IoStatus.Status = Status;
|
Irp->IoStatus.Status = Status;
|
||||||
|
|
|
@ -43,5 +43,16 @@ NTSTATUS ObReferenceObjectByPointer(PVOID Object,
|
||||||
POBJECT_TYPE ObjectType,
|
POBJECT_TYPE ObjectType,
|
||||||
KPROCESSOR_MODE AccessMode);
|
KPROCESSOR_MODE AccessMode);
|
||||||
|
|
||||||
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
|
NTSTATUS ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||||
PVOID* Object, PWSTR* UnparsedSection);
|
ULONG Attributes,
|
||||||
|
PACCESS_STATE PassedAccessState,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_TYPE ObjectType,
|
||||||
|
KPROCESSOR_MODE AccessMode,
|
||||||
|
PVOID ParseContext,
|
||||||
|
PVOID* ObjectPtr);
|
||||||
|
|
||||||
|
PVOID ObCreateObject(PHANDLE Handle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
POBJECT_TYPE Type);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
struct _DIRECTORY_OBJECT;
|
struct _DIRECTORY_OBJECT;
|
||||||
|
struct _OBJECT_ATTRIBUTES;
|
||||||
|
|
||||||
typedef ULONG ACCESS_STATE, *PACCESS_STATE;
|
typedef ULONG ACCESS_STATE, *PACCESS_STATE;
|
||||||
|
|
||||||
|
@ -7,9 +8,6 @@ typedef struct _OBJECT_HANDLE_INFORMATION {
|
||||||
ACCESS_MASK GrantedAccess;
|
ACCESS_MASK GrantedAccess;
|
||||||
} OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
|
} OBJECT_HANDLE_INFORMATION, *POBJECT_HANDLE_INFORMATION;
|
||||||
|
|
||||||
struct _OBJECT;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct _OBJECT_TYPE
|
typedef struct _OBJECT_TYPE
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -62,18 +60,18 @@ typedef struct _OBJECT_TYPE
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Called to close an object if OkayToClose returns true
|
* PURPOSE: Called to close an object if OkayToClose returns true
|
||||||
*/
|
*/
|
||||||
VOID (*Close)(PVOID ObjectBody);
|
VOID (*Close)(PVOID ObjectBody, ULONG HandleCount);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Called to close an object if OkayToClose returns true
|
* PURPOSE: Called to delete an object when the last reference is removed
|
||||||
*/
|
*/
|
||||||
VOID (*Delete)(VOID);
|
VOID (*Delete)(PVOID ObjectBody);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Called when an open attempts to open a file apparently
|
* PURPOSE: Called when an open attempts to open a file apparently
|
||||||
* residing within the object
|
* residing within the object
|
||||||
*/
|
*/
|
||||||
PVOID (*Parse)(struct _OBJECT *ParsedObject, PWSTR UnparsedSection);
|
PVOID (*Parse)(PVOID ParsedObject, PWSTR* Path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*/
|
*/
|
||||||
|
@ -88,6 +86,11 @@ typedef struct _OBJECT_TYPE
|
||||||
*/
|
*/
|
||||||
VOID (*OkayToClose)(VOID);
|
VOID (*OkayToClose)(VOID);
|
||||||
|
|
||||||
|
NTSTATUS (*Create)(PVOID ObjectBody,
|
||||||
|
PVOID Parent,
|
||||||
|
PWSTR RemainingPath,
|
||||||
|
struct _OBJECT_ATTRIBUTES* ObjectAttributes);
|
||||||
|
|
||||||
} OBJECT_TYPE, *POBJECT_TYPE;
|
} OBJECT_TYPE, *POBJECT_TYPE;
|
||||||
|
|
||||||
|
|
||||||
|
@ -133,3 +136,5 @@ typedef struct _HANDLE_TABLE
|
||||||
LIST_ENTRY ListHead;
|
LIST_ENTRY ListHead;
|
||||||
KSPIN_LOCK ListLock;
|
KSPIN_LOCK ListLock;
|
||||||
} HANDLE_TABLE, *PHANDLE_TABLE;
|
} HANDLE_TABLE, *PHANDLE_TABLE;
|
||||||
|
|
||||||
|
extern POBJECT_TYPE ObDirectoryType;
|
||||||
|
|
|
@ -1558,47 +1558,35 @@ ZwFlushVirtualMemory(
|
||||||
IN ULONG NumberOfBytesToFlush,
|
IN ULONG NumberOfBytesToFlush,
|
||||||
OUT PULONG NumberOfBytesFlushed OPTIONAL
|
OUT PULONG NumberOfBytesFlushed OPTIONAL
|
||||||
);
|
);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Flushes the dirty pages to file
|
* FUNCTION: Flushes the dirty pages to file
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
|
* FIXME: Not sure this does (how is the file specified)
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtFlushWriteBuffer(VOID);
|
||||||
STDCALL
|
NTSTATUS STDCALL ZwFlushWriteBuffer(VOID);
|
||||||
NtFlushWriteBuffer (
|
|
||||||
VOID
|
/*
|
||||||
);
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
ZwFlushWriteBuffer (
|
|
||||||
VOID
|
|
||||||
);
|
|
||||||
/*
|
|
||||||
* FUNCTION: Frees a range of virtual memory
|
* FUNCTION: Frees a range of virtual memory
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* ProcessHandle = Points to the process that allocated the virtual memory
|
* ProcessHandle = Points to the process that allocated the virtual
|
||||||
* BaseAddress = Points to the memory address, rounded down to a multiple of the pagesize
|
* memory
|
||||||
* RegionSize = Limits the range to free, rounded up to a multiple of the paging size
|
* BaseAddress = Points to the memory address, rounded down to a
|
||||||
|
* multiple of the pagesize
|
||||||
|
* RegionSize = Limits the range to free, rounded up to a multiple of
|
||||||
|
* the paging size
|
||||||
* FreeType = Can be one of the values: MEM_DECOMMIT, or MEM_RELEASE
|
* FreeType = Can be one of the values: MEM_DECOMMIT, or MEM_RELEASE
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
*/
|
*/
|
||||||
|
NTSTATUS STDCALL NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
NTSTATUS
|
IN PVOID *BaseAddress,
|
||||||
STDCALL
|
IN PULONG RegionSize,
|
||||||
NtFreeVirtualMemory(
|
IN ULONG FreeType);
|
||||||
IN HANDLE ProcessHandle,
|
NTSTATUS STDCALL ZwFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
IN PVOID *BaseAddress,
|
IN PVOID *BaseAddress,
|
||||||
IN PULONG RegionSize,
|
IN PULONG RegionSize,
|
||||||
IN ULONG FreeType
|
IN ULONG FreeType);
|
||||||
);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
ZwFreeVirtualMemory(
|
|
||||||
IN HANDLE ProcessHandle,
|
|
||||||
IN PVOID *BaseAddress,
|
|
||||||
IN PULONG RegionSize,
|
|
||||||
IN ULONG FreeType
|
|
||||||
);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Sends FSCTL to the filesystem
|
* FUNCTION: Sends FSCTL to the filesystem
|
||||||
|
|
|
@ -45,4 +45,14 @@ NTSTATUS IoPageRead(PFILE_OBJECT FileObject,
|
||||||
PLARGE_INTEGER Offset,
|
PLARGE_INTEGER Offset,
|
||||||
PIO_STATUS_BLOCK StatusBlock);
|
PIO_STATUS_BLOCK StatusBlock);
|
||||||
VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
|
VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost);
|
||||||
|
|
||||||
|
NTSTATUS IopCreateFile(PVOID ObjectBody,
|
||||||
|
PVOID Parent,
|
||||||
|
PWSTR RemainingPath,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||||
|
NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
||||||
|
PVOID Parent,
|
||||||
|
PWSTR RemainingPath,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -78,16 +78,18 @@ typedef struct
|
||||||
unsigned int module_length[64];
|
unsigned int module_length[64];
|
||||||
} boot_param;
|
} boot_param;
|
||||||
|
|
||||||
|
VOID NtInitializeEventImplementation(VOID);
|
||||||
|
VOID NtInit(VOID);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initalization functions (called once by main())
|
* Initalization functions (called once by main())
|
||||||
*/
|
*/
|
||||||
void MmInitialize(boot_param* bp);
|
VOID MmInitialize(boot_param* bp);
|
||||||
void HalInit(boot_param* bp);
|
VOID HalInit(boot_param* bp);
|
||||||
void IoInit(void);
|
VOID IoInit(VOID);
|
||||||
void ObInit(void);
|
VOID ObInit(VOID);
|
||||||
void PsInit(void);
|
VOID PsInit(VOID);
|
||||||
void TstBegin(void);
|
VOID TstBegin(VOID);
|
||||||
VOID KeInit(VOID);
|
VOID KeInit(VOID);
|
||||||
VOID HalInitConsole(boot_param* bp);
|
VOID HalInitConsole(boot_param* bp);
|
||||||
|
|
||||||
|
|
|
@ -61,10 +61,10 @@ VOID ObDeleteHandle(HANDLE Handle);
|
||||||
NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
|
NTSTATUS ObLookupObject(HANDLE rootdir, PWSTR string, PVOID* Object,
|
||||||
PWSTR* UnparsedSection, ULONG Attributes);
|
PWSTR* UnparsedSection, ULONG Attributes);
|
||||||
|
|
||||||
PVOID ObGenericCreateObject(PHANDLE Handle,
|
PVOID ObCreateObject(PHANDLE Handle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
POBJECT_TYPE Type);
|
POBJECT_TYPE Type);
|
||||||
VOID ObInitializeHandleTable(PKPROCESS Parent, BOOLEAN Inherit,
|
VOID ObInitializeHandleTable(PKPROCESS Parent, BOOLEAN Inherit,
|
||||||
PKPROCESS Process);
|
PKPROCESS Process);
|
||||||
VOID ObRemoveEntry(POBJECT_HEADER Header);
|
VOID ObRemoveEntry(POBJECT_HEADER Header);
|
||||||
|
@ -101,5 +101,6 @@ typedef struct
|
||||||
} HANDLE_REP, *PHANDLE_REP;
|
} HANDLE_REP, *PHANDLE_REP;
|
||||||
|
|
||||||
PHANDLE_REP ObTranslateHandle(PKPROCESS Process, HANDLE h);
|
PHANDLE_REP ObTranslateHandle(PKPROCESS Process, HANDLE h);
|
||||||
|
extern PDIRECTORY_OBJECT NameSpaceRoot;
|
||||||
|
|
||||||
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */
|
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */
|
||||||
|
|
|
@ -79,6 +79,28 @@ HANDLE STDCALL CreateFileW(LPCWSTR lpFileName,
|
||||||
WCHAR *FilePart;
|
WCHAR *FilePart;
|
||||||
UINT Len = 0;
|
UINT Len = 0;
|
||||||
|
|
||||||
|
switch (dwCreationDisposition)
|
||||||
|
{
|
||||||
|
case CREATE_NEW:
|
||||||
|
dwCreationDisposition = FILE_CREATE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CREATE_ALWAYS:
|
||||||
|
dwCreationDisposition = FILE_OVERWRITE_IF;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPEN_EXISTING:
|
||||||
|
dwCreationDisposition = FILE_OPEN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OPEN_ALWAYS:
|
||||||
|
dwCreationDisposition = OPEN_ALWAYS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRUNCATE_EXISTING:
|
||||||
|
dwCreationDisposition = FILE_OVERWRITE;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINT("CreateFileW(lpFileName %w)\n",lpFileName);
|
DPRINT("CreateFileW(lpFileName %w)\n",lpFileName);
|
||||||
|
|
||||||
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
|
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
|
||||||
|
|
|
@ -63,6 +63,7 @@ DWORD STDCALL GetCurrentDirectoryW(DWORD nBufferLength, LPWSTR lpBuffer)
|
||||||
BOOL STDCALL SetCurrentDirectoryA(LPCSTR lpPathName)
|
BOOL STDCALL SetCurrentDirectoryA(LPCSTR lpPathName)
|
||||||
{
|
{
|
||||||
UINT i;
|
UINT i;
|
||||||
|
WCHAR TempStr[MAX_PATH];
|
||||||
|
|
||||||
DPRINT("SetCurrentDirectoryA(lpPathName %s)\n",lpPathName);
|
DPRINT("SetCurrentDirectoryA(lpPathName %s)\n",lpPathName);
|
||||||
|
|
||||||
|
@ -73,24 +74,59 @@ BOOL STDCALL SetCurrentDirectoryA(LPCSTR lpPathName)
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((lpPathName[i])!=0 && i < MAX_PATH)
|
while ((lpPathName[i])!=0 && i < MAX_PATH)
|
||||||
{
|
{
|
||||||
CurrentDirectoryW[i] = (unsigned short)lpPathName[i];
|
TempStr[i] = (unsigned short)lpPathName[i];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
CurrentDirectoryW[i] = 0;
|
TempStr[i] = 0;
|
||||||
|
|
||||||
DPRINT("CurrentDirectoryW = '%w'\n",CurrentDirectoryW);
|
return(SetCurrentDirectoryW(TempStr));
|
||||||
|
|
||||||
return(TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
WINBOOL STDCALL SetCurrentDirectoryW(LPCWSTR lpPathName)
|
WINBOOL STDCALL SetCurrentDirectoryW(LPCWSTR lpPathName)
|
||||||
{
|
{
|
||||||
|
WCHAR TempDir[MAX_PATH];
|
||||||
|
HANDLE TempHandle;
|
||||||
|
ULONG Len;
|
||||||
|
|
||||||
|
DPRINT("SetCurrentDirectoryW(lpPathName %w)\n",lpPathName);
|
||||||
|
|
||||||
if ( lpPathName == NULL )
|
if ( lpPathName == NULL )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if ( lstrlenW(lpPathName) > MAX_PATH )
|
if ( lstrlenW(lpPathName) > MAX_PATH )
|
||||||
return FALSE;
|
return FALSE;
|
||||||
lstrcpyW(CurrentDirectoryW,lpPathName);
|
|
||||||
|
lstrcpyW(TempDir, CurrentDirectoryW);
|
||||||
|
GetFullPathNameW(lpPathName,
|
||||||
|
MAX_PATH,
|
||||||
|
TempDir,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
Len = lstrlenW(TempDir);
|
||||||
|
if (TempDir[Len-1] != '\\')
|
||||||
|
{
|
||||||
|
TempDir[Len] = '\\';
|
||||||
|
TempDir[Len+1] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("TempDir %w\n",TempDir);
|
||||||
|
|
||||||
|
TempHandle = CreateFileW(TempDir,
|
||||||
|
FILE_TRAVERSE,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_ATTRIBUTE_DIRECTORY,
|
||||||
|
NULL);
|
||||||
|
if (TempHandle == NULL)
|
||||||
|
{
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
CloseHandle(TempHandle);
|
||||||
|
lstrcpyW(CurrentDirectoryW, TempDir);
|
||||||
|
|
||||||
|
DPRINT("CurrentDirectoryW %w\n",CurrentDirectoryW);
|
||||||
|
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -171,84 +171,80 @@ DWORD STDCALL GetFullPathNameA(LPCSTR lpFileName,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define IS_END_OF_NAME(ch) (!(ch) || ((ch) == L'/') || ((ch) == L'\\'))
|
DWORD STDCALL GetFullPathNameW(LPCWSTR lpFileName,
|
||||||
|
DWORD nBufferLength,
|
||||||
|
LPWSTR lpBuffer,
|
||||||
DWORD
|
LPWSTR *lpFilePart)
|
||||||
STDCALL
|
|
||||||
GetFullPathNameW(
|
|
||||||
LPCWSTR lpFileName,
|
|
||||||
DWORD nBufferLength,
|
|
||||||
LPWSTR lpBuffer,
|
|
||||||
LPWSTR *lpFilePart
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
PWSTR p;
|
||||||
|
PWSTR prev = NULL;
|
||||||
|
|
||||||
WCHAR buffer[MAX_PATH];
|
DPRINT("GetFullPathNameW(lpFileName %w, nBufferLength %d, lpBuffer %w, "
|
||||||
WCHAR *p;
|
"lpFilePart %x)\n",lpFileName,nBufferLength,lpBuffer,lpFilePart);
|
||||||
|
|
||||||
if (!lpFileName || !lpBuffer) return 0;
|
if (!lpFileName || !lpBuffer) return 0;
|
||||||
|
|
||||||
p = buffer;
|
if (isalpha(lpFileName[0]) && lpFileName[1] == ':')
|
||||||
|
{
|
||||||
|
lstrcpyW(lpBuffer, lpFileName);
|
||||||
|
}
|
||||||
|
else if (lpFileName[0] == '\\')
|
||||||
|
{
|
||||||
|
lstrcpyW(&lpBuffer[2], lpFileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lstrcatW(lpBuffer, lpFileName);
|
||||||
|
}
|
||||||
|
|
||||||
if (IS_END_OF_NAME(*lpFileName) && (*lpFileName)) /* Absolute path */
|
DPRINT("lpBuffer %w\n",lpBuffer);
|
||||||
{
|
|
||||||
while (*lpFileName == L'\\')
|
|
||||||
lpFileName++;
|
|
||||||
}
|
|
||||||
else /* Relative path or empty path */
|
|
||||||
{
|
|
||||||
if ( GetCurrentDirectoryW(MAX_PATH,p) == 0 )
|
|
||||||
wcscpy( p, L"C:");
|
|
||||||
if (*p)
|
|
||||||
p += wcslen(p);
|
|
||||||
}
|
|
||||||
if (!*lpFileName) /* empty path */
|
|
||||||
*p++ = '\\';
|
|
||||||
*p = '\0';
|
|
||||||
|
|
||||||
while (*lpFileName)
|
p = lpBuffer + 2;
|
||||||
{
|
|
||||||
if (*lpFileName == '.')
|
|
||||||
{
|
|
||||||
if (IS_END_OF_NAME(lpFileName[1]))
|
|
||||||
{
|
|
||||||
lpFileName++;
|
|
||||||
while (*lpFileName == L'\\' ) lpFileName++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else if ((lpFileName[1] == L'.') && IS_END_OF_NAME(lpFileName[2]))
|
|
||||||
{
|
|
||||||
lpFileName += 2;
|
|
||||||
while ((*lpFileName == '\\') ) lpFileName++;
|
|
||||||
while ((p > buffer + 2) && (*p != '\\')) p--;
|
|
||||||
*p = '\0'; /* Remove trailing separator */
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (p >= buffer + sizeof(buffer) - 1)
|
|
||||||
{
|
|
||||||
//DOS_ERROR( ER_PathNotFound, EC_NotFound, SA_Abort, EL_Disk);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*p++ = '\\';
|
|
||||||
while (!IS_END_OF_NAME(*lpFileName) && (p < buffer + sizeof(buffer) -1))
|
|
||||||
*p++ = *lpFileName++;
|
|
||||||
*p = '\0';
|
|
||||||
while ((*lpFileName == '\\') ) lpFileName++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!buffer[2])
|
while ((*p) != 0)
|
||||||
{
|
{
|
||||||
buffer[2] = '\\';
|
DPRINT("prev %w p %w\n",prev,p);
|
||||||
buffer[3] = '\0';
|
if (p[1] == '.' && (p[2] == '\\' || p[2] == 0))
|
||||||
}
|
{
|
||||||
|
lstrcpyW(p, p+2);
|
||||||
|
}
|
||||||
|
else if (p[1] == '.' && p[2] == '.' && (p[3] == '\\' || p[3] == 0) &&
|
||||||
|
prev != NULL)
|
||||||
|
{
|
||||||
|
lstrcpyW(prev, p+3);
|
||||||
|
p = prev;
|
||||||
|
if (prev == (lpBuffer+2))
|
||||||
|
{
|
||||||
|
prev = NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prev--;
|
||||||
|
while ((*prev) != '\\')
|
||||||
|
{
|
||||||
|
prev--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prev = p;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
while ((*p) != 0 && (*p) != '\\');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lpFilePart != NULL)
|
||||||
|
{
|
||||||
|
(*lpFilePart) = prev;
|
||||||
|
}
|
||||||
|
|
||||||
wcsncpy( lpBuffer, buffer, nBufferLength);
|
DPRINT("lpBuffer %w\n",lpBuffer);
|
||||||
|
|
||||||
//TRACE(dosfs, "returning %s\n", buffer );
|
return wcslen(lpBuffer);
|
||||||
return wcslen(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
all: ntdll.a
|
all: ntdll.a
|
||||||
|
|
||||||
OBJECTS = napi.o stubs/stubs.o string/wstring.o stdio/vsprintf.o \
|
OBJECTS = napi.o stubs/stubs.o string/wstring.o stdio/vsprintf.o \
|
||||||
rtl/unicode.o rtl/namespc.o
|
rtl/unicode.o rtl/namespc.o string/ctype.o
|
||||||
|
|
||||||
ntdll.a: $(OBJECTS)
|
ntdll.a: $(OBJECTS)
|
||||||
$(AR) vcsr ntdll.a $(OBJECTS)
|
$(AR) vcsr ntdll.a $(OBJECTS)
|
||||||
|
|
42
reactos/lib/ntdll/string/ctype.c
Normal file
42
reactos/lib/ntdll/string/ctype.c
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
|
||||||
|
#define upalpha ('A' - 'a')
|
||||||
|
|
||||||
|
int isalpha(char c)
|
||||||
|
{
|
||||||
|
return(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')));
|
||||||
|
}
|
||||||
|
|
||||||
|
int isspace(char c)
|
||||||
|
{
|
||||||
|
return(c==' '||c=='\t');
|
||||||
|
}
|
||||||
|
|
||||||
|
char toupper(char c)
|
||||||
|
{
|
||||||
|
if ((c>='a') && (c<='z')) return (c+upalpha);
|
||||||
|
return(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
int islower(char c)
|
||||||
|
{
|
||||||
|
if ((c>='a') && (c<='z')) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int isdigit(char c)
|
||||||
|
{
|
||||||
|
if ((c>='0') && (c<='9')) return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int isxdigit(char c)
|
||||||
|
{
|
||||||
|
if (((c>='0') && (c<='9')) || ((toupper(c)>='A') && (toupper(c)<='Z')))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -543,18 +543,13 @@ STUB(cos)
|
||||||
STUB(fabs)
|
STUB(fabs)
|
||||||
STUB(floor)
|
STUB(floor)
|
||||||
STUB(isalnum)
|
STUB(isalnum)
|
||||||
STUB(isalpha)
|
|
||||||
STUB(iscntrl)
|
STUB(iscntrl)
|
||||||
STUB(isdigit)
|
|
||||||
STUB(isgraph)
|
STUB(isgraph)
|
||||||
STUB(islower)
|
|
||||||
STUB(isprint)
|
STUB(isprint)
|
||||||
STUB(ispunct)
|
STUB(ispunct)
|
||||||
STUB(isspace)
|
|
||||||
STUB(isupper)
|
STUB(isupper)
|
||||||
STUB(iswalpha)
|
STUB(iswalpha)
|
||||||
STUB(iswctype)
|
STUB(iswctype)
|
||||||
STUB(isxdigit)
|
|
||||||
STUB(labs)
|
STUB(labs)
|
||||||
STUB(log)
|
STUB(log)
|
||||||
STUB(mbstowcs)
|
STUB(mbstowcs)
|
||||||
|
@ -585,6 +580,4 @@ STUB(strtol)
|
||||||
STUB(strtoul)
|
STUB(strtoul)
|
||||||
STUB(swprintf)
|
STUB(swprintf)
|
||||||
STUB(tan)
|
STUB(tan)
|
||||||
STUB(tolower)
|
|
||||||
STUB(toupper)
|
|
||||||
STUB(towlower)
|
STUB(towlower)
|
||||||
|
|
|
@ -12,127 +12,97 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <ddk/ntifs.h>
|
#include <ddk/ntifs.h>
|
||||||
|
#include <internal/bitops.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* TYPES *********************************************************************/
|
/* TYPES *********************************************************************/
|
||||||
|
|
||||||
#define CACHE_SEGMENT_SIZE (0x10000)
|
#define CACHE_SEGMENT_SIZE (0x10000)
|
||||||
|
|
||||||
#define CACHE_SEGMENT_INVALID (0) // Isn't valid
|
|
||||||
#define CACHE_SEGMENT_WRITTEN (1) // Written
|
|
||||||
#define CACHE_SEGMENT_READ (2)
|
|
||||||
|
|
||||||
typedef struct _CACHE_SEGMENT
|
typedef struct _CACHE_SEGMENT
|
||||||
{
|
{
|
||||||
ULONG Type; // Debugging
|
PVOID BaseAddress;
|
||||||
ULONG Size;
|
PMEMORY_AREA MemoryArea;
|
||||||
LIST_ENTRY ListEntry; // Entry in the per-open list of segments
|
ULONG ValidPages;
|
||||||
PVOID BaseAddress; // Base address of the mapping
|
ULONG AllocatedPages;
|
||||||
ULONG ValidLength; // Length of the mapping
|
LIST_ENTRY ListEntry;
|
||||||
ULONG State; // Information
|
ULONG FileOffset;
|
||||||
MEMORY_AREA* MemoryArea; // Memory area for the mapping
|
|
||||||
ULONG FileOffset; // Offset within the file of the mapping
|
|
||||||
KEVENT Event;
|
|
||||||
BOOLEAN Dirty; // Contains dirty data
|
|
||||||
} CACHE_SEGMENT, *PCACHE_SEGMENT;
|
} CACHE_SEGMENT, *PCACHE_SEGMENT;
|
||||||
|
|
||||||
typedef struct _CC1_CCB
|
typedef struct _BCB
|
||||||
{
|
{
|
||||||
ULONG Type;
|
|
||||||
ULONG Size;
|
|
||||||
LIST_ENTRY CacheSegmentListHead;
|
LIST_ENTRY CacheSegmentListHead;
|
||||||
KSPIN_LOCK CacheSegmentListLock;
|
PFILE_OBJECT FileObject;
|
||||||
LIST_ENTRY ListEntry;
|
KSPIN_LOCK BcbLock;
|
||||||
} CC1_CCB, PCC1_CCB;
|
} BCB, *PBCB;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
PVOID Cc1FlushView(PCC1_CCB CacheDesc,
|
NTSTATUS CcRequestCachePage(PBCB Bcb,
|
||||||
ULONG FileOffset,
|
ULONG FileOffset,
|
||||||
ULONG Length)
|
PVOID* BaseAddress,
|
||||||
{
|
PBOOLEAN UptoDate)
|
||||||
}
|
|
||||||
|
|
||||||
PVOID Cc1PurgeView(PCC1_CCB CacheDesc,
|
|
||||||
ULONG FileOffset,
|
|
||||||
ULONG Length)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS Cc1RequestView(PCC1_CCB CacheDesc,
|
|
||||||
ULONG FileOffset,
|
|
||||||
ULONG Length,
|
|
||||||
PCACHE_SEGMENT ReturnedSegments[],
|
|
||||||
PULONG NrSegments)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Request a view for caching data
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
|
KIRQL oldirql;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
PCACHE_SEGMENT current;
|
PCACHE_SEGMENT current;
|
||||||
PCACHE_SEGMENT new_segment;
|
ULONG InternalOffset;
|
||||||
ULONG MaxSegments;
|
|
||||||
ULONG LengthDelta;
|
|
||||||
|
|
||||||
MaxSegments = *NrSegments;
|
KeAcquireSpinLock(&Bcb->BcbLock, &oldirql);
|
||||||
(*NrSegments) = 0;
|
|
||||||
|
|
||||||
KeAcquireSpinLock(&CacheDesc->CacheSegmentListLock);
|
current_entry = Bcb->CacheSegmentListHead.Flink;
|
||||||
|
while (current_entry != &Bcb->CacheSegmentListHead)
|
||||||
current_entry = CacheDesc->CacheSegmentListHead.Flink;
|
|
||||||
while (current_entry != &(CacheDesc->CacheSegmentListHead))
|
|
||||||
{
|
{
|
||||||
current = CONTAING_RECORD(current_entry, CACHE_SEGMENT, ListEntry);
|
current = CONTAING_RECORD(current, CACHE_SEGMENT, ListEntry);
|
||||||
|
|
||||||
if (current->FileOffset <= FileOffset &&
|
if (current->FileOffset <= FileOffset &&
|
||||||
(current->FileOffset + current->ValidLength) > FileOffset)
|
(current->FileOffset + CACHE_SEGMENT_SIZE) > FileOffset)
|
||||||
{
|
{
|
||||||
ReturnedSegments[(*NrSegments)] = current;
|
InternalOffset = (FileOffset - current->FileOffset);
|
||||||
(*NrSegments)++;
|
|
||||||
FileOffset = current->FileOffset + current->ValidLength;
|
|
||||||
LengthDelta = (FileOffset - current->FileOffset);
|
|
||||||
if (Length <= LengthDelta)
|
|
||||||
{
|
|
||||||
KeReleaseSpinLock(&CacheDesc->CacheSegmentListLock);
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
Length = Length - LengthDelta;
|
|
||||||
}
|
|
||||||
else if (current->FileOffset <= (FileOffset + Length) &&
|
|
||||||
(current->FileOffset + current->ValidLength) >
|
|
||||||
(FileOffset + Length))
|
|
||||||
{
|
|
||||||
ReturnedSegments[(*NrSegments)] = current;
|
|
||||||
(*NrSegments)++;
|
|
||||||
Length = Length - ((FileOffset + Length) - current->FileOffset);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!test_bit(InternalOffset / PAGESIZE,
|
||||||
|
current->AllocatedPages))
|
||||||
|
{
|
||||||
|
MmSetPageEntry(PsGetCurrentProcess(),
|
||||||
|
current->BaseAddress + InternalOffset,
|
||||||
|
PAGE_READWRITE,
|
||||||
|
get_free_page());
|
||||||
|
}
|
||||||
|
if (!test_bit(InternalOffset / PAGESIZE,
|
||||||
|
current->ValidPages))
|
||||||
|
{
|
||||||
|
UptoDate = False;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UptoDate = True;
|
||||||
|
}
|
||||||
|
(*BaseAddress) = current->BaseAddress + InternalOffset;
|
||||||
|
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
KeReleaseSpinLock(&CacheDesc->CacheSegmentListLock);
|
KeReleaseSpinLock(&Bcb->BcbLock, oldirql);
|
||||||
}
|
}
|
||||||
|
|
||||||
PCC1_CCB Cc1InitializeFileCache(PFILE_OBJECT FileObject)
|
NTSTATUS CcInitializeFileCache(PFILE_OBJECT FileObject,
|
||||||
/*
|
PBCB* Bcb)
|
||||||
* FUNCTION: Initialize caching for a file
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
PCC1_CCB CacheDesc;
|
(*Bcb) = ExAllocatePool(NonPagedPool, sizeof(BCB));
|
||||||
|
if ((*Bcb) == NULL)
|
||||||
CacheDesc = ExAllocatePool(NonPagedPool, sizeof(CC1_CCB));
|
|
||||||
if (CacheDesc == NULL)
|
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(STATUS_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
CacheDesc->Type = CC1_CCB_ID;
|
(*Bcb)->FileObject = FileObject;
|
||||||
InitializeListHead(&CacheDesc->CacheSegmentListHead);
|
InitializeListHead(&(*Bcb)->CacheSegmentListHead);
|
||||||
KeInitializeSpinLock(&CacheDesc->CacheSegmentListLock);
|
KeInitializeSpinLock(&(*Bcb)->BcbLock);
|
||||||
|
|
||||||
return(CacheDesc);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -619,46 +619,32 @@ NtSetInformationKey(
|
||||||
KeyInformationLength);
|
KeyInformationLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwSetInformationKey(IN HANDLE KeyHandle,
|
||||||
STDCALL
|
IN CINT KeyInformationClass,
|
||||||
ZwSetInformationKey(
|
IN PVOID KeyInformation,
|
||||||
IN HANDLE KeyHandle,
|
IN ULONG KeyInformationLength)
|
||||||
IN CINT KeyInformationClass,
|
|
||||||
IN PVOID KeyInformation,
|
|
||||||
IN ULONG KeyInformationLength
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtUnloadKey(HANDLE KeyHandle)
|
||||||
STDCALL
|
|
||||||
NtUnloadKey(
|
|
||||||
HANDLE KeyHandle
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
return ZwUnloadKey(KeyHandle);
|
return ZwUnloadKey(KeyHandle);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwUnloadKey(HANDLE KeyHandle)
|
||||||
STDCALL
|
|
||||||
ZwUnloadKey(
|
|
||||||
HANDLE KeyHandle
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL NtInitializeRegistry(BOOLEAN SetUpBoot)
|
||||||
NtInitializeRegistry(BOOLEAN SetUpBoot)
|
|
||||||
{
|
{
|
||||||
return ZwInitializeRegistry(SetUpBoot);
|
return ZwInitializeRegistry(SetUpBoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL ZwInitializeRegistry(BOOLEAN SetUpBoot)
|
||||||
ZwInitializeRegistry(BOOLEAN SetUpBoot)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS RtlCheckRegistryKey(ULONG RelativeTo, PWSTR Path)
|
NTSTATUS RtlCheckRegistryKey(ULONG RelativeTo, PWSTR Path)
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ke/bug.c
|
* FILE: ntoskrnl/ex/power.c
|
||||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
* PURPOSE: Power managment
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
|
* Added reboot support 30/01/99
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/hal/io.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
@ -26,7 +28,34 @@ NTSTATUS STDCALL NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
||||||
return(ZwShutdownSystem(Action));
|
return(ZwShutdownSystem(Action));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwShutdownSystem(IN SHUTDOWN_ACTION Action)
|
static void kb_wait(void)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
int i;
|
||||||
|
|
||||||
|
for (i=0; i<10000; i++)
|
||||||
|
{
|
||||||
|
if ((inb_p(0x64) & 0x02) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ZwShutdownSystem(IN SHUTDOWN_ACTION Action)
|
||||||
|
/*
|
||||||
|
* FIXME: Does a reboot only
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
int i, j;
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
for (i=0; i<100; i++)
|
||||||
|
{
|
||||||
|
kb_wait();
|
||||||
|
for (j=0; j<500; j++);
|
||||||
|
outb(0xfe, 0x64);
|
||||||
|
for (j=0; j<500; j++);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: mkernel/hal/eisa.c
|
* FILE: ntoskrnl/hal/pci
|
||||||
* PURPOSE: Interfaces to the PCI bus
|
* PURPOSE: Interfaces to BIOS32 interface
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* 05/06/98: Created
|
* 05/06/98: Created
|
||||||
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
/* INCLUDES ***************************************************************/
|
/* INCLUDES ***************************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/mm.h>
|
#include <internal/mm.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
|
|
@ -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: mkernel/hal/x86/halinit.c
|
* FILE: ntoskrnl/hal/x86/halinit.c
|
||||||
* PURPOSE: Initalize the uniprocessor, x86 hal
|
* PURPOSE: Initalize the uniprocessor, x86 hal
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
|
|
@ -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: mkernel/hal/eisa.c
|
* FILE: ntoskrnl/hal/isa.c
|
||||||
* PURPOSE: Interfaces to the ISA bus
|
* PURPOSE: Interfaces to the ISA bus
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/hal/x86/mbr.c
|
* FILE: ntoskrnl/hal/x86/mbr.c
|
||||||
* PURPOSE: Functions for reading the master boot record (MBR)
|
* PURPOSE: Functions for reading the master boot record (MBR)
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/hal/x86/mp.c
|
* FILE: ntoskrnl/hal/x86/mp.c
|
||||||
* PURPOSE: Multiprocessor stubs
|
* PURPOSE: Multiprocessor stubs
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/hal/x86/spinlock.c
|
* FILE: ntoskrnl/hal/x86/spinlock.c
|
||||||
* PURPOSE: Implements spinlocks
|
* PURPOSE: Implements spinlocks
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* 3/6/98: Created
|
* 3/6/98: Created
|
||||||
*/
|
*/
|
||||||
|
@ -15,7 +15,6 @@
|
||||||
|
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ****************************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
|
@ -35,7 +35,7 @@ NTSTATUS IoPrepareIrpBuffer(PIRP Irp,
|
||||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
{
|
{
|
||||||
IoFreeIrp(Irp);
|
IoFreeIrp(Irp);
|
||||||
return(NULL);
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
/* FIXME: should copy buffer in on other ops */
|
/* FIXME: should copy buffer in on other ops */
|
||||||
if (MajorFunction == IRP_MJ_WRITE)
|
if (MajorFunction == IRP_MJ_WRITE)
|
||||||
|
@ -262,11 +262,14 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
||||||
StackPtr->FileObject = NULL;
|
StackPtr->FileObject = NULL;
|
||||||
StackPtr->CompletionRoutine = NULL;
|
StackPtr->CompletionRoutine = NULL;
|
||||||
|
|
||||||
IoPrepareIrpBuffer(Irp,
|
if (Buffer != NULL)
|
||||||
DeviceObject,
|
{
|
||||||
Buffer,
|
IoPrepareIrpBuffer(Irp,
|
||||||
Length,
|
DeviceObject,
|
||||||
MajorFunction);
|
Buffer,
|
||||||
|
Length,
|
||||||
|
MajorFunction);
|
||||||
|
}
|
||||||
|
|
||||||
if (MajorFunction == IRP_MJ_READ)
|
if (MajorFunction == IRP_MJ_READ)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,8 +29,6 @@ VOID IoReadWriteCompletion(PDEVICE_OBJECT DeviceObject,
|
||||||
|
|
||||||
FileObject = IoStack->FileObject;
|
FileObject = IoStack->FileObject;
|
||||||
|
|
||||||
DPRINT("FileObject %x\n",FileObject);
|
|
||||||
|
|
||||||
if (DeviceObject->Flags & DO_BUFFERED_IO)
|
if (DeviceObject->Flags & DO_BUFFERED_IO)
|
||||||
{
|
{
|
||||||
if (IoStack->MajorFunction == IRP_MJ_READ)
|
if (IoStack->MajorFunction == IRP_MJ_READ)
|
||||||
|
@ -70,6 +68,7 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IoStack;
|
PIO_STACK_LOCATION IoStack;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
PFILE_OBJECT FileObject;
|
||||||
|
|
||||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||||
|
|
||||||
|
@ -98,5 +97,12 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost)
|
||||||
KeSetEvent(Irp->UserEvent,PriorityBoost,FALSE);
|
KeSetEvent(Irp->UserEvent,PriorityBoost,FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileObject = IoStack->FileObject;
|
||||||
|
|
||||||
|
if (FileObject != NULL && IoStack->MajorFunction != IRP_MJ_CLOSE)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(FileObject);
|
||||||
|
}
|
||||||
|
|
||||||
IoFreeIrp(Irp);
|
IoFreeIrp(Irp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,68 @@ NTSTATUS NtCreateFile(PHANDLE FileHandle,
|
||||||
EaLength));
|
EaLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS IopCreateFile(PVOID ObjectBody,
|
||||||
|
PVOID Parent,
|
||||||
|
PWSTR RemainingPath,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
{
|
||||||
|
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)Parent;
|
||||||
|
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("IopCreateFile(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
||||||
|
ObjectBody,Parent,RemainingPath);
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByPointer(DeviceObject,
|
||||||
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
|
IoDeviceType,
|
||||||
|
UserMode);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
CHECKPOINT;
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||||
|
|
||||||
|
DPRINT("DeviceObject %x\n",DeviceObject);
|
||||||
|
|
||||||
|
if (RemainingPath == NULL)
|
||||||
|
{
|
||||||
|
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
|
||||||
|
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
||||||
|
(ObjectAttributes->ObjectName->Length+1)*2);
|
||||||
|
FileObject->FileName.Length = ObjectAttributes->ObjectName->Length;
|
||||||
|
FileObject->FileName.MaximumLength =
|
||||||
|
ObjectAttributes->ObjectName->MaximumLength;
|
||||||
|
RtlCopyUnicodeString(&(FileObject->FileName),
|
||||||
|
ObjectAttributes->ObjectName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM &&
|
||||||
|
DeviceObject->DeviceType != FILE_DEVICE_DISK)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
|
||||||
|
{
|
||||||
|
Status = IoTryToMountStorageDevice(DeviceObject);
|
||||||
|
if (Status!=STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
||||||
|
}
|
||||||
|
RtlInitUnicodeString(&(FileObject->FileName),wstrdup(RemainingPath));
|
||||||
|
}
|
||||||
|
DPRINT("FileObject->FileName.Buffer %w\n",FileObject->FileName.Buffer);
|
||||||
|
FileObject->DeviceObject=DeviceObject;
|
||||||
|
FileObject->Vpb=DeviceObject->Vpb;
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
@ -91,14 +153,11 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PVOID Object;
|
PFILE_OBJECT FileObject;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
KEVENT Event;
|
KEVENT Event;
|
||||||
PDEVICE_OBJECT DeviceObject;
|
|
||||||
PFILE_OBJECT FileObject;
|
|
||||||
PIO_STACK_LOCATION StackLoc;
|
PIO_STACK_LOCATION StackLoc;
|
||||||
PWSTR Remainder;
|
|
||||||
|
|
||||||
DPRINT("ZwCreateFile(FileHandle %x, DesiredAccess %x, "
|
DPRINT("ZwCreateFile(FileHandle %x, DesiredAccess %x, "
|
||||||
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %w)\n",
|
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %w)\n",
|
||||||
|
@ -109,76 +168,15 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||||
|
|
||||||
*FileHandle=0;
|
*FileHandle=0;
|
||||||
|
|
||||||
FileObject = ObGenericCreateObject(FileHandle,
|
FileObject = ObCreateObject(FileHandle,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
NULL,
|
ObjectAttributes,
|
||||||
IoFileType);
|
IoFileType);
|
||||||
memset(FileObject,0,sizeof(FILE_OBJECT));
|
if (FileObject == NULL)
|
||||||
|
|
||||||
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Remainder);
|
|
||||||
|
|
||||||
if (Status != STATUS_SUCCESS && Status != STATUS_FS_QUERY_REQUIRED)
|
|
||||||
{
|
{
|
||||||
DPRINT("%s() = Failed to find object\n",__FUNCTION__);
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
ZwClose(*FileHandle);
|
|
||||||
*FileHandle=0;
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DeviceObject = (PDEVICE_OBJECT)Object;
|
|
||||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
|
||||||
|
|
||||||
if (Status == STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
|
|
||||||
FileObject->FileName.Buffer = ExAllocatePool(NonPagedPool,
|
|
||||||
(ObjectAttributes->ObjectName->Length+1)*2);
|
|
||||||
FileObject->FileName.Length = ObjectAttributes->ObjectName->Length;
|
|
||||||
FileObject->FileName.MaximumLength =
|
|
||||||
ObjectAttributes->ObjectName->MaximumLength;
|
|
||||||
RtlCopyUnicodeString(&(FileObject->FileName),
|
|
||||||
ObjectAttributes->ObjectName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
DPRINT("DeviceObject %x\n",DeviceObject);
|
|
||||||
DPRINT("FileHandle %x\n",FileHandle);
|
|
||||||
if (DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM &&
|
|
||||||
DeviceObject->DeviceType != FILE_DEVICE_DISK)
|
|
||||||
{
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
ZwClose(*FileHandle);
|
|
||||||
*FileHandle=0;
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
DPRINT("DeviceObject->Vpb %x\n",DeviceObject->Vpb);
|
|
||||||
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
Status = IoTryToMountStorageDevice(DeviceObject);
|
|
||||||
if (Status!=STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
ZwClose(*FileHandle);
|
|
||||||
*FileHandle=0;
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
DeviceObject = IoGetAttachedDevice(DeviceObject);
|
|
||||||
}
|
|
||||||
DPRINT("Remainder %x\n",Remainder);
|
|
||||||
DPRINT("Remainder %w\n",Remainder);
|
|
||||||
DPRINT("FileObject->FileName.Buffer %w\n",FileObject->FileName.Buffer);
|
|
||||||
RtlInitUnicodeString(&(FileObject->FileName),wstrdup(Remainder));
|
|
||||||
DPRINT("FileObject->FileName.Buffer %x %w\n",
|
|
||||||
FileObject->FileName.Buffer,FileObject->FileName.Buffer);
|
|
||||||
}
|
|
||||||
CHECKPOINT;
|
|
||||||
DPRINT("FileObject->FileName.Buffer %x\n",FileObject->FileName.Buffer);
|
|
||||||
|
|
||||||
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
|
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
|
||||||
{
|
{
|
||||||
FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
|
FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
|
||||||
|
@ -189,18 +187,11 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||||
FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
|
FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileObject->DeviceObject=DeviceObject;
|
|
||||||
FileObject->Vpb=DeviceObject->Vpb;
|
|
||||||
|
|
||||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||||
|
|
||||||
DPRINT("DevObj StackSize %d\n", DeviceObject->StackSize);
|
Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize, FALSE);
|
||||||
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
|
|
||||||
if (Irp==NULL)
|
if (Irp==NULL)
|
||||||
{
|
{
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
ZwClose(*FileHandle);
|
|
||||||
*FileHandle=0;
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,31 +200,26 @@ NTSTATUS ZwCreateFile(PHANDLE FileHandle,
|
||||||
StackLoc->MinorFunction = 0;
|
StackLoc->MinorFunction = 0;
|
||||||
StackLoc->Flags = 0;
|
StackLoc->Flags = 0;
|
||||||
StackLoc->Control = 0;
|
StackLoc->Control = 0;
|
||||||
StackLoc->DeviceObject = DeviceObject;
|
StackLoc->DeviceObject = FileObject->DeviceObject;
|
||||||
StackLoc->FileObject=FileObject;
|
StackLoc->FileObject = FileObject;
|
||||||
StackLoc->Parameters.Create.Options=CreateOptions&FILE_VALID_OPTION_FLAGS;
|
StackLoc->Parameters.Create.Options = CreateOptions&FILE_VALID_OPTION_FLAGS;
|
||||||
StackLoc->Parameters.Create.Options|=CreateDisposition<<24;
|
StackLoc->Parameters.Create.Options |= CreateDisposition<<24;
|
||||||
Status = IoCallDriver(DeviceObject,Irp);
|
|
||||||
if (Status==STATUS_PENDING)
|
Status = IoCallDriver(FileObject->DeviceObject,Irp);
|
||||||
|
if (Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||||
Status = IoStatusBlock->Status;
|
Status = IoStatusBlock->Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Status!=STATUS_SUCCESS)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("FileObject->FileName.Buffer %x\n",FileObject->FileName.Buffer);
|
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
ZwClose(*FileHandle);
|
ZwClose(*FileHandle);
|
||||||
*FileHandle=0;
|
(*FileHandle) = 0;
|
||||||
return(Status);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("*FileHandle %x\n",*FileHandle);
|
DPRINT("Finished ZwCreateFile()\n");
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
|
|
||||||
return(Status);
|
return(Status);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NtOpenFile(PHANDLE FileHandle,
|
NTSTATUS NtOpenFile(PHANDLE FileHandle,
|
||||||
|
|
|
@ -112,6 +112,15 @@ VOID IoRegisterDriverReinitialization(PDRIVER_OBJECT DriverObject,
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS IopDefaultDispatchFunction(PDEVICE_OBJECT DeviceObject,
|
||||||
|
PIRP Irp)
|
||||||
|
{
|
||||||
|
Irp->IoStatus.Status = STATUS_NOT_IMPLEMENTED;
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
|
||||||
|
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||||
|
return(STATUS_NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS InitializeLoadedDriver(PDRIVER_INITIALIZE entry)
|
NTSTATUS InitializeLoadedDriver(PDRIVER_INITIALIZE entry)
|
||||||
/*
|
/*
|
||||||
|
@ -121,6 +130,7 @@ NTSTATUS InitializeLoadedDriver(PDRIVER_INITIALIZE entry)
|
||||||
{
|
{
|
||||||
NTSTATUS ret;
|
NTSTATUS ret;
|
||||||
PDRIVER_OBJECT DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
|
ULONG i;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate memory for a driver object
|
* Allocate memory for a driver object
|
||||||
|
@ -133,8 +143,12 @@ NTSTATUS InitializeLoadedDriver(PDRIVER_INITIALIZE entry)
|
||||||
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
DbgPrint("%s:%d\n",__FILE__,__LINE__);
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
}
|
}
|
||||||
memset(DriverObject, '\0', sizeof(DRIVER_OBJECT));
|
memset(DriverObject, 0, sizeof(DRIVER_OBJECT));
|
||||||
CHECKPOINT;
|
|
||||||
|
for (i=0; i<=IRP_MJ_MAXIMUM_FUNCTION; i++)
|
||||||
|
{
|
||||||
|
DriverObject->MajorFunction[i] = IopDefaultDispatchFunction;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initalize the driver
|
* Initalize the driver
|
||||||
|
@ -166,6 +180,29 @@ NTSTATUS IoAttachDevice(PDEVICE_OBJECT SourceDevice,
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
||||||
|
PVOID Parent,
|
||||||
|
PWSTR RemainingPath,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
{
|
||||||
|
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)ObjectBody;
|
||||||
|
|
||||||
|
DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
||||||
|
ObjectBody, Parent, RemainingPath);
|
||||||
|
|
||||||
|
if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Parent != NULL && RemainingPath != NULL)
|
||||||
|
{
|
||||||
|
ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1);
|
||||||
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||||
ULONG DeviceExtensionSize,
|
ULONG DeviceExtensionSize,
|
||||||
PUNICODE_STRING DeviceName,
|
PUNICODE_STRING DeviceName,
|
||||||
|
@ -209,11 +246,11 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||||
if (DeviceName!=NULL)
|
if (DeviceName!=NULL)
|
||||||
{
|
{
|
||||||
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
|
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
|
||||||
dev = ObGenericCreateObject(&devh,0,&dev_attr,IoDeviceType);
|
dev = ObCreateObject(&devh,0,&dev_attr,IoDeviceType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dev = ObGenericCreateObject(&devh,0,NULL,IoDeviceType);
|
dev = ObCreateObject(&devh,0,NULL,IoDeviceType);
|
||||||
}
|
}
|
||||||
|
|
||||||
*DeviceObject=NULL;
|
*DeviceObject=NULL;
|
||||||
|
|
|
@ -204,7 +204,6 @@ NTSTATUS STDCALL ZwQueryDirectoryFile(
|
||||||
}
|
}
|
||||||
Status = IoStatusBlock->Status;
|
Status = IoStatusBlock->Status;
|
||||||
}
|
}
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/io/errlog.c
|
* FILE: ntoskrnl/io/errlog.c
|
||||||
* PURPOSE: Error logging
|
* PURPOSE: Error logging
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -17,12 +17,11 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS NtQueryInformationFile(HANDLE FileHandle,
|
||||||
NtQueryInformationFile(HANDLE FileHandle,
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock,
|
PVOID FileInformation,
|
||||||
PVOID FileInformation,
|
ULONG Length,
|
||||||
ULONG Length,
|
FILE_INFORMATION_CLASS FileInformationClass)
|
||||||
FILE_INFORMATION_CLASS FileInformationClass)
|
|
||||||
{
|
{
|
||||||
return ZwQueryInformationFile(FileHandle,
|
return ZwQueryInformationFile(FileHandle,
|
||||||
IoStatusBlock,
|
IoStatusBlock,
|
||||||
|
@ -31,12 +30,11 @@ NtQueryInformationFile(HANDLE FileHandle,
|
||||||
FileInformationClass);
|
FileInformationClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS ZwQueryInformationFile(HANDLE FileHandle,
|
||||||
ZwQueryInformationFile(HANDLE FileHandle,
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock,
|
PVOID FileInformation,
|
||||||
PVOID FileInformation,
|
ULONG Length,
|
||||||
ULONG Length,
|
FILE_INFORMATION_CLASS FileInformationClass)
|
||||||
FILE_INFORMATION_CLASS FileInformationClass)
|
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PFILE_OBJECT FileObject;
|
PFILE_OBJECT FileObject;
|
||||||
|
@ -92,12 +90,11 @@ ZwQueryInformationFile(HANDLE FileHandle,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS NtSetInformationFile(HANDLE FileHandle,
|
||||||
NtSetInformationFile(HANDLE FileHandle,
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock,
|
PVOID FileInformation,
|
||||||
PVOID FileInformation,
|
ULONG Length,
|
||||||
ULONG Length,
|
FILE_INFORMATION_CLASS FileInformationClass)
|
||||||
FILE_INFORMATION_CLASS FileInformationClass)
|
|
||||||
{
|
{
|
||||||
return ZwSetInformationFile(FileHandle,
|
return ZwSetInformationFile(FileHandle,
|
||||||
IoStatusBlock,
|
IoStatusBlock,
|
||||||
|
@ -106,57 +103,52 @@ NtSetInformationFile(HANDLE FileHandle,
|
||||||
FileInformationClass);
|
FileInformationClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS ZwSetInformationFile(HANDLE FileHandle,
|
||||||
ZwSetInformationFile(HANDLE FileHandle,
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock,
|
PVOID FileInformation,
|
||||||
PVOID FileInformation,
|
ULONG Length,
|
||||||
ULONG Length,
|
FILE_INFORMATION_CLASS FileInformationClass)
|
||||||
FILE_INFORMATION_CLASS FileInformationClass)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
PGENERIC_MAPPING
|
PGENERIC_MAPPING IoGetFileObjectGenericMapping(VOID)
|
||||||
IoGetFileObjectGenericMapping(VOID)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL NtQueryAttributesFile(IN HANDLE FileHandle,
|
||||||
NtQueryAttributesFile(IN HANDLE FileHandle,
|
IN PVOID Buffer)
|
||||||
IN PVOID Buffer)
|
|
||||||
{
|
{
|
||||||
return ZwQueryAttributesFile(FileHandle, Buffer);
|
return ZwQueryAttributesFile(FileHandle, Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL ZwQueryAttributesFile(IN HANDLE FileHandle, IN PVOID Buffer)
|
||||||
ZwQueryAttributesFile(IN HANDLE FileHandle, IN PVOID Buffer)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL NtQueryFullAttributesFile(IN HANDLE FileHandle,
|
||||||
NtQueryFullAttributesFile(IN HANDLE FileHandle, IN PVOID Attributes)
|
IN PVOID Attributes)
|
||||||
{
|
{
|
||||||
return ZwQueryFullAttributesFile(FileHandle, Attributes);
|
return ZwQueryFullAttributesFile(FileHandle, Attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL ZwQueryFullAttributesFile(IN HANDLE FileHandle,
|
||||||
ZwQueryFullAttributesFile(IN HANDLE FileHandle, IN PVOID Attributes)
|
IN PVOID Attributes)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL NtQueryEaFile(IN HANDLE FileHandle,
|
||||||
NtQueryEaFile(IN HANDLE FileHandle,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PVOID Buffer,
|
||||||
OUT PVOID Buffer,
|
IN ULONG Length,
|
||||||
IN ULONG Length,
|
IN BOOLEAN ReturnSingleEntry,
|
||||||
IN BOOLEAN ReturnSingleEntry,
|
IN PVOID EaList OPTIONAL,
|
||||||
IN PVOID EaList OPTIONAL,
|
IN ULONG EaListLength,
|
||||||
IN ULONG EaListLength,
|
IN PULONG EaIndex OPTIONAL,
|
||||||
IN PULONG EaIndex OPTIONAL,
|
IN BOOLEAN RestartScan)
|
||||||
IN BOOLEAN RestartScan)
|
|
||||||
{
|
{
|
||||||
return NtQueryEaFile(FileHandle,
|
return NtQueryEaFile(FileHandle,
|
||||||
IoStatusBlock,
|
IoStatusBlock,
|
||||||
|
@ -169,25 +161,23 @@ NtQueryEaFile(IN HANDLE FileHandle,
|
||||||
RestartScan);
|
RestartScan);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL ZwQueryEaFile(IN HANDLE FileHandle,
|
||||||
ZwQueryEaFile(IN HANDLE FileHandle,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PVOID Buffer,
|
||||||
OUT PVOID Buffer,
|
IN ULONG Length,
|
||||||
IN ULONG Length,
|
IN BOOLEAN ReturnSingleEntry,
|
||||||
IN BOOLEAN ReturnSingleEntry,
|
IN PVOID EaList OPTIONAL,
|
||||||
IN PVOID EaList OPTIONAL,
|
IN ULONG EaListLength,
|
||||||
IN ULONG EaListLength,
|
IN PULONG EaIndex OPTIONAL,
|
||||||
IN PULONG EaIndex OPTIONAL,
|
IN BOOLEAN RestartScan)
|
||||||
IN BOOLEAN RestartScan)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL NtSetEaFile(IN HANDLE FileHandle,
|
||||||
NtSetEaFile(IN HANDLE FileHandle,
|
IN PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN PIO_STATUS_BLOCK IoStatusBlock,
|
PVOID EaBuffer,
|
||||||
PVOID EaBuffer,
|
ULONG EaBufferSize)
|
||||||
ULONG EaBufferSize)
|
|
||||||
{
|
{
|
||||||
return ZwSetEaFile(FileHandle,
|
return ZwSetEaFile(FileHandle,
|
||||||
IoStatusBlock,
|
IoStatusBlock,
|
||||||
|
@ -195,11 +185,10 @@ NtSetEaFile(IN HANDLE FileHandle,
|
||||||
EaBufferSize);
|
EaBufferSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL ZwSetEaFile(IN HANDLE FileHandle,
|
||||||
ZwSetEaFile(IN HANDLE FileHandle,
|
IN PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN PIO_STATUS_BLOCK IoStatusBlock,
|
PVOID EaBuffer,
|
||||||
PVOID EaBuffer,
|
ULONG EaBufferSize)
|
||||||
ULONG EaBufferSize)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ NTSTATUS STDCALL ZwFlushBuffersFile(IN HANDLE FileHandle,
|
||||||
* the flush buffers operation. The information field is
|
* the flush buffers operation. The information field is
|
||||||
* set to number of bytes flushed to disk.
|
* set to number of bytes flushed to disk.
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
* REMARKS: This funciton maps to the win32 FlushFileBuffers
|
* REMARKS: This function maps to the win32 FlushFileBuffers
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = NULL;
|
PFILE_OBJECT FileObject = NULL;
|
||||||
|
|
|
@ -23,12 +23,61 @@
|
||||||
POBJECT_TYPE IoDeviceType = NULL;
|
POBJECT_TYPE IoDeviceType = NULL;
|
||||||
POBJECT_TYPE IoFileType = NULL;
|
POBJECT_TYPE IoFileType = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
VOID IopCloseFile(PVOID ObjectBody)
|
VOID IopCloseFile(PVOID ObjectBody, ULONG HandleCount)
|
||||||
{
|
{
|
||||||
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
||||||
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
if (HandleCount > 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ObReferenceObjectByPointer(FileObject,
|
||||||
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
|
IoFileType,
|
||||||
|
UserMode);
|
||||||
|
|
||||||
|
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_CLEANUP,
|
||||||
|
FileObject->DeviceObject,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->FileObject = FileObject;
|
||||||
|
|
||||||
|
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID IopDeleteFile(PVOID ObjectBody)
|
||||||
|
{
|
||||||
|
PFILE_OBJECT FileObject = (PFILE_OBJECT)ObjectBody;
|
||||||
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
ObReferenceObjectByPointer(ObjectBody,
|
||||||
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
|
IoFileType,
|
||||||
|
UserMode);
|
||||||
|
|
||||||
|
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_CLOSE,
|
||||||
|
FileObject->DeviceObject,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->FileObject = FileObject;
|
||||||
|
|
||||||
|
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
||||||
|
|
||||||
if (FileObject->FileName.Buffer != NULL)
|
if (FileObject->FileName.Buffer != NULL)
|
||||||
{
|
{
|
||||||
|
@ -62,6 +111,7 @@ VOID IoInit(VOID)
|
||||||
IoDeviceType->Security = NULL;
|
IoDeviceType->Security = NULL;
|
||||||
IoDeviceType->QueryName = NULL;
|
IoDeviceType->QueryName = NULL;
|
||||||
IoDeviceType->OkayToClose = NULL;
|
IoDeviceType->OkayToClose = NULL;
|
||||||
|
IoDeviceType->Create = IopCreateDevice;
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiString,"Device");
|
RtlInitAnsiString(&AnsiString,"Device");
|
||||||
RtlAnsiStringToUnicodeString(&IoDeviceType->TypeName,&AnsiString,TRUE);
|
RtlAnsiStringToUnicodeString(&IoDeviceType->TypeName,&AnsiString,TRUE);
|
||||||
|
@ -77,11 +127,12 @@ VOID IoInit(VOID)
|
||||||
IoFileType->Dump = NULL;
|
IoFileType->Dump = NULL;
|
||||||
IoFileType->Open = NULL;
|
IoFileType->Open = NULL;
|
||||||
IoFileType->Close = IopCloseFile;
|
IoFileType->Close = IopCloseFile;
|
||||||
IoFileType->Delete = NULL;
|
IoFileType->Delete = IopDeleteFile;
|
||||||
IoFileType->Parse = NULL;
|
IoFileType->Parse = NULL;
|
||||||
IoFileType->Security = NULL;
|
IoFileType->Security = NULL;
|
||||||
IoFileType->QueryName = NULL;
|
IoFileType->QueryName = NULL;
|
||||||
IoFileType->OkayToClose = NULL;
|
IoFileType->OkayToClose = NULL;
|
||||||
|
IoFileType->Create = IopCreateFile;
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiString,"File");
|
RtlInitAnsiString(&AnsiString,"File");
|
||||||
RtlAnsiStringToUnicodeString(&IoFileType->TypeName,&AnsiString,TRUE);
|
RtlAnsiStringToUnicodeString(&IoFileType->TypeName,&AnsiString,TRUE);
|
||||||
|
|
|
@ -150,10 +150,7 @@ PIO_STACK_LOCATION IoGetNextIrpStackLocation(PIRP Irp)
|
||||||
* RETURNS: A pointer to the stack location
|
* RETURNS: A pointer to the stack location
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DPRINT("IoGetNextIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
DPRINT("IoGetNextIrpStackLocation(Irp %x)\n",Irp);
|
||||||
Irp,
|
|
||||||
Irp->CurrentLocation,
|
|
||||||
Irp->StackCount);
|
|
||||||
|
|
||||||
assert(Irp!=NULL);
|
assert(Irp!=NULL);
|
||||||
DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
|
DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
|
||||||
|
@ -166,12 +163,19 @@ NTSTATUS IoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PDRIVER_OBJECT DriverObject = DeviceObject->DriverObject;
|
PDRIVER_OBJECT DriverObject;
|
||||||
PIO_STACK_LOCATION param = IoGetNextIrpStackLocation(Irp);
|
PIO_STACK_LOCATION param;
|
||||||
|
|
||||||
|
DPRINT("IoCallDriver(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||||
|
|
||||||
|
DriverObject = DeviceObject->DriverObject;
|
||||||
|
param = IoGetNextIrpStackLocation(Irp);
|
||||||
|
|
||||||
Irp->Tail.Overlay.CurrentStackLocation--;
|
Irp->Tail.Overlay.CurrentStackLocation--;
|
||||||
Irp->CurrentLocation--;
|
Irp->CurrentLocation--;
|
||||||
|
|
||||||
|
DPRINT("DriverObject->MajorFunction[param->MajorFunction] %x\n",
|
||||||
|
DriverObject->MajorFunction[param->MajorFunction]);
|
||||||
Status = DriverObject->MajorFunction[param->MajorFunction](DeviceObject,
|
Status = DriverObject->MajorFunction[param->MajorFunction](DeviceObject,
|
||||||
Irp);
|
Irp);
|
||||||
return Status;
|
return Status;
|
||||||
|
|
|
@ -31,6 +31,11 @@ NTSTATUS IoPageRead(PFILE_OBJECT FileObject,
|
||||||
DPRINT("IoPageRead(FileObject %x, Address %x)\n",
|
DPRINT("IoPageRead(FileObject %x, Address %x)\n",
|
||||||
FileObject,Address);
|
FileObject,Address);
|
||||||
|
|
||||||
|
ObReferenceObjectByPointer(FileObject,
|
||||||
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
|
IoFileType,
|
||||||
|
UserMode);
|
||||||
|
|
||||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
||||||
FileObject->DeviceObject,
|
FileObject->DeviceObject,
|
||||||
|
|
|
@ -107,7 +107,6 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||||
return(IoStatusBlock->Status);
|
return(IoStatusBlock->Status);
|
||||||
}
|
}
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,8 +187,6 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle,
|
||||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
}
|
}
|
||||||
ObDereferenceObject(FileObject);
|
|
||||||
|
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,40 @@ POBJECT_TYPE IoSymbolicLinkType = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS IopCreateSymbolicLink(PVOID Object,
|
||||||
|
PVOID Parent,
|
||||||
|
PWSTR RemainingPath,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
{
|
||||||
|
if (Parent != NULL && RemainingPath != NULL)
|
||||||
|
{
|
||||||
|
ObAddEntryDirectory(Parent, Object, RemainingPath+1);
|
||||||
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID IopParseSymbolicLink(PVOID Object,
|
||||||
|
PWSTR* RemainingPath)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PSYMLNK_OBJECT SymlinkObject = (PSYMLNK_OBJECT)Object;
|
||||||
|
PVOID ReturnedObject;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByName(SymlinkObject->Target.ObjectName,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
NULL,
|
||||||
|
&ReturnedObject);
|
||||||
|
if (NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(ReturnedObject);
|
||||||
|
}
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
VOID IoInitSymbolicLinkImplementation(VOID)
|
VOID IoInitSymbolicLinkImplementation(VOID)
|
||||||
{
|
{
|
||||||
ANSI_STRING AnsiString;
|
ANSI_STRING AnsiString;
|
||||||
|
@ -46,10 +80,11 @@ VOID IoInitSymbolicLinkImplementation(VOID)
|
||||||
IoSymbolicLinkType->Open = NULL;
|
IoSymbolicLinkType->Open = NULL;
|
||||||
IoSymbolicLinkType->Close = NULL;
|
IoSymbolicLinkType->Close = NULL;
|
||||||
IoSymbolicLinkType->Delete = NULL;
|
IoSymbolicLinkType->Delete = NULL;
|
||||||
IoSymbolicLinkType->Parse = NULL;
|
IoSymbolicLinkType->Parse = IopParseSymbolicLink;
|
||||||
IoSymbolicLinkType->Security = NULL;
|
IoSymbolicLinkType->Security = NULL;
|
||||||
IoSymbolicLinkType->QueryName = NULL;
|
IoSymbolicLinkType->QueryName = NULL;
|
||||||
IoSymbolicLinkType->OkayToClose = NULL;
|
IoSymbolicLinkType->OkayToClose = NULL;
|
||||||
|
IoSymbolicLinkType->Create = IopCreateSymbolicLink;
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiString,"Symbolic Link");
|
RtlInitAnsiString(&AnsiString,"Symbolic Link");
|
||||||
RtlAnsiStringToUnicodeString(&IoSymbolicLinkType->TypeName,
|
RtlAnsiStringToUnicodeString(&IoSymbolicLinkType->TypeName,
|
||||||
|
@ -72,9 +107,15 @@ NTSTATUS ZwOpenSymbolicLinkObject(OUT PHANDLE LinkHandle,
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PVOID Object;
|
PVOID Object;
|
||||||
PWSTR Ignored;
|
|
||||||
|
|
||||||
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Ignored);
|
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
|
||||||
|
ObjectAttributes->Attributes,
|
||||||
|
NULL,
|
||||||
|
DesiredAccess,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
NULL,
|
||||||
|
&Object);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
|
@ -117,21 +158,6 @@ NTSTATUS ZwQuerySymbolicLinkObject(IN HANDLE LinkHandle,
|
||||||
return(STATUS_SUCCESS);
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
||||||
PUNICODE_STRING DeviceName)
|
PUNICODE_STRING DeviceName)
|
||||||
{
|
{
|
||||||
|
@ -150,10 +176,10 @@ NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
||||||
SymbolicLinkName->Buffer,DeviceName->Buffer);
|
SymbolicLinkName->Buffer,DeviceName->Buffer);
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,SymbolicLinkName,0,NULL,NULL);
|
InitializeObjectAttributes(&ObjectAttributes,SymbolicLinkName,0,NULL,NULL);
|
||||||
SymbolicLink = ObGenericCreateObject(&SymbolicLinkHandle,
|
SymbolicLink = ObCreateObject(&SymbolicLinkHandle,
|
||||||
SYMBOLIC_LINK_ALL_ACCESS,
|
SYMBOLIC_LINK_ALL_ACCESS,
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
IoSymbolicLinkType);
|
IoSymbolicLinkType);
|
||||||
if (SymbolicLink == NULL)
|
if (SymbolicLink == NULL)
|
||||||
{
|
{
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
@ -163,7 +189,7 @@ NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
||||||
SymbolicLink->TargetName.MaximumLength =
|
SymbolicLink->TargetName.MaximumLength =
|
||||||
((wstrlen(DeviceName->Buffer) + 1) * sizeof(WCHAR));
|
((wstrlen(DeviceName->Buffer) + 1) * sizeof(WCHAR));
|
||||||
SymbolicLink->TargetName.Buffer = ExAllocatePool(NonPagedPool,
|
SymbolicLink->TargetName.Buffer = ExAllocatePool(NonPagedPool,
|
||||||
SymbolicLink->TargetName.MaximumLength);
|
SymbolicLink->TargetName.MaximumLength);
|
||||||
RtlCopyUnicodeString(&(SymbolicLink->TargetName), DeviceName);
|
RtlCopyUnicodeString(&(SymbolicLink->TargetName), DeviceName);
|
||||||
DPRINT("DeviceName %w\n", SymbolicLink->TargetName.Buffer);
|
DPRINT("DeviceName %w\n", SymbolicLink->TargetName.Buffer);
|
||||||
InitializeObjectAttributes(&(SymbolicLink->Target),
|
InitializeObjectAttributes(&(SymbolicLink->Target),
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
VOID ExRaiseStatus(NTSTATUS Status)
|
VOID ExRaiseStatus(NTSTATUS Status)
|
||||||
{
|
{
|
||||||
DbgPrint("ExRaiseStatus(%d)\n",Status);
|
DbgPrint("ExRaiseStatus(%x)\n",Status);
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
#include <internal/kernel.h>
|
#include <internal/ntoskrnl.h>
|
||||||
#include <internal/linkage.h>
|
#include <internal/linkage.h>
|
||||||
#include <internal/module.h>
|
#include <internal/module.h>
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
|
@ -957,10 +957,10 @@ LdrLoadImage(HANDLE ProcessHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build a module structure for the image */
|
/* Build a module structure for the image */
|
||||||
Module = ObGenericCreateObject(ModuleHandle,
|
Module = ObCreateObject(ModuleHandle,
|
||||||
PROCESS_ALL_ACCESS,
|
PROCESS_ALL_ACCESS,
|
||||||
NULL,
|
NULL,
|
||||||
ObModuleType);
|
ObModuleType);
|
||||||
if (Module == NULL)
|
if (Module == NULL)
|
||||||
{
|
{
|
||||||
ZwClose(FileHandle);
|
ZwClose(FileHandle);
|
||||||
|
|
|
@ -7,7 +7,7 @@ include hal/x86/sources
|
||||||
|
|
||||||
NT_OBJECTS = nt/port.o nt/channel.o nt/ntevent.o nt/nttimer.o nt/atom.o \
|
NT_OBJECTS = nt/port.o nt/channel.o nt/ntevent.o nt/nttimer.o nt/atom.o \
|
||||||
nt/evtpair.o nt/ntsem.o nt/mutant.o nt/misc.o nt/plugplay.o \
|
nt/evtpair.o nt/ntsem.o nt/mutant.o nt/misc.o nt/plugplay.o \
|
||||||
nt/profile.o
|
nt/profile.o nt/nt.o
|
||||||
|
|
||||||
RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \
|
RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \
|
||||||
rtl/time.o rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \
|
rtl/time.o rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \
|
||||||
|
@ -32,7 +32,7 @@ IO_OBJECTS = io/iomgr.o io/create.o io/irp.o io/device.o io/rw.o \
|
||||||
io/fs.o io/vpb.o io/buildirp.o io/flush.o io/dir.o io/iocomp.o \
|
io/fs.o io/vpb.o io/buildirp.o io/flush.o io/dir.o io/iocomp.o \
|
||||||
io/mailslot.o io/npipe.o io/lock.o io/page.o io/cleanup.o
|
io/mailslot.o io/npipe.o io/lock.o io/page.o io/cleanup.o
|
||||||
|
|
||||||
OB_OBJECTS = ob/object.o ob/handle.o ob/namespc.o
|
OB_OBJECTS = ob/object.o ob/handle.o ob/namespc.o ob/ntobj.o ob/dirobj.o
|
||||||
|
|
||||||
PS_OBJECTS = ps/psmgr.o ps/thread.o ps/process.o ps/idle.o ps/kill.o \
|
PS_OBJECTS = ps/psmgr.o ps/thread.o ps/process.o ps/idle.o ps/kill.o \
|
||||||
ps/tinfo.o
|
ps/tinfo.o
|
||||||
|
@ -45,7 +45,7 @@ SE_OBJECTS = se/semgr.o
|
||||||
|
|
||||||
CM_OBJECTS = cm/registry.o
|
CM_OBJECTS = cm/registry.o
|
||||||
|
|
||||||
TST_OBJECTS = tst/test.o tst/sshell.o tst/readline.o
|
TST_OBJECTS = tst/test.o
|
||||||
|
|
||||||
DBG_OBJECTS = dbg/brkpoint.o dbg/errinfo.o
|
DBG_OBJECTS = dbg/brkpoint.o dbg/errinfo.o
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/mm/cont.c
|
* FILE: ntoskrnl/mm/cont.c
|
||||||
* PURPOSE: Manages continuous memory
|
* PURPOSE: Manages continuous memory
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <internal/kernel.h>
|
|
||||||
#include <internal/linkage.h>
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
|
@ -125,7 +125,7 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
||||||
*/
|
*/
|
||||||
if (marea==NULL )
|
if (marea==NULL )
|
||||||
{
|
{
|
||||||
printk("Area is invalid\n");
|
DbgPrint("(%s:%d) Area is invalid\n",__FILE__,__LINE__);
|
||||||
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/mm/cont.c
|
* FILE: ntoskrnl/mm/cont.c
|
||||||
* PURPOSE: Manages non-cached memory
|
* PURPOSE: Manages non-cached memory
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <internal/kernel.h>
|
|
||||||
#include <internal/linkage.h>
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
|
@ -25,6 +25,44 @@ POBJECT_TYPE MmSectionType = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID MmpDeleteSection(PVOID ObjectBody)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS MmpCreateSection(PVOID ObjectBody,
|
||||||
|
PVOID Parent,
|
||||||
|
PWSTR RemainingPath)
|
||||||
|
{
|
||||||
|
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)ObjectBody;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("MmpCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
||||||
|
ObjectBody, Parent, RemainingPath);
|
||||||
|
|
||||||
|
if (RemainingPath == NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wcschr(RemainingPath+1, '\\') != NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByPointer(Parent,
|
||||||
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
|
ObDirectoryType,
|
||||||
|
UserMode);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS MmInitSectionImplementation(VOID)
|
NTSTATUS MmInitSectionImplementation(VOID)
|
||||||
{
|
{
|
||||||
ANSI_STRING AnsiString;
|
ANSI_STRING AnsiString;
|
||||||
|
@ -40,11 +78,12 @@ NTSTATUS MmInitSectionImplementation(VOID)
|
||||||
MmSectionType->Dump = NULL;
|
MmSectionType->Dump = NULL;
|
||||||
MmSectionType->Open = NULL;
|
MmSectionType->Open = NULL;
|
||||||
MmSectionType->Close = NULL;
|
MmSectionType->Close = NULL;
|
||||||
MmSectionType->Delete = NULL;
|
MmSectionType->Delete = MmpDeleteSection;
|
||||||
MmSectionType->Parse = NULL;
|
MmSectionType->Parse = NULL;
|
||||||
MmSectionType->Security = NULL;
|
MmSectionType->Security = NULL;
|
||||||
MmSectionType->QueryName = NULL;
|
MmSectionType->QueryName = NULL;
|
||||||
MmSectionType->OkayToClose = NULL;
|
MmSectionType->OkayToClose = NULL;
|
||||||
|
MmSectionType->Create = MmpCreateSection;
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiString,"Section");
|
RtlInitAnsiString(&AnsiString,"Section");
|
||||||
RtlAnsiStringToUnicodeString(&MmSectionType->TypeName,
|
RtlAnsiStringToUnicodeString(&MmSectionType->TypeName,
|
||||||
|
@ -106,10 +145,10 @@ NTSTATUS STDCALL ZwCreateSection(OUT PHANDLE SectionHandle,
|
||||||
|
|
||||||
DbgPrint("ZwCreateSection()\n");
|
DbgPrint("ZwCreateSection()\n");
|
||||||
|
|
||||||
Section = ObGenericCreateObject(SectionHandle,
|
Section = ObCreateObject(SectionHandle,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
ObjectAttributes,
|
ObjectAttributes,
|
||||||
MmSectionType);
|
MmSectionType);
|
||||||
|
|
||||||
if (MaximumSize != NULL)
|
if (MaximumSize != NULL)
|
||||||
{
|
{
|
||||||
|
@ -120,20 +159,27 @@ NTSTATUS STDCALL ZwCreateSection(OUT PHANDLE SectionHandle,
|
||||||
LARGE_INTEGER_QUAD_PART(Section->MaximumSize) = 0xffffffff;
|
LARGE_INTEGER_QUAD_PART(Section->MaximumSize) = 0xffffffff;
|
||||||
}
|
}
|
||||||
Section->SectionPageProtection = SectionPageProtection;
|
Section->SectionPageProtection = SectionPageProtection;
|
||||||
Status = ObReferenceObjectByHandle(FileHandle,
|
|
||||||
FILE_READ_DATA,
|
|
||||||
IoFileType,
|
|
||||||
UserMode,
|
|
||||||
(PVOID*)&Section->FileObject,
|
|
||||||
NULL);
|
|
||||||
if (Status != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
DPRINT("ZwCreateSection() = %x\n",Status);
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
Section->AllocateAttributes = AllocationAttributes;
|
Section->AllocateAttributes = AllocationAttributes;
|
||||||
|
|
||||||
|
if (FileHandle != NULL)
|
||||||
|
{
|
||||||
|
Status = ObReferenceObjectByHandle(FileHandle,
|
||||||
|
FILE_READ_DATA,
|
||||||
|
IoFileType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&Section->FileObject,
|
||||||
|
NULL);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
DPRINT("ZwCreateSection() = %x\n",Status);
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Section->FileObject = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINT("ZwCreateSection() = STATUS_SUCCESS\n");
|
DPRINT("ZwCreateSection() = STATUS_SUCCESS\n");
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -153,23 +199,26 @@ NTSTATUS ZwOpenSection(PHANDLE SectionHandle,
|
||||||
{
|
{
|
||||||
PVOID Object;
|
PVOID Object;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PWSTR Ignored;
|
|
||||||
|
|
||||||
*SectionHandle = 0;
|
*SectionHandle = 0;
|
||||||
|
|
||||||
Status = ObOpenObjectByName(ObjectAttributes,&Object,&Ignored);
|
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
|
||||||
|
ObjectAttributes->Attributes,
|
||||||
|
NULL,
|
||||||
|
DesiredAccess,
|
||||||
|
MmSectionType,
|
||||||
|
UserMode,
|
||||||
|
NULL,
|
||||||
|
&Object);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BODY_TO_HEADER(Object)->ObjectType!=MmSectionType)
|
*SectionHandle = ObInsertHandle(KeGetCurrentProcess(),
|
||||||
{
|
Object,
|
||||||
return(STATUS_UNSUCCESSFUL);
|
DesiredAccess,
|
||||||
}
|
FALSE);
|
||||||
|
|
||||||
*SectionHandle = ObInsertHandle(KeGetCurrentProcess(),Object,
|
|
||||||
DesiredAccess,FALSE);
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
22
reactos/ntoskrnl/nt/nt.c
Normal file
22
reactos/ntoskrnl/nt/nt.c
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/nt/nt.c
|
||||||
|
* PURPOSE: Initialization of system call interfaces
|
||||||
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* Created 22/05/98
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID NtInit(VOID)
|
||||||
|
{
|
||||||
|
NtInitializeEventImplementation();
|
||||||
|
}
|
|
@ -92,10 +92,10 @@ NTSTATUS STDCALL ZwCreateEvent(OUT PHANDLE EventHandle,
|
||||||
{
|
{
|
||||||
PKEVENT Event;
|
PKEVENT Event;
|
||||||
|
|
||||||
Event = ObGenericCreateObject(EventHandle,
|
Event = ObCreateObject(EventHandle,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
ObjectAttributes,
|
ObjectAttributes,
|
||||||
ExEventType);
|
ExEventType);
|
||||||
if (ManualReset == TRUE)
|
if (ManualReset == TRUE)
|
||||||
{
|
{
|
||||||
KeInitializeEvent(Event,NotificationEvent,InitialState);
|
KeInitializeEvent(Event,NotificationEvent,InitialState);
|
||||||
|
@ -121,9 +121,16 @@ NTSTATUS STDCALL ZwOpenEvent(OUT PHANDLE EventHandle,
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKEVENT Event;
|
PKEVENT Event;
|
||||||
PWSTR Ignored;
|
|
||||||
|
|
||||||
Status = ObOpenObjectByName(ObjectAttributes,(PVOID*)Event,&Ignored);
|
|
||||||
|
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
|
||||||
|
ObjectAttributes->Attributes,
|
||||||
|
NULL,
|
||||||
|
DesiredAccess,
|
||||||
|
ExEventType,
|
||||||
|
UserMode,
|
||||||
|
NULL,
|
||||||
|
(PVOID*)&Event);
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/nt/port.c
|
* FILE: ntoskrnl/nt/port.c
|
||||||
* PURPOSE: Communication mechanism (like Mach?)
|
* PURPOSE: Communication mechanism (like Mach?)
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
|
267
reactos/ntoskrnl/ob/dirobj.c
Normal file
267
reactos/ntoskrnl/ob/dirobj.c
Normal file
|
@ -0,0 +1,267 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/ob/dirobj.c
|
||||||
|
* PURPOSE: Interface functions to directory object
|
||||||
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* 22/05/98: Created
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ***************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/ob.h>
|
||||||
|
#include <internal/io.h>
|
||||||
|
#include <internal/string.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
|
||||||
|
/* FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS NtOpenDirectoryObject(PHANDLE DirectoryHandle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
{
|
||||||
|
return(ZwOpenDirectoryObject(DirectoryHandle,
|
||||||
|
DesiredAccess,
|
||||||
|
ObjectAttributes));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS ZwOpenDirectoryObject(PHANDLE DirectoryHandle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Opens a namespace directory object
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DirectoryHandle (OUT) = Variable which receives the directory handle
|
||||||
|
* DesiredAccess = Desired access to the directory
|
||||||
|
* ObjectAttributes = Structure describing the directory
|
||||||
|
* RETURNS: Status
|
||||||
|
* NOTES: Undocumented
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PVOID Object;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
*DirectoryHandle = 0;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
|
||||||
|
ObjectAttributes->Attributes,
|
||||||
|
NULL,
|
||||||
|
DesiredAccess,
|
||||||
|
ObDirectoryType,
|
||||||
|
UserMode,
|
||||||
|
NULL,
|
||||||
|
&Object);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
*DirectoryHandle = ObInsertHandle(KeGetCurrentProcess(),Object,
|
||||||
|
DesiredAccess,FALSE);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS NtQueryDirectoryObject(IN HANDLE DirObjHandle,
|
||||||
|
OUT POBJDIR_INFORMATION DirObjInformation,
|
||||||
|
IN ULONG BufferLength,
|
||||||
|
IN BOOLEAN GetNextIndex,
|
||||||
|
IN BOOLEAN IgnoreInputIndex,
|
||||||
|
IN OUT PULONG ObjectIndex,
|
||||||
|
OUT PULONG DataWritten OPTIONAL)
|
||||||
|
{
|
||||||
|
return(ZwQueryDirectoryObject(DirObjHandle,
|
||||||
|
DirObjInformation,
|
||||||
|
BufferLength,
|
||||||
|
GetNextIndex,
|
||||||
|
IgnoreInputIndex,
|
||||||
|
ObjectIndex,
|
||||||
|
DataWritten));
|
||||||
|
}
|
||||||
|
|
||||||
|
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: Reads information from a namespace directory
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DirObjInformation (OUT) = Buffer to hold the data read
|
||||||
|
* BufferLength = Size of the buffer in bytes
|
||||||
|
* GetNextIndex = If TRUE then set ObjectIndex to the index of the
|
||||||
|
* next object
|
||||||
|
* If FALSE then set ObjectIndex to the number of
|
||||||
|
* objects in the directory
|
||||||
|
* IgnoreInputIndex = If TRUE start reading at index 0
|
||||||
|
* If FALSE start reading at the index specified
|
||||||
|
* by object index
|
||||||
|
* ObjectIndex = Zero based index into the directory, interpretation
|
||||||
|
* depends on IgnoreInputIndex and GetNextIndex
|
||||||
|
* DataWritten (OUT) = Caller supplied storage for the number of bytes
|
||||||
|
* written (or NULL)
|
||||||
|
* RETURNS: Status
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PDIRECTORY_OBJECT dir = NULL;
|
||||||
|
ULONG EntriesToRead;
|
||||||
|
PLIST_ENTRY current_entry;
|
||||||
|
POBJECT_HEADER current;
|
||||||
|
ULONG i=0;
|
||||||
|
ULONG EntriesToSkip;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("ZwQueryDirectoryObject(DirObjHandle %x)\n",DirObjHandle);
|
||||||
|
DPRINT("dir %x namespc_root %x\n",dir,HEADER_TO_BODY(&(namespc_root.hdr)));
|
||||||
|
|
||||||
|
// assert_irql(PASSIVE_LEVEL);
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(DirObjHandle,
|
||||||
|
DIRECTORY_QUERY,
|
||||||
|
ObDirectoryType,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&dir,
|
||||||
|
NULL);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
EntriesToRead = BufferLength / sizeof(OBJDIR_INFORMATION);
|
||||||
|
*DataWritten = 0;
|
||||||
|
|
||||||
|
DPRINT("EntriesToRead %d\n",EntriesToRead);
|
||||||
|
|
||||||
|
current_entry = dir->head.Flink;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Optionally, skip over some entries at the start of the directory
|
||||||
|
*/
|
||||||
|
if (!IgnoreInputIndex)
|
||||||
|
{
|
||||||
|
CHECKPOINT;
|
||||||
|
|
||||||
|
EntriesToSkip = *ObjectIndex;
|
||||||
|
while ( i<EntriesToSkip && current_entry!=NULL)
|
||||||
|
{
|
||||||
|
current_entry = current_entry->Flink;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("DirObjInformation %x\n",DirObjInformation);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Read the maximum entries possible into the buffer
|
||||||
|
*/
|
||||||
|
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+1)*2);
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
*ObjectIndex=i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while ( current_entry!=(&(dir->head)) )
|
||||||
|
{
|
||||||
|
current_entry=current_entry->Flink;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
*ObjectIndex=i;
|
||||||
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS NtCreateDirectoryObject(PHANDLE DirectoryHandle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
{
|
||||||
|
return(ZwCreateDirectoryObject(DirectoryHandle,
|
||||||
|
DesiredAccess,
|
||||||
|
ObjectAttributes));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS ZwCreateDirectoryObject(PHANDLE DirectoryHandle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Creates or opens a directory object (a container for other
|
||||||
|
* objects)
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DirectoryHandle (OUT) = Caller supplied storage for the handle
|
||||||
|
* of the directory
|
||||||
|
* DesiredAccess = Access desired to the directory
|
||||||
|
* ObjectAttributes = Object attributes initialized with
|
||||||
|
* InitializeObjectAttributes
|
||||||
|
* RETURNS: Status
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PDIRECTORY_OBJECT dir;
|
||||||
|
|
||||||
|
dir = ObCreateObject(DirectoryHandle,
|
||||||
|
DesiredAccess,
|
||||||
|
ObjectAttributes,
|
||||||
|
ObDirectoryType);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
|
||||||
|
PUNICODE_STRING ObjectName,
|
||||||
|
ULONG Attributes,
|
||||||
|
HANDLE RootDirectory,
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a
|
||||||
|
* subsequent call to ZwCreateXXX or ZwOpenXXX
|
||||||
|
* ARGUMENTS:
|
||||||
|
* InitializedAttributes (OUT) = Caller supplied storage for the
|
||||||
|
* object attributes
|
||||||
|
* ObjectName = Full path name for object
|
||||||
|
* Attributes = Attributes for the object
|
||||||
|
* RootDirectory = Where the object should be placed or NULL
|
||||||
|
* SecurityDescriptor = Ignored
|
||||||
|
*
|
||||||
|
* NOTE:
|
||||||
|
* Either ObjectName is a fully qualified pathname or a path relative
|
||||||
|
* to RootDirectory
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
DPRINT("InitializeObjectAttributes(InitializedAttributes %x "
|
||||||
|
"ObjectName %x Attributes %x RootDirectory %x)\n",
|
||||||
|
InitializedAttributes,ObjectName,Attributes,RootDirectory);
|
||||||
|
InitializedAttributes->Length=sizeof(OBJECT_ATTRIBUTES);
|
||||||
|
InitializedAttributes->RootDirectory=RootDirectory;
|
||||||
|
InitializedAttributes->ObjectName=ObjectName;
|
||||||
|
InitializedAttributes->Attributes=Attributes;
|
||||||
|
InitializedAttributes->SecurityDescriptor=SecurityDescriptor;
|
||||||
|
InitializedAttributes->SecurityQualityOfService=NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -215,8 +215,10 @@ VOID ObDeleteHandle(HANDLE Handle)
|
||||||
DPRINT("Finished ObDeleteHandle()\n");
|
DPRINT("Finished ObDeleteHandle()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
HANDLE ObInsertHandle(PKPROCESS Process, PVOID ObjectBody,
|
HANDLE ObInsertHandle(PKPROCESS Process,
|
||||||
ACCESS_MASK GrantedAccess, BOOLEAN Inherit)
|
PVOID ObjectBody,
|
||||||
|
ACCESS_MASK GrantedAccess,
|
||||||
|
BOOLEAN Inherit)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Add a handle referencing an object
|
* FUNCTION: Add a handle referencing an object
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
|
|
@ -24,193 +24,10 @@
|
||||||
|
|
||||||
POBJECT_TYPE ObDirectoryType = NULL;
|
POBJECT_TYPE ObDirectoryType = NULL;
|
||||||
|
|
||||||
static struct
|
PDIRECTORY_OBJECT NameSpaceRoot = NULL;
|
||||||
{
|
|
||||||
OBJECT_HEADER hdr;
|
|
||||||
// DIRECTORY_OBJECT directory;
|
|
||||||
LIST_ENTRY head;
|
|
||||||
KSPIN_LOCK Lock;
|
|
||||||
} namespc_root = {{0,},};
|
|
||||||
|
|
||||||
/* FUNCTIONS **************************************************************/
|
/* FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
NTSTATUS NtOpenDirectoryObject(PHANDLE DirectoryHandle,
|
|
||||||
ACCESS_MASK DesiredAccess,
|
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
|
||||||
{
|
|
||||||
return(ZwOpenDirectoryObject(DirectoryHandle,
|
|
||||||
DesiredAccess,
|
|
||||||
ObjectAttributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS ZwOpenDirectoryObject(PHANDLE DirectoryHandle,
|
|
||||||
ACCESS_MASK DesiredAccess,
|
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Opens a namespace directory object
|
|
||||||
* ARGUMENTS:
|
|
||||||
* DirectoryHandle (OUT) = Variable which receives the directory handle
|
|
||||||
* DesiredAccess = Desired access to the directory
|
|
||||||
* ObjectAttributes = Structure describing the directory
|
|
||||||
* RETURNS: Status
|
|
||||||
* NOTES: Undocumented
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PVOID Object;
|
|
||||||
NTSTATUS Status;
|
|
||||||
PWSTR Ignored;
|
|
||||||
|
|
||||||
*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 = ObInsertHandle(KeGetCurrentProcess(),Object,
|
|
||||||
DesiredAccess,FALSE);
|
|
||||||
CHECKPOINT;
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NtQueryDirectoryObject(IN HANDLE DirObjHandle,
|
|
||||||
OUT POBJDIR_INFORMATION DirObjInformation,
|
|
||||||
IN ULONG BufferLength,
|
|
||||||
IN BOOLEAN GetNextIndex,
|
|
||||||
IN BOOLEAN IgnoreInputIndex,
|
|
||||||
IN OUT PULONG ObjectIndex,
|
|
||||||
OUT PULONG DataWritten OPTIONAL)
|
|
||||||
{
|
|
||||||
return(ZwQueryDirectoryObject(DirObjHandle,
|
|
||||||
DirObjInformation,
|
|
||||||
BufferLength,
|
|
||||||
GetNextIndex,
|
|
||||||
IgnoreInputIndex,
|
|
||||||
ObjectIndex,
|
|
||||||
DataWritten));
|
|
||||||
}
|
|
||||||
|
|
||||||
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: Reads information from a namespace directory
|
|
||||||
* ARGUMENTS:
|
|
||||||
* DirObjInformation (OUT) = Buffer to hold the data read
|
|
||||||
* BufferLength = Size of the buffer in bytes
|
|
||||||
* GetNextIndex = If TRUE then set ObjectIndex to the index of the
|
|
||||||
* next object
|
|
||||||
* If FALSE then set ObjectIndex to the number of
|
|
||||||
* objects in the directory
|
|
||||||
* IgnoreInputIndex = If TRUE start reading at index 0
|
|
||||||
* If FALSE start reading at the index specified
|
|
||||||
* by object index
|
|
||||||
* ObjectIndex = Zero based index into the directory, interpretation
|
|
||||||
* depends on IgnoreInputIndex and GetNextIndex
|
|
||||||
* DataWritten (OUT) = Caller supplied storage for the number of bytes
|
|
||||||
* written (or NULL)
|
|
||||||
* RETURNS: Status
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PDIRECTORY_OBJECT dir = NULL;
|
|
||||||
ULONG EntriesToRead;
|
|
||||||
PLIST_ENTRY current_entry;
|
|
||||||
POBJECT_HEADER current;
|
|
||||||
ULONG i=0;
|
|
||||||
ULONG EntriesToSkip;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT("ZwQueryDirectoryObject(DirObjHandle %x)\n",DirObjHandle);
|
|
||||||
DPRINT("dir %x namespc_root %x\n",dir,HEADER_TO_BODY(&(namespc_root.hdr)));
|
|
||||||
|
|
||||||
// assert_irql(PASSIVE_LEVEL);
|
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(DirObjHandle,
|
|
||||||
DIRECTORY_QUERY,
|
|
||||||
ObDirectoryType,
|
|
||||||
UserMode,
|
|
||||||
(PVOID*)&dir,
|
|
||||||
NULL);
|
|
||||||
if (Status != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
EntriesToRead = BufferLength / sizeof(OBJDIR_INFORMATION);
|
|
||||||
*DataWritten = 0;
|
|
||||||
|
|
||||||
DPRINT("EntriesToRead %d\n",EntriesToRead);
|
|
||||||
|
|
||||||
current_entry = dir->head.Flink;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Optionally, skip over some entries at the start of the directory
|
|
||||||
*/
|
|
||||||
if (!IgnoreInputIndex)
|
|
||||||
{
|
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
EntriesToSkip = *ObjectIndex;
|
|
||||||
while ( i<EntriesToSkip && current_entry!=NULL)
|
|
||||||
{
|
|
||||||
current_entry = current_entry->Flink;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("DirObjInformation %x\n",DirObjInformation);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Read the maximum entries possible into the buffer
|
|
||||||
*/
|
|
||||||
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+1)*2);
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
*ObjectIndex=i;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while ( current_entry!=(&(dir->head)) )
|
|
||||||
{
|
|
||||||
current_entry=current_entry->Flink;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
*ObjectIndex=i;
|
|
||||||
}
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
NTSTATUS ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||||
ULONG Attributes,
|
ULONG Attributes,
|
||||||
PACCESS_STATE PassedAccessState,
|
PACCESS_STATE PassedAccessState,
|
||||||
|
@ -220,34 +37,173 @@ NTSTATUS ObReferenceObjectByName(PUNICODE_STRING ObjectPath,
|
||||||
PVOID ParseContext,
|
PVOID ParseContext,
|
||||||
PVOID* ObjectPtr)
|
PVOID* ObjectPtr)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PVOID Object;
|
||||||
|
PWSTR RemainingPath;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
ObjectPath,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
ObFindObject(&ObjectAttributes,
|
||||||
|
&Object,
|
||||||
|
&RemainingPath);
|
||||||
|
|
||||||
|
if (RemainingPath != NULL ||
|
||||||
|
Object == NULL)
|
||||||
|
{
|
||||||
|
*ObjectPtr = NULL;
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
*ObjectPtr = Object;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
|
VOID ObAddEntryDirectory(PDIRECTORY_OBJECT Parent,
|
||||||
PVOID* Object, PWSTR* UnparsedSection)
|
POBJECT Object,
|
||||||
|
PWSTR Name)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Add an entry to a namespace directory
|
||||||
|
* ARGUMENTS:
|
||||||
|
* parent = directory to add in
|
||||||
|
* name = Name to give the entry
|
||||||
|
* Object = Header of the object to add the entry for
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
|
KIRQL oldlvl;
|
||||||
|
POBJECT_HEADER Header = BODY_TO_HEADER(Object);
|
||||||
|
|
||||||
|
RtlInitUnicodeString(&Header->Name, wstrdup(Name));
|
||||||
|
Header->Parent = Parent;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&Parent->Lock, &oldlvl);
|
||||||
|
InsertTailList(&Parent->head, &Header->Entry);
|
||||||
|
KeReleaseSpinLock(&Parent->Lock, oldlvl);
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID ObpFindEntryDirectory(PDIRECTORY_OBJECT DirectoryObject,
|
||||||
|
PWSTR Name,
|
||||||
|
ULONG Attributes)
|
||||||
|
{
|
||||||
|
PLIST_ENTRY current = DirectoryObject->head.Flink;
|
||||||
|
POBJECT_HEADER current_obj;
|
||||||
|
|
||||||
|
DPRINT("ObDirLookup(dir %x, name %w)\n",DirectoryObject, Name);
|
||||||
|
|
||||||
|
if (Name[0]==0)
|
||||||
|
{
|
||||||
|
return(DirectoryObject);
|
||||||
|
}
|
||||||
|
if (Name[0]=='.' && Name[1]==0)
|
||||||
|
{
|
||||||
|
return(DirectoryObject);
|
||||||
|
}
|
||||||
|
if (Name[0]=='.' && Name[1]=='.' && Name[2]==0)
|
||||||
|
{
|
||||||
|
return(BODY_TO_HEADER(DirectoryObject)->Parent);
|
||||||
|
}
|
||||||
|
while (current!=(&(DirectoryObject->head)))
|
||||||
|
{
|
||||||
|
current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,Entry);
|
||||||
|
DPRINT("Scanning %w %w\n",current_obj->Name.Buffer, Name);
|
||||||
|
if (Attributes & OBJ_CASE_INSENSITIVE)
|
||||||
|
{
|
||||||
|
if (wcsicmp(current_obj->Name.Buffer, Name)==0)
|
||||||
|
{
|
||||||
|
DPRINT("Found it %x\n",HEADER_TO_BODY(current_obj));
|
||||||
|
return(HEADER_TO_BODY(current_obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( wcscmp(current_obj->Name.Buffer, Name)==0)
|
||||||
|
{
|
||||||
|
DPRINT("Found it %x\n",HEADER_TO_BODY(current_obj));
|
||||||
|
return(HEADER_TO_BODY(current_obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
current = current->Flink;
|
||||||
|
}
|
||||||
|
DPRINT("%s() = NULL\n",__FUNCTION__);
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID ObpParseDirectory(PVOID Object, PWSTR* Path)
|
||||||
|
{
|
||||||
|
PWSTR end;
|
||||||
|
PVOID FoundObject;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("ObOpenObjectByName(ObjectAttributes %x, Object %x)\n",
|
DPRINT("ObpParseDirectory(Object %x, Path %x, *Path %w)\n",
|
||||||
ObjectAttributes,Object);
|
Object,Path,*Path);
|
||||||
DPRINT("ObjectAttributes = {ObjectName %x ObjectName->Buffer %w}\n",
|
|
||||||
ObjectAttributes->ObjectName,ObjectAttributes->ObjectName->Buffer);
|
|
||||||
DPRINT("ObjectAttributes->ObjectName->Length %d\n",
|
|
||||||
ObjectAttributes->ObjectName->Length);
|
|
||||||
|
|
||||||
*Object = NULL;
|
if ((*Path) == NULL)
|
||||||
Status = ObLookupObject(ObjectAttributes->RootDirectory,
|
{
|
||||||
ObjectAttributes->ObjectName->Buffer,
|
return(NULL);
|
||||||
Object,
|
}
|
||||||
UnparsedSection,
|
|
||||||
ObjectAttributes->Attributes);
|
end = wcschr((*Path)+1, '\\');
|
||||||
DPRINT("*Object %x\n",*Object);
|
if (end != NULL)
|
||||||
DPRINT("ObjectAttributes->ObjectName->Length %d\n",
|
{
|
||||||
ObjectAttributes->ObjectName->Length);
|
*end = 0;
|
||||||
return(Status);
|
}
|
||||||
|
|
||||||
|
FoundObject = ObpFindEntryDirectory(Object, (*Path)+1, 0);
|
||||||
|
|
||||||
|
if (FoundObject == NULL)
|
||||||
|
{
|
||||||
|
if (end != NULL)
|
||||||
|
{
|
||||||
|
*end = '\\';
|
||||||
|
}
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObReferenceObjectByPointer(FoundObject,
|
||||||
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
|
NULL,
|
||||||
|
UserMode);
|
||||||
|
|
||||||
|
if (end != NULL)
|
||||||
|
{
|
||||||
|
*end = '\\';
|
||||||
|
*Path = end;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*Path = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(FoundObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ObInit(void)
|
NTSTATUS ObpCreateDirectory(PVOID ObjectBody,
|
||||||
|
PVOID Parent,
|
||||||
|
PWSTR RemainingPath,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
{
|
||||||
|
PDIRECTORY_OBJECT DirectoryObject = (PDIRECTORY_OBJECT)ObjectBody;
|
||||||
|
|
||||||
|
DPRINT("ObpCreateDirectory(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
||||||
|
ObjectBody, Parent, RemainingPath);
|
||||||
|
|
||||||
|
if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Parent != NULL && RemainingPath != NULL)
|
||||||
|
{
|
||||||
|
ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1);
|
||||||
|
}
|
||||||
|
InitializeListHead(&DirectoryObject->head);
|
||||||
|
KeInitializeSpinLock(&DirectoryObject->Lock);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID ObInit(VOID)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Initialize the object manager namespace
|
* FUNCTION: Initialize the object manager namespace
|
||||||
*/
|
*/
|
||||||
|
@ -266,141 +222,20 @@ void ObInit(void)
|
||||||
ObDirectoryType->Open = NULL;
|
ObDirectoryType->Open = NULL;
|
||||||
ObDirectoryType->Close = NULL;
|
ObDirectoryType->Close = NULL;
|
||||||
ObDirectoryType->Delete = NULL;
|
ObDirectoryType->Delete = NULL;
|
||||||
ObDirectoryType->Parse = NULL;
|
ObDirectoryType->Parse = ObpParseDirectory;
|
||||||
ObDirectoryType->Security = NULL;
|
ObDirectoryType->Security = NULL;
|
||||||
ObDirectoryType->QueryName = NULL;
|
ObDirectoryType->QueryName = NULL;
|
||||||
ObDirectoryType->OkayToClose = NULL;
|
ObDirectoryType->OkayToClose = NULL;
|
||||||
|
ObDirectoryType->Create = ObpCreateDirectory;
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiString,"Directory");
|
RtlInitAnsiString(&AnsiString,"Directory");
|
||||||
RtlAnsiStringToUnicodeString(&ObDirectoryType->TypeName,
|
RtlAnsiStringToUnicodeString(&ObDirectoryType->TypeName,
|
||||||
&AnsiString,TRUE);
|
&AnsiString,TRUE);
|
||||||
|
|
||||||
ObInitializeObjectHeader(ObDirectoryType,NULL,&namespc_root.hdr);
|
NameSpaceRoot = ObCreateObject(NULL,
|
||||||
InitializeListHead(&namespc_root.head);
|
STANDARD_RIGHTS_REQUIRED,
|
||||||
}
|
NULL,
|
||||||
|
ObDirectoryType);
|
||||||
NTSTATUS NtCreateDirectoryObject(PHANDLE DirectoryHandle,
|
|
||||||
ACCESS_MASK DesiredAccess,
|
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
|
||||||
{
|
|
||||||
return(ZwCreateDirectoryObject(DirectoryHandle,
|
|
||||||
DesiredAccess,
|
|
||||||
ObjectAttributes));
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS ZwCreateDirectoryObject(PHANDLE DirectoryHandle,
|
|
||||||
ACCESS_MASK DesiredAccess,
|
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Creates or opens a directory object (a container for other
|
|
||||||
* objects)
|
|
||||||
* ARGUMENTS:
|
|
||||||
* DirectoryHandle (OUT) = Caller supplied storage for the handle
|
|
||||||
* of the directory
|
|
||||||
* DesiredAccess = Access desired to the directory
|
|
||||||
* ObjectAttributes = Object attributes initialized with
|
|
||||||
* InitializeObjectAttributes
|
|
||||||
* RETURNS: Status
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PDIRECTORY_OBJECT dir;
|
|
||||||
|
|
||||||
dir = ObGenericCreateObject(DirectoryHandle,DesiredAccess,ObjectAttributes,
|
|
||||||
ObDirectoryType);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the object body
|
|
||||||
*/
|
|
||||||
InitializeListHead(&dir->head);
|
|
||||||
KeInitializeSpinLock(&(dir->Lock));
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
|
|
||||||
PUNICODE_STRING ObjectName,
|
|
||||||
ULONG Attributes,
|
|
||||||
HANDLE RootDirectory,
|
|
||||||
PSECURITY_DESCRIPTOR SecurityDescriptor)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Sets up a parameter of type OBJECT_ATTRIBUTES for a
|
|
||||||
* subsequent call to ZwCreateXXX or ZwOpenXXX
|
|
||||||
* ARGUMENTS:
|
|
||||||
* InitializedAttributes (OUT) = Caller supplied storage for the
|
|
||||||
* object attributes
|
|
||||||
* ObjectName = Full path name for object
|
|
||||||
* Attributes = Attributes for the object
|
|
||||||
* RootDirectory = Where the object should be placed or NULL
|
|
||||||
* SecurityDescriptor = Ignored
|
|
||||||
*
|
|
||||||
* NOTE:
|
|
||||||
* Either ObjectName is a fully qualified pathname or a path relative
|
|
||||||
* to RootDirectory
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
DPRINT("InitializeObjectAttributes(InitializedAttributes %x "
|
|
||||||
"ObjectName %x Attributes %x RootDirectory %x)\n",
|
|
||||||
InitializedAttributes,ObjectName,Attributes,RootDirectory);
|
|
||||||
InitializedAttributes->Length=sizeof(OBJECT_ATTRIBUTES);
|
|
||||||
InitializedAttributes->RootDirectory=RootDirectory;
|
|
||||||
InitializedAttributes->ObjectName=ObjectName;
|
|
||||||
InitializedAttributes->Attributes=Attributes;
|
|
||||||
InitializedAttributes->SecurityDescriptor=SecurityDescriptor;
|
|
||||||
InitializedAttributes->SecurityQualityOfService=NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
static PVOID ObDirLookup(PDIRECTORY_OBJECT dir, PWSTR name,
|
|
||||||
ULONG Attributes)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Looks up an entry within a namespace directory
|
|
||||||
* ARGUMENTS:
|
|
||||||
* dir = Directory to lookup in
|
|
||||||
* name = Entry name to find
|
|
||||||
* RETURNS: A pointer to the object body if found
|
|
||||||
* NULL otherwise
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
LIST_ENTRY* current = dir->head.Flink;
|
|
||||||
POBJECT_HEADER current_obj;
|
|
||||||
|
|
||||||
DPRINT("ObDirLookup(dir %x, name %w)\n",dir,name);
|
|
||||||
|
|
||||||
if (name[0]==0)
|
|
||||||
{
|
|
||||||
return(dir);
|
|
||||||
}
|
|
||||||
if (name[0]=='.'&&name[1]==0)
|
|
||||||
{
|
|
||||||
return(dir);
|
|
||||||
}
|
|
||||||
if (name[0]=='.'&&name[1]=='.'&&name[2]==0)
|
|
||||||
{
|
|
||||||
return(BODY_TO_HEADER(dir)->Parent);
|
|
||||||
}
|
|
||||||
while (current!=(&(dir->head)))
|
|
||||||
{
|
|
||||||
current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,Entry);
|
|
||||||
DPRINT("Scanning %w\n",current_obj->Name.Buffer);
|
|
||||||
if (Attributes & OBJ_CASE_INSENSITIVE)
|
|
||||||
{
|
|
||||||
if (wcsicmp(current_obj->Name.Buffer, name)==0)
|
|
||||||
{
|
|
||||||
DPRINT("Found it %x\n",HEADER_TO_BODY(current_obj));
|
|
||||||
return(HEADER_TO_BODY(current_obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( wcscmp(current_obj->Name.Buffer, name)==0)
|
|
||||||
{
|
|
||||||
DPRINT("Found it %x\n",HEADER_TO_BODY(current_obj));
|
|
||||||
return(HEADER_TO_BODY(current_obj));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
current = current->Flink;
|
|
||||||
}
|
|
||||||
DPRINT("%s() = NULL\n",__FUNCTION__);
|
|
||||||
return(NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ObRemoveEntry(POBJECT_HEADER Header)
|
VOID ObRemoveEntry(POBJECT_HEADER Header)
|
||||||
|
@ -414,153 +249,3 @@ VOID ObRemoveEntry(POBJECT_HEADER Header)
|
||||||
KeReleaseSpinLock(&(Header->Parent->Lock),oldlvl);
|
KeReleaseSpinLock(&(Header->Parent->Lock),oldlvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ObCreateEntry(PDIRECTORY_OBJECT parent,POBJECT_HEADER Object)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Add an entry to a namespace directory
|
|
||||||
* ARGUMENTS:
|
|
||||||
* parent = directory to add in
|
|
||||||
* name = Name to give the entry
|
|
||||||
* Object = Header of the object to add the entry for
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
DPRINT("ObjCreateEntry(%x,%x,%x,%w)\n",parent,Object,Object->Name.Buffer,
|
|
||||||
Object->Name.Buffer);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Insert ourselves in our parents list
|
|
||||||
*/
|
|
||||||
InsertTailList(&parent->head,&Object->Entry);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS ObLookupObject(HANDLE rootdir,
|
|
||||||
PWSTR string,
|
|
||||||
PVOID* Object,
|
|
||||||
PWSTR* UnparsedSection,
|
|
||||||
ULONG Attributes)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Lookup an object within the system namespc
|
|
||||||
* ARGUMENTS:
|
|
||||||
* root = Directory to start lookup from
|
|
||||||
* _string = Pathname to lookup
|
|
||||||
* RETURNS: On success a pointer to the object body
|
|
||||||
* On failure NULL
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PWSTR current;
|
|
||||||
PWSTR next;
|
|
||||||
PDIRECTORY_OBJECT current_dir = NULL;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT("ObLookupObject(rootdir %x, string %x, string %w, Object %x, "
|
|
||||||
"UnparsedSection %x)\n",rootdir,string,string,Object,
|
|
||||||
UnparsedSection);
|
|
||||||
*UnparsedSection = NULL;
|
|
||||||
*Object = NULL;
|
|
||||||
|
|
||||||
if (rootdir == NULL)
|
|
||||||
{
|
|
||||||
current_dir = HEADER_TO_BODY(&(namespc_root.hdr));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ObReferenceObjectByHandle(rootdir,
|
|
||||||
DIRECTORY_TRAVERSE,
|
|
||||||
NULL,
|
|
||||||
UserMode,
|
|
||||||
(PVOID*)¤t_dir,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Bit of a hack this
|
|
||||||
*/
|
|
||||||
if (string[0] == 0)
|
|
||||||
{
|
|
||||||
*Object = current_dir;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (string[0] != '\\')
|
|
||||||
{
|
|
||||||
DbgPrint("Non absolute pathname passed\n");
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
next = string;
|
|
||||||
current = next + 1;
|
|
||||||
|
|
||||||
while (next != NULL &&
|
|
||||||
BODY_TO_HEADER(current_dir)->ObjectType == ObDirectoryType)
|
|
||||||
{
|
|
||||||
*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,
|
|
||||||
Attributes);
|
|
||||||
if (current_dir == NULL)
|
|
||||||
{
|
|
||||||
DbgPrint("Path component %w not found\n", current);
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (BODY_TO_HEADER(current_dir)->ObjectType == IoSymbolicLinkType)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
if (BODY_TO_HEADER(current_dir)->ObjectType == IoDeviceType)
|
|
||||||
{
|
|
||||||
Status = STATUS_FS_QUERY_REQUIRED;
|
|
||||||
}
|
|
||||||
else if (BODY_TO_HEADER(current_dir)->ObjectType->Parse != NULL)
|
|
||||||
{
|
|
||||||
current_dir = BODY_TO_HEADER(current_dir)->ObjectType->
|
|
||||||
Parse(current_dir,
|
|
||||||
UnparsedSection);
|
|
||||||
Status = (current_dir != NULL) ? STATUS_SUCCESS :
|
|
||||||
STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Status = STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
CHECKPOINT;
|
|
||||||
*Object = current_dir;
|
|
||||||
DPRINT("current_dir %x\n", current_dir);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
148
reactos/ntoskrnl/ob/ntobj.c
Normal file
148
reactos/ntoskrnl/ob/ntobj.c
Normal file
|
@ -0,0 +1,148 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: ntoskrnl/ob/ntobj.c
|
||||||
|
* PURPOSE: User mode interface to object manager
|
||||||
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
|
* UPDATE HISTORY:
|
||||||
|
* 10/06/98: Created
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/ob.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS ************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtSetInformationObject(IN HANDLE ObjectHandle,
|
||||||
|
IN CINT ObjectInformationClass,
|
||||||
|
IN PVOID ObjectInformation,
|
||||||
|
IN ULONG Length)
|
||||||
|
{
|
||||||
|
return(ZwSetInformationObject(ObjectHandle,
|
||||||
|
ObjectInformationClass,
|
||||||
|
ObjectInformation,
|
||||||
|
Length));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ZwSetInformationObject(IN HANDLE ObjectHandle,
|
||||||
|
IN CINT ObjectInformationClass,
|
||||||
|
IN PVOID ObjectInformation,
|
||||||
|
IN ULONG Length)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtQueryObject(IN HANDLE ObjectHandle,
|
||||||
|
IN CINT ObjectInformationClass,
|
||||||
|
OUT PVOID ObjectInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
OUT PULONG ResultLength)
|
||||||
|
{
|
||||||
|
return(ZwQueryObject(ObjectHandle,
|
||||||
|
ObjectInformationClass,
|
||||||
|
ObjectInformation,
|
||||||
|
Length,
|
||||||
|
ResultLength));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ZwQueryObject(IN HANDLE ObjectHandle,
|
||||||
|
IN CINT ObjectInformationClass,
|
||||||
|
OUT PVOID ObjectInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
OUT PULONG ResultLength)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID ObMakeTemporaryObject(PVOID ObjectBody)
|
||||||
|
{
|
||||||
|
POBJECT_HEADER ObjectHeader;
|
||||||
|
|
||||||
|
ObjectHeader = BODY_TO_HEADER(ObjectBody);
|
||||||
|
ObjectHeader->Permanent = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS NtMakeTemporaryObject(HANDLE Handle)
|
||||||
|
{
|
||||||
|
return(ZwMakeTemporaryObject(Handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS ZwMakeTemporaryObject(HANDLE Handle)
|
||||||
|
{
|
||||||
|
PVOID Object;
|
||||||
|
NTSTATUS Status;
|
||||||
|
POBJECT_HEADER ObjectHeader;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(Handle,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
KernelMode,
|
||||||
|
&Object,
|
||||||
|
NULL);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectHeader = BODY_TO_HEADER(Object);
|
||||||
|
ObjectHeader->Permanent = FALSE;
|
||||||
|
|
||||||
|
ObDereferenceObject(Object);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS NtClose(HANDLE Handle)
|
||||||
|
{
|
||||||
|
return(ZwClose(Handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS ZwClose(HANDLE Handle)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Closes a handle reference to an object
|
||||||
|
* ARGUMENTS:
|
||||||
|
* Handle = handle to close
|
||||||
|
* RETURNS: Status
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PVOID ObjectBody;
|
||||||
|
POBJECT_HEADER Header;
|
||||||
|
PHANDLE_REP HandleRep;
|
||||||
|
|
||||||
|
assert_irql(PASSIVE_LEVEL);
|
||||||
|
|
||||||
|
DPRINT("ZwClose(Handle %x)\n",Handle);
|
||||||
|
|
||||||
|
HandleRep = ObTranslateHandle(KeGetCurrentProcess(),Handle);
|
||||||
|
if (HandleRep == NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_INVALID_HANDLE);
|
||||||
|
}
|
||||||
|
ObjectBody = HandleRep->ObjectBody;
|
||||||
|
|
||||||
|
HandleRep->ObjectBody = NULL;
|
||||||
|
|
||||||
|
Header = BODY_TO_HEADER(ObjectBody);
|
||||||
|
|
||||||
|
Header->RefCount++;
|
||||||
|
Header->HandleCount--;
|
||||||
|
|
||||||
|
if (Header->ObjectType != NULL &&
|
||||||
|
Header->ObjectType->Close != NULL)
|
||||||
|
{
|
||||||
|
Header->ObjectType->Close(ObjectBody, Header->HandleCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
Header->RefCount--;
|
||||||
|
|
||||||
|
ObPerformRetentionChecks(Header);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ob/object.c
|
* FILE: ntoskrnl/ob/object.c
|
||||||
* PURPOSE: Implements generic object managment functions
|
* PURPOSE: Implements generic object managment functions
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* 10/06/98: Created
|
* 10/06/98: Created
|
||||||
*/
|
*/
|
||||||
|
@ -20,222 +20,150 @@
|
||||||
|
|
||||||
/* FUNCTIONS ************************************************************/
|
/* FUNCTIONS ************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL NtSetInformationObject(IN HANDLE ObjectHandle,
|
VOID ObInitializeObject(POBJECT_HEADER ObjectHeader,
|
||||||
IN CINT ObjectInformationClass,
|
PHANDLE Handle,
|
||||||
IN PVOID ObjectInformation,
|
ACCESS_MASK DesiredAccess,
|
||||||
IN ULONG Length)
|
POBJECT_TYPE Type,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
{
|
{
|
||||||
return(ZwSetInformationObject(ObjectHandle,
|
|
||||||
ObjectInformationClass,
|
|
||||||
ObjectInformation,
|
|
||||||
Length));
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwSetInformationObject(IN HANDLE ObjectHandle,
|
|
||||||
IN CINT ObjectInformationClass,
|
|
||||||
IN PVOID ObjectInformation,
|
|
||||||
IN ULONG Length)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtQueryObject(IN HANDLE ObjectHandle,
|
|
||||||
IN CINT ObjectInformationClass,
|
|
||||||
OUT PVOID ObjectInformation,
|
|
||||||
IN ULONG Length,
|
|
||||||
OUT PULONG ResultLength)
|
|
||||||
{
|
|
||||||
return(ZwQueryObject(ObjectHandle,
|
|
||||||
ObjectInformationClass,
|
|
||||||
ObjectInformation,
|
|
||||||
Length,
|
|
||||||
ResultLength));
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwQueryObject(IN HANDLE ObjectHandle,
|
|
||||||
IN CINT ObjectInformationClass,
|
|
||||||
OUT PVOID ObjectInformation,
|
|
||||||
IN ULONG Length,
|
|
||||||
OUT PULONG ResultLength)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID ObMakeTemporaryObject(PVOID ObjectBody)
|
|
||||||
{
|
|
||||||
POBJECT_HEADER ObjectHeader;
|
|
||||||
|
|
||||||
ObjectHeader = BODY_TO_HEADER(ObjectBody);
|
|
||||||
ObjectHeader->Permanent = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS NtMakeTemporaryObject(HANDLE Handle)
|
|
||||||
{
|
|
||||||
return(ZwMakeTemporaryObject(Handle));
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS ZwMakeTemporaryObject(HANDLE Handle)
|
|
||||||
{
|
|
||||||
PVOID Object;
|
|
||||||
NTSTATUS Status;
|
|
||||||
POBJECT_HEADER ObjectHeader;
|
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(Handle,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
KernelMode,
|
|
||||||
&Object,
|
|
||||||
NULL);
|
|
||||||
if (Status != STATUS_SUCCESS)
|
|
||||||
{
|
|
||||||
return(Status);
|
|
||||||
}
|
|
||||||
|
|
||||||
ObjectHeader = BODY_TO_HEADER(Object);
|
|
||||||
ObjectHeader->Permanent = FALSE;
|
|
||||||
|
|
||||||
ObDereferenceObject(Object);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
PVOID ObGenericCreateObject(PHANDLE Handle,
|
|
||||||
ACCESS_MASK DesiredAccess,
|
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
|
||||||
POBJECT_TYPE Type)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Creates a new object
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
POBJECT_HEADER hdr = NULL;
|
|
||||||
PWSTR path;
|
|
||||||
PWSTR name;
|
|
||||||
PWSTR Ignored;
|
|
||||||
PULONG addr;
|
|
||||||
PWSTR Buffer;
|
|
||||||
|
|
||||||
DPRINT("ObGenericCreateObject(Handle %x, DesiredAccess %x,"
|
|
||||||
"ObjectAttributes %x, Type %x)\n",Handle,DesiredAccess,
|
|
||||||
ObjectAttributes,Type);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Allocate the object body and header
|
|
||||||
*/
|
|
||||||
hdr=(POBJECT_HEADER)ExAllocatePool(NonPagedPool,OBJECT_ALLOC_SIZE(Type));
|
|
||||||
DPRINT("OBJECT_ALLOC_SIZE(Type) %d\n",OBJECT_ALLOC_SIZE(Type));
|
|
||||||
if (hdr==NULL)
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
DPRINT("hdr %x\n",hdr);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If unnamed then initalize
|
|
||||||
*/
|
|
||||||
if (ObjectAttributes==NULL || ObjectAttributes->ObjectName==NULL)
|
|
||||||
{
|
|
||||||
ObInitializeObjectHeader(Type,NULL,hdr);
|
|
||||||
if (Handle != NULL)
|
|
||||||
{
|
|
||||||
*Handle = ObInsertHandle(KeGetCurrentProcess(),
|
|
||||||
HEADER_TO_BODY(hdr),
|
|
||||||
DesiredAccess,
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
return(HEADER_TO_BODY(hdr));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Copy the object name into a buffer
|
|
||||||
*/
|
|
||||||
// DbgPrint("ObjectAttributes->ObjectName %x\n",ObjectAttributes->ObjectName);
|
|
||||||
// DbgPrint("ObjectAttributes->ObjectName->Length %d\n",
|
|
||||||
// ObjectAttributes->ObjectName->Length);
|
|
||||||
// DbgPrint("ObjectAttributes->ObjectName->MaximumLength %d\n",
|
|
||||||
// ObjectAttributes->ObjectName->MaximumLength);
|
|
||||||
Buffer = ExAllocatePool(NonPagedPool,
|
|
||||||
((ObjectAttributes->ObjectName->Length+1)*2));
|
|
||||||
if (Buffer==NULL)
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
memcpy(Buffer, ObjectAttributes->ObjectName->Buffer,
|
|
||||||
(ObjectAttributes->ObjectName->Length+1)*2);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Seperate the name into a path and name
|
|
||||||
*/
|
|
||||||
name = wcsrchr(Buffer,'\\');
|
|
||||||
if (name==NULL)
|
|
||||||
{
|
|
||||||
name=Buffer;
|
|
||||||
path=NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
path=Buffer;
|
|
||||||
*name=0;
|
|
||||||
name=name+1;
|
|
||||||
}
|
|
||||||
DPRINT("name %w path %w\n",name,path);
|
|
||||||
|
|
||||||
ObLookupObject(ObjectAttributes->RootDirectory,
|
|
||||||
path,
|
|
||||||
&hdr->Parent,
|
|
||||||
&Ignored,
|
|
||||||
0L);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize the object header
|
|
||||||
*/
|
|
||||||
ObInitializeObjectHeader(Type,name,hdr);
|
|
||||||
|
|
||||||
|
|
||||||
ObCreateEntry(hdr->Parent,hdr);
|
|
||||||
|
|
||||||
DPRINT("Handle %x\n",Handle);
|
|
||||||
if (Handle != NULL)
|
|
||||||
{
|
|
||||||
*Handle = ObInsertHandle(KeGetCurrentProcess(),
|
|
||||||
HEADER_TO_BODY(hdr),
|
|
||||||
DesiredAccess,
|
|
||||||
FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
return(HEADER_TO_BODY(hdr));
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID ObInitializeObjectHeader(POBJECT_TYPE Type, PWSTR name,
|
|
||||||
POBJECT_HEADER ObjectHeader)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Creates a new object
|
|
||||||
* ARGUMENT:
|
|
||||||
* id = Identifier for the type of object
|
|
||||||
* obj = Pointer to the header of the object
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PWSTR temp_name;
|
|
||||||
|
|
||||||
DPRINT("ObInitializeObjectHeader(id %x name %w obj %x)\n",Type,
|
|
||||||
name,ObjectHeader);
|
|
||||||
|
|
||||||
ObjectHeader->HandleCount = 1;
|
ObjectHeader->HandleCount = 1;
|
||||||
ObjectHeader->RefCount = 1;
|
ObjectHeader->RefCount = 1;
|
||||||
ObjectHeader->ObjectType = Type;
|
ObjectHeader->ObjectType = Type;
|
||||||
ObjectHeader->Permanent = FALSE;
|
ObjectHeader->Permanent = FALSE;
|
||||||
if (name==NULL)
|
RtlInitUnicodeString(&(ObjectHeader->Name),NULL);
|
||||||
|
if (Handle != NULL)
|
||||||
{
|
{
|
||||||
ObjectHeader->Name.Length=0;
|
*Handle = ObInsertHandle(KeGetCurrentProcess(),
|
||||||
ObjectHeader->Name.Buffer=NULL;
|
HEADER_TO_BODY(ObjectHeader),
|
||||||
}
|
DesiredAccess,
|
||||||
else
|
FALSE);
|
||||||
{
|
|
||||||
RtlInitUnicodeString(&(ObjectHeader->Name),name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
PVOID* ReturnedObject,
|
||||||
|
PWSTR* RemainingPath)
|
||||||
|
{
|
||||||
|
PVOID NextObject;
|
||||||
|
PVOID CurrentObject;
|
||||||
|
POBJECT_HEADER CurrentHeader;
|
||||||
|
NTSTATUS Status;
|
||||||
|
PWSTR Path;
|
||||||
|
PWSTR current;
|
||||||
|
|
||||||
|
DPRINT("ObFindObject(ObjectAttributes %x, ReturnedObject %x, "
|
||||||
|
"RemainingPath %x)\n",ObjectAttributes,ReturnedObject,RemainingPath);
|
||||||
|
DPRINT("ObjectAttributes->ObjectName->Buffer %x\n",
|
||||||
|
ObjectAttributes->ObjectName->Buffer);
|
||||||
|
|
||||||
|
if (ObjectAttributes->RootDirectory == NULL)
|
||||||
|
{
|
||||||
|
ObReferenceObjectByPointer(NameSpaceRoot,
|
||||||
|
DIRECTORY_TRAVERSE,
|
||||||
|
NULL,
|
||||||
|
UserMode);
|
||||||
|
CurrentObject = NameSpaceRoot;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Status = ObReferenceObjectByHandle(ObjectAttributes->RootDirectory,
|
||||||
|
DIRECTORY_TRAVERSE,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
&CurrentObject,
|
||||||
|
NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Path = ObjectAttributes->ObjectName->Buffer;
|
||||||
|
|
||||||
|
if (Path[0] == 0)
|
||||||
|
{
|
||||||
|
*ReturnedObject = CurrentObject;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Path[0] != '\\')
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
current = Path;
|
||||||
|
|
||||||
|
while (TRUE)
|
||||||
|
{
|
||||||
|
DPRINT("current %w\n",current);
|
||||||
|
CurrentHeader = BODY_TO_HEADER(CurrentObject);
|
||||||
|
if (CurrentHeader->ObjectType->Parse == NULL)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
NextObject = CurrentHeader->ObjectType->Parse(CurrentObject,
|
||||||
|
¤t);
|
||||||
|
if (NextObject == NULL)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ObDereferenceObject(CurrentObject);
|
||||||
|
CurrentObject = NextObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
*RemainingPath = current;
|
||||||
|
*ReturnedObject = CurrentObject;
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PVOID ObCreateObject(PHANDLE Handle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
POBJECT_TYPE Type)
|
||||||
|
{
|
||||||
|
PVOID Parent = NULL;
|
||||||
|
PWSTR RemainingPath = NULL;
|
||||||
|
POBJECT_HEADER Header;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
DPRINT("ObCreateObject(Handle %x, ObjectAttributes %x, Type %x)\n");
|
||||||
|
if (ObjectAttributes != NULL &&
|
||||||
|
ObjectAttributes->ObjectName != NULL)
|
||||||
|
{
|
||||||
|
DPRINT("ObjectAttributes->ObjectName->Buffer %w\n",
|
||||||
|
ObjectAttributes->ObjectName->Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ObjectAttributes != NULL &&
|
||||||
|
ObjectAttributes->ObjectName != NULL)
|
||||||
|
{
|
||||||
|
ObFindObject(ObjectAttributes,
|
||||||
|
&Parent,
|
||||||
|
&RemainingPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
Header = (POBJECT_HEADER)ExAllocatePool(NonPagedPool,
|
||||||
|
OBJECT_ALLOC_SIZE(Type));
|
||||||
|
ObInitializeObject(Header,
|
||||||
|
Handle,
|
||||||
|
DesiredAccess,
|
||||||
|
Type,
|
||||||
|
ObjectAttributes);
|
||||||
|
if (Header->ObjectType != NULL &&
|
||||||
|
Header->ObjectType->Create != NULL)
|
||||||
|
{
|
||||||
|
Status = Header->ObjectType->Create(HEADER_TO_BODY(Header),
|
||||||
|
Parent,
|
||||||
|
RemainingPath,
|
||||||
|
ObjectAttributes);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(HEADER_TO_BODY(Header));
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS ObReferenceObjectByPointer(PVOID ObjectBody,
|
NTSTATUS ObReferenceObjectByPointer(PVOID ObjectBody,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
|
@ -251,12 +179,21 @@ NTSTATUS ObReferenceObjectByPointer(PVOID ObjectBody,
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
POBJECT_HEADER Object;
|
POBJECT_HEADER ObjectHeader;
|
||||||
|
|
||||||
DPRINT("ObReferenceObjectByPointer(%x)\n",ObjectBody);
|
DPRINT("ObReferenceObjectByPointer(ObjectBody %x, ObjectType %x)\n",
|
||||||
|
ObjectBody,ObjectType);
|
||||||
|
|
||||||
Object = BODY_TO_HEADER(ObjectBody);
|
ObjectHeader = BODY_TO_HEADER(ObjectBody);
|
||||||
Object->RefCount++;
|
|
||||||
|
if (ObjectType != NULL && ObjectHeader->ObjectType != ObjectType)
|
||||||
|
{
|
||||||
|
DPRINT("Failed (type was %x %w)\n",ObjectHeader->ObjectType,
|
||||||
|
ObjectHeader->ObjectType->TypeName.Buffer);
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
ObjectHeader->RefCount++;
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,9 +211,9 @@ NTSTATUS ObPerformRetentionChecks(POBJECT_HEADER Header)
|
||||||
!Header->Permanent)
|
!Header->Permanent)
|
||||||
{
|
{
|
||||||
if (Header->ObjectType != NULL &&
|
if (Header->ObjectType != NULL &&
|
||||||
Header->ObjectType->Close != NULL)
|
Header->ObjectType->Delete != NULL)
|
||||||
{
|
{
|
||||||
Header->ObjectType->Close(HEADER_TO_BODY(Header));
|
Header->ObjectType->Delete(HEADER_TO_BODY(Header));
|
||||||
}
|
}
|
||||||
if (Header->Name.Buffer != NULL)
|
if (Header->Name.Buffer != NULL)
|
||||||
{
|
{
|
||||||
|
@ -305,45 +242,6 @@ VOID ObDereferenceObject(PVOID ObjectBody)
|
||||||
ObPerformRetentionChecks(Header);
|
ObPerformRetentionChecks(Header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS NtClose(HANDLE Handle)
|
|
||||||
{
|
|
||||||
return(ZwClose(Handle));
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS ZwClose(HANDLE Handle)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Closes a handle reference to an object
|
|
||||||
* ARGUMENTS:
|
|
||||||
* Handle = handle to close
|
|
||||||
* RETURNS: Status
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PVOID ObjectBody;
|
|
||||||
POBJECT_HEADER Header;
|
|
||||||
PHANDLE_REP HandleRep;
|
|
||||||
|
|
||||||
assert_irql(PASSIVE_LEVEL);
|
|
||||||
|
|
||||||
DPRINT("ZwClose(Handle %x)\n",Handle);
|
|
||||||
|
|
||||||
HandleRep = ObTranslateHandle(KeGetCurrentProcess(),Handle);
|
|
||||||
if (HandleRep == NULL)
|
|
||||||
{
|
|
||||||
return(STATUS_INVALID_HANDLE);
|
|
||||||
}
|
|
||||||
ObjectBody = HandleRep->ObjectBody;
|
|
||||||
|
|
||||||
HandleRep->ObjectBody = NULL;
|
|
||||||
|
|
||||||
Header = BODY_TO_HEADER(ObjectBody);
|
|
||||||
|
|
||||||
Header->HandleCount--;
|
|
||||||
ObPerformRetentionChecks(Header);
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
|
NTSTATUS ObReferenceObjectByHandle(HANDLE Handle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_TYPE ObjectType,
|
POBJECT_TYPE ObjectType,
|
||||||
|
|
|
@ -59,7 +59,7 @@ VOID PsInitProcessManagment(VOID)
|
||||||
/*
|
/*
|
||||||
* Initialize the system process
|
* Initialize the system process
|
||||||
*/
|
*/
|
||||||
SystemProcess = ObGenericCreateObject(NULL,PROCESS_ALL_ACCESS,NULL,
|
SystemProcess = ObCreateObject(NULL,PROCESS_ALL_ACCESS,NULL,
|
||||||
PsProcessType);
|
PsProcessType);
|
||||||
KProcess = &SystemProcess->Pcb;
|
KProcess = &SystemProcess->Pcb;
|
||||||
|
|
||||||
|
@ -172,10 +172,10 @@ NTSTATUS STDCALL ZwCreateProcess(
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Process = ObGenericCreateObject(ProcessHandle,
|
Process = ObCreateObject(ProcessHandle,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
ObjectAttributes,
|
ObjectAttributes,
|
||||||
PsProcessType);
|
PsProcessType);
|
||||||
KeInitializeDispatcherHeader(&Process->Pcb.DispatcherHeader,
|
KeInitializeDispatcherHeader(&Process->Pcb.DispatcherHeader,
|
||||||
0,
|
0,
|
||||||
sizeof(EPROCESS),
|
sizeof(EPROCESS),
|
||||||
|
|
|
@ -216,10 +216,10 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
|
|
||||||
PiNrThreads++;
|
PiNrThreads++;
|
||||||
|
|
||||||
Thread = ObGenericCreateObject(ThreadHandle,
|
Thread = ObCreateObject(ThreadHandle,
|
||||||
DesiredAccess,
|
DesiredAccess,
|
||||||
ThreadAttributes,
|
ThreadAttributes,
|
||||||
PsThreadType);
|
PsThreadType);
|
||||||
DPRINT("Thread = %x\n",Thread);
|
DPRINT("Thread = %x\n",Thread);
|
||||||
Thread->Tcb.LastTick = 0;
|
Thread->Tcb.LastTick = 0;
|
||||||
Thread->Tcb.ThreadState=THREAD_STATE_SUSPENDED;
|
Thread->Tcb.ThreadState=THREAD_STATE_SUSPENDED;
|
||||||
|
|
|
@ -1,18 +1,16 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: mkernel/rtl/seqlist.c
|
* FILE: ntoskrnl/rtl/seqlist.c
|
||||||
* PURPOSE: Implementing sequenced lists
|
* PURPOSE: Implementing sequenced lists
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* REVISION HISTORY:
|
* REVISION HISTORY:
|
||||||
* 28/06/98: Created
|
* 28/06/98: Created
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ***************************************************************/
|
/* INCLUDES ***************************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/kernel.h>
|
|
||||||
|
|
||||||
/* TYPES ********************************************************************/
|
/* TYPES ********************************************************************/
|
||||||
|
|
||||||
|
|
|
@ -11,8 +11,6 @@
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <internal/kernel.h>
|
|
||||||
#include <internal/linkage.h>
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/tst/test.c
|
* FILE: ntoskrnl/tst/test.c
|
||||||
* PURPOSE: Kernel regression tests
|
* PURPOSE: Kernel regression tests
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* 28/05/98: Created
|
* 28/05/98: Created
|
||||||
*/
|
*/
|
||||||
|
@ -25,66 +25,8 @@
|
||||||
|
|
||||||
#define IDE_SECTOR_SZ 512
|
#define IDE_SECTOR_SZ 512
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
|
||||||
|
|
||||||
static KEVENT event = {};
|
|
||||||
//static KEVENT event2;
|
|
||||||
NTSTATUS TstShell(VOID);
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
NTSTATUS TstPlaySound(VOID)
|
|
||||||
{
|
|
||||||
HANDLE hfile;
|
|
||||||
|
|
||||||
// * Open the parallel port
|
|
||||||
printk("Opening Waveout\n");
|
|
||||||
// hfile = CreateFile("\\Device\\WaveOut",0,0,0,0,0,0);
|
|
||||||
if (hfile == NULL)
|
|
||||||
{
|
|
||||||
printk("File open failed\n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// WriteFile(hfile,wave,wavelength,NULL,NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS TstFirstThread(PVOID start)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
printk("Beginning Thread A\n");
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
|
||||||
printk("AAA ");
|
|
||||||
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS TstSecondThread(PVOID start)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
printk("Beginning Thread B\n");
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
|
||||||
printk("BBB ");
|
|
||||||
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS TstThreadSupport()
|
|
||||||
{
|
|
||||||
HANDLE th1, th2;
|
|
||||||
|
|
||||||
KeInitializeEvent(&event,SynchronizationEvent,TRUE);
|
|
||||||
PsCreateSystemThread(&th1,0,NULL,NULL,NULL,TstFirstThread,NULL);
|
|
||||||
PsCreateSystemThread(&th2,0,NULL,NULL,NULL,TstSecondThread,NULL);
|
|
||||||
printk("Ending main thread\n");
|
|
||||||
for(;;);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID ExExecuteShell(VOID)
|
VOID ExExecuteShell(VOID)
|
||||||
{
|
{
|
||||||
|
@ -99,6 +41,7 @@ VOID ExExecuteShell(VOID)
|
||||||
LARGE_INTEGER SectionOffset;
|
LARGE_INTEGER SectionOffset;
|
||||||
ULONG Size, StackSize;
|
ULONG Size, StackSize;
|
||||||
CONTEXT Context;
|
CONTEXT Context;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
ZwCreateProcess(&ShellHandle,
|
ZwCreateProcess(&ShellHandle,
|
||||||
PROCESS_ALL_ACCESS,
|
PROCESS_ALL_ACCESS,
|
||||||
|
@ -112,8 +55,8 @@ VOID ExExecuteShell(VOID)
|
||||||
RtlInitAnsiString(&afilename,"\\??\\C:\\reactos\\system\\shell.bin");
|
RtlInitAnsiString(&afilename,"\\??\\C:\\reactos\\system\\shell.bin");
|
||||||
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
||||||
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
||||||
ZwOpenFile(&hfile,FILE_ALL_ACCESS,&attr,NULL,0,0);
|
Status = ZwOpenFile(&hfile,FILE_ALL_ACCESS,&attr,NULL,0,0);
|
||||||
if (hfile==NULL)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint("Failed to open file\n");
|
DbgPrint("Failed to open file\n");
|
||||||
return;
|
return;
|
||||||
|
@ -443,102 +386,8 @@ void TstIDERead(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
TstKeyboard(void)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
HANDLE FileHandle;
|
|
||||||
ANSI_STRING AnsiDeviceName;
|
|
||||||
UNICODE_STRING UnicodeDeviceName;
|
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
|
||||||
KEY_EVENT_RECORD KeyEvent[2];
|
|
||||||
|
|
||||||
DbgPrint("Testing keyboard driver...\n");
|
|
||||||
|
|
||||||
DbgPrint("Opening Keyboard device\n");
|
|
||||||
RtlInitAnsiString(&AnsiDeviceName, "\\Device\\Keyboard");
|
|
||||||
RtlAnsiStringToUnicodeString(&UnicodeDeviceName, &AnsiDeviceName, TRUE);
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
|
||||||
&UnicodeDeviceName,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
Status = ZwOpenFile(&FileHandle, FILE_GENERIC_READ, &ObjectAttributes, NULL, 0, 0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("Failed to open keyboard\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
DbgPrint(">");
|
|
||||||
for(;;)
|
|
||||||
{
|
|
||||||
Status = ZwReadFile(FileHandle,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&KeyEvent,
|
|
||||||
sizeof(KeyEvent),
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DbgPrint("Failed to read key event, status %08x\n", Status);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
DbgPrint("%c",KeyEvent[0].AsciiChar);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int TTcnt = 0;
|
|
||||||
|
|
||||||
VOID TstTimerDpc(struct _KDPC* Dpc,
|
|
||||||
PVOID DeferredContext,
|
|
||||||
PVOID SystemArgument1,
|
|
||||||
PVOID SystemArgument2)
|
|
||||||
{
|
|
||||||
TTcnt++;
|
|
||||||
|
|
||||||
DPRINT("Timer DPC cnt:%d\n", TTcnt);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
TstTimer(void)
|
|
||||||
{
|
|
||||||
PIO_TIMER Timer = ExAllocatePool(NonPagedPool,sizeof(IO_TIMER));
|
|
||||||
long long int lli = -10000000;
|
|
||||||
LARGE_INTEGER li = *(LARGE_INTEGER *)&lli;
|
|
||||||
|
|
||||||
CHECKPOINT;
|
|
||||||
KeInitializeTimer(&Timer->timer);
|
|
||||||
CHECKPOINT;
|
|
||||||
KeInitializeDpc(&Timer->dpc, TstTimerDpc, NULL);
|
|
||||||
CHECKPOINT;
|
|
||||||
KeSetTimerEx(&Timer->timer,
|
|
||||||
li,
|
|
||||||
1000,
|
|
||||||
&Timer->dpc);
|
|
||||||
CHECKPOINT;
|
|
||||||
while (TTcnt < 100)
|
|
||||||
;
|
|
||||||
CHECKPOINT;
|
|
||||||
KeCancelTimer(&Timer->timer);
|
|
||||||
CHECKPOINT;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TstBegin()
|
void TstBegin()
|
||||||
{
|
{
|
||||||
ExExecuteShell();
|
ExExecuteShell();
|
||||||
// TstFileRead();
|
|
||||||
// TstGeneralWrite();
|
|
||||||
// TstThreadSupport();
|
|
||||||
// TstKeyboard();
|
|
||||||
// TstIDERead();
|
|
||||||
// TstKeyboardRead();
|
|
||||||
// TstShell();
|
|
||||||
// TstTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue