mirror of
https://github.com/reactos/reactos.git
synced 2025-05-29 22:18:13 +00:00
This commit was generated by cvs2svn to compensate for changes in r21,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=22
This commit is contained in:
parent
bbddb2c838
commit
35cc27eee0
38 changed files with 1080 additions and 1118 deletions
|
@ -39,8 +39,8 @@ enum
|
||||||
*/
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
STATUS_SUCCESS,
|
STATUS_SUCCESS = 0x0,
|
||||||
STATUS_INSUFFICIENT_RESOURCES,
|
STATUS_INSUFFICIENT_RESOURCES = 0x80000000,
|
||||||
STATUS_OBJECT_NAME_EXISTS,
|
STATUS_OBJECT_NAME_EXISTS,
|
||||||
STATUS_OBJECT_NAME_COLLISION,
|
STATUS_OBJECT_NAME_COLLISION,
|
||||||
// STATUS_DATATYPE_MISALIGNMENT,
|
// STATUS_DATATYPE_MISALIGNMENT,
|
||||||
|
@ -179,7 +179,9 @@ enum
|
||||||
STATUS_NO_MEDIA_IN_DRIVE,
|
STATUS_NO_MEDIA_IN_DRIVE,
|
||||||
STATUS_VERIFY_REQUIRED,
|
STATUS_VERIFY_REQUIRED,
|
||||||
STATUS_UNRECOGNIZED_MEDIA,
|
STATUS_UNRECOGNIZED_MEDIA,
|
||||||
|
STATUS_UNRECOGNIZED_VOLUME,
|
||||||
// STATUS_WRONG_VOLUME,
|
// STATUS_WRONG_VOLUME,
|
||||||
|
STATUS_FS_DRIVER_REQUIRED,
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -63,6 +63,7 @@ typedef VOID (*PIO_APC_ROUTINE) (PVOID ApcContext,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Special timer associated with each device
|
* PURPOSE: Special timer associated with each device
|
||||||
|
* NOTES: This is a guess
|
||||||
*/
|
*/
|
||||||
typedef struct _IO_TIMER
|
typedef struct _IO_TIMER
|
||||||
{
|
{
|
||||||
|
@ -192,6 +193,27 @@ typedef struct _IO_COMPLETION_CONTEXT
|
||||||
ULONG Key;
|
ULONG Key;
|
||||||
} IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
|
} IO_COMPLETION_CONTEXT, *PIO_COMPLETION_CONTEXT;
|
||||||
|
|
||||||
|
#define FO_FILE_OPEN 0x00000001
|
||||||
|
#define FO_SYNCHRONOUS_IO 0x00000002
|
||||||
|
#define FO_ALERTABLE_IO 0x00000004
|
||||||
|
#define FO_NO_INTERMEDIATE_BUFFERING 0x00000008
|
||||||
|
#define FO_WRITE_THROUGH 0x00000010
|
||||||
|
#define FO_SEQUENTIAL_ONLY 0x00000020
|
||||||
|
#define FO_CACHE_SUPPORTED 0x00000040
|
||||||
|
#define FO_NAMED_PIPE 0x00000080
|
||||||
|
#define FO_STREAM_FILE 0x00000100
|
||||||
|
#define FO_MAILSLOT 0x00000200
|
||||||
|
#define FO_GENERATE_AUDIT_ON_CLOSE 0x00000400
|
||||||
|
#define FO_DIRECT_DEVICE_OPEN 0x00000800
|
||||||
|
#define FO_FILE_MODIFIED 0x00001000
|
||||||
|
#define FO_FILE_SIZE_CHANGED 0x00002000
|
||||||
|
#define FO_CLEANUP_COMPLETE 0x00004000
|
||||||
|
#define FO_TEMPORARY_FILE 0x00008000
|
||||||
|
#define FO_DELETE_ON_CLOSE 0x00010000
|
||||||
|
#define FO_OPENED_CASE_SENSITIVE 0x00020000
|
||||||
|
#define FO_HANDLE_CREATED 0x00040000
|
||||||
|
#define FO_FILE_FAST_IO_READ 0x00080000
|
||||||
|
|
||||||
typedef struct _FILE_OBJECT
|
typedef struct _FILE_OBJECT
|
||||||
{
|
{
|
||||||
CSHORT Type;
|
CSHORT Type;
|
||||||
|
|
|
@ -3,6 +3,12 @@
|
||||||
|
|
||||||
/* KERNEL FUNCTIONS ********************************************************/
|
/* KERNEL FUNCTIONS ********************************************************/
|
||||||
|
|
||||||
|
VOID KeDrainApcQueue(VOID);
|
||||||
|
VOID KeInitializeApc(PKAPC Apc, PKNORMAL_ROUTINE NormalRoutine,
|
||||||
|
PVOID NormalContext,
|
||||||
|
PKTHREAD TargetThread);
|
||||||
|
BOOLEAN KeInsertQueueApc(PKAPC Apc);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Acquires a spinlock so the caller can synchronize access to
|
* FUNCTION: Acquires a spinlock so the caller can synchronize access to
|
||||||
* data
|
* data
|
||||||
|
|
|
@ -34,7 +34,7 @@ typedef struct
|
||||||
USHORT WaitType;
|
USHORT WaitType;
|
||||||
} KWAIT_BLOCK, *PKWAIT_BLOCK;
|
} KWAIT_BLOCK, *PKWAIT_BLOCK;
|
||||||
|
|
||||||
|
#define _KTHREAD _ETHREAD
|
||||||
|
|
||||||
typedef struct _ETHREAD
|
typedef struct _ETHREAD
|
||||||
/*
|
/*
|
||||||
|
@ -47,7 +47,7 @@ typedef struct _ETHREAD
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Head of the queue of apcs
|
* PURPOSE: Head of the queue of apcs
|
||||||
*/
|
*/
|
||||||
LIST_ENTRY apc_queue_head;
|
LIST_ENTRY ApcQueueHead;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Entry in the linked list of threads
|
* PURPOSE: Entry in the linked list of threads
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
/* MEMORY MANAGMENT ******************************************************/
|
/* MEMORY MANAGMENT ******************************************************/
|
||||||
|
|
||||||
|
#include <internal/hal/page.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Determines if the given virtual address is page aligned
|
* FUNCTION: Determines if the given virtual address is page aligned
|
||||||
*/
|
*/
|
||||||
|
@ -27,7 +29,16 @@
|
||||||
* Size = Size of range
|
* Size = Size of range
|
||||||
* RETURNS: The number of pages
|
* RETURNS: The number of pages
|
||||||
*/
|
*/
|
||||||
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va, Size)
|
extern inline unsigned int ADDRESS_AND_SIZE_TO_SPAN_PAGES(PVOID Va,
|
||||||
|
ULONG Size)
|
||||||
|
{
|
||||||
|
ULONG HighestAddr;
|
||||||
|
ULONG LowestAddr;
|
||||||
|
|
||||||
|
HighestAddr = PAGE_ROUND_UP(Size + ((ULONG)Va));
|
||||||
|
LowestAddr = PAGE_ROUND_DOWN((ULONG)Va);
|
||||||
|
return((HighestAddr - LowestAddr) / PAGESIZE);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Returns FALSE is the pointer is NULL, TRUE otherwise
|
* FUNCTION: Returns FALSE is the pointer is NULL, TRUE otherwise
|
||||||
|
|
|
@ -1,4 +1,25 @@
|
||||||
typedef struct _MDL
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MDL_MAPPED_TO_SYSTEM_VA = 0x1,
|
||||||
|
MDL_PAGES_LOCKED = 0x2,
|
||||||
|
MDL_SOURCE_IS_NONPAGED_POOL = 0x4,
|
||||||
|
MDL_ALLOCATED_FIXED_SIZE = 0x8,
|
||||||
|
MDL_PARTIAL = 0x10,
|
||||||
|
MDL_PARTIAL_HAS_BEEN_MAPPED = 0x20,
|
||||||
|
MDL_IO_PAGE_READ = 0x40,
|
||||||
|
MDL_WRITE_OPERATION = 0x80,
|
||||||
|
MDL_PARENT_MAPPED_SYSTEM_VA = 0x100,
|
||||||
|
MDL_LOCK_HELD = 0x200,
|
||||||
|
MDL_SCATTER_GATHER_VA = 0x400,
|
||||||
|
MDL_IO_SPACE = 0x800,
|
||||||
|
MDL_NETWORK_HEADER = 0x1000,
|
||||||
|
MDL_MAPPING_CAN_FAIL = 0x2000,
|
||||||
|
MDL_ALLOCATED_MUST_SUCCEED = 0x4000,
|
||||||
|
MDL_64_BIT_VA = 0x8000,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct _MDL
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Describes a user buffer passed to a system API
|
* PURPOSE: Describes a user buffer passed to a system API
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -64,9 +64,8 @@ enum {
|
||||||
#include <ddk/iofuncs.h>
|
#include <ddk/iofuncs.h>
|
||||||
#include <ddk/psfuncs.h>
|
#include <ddk/psfuncs.h>
|
||||||
#include <ddk/obfuncs.h>
|
#include <ddk/obfuncs.h>
|
||||||
|
#include <ddk/dbgfuncs.h>
|
||||||
ULONG DbgPrint(PCH Format,...);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -42,3 +42,6 @@ NTSTATUS ObReferenceObjectByPointer(PVOID Object,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_TYPE ObjectType,
|
POBJECT_TYPE ObjectType,
|
||||||
KPROCESSOR_MODE AccessMode);
|
KPROCESSOR_MODE AccessMode);
|
||||||
|
|
||||||
|
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
PVOID* Object);
|
||||||
|
|
|
@ -133,17 +133,9 @@ typedef struct _OBJECT
|
||||||
typedef struct _OBJECT_ATTRIBUTES
|
typedef struct _OBJECT_ATTRIBUTES
|
||||||
{
|
{
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
|
HANDLE RootDirectory;
|
||||||
/*
|
PUNICODE_STRING ObjectName;
|
||||||
* PURPOSE: Attributes of the object
|
|
||||||
*/
|
|
||||||
ULONG Attributes;
|
ULONG Attributes;
|
||||||
|
PVOID SecurityDescriptor;
|
||||||
SECURITY_DESCRIPTOR SecurityDescriptor;
|
PVOID SecurityQualityOfService;
|
||||||
// SecurityQualityOfService
|
|
||||||
|
|
||||||
struct _DIRECTORY_OBJECT* parent;
|
|
||||||
UNICODE_STRING name;
|
|
||||||
UNICODE_STRING path;
|
|
||||||
|
|
||||||
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
|
} OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES;
|
||||||
|
|
|
@ -226,7 +226,7 @@ VOID RtlStoreUshort(PUSHORT Address, USHORT Value);
|
||||||
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS TimeFields, PLARGE_INTEGER Time);
|
BOOLEAN RtlTimeFieldsToTime(PTIME_FIELDS TimeFields, PLARGE_INTEGER Time);
|
||||||
VOID RtlTimeToTimeFields(PLARGE_INTEGER Time, PTIME_FIELDS TimeFields);
|
VOID RtlTimeToTimeFields(PLARGE_INTEGER Time, PTIME_FIELDS TimeFields);
|
||||||
PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep, PWSTR* temp);
|
PWSTR RtlStrtok(PUNICODE_STRING _string, PWSTR _sep, PWSTR* temp);
|
||||||
|
VOID RtlGetCallersAddress(PVOID* CallersAddress);
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ULONG Length;
|
ULONG Length;
|
||||||
|
|
|
@ -22,6 +22,6 @@
|
||||||
NTSTATUS InitalizeLoadedDriver(PDRIVER_INITIALIZE entry);
|
NTSTATUS InitalizeLoadedDriver(PDRIVER_INITIALIZE entry);
|
||||||
|
|
||||||
VOID IoInitCancelHandling(VOID);
|
VOID IoInitCancelHandling(VOID);
|
||||||
|
VOID IoInitSymbolicLinkImplementation(VOID);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -40,6 +40,7 @@ enum
|
||||||
OBJTYP_SYMLNK,
|
OBJTYP_SYMLNK,
|
||||||
OBJTYP_DEVICE,
|
OBJTYP_DEVICE,
|
||||||
OBJTYP_THREAD,
|
OBJTYP_THREAD,
|
||||||
|
OBJTYP_FILE,
|
||||||
OBJTYP_MAX,
|
OBJTYP_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -47,7 +48,7 @@ BOOL ObAddObjectToNameSpace(PUNICODE_STRING path, POBJECT_HEADER Object);
|
||||||
|
|
||||||
VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type);
|
VOID ObRegisterType(CSHORT id, OBJECT_TYPE* type);
|
||||||
|
|
||||||
VOID ObInitializeObjectHeader(CSHORT id, PUNICODE_STRING name,
|
VOID ObInitializeObjectHeader(CSHORT id, PWSTR name,
|
||||||
POBJECT_HEADER obj);
|
POBJECT_HEADER obj);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -58,9 +59,8 @@ VOID ObInitializeObjectHeader(CSHORT id, PUNICODE_STRING name,
|
||||||
*/
|
*/
|
||||||
ULONG ObSizeOf(CSHORT Type);
|
ULONG ObSizeOf(CSHORT Type);
|
||||||
HANDLE ObAddHandle(PVOID obj);
|
HANDLE ObAddHandle(PVOID obj);
|
||||||
|
PVOID ObLookupObject(HANDLE rooth, PWSTR _string);
|
||||||
PVOID ObGetObjectByHandle(HANDLE h);
|
PVOID ObGetObjectByHandle(HANDLE h);
|
||||||
PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string);
|
|
||||||
PVOID ObGenericCreateObject(PHANDLE Handle,
|
PVOID ObGenericCreateObject(PHANDLE Handle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
|
|
@ -9,9 +9,9 @@
|
||||||
#ifndef __VERSION_H
|
#ifndef __VERSION_H
|
||||||
#define __VERSION_H
|
#define __VERSION_H
|
||||||
|
|
||||||
#define KERNEL_VERSION "0.0.8"
|
#define KERNEL_VERSION "0.0.9"
|
||||||
#define KERNEL_MAJOR_VERSION 0
|
#define KERNEL_MAJOR_VERSION 0
|
||||||
#define KERNEL_MINOR_VERSION 0
|
#define KERNEL_MINOR_VERSION 0
|
||||||
#define KERNEL_PATCH_LEVEL 8
|
#define KERNEL_PATCH_LEVEL 9
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -38,7 +38,7 @@ extern __kernel_size_t strnlen(const char *,__kernel_size_t);
|
||||||
extern __kernel_size_t strspn(const char *,const char *);
|
extern __kernel_size_t strspn(const char *,const char *);
|
||||||
extern int strcmp(const char *,const char *);
|
extern int strcmp(const char *,const char *);
|
||||||
extern int strncmp(const char *,const char *,__kernel_size_t);
|
extern int strncmp(const char *,const char *,__kernel_size_t);
|
||||||
extern int stricmp(const char* cs,const char * ct)
|
extern int stricmp(const char* cs,const char * ct);
|
||||||
extern int strnicmp(const char* cs,const char * ct, size_t count);
|
extern int strnicmp(const char* cs,const char * ct, size_t count);
|
||||||
|
|
||||||
extern void * memset(void *,int,__kernel_size_t);
|
extern void * memset(void *,int,__kernel_size_t);
|
||||||
|
|
|
@ -27,8 +27,8 @@ extern wchar_t * wcscat(wchar_t *, const wchar_t *);
|
||||||
extern wchar_t * wcsncat(wchar_t *, const wchar_t *, __kernel_size_t);
|
extern wchar_t * wcsncat(wchar_t *, const wchar_t *, __kernel_size_t);
|
||||||
extern int wcscmp(const wchar_t *,const wchar_t *);
|
extern int wcscmp(const wchar_t *,const wchar_t *);
|
||||||
extern int wcsncmp(const wchar_t *,const wchar_t *,__kernel_size_t);
|
extern int wcsncmp(const wchar_t *,const wchar_t *,__kernel_size_t);
|
||||||
extern wchar_t * wcschr(const wchar_t *,int);
|
wchar_t* wcschr(wchar_t* str, wchar_t ch);
|
||||||
extern wchar_t * wcsrchr(const wchar_t *,int);
|
extern wchar_t * wcsrchr(const wchar_t *,wchar_t);
|
||||||
extern wchar_t * wcspbrk(const wchar_t *,const wchar_t *);
|
extern wchar_t * wcspbrk(const wchar_t *,const wchar_t *);
|
||||||
extern wchar_t * wcstok(wchar_t *,const wchar_t *);
|
extern wchar_t * wcstok(wchar_t *,const wchar_t *);
|
||||||
extern wchar_t * wcsstr(const wchar_t *,const wchar_t *);
|
extern wchar_t * wcsstr(const wchar_t *,const wchar_t *);
|
||||||
|
@ -36,499 +36,6 @@ extern size_t wcsnlen(const wchar_t * s, size_t count);
|
||||||
extern int wcsicmp(const wchar_t* cs,const wchar_t * ct);
|
extern int wcsicmp(const wchar_t* cs,const wchar_t * ct);
|
||||||
extern int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
|
extern int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Include machine specific inline routines
|
|
||||||
*/
|
|
||||||
//#ifndef _I386_STRING_H_
|
|
||||||
//#define _I386_STRING_H_
|
|
||||||
|
|
||||||
/*
|
|
||||||
* On a 486 or Pentium, we are better off not using the
|
|
||||||
* byte string operations. But on a 386 or a PPro the
|
|
||||||
* byte string ops are faster than doing it by hand
|
|
||||||
* (MUCH faster on a Pentium).
|
|
||||||
*
|
|
||||||
* Also, the byte strings actually work correctly. Forget
|
|
||||||
* the i486 routines for now as they may be broken..
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if FIXED_486_STRING && (CPU == 486 || CPU == 586)
|
|
||||||
#include <asm/string-486.h>
|
|
||||||
#else
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This string-include defines all string functions as inline
|
|
||||||
* functions. Use gcc. It also assumes ds=es=data space, this should be
|
|
||||||
* normal. Most of the string-functions are rather heavily hand-optimized,
|
|
||||||
* see especially wcstok,wcsstr,wcs[c]spn. They should work, but are not
|
|
||||||
* very easy to understand. Everything is done entirely within the register
|
|
||||||
* set, making the functions fast and clean. String instructions have been
|
|
||||||
* used through-out, making for "slightly" unclear code :-)
|
|
||||||
*
|
|
||||||
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSCPY
|
|
||||||
extern inline wchar_t * wcscpy(wchar_t * dest,const wchar_t *src)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n"
|
|
||||||
"1:\tlodsw\n\t"
|
|
||||||
"stosw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"jne 1b"
|
|
||||||
: /* no output */
|
|
||||||
:"S" (src),"D" (dest):"esi","edi","eax","memory");
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSNCPY
|
|
||||||
inline wchar_t * wcsncpy(wchar_t * dest,const wchar_t *src,size_t count)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n"
|
|
||||||
"1:\tdecl %2\n\t"
|
|
||||||
"js 2f\n\t"
|
|
||||||
"lodsw\n\t"
|
|
||||||
"stosw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"jne 1b\n\t"
|
|
||||||
"rep\n\t"
|
|
||||||
"stosw\n"
|
|
||||||
"2:"
|
|
||||||
: /* no output */
|
|
||||||
:"S" (src),"D" (dest),"c" (count):"esi","edi","eax","ecx","memory");
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSCAT
|
|
||||||
inline wchar_t * wcscat(wchar_t * dest,const wchar_t * src)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t"
|
|
||||||
"repnz\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"decl %1\n"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"1:\tlodsw\n\t"
|
|
||||||
"stosw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"jne 1b"
|
|
||||||
: /* no output */
|
|
||||||
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"esi","edi","eax","ecx");
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSNCAT
|
|
||||||
inline wchar_t * wcsncat(wchar_t * dest,const wchar_t * src,size_t count)
|
|
||||||
{
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t"
|
|
||||||
"repnz\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"movl %4,%3\n"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"1:\tdecl %3\n\t"
|
|
||||||
"js 2f\n\t"
|
|
||||||
"lodsw\n\t"
|
|
||||||
"stosw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"jne 1b\n"
|
|
||||||
"2:\txorl %2,%2\n\t"
|
|
||||||
"stosw"
|
|
||||||
: /* no output */
|
|
||||||
:"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count)
|
|
||||||
:"esi","edi","eax","ecx","memory");
|
|
||||||
return dest;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSCMP
|
|
||||||
inline int wcscmp(const wchar_t* cs,const wchar_t * ct)
|
|
||||||
{
|
|
||||||
register int __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n"
|
|
||||||
"1:\tlodsw\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"jne 2f\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"jne 1b\n\t"
|
|
||||||
"xorl %%eax,%%eax\n\t"
|
|
||||||
"jmp 3f\n"
|
|
||||||
"2:\tsbbl %%eax,%%eax\n\t"
|
|
||||||
"orw $1,%%eax\n"
|
|
||||||
"3:"
|
|
||||||
:"=a" (__res):"S" (cs),"D" (ct):"esi","edi");
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSNCMP
|
|
||||||
inline int wcsncmp(const wchar_t * cs,const wchar_t * ct,size_t count)
|
|
||||||
{
|
|
||||||
register int __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n"
|
|
||||||
"1:\tdecl %3\n\t"
|
|
||||||
"js 2f\n\t"
|
|
||||||
"lodsw\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"jne 3f\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"jne 1b\n"
|
|
||||||
"2:\txorl %%eax,%%eax\n\t"
|
|
||||||
"jmp 4f\n"
|
|
||||||
"3:\tsbbl %%eax,%%eax\n\t"
|
|
||||||
"orw $1,%%eax\n"
|
|
||||||
"4:"
|
|
||||||
:"=a" (__res):"S" (cs),"D" (ct),"c" (count):"esi","edi","ecx");
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSCHR
|
|
||||||
inline wchar_t * wcschr(const wchar_t * s, int c)
|
|
||||||
{
|
|
||||||
register wchar_t * __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t"
|
|
||||||
"movw %%eax,%%edx\n"
|
|
||||||
"1:\tlodsw\n\t"
|
|
||||||
"cmpw %%edx,%%eax\n\t"
|
|
||||||
"je 2f\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"jne 1b\n\t"
|
|
||||||
"movl $1,%1\n"
|
|
||||||
"2:\tmovl %1,%0\n\t"
|
|
||||||
"decl %0\n\t"
|
|
||||||
"decl %0\n\t"
|
|
||||||
:"=a" (__res):"S" (s),"0" (c):"esi");
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSRCHR
|
|
||||||
inline wchar_t * wcsrchr(const wchar_t * s, int c)
|
|
||||||
{
|
|
||||||
register wchar_t * __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t"
|
|
||||||
"movw %%eax,%%edx\n"
|
|
||||||
"1:\tlodsw\n\t"
|
|
||||||
"cmpw %%edx,%%eax\n\t"
|
|
||||||
"jne 2f\n\t"
|
|
||||||
"leal -2(%%esi),%0\n"
|
|
||||||
"2:\ttestw %%eax,%%eax\n\t"
|
|
||||||
"jne 1b"
|
|
||||||
:"=d" (__res):"0" (0),"S" (s),"a" (c):"eax","esi");
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSSPN
|
|
||||||
inline size_t wcsspn(const wchar_t * cs, const wchar_t * ct)
|
|
||||||
{
|
|
||||||
register wchar_t * __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"notl %%ecx\n\t"
|
|
||||||
"decl %%ecx\n\t"
|
|
||||||
"movl %%ecx,%%edx\n"
|
|
||||||
"1:\tlodsw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"je 2f\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"movl %%edx,%%ecx\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasb\n\t"
|
|
||||||
"je 1b\n"
|
|
||||||
"2:\tdecl %0"
|
|
||||||
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
|
|
||||||
:"eax","ecx","edx","edi");
|
|
||||||
return __res-cs;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSCSPN
|
|
||||||
inline size_t wcscspn(const wchar_t * cs, const wchar_t * ct)
|
|
||||||
{
|
|
||||||
register wchar_t * __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"notl %%ecx\n\t"
|
|
||||||
"decl %%ecx\n\t"
|
|
||||||
"movl %%ecx,%%edx\n"
|
|
||||||
"1:\tlodsw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"je 2f\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"movl %%edx,%%ecx\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"jne 1b\n"
|
|
||||||
"2:\tdecl %0"
|
|
||||||
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
|
|
||||||
:"eax","ecx","edx","edi");
|
|
||||||
return __res-cs;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_STRPBRK
|
|
||||||
inline wchar_t * wcspbrk(const wchar_t * cs,const wchar_t * ct)
|
|
||||||
{
|
|
||||||
register wchar_t * __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"notl %%ecx\n\t"
|
|
||||||
"decl %%ecx\n\t"
|
|
||||||
"movl %%ecx,%%edx\n"
|
|
||||||
"1:\tlodsw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"je 2f\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"movl %%edx,%%ecx\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"jne 1b\n\t"
|
|
||||||
"decl %0\n\t"
|
|
||||||
"jmp 3f\n"
|
|
||||||
"2:\txorl %0,%0\n"
|
|
||||||
"3:"
|
|
||||||
:"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct)
|
|
||||||
:"eax","ecx","edx","edi");
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSSTR
|
|
||||||
inline wchar_t * wcsstr(const wchar_t * cs,const wchar_t * ct)
|
|
||||||
{
|
|
||||||
register wchar_t * __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t" \
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"notl %%ecx\n\t"
|
|
||||||
"decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
|
|
||||||
"movl %%ecx,%%edx\n"
|
|
||||||
"1:\tmovl %4,%%edi\n\t"
|
|
||||||
"movl %%esi,%%eax\n\t"
|
|
||||||
"movl %%edx,%%ecx\n\t"
|
|
||||||
"repe\n\t"
|
|
||||||
"cmpsw\n\t"
|
|
||||||
"je 2f\n\t" /* also works for empty string, see above */
|
|
||||||
"xchgl %%eax,%%esi\n\t"
|
|
||||||
"incl %%esi\n\t"
|
|
||||||
"cmpw $0,-1(%%eax)\n\t"
|
|
||||||
"jne 1b\n\t"
|
|
||||||
"xorl %%eax,%%eax\n\t"
|
|
||||||
"2:"
|
|
||||||
:"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct)
|
|
||||||
:"ecx","edx","edi","esi");
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSLEN
|
|
||||||
inline size_t wcslen(const wchar_t * s)
|
|
||||||
{
|
|
||||||
register int __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"notl %0\n\t"
|
|
||||||
"decl %0"
|
|
||||||
:"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"edi");
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSTOK
|
|
||||||
|
|
||||||
|
|
||||||
inline wchar_t * wcstok(wchar_t * s,const wchar_t * ct)
|
|
||||||
{
|
|
||||||
|
|
||||||
register wchar_t * __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"testl %1,%1\n\t"
|
|
||||||
"jne 1f\n\t"
|
|
||||||
"testl %0,%0\n\t"
|
|
||||||
"je 8f\n\t"
|
|
||||||
"movl %0,%1\n"
|
|
||||||
"1:\txorl %0,%0\n\t"
|
|
||||||
"movl $-1,%%ecx\n\t"
|
|
||||||
"xorl %%eax,%%eax\n\t"
|
|
||||||
"cld\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"repnz\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"notl %%ecx\n\t"
|
|
||||||
"decl %%ecx\n\t"
|
|
||||||
"decl %%ecx\n\t"
|
|
||||||
"je 7f\n\t" /* empty delimiter-string */
|
|
||||||
"movl %%ecx,%%edx\n"
|
|
||||||
"2:\tlodsw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"je 7f\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"movl %%edx,%%ecx\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"je 2b\n\t"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"cmpw $0,(%1)\n\t"
|
|
||||||
"je 7f\n\t"
|
|
||||||
"movl %1,%0\n"
|
|
||||||
"3:\tlodsw\n\t"
|
|
||||||
"testw %%eax,%%eax\n\t"
|
|
||||||
"je 5f\n\t"
|
|
||||||
"movl %4,%%edi\n\t"
|
|
||||||
"movl %%edx,%%ecx\n\t"
|
|
||||||
"repne\n\t"
|
|
||||||
"scasw\n\t"
|
|
||||||
"jne 3b\n\t"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"decl %1\n\t"
|
|
||||||
"cmpw $0,(%1)\n\t"
|
|
||||||
"je 5f\n\t"
|
|
||||||
"movw $0,(%1)\n\t"
|
|
||||||
"incl %1\n\t"
|
|
||||||
"incl %1\n\t"
|
|
||||||
"jmp 6f\n"
|
|
||||||
"5:\txorl %1,%1\n"
|
|
||||||
"6:\tcmpw $0,(%0)\n\t"
|
|
||||||
"jne 7f\n\t"
|
|
||||||
"xorl %0,%0\n"
|
|
||||||
"7:\ttestl %0,%0\n\t"
|
|
||||||
"jne 8f\n\t"
|
|
||||||
"movl %0,%1\n"
|
|
||||||
"8:"
|
|
||||||
:"=b" (__res),"=S" (___wcstok)
|
|
||||||
:"0" (___wcstok),"1" (s),"g" (ct)
|
|
||||||
:"eax","ecx","edx","edi","memory");
|
|
||||||
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSNNLEN
|
|
||||||
inline size_t wcsnlen(const wchar_t * s, size_t count)
|
|
||||||
{
|
|
||||||
register int __res;
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"movl %1,%0\n\t"
|
|
||||||
"jmp 2f\n"
|
|
||||||
"1:\tcmpw $0,(%0)\n\t"
|
|
||||||
"je 3f\n\t"
|
|
||||||
"incl %0\n"
|
|
||||||
"2:\tdecl %2\n\t"
|
|
||||||
"cmpl $-1,%2\n\t"
|
|
||||||
"jne 1b\n"
|
|
||||||
"3:\tsubl %1,%0"
|
|
||||||
:"=a" (__res)
|
|
||||||
:"c" (s),"d" (count)
|
|
||||||
:"edx");
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSICMP
|
|
||||||
inline int wcsicmp(const wchar_t* cs,const wchar_t * ct)
|
|
||||||
{
|
|
||||||
register int __res;
|
|
||||||
|
|
||||||
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n"
|
|
||||||
"1:\tmovw (%%esi), %%eax\n\t"
|
|
||||||
"movw (%%edi), %%edx \n\t"
|
|
||||||
"cmpw $0x5A, %%eax\n\t"
|
|
||||||
"ja 2f\t\n"
|
|
||||||
"cmpw $0x40, %%eax\t\n"
|
|
||||||
"jbe 2f\t\n"
|
|
||||||
"addw $0x20, %%eax\t\n"
|
|
||||||
"2:\t cmpw $0x5A, %%edx\t\n"
|
|
||||||
"ja 3f\t\n"
|
|
||||||
"cmpw $0x40, %%edx\t\n"
|
|
||||||
"jbe 3f\t\n"
|
|
||||||
"addw $0x20, %%edx\t\n"
|
|
||||||
"3:\t inc %%esi\t\n"
|
|
||||||
"inc %%esi\t\n"
|
|
||||||
"inc %%edi\t\n"
|
|
||||||
"inc %%edi\t\n"
|
|
||||||
"cmpw %%eax, %%edx\t\n"
|
|
||||||
"jne 4f\n\t"
|
|
||||||
"cmpw $00, %%eax\n\t"
|
|
||||||
"jne 1b\n\t"
|
|
||||||
"xorl %%eax,%%eax\n\t"
|
|
||||||
"jmp 5f\n"
|
|
||||||
"4:\tsbbl %%eax,%%eax\n\t"
|
|
||||||
"orw $1,%%eax\n"
|
|
||||||
"5:"
|
|
||||||
:"=a" (__res):"S" (cs),"D" (ct):"esi","edi");
|
|
||||||
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define __HAVE_ARCH_WCSNICMP
|
|
||||||
inline int wcsnicmp(const wchar_t* cs,const wchar_t * ct, size_t count)
|
|
||||||
{
|
|
||||||
register int __res;
|
|
||||||
|
|
||||||
|
|
||||||
__asm__ __volatile__(
|
|
||||||
"cld\n"
|
|
||||||
"1:\t decl %3\n\t"
|
|
||||||
"js 6f\n\t"
|
|
||||||
"movw (%%esi), %%eax\n\t"
|
|
||||||
"movw (%%edi), %%edx \n\t"
|
|
||||||
"cmpw $0x5A, %%eax\n\t"
|
|
||||||
"ja 2f\t\n"
|
|
||||||
"cmpw $0x40, %%eax\t\n"
|
|
||||||
"jbe 2f\t\n"
|
|
||||||
"addw $0x20, %%eax\t\n"
|
|
||||||
"2:\t cmpw $0x5A, %%edx\t\n"
|
|
||||||
"ja 3f\t\n"
|
|
||||||
"cmpw $0x40, %%edx\t\n"
|
|
||||||
"jbe 3f\t\n"
|
|
||||||
"addw $0x20, %%edx\t\n"
|
|
||||||
"3:\t inc %%esi\t\n"
|
|
||||||
"inc %%esi\t\n"
|
|
||||||
"inc %%edi\t\n"
|
|
||||||
"inc %%edi\t\n"
|
|
||||||
"cmpw %%eax, %%edx\t\n"
|
|
||||||
"jne 4f\n\t"
|
|
||||||
"cmpw $00, %%eax\n\t"
|
|
||||||
"jne 1b\n\t"
|
|
||||||
"6:xorl %%eax,%%eax\n\t"
|
|
||||||
"jmp 5f\n"
|
|
||||||
"4:\tsbbl %%eax,%%eax\n\t"
|
|
||||||
"orw $1,%%eax\n"
|
|
||||||
"5:"
|
|
||||||
:"=a" (__res):"S" (cs),"D" (ct), "c" (count):"esi","edi", "ecx");
|
|
||||||
|
|
||||||
|
|
||||||
return __res;
|
|
||||||
}
|
|
||||||
|
|
||||||
//#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
free_page
|
||||||
|
get_dma_page
|
||||||
DbgPrint
|
DbgPrint
|
||||||
printk
|
printk
|
||||||
ExAcquireFastMutex
|
ExAcquireFastMutex
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top directory
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel v0.0.2
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: hal/page.cc
|
* FILE: ntoskrnl/hal/x86/page.c
|
||||||
* PURPOSE: low level memory managment manipulation
|
* PURPOSE: low level memory managment manipulation
|
||||||
* PROGRAMER: David Welch
|
* PROGRAMER: David Welch
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
|
|
@ -232,7 +232,40 @@ int bad_user_access_length(void)
|
||||||
|
|
||||||
ULONG DbgPrint(PCH Format, ...)
|
ULONG DbgPrint(PCH Format, ...)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
char buffer[256];
|
||||||
|
char* str=buffer;
|
||||||
|
va_list ap;
|
||||||
|
unsigned int eflags;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Because this is used by alomost every subsystem including irqs it
|
||||||
|
* must be atomic. The following code sequence disables interrupts after
|
||||||
|
* saving the previous state of the interrupt flag
|
||||||
|
*/
|
||||||
|
__asm__("pushf\n\tpop %0\n\tcli\n\t"
|
||||||
|
: "=m" (eflags)
|
||||||
|
: /* */);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Process the format string into a fixed length buffer using the
|
||||||
|
* standard C RTL function
|
||||||
|
*/
|
||||||
|
va_start(ap,Format);
|
||||||
|
vsprintf(buffer,Format,ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
while ((*str)!=0)
|
||||||
|
{
|
||||||
|
putchar(*str);
|
||||||
|
str++;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Restore the interrupt flag
|
||||||
|
*/
|
||||||
|
__asm__("push %0\n\tpopf\n\t"
|
||||||
|
:
|
||||||
|
: "m" (eflags));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitConsole(boot_param* bp)
|
void InitConsole(boot_param* bp)
|
||||||
|
|
|
@ -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/iomgr/create.cc
|
* FILE: ntoskrnl/io/create.c
|
||||||
* PURPOSE: Handling file create/open apis
|
* PURPOSE: Handling file create/open apis
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
#include <internal/kernel.h>
|
#include <internal/kernel.h>
|
||||||
#include <internal/objmgr.h>
|
#include <internal/objmgr.h>
|
||||||
#include <internal/iomgr.h>
|
#include <internal/iomgr.h>
|
||||||
|
#include <internal/string.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -43,59 +44,54 @@ NTSTATUS ZwOpenFile(PHANDLE FileHandle,
|
||||||
ULONG ShareAccess,
|
ULONG ShareAccess,
|
||||||
ULONG OpenOptions)
|
ULONG OpenOptions)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PVOID Object;
|
||||||
}
|
NTSTATUS Status;
|
||||||
|
|
||||||
HANDLE STDCALL CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess,
|
|
||||||
DWORD dwShareMode,
|
|
||||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
|
||||||
DWORD dwCreationDisposition,
|
|
||||||
DWORD dwFlagsAndAttributes,
|
|
||||||
HANDLE hTemplateFile)
|
|
||||||
{
|
|
||||||
PDEVICE_OBJECT DeviceObject;
|
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
HANDLE hfile;
|
KEVENT Event;
|
||||||
UNICODE_STRING filename;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
ANSI_STRING afilename;
|
PFILE_OBJECT FileObject;
|
||||||
|
PIO_STACK_LOCATION StackLoc;
|
||||||
|
|
||||||
RtlInitAnsiString(&afilename,lpFileName);
|
assert_irql(PASSIVE_LEVEL);
|
||||||
RtlAnsiStringToUnicodeString(&filename,&afilename,TRUE);
|
|
||||||
DeviceObject = ObLookupObject(NULL,&filename);
|
|
||||||
DPRINT("Sending IRP for IRP_MJ_CREATE to %x\n",DeviceObject);
|
|
||||||
if (DeviceObject==NULL)
|
|
||||||
{
|
|
||||||
DPRINT("(%s:%d) Object not found\n",__FILE__,__LINE__);
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
hfile = ObAddHandle(DeviceObject);
|
|
||||||
|
|
||||||
/*
|
*FileHandle=0;
|
||||||
* Tell the device we are openining it
|
|
||||||
*/
|
Status = ObOpenObjectByName(ObjectAttributes,&Object);
|
||||||
Irp = IoAllocateIrp(DeviceObject->StackSize, TRUE);
|
DPRINT("Object %x Status %x\n",Object,Status);
|
||||||
if (Irp==NULL)
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Preparing IRP\n");
|
DeviceObject = (PDEVICE_OBJECT)Object;
|
||||||
|
|
||||||
|
FileObject = ObGenericCreateObject(FileHandle,0,NULL,OBJTYP_FILE);
|
||||||
|
DPRINT("FileObject %x DeviceObject %x\n",FileObject,DeviceObject);
|
||||||
|
memset(FileObject,0,sizeof(FILE_OBJECT));
|
||||||
|
FileObject->DeviceObject=DeviceObject;
|
||||||
|
FileObject->Flags = FileObject->Flags | FO_DIRECT_DEVICE_OPEN;
|
||||||
|
|
||||||
/*
|
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||||
* Set up the stack location
|
|
||||||
*/
|
|
||||||
Irp->Stack[Irp->CurrentLocation].MajorFunction = IRP_MJ_CREATE;
|
|
||||||
Irp->Stack[Irp->CurrentLocation].MinorFunction = 0;
|
|
||||||
Irp->Stack[Irp->CurrentLocation].Flags = 0;
|
|
||||||
Irp->Stack[Irp->CurrentLocation].Control = 0;
|
|
||||||
Irp->Stack[Irp->CurrentLocation].DeviceObject = DeviceObject;
|
|
||||||
// Irp->Stack[Irp->StackPtr].FileObject = &files[hfile];
|
|
||||||
|
|
||||||
DPRINT("Sending IRP\n");
|
Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
|
||||||
|
if (Irp==NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
StackLoc = IoGetNextIrpStackLocation(Irp);
|
||||||
|
DPRINT("StackLoc %x\n",StackLoc);
|
||||||
|
StackLoc->MajorFunction = IRP_MJ_CREATE;
|
||||||
|
StackLoc->MinorFunction = 0;
|
||||||
|
StackLoc->Flags = 0;
|
||||||
|
StackLoc->Control = 0;
|
||||||
|
StackLoc->DeviceObject = DeviceObject;
|
||||||
|
StackLoc->FileObject=FileObject;
|
||||||
|
DPRINT("DeviceObject %x\n",DeviceObject);
|
||||||
|
DPRINT("DeviceObject->DriverObject %x\n",DeviceObject->DriverObject);
|
||||||
IoCallDriver(DeviceObject,Irp);
|
IoCallDriver(DeviceObject,Irp);
|
||||||
|
|
||||||
DPRINT("Returning %x\n",hfile);
|
return(STATUS_SUCCESS);
|
||||||
return(hfile);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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/iomgr/device.cc
|
* FILE: ntoskrnl/io/device.c
|
||||||
* PURPOSE: Manage devices
|
* PURPOSE: Manage devices
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
@ -22,6 +22,16 @@
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS ZwLoadDriver(PUNICODE_STRING DriverServiceName)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Loads a driver
|
||||||
|
* ARGUMENTS:
|
||||||
|
* DriverServiceName = Name of the service to load (registry key)
|
||||||
|
* RETURNS: Status
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS IoAttachDeviceByPointer(PDEVICE_OBJECT SourceDevice,
|
NTSTATUS IoAttachDeviceByPointer(PDEVICE_OBJECT SourceDevice,
|
||||||
PDEVICE_OBJECT TargetDevice)
|
PDEVICE_OBJECT TargetDevice)
|
||||||
{
|
{
|
||||||
|
@ -143,7 +153,10 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||||
PDEVICE_OBJECT dev;
|
PDEVICE_OBJECT dev;
|
||||||
OBJECT_ATTRIBUTES dev_attr;
|
OBJECT_ATTRIBUTES dev_attr;
|
||||||
HANDLE devh;
|
HANDLE devh;
|
||||||
|
|
||||||
|
DPRINT("IoCreateDevice(DriverObject %x, DeviceName %w)\n",DriverObject,
|
||||||
|
DeviceName->Buffer);
|
||||||
|
|
||||||
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
|
InitializeObjectAttributes(&dev_attr,DeviceName,0,NULL,NULL);
|
||||||
dev = ObGenericCreateObject(&devh,0,&dev_attr,OBJTYP_DEVICE);
|
dev = ObGenericCreateObject(&devh,0,&dev_attr,OBJTYP_DEVICE);
|
||||||
|
|
||||||
|
@ -166,6 +179,9 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->DriverObject = DriverObject;
|
dev->DriverObject = DriverObject;
|
||||||
|
DPRINT("dev %x\n",dev);
|
||||||
|
DPRINT("dev->DriverObject %x\n",dev->DriverObject);
|
||||||
|
|
||||||
dev->CurrentIrp=NULL;
|
dev->CurrentIrp=NULL;
|
||||||
dev->Flags=0;
|
dev->Flags=0;
|
||||||
|
|
||||||
|
@ -181,6 +197,7 @@ NTSTATUS IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||||
dev->AlignmentRequirement=1;
|
dev->AlignmentRequirement=1;
|
||||||
|
|
||||||
*DeviceObject=dev;
|
*DeviceObject=dev;
|
||||||
|
DPRINT("dev->DriverObject %x\n",dev->DriverObject);
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
OBJECT_TYPE DeviceObjectType = {{NULL,0,0},
|
OBJECT_TYPE DeviceObjectType = {{0,0,NULL},
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
ULONG_MAX,
|
ULONG_MAX,
|
||||||
|
@ -33,6 +33,23 @@ OBJECT_TYPE DeviceObjectType = {{NULL,0,0},
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
OBJECT_TYPE FileObjectType = {{0,0,NULL},
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
ULONG_MAX,
|
||||||
|
ULONG_MAX,
|
||||||
|
sizeof(FILE_OBJECT),
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
@ -44,12 +61,25 @@ VOID IoInit(VOID)
|
||||||
UNICODE_STRING string;
|
UNICODE_STRING string;
|
||||||
ANSI_STRING astring;
|
ANSI_STRING astring;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Register iomgr types
|
||||||
|
*/
|
||||||
|
RtlInitAnsiString(&astring,"Device");
|
||||||
|
RtlAnsiStringToUnicodeString(&DeviceObjectType.TypeName,&astring,TRUE);
|
||||||
ObRegisterType(OBJTYP_DEVICE,&DeviceObjectType);
|
ObRegisterType(OBJTYP_DEVICE,&DeviceObjectType);
|
||||||
|
|
||||||
|
RtlInitAnsiString(&astring,"File");
|
||||||
|
RtlAnsiStringToUnicodeString(&FileObjectType.TypeName,&astring,TRUE);
|
||||||
|
ObRegisterType(OBJTYP_FILE,&FileObjectType);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the device directory
|
||||||
|
*/
|
||||||
RtlInitAnsiString(&astring,"\\Device");
|
RtlInitAnsiString(&astring,"\\Device");
|
||||||
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
|
RtlAnsiStringToUnicodeString(&string,&astring,TRUE);
|
||||||
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
|
InitializeObjectAttributes(&attr,&string,0,NULL,NULL);
|
||||||
ZwCreateDirectoryObject(&handle,0,&attr);
|
ZwCreateDirectoryObject(&handle,0,&attr);
|
||||||
|
|
||||||
IoInitCancelHandling();
|
IoInitCancelHandling();
|
||||||
|
IoInitSymbolicLinkImplementation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,8 +89,75 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
PLARGE_INTEGER StartingOffset,
|
PLARGE_INTEGER StartingOffset,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock)
|
PIO_STATUS_BLOCK IoStatusBlock)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Allocates and sets up an IRP to be sent to lower level drivers
|
||||||
|
* ARGUMENTS:
|
||||||
|
* MajorFunction = One of IRP_MJ_READ, IRP_MJ_WRITE,
|
||||||
|
* IRP_MJ_FLUSH_BUFFERS or IRP_MJ_SHUTDOWN
|
||||||
|
* DeviceObject = Device object to send the irp to
|
||||||
|
* Buffer = Buffer into which data will be read or written
|
||||||
|
* Length = Length in bytes of the irp to be allocated
|
||||||
|
* StartingOffset = Starting offset on the device
|
||||||
|
* IoStatusBlock (OUT) = Storage for the result of the operation
|
||||||
|
* RETURNS: The IRP allocated on success, or
|
||||||
|
* NULL on failure
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
|
||||||
|
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
||||||
|
if (Irp==NULL)
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Irp->UserBuffer = (LPVOID)Buffer;
|
||||||
|
if (DeviceObject->Flags&DO_BUFFERED_IO)
|
||||||
|
{
|
||||||
|
DPRINT("Doing buffer i/o\n",0);
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
|
ExAllocatePool(NonPagedPool,Length);
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
Irp->UserBuffer = NULL;
|
||||||
|
}
|
||||||
|
if (DeviceObject->Flags&DO_DIRECT_IO)
|
||||||
|
{
|
||||||
|
DPRINT("Doing direct i/o\n",0);
|
||||||
|
|
||||||
|
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
|
||||||
|
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
||||||
|
Irp->UserBuffer = NULL;
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Irp->UserIosb = IoStatusBlock;
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->MajorFunction = MajorFunction;
|
||||||
|
StackPtr->MinorFunction = 0;
|
||||||
|
StackPtr->Flags = 0;
|
||||||
|
StackPtr->Control = 0;
|
||||||
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->Parameters.Write.Length = Length;
|
||||||
|
if (StartingOffset!=NULL)
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.LowPart =
|
||||||
|
StartingOffset->LowPart;
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.HighPart =
|
||||||
|
StartingOffset->HighPart;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
||||||
|
@ -113,29 +180,78 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
||||||
PLARGE_INTEGER StartingOffset,
|
PLARGE_INTEGER StartingOffset,
|
||||||
PKEVENT Event,
|
PKEVENT Event,
|
||||||
PIO_STATUS_BLOCK IoStatusBlock)
|
PIO_STATUS_BLOCK IoStatusBlock)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Allocates and builds an IRP to be sent synchronously to lower
|
||||||
|
* level driver(s)
|
||||||
|
* ARGUMENTS:
|
||||||
|
* MajorFunction = Major function code, one of IRP_MJ_READ,
|
||||||
|
* IRP_MJ_WRITE, IRP_MJ_FLUSH_BUFFERS, IRP_MJ_SHUTDOWN
|
||||||
|
* DeviceObject = Target device object
|
||||||
|
* Buffer = Buffer containing data for a read or write
|
||||||
|
* Length = Length in bytes of the information to be transferred
|
||||||
|
* StartingOffset = Offset to begin the read/write from
|
||||||
|
* Event (OUT) = Will be set when the operation is complete
|
||||||
|
* IoStatusBlock (OUT) = Set to the status of the operation
|
||||||
|
* RETURNS: The IRP allocated on success, or
|
||||||
|
* NULL on failure
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
PDRIVER_OBJECT DriverObject = DeviceObject->DriverObject;
|
PIRP Irp;
|
||||||
PIRP irp;
|
|
||||||
PIO_STACK_LOCATION StackPtr;
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
|
||||||
/*
|
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
||||||
* Allocate an IRP for the transfer
|
if (Irp==NULL)
|
||||||
*/
|
|
||||||
irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
|
||||||
if (irp==NULL)
|
|
||||||
{
|
{
|
||||||
printk("Failed to allocate IRP\n");
|
return(NULL);
|
||||||
return(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
Irp->UserBuffer = (LPVOID)Buffer;
|
||||||
* Prepare the parameter in the next IO stack location
|
if (DeviceObject->Flags&DO_BUFFERED_IO)
|
||||||
*/
|
{
|
||||||
StackPtr = IoGetNextIrpStackLocation(irp);
|
DPRINT("Doing buffer i/o\n",0);
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
|
ExAllocatePool(NonPagedPool,Length);
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
Irp->UserBuffer = NULL;
|
||||||
|
}
|
||||||
|
if (DeviceObject->Flags&DO_DIRECT_IO)
|
||||||
|
{
|
||||||
|
DPRINT("Doing direct i/o\n",0);
|
||||||
|
|
||||||
|
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
|
||||||
|
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
||||||
|
Irp->UserBuffer = NULL;
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Irp->UserIosb = IoStatusBlock;
|
||||||
|
Irp->UserEvent = Event;
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
StackPtr->MajorFunction = MajorFunction;
|
StackPtr->MajorFunction = MajorFunction;
|
||||||
StackPtr->MinorFunction = 0;
|
StackPtr->MinorFunction = 0;
|
||||||
StackPtr->Flags = 0;
|
StackPtr->Flags = 0;
|
||||||
StackPtr->Control = 0;
|
StackPtr->Control = 0;
|
||||||
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->Parameters.Write.Length = Length;
|
||||||
|
if (StartingOffset!=NULL)
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.LowPart =
|
||||||
|
StartingOffset->LowPart;
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.HighPart =
|
||||||
|
StartingOffset->HighPart;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
USHORT IoSizeOfIrp(CCHAR StackSize)
|
USHORT IoSizeOfIrp(CCHAR StackSize)
|
||||||
|
@ -204,13 +320,15 @@ NTSTATUS IoCallDriver(PDEVICE_OBJECT DevObject, PIRP irp)
|
||||||
{
|
{
|
||||||
PDRIVER_OBJECT drv = DevObject->DriverObject;
|
PDRIVER_OBJECT drv = DevObject->DriverObject;
|
||||||
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(irp);
|
IO_STACK_LOCATION* param = IoGetNextIrpStackLocation(irp);
|
||||||
|
DPRINT("Deviceobject %x\n",DevObject);
|
||||||
|
DPRINT("Irp %x\n",irp);
|
||||||
irp->Tail.Overlay.CurrentStackLocation--;
|
irp->Tail.Overlay.CurrentStackLocation--;
|
||||||
irp->CurrentLocation--;
|
irp->CurrentLocation--;
|
||||||
DPRINT("Io stack address %x\n",param);
|
DPRINT("Io stack address %x\n",param);
|
||||||
DPRINT("Function %d Routine %x\n",param->MajorFunction,
|
DPRINT("Function %d Routine %x\n",param->MajorFunction,
|
||||||
drv->MajorFunction[param->MajorFunction]);
|
drv->MajorFunction[param->MajorFunction]);
|
||||||
DPRINT("IRP_MJ_CREATE %d\n",IRP_MJ_CREATE);
|
DPRINT("IRP_MJ_CREATE %d\n",IRP_MJ_CREATE);
|
||||||
|
|
||||||
return(drv->MajorFunction[param->MajorFunction](DevObject,irp));
|
return(drv->MajorFunction[param->MajorFunction](DevObject,irp));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +390,7 @@ VOID IoSetCompletionRoutine(PIRP Irp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID IoCompleteRequest(IRP* Irp, CCHAR PriorityBoost)
|
VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Indicates the caller has finished all processing for a given
|
* FUNCTION: Indicates the caller has finished all processing for a given
|
||||||
* I/O request and is returning the given IRP to the I/O manager
|
* I/O request and is returning the given IRP to the I/O manager
|
||||||
|
@ -282,9 +400,15 @@ VOID IoCompleteRequest(IRP* Irp, CCHAR PriorityBoost)
|
||||||
* thread making the request
|
* thread making the request
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i=0;
|
||||||
|
unsigned int stack_size;
|
||||||
|
|
||||||
for (i=0;i<0;i++)
|
DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d)\n",
|
||||||
|
Irp,PriorityBoost);
|
||||||
|
DPRINT("Irp->Stack[i].DeviceObject->StackSize %x\n",
|
||||||
|
Irp->Stack[i].DeviceObject->StackSize);
|
||||||
|
stack_size = Irp->Stack[i].DeviceObject->StackSize;
|
||||||
|
for (i=0;i<stack_size;i++)
|
||||||
{
|
{
|
||||||
if (Irp->Stack[i].CompletionRoutine!=NULL)
|
if (Irp->Stack[i].CompletionRoutine!=NULL)
|
||||||
{
|
{
|
||||||
|
@ -292,4 +416,17 @@ VOID IoCompleteRequest(IRP* Irp, CCHAR PriorityBoost)
|
||||||
Irp->Stack[i].CompletionContext);
|
Irp->Stack[i].CompletionContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Irp->UserEvent!=NULL)
|
||||||
|
{
|
||||||
|
KeSetEvent(Irp->UserEvent,PriorityBoost,FALSE);
|
||||||
|
}
|
||||||
|
if (Irp->UserIosb!=NULL)
|
||||||
|
{
|
||||||
|
*Irp->UserIosb=Irp->IoStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -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: kernel/base/bug.c
|
* FILE: ntoskrnl/io/mdl.c
|
||||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
* PURPOSE: Io manager mdl functions
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
|
@ -62,7 +62,7 @@ VOID IoBuildPartialMdl(PMDL SourceMdl,
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID IoFreeMdl(PMDL Mdl)
|
VOID IoFreeMdl(PMDL Mdl)
|
||||||
{
|
{
|
||||||
MmUnmapLockedPages(MmGetSystemAddressForMdl(Mdl),Mdl);
|
MmUnmapLockedPages(MmGetSystemAddressForMdl(Mdl),Mdl);
|
||||||
MmUnlockPages(Mdl);
|
MmUnlockPages(Mdl);
|
||||||
ExFreePool(Mdl);
|
ExFreePool(Mdl);
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
#include <internal/objmgr.h>
|
#include <internal/objmgr.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
@ -38,191 +38,157 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||||
PLARGE_INTEGER ByteOffset,
|
PLARGE_INTEGER ByteOffset,
|
||||||
PULONG Key)
|
PULONG Key)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(FileHandle);
|
||||||
}
|
PFILE_OBJECT FileObject = (PFILE_OBJECT)hdr;
|
||||||
|
PIRP Irp;
|
||||||
NTSTATUS ZwWriteFile(HANDLE FileHandle,
|
|
||||||
HANDLE Event,
|
|
||||||
PIO_APC_ROUTINE ApcRoutine,
|
|
||||||
PVOID ApcContext,
|
|
||||||
PIO_STATUS_BLOCK IoStatusBlock,
|
|
||||||
PVOID Buffer,
|
|
||||||
ULONG Length,
|
|
||||||
PLARGE_INTEGER ByteOffset,
|
|
||||||
PULONG Key)
|
|
||||||
{
|
|
||||||
UNIMPLEMENTED;
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL WriteDevice(PDEVICE_OBJECT dev, LPVOID lpBuffer,
|
|
||||||
DWORD nNumberOfBytesToWrite,
|
|
||||||
LPDWORD lpNumberOfBytesWritten,
|
|
||||||
LPOVERLAPPED lpOverlapped)
|
|
||||||
{
|
|
||||||
PDRIVER_OBJECT drv = dev->DriverObject;
|
|
||||||
PIRP irp;
|
|
||||||
PIO_STACK_LOCATION StackPtr;
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
|
||||||
DPRINT("dev %x drv %x\n",dev,drv);
|
if (hdr==NULL)
|
||||||
|
|
||||||
/*
|
|
||||||
* Build an irp for the transfer
|
|
||||||
*/
|
|
||||||
irp = IoAllocateIrp(dev->StackSize,TRUE);
|
|
||||||
if (irp==NULL)
|
|
||||||
{
|
{
|
||||||
printk("Failed to allocate IRP\n");
|
return(STATUS_INVALID_HANDLE);
|
||||||
return(FALSE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize,TRUE);
|
||||||
* Prepare the user buffer
|
if (Irp==NULL)
|
||||||
*/
|
{
|
||||||
DPRINT1("Preparing user buffer\n");
|
return(STATUS_UNSUCCESSFUL);
|
||||||
irp->UserBuffer = (LPVOID)lpBuffer; // This handles the 'neither' method
|
}
|
||||||
if (dev->Flags&DO_BUFFERED_IO)
|
|
||||||
|
Irp->UserBuffer = (LPVOID)Buffer;
|
||||||
|
if (FileObject->DeviceObject->Flags&DO_BUFFERED_IO)
|
||||||
{
|
{
|
||||||
DPRINT1("Doing buffer i/o\n");
|
DPRINT1("Doing buffer i/o\n");
|
||||||
irp->AssociatedIrp.SystemBuffer = (PVOID)
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
ExAllocatePool(NonPagedPool,nNumberOfBytesToWrite);
|
ExAllocatePool(NonPagedPool,Length);
|
||||||
if (irp->AssociatedIrp.SystemBuffer==NULL)
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
{
|
{
|
||||||
return(FALSE);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
memcpy(irp->AssociatedIrp.SystemBuffer,lpBuffer,nNumberOfBytesToWrite);
|
Irp->UserBuffer = NULL;
|
||||||
irp->UserBuffer = NULL;
|
|
||||||
}
|
}
|
||||||
if (dev->Flags&DO_DIRECT_IO)
|
if (FileObject->DeviceObject->Flags&DO_DIRECT_IO)
|
||||||
{
|
{
|
||||||
DPRINT1("Doing direct i/o\n");
|
DPRINT1("Doing direct i/o\n");
|
||||||
|
|
||||||
irp->MdlAddress = MmCreateMdl(NULL,lpBuffer,nNumberOfBytesToWrite);
|
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
|
||||||
MmProbeAndLockPages(irp->MdlAddress,UserMode,IoWriteAccess);
|
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
||||||
irp->UserBuffer = NULL;
|
Irp->UserBuffer = NULL;
|
||||||
irp->AssociatedIrp.SystemBuffer = NULL;
|
Irp->AssociatedIrp.SystemBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
* Set up the stack location
|
DPRINT("StackPtr %x\n",StackPtr);
|
||||||
*/
|
|
||||||
StackPtr = IoGetNextIrpStackLocation(irp);
|
|
||||||
StackPtr->MajorFunction = IRP_MJ_WRITE;
|
|
||||||
StackPtr->MinorFunction = 0;
|
|
||||||
StackPtr->Flags = 0;
|
|
||||||
StackPtr->Control = 0;
|
|
||||||
StackPtr->DeviceObject = dev;
|
|
||||||
StackPtr->FileObject = NULL;
|
|
||||||
StackPtr->Parameters.Write.Length = nNumberOfBytesToWrite;
|
|
||||||
|
|
||||||
DPRINT1("Sending IRP\n");
|
|
||||||
IoCallDriver(dev,irp);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Free the above buffer
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
WINBOOL STDCALL WriteFile(HANDLE hFile, LPCVOID lpBuffer,
|
|
||||||
DWORD nNumberOfBytesToWrite,
|
|
||||||
LPDWORD lpNumberOfBytesWritten,
|
|
||||||
LPOVERLAPPED lpOverlapped)
|
|
||||||
{
|
|
||||||
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(hFile);
|
|
||||||
|
|
||||||
if (hdr->Type==OBJTYP_DEVICE)
|
|
||||||
{
|
|
||||||
return(WriteDevice(hdr,lpBuffer,nNumberOfBytesToWrite,
|
|
||||||
lpNumberOfBytesWritten,lpOverlapped));
|
|
||||||
}
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
static BOOL ReadDevice(PDEVICE_OBJECT dev, LPVOID lpBuffer,
|
|
||||||
DWORD nNumberOfBytesToWrite,
|
|
||||||
LPDWORD lpNumberOfBytesWritten,
|
|
||||||
LPOVERLAPPED lpOverlapped)
|
|
||||||
{
|
|
||||||
PDRIVER_OBJECT drv = dev->DriverObject;
|
|
||||||
PIRP irp;
|
|
||||||
PIO_STACK_LOCATION StackPtr;
|
|
||||||
|
|
||||||
DPRINT("dev %x drv %x\n",dev,drv);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Build an irp for the transfer
|
|
||||||
*/
|
|
||||||
irp = IoAllocateIrp(dev->StackSize,TRUE);
|
|
||||||
if (irp==NULL)
|
|
||||||
{
|
|
||||||
printk("Failed to allocate IRP\n");
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Prepare the user buffer
|
|
||||||
*/
|
|
||||||
DPRINT1("Preparing user buffer\n");
|
|
||||||
irp->UserBuffer = (LPVOID)lpBuffer; // This handles the 'neither' method
|
|
||||||
if (dev->Flags&DO_BUFFERED_IO)
|
|
||||||
{
|
|
||||||
DPRINT1("Doing buffer i/o\n");
|
|
||||||
irp->AssociatedIrp.SystemBuffer = (PVOID)
|
|
||||||
ExAllocatePool(NonPagedPool,nNumberOfBytesToWrite);
|
|
||||||
if (irp->AssociatedIrp.SystemBuffer==NULL)
|
|
||||||
{
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
memcpy(irp->AssociatedIrp.SystemBuffer,lpBuffer,nNumberOfBytesToWrite);
|
|
||||||
irp->UserBuffer = NULL;
|
|
||||||
}
|
|
||||||
if (dev->Flags&DO_DIRECT_IO)
|
|
||||||
{
|
|
||||||
DPRINT1("Doing direct i/o\n");
|
|
||||||
|
|
||||||
irp->MdlAddress = MmCreateMdl(NULL,lpBuffer,nNumberOfBytesToWrite);
|
|
||||||
MmProbeAndLockPages(irp->MdlAddress,UserMode,IoWriteAccess);
|
|
||||||
irp->UserBuffer = NULL;
|
|
||||||
irp->AssociatedIrp.SystemBuffer = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set up the stack location
|
|
||||||
*/
|
|
||||||
StackPtr = IoGetNextIrpStackLocation(irp);
|
|
||||||
StackPtr->MajorFunction = IRP_MJ_READ;
|
StackPtr->MajorFunction = IRP_MJ_READ;
|
||||||
StackPtr->MinorFunction = 0;
|
StackPtr->MinorFunction = 0;
|
||||||
StackPtr->Flags = 0;
|
StackPtr->Flags = 0;
|
||||||
StackPtr->Control = 0;
|
StackPtr->Control = 0;
|
||||||
StackPtr->DeviceObject = dev;
|
StackPtr->DeviceObject = FileObject->DeviceObject;
|
||||||
StackPtr->FileObject = NULL;
|
StackPtr->FileObject = FileObject;
|
||||||
StackPtr->Parameters.Write.Length = nNumberOfBytesToWrite;
|
StackPtr->Parameters.Write.Length = Length;
|
||||||
|
if (ByteOffset!=NULL)
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.LowPart = ByteOffset->LowPart;
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.HighPart = ByteOffset->HighPart;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
|
||||||
|
}
|
||||||
|
if (Key!=NULL)
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.Key = *Key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.Key = 0;
|
||||||
|
}
|
||||||
|
|
||||||
DPRINT1("Sending IRP\n");
|
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||||
IoCallDriver(dev,irp);
|
IoCallDriver(FileObject->DeviceObject,Irp);
|
||||||
|
memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
/*
|
|
||||||
* Free the above buffer
|
|
||||||
*/
|
|
||||||
DPRINT1("Finished ReadDevice\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS ZwWriteFile(HANDLE FileHandle,
|
||||||
|
HANDLE Event,
|
||||||
WINBOOL STDCALL ReadFile(HANDLE hFile, LPVOID lpBuffer,
|
PIO_APC_ROUTINE ApcRoutine,
|
||||||
DWORD nNumberOfBytesToWrite,
|
PVOID ApcContext,
|
||||||
LPDWORD lpNumberOfBytesWritten,
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
LPOVERLAPPED lpOverlapped)
|
PVOID Buffer,
|
||||||
|
ULONG Length,
|
||||||
|
PLARGE_INTEGER ByteOffset,
|
||||||
|
PULONG Key)
|
||||||
{
|
{
|
||||||
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(hFile);
|
COMMON_BODY_HEADER* hdr = ObGetObjectByHandle(FileHandle);
|
||||||
|
PFILE_OBJECT FileObject = (PFILE_OBJECT)hdr;
|
||||||
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
|
||||||
if (hdr->Type==OBJTYP_DEVICE)
|
if (hdr==NULL)
|
||||||
{
|
{
|
||||||
return(ReadDevice((PDEVICE_OBJECT)hdr,lpBuffer,nNumberOfBytesToWrite,
|
return(STATUS_INVALID_HANDLE);
|
||||||
lpNumberOfBytesWritten,lpOverlapped));
|
|
||||||
}
|
}
|
||||||
return(FALSE);
|
|
||||||
|
Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize,TRUE);
|
||||||
|
if (Irp==NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Irp->UserBuffer = (LPVOID)Buffer;
|
||||||
|
if (FileObject->DeviceObject->Flags&DO_BUFFERED_IO)
|
||||||
|
{
|
||||||
|
DPRINT1("Doing buffer i/o\n");
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||||
|
ExAllocatePool(NonPagedPool,Length);
|
||||||
|
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
memcpy(Irp->AssociatedIrp.SystemBuffer,Buffer,Length);
|
||||||
|
Irp->UserBuffer = NULL;
|
||||||
|
}
|
||||||
|
if (FileObject->DeviceObject->Flags&DO_DIRECT_IO)
|
||||||
|
{
|
||||||
|
DPRINT1("Doing direct i/o\n");
|
||||||
|
|
||||||
|
Irp->MdlAddress = MmCreateMdl(NULL,Buffer,Length);
|
||||||
|
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoReadAccess);
|
||||||
|
Irp->UserBuffer = NULL;
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
DPRINT("StackPtr %x\n",StackPtr);
|
||||||
|
StackPtr->MajorFunction = IRP_MJ_WRITE;
|
||||||
|
StackPtr->MinorFunction = 0;
|
||||||
|
StackPtr->Flags = 0;
|
||||||
|
StackPtr->Control = 0;
|
||||||
|
StackPtr->DeviceObject = FileObject->DeviceObject;
|
||||||
|
StackPtr->FileObject = FileObject;
|
||||||
|
StackPtr->Parameters.Write.Length = Length;
|
||||||
|
if (ByteOffset!=NULL)
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.LowPart = ByteOffset->LowPart;
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.HighPart = ByteOffset->HighPart;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
|
||||||
|
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
|
||||||
|
}
|
||||||
|
if (Key!=NULL)
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.Key = *Key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.Write.Key = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||||
|
IoCallDriver(FileObject->DeviceObject,Irp);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/iomgr/symlink.c
|
* FILE: ntoskrnl/io/symlink.c
|
||||||
* PURPOSE: Implements symbolic links
|
* PURPOSE: Implements symbolic links
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
@ -16,12 +16,41 @@
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
PVOID Target;
|
||||||
|
} SYMBOLIC_LINK_OBJECT;
|
||||||
|
|
||||||
|
OBJECT_TYPE SymlinkObjectType = {{NULL,0,0},
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
ULONG_MAX,
|
||||||
|
ULONG_MAX,
|
||||||
|
sizeof(SYMBOLIC_LINK_OBJECT),
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID IoInitSymbolicLinkImplementation(VOID)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
NTSTATUS IoCreateUnprotectedSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
||||||
PUNICODE_STRING DeviceName)
|
PUNICODE_STRING DeviceName)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
return(IoCreateSymbolicLink(SymbolicLinkName,DeviceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
NTSTATUS IoCreateSymbolicLink(PUNICODE_STRING SymbolicLinkName,
|
||||||
|
|
|
@ -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: kernel/iomgr/timer.c
|
* FILE: ntoskrnl/io/timer.c
|
||||||
* PURPOSE: IO timers
|
* PURPOSE: io timers
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
|
|
|
@ -13,8 +13,47 @@
|
||||||
#include <internal/kernel.h>
|
#include <internal/kernel.h>
|
||||||
#include <internal/linkage.h>
|
#include <internal/linkage.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/string.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
VOID KeDrainApcQueue(VOID)
|
||||||
|
{
|
||||||
|
PLIST_ENTRY current_entry;
|
||||||
|
PKAPC current;
|
||||||
|
|
||||||
|
current_entry = KeGetCurrentThread()->ApcQueueHead.Flink;
|
||||||
|
while (current_entry!=NULL)
|
||||||
|
{
|
||||||
|
current = CONTAINING_RECORD(current_entry,KAPC,ApcListEntry);
|
||||||
|
current->NormalRoutine(current->NormalContext,
|
||||||
|
current->SystemArgument1,
|
||||||
|
current->SystemArgument2);
|
||||||
|
current_entry = current_entry->Flink;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID KeInitializeApc(PKAPC Apc, PKNORMAL_ROUTINE NormalRoutine,
|
||||||
|
PVOID NormalContext,
|
||||||
|
PKTHREAD TargetThread)
|
||||||
|
{
|
||||||
|
memset(Apc,0,sizeof(KAPC));
|
||||||
|
Apc->Thread = TargetThread;
|
||||||
|
Apc->NormalRoutine=NormalRoutine;
|
||||||
|
Apc->NormalContext=NormalContext;
|
||||||
|
Apc->Inserted=FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN KeInsertQueueApc(PKAPC Apc)
|
||||||
|
{
|
||||||
|
if (Apc->Inserted)
|
||||||
|
{
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
Apc->Inserted=TRUE;
|
||||||
|
InsertTailList(&Apc->Thread->ApcQueueHead,&Apc->ApcListEntry);
|
||||||
|
return(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/base/bug.c
|
* FILE: ntoskrnl/ke/bug.c
|
||||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
* PURPOSE: Graceful system shutdown if a bug is detected
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
void free_page(void);
|
||||||
|
void get_dma_page(void);
|
||||||
void DbgPrint(void);
|
void DbgPrint(void);
|
||||||
void printk(void);
|
void printk(void);
|
||||||
void ExAcquireFastMutex(void);
|
void ExAcquireFastMutex(void);
|
||||||
|
@ -378,6 +380,8 @@ void sprintf(void);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
export symbol_table[]={
|
export symbol_table[]={
|
||||||
|
{"_free_page",(unsigned int)free_page},
|
||||||
|
{"_get_dma_page",(unsigned int)get_dma_page},
|
||||||
{"_DbgPrint",(unsigned int)DbgPrint},
|
{"_DbgPrint",(unsigned int)DbgPrint},
|
||||||
{"_printk",(unsigned int)printk},
|
{"_printk",(unsigned int)printk},
|
||||||
{"_ExAcquireFastMutex",(unsigned int)ExAcquireFastMutex},
|
{"_ExAcquireFastMutex",(unsigned int)ExAcquireFastMutex},
|
||||||
|
|
|
@ -8,7 +8,8 @@ include hal/x86/sources
|
||||||
|
|
||||||
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 \
|
||||||
rtl/list.o rtl/slist.o rtl/interlck.o
|
rtl/list.o rtl/slist.o rtl/interlck.o rtl/return.o \
|
||||||
|
rtl/wstring.o
|
||||||
|
|
||||||
KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o ke/exports.o \
|
KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o ke/exports.o \
|
||||||
ke/module.o ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
|
ke/module.o ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
|
||||||
|
@ -24,13 +25,15 @@ IO_OBJECTS = io/iomgr.o io/create.o io/irp.o io/device.o io/rw.o \
|
||||||
io/queue.o io/drvlck.o io/timer.o io/share.o io/errlog.o \
|
io/queue.o io/drvlck.o io/timer.o io/share.o io/errlog.o \
|
||||||
io/shutdown.o io/fdisk.o io/cancel.o io/error.o io/arc.o \
|
io/shutdown.o io/fdisk.o io/cancel.o io/error.o io/arc.o \
|
||||||
io/dpc.o io/symlink.o io/adapter.o io/cntrller.o io/mdl.o \
|
io/dpc.o io/symlink.o io/adapter.o io/cntrller.o io/mdl.o \
|
||||||
io/resource.o io/event.o io/process.o io/file.o io/ioctrl.o
|
io/resource.o io/event.o io/process.o io/file.o io/ioctrl.o \
|
||||||
|
io/fs.o
|
||||||
|
|
||||||
OB_OBJECTS = ob/object.o ob/handle.o ob/namespc.o
|
OB_OBJECTS = ob/object.o ob/handle.o ob/namespc.o
|
||||||
|
|
||||||
PS_OBJECTS = ps/psmgr.o ps/thread.o ps/process.o
|
PS_OBJECTS = ps/psmgr.o ps/thread.o ps/process.o
|
||||||
|
|
||||||
EX_OBJECTS = ex/work.o ex/fmutex.o ex/resource.o ex/time.o ex/interlck.o
|
EX_OBJECTS = ex/work.o ex/fmutex.o ex/resource.o ex/time.o ex/interlck.o \
|
||||||
|
ex/callback.o
|
||||||
|
|
||||||
SE_OBJECTS = se/semgr.o
|
SE_OBJECTS = se/semgr.o
|
||||||
|
|
||||||
|
@ -38,10 +41,14 @@ CFG_OBJECTS = cfg/registry.o
|
||||||
|
|
||||||
TST_OBJECTS = tst/test.o
|
TST_OBJECTS = tst/test.o
|
||||||
|
|
||||||
|
DBG_OBJECTS = dbg/brkpoint.o
|
||||||
|
|
||||||
|
LDR_OBJECTS = ldr/loader.o
|
||||||
|
|
||||||
OBJECTS = $(HAL_OBJECTS) $(KE_OBJECTS) $(RTL_OBJECTS) $(MM_OBJECTS) \
|
OBJECTS = $(HAL_OBJECTS) $(KE_OBJECTS) $(RTL_OBJECTS) $(MM_OBJECTS) \
|
||||||
$(IO_OBJECTS) $(OB_OBJECTS) $(PS_OBJECTS) $(EX_OBJECTS) \
|
$(IO_OBJECTS) $(OB_OBJECTS) $(PS_OBJECTS) $(EX_OBJECTS) \
|
||||||
$(SE_OBJECTS) $(CFG_OBJECTS) $(TST_OBJECTS)
|
$(SE_OBJECTS) $(CFG_OBJECTS) $(TST_OBJECTS) $(DBG_OBJECTS)
|
||||||
|
|
||||||
utils/export/export$(EXE_POSTFIX): utils/export/export.c
|
utils/export/export$(EXE_POSTFIX): utils/export/export.c
|
||||||
$(NATIVE_CC) -g utils/export/export.c -o utils/export/export$(EXE_POSTFIX)
|
$(NATIVE_CC) -g utils/export/export.c -o utils/export/export$(EXE_POSTFIX)
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: kernel/mm/mdl.cc
|
* FILE: ntoskrnl/mm/mdl.c
|
||||||
* PURPOSE: Manipulates MDLs
|
* PURPOSE: Manipulates MDLs
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
@ -15,19 +15,45 @@
|
||||||
#include <internal/hal/page.h>
|
#include <internal/hal/page.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
|
||||||
VOID MmUnlockPages(PMDL MemoryDescriptorList)
|
VOID MmUnlockPages(PMDL MemoryDescriptorList)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Unlocks the physical pages described by a given MDL
|
||||||
|
* ARGUMENTS:
|
||||||
|
* MemoryDescriptorList = MDL describing the buffer to be unlocked
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID MmMapLockedPages(PMDL MemoryDescriptorList, KPROCESSOR_MODE AccessMode)
|
PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PVOID base;
|
||||||
|
unsigned int i;
|
||||||
|
ULONG* mdl_pages=NULL;
|
||||||
|
|
||||||
|
DPRINT("Mdl->ByteCount %x\n",Mdl->ByteCount);
|
||||||
|
DPRINT("PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE) %x\n",
|
||||||
|
PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);
|
||||||
|
|
||||||
|
base = VirtualAlloc((LPVOID)0,Mdl->ByteCount,MEM_COMMIT,
|
||||||
|
PAGE_SYSTEM + PAGE_EXECUTE_READWRITE);
|
||||||
|
mdl_pages = (ULONG *)(Mdl + 1);
|
||||||
|
for (i=0; i<(PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE); i++)
|
||||||
|
{
|
||||||
|
DPRINT("Writing %x with physical address %x\n",
|
||||||
|
base+(i*PAGESIZE),mdl_pages[i]);
|
||||||
|
DPRINT("&((PULONG)(Mdl+1))[i] %x\n",&mdl_pages[i]);
|
||||||
|
set_page(base+(i*PAGESIZE),PA_READ + PA_SYSTEM,
|
||||||
|
mdl_pages[i]);
|
||||||
|
}
|
||||||
|
DPRINT("base %x\n",base);
|
||||||
|
return(base + Mdl->ByteOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList)
|
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList)
|
||||||
|
@ -56,20 +82,36 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
||||||
* Operation = Operation to probe for
|
* Operation = Operation to probe for
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
* Find the memory area containing the buffer
|
|
||||||
*/
|
|
||||||
ULONG* mdl_pages=NULL;
|
ULONG* mdl_pages=NULL;
|
||||||
int i;
|
int i;
|
||||||
memory_area* marea=find_first_marea(memory_area_list_head,
|
memory_area* marea;
|
||||||
(ULONG)Mdl->StartVa,
|
|
||||||
Mdl->ByteCount);
|
DPRINT("MmProbeAndLockPages(Mdl %x)\n",Mdl);
|
||||||
|
DPRINT("StartVa %x\n",Mdl->StartVa);
|
||||||
|
|
||||||
|
if (Mdl->StartVa > KERNEL_BASE)
|
||||||
|
{
|
||||||
|
marea=find_first_marea(system_memory_area_list_head,
|
||||||
|
(ULONG)Mdl->StartVa,
|
||||||
|
Mdl->ByteCount);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
marea=find_first_marea(memory_area_list_head,
|
||||||
|
(ULONG)Mdl->StartVa,
|
||||||
|
Mdl->ByteCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
DPRINT("marea %x\n",marea);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the area is valid
|
* Check the area is valid
|
||||||
*/
|
*/
|
||||||
if (marea==NULL || (marea->base+marea->length) < ((ULONG)Mdl->StartVa))
|
if (marea==NULL || (marea->base+marea->length) < ((ULONG)Mdl->StartVa))
|
||||||
{
|
{
|
||||||
|
printk("Area is invalid\n");
|
||||||
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,6 +131,7 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
||||||
case IoModifyAccess:
|
case IoModifyAccess:
|
||||||
if (marea->access&PAGE_GUARD || marea->access&PAGE_READONLY)
|
if (marea->access&PAGE_GUARD || marea->access&PAGE_READONLY)
|
||||||
{
|
{
|
||||||
|
printk("Invalid area protections\n");
|
||||||
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -108,7 +151,7 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
||||||
/*
|
/*
|
||||||
* Lock the pages
|
* Lock the pages
|
||||||
*/
|
*/
|
||||||
mdl_pages = (ULONG *)(Mdl + sizeof(MDL));
|
mdl_pages = (ULONG *)(Mdl + 1);
|
||||||
|
|
||||||
for (i=0;i<(PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);i++)
|
for (i=0;i<(PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);i++)
|
||||||
{
|
{
|
||||||
|
@ -119,6 +162,8 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
||||||
}
|
}
|
||||||
mdl_pages[i]=MmGetPhysicalAddress((PVOID)(PAGE_ROUND_DOWN(Mdl->StartVa)
|
mdl_pages[i]=MmGetPhysicalAddress((PVOID)(PAGE_ROUND_DOWN(Mdl->StartVa)
|
||||||
+(i*PAGESIZE)));
|
+(i*PAGESIZE)));
|
||||||
|
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
|
||||||
|
DPRINT("&mdl_pages[i] %x\n",&mdl_pages[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,13 +196,9 @@ ULONG MmSizeOfMdl(PVOID Base, ULONG Length)
|
||||||
* Length = number of bytes to map
|
* Length = number of bytes to map
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
unsigned int len=PAGE_ROUND_UP(Length)/PAGESIZE;
|
unsigned int len=ADDRESS_AND_SIZE_TO_SPAN_PAGES(Base,Length);
|
||||||
|
|
||||||
if (!IS_PAGE_ALIGNED(Base))
|
|
||||||
{
|
|
||||||
len++;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
DPRINT("MmSizeOfMdl() %x\n",sizeof(MDL)+(len*sizeof(ULONG)));
|
||||||
return(sizeof(MDL)+(len*sizeof(ULONG)));
|
return(sizeof(MDL)+(len*sizeof(ULONG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,12 +208,32 @@ PVOID MmGetMdlVirtualAddress(PMDL Mdl)
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID MmGetSystemAddressForMdl(PMDL Mdl)
|
PVOID MmGetSystemAddressForMdl(PMDL Mdl)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Returns a nonpaged system-space virtual address for the buffer
|
||||||
|
* described by the MDL. It maps the physical pages described by a given
|
||||||
|
* MDL into system space, if they are not already mapped to system space.
|
||||||
|
* ARGUMENTS:
|
||||||
|
* Mdl = Mdl to map
|
||||||
|
* RETURNS: The base system-space virtual address that maps the physical
|
||||||
|
* pages described by the given MDL.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
Mdl->MappedSystemVa = MmMapLockedPages(Mdl,KernelMode);
|
if (!( (Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA) ||
|
||||||
|
(Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) ))
|
||||||
|
{
|
||||||
|
Mdl->MappedSystemVa = MmMapLockedPages(Mdl,KernelMode);
|
||||||
|
}
|
||||||
return(Mdl->MappedSystemVa);
|
return(Mdl->MappedSystemVa);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmBuildMdlForNonPagedPool(PMDL Mdl)
|
VOID MmBuildMdlForNonPagedPool(PMDL Mdl)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Fills in the corresponding physical page array of a given
|
||||||
|
* MDL for a buffer in nonpaged system space
|
||||||
|
* ARGUMENTS:
|
||||||
|
* Mdl = Points to an MDL that supplies a virtual address,
|
||||||
|
* byte offset and length
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
int va;
|
int va;
|
||||||
for (va=0; va<Mdl->Size; va++)
|
for (va=0; va<Mdl->Size; va++)
|
||||||
|
@ -180,21 +241,25 @@ VOID MmBuildMdlForNonPagedPool(PMDL Mdl)
|
||||||
((PULONG)(Mdl + 1))[va] = MmGetPhysicalAddress(
|
((PULONG)(Mdl + 1))[va] = MmGetPhysicalAddress(
|
||||||
Mdl->StartVa+ (va * PAGESIZE));
|
Mdl->StartVa+ (va * PAGESIZE));
|
||||||
}
|
}
|
||||||
|
Mdl->MappedSystemVa = Mdl->StartVa;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
|
VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Initializes the header of an MDL
|
||||||
|
* ARGUMENTS:
|
||||||
|
* MemoryDescriptorList = Points to the MDL to be initialized
|
||||||
|
* BaseVa = Points to the base virtual address of a buffer
|
||||||
|
* Length = Specifies the length (in bytes) of a buffer
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
memset(MemoryDescriptorList,0,sizeof(MDL));
|
memset(MemoryDescriptorList,0,sizeof(MDL));
|
||||||
MemoryDescriptorList->StartVa = PAGE_ROUND_DOWN(Base);
|
MemoryDescriptorList->StartVa = PAGE_ROUND_DOWN(Base);
|
||||||
MemoryDescriptorList->ByteOffset = Base - PAGE_ROUND_DOWN(Base);
|
MemoryDescriptorList->ByteOffset = Base - PAGE_ROUND_DOWN(Base);
|
||||||
MemoryDescriptorList->MdlFlags = 0;
|
MemoryDescriptorList->MdlFlags = 0;
|
||||||
MemoryDescriptorList->ByteCount = Length;
|
MemoryDescriptorList->ByteCount = Length;
|
||||||
MemoryDescriptorList->Size = PAGE_ROUND_UP(Length) / PAGESIZE;
|
MemoryDescriptorList->Size = sizeof(MDL) +
|
||||||
if (!IS_PAGE_ALIGNED(Base))
|
(ADDRESS_AND_SIZE_TO_SPAN_PAGES(Base,Length) * sizeof(ULONG));
|
||||||
{
|
|
||||||
MemoryDescriptorList->Size = MemoryDescriptorList->Size
|
|
||||||
+ sizeof(ULONG);
|
|
||||||
}
|
|
||||||
MemoryDescriptorList->Process = PsGetCurrentProcess();
|
MemoryDescriptorList->Process = PsGetCurrentProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +276,10 @@ PMDL MmCreateMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
|
||||||
{
|
{
|
||||||
if (MemoryDescriptorList == NULL)
|
if (MemoryDescriptorList == NULL)
|
||||||
{
|
{
|
||||||
MemoryDescriptorList = (PMDL)ExAllocatePool(NonPagedPool,sizeof(MDL));
|
ULONG Size;
|
||||||
|
|
||||||
|
Size = MmSizeOfMdl(Base,Length);
|
||||||
|
MemoryDescriptorList = (PMDL)ExAllocatePool(NonPagedPool,Size);
|
||||||
if (MemoryDescriptorList==NULL)
|
if (MemoryDescriptorList==NULL)
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(NULL);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
* in take_block (if current bigger than required)
|
* in take_block (if current bigger than required)
|
||||||
* in remove_from_used_list
|
* in remove_from_used_list
|
||||||
* in ExFreePool
|
* in ExFreePool
|
||||||
|
* 23/08/98: Fixes from Robert Bergkvist (fragdance@hotmail.com)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ****************************************************************/
|
||||||
|
@ -250,15 +251,20 @@ static void remove_from_free_list(block_hdr* current)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (current->previous!=NULL)
|
if (current->next==NULL)
|
||||||
{
|
{
|
||||||
current->previous->next=current->next;
|
current->previous->next=NULL;
|
||||||
}
|
}
|
||||||
if (current->next!=NULL)
|
else if (current->previous==NULL)
|
||||||
{
|
{
|
||||||
DPRINT("current->previous %x\n",current->previous);
|
current->next->previous=NULL;
|
||||||
current->next->previous=current->previous;
|
free_list_head=current->next;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
current->next->previous=current->previous;
|
||||||
|
current->previous->next=current->next;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
nr_free_blocks--;
|
nr_free_blocks--;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top directory
|
* COPYRIGHT: See COPYING in the top directory
|
||||||
* PROJECT: ReactOS kernel v0.0.2
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: mm/virtual.cc
|
* FILE: ntoskrnl/mm/virtual.c
|
||||||
* PURPOSE: implementing the Virtualxxx section of the win32 api
|
* PURPOSE: implementing the Virtualxxx section of the win32 api
|
||||||
* PROGRAMMER: David Welch
|
* PROGRAMMER: David Welch
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
@ -22,17 +22,22 @@
|
||||||
|
|
||||||
/* TYPES *******************************************************************/
|
/* TYPES *******************************************************************/
|
||||||
|
|
||||||
|
extern unsigned int etext;
|
||||||
|
extern unsigned int end;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These two are statically declared because mm is initalized before the
|
* These two are statically declared because mm is initalized before the
|
||||||
* memory pool
|
* memory pool
|
||||||
*/
|
*/
|
||||||
static memory_area kernel_area_desc;
|
static memory_area kernel_text_desc;
|
||||||
|
static memory_area kernel_data_desc;
|
||||||
|
static memory_area kernel_param_desc;
|
||||||
static memory_area kernel_pool_desc;
|
static memory_area kernel_pool_desc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Head of the list of system memory areas
|
* Head of the list of system memory areas
|
||||||
*/
|
*/
|
||||||
memory_area* system_memory_area_list_head=&kernel_area_desc;
|
memory_area* system_memory_area_list_head=&kernel_text_desc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Head of the list of user memory areas (this should be per process)
|
* Head of the list of user memory areas (this should be per process)
|
||||||
|
@ -62,16 +67,33 @@ void VirtualInit(boot_param* bp)
|
||||||
/*
|
/*
|
||||||
* Setup the system area descriptor list
|
* Setup the system area descriptor list
|
||||||
*/
|
*/
|
||||||
kernel_area_desc.base = KERNEL_BASE;
|
kernel_text_desc.base = KERNEL_BASE;
|
||||||
kernel_area_desc.length = kernel_len;
|
kernel_text_desc.length = ((ULONG)&etext) - KERNEL_BASE;
|
||||||
kernel_area_desc.next = &kernel_pool_desc;
|
kernel_text_desc.previous = NULL;
|
||||||
kernel_area_desc.load_page=NULL;
|
kernel_text_desc.next = &kernel_data_desc;
|
||||||
|
kernel_text_desc.load_page=NULL;
|
||||||
|
kernel_text_desc.access = PAGE_EXECUTE_READ;
|
||||||
|
|
||||||
|
kernel_data_desc.base = PAGE_ROUND_UP(((ULONG)&etext));
|
||||||
|
kernel_data_desc.length = ((ULONG)&end) - kernel_text_desc.base;
|
||||||
|
kernel_data_desc.previous = &kernel_text_desc;
|
||||||
|
kernel_data_desc.next = &kernel_param_desc;
|
||||||
|
kernel_data_desc.load_page=NULL;
|
||||||
|
kernel_data_desc.access = PAGE_READWRITE;
|
||||||
|
|
||||||
|
kernel_param_desc.base = PAGE_ROUND_UP(((ULONG)&end));
|
||||||
|
kernel_param_desc.length = kernel_len - (kernel_data_desc.length +
|
||||||
|
kernel_text_desc.length);
|
||||||
|
kernel_param_desc.previous = &kernel_data_desc;
|
||||||
|
kernel_param_desc.next = &kernel_pool_desc;
|
||||||
|
kernel_param_desc.load_page=NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The kmalloc area starts one page after the kernel area
|
* The kmalloc area starts one page after the kernel area
|
||||||
*/
|
*/
|
||||||
kernel_pool_desc.base = KERNEL_BASE+ PAGE_ROUND_UP(kernel_len) + PAGESIZE;
|
kernel_pool_desc.base = KERNEL_BASE+ PAGE_ROUND_UP(kernel_len) + PAGESIZE;
|
||||||
kernel_pool_desc.length = NONPAGED_POOL_SIZE;
|
kernel_pool_desc.length = NONPAGED_POOL_SIZE;
|
||||||
|
kernel_pool_desc.previous = &kernel_param_desc;
|
||||||
kernel_pool_desc.next = NULL;
|
kernel_pool_desc.next = NULL;
|
||||||
kernel_pool_desc.load_page=NULL;
|
kernel_pool_desc.load_page=NULL;
|
||||||
|
|
||||||
|
@ -98,8 +120,10 @@ memory_area* find_first_marea(memory_area* list_head, unsigned int base,
|
||||||
{
|
{
|
||||||
if (current==NULL)
|
if (current==NULL)
|
||||||
{
|
{
|
||||||
|
// printk("current is null\n");
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
// printk("current %x current->base %x\n",current,current->base);
|
||||||
if (current->base == base && length==0)
|
if (current->base == base && length==0)
|
||||||
{
|
{
|
||||||
return(current);
|
return(current);
|
||||||
|
@ -210,11 +234,14 @@ static LPVOID allocate_marea(DWORD dwSize, DWORD flAllocationType,
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
memory_area* current=*list_head;
|
memory_area* current=*list_head;
|
||||||
|
memory_area* previous;
|
||||||
memory_area* ndesc=NULL;
|
memory_area* ndesc=NULL;
|
||||||
|
|
||||||
|
previous=current;
|
||||||
while (current!=NULL)
|
while (current!=NULL)
|
||||||
{
|
{
|
||||||
last_addr = PAGE_ROUND_UP(current->base + current->length);
|
last_addr = PAGE_ROUND_UP(current->base + current->length);
|
||||||
|
previous=current;
|
||||||
current=current->next;
|
current=current->next;
|
||||||
}
|
}
|
||||||
ndesc = ExAllocatePool(NonPagedPool,sizeof(memory_area));
|
ndesc = ExAllocatePool(NonPagedPool,sizeof(memory_area));
|
||||||
|
@ -223,14 +250,14 @@ static LPVOID allocate_marea(DWORD dwSize, DWORD flAllocationType,
|
||||||
ndesc->lock=FALSE;
|
ndesc->lock=FALSE;
|
||||||
ndesc->base=last_addr+PAGESIZE;
|
ndesc->base=last_addr+PAGESIZE;
|
||||||
ndesc->length=dwSize;
|
ndesc->length=dwSize;
|
||||||
ndesc->previous=current;
|
ndesc->previous=previous;
|
||||||
if (current!=NULL)
|
if (previous!=NULL)
|
||||||
{
|
{
|
||||||
ndesc->next=current->next;
|
ndesc->next=previous->next;
|
||||||
current->next=ndesc;
|
previous->next=ndesc;
|
||||||
if (current->next!=NULL)
|
if (previous->next!=NULL)
|
||||||
{
|
{
|
||||||
current->next->previous=ndesc;
|
previous->next->previous=ndesc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
/* INCLUDES ***************************************************************/
|
/* INCLUDES ***************************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <wstring.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/objmgr.h>
|
#include <internal/objmgr.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
#include <internal/kernel.h>
|
#include <internal/kernel.h>
|
||||||
#include <wstring.h>
|
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -48,6 +48,78 @@ static struct
|
||||||
|
|
||||||
/* FUNCTIONS **************************************************************/
|
/* FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS ZwOpenDirectoryObject(PHANDLE DirectoryHandle,
|
||||||
|
ACCESS_MASK DesiredAccess,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
|
{
|
||||||
|
PVOID Object;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = ObOpenObjectByName(ObjectAttributes,&Object);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (BODY_TO_HEADER(Object)->Type!=OBJTYP_DIRECTORY)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
|
||||||
|
*DirectoryHandle = ObAddHandle(Object);
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
POBJECT_HEADER hdr = ObGetObjectByHandle(DirObjHandle);
|
||||||
|
PDIRECTORY_OBJECT dir = (PDIRECTORY_OBJECT)(HEADER_TO_BODY(hdr));
|
||||||
|
PLIST_ENTRY current_entry;
|
||||||
|
POBJECT_HEADER current;
|
||||||
|
PWSTR outbuffer = (PWSTR)(ObjectIndex);
|
||||||
|
|
||||||
|
current_entry = dir->head.Flink;
|
||||||
|
while (current_entry!=NULL)
|
||||||
|
{
|
||||||
|
current = CONTAINING_RECORD(current_entry,OBJECT_HEADER,entry);
|
||||||
|
if (BufferLength < wstrlen(current->name.Buffer))
|
||||||
|
{
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
BufferLength = BufferLength - wstrlen(current->name.Buffer);
|
||||||
|
// wcscpy(outbuffer,current->name.Buffer);
|
||||||
|
outbuffer = outbuffer + wstrlen(current->name.Buffer);
|
||||||
|
current_entry = current_entry->Flink;
|
||||||
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS ObOpenObjectByName(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
PVOID* Object)
|
||||||
|
{
|
||||||
|
|
||||||
|
DPRINT("ObOpenObjectByName(ObjectAttributes %x, Object %x)\n",
|
||||||
|
ObjectAttributes,Object);
|
||||||
|
DPRINT("ObjectAttributes = {ObjectName %x ObjectName->Buffer %w}\n",
|
||||||
|
ObjectAttributes->ObjectName,ObjectAttributes->ObjectName->Buffer);
|
||||||
|
|
||||||
|
*Object = ObLookupObject(ObjectAttributes->RootDirectory,
|
||||||
|
ObjectAttributes->ObjectName->Buffer);
|
||||||
|
DPRINT("*Object %x\n",*Object);
|
||||||
|
if ((*Object)==NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_NO_SUCH_FILE);
|
||||||
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
void ObjNamespcInit(void)
|
void ObjNamespcInit(void)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Initialize the object manager namespace
|
* FUNCTION: Initialize the object manager namespace
|
||||||
|
@ -92,20 +164,6 @@ NTSTATUS ZwCreateDirectoryObject(PHANDLE DirectoryHandle,
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PWSTR Rtlstrrchr(PUNICODE_STRING string, WCHAR c)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
DPRINT("string->Length %d\n",string->Length);
|
|
||||||
for (i=(string->Length-1);i>=0;i--)
|
|
||||||
{
|
|
||||||
if (string->Buffer[i]==c)
|
|
||||||
{
|
|
||||||
return(&string->Buffer[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
|
VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
|
||||||
PUNICODE_STRING ObjectName,
|
PUNICODE_STRING ObjectName,
|
||||||
ULONG Attributes,
|
ULONG Attributes,
|
||||||
|
@ -127,70 +185,15 @@ VOID InitializeObjectAttributes(POBJECT_ATTRIBUTES InitializedAttributes,
|
||||||
* to RootDirectory
|
* to RootDirectory
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
UNICODE_STRING path;
|
DPRINT("InitializeObjectAttributes(InitializedAttributes %x "
|
||||||
PWSTR name = NULL;
|
"ObjectName %x Attributes %x RootDirectory %x)\n",
|
||||||
PDIRECTORY_OBJECT parent_dir;
|
InitializedAttributes,ObjectName,Attributes,RootDirectory);
|
||||||
|
InitializedAttributes->Length=sizeof(OBJECT_ATTRIBUTES);
|
||||||
DPRINT("InitalizeObjectAttributes(ObjectName %w)\n",ObjectName->Buffer);
|
InitializedAttributes->RootDirectory=RootDirectory;
|
||||||
|
InitializedAttributes->ObjectName=ObjectName;
|
||||||
if (RootDirectory!=NULL)
|
InitializedAttributes->Attributes=Attributes;
|
||||||
{
|
InitializedAttributes->SecurityDescriptor=SecurityDescriptor;
|
||||||
ObReferenceObjectByHandle(RootDirectory,DIRECTORY_TRAVERSE,NULL,
|
InitializedAttributes->SecurityQualityOfService=NULL;
|
||||||
UserMode,(PVOID*)&parent_dir,NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
parent_dir = HEADER_TO_BODY((POBJECT_HEADER)&namespc_root);
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
|
||||||
|
|
||||||
path.Buffer = ExAllocatePool(NonPagedPool,
|
|
||||||
ObjectName->Length*sizeof(WCHAR));
|
|
||||||
path.MaximumLength = ObjectName->Length;
|
|
||||||
RtlCopyUnicodeString(&path,ObjectName);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Seperate the path into the name of the object and the name of its
|
|
||||||
* direct parent directory
|
|
||||||
*/
|
|
||||||
name = Rtlstrrchr(&path,'\\');
|
|
||||||
*name=0;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Find the objects parent directory
|
|
||||||
*/
|
|
||||||
DPRINT("parent_dir %x\n",&(parent_dir->Type));
|
|
||||||
parent_dir=(PDIRECTORY_OBJECT)ObLookupObject(parent_dir,&path);
|
|
||||||
if (parent_dir==NULL)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure the parent directory doesn't disappear
|
|
||||||
*/
|
|
||||||
ObReferenceObjectByPointer(parent_dir,DIRECTORY_CREATE_OBJECT,NULL,
|
|
||||||
UserMode);
|
|
||||||
|
|
||||||
InitializedAttributes->Attributes = Attributes;
|
|
||||||
InitializedAttributes->parent = parent_dir;
|
|
||||||
RtlInitUnicodeString(&InitializedAttributes->name,name+1);
|
|
||||||
InitializedAttributes->path = path;
|
|
||||||
}
|
|
||||||
|
|
||||||
int _wcscmp(wchar_t* str1, wchar_t* str2)
|
|
||||||
{
|
|
||||||
while ( (*str1)==(*str2) )
|
|
||||||
{
|
|
||||||
str1++;
|
|
||||||
str2++;
|
|
||||||
if ( (*str1)==((wchar_t)0) && (*str1)==((wchar_t)0) )
|
|
||||||
{
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return( (*str1) - (*str2) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static PVOID ObDirLookup(PDIRECTORY_OBJECT dir, PWSTR name)
|
static PVOID ObDirLookup(PDIRECTORY_OBJECT dir, PWSTR name)
|
||||||
|
@ -205,12 +208,24 @@ static PVOID ObDirLookup(PDIRECTORY_OBJECT dir, PWSTR name)
|
||||||
{
|
{
|
||||||
LIST_ENTRY* current = ((PDIRECTORY_OBJECT)dir)->head.Flink;
|
LIST_ENTRY* current = ((PDIRECTORY_OBJECT)dir)->head.Flink;
|
||||||
POBJECT_HEADER current_obj;
|
POBJECT_HEADER current_obj;
|
||||||
DPRINT("ObDirLookup(dir %x, name %w\n",dir,name);
|
DPRINT("ObDirLookup(dir %x, name %w)\n",dir,name);
|
||||||
|
if (name[0]==0)
|
||||||
|
{
|
||||||
|
return(BODY_TO_HEADER(dir));
|
||||||
|
}
|
||||||
|
if (name[0]=='.'&&name[1]==0)
|
||||||
|
{
|
||||||
|
return(BODY_TO_HEADER(dir));
|
||||||
|
}
|
||||||
|
if (name[0]=='.'&&name[1]=='.'&&name[2]==0)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
while (current!=NULL)
|
while (current!=NULL)
|
||||||
{
|
{
|
||||||
current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,entry);
|
current_obj = CONTAINING_RECORD(current,OBJECT_HEADER,entry);
|
||||||
DPRINT("current_obj->name %w\n",current_obj->name.Buffer);
|
if ( wcscmp(current_obj->name.Buffer, name)==0)
|
||||||
if ( _wcscmp(current_obj->name.Buffer, name)==0)
|
|
||||||
{
|
{
|
||||||
return(current_obj);
|
return(current_obj);
|
||||||
}
|
}
|
||||||
|
@ -244,20 +259,7 @@ VOID ObCreateEntry(PDIRECTORY_OBJECT parent,POBJECT_HEADER Object)
|
||||||
InsertTailList(&parent->head,&Object->entry);
|
InsertTailList(&parent->head,&Object->entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t* _wcschr(wchar_t* str, wchar_t ch)
|
PVOID ObLookupObject(HANDLE rooth, PWSTR string)
|
||||||
{
|
|
||||||
while ((*str)!=((wchar_t)0))
|
|
||||||
{
|
|
||||||
if ((*str)==ch)
|
|
||||||
{
|
|
||||||
return(str);
|
|
||||||
}
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string)
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Lookup an object within the system namespc
|
* FUNCTION: Lookup an object within the system namespc
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -269,30 +271,31 @@ PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string)
|
||||||
{
|
{
|
||||||
PWSTR current;
|
PWSTR current;
|
||||||
PWSTR next;
|
PWSTR next;
|
||||||
PDIRECTORY_OBJECT current_dir = root;
|
PDIRECTORY_OBJECT current_dir = NULL;
|
||||||
POBJECT_HEADER current_hdr;
|
POBJECT_HEADER current_hdr;
|
||||||
PWSTR string;
|
|
||||||
|
|
||||||
DPRINT("root %x string %w\n",root,_string->Buffer);
|
DPRINT("root %x string %w\n",rooth,string);
|
||||||
|
|
||||||
if (root==NULL)
|
if (rooth==NULL)
|
||||||
{
|
{
|
||||||
current_dir = HEADER_TO_BODY(&(namespc_root.hdr));
|
current_dir = HEADER_TO_BODY(&(namespc_root.hdr));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ObReferenceObjectByHandle(rooth,DIRECTORY_TRAVERSE,NULL,
|
||||||
|
UserMode,(PVOID*)¤t_dir,NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Bit of a hack this
|
* Bit of a hack this
|
||||||
*/
|
*/
|
||||||
if (_string->Buffer[0]==0)
|
if (string[0]==0)
|
||||||
{
|
{
|
||||||
DPRINT("current_dir %x\n",current_dir);
|
DPRINT("current_dir %x\n",current_dir);
|
||||||
DPRINT("type %d\n",current_dir->Type);
|
DPRINT("type %d\n",current_dir->Type);
|
||||||
return(current_dir);
|
return(current_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
string=(PWSTR)ExAllocatePool(NonPagedPool,(_string->Length+1)*2);
|
|
||||||
wcscpy(string,_string->Buffer);
|
|
||||||
|
|
||||||
DPRINT("string = %w\n",string);
|
DPRINT("string = %w\n",string);
|
||||||
|
|
||||||
if (string[0]!='\\')
|
if (string[0]!='\\')
|
||||||
|
@ -304,7 +307,7 @@ PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string)
|
||||||
|
|
||||||
current = string+1;
|
current = string+1;
|
||||||
DPRINT("current %w\n",current);
|
DPRINT("current %w\n",current);
|
||||||
next = _wcschr(string+1,'\\');
|
next = wcschr(string+1,'\\');
|
||||||
if (next!=NULL)
|
if (next!=NULL)
|
||||||
{
|
{
|
||||||
*next=0;
|
*next=0;
|
||||||
|
@ -341,7 +344,7 @@ PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string)
|
||||||
current_dir = HEADER_TO_BODY(current_hdr);
|
current_dir = HEADER_TO_BODY(current_hdr);
|
||||||
|
|
||||||
current = next+1;
|
current = next+1;
|
||||||
next = _wcschr(next+1,'\\');
|
next = wcschr(next+1,'\\');
|
||||||
if (next!=NULL)
|
if (next!=NULL)
|
||||||
{
|
{
|
||||||
*next=0;
|
*next=0;
|
||||||
|
@ -353,11 +356,9 @@ PVOID ObLookupObject(PDIRECTORY_OBJECT root, PUNICODE_STRING _string)
|
||||||
current_hdr = ObDirLookup(current_dir,current);
|
current_hdr = ObDirLookup(current_dir,current);
|
||||||
if (current_hdr==NULL)
|
if (current_hdr==NULL)
|
||||||
{
|
{
|
||||||
ExFreePool(string);
|
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
DPRINT("Returning %x %x\n",current_hdr,HEADER_TO_BODY(current_hdr));
|
DPRINT("Returning %x %x\n",current_hdr,HEADER_TO_BODY(current_hdr));
|
||||||
ExFreePool(string);
|
|
||||||
return(HEADER_TO_BODY(current_hdr));
|
return(HEADER_TO_BODY(current_hdr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/objmgr.h>
|
#include <internal/objmgr.h>
|
||||||
#include <internal/kernel.h>
|
#include <internal/kernel.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -37,9 +38,14 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
|
||||||
CSHORT Type)
|
CSHORT Type)
|
||||||
{
|
{
|
||||||
POBJECT_HEADER hdr = NULL;
|
POBJECT_HEADER hdr = NULL;
|
||||||
|
UNICODE_STRING ObjectName;
|
||||||
|
PWSTR path;
|
||||||
|
PWSTR name;
|
||||||
|
PDIRECTORY_OBJECT parent;
|
||||||
|
|
||||||
DPRINT("ObGenericCreateObject(Handle %x ObjectAttributes %x Type %x)\n",
|
DPRINT("ObGenericCreateObject(Handle %x, DesiredAccess %x,"
|
||||||
Handle,ObjectAttributes,Type);
|
"ObjectAttributes %x, Type %x)\n",Handle,DesiredAccess,ObjectAttributes,
|
||||||
|
Type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate the object body and header
|
* Allocate the object body and header
|
||||||
|
@ -49,30 +55,56 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If unnamed then initalize
|
||||||
|
*/
|
||||||
|
if (ObjectAttributes==NULL)
|
||||||
|
{
|
||||||
|
ObInitializeObjectHeader(Type,NULL,hdr);
|
||||||
|
*Handle = ObAddHandle(HEADER_TO_BODY(hdr));
|
||||||
|
return(HEADER_TO_BODY(hdr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copy the object name into a buffer
|
||||||
|
*/
|
||||||
|
DPRINT("ObjectAttributes->ObjectName %x\n",ObjectAttributes->ObjectName);
|
||||||
|
DPRINT("ObjectAttributes->ObjectName->Length %d\n",
|
||||||
|
ObjectAttributes->ObjectName->Length);
|
||||||
|
ObjectName.MaximumLength = ObjectAttributes->ObjectName->Length;
|
||||||
|
ObjectName.Buffer = ExAllocatePool(NonPagedPool,
|
||||||
|
((ObjectAttributes->ObjectName->Length+1)*2));
|
||||||
|
if (ObjectName.Buffer==NULL)
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
RtlCopyUnicodeString(&ObjectName,ObjectAttributes->ObjectName);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Seperate the name into a path and name
|
||||||
|
*/
|
||||||
|
name = wcsrchr(ObjectName.Buffer,'\\');
|
||||||
|
if (name==NULL)
|
||||||
|
{
|
||||||
|
name=ObjectName.Buffer;
|
||||||
|
path=NULL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
path=ObjectName.Buffer;
|
||||||
|
*name=0;
|
||||||
|
name=name+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
parent = ObLookupObject(ObjectAttributes->RootDirectory,path);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Initialize the object header
|
* Initialize the object header
|
||||||
*/
|
*/
|
||||||
if (ObjectAttributes!=NULL)
|
ObInitializeObjectHeader(Type,name,hdr);
|
||||||
{
|
ObCreateEntry(parent,hdr);
|
||||||
ObInitializeObjectHeader(Type,&ObjectAttributes->name,hdr);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ObInitializeObjectHeader(Type,NULL,hdr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// DPRINT("ObjectAttributes->parent->Type %d\n",
|
|
||||||
// ObjectAttributes->parent->Type);
|
|
||||||
if (ObjectAttributes!=NULL)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* Add the object to its parent directory
|
|
||||||
*/
|
|
||||||
DPRINT("hdr->name.Buffer %x\n",hdr->name.Buffer);
|
|
||||||
ObCreateEntry(ObjectAttributes->parent,hdr);
|
|
||||||
}
|
|
||||||
|
|
||||||
DPRINT("Handle %x\n",Handle);
|
DPRINT("Handle %x\n",Handle);
|
||||||
*Handle = ObAddHandle(HEADER_TO_BODY(hdr));
|
*Handle = ObAddHandle(HEADER_TO_BODY(hdr));
|
||||||
|
|
||||||
|
@ -81,6 +113,8 @@ PVOID ObGenericCreateObject(PHANDLE Handle,
|
||||||
|
|
||||||
ULONG ObSizeOf(CSHORT Type)
|
ULONG ObSizeOf(CSHORT Type)
|
||||||
{
|
{
|
||||||
|
DPRINT("ObSizeOf(Type %d)\n",Type);
|
||||||
|
DPRINT("ObSizeOf() Returning %d\n",ObjectTypes[Type]->PagedPoolCharge);
|
||||||
return(ObjectTypes[Type]->PagedPoolCharge);
|
return(ObjectTypes[Type]->PagedPoolCharge);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +129,7 @@ VOID ObRegisterType(CSHORT id, POBJECT_TYPE type)
|
||||||
ObjectTypes[id]=type;
|
ObjectTypes[id]=type;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID ObInitializeObjectHeader(CSHORT id, PUNICODE_STRING name,
|
VOID ObInitializeObjectHeader(CSHORT id, PWSTR name,
|
||||||
POBJECT_HEADER obj)
|
POBJECT_HEADER obj)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Creates a new object
|
* FUNCTION: Creates a new object
|
||||||
|
@ -104,10 +138,12 @@ VOID ObInitializeObjectHeader(CSHORT id, PUNICODE_STRING name,
|
||||||
* obj = Pointer to the header of the object
|
* obj = Pointer to the header of the object
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
PWSTR temp_name;
|
||||||
|
|
||||||
if (name!=NULL)
|
if (name!=NULL)
|
||||||
{
|
{
|
||||||
DPRINT("ObInitializeObjectHeader(id %d name %w obj %x)\n",id,
|
DPRINT("ObInitializeObjectHeader(id %d name %w obj %x)\n",id,
|
||||||
name->Buffer,obj);
|
name,obj);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -125,13 +161,13 @@ VOID ObInitializeObjectHeader(CSHORT id, PUNICODE_STRING name,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
obj->name.Length = 0;
|
DPRINT("name %w\n",name);
|
||||||
obj->name.MaximumLength = name->Length;
|
obj->name.MaximumLength = wstrlen(name);
|
||||||
obj->name.Buffer = ExAllocatePool(NonPagedPool,
|
obj->name.Buffer = ExAllocatePool(NonPagedPool,
|
||||||
(name->Length+1)*sizeof(WCHAR));
|
(obj->name.MaximumLength+1)*2);
|
||||||
DPRINT("obj->name.Buffer %x\n",obj->name.Buffer);
|
DPRINT("name %w\n",name);
|
||||||
RtlCopyUnicodeString(&obj->name,name);
|
RtlInitUnicodeString(&obj->name,name);
|
||||||
DPRINT("obj->name.Buffer %x\n",obj->name.Buffer);
|
DPRINT("name %w\n",obj->name.Buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,10 +186,11 @@ NTSTATUS ObReferenceObjectByPointer(PVOID ObjectBody,
|
||||||
* RETURNS: Status
|
* RETURNS: Status
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
POBJECT_HEADER Object = BODY_TO_HEADER(ObjectBody);
|
POBJECT_HEADER Object;
|
||||||
|
|
||||||
DPRINT("ObReferenceObjectByPointer(%x %x)\n",ObjectBody,Object);
|
DPRINT("ObReferenceObjectByPointer(%x %x)\n",ObjectBody,Object);
|
||||||
|
|
||||||
|
Object = BODY_TO_HEADER(ObjectBody);
|
||||||
Object->RefCount++;
|
Object->RefCount++;
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -180,7 +217,7 @@ NTSTATUS ZwClose(HANDLE Handle)
|
||||||
{
|
{
|
||||||
PVOID ObjectBody;
|
PVOID ObjectBody;
|
||||||
|
|
||||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
assert_irql(PASSIVE_LEVEL);
|
||||||
|
|
||||||
ObjectBody = ObGetObjectByHandle(Handle);
|
ObjectBody = ObGetObjectByHandle(Handle);
|
||||||
if (ObjectBody == NULL)
|
if (ObjectBody == NULL)
|
||||||
|
|
|
@ -310,6 +310,7 @@ NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
|
||||||
|
|
||||||
ExInterlockedInsertHeadList(&ThreadListHead,&thread->Entry,
|
ExInterlockedInsertHeadList(&ThreadListHead,&thread->Entry,
|
||||||
&ThreadListLock);
|
&ThreadListLock);
|
||||||
|
InitializeListHead(&thread->ApcQueueHead);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <base.h>
|
#include <base.h>
|
||||||
|
#include <wstring.h>
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
@ -30,59 +31,40 @@ WCHAR wtoupper(WCHAR c)
|
||||||
{
|
{
|
||||||
if((c>='a') && (c<='z')) return c+Aa_Difference;
|
if((c>='a') && (c<='z')) return c+Aa_Difference;
|
||||||
return c;
|
return c;
|
||||||
}
|
};
|
||||||
|
|
||||||
unsigned long wstrlen(PWSTR s)
|
|
||||||
{
|
|
||||||
WCHAR c=' ';
|
|
||||||
unsigned int len=0;
|
|
||||||
|
|
||||||
while(c!=0) {
|
|
||||||
c=*s;
|
|
||||||
s++;
|
|
||||||
len++;
|
|
||||||
};
|
|
||||||
s-=len;
|
|
||||||
|
|
||||||
return len-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
|
ULONG RtlAnsiStringToUnicodeSize(IN PANSI_STRING AnsiString)
|
||||||
{
|
{
|
||||||
return AnsiString->Length*2;
|
return AnsiString->Length*2;
|
||||||
}
|
};
|
||||||
|
|
||||||
NTSTATUS RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
NTSTATUS RtlAnsiStringToUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
IN PANSI_STRING SourceString,
|
IN PANSI_STRING SourceString, IN BOOLEAN AllocateDestinationString)
|
||||||
IN BOOLEAN AllocateDestinationString)
|
|
||||||
{
|
{
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
|
|
||||||
if (AllocateDestinationString==TRUE)
|
|
||||||
{
|
|
||||||
DestinationString->Buffer=ExAllocatePool(NonPagedPool,
|
|
||||||
(SourceString->Length+1)*2);
|
|
||||||
DestinationString->MaximumLength=SourceString->Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
DestinationString->Length=SourceString->Length;
|
if(AllocateDestinationString==TRUE) {
|
||||||
|
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1);
|
||||||
memset(DestinationString->Buffer,0,SourceString->Length*2);
|
DestinationString->MaximumLength=SourceString->Length;
|
||||||
|
};
|
||||||
for (i=0; i<SourceString->Length; i++)
|
|
||||||
{
|
DestinationString->Length=SourceString->Length;
|
||||||
*DestinationString->Buffer=*SourceString->Buffer;
|
memset(DestinationString->Buffer, 0, SourceString->Length*2);
|
||||||
|
|
||||||
SourceString->Buffer++;
|
for (i=0; i<SourceString->Length; i++)
|
||||||
DestinationString->Buffer++;
|
{
|
||||||
};
|
*DestinationString->Buffer=*SourceString->Buffer;
|
||||||
*DestinationString->Buffer=0;
|
|
||||||
|
SourceString->Buffer++;
|
||||||
SourceString->Buffer-=SourceString->Length;
|
DestinationString->Buffer++;
|
||||||
DestinationString->Buffer-=SourceString->Length;
|
};
|
||||||
|
*DestinationString->Buffer=0;
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
SourceString->Buffer-=SourceString->Length;
|
||||||
|
DestinationString->Buffer-=SourceString->Length;
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
};
|
||||||
|
|
||||||
NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination,
|
NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination,
|
||||||
IN PUNICODE_STRING Source)
|
IN PUNICODE_STRING Source)
|
||||||
|
@ -104,7 +86,7 @@ NTSTATUS RtlAppendUnicodeStringToString(IN OUT PUNICODE_STRING Destination,
|
||||||
|
|
||||||
Destination->Length+=Source->Length;
|
Destination->Length+=Source->Length;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
};
|
||||||
|
|
||||||
NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
|
NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
|
||||||
IN PWSTR Source)
|
IN PWSTR Source)
|
||||||
|
@ -126,12 +108,12 @@ NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
|
||||||
|
|
||||||
Destination->Length+=slen;
|
Destination->Length+=slen;
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
};
|
||||||
|
|
||||||
NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
|
NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
|
||||||
{
|
{
|
||||||
*Value=simple_strtoul((const char *)String, NULL, Base);
|
*Value=simple_strtoul((const char *)String, NULL, Base);
|
||||||
}
|
};
|
||||||
|
|
||||||
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
||||||
{
|
{
|
||||||
|
@ -160,7 +142,7 @@ LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
||||||
String2->Buffer-=i;
|
String2->Buffer-=i;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
};
|
||||||
|
|
||||||
LONG RtlCompareUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
|
LONG RtlCompareUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
|
||||||
BOOLEAN CaseInsensitive)
|
BOOLEAN CaseInsensitive)
|
||||||
|
@ -194,7 +176,7 @@ LONG RtlCompareUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
|
||||||
String2->Buffer-=i;
|
String2->Buffer-=i;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
};
|
||||||
|
|
||||||
VOID RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
|
VOID RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
|
||||||
{
|
{
|
||||||
|
@ -202,7 +184,6 @@ VOID RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
|
||||||
|
|
||||||
if(SourceString==NULL) {
|
if(SourceString==NULL) {
|
||||||
DestinationString->Length=0;
|
DestinationString->Length=0;
|
||||||
DestinationString->Buffer=NULL;
|
|
||||||
} else {
|
} else {
|
||||||
if(SourceString->Length<DestinationString->MaximumLength) {
|
if(SourceString->Length<DestinationString->MaximumLength) {
|
||||||
copylen=SourceString->Length;
|
copylen=SourceString->Length;
|
||||||
|
@ -211,62 +192,40 @@ VOID RtlCopyString(IN OUT PSTRING DestinationString, IN PSTRING SourceString)
|
||||||
};
|
};
|
||||||
for(i=0; i<copylen; i++)
|
for(i=0; i<copylen; i++)
|
||||||
{
|
{
|
||||||
*(DestinationString->Buffer)=*(SourceString->Buffer);
|
*DestinationString->Buffer=*SourceString->Buffer;
|
||||||
DestinationString++;
|
DestinationString->Buffer++;
|
||||||
SourceString++;
|
SourceString->Buffer++;
|
||||||
};
|
};
|
||||||
*DestinationString->Buffer=0;
|
*DestinationString->Buffer=0;
|
||||||
DestinationString->Buffer-=copylen;
|
DestinationString->Buffer-=copylen;
|
||||||
SourceString->Buffer-=copylen;
|
SourceString->Buffer-=copylen;
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
VOID RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
VOID RtlCopyUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
IN PUNICODE_STRING SourceString)
|
IN PUNICODE_STRING SourceString)
|
||||||
{
|
{
|
||||||
unsigned long copylen, i;
|
unsigned long copylen, i;
|
||||||
WCHAR* src;
|
|
||||||
WCHAR* dest;
|
if(SourceString==NULL) {
|
||||||
|
DestinationString->Length=0;
|
||||||
DPRINT("RtlCopyUnicodeString(Dest %x Source %x)\n",DestinationString,
|
} else {
|
||||||
SourceString);
|
if(SourceString->Length<DestinationString->MaximumLength) {
|
||||||
DPRINT("Dest->Length %d Dest->Buffer %x\n",DestinationString->Length,
|
copylen=SourceString->Length;
|
||||||
DestinationString->Buffer);
|
} else {
|
||||||
if (SourceString!=NULL)
|
copylen=DestinationString->MaximumLength;
|
||||||
{
|
};
|
||||||
DPRINT("Source->Length %d Source->Buffer %x\n",SourceString->Length,
|
for(i=0; i<copylen; i++)
|
||||||
SourceString->Buffer);
|
{
|
||||||
}
|
*DestinationString->Buffer=*SourceString->Buffer;
|
||||||
|
DestinationString->Buffer++;
|
||||||
if(SourceString==NULL)
|
SourceString->Buffer++;
|
||||||
{
|
};
|
||||||
DestinationString->Length=0;
|
*DestinationString->Buffer=0;
|
||||||
}
|
DestinationString->Buffer-=copylen;
|
||||||
else
|
SourceString->Buffer-=copylen;
|
||||||
{
|
};
|
||||||
DestinationString->Length=SourceString->Length;
|
};
|
||||||
if(SourceString->Length<DestinationString->MaximumLength)
|
|
||||||
{
|
|
||||||
copylen=SourceString->Length;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
copylen=DestinationString->MaximumLength;
|
|
||||||
}
|
|
||||||
DPRINT("Beginning copy of length %d\n",copylen);
|
|
||||||
src = SourceString->Buffer;
|
|
||||||
dest = DestinationString->Buffer;
|
|
||||||
for(i=0; i<copylen; i++)
|
|
||||||
{
|
|
||||||
*dest=*src;
|
|
||||||
src++;
|
|
||||||
dest++;
|
|
||||||
}
|
|
||||||
DPRINT("Finished copy %x\n",DestinationString->Buffer);
|
|
||||||
*dest=0;
|
|
||||||
DPRINT("Finished copy %x\n",DestinationString->Buffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
||||||
{
|
{
|
||||||
|
@ -300,7 +259,7 @@ BOOLEAN RtlEqualString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive
|
||||||
String2->Buffer-=i;
|
String2->Buffer-=i;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
};
|
||||||
|
|
||||||
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
|
BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
|
||||||
BOOLEAN CaseInsensitive)
|
BOOLEAN CaseInsensitive)
|
||||||
|
@ -335,17 +294,17 @@ BOOLEAN RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2,
|
||||||
String2->Buffer-=i;
|
String2->Buffer-=i;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
};
|
||||||
|
|
||||||
VOID RtlFreeAnsiString(IN PANSI_STRING AnsiString)
|
VOID RtlFreeAnsiString(IN PANSI_STRING AnsiString)
|
||||||
{
|
{
|
||||||
ExFreePool(AnsiString->Buffer);
|
ExFreePool(AnsiString->Buffer);
|
||||||
}
|
};
|
||||||
|
|
||||||
VOID RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
|
VOID RtlFreeUnicodeString(IN PUNICODE_STRING UnicodeString)
|
||||||
{
|
{
|
||||||
ExFreePool(UnicodeString->Buffer);
|
ExFreePool(UnicodeString->Buffer);
|
||||||
}
|
};
|
||||||
|
|
||||||
VOID RtlInitAnsiString(IN OUT PANSI_STRING DestinationString,
|
VOID RtlInitAnsiString(IN OUT PANSI_STRING DestinationString,
|
||||||
IN PCSZ SourceString)
|
IN PCSZ SourceString)
|
||||||
|
@ -361,7 +320,7 @@ VOID RtlInitAnsiString(IN OUT PANSI_STRING DestinationString,
|
||||||
DestinationString->MaximumLength=DestSize+1;
|
DestinationString->MaximumLength=DestSize+1;
|
||||||
};
|
};
|
||||||
DestinationString->Buffer=(PCHAR)SourceString;
|
DestinationString->Buffer=(PCHAR)SourceString;
|
||||||
}
|
};
|
||||||
|
|
||||||
VOID RtlInitString(IN OUT PSTRING DestinationString,
|
VOID RtlInitString(IN OUT PSTRING DestinationString,
|
||||||
IN PCSZ SourceString)
|
IN PCSZ SourceString)
|
||||||
|
@ -369,7 +328,7 @@ VOID RtlInitString(IN OUT PSTRING DestinationString,
|
||||||
DestinationString->Length=strlen((char *)SourceString);
|
DestinationString->Length=strlen((char *)SourceString);
|
||||||
DestinationString->MaximumLength=strlen((char *)SourceString)+1;
|
DestinationString->MaximumLength=strlen((char *)SourceString)+1;
|
||||||
DestinationString->Buffer=SourceString;
|
DestinationString->Buffer=SourceString;
|
||||||
}
|
};
|
||||||
|
|
||||||
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
IN PCWSTR SourceString)
|
IN PCWSTR SourceString)
|
||||||
|
@ -388,7 +347,7 @@ VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
|
|
||||||
DestinationString->Buffer=(PWSTR)SourceString;
|
DestinationString->Buffer=(PWSTR)SourceString;
|
||||||
};
|
};
|
||||||
}
|
};
|
||||||
|
|
||||||
NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */
|
NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */
|
||||||
IN OUT PUNICODE_STRING String)
|
IN OUT PUNICODE_STRING String)
|
||||||
|
@ -396,7 +355,7 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
||||||
char *str;
|
char *str;
|
||||||
unsigned long len, i;
|
unsigned long len, i;
|
||||||
|
|
||||||
str=ExAllocatePool(NonPagedPool, 100);
|
str=ExAllocatePool(NonPagedPool, 1024);
|
||||||
if(Base==16) {
|
if(Base==16) {
|
||||||
sprintf(str, "%x", Value);
|
sprintf(str, "%x", Value);
|
||||||
} else
|
} else
|
||||||
|
@ -424,37 +383,35 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
||||||
ExFreePool(str);
|
ExFreePool(str);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
};
|
||||||
|
|
||||||
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
||||||
IN PUNICODE_STRING SourceString,
|
IN PUNICODE_STRING SourceString,
|
||||||
IN BOOLEAN AllocateDestinationString)
|
IN BOOLEAN AllocateDestinationString)
|
||||||
{
|
{
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
WCHAR* dest;
|
|
||||||
char* src;
|
|
||||||
|
|
||||||
if(AllocateDestinationString==TRUE)
|
|
||||||
{
|
|
||||||
DestinationString->Buffer=ExAllocatePool(NonPagedPool,
|
|
||||||
(SourceString->Length+1)*2);
|
|
||||||
DestinationString->MaximumLength=SourceString->Length;
|
|
||||||
}
|
|
||||||
|
|
||||||
DestinationString->Length=SourceString->Length;
|
if(AllocateDestinationString==TRUE) {
|
||||||
|
|
||||||
dest = DestinationString->Buffer;
|
|
||||||
src = SourceString->Buffer;
|
|
||||||
for(i=0; i<SourceString->Length; i++)
|
|
||||||
{
|
|
||||||
*dest=*src;
|
|
||||||
src++;
|
|
||||||
dest++;
|
|
||||||
}
|
|
||||||
*DestinationString->Buffer=0;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
// Causes excetion 14(0) in _Validate_Free_List
|
||||||
}
|
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length+1);
|
||||||
|
DestinationString->MaximumLength=SourceString->Length+1;
|
||||||
|
};
|
||||||
|
|
||||||
|
DestinationString->Length=SourceString->Length;
|
||||||
|
|
||||||
|
for(i=0; i<SourceString->Length; i++) {
|
||||||
|
*DestinationString->Buffer=*SourceString->Buffer;
|
||||||
|
DestinationString->Buffer++;
|
||||||
|
SourceString->Buffer++;
|
||||||
|
};
|
||||||
|
*DestinationString->Buffer=0;
|
||||||
|
|
||||||
|
DestinationString->Buffer-=SourceString->Length;
|
||||||
|
SourceString->Buffer-=SourceString->Length;
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
};
|
||||||
|
|
||||||
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
|
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
|
||||||
OUT PULONG Value)
|
OUT PULONG Value)
|
||||||
|
@ -511,7 +468,7 @@ NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
|
||||||
*Value=simple_strtoul(str, NULL, Base);
|
*Value=simple_strtoul(str, NULL, Base);
|
||||||
|
|
||||||
ExFreePool(str);
|
ExFreePool(str);
|
||||||
}
|
};
|
||||||
|
|
||||||
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
IN PUNICODE_STRING SourceString,
|
IN PUNICODE_STRING SourceString,
|
||||||
|
@ -520,15 +477,15 @@ NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
unsigned long i;
|
unsigned long i;
|
||||||
|
|
||||||
if(AllocateDestinationString==TRUE) {
|
if(AllocateDestinationString==TRUE) {
|
||||||
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length+1);
|
DestinationString->Buffer=ExAllocatePool(NonPagedPool, SourceString->Length*2+1);
|
||||||
DestinationString->Length=SourceString->Length;
|
DestinationString->Length=SourceString->Length;
|
||||||
DestinationString->MaximumLength-SourceString->Length+1;
|
DestinationString->MaximumLength=SourceString->Length+1;
|
||||||
};
|
};
|
||||||
|
|
||||||
for(i=0; i<SourceString->Length; i++) {
|
for(i=0; i<SourceString->Length; i++) {
|
||||||
*DestinationString->Buffer=wtoupper(*SourceString->Buffer);
|
*DestinationString->Buffer=wtoupper(*SourceString->Buffer);
|
||||||
DestinationString++;
|
DestinationString->Buffer++;
|
||||||
SourceString++;
|
SourceString->Buffer++;
|
||||||
};
|
};
|
||||||
*DestinationString->Buffer=0;
|
*DestinationString->Buffer=0;
|
||||||
|
|
||||||
|
@ -536,7 +493,7 @@ NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
SourceString->Buffer-=SourceString->Length;
|
SourceString->Buffer-=SourceString->Length;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
};
|
||||||
|
|
||||||
VOID RtlUpcaseString(IN OUT PSTRING DestinationString,
|
VOID RtlUpcaseString(IN OUT PSTRING DestinationString,
|
||||||
IN PSTRING SourceString)
|
IN PSTRING SourceString)
|
||||||
|
@ -551,11 +508,11 @@ VOID RtlUpcaseString(IN OUT PSTRING DestinationString,
|
||||||
|
|
||||||
for(i=0; i<len; i++) {
|
for(i=0; i<len; i++) {
|
||||||
*DestinationString->Buffer=toupper(*SourceString->Buffer);
|
*DestinationString->Buffer=toupper(*SourceString->Buffer);
|
||||||
DestinationString++;
|
DestinationString->Buffer++;
|
||||||
SourceString++;
|
SourceString->Buffer++;
|
||||||
};
|
};
|
||||||
*DestinationString->Buffer=0;
|
*DestinationString->Buffer=0;
|
||||||
|
|
||||||
DestinationString->Buffer-=len;
|
DestinationString->Buffer-=len;
|
||||||
SourceString->Buffer-=len;
|
SourceString->Buffer-=len;
|
||||||
}
|
};
|
||||||
|
|
|
@ -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: ntoskrnl/test/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@mcmail.com)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
|
@ -11,41 +11,52 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/kernel.h>
|
#include <internal/kernel.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
#include <in.h>
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
static KEVENT event;
|
static KEVENT event;
|
||||||
|
|
||||||
/* 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)
|
NTSTATUS TstFirstThread(PVOID start)
|
||||||
{
|
{
|
||||||
printk("Beginning Thread A\n");
|
printk("Beginning Thread A\n");
|
||||||
for(;;)
|
KeClearEvent(&event);
|
||||||
{
|
KeSetEvent(&event,IO_NO_INCREMENT,TRUE);
|
||||||
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
|
||||||
KeClearEvent(&event);
|
|
||||||
printk("AAA ");
|
|
||||||
KeSetEvent(&event,IO_NO_INCREMENT,TRUE);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS TstSecondThread(PVOID start)
|
NTSTATUS TstSecondThread(PVOID start)
|
||||||
{
|
{
|
||||||
printk("Beginning Thread B\n");
|
printk("Beginning Thread B\n");
|
||||||
for(;;)
|
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
||||||
{
|
printk("Ending Thread B\n");
|
||||||
KeSetEvent(&event,IO_NO_INCREMENT,TRUE);
|
|
||||||
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
|
||||||
KeClearEvent(&event);
|
|
||||||
printk("BBB ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS TstThreadSupport()
|
NTSTATUS TstThreadSupport()
|
||||||
|
@ -53,22 +64,53 @@ NTSTATUS TstThreadSupport()
|
||||||
HANDLE th1, th2;
|
HANDLE th1, th2;
|
||||||
|
|
||||||
KeInitializeEvent(&event,SynchronizationEvent,FALSE);
|
KeInitializeEvent(&event,SynchronizationEvent,FALSE);
|
||||||
PsCreateSystemThread(&th1,0,NULL,NULL,NULL,TstFirstThread,NULL);
|
// PsCreateSystemThread(&th1,0,NULL,NULL,NULL,TstFirstThread,NULL);
|
||||||
|
KeClearEvent(&event);
|
||||||
PsCreateSystemThread(&th2,0,NULL,NULL,NULL,TstSecondThread,NULL);
|
PsCreateSystemThread(&th2,0,NULL,NULL,NULL,TstSecondThread,NULL);
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TstGeneralWrite()
|
||||||
|
{
|
||||||
|
OBJECT_ATTRIBUTES attr;
|
||||||
|
HANDLE hfile;
|
||||||
|
char buf[256];
|
||||||
|
ANSI_STRING afilename;
|
||||||
|
UNICODE_STRING ufilename;
|
||||||
|
|
||||||
|
DbgPrint("Opening test device\n");
|
||||||
|
RtlInitAnsiString(&afilename,"\\Device\\Test");
|
||||||
|
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
||||||
|
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
||||||
|
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
|
||||||
|
if (hfile==NULL)
|
||||||
|
{
|
||||||
|
DbgPrint("Failed to open test device\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
strcpy(buf,"hello world");
|
||||||
|
ZwWriteFile(hfile,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
buf,
|
||||||
|
strlen(buf),
|
||||||
|
0,
|
||||||
|
0);
|
||||||
|
}
|
||||||
|
|
||||||
void TstParallelPortWrite()
|
void TstParallelPortWrite()
|
||||||
{
|
{
|
||||||
HANDLE hfile;
|
HANDLE hfile;
|
||||||
|
|
||||||
DbgPrint("Opening parallel port\n");
|
DbgPrint("Opening parallel port\n");
|
||||||
hfile = CreateFile("\\Device\\Parallel",0,0,0,0,0,0);
|
// hfile = CreateFile("\\Device\\Parallel",0,0,0,0,0,0);
|
||||||
if (hfile==NULL)
|
if (hfile==NULL)
|
||||||
{
|
{
|
||||||
DbgPrint("Failed to open parallel port\n");
|
DbgPrint("Failed to open parallel port\n");
|
||||||
}
|
}
|
||||||
WriteFile(hfile,"hello world",strlen("hello world"),NULL,NULL);
|
// WriteFile(hfile,"hello world",strlen("hello world"),NULL,NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TstKeyboardRead()
|
void TstKeyboardRead()
|
||||||
|
@ -76,7 +118,7 @@ void TstKeyboardRead()
|
||||||
KEY_EVENT_RECORD key;
|
KEY_EVENT_RECORD key;
|
||||||
HANDLE hfile;
|
HANDLE hfile;
|
||||||
|
|
||||||
hfile = CreateFile("\\Device\\Keyboard",0,0,0,0,0,0);
|
// hfile = CreateFile("\\Device\\Keyboard",0,0,0,0,0,0);
|
||||||
if (hfile == NULL)
|
if (hfile == NULL)
|
||||||
{
|
{
|
||||||
printk("Failed to open keyboard\n");
|
printk("Failed to open keyboard\n");
|
||||||
|
@ -84,7 +126,7 @@ void TstKeyboardRead()
|
||||||
}
|
}
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
ReadFile(hfile,&key,sizeof(KEY_EVENT_RECORD),NULL,NULL);
|
// ReadFile(hfile,&key,sizeof(KEY_EVENT_RECORD),NULL,NULL);
|
||||||
printk("%c",key.AsciiChar);
|
printk("%c",key.AsciiChar);
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
@ -92,6 +134,6 @@ void TstKeyboardRead()
|
||||||
|
|
||||||
void TstBegin()
|
void TstBegin()
|
||||||
{
|
{
|
||||||
TstKeyboardRead();
|
TstGeneralWrite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue