mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Cleaned up code a bit
svn path=/trunk/; revision=339
This commit is contained in:
parent
3f0a7424cb
commit
8688a2a272
80 changed files with 1191 additions and 1213 deletions
|
@ -184,8 +184,8 @@ typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
|
||||||
/*
|
/*
|
||||||
* Driver cancel declaration
|
* Driver cancel declaration
|
||||||
*/
|
*/
|
||||||
typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject,
|
typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DEVICE_OBJECT* DeviceObject,
|
||||||
PUNICODE_STRING RegistryPath);
|
struct _IRP* RegistryPath);
|
||||||
|
|
||||||
|
|
||||||
typedef struct _SECTION_OBJECT_POINTERS
|
typedef struct _SECTION_OBJECT_POINTERS
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#define SET_LARGE_INTEGER_LOW_PART(LI, LP) \
|
#define SET_LARGE_INTEGER_LOW_PART(LI, LP) \
|
||||||
( (LI) = ((LI) & 0xFFFFFFFF00000000L) | (LP) )
|
( (LI) = ((LI) & 0xFFFFFFFF00000000L) | (LP) )
|
||||||
#define LARGE_INTEGER_QUAD_PART(LI) (LI)
|
#define LARGE_INTEGER_QUAD_PART(LI) (LI)
|
||||||
|
#define INITIALIZE_LARGE_INTEGER (0)
|
||||||
|
|
||||||
typedef long long int LONGLONG, *PLONGLONG;
|
typedef long long int LONGLONG, *PLONGLONG;
|
||||||
typedef unsigned long long int ULONGLONG, *PULONGLONG;
|
typedef unsigned long long int ULONGLONG, *PULONGLONG;
|
||||||
|
@ -26,6 +27,7 @@ typedef unsigned long long int ULONGLONG, *PULONGLONG;
|
||||||
#define SET_LARGE_INTEGER_LOW_PART(LargeInteger,Unsigned_Long) \
|
#define SET_LARGE_INTEGER_LOW_PART(LargeInteger,Unsigned_Long) \
|
||||||
((LargeInteger).LowPart = (Unsigned_Long))
|
((LargeInteger).LowPart = (Unsigned_Long))
|
||||||
#define LARGE_INTEGER_QUAD_PART(LI) (*(LONGLONG *)(&(LI)))
|
#define LARGE_INTEGER_QUAD_PART(LI) (*(LONGLONG *)(&(LI)))
|
||||||
|
#define INITIALIZE_LARGE_INTEGER ({0,0})
|
||||||
|
|
||||||
typedef double LONGLONG, *PLONGLONG;
|
typedef double LONGLONG, *PLONGLONG;
|
||||||
typedef double ULONGLONG, *PULONGLONG;
|
typedef double ULONGLONG, *PULONGLONG;
|
||||||
|
|
|
@ -145,7 +145,7 @@ LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
|
||||||
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
|
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
|
||||||
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
|
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
|
||||||
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
|
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
|
||||||
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length);
|
VOID RtlCopyMemory(VOID* Destination, CONST VOID* Source, ULONG Length);
|
||||||
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
|
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
|
||||||
VOID RtlCopyUnicodeString(PUNICODE_STRING DestinationString,
|
VOID RtlCopyUnicodeString(PUNICODE_STRING DestinationString,
|
||||||
PUNICODE_STRING SourceString);
|
PUNICODE_STRING SourceString);
|
||||||
|
|
|
@ -30,6 +30,7 @@ NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
|
||||||
|
|
||||||
VOID IoInitCancelHandling(VOID);
|
VOID IoInitCancelHandling(VOID);
|
||||||
VOID IoInitSymbolicLinkImplementation(VOID);
|
VOID IoInitSymbolicLinkImplementation(VOID);
|
||||||
|
VOID IoInitFileSystemImplementation(VOID);
|
||||||
|
|
||||||
NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject);
|
NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject);
|
||||||
POBJECT IoOpenSymlink(POBJECT SymbolicLink);
|
POBJECT IoOpenSymlink(POBJECT SymbolicLink);
|
||||||
|
@ -54,5 +55,6 @@ NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
||||||
PVOID Parent,
|
PVOID Parent,
|
||||||
PWSTR RemainingPath,
|
PWSTR RemainingPath,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes);
|
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||||
|
NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait);
|
VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait);
|
||||||
VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
|
VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
|
||||||
VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
|
VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
|
||||||
|
VOID KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr);
|
||||||
|
|
||||||
VOID KiInterruptDispatch(ULONG irq);
|
VOID KiInterruptDispatch(ULONG irq);
|
||||||
VOID KiDispatchInterrupt(ULONG irq);
|
VOID KiDispatchInterrupt(ULONG irq);
|
||||||
|
@ -36,10 +37,10 @@ VOID KeInitExceptions(VOID);
|
||||||
VOID KeInitIRQ(VOID);
|
VOID KeInitIRQ(VOID);
|
||||||
VOID KeInitTimer(VOID);
|
VOID KeInitTimer(VOID);
|
||||||
VOID KeInitDpc(VOID);
|
VOID KeInitDpc(VOID);
|
||||||
VOID KeInitBugCheck(VOID);
|
|
||||||
VOID KeInitDispatcher(VOID);
|
VOID KeInitDispatcher(VOID);
|
||||||
VOID KeCalibrateTimerLoop(VOID);
|
VOID KeCalibrateTimerLoop(VOID);
|
||||||
VOID KeInitializeDispatcher(VOID);
|
VOID KeInitializeDispatcher(VOID);
|
||||||
VOID KeInitializeTimerImpl(VOID);
|
VOID KeInitializeTimerImpl(VOID);
|
||||||
|
VOID KeInitializeBugCheck(VOID);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -2,5 +2,7 @@
|
||||||
NTSTATUS LdrLoadDriver(PUNICODE_STRING Filename);
|
NTSTATUS LdrLoadDriver(PUNICODE_STRING Filename);
|
||||||
NTSTATUS LdrLoadInitialProcess(VOID);
|
NTSTATUS LdrLoadInitialProcess(VOID);
|
||||||
VOID LdrLoadAutoConfigDrivers(VOID);
|
VOID LdrLoadAutoConfigDrivers(VOID);
|
||||||
|
VOID LdrInitModuleManagement(VOID);
|
||||||
|
NTSTATUS LdrProcessDriver(PVOID ModuleLoadBase);
|
||||||
|
|
||||||
|
|
||||||
|
|
1
reactos/include/internal/nt.h
Normal file
1
reactos/include/internal/nt.h
Normal file
|
@ -0,0 +1 @@
|
||||||
|
VOID NtInitializeEventImplementation(VOID);
|
|
@ -60,6 +60,7 @@ PVOID ObCreateObject(PHANDLE Handle,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
POBJECT_TYPE Type);
|
POBJECT_TYPE Type);
|
||||||
VOID ObRemoveEntry(POBJECT_HEADER Header);
|
VOID ObRemoveEntry(POBJECT_HEADER Header);
|
||||||
|
NTSTATUS ObPerformRetentionChecks(POBJECT_HEADER Header);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Creates an entry within a directory
|
* FUNCTION: Creates an entry within a directory
|
||||||
|
@ -106,6 +107,9 @@ NTSTATUS ObCreateHandle(PEPROCESS Process,
|
||||||
VOID ObCreateHandleTable(PEPROCESS Parent,
|
VOID ObCreateHandleTable(PEPROCESS Parent,
|
||||||
BOOLEAN Inherit,
|
BOOLEAN Inherit,
|
||||||
PEPROCESS Process);
|
PEPROCESS Process);
|
||||||
|
NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
|
PVOID* ReturnedObject,
|
||||||
|
PWSTR* RemainingPath);
|
||||||
|
|
||||||
|
|
||||||
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */
|
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */
|
||||||
|
|
|
@ -14,6 +14,8 @@ VOID PsInitProcessManagment(VOID);
|
||||||
VOID PsInitIdleThread(VOID);
|
VOID PsInitIdleThread(VOID);
|
||||||
VOID PsDispatchThread(VOID);
|
VOID PsDispatchThread(VOID);
|
||||||
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus);
|
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus);
|
||||||
|
VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus);
|
||||||
|
VOID PsReleaseThread(PETHREAD Thread);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Thread states
|
* PURPOSE: Thread states
|
||||||
|
@ -54,5 +56,6 @@ void HalInitFirstTask(PETHREAD thread);
|
||||||
BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
|
BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
|
||||||
void HalTaskSwitch(PKTHREAD thread);
|
void HalTaskSwitch(PKTHREAD thread);
|
||||||
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context);
|
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context);
|
||||||
|
NTSTATUS HalReleaseTask(PETHREAD Thread);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,60 +0,0 @@
|
||||||
#ifndef _LINUX_TYPES_H
|
|
||||||
#define _LINUX_TYPES_H
|
|
||||||
|
|
||||||
#ifndef NULL
|
|
||||||
# define NULL ((void *) 0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef _I386_TYPES_H
|
|
||||||
#define _I386_TYPES_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
* __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
|
|
||||||
* header files exported to user space
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef __signed__ char __s8;
|
|
||||||
typedef unsigned char __u8;
|
|
||||||
|
|
||||||
typedef __signed__ short __s16;
|
|
||||||
typedef unsigned short __u16;
|
|
||||||
|
|
||||||
typedef __signed__ int __s32;
|
|
||||||
typedef unsigned int __u32;
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
|
|
||||||
typedef __signed__ long long __s64;
|
|
||||||
typedef unsigned long long __u64;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
* These aren't exported outside the kernel to avoid name space clashes
|
|
||||||
*/
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
|
|
||||||
typedef signed char s8;
|
|
||||||
typedef unsigned char u8;
|
|
||||||
|
|
||||||
typedef signed short s16;
|
|
||||||
typedef unsigned short u16;
|
|
||||||
|
|
||||||
typedef signed int s32;
|
|
||||||
typedef unsigned int u32;
|
|
||||||
|
|
||||||
typedef signed long long s64;
|
|
||||||
typedef unsigned long long u64;
|
|
||||||
|
|
||||||
#endif /* __KERNEL__ */
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef SIZE_T_DEFINED
|
|
||||||
#define SIZE_T_DEFINED
|
|
||||||
typedef unsigned int size_t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef size_t __kernel_size_t;
|
|
||||||
|
|
||||||
#endif /* _LINUX_TYPES_H */
|
|
16
reactos/include/ntdll/ldr.h
Normal file
16
reactos/include/ntdll/ldr.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
typedef NTSTATUS (*PEPFUNC)(VOID);
|
||||||
|
|
||||||
|
typedef struct _DLL
|
||||||
|
{
|
||||||
|
PIMAGE_NT_HEADERS Headers;
|
||||||
|
PVOID BaseAddress;
|
||||||
|
HANDLE SectionHandle;
|
||||||
|
struct _DLL* Prev;
|
||||||
|
struct _DLL* Next;
|
||||||
|
} DLL, *PDLL;
|
||||||
|
|
||||||
|
#define RVA(m, b) ((ULONG)b + m)
|
||||||
|
|
||||||
|
extern DLL LdrDllListHead;
|
||||||
|
|
||||||
|
PEPFUNC LdrPEStartup(PVOID ImageBase, HANDLE SectionHandle);
|
|
@ -1,5 +1,7 @@
|
||||||
extern void dprintf(char* fmt,...);
|
extern void dprintf(char* fmt,...);
|
||||||
|
|
||||||
|
#define UNIMPLEMENTED dprintf("%s in %s:%d is unimplemented\n",__FUNCTION__,__FILE__,__LINE__);
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define DPRINT(args...)
|
#define DPRINT(args...)
|
||||||
#else
|
#else
|
||||||
|
|
9
reactos/include/ntdll/rtl.h
Normal file
9
reactos/include/ntdll/rtl.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
VOID WINAPI __RtlInitHeap(PVOID base, ULONG minsize, ULONG maxsize);
|
||||||
|
|
||||||
|
#define HEAP_BASE (0xa0000000)
|
||||||
|
|
||||||
|
VOID RtlDeleteCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
|
||||||
|
VOID RtlEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
|
||||||
|
VOID RtlInitializeCriticalSection(LPCRITICAL_SECTION pcritical);
|
||||||
|
VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
|
||||||
|
WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
|
|
@ -433,8 +433,8 @@ RtlUnlockHeap@4
|
||||||
RtlValidateHeap@12
|
RtlValidateHeap@12
|
||||||
RtlInitAnsiString
|
RtlInitAnsiString
|
||||||
RtlInitUnicodeString
|
RtlInitUnicodeString
|
||||||
RtlLargeIntegerDivide
|
|
||||||
RtlLargeIntegerAdd
|
RtlLargeIntegerAdd
|
||||||
|
RtlLargeIntegerDivide
|
||||||
RtlEnlargedIntegerMultiply
|
RtlEnlargedIntegerMultiply
|
||||||
RtlEnlargedUnsignedMultiply
|
RtlEnlargedUnsignedMultiply
|
||||||
RtlExtendedIntegerMultiply
|
RtlExtendedIntegerMultiply
|
||||||
|
@ -455,9 +455,9 @@ wcscpy
|
||||||
wcschr
|
wcschr
|
||||||
wcscat
|
wcscat
|
||||||
wcscmp
|
wcscmp
|
||||||
wcsicmp
|
|
||||||
wcsnicmp
|
|
||||||
wcsncpy
|
wcsncpy
|
||||||
wcslen
|
wcslen
|
||||||
wcsrchr
|
wcsrchr
|
||||||
|
wcsicmp
|
||||||
|
wcsnicmp
|
||||||
vsprintf
|
vsprintf
|
||||||
|
|
|
@ -14,221 +14,20 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <pe.h>
|
#include <pe.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <internal/string.h>
|
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <ntdll/ldr.h>
|
||||||
|
#include <ntdll/rtl.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
//#define NDEBUG
|
||||||
#include <ntdll/ntdll.h>
|
#include <ntdll/ntdll.h>
|
||||||
|
|
||||||
PVOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize);
|
|
||||||
|
|
||||||
/* MACROS ********************************************************************/
|
|
||||||
|
|
||||||
#define RVA(m, b) ((ULONG)b + m)
|
|
||||||
|
|
||||||
/* TYPEDEFS ******************************************************************/
|
|
||||||
|
|
||||||
typedef NTSTATUS (*PEPFUNC)(VOID);
|
|
||||||
|
|
||||||
typedef struct _DLL
|
|
||||||
{
|
|
||||||
PIMAGE_NT_HEADERS Headers;
|
|
||||||
PVOID BaseAddress;
|
|
||||||
struct _DLL* Prev;
|
|
||||||
struct _DLL* Next;
|
|
||||||
} DLL, *PDLL;
|
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
static DLL DllListHead;
|
DLL LdrDllListHead;
|
||||||
|
extern unsigned int _image_base__;
|
||||||
#define HEAP_BASE (0xa0000000)
|
|
||||||
|
|
||||||
/* FORWARD DECLARATIONS ******************************************************/
|
|
||||||
|
|
||||||
static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle);
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
static NTSTATUS LdrMapSections(PVOID ImageBase, HANDLE SectionHandle,
|
|
||||||
PIMAGE_NT_HEADERS NTHeaders)
|
|
||||||
{
|
|
||||||
ULONG i;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
for (i=0; i<NTHeaders->FileHeader.NumberOfSections; i++)
|
|
||||||
{
|
|
||||||
PIMAGE_SECTION_HEADER Sections;
|
|
||||||
LARGE_INTEGER Offset;
|
|
||||||
ULONG Base;
|
|
||||||
|
|
||||||
Sections = (PIMAGE_SECTION_HEADER)SECHDROFFSET(ImageBase);
|
|
||||||
Base = Sections[i].VirtualAddress + ImageBase;
|
|
||||||
SET_LARGE_INTEGER_HIGH_PART(Offset,0);
|
|
||||||
SET_LARGE_INTEGER_LOW_PART(Offset,Sections[i].PointerToRawData);
|
|
||||||
Status = ZwMapViewOfSection(SectionHandle,
|
|
||||||
NtCurrentProcess(),
|
|
||||||
(PVOID *)&Base,
|
|
||||||
0,
|
|
||||||
Sections[i].Misc.VirtualSize,
|
|
||||||
&Offset,
|
|
||||||
&Sections[i].Misc.VirtualSize,
|
|
||||||
0,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS LdrLoadDll(PDLL* Base, PCHAR Name)
|
|
||||||
{
|
|
||||||
char fqname[255] = "\\??\\C:\\reactos\\system\\";
|
|
||||||
ANSI_STRING AnsiString;
|
|
||||||
UNICODE_STRING UnicodeString;
|
|
||||||
OBJECT_ATTRIBUTES FileObjectAttributes;
|
|
||||||
char BlockBuffer[1024];
|
|
||||||
PIMAGE_DOS_HEADER DosHeader;
|
|
||||||
NTSTATUS Status;
|
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
|
||||||
PEPFUNC DllStartupAddr;
|
|
||||||
ULONG ImageBase, ImageSize, InitialViewSize;
|
|
||||||
HANDLE FileHandle, SectionHandle;
|
|
||||||
PDLL DllDesc;
|
|
||||||
|
|
||||||
DPRINT("LdrLoadDll(Base %x, Name %s)\n",Base,Name);
|
|
||||||
|
|
||||||
strcat(fqname, Name);
|
|
||||||
|
|
||||||
DPRINT("fqname %s\n",fqname);
|
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiString,fqname);
|
|
||||||
RtlAnsiStringToUnicodeString(&UnicodeString,&AnsiString,TRUE);
|
|
||||||
|
|
||||||
InitializeObjectAttributes(&FileObjectAttributes,
|
|
||||||
&UnicodeString,
|
|
||||||
0,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
DPRINT("Opening dll\n");
|
|
||||||
Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes,
|
|
||||||
NULL, 0, 0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("Dll open failed ");
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("Dll header read failed ");
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
|
|
||||||
if (DosHeader->e_magic != IMAGE_DOS_MAGIC ||
|
|
||||||
DosHeader->e_lfanew == 0L ||
|
|
||||||
*(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
|
|
||||||
{
|
|
||||||
DPRINT("NTDLL format invalid\n");
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
|
|
||||||
ImageBase = NTHeaders->OptionalHeader.ImageBase;
|
|
||||||
ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
|
|
||||||
|
|
||||||
DPRINT("ImageBase %x\n",ImageBase);
|
|
||||||
DllStartupAddr = ImageBase + NTHeaders->OptionalHeader.AddressOfEntryPoint;
|
|
||||||
|
|
||||||
/* Create a section for NTDLL */
|
|
||||||
Status = ZwCreateSection(&SectionHandle,
|
|
||||||
SECTION_ALL_ACCESS,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
PAGE_READWRITE,
|
|
||||||
MEM_COMMIT,
|
|
||||||
FileHandle);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("NTDLL create section failed ");
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Map the NTDLL into the process */
|
|
||||||
InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)
|
|
||||||
+ sizeof(IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
|
|
||||||
Status = ZwMapViewOfSection(SectionHandle,
|
|
||||||
NtCurrentProcess(),
|
|
||||||
(PVOID *)&ImageBase,
|
|
||||||
0,
|
|
||||||
InitialViewSize,
|
|
||||||
NULL,
|
|
||||||
&InitialViewSize,
|
|
||||||
0,
|
|
||||||
MEM_COMMIT,
|
|
||||||
PAGE_READWRITE);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("NTDLL map view of secion failed ");
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
ZwClose(FileHandle);
|
|
||||||
|
|
||||||
DllDesc = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DLL));
|
|
||||||
DllDesc->Headers = NTHeaders;
|
|
||||||
DllDesc->BaseAddress = ImageBase;
|
|
||||||
DllDesc->Next = DllListHead.Next;
|
|
||||||
DllDesc->Prev = &DllListHead;
|
|
||||||
DllListHead.Next->Prev = DllDesc;
|
|
||||||
DllListHead.Next = DllDesc;
|
|
||||||
|
|
||||||
LdrPEStartup(ImageBase, SectionHandle);
|
|
||||||
|
|
||||||
*Base = DllDesc;
|
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS LdrFindDll(PDLL* Base, PCHAR Name)
|
|
||||||
{
|
|
||||||
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
|
||||||
DLL* current;
|
|
||||||
PIMAGE_OPTIONAL_HEADER OptionalHeader;
|
|
||||||
|
|
||||||
DPRINT("LdrFindDll(Name %s)\n",Name);
|
|
||||||
|
|
||||||
current = &DllListHead;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
OptionalHeader = ¤t->Headers->OptionalHeader;
|
|
||||||
ExportDir = (PIMAGE_EXPORT_DIRECTORY)OptionalHeader->DataDirectory[
|
|
||||||
IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
|
|
||||||
ExportDir = ((ULONG)ExportDir + (ULONG)current->BaseAddress);
|
|
||||||
|
|
||||||
DPRINT("Scanning %s\n",ExportDir->Name + current->BaseAddress);
|
|
||||||
if (strcmp(ExportDir->Name + current->BaseAddress, Name) == 0)
|
|
||||||
{
|
|
||||||
*Base = current;
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
current = current->Next;
|
|
||||||
} while (current != &DllListHead);
|
|
||||||
|
|
||||||
DPRINT("Failed to find dll %s\n",Name);
|
|
||||||
|
|
||||||
return(LdrLoadDll(Base, Name));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* LdrStartup
|
/* LdrStartup
|
||||||
* FUNCTION:
|
* FUNCTION:
|
||||||
* Handles Process Startup Activities.
|
* Handles Process Startup Activities.
|
||||||
|
@ -245,11 +44,13 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
|
||||||
DPRINT("LdrStartup(ImageBase %x, SectionHandle %x)\n",ImageBase,
|
DPRINT("LdrStartup(ImageBase %x, SectionHandle %x)\n",ImageBase,
|
||||||
SectionHandle);
|
SectionHandle);
|
||||||
|
|
||||||
DllListHead.BaseAddress = 0x80000000;
|
DPRINT("&_image_base__ %x\n",&_image_base__);
|
||||||
DllListHead.Prev = &DllListHead;
|
LdrDllListHead.BaseAddress = (PVOID)&_image_base__;
|
||||||
DllListHead.Next = &DllListHead;
|
LdrDllListHead.Prev = &LdrDllListHead;
|
||||||
PEDosHeader = (PIMAGE_DOS_HEADER)DllListHead.BaseAddress;
|
LdrDllListHead.Next = &LdrDllListHead;
|
||||||
DllListHead.Headers = (PIMAGE_NT_HEADERS)(DllListHead.BaseAddress +
|
LdrDllListHead.SectionHandle = SectionHandle;
|
||||||
|
PEDosHeader = (PIMAGE_DOS_HEADER)LdrDllListHead.BaseAddress;
|
||||||
|
LdrDllListHead.Headers = (PIMAGE_NT_HEADERS)(LdrDllListHead.BaseAddress +
|
||||||
PEDosHeader->e_lfanew);
|
PEDosHeader->e_lfanew);
|
||||||
|
|
||||||
/* If MZ header exists */
|
/* If MZ header exists */
|
||||||
|
@ -263,10 +64,10 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
|
||||||
}
|
}
|
||||||
|
|
||||||
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew);
|
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew);
|
||||||
__RtlInitHeap(HEAP_BASE,
|
__RtlInitHeap((PVOID)HEAP_BASE,
|
||||||
NTHeaders->OptionalHeader.SizeOfHeapCommit,
|
NTHeaders->OptionalHeader.SizeOfHeapCommit,
|
||||||
NTHeaders->OptionalHeader.SizeOfHeapReserve);
|
NTHeaders->OptionalHeader.SizeOfHeapReserve);
|
||||||
EntryPoint = LdrPEStartup(ImageBase, SectionHandle);
|
EntryPoint = LdrPEStartup((PVOID)ImageBase, SectionHandle);
|
||||||
|
|
||||||
if (EntryPoint == NULL)
|
if (EntryPoint == NULL)
|
||||||
{
|
{
|
||||||
|
@ -278,234 +79,3 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
|
||||||
Status = EntryPoint();
|
Status = EntryPoint();
|
||||||
ZwTerminateProcess(NtCurrentProcess(),Status);
|
ZwTerminateProcess(NtCurrentProcess(),Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PVOID LdrGetExportByOrdinal(PDLL Module, ULONG Ordinal)
|
|
||||||
{
|
|
||||||
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
|
||||||
USHORT* ExOrdinals;
|
|
||||||
|
|
||||||
ExportDir = (Module->BaseAddress +
|
|
||||||
(Module->Headers->OptionalHeader.
|
|
||||||
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
|
|
||||||
|
|
||||||
ExOrdinals = (USHORT*)RVA(Module->BaseAddress,
|
|
||||||
ExportDir->AddressOfNameOrdinals);
|
|
||||||
return(ExOrdinals[Ordinal - ExportDir->Base]);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PVOID LdrGetExportByName(PDLL Module, PUCHAR SymbolName)
|
|
||||||
{
|
|
||||||
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
|
||||||
PDWORD* ExFunctions;
|
|
||||||
PDWORD* ExNames;
|
|
||||||
USHORT* ExOrdinals;
|
|
||||||
ULONG i;
|
|
||||||
PVOID ExName;
|
|
||||||
ULONG Ordinal;
|
|
||||||
|
|
||||||
DPRINT("LdrFindExport(Module %x, SymbolName %s)\n",
|
|
||||||
Module, SymbolName);
|
|
||||||
|
|
||||||
ExportDir = (Module->BaseAddress +
|
|
||||||
(Module->Headers->OptionalHeader.
|
|
||||||
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
|
|
||||||
|
|
||||||
/* Get header pointers */
|
|
||||||
ExNames = (PDWORD*)RVA(Module->BaseAddress, ExportDir->AddressOfNames);
|
|
||||||
ExOrdinals = (USHORT*)RVA(Module->BaseAddress,
|
|
||||||
ExportDir->AddressOfNameOrdinals);
|
|
||||||
ExFunctions = (PDWORD*)RVA(Module->BaseAddress,
|
|
||||||
ExportDir->AddressOfFunctions);
|
|
||||||
for (i=0; i<ExportDir->NumberOfFunctions; i++)
|
|
||||||
{
|
|
||||||
ExName = RVA(Module->BaseAddress, ExNames[i]);
|
|
||||||
if (strcmp(ExName,SymbolName) == 0)
|
|
||||||
{
|
|
||||||
Ordinal = ExOrdinals[i];
|
|
||||||
return(RVA(Module->BaseAddress, ExFunctions[Ordinal]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
|
|
||||||
DWORD ImageBase)
|
|
||||||
{
|
|
||||||
USHORT NumberOfEntries;
|
|
||||||
PUSHORT pValue16;
|
|
||||||
ULONG RelocationRVA;
|
|
||||||
ULONG Delta32, Offset;
|
|
||||||
PULONG pValue32;
|
|
||||||
PRELOCATION_DIRECTORY RelocationDir;
|
|
||||||
PRELOCATION_ENTRY RelocationBlock;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[
|
|
||||||
IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
|
|
||||||
if (RelocationRVA)
|
|
||||||
{
|
|
||||||
RelocationDir = (PRELOCATION_DIRECTORY)((PCHAR)ImageBase +
|
|
||||||
RelocationRVA);
|
|
||||||
while (RelocationDir->SizeOfBlock)
|
|
||||||
{
|
|
||||||
Delta32 = (unsigned long)(ImageBase -
|
|
||||||
NTHeaders->OptionalHeader.ImageBase);
|
|
||||||
RelocationBlock = (PRELOCATION_ENTRY)
|
|
||||||
(RelocationRVA + ImageBase + sizeof(RELOCATION_DIRECTORY));
|
|
||||||
NumberOfEntries =
|
|
||||||
(RelocationDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) /
|
|
||||||
sizeof(RELOCATION_ENTRY);
|
|
||||||
for (i = 0; i < NumberOfEntries; i++)
|
|
||||||
{
|
|
||||||
Offset = (RelocationBlock[i].TypeOffset & 0xfff) +
|
|
||||||
RelocationDir->VirtualAddress;
|
|
||||||
switch (RelocationBlock[i].TypeOffset >> 12)
|
|
||||||
{
|
|
||||||
case TYPE_RELOC_ABSOLUTE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_RELOC_HIGH:
|
|
||||||
pValue16 = (PUSHORT) (ImageBase + Offset);
|
|
||||||
*pValue16 += Delta32 >> 16;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_RELOC_LOW:
|
|
||||||
pValue16 = (PUSHORT)(ImageBase + Offset);
|
|
||||||
*pValue16 += Delta32 & 0xffff;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_RELOC_HIGHLOW:
|
|
||||||
pValue32 = (PULONG) (ImageBase + Offset);
|
|
||||||
*pValue32 += Delta32;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TYPE_RELOC_HIGHADJ:
|
|
||||||
/* FIXME: do the highadjust fixup */
|
|
||||||
DPRINT("TYPE_RELOC_HIGHADJ fixup not implemented"
|
|
||||||
", sorry\n");
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
|
|
||||||
default:
|
|
||||||
DPRINT("unexpected fixup type\n");
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
RelocationRVA += RelocationDir->SizeOfBlock;
|
|
||||||
RelocationDir = (PRELOCATION_DIRECTORY)(ImageBase +
|
|
||||||
RelocationRVA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
|
|
||||||
DWORD ImageBase)
|
|
||||||
{
|
|
||||||
PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory;
|
|
||||||
ULONG Ordinal;
|
|
||||||
PDLL Module;
|
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
/* Process each import module */
|
|
||||||
ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
|
|
||||||
(ImageBase + NTHeaders->OptionalHeader.
|
|
||||||
DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
|
|
||||||
while (ImportModuleDirectory->dwRVAModuleName)
|
|
||||||
{
|
|
||||||
PVOID *ImportAddressList;
|
|
||||||
PULONG FunctionNameList;
|
|
||||||
DWORD pName;
|
|
||||||
PWORD pHint;
|
|
||||||
|
|
||||||
Status = LdrFindDll(&Module,
|
|
||||||
(PCHAR)(ImageBase +
|
|
||||||
ImportModuleDirectory->dwRVAModuleName));
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get the import address list */
|
|
||||||
ImportAddressList = (PVOID *)
|
|
||||||
(NTHeaders->OptionalHeader.ImageBase +
|
|
||||||
ImportModuleDirectory->dwRVAFunctionAddressList);
|
|
||||||
|
|
||||||
/* Get the list of functions to import */
|
|
||||||
if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
|
|
||||||
{
|
|
||||||
FunctionNameList = (PULONG) (ImageBase +
|
|
||||||
ImportModuleDirectory->dwRVAFunctionNameList);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
FunctionNameList = (PULONG) (ImageBase +
|
|
||||||
ImportModuleDirectory->dwRVAFunctionAddressList);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Walk through function list and fixup addresses */
|
|
||||||
while(*FunctionNameList != 0L)
|
|
||||||
{
|
|
||||||
if ((*FunctionNameList) & 0x80000000)
|
|
||||||
{
|
|
||||||
Ordinal = (*FunctionNameList) & 0x7fffffff;
|
|
||||||
*ImportAddressList = LdrGetExportByOrdinal(Module, Ordinal);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pName = (DWORD)(ImageBase + *FunctionNameList + 2);
|
|
||||||
pHint = (PWORD)(ImageBase + *FunctionNameList);
|
|
||||||
|
|
||||||
*ImportAddressList = LdrGetExportByName(Module,pName);
|
|
||||||
if ((*ImportAddressList) == NULL)
|
|
||||||
{
|
|
||||||
return(STATUS_UNSUCCESSFUL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ImportAddressList++;
|
|
||||||
FunctionNameList++;
|
|
||||||
}
|
|
||||||
ImportModuleDirectory++;
|
|
||||||
}
|
|
||||||
return(STATUS_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
|
||||||
PEPFUNC EntryPoint;
|
|
||||||
PIMAGE_DOS_HEADER DosHeader;
|
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
|
||||||
|
|
||||||
DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
|
|
||||||
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + DosHeader->e_lfanew);
|
|
||||||
|
|
||||||
/* Initialize Image sections */
|
|
||||||
LdrMapSections(ImageBase, SectionHandle, NTHeaders);
|
|
||||||
|
|
||||||
if (ImageBase != (DWORD) NTHeaders->OptionalHeader.ImageBase)
|
|
||||||
{
|
|
||||||
Status = LdrPerformRelocations(NTHeaders, ImageBase);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].
|
|
||||||
VirtualAddress != 0)
|
|
||||||
{
|
|
||||||
Status = LdrFixupImports(NTHeaders, ImageBase);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
EntryPoint = ImageBase + NTHeaders->OptionalHeader.AddressOfEntryPoint;
|
|
||||||
|
|
||||||
return(EntryPoint);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
442
reactos/lib/ntdll/ldr/utils.c
Normal file
442
reactos/lib/ntdll/ldr/utils.c
Normal file
|
@ -0,0 +1,442 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS kernel
|
||||||
|
* FILE: lib/ntdll/ldr/startup.c
|
||||||
|
* PURPOSE: Process startup for PE executables
|
||||||
|
* PROGRAMMERS: Jean Michault
|
||||||
|
* Rex Jolliff (rex@lvcablemodem.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
|
#define WIN32_NO_PEHDR
|
||||||
|
#include <windows.h>
|
||||||
|
#include <ddk/ntddk.h>
|
||||||
|
#include <pe.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <internal/string.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
#include <ntdll/ldr.h>
|
||||||
|
|
||||||
|
//#define NDEBUG
|
||||||
|
#include <ntdll/ntdll.h>
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
static NTSTATUS LdrLoadDll(PDLL* Dll, PCHAR Name)
|
||||||
|
{
|
||||||
|
char fqname[255] = "\\??\\C:\\reactos\\system\\";
|
||||||
|
ANSI_STRING AnsiString;
|
||||||
|
UNICODE_STRING UnicodeString;
|
||||||
|
OBJECT_ATTRIBUTES FileObjectAttributes;
|
||||||
|
char BlockBuffer[1024];
|
||||||
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
|
NTSTATUS Status;
|
||||||
|
PIMAGE_NT_HEADERS NTHeaders;
|
||||||
|
PEPFUNC DllStartupAddr;
|
||||||
|
ULONG ImageSize, InitialViewSize;
|
||||||
|
PVOID ImageBase;
|
||||||
|
HANDLE FileHandle, SectionHandle;
|
||||||
|
|
||||||
|
DPRINT("LdrLoadDll(Base %x, Name %s)\n",Dll,Name);
|
||||||
|
|
||||||
|
strcat(fqname, Name);
|
||||||
|
|
||||||
|
DPRINT("fqname %s\n",fqname);
|
||||||
|
|
||||||
|
RtlInitAnsiString(&AnsiString,fqname);
|
||||||
|
RtlAnsiStringToUnicodeString(&UnicodeString,&AnsiString,TRUE);
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&FileObjectAttributes,
|
||||||
|
&UnicodeString,
|
||||||
|
0,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
DPRINT("Opening dll\n");
|
||||||
|
Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes,
|
||||||
|
NULL, 0, 0);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("Dll open failed ");
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("Dll header read failed ");
|
||||||
|
ZwClose(FileHandle);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
|
||||||
|
if (DosHeader->e_magic != IMAGE_DOS_MAGIC ||
|
||||||
|
DosHeader->e_lfanew == 0L ||
|
||||||
|
*(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
|
||||||
|
{
|
||||||
|
DPRINT("NTDLL format invalid\n");
|
||||||
|
ZwClose(FileHandle);
|
||||||
|
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
|
||||||
|
ImageBase = (PVOID)NTHeaders->OptionalHeader.ImageBase;
|
||||||
|
ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
|
||||||
|
|
||||||
|
DPRINT("ImageBase %x\n",ImageBase);
|
||||||
|
DllStartupAddr = (PEPFUNC)(ImageBase +
|
||||||
|
NTHeaders->OptionalHeader.AddressOfEntryPoint);
|
||||||
|
|
||||||
|
/* Create a section for NTDLL */
|
||||||
|
Status = ZwCreateSection(&SectionHandle,
|
||||||
|
SECTION_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
PAGE_READWRITE,
|
||||||
|
MEM_COMMIT,
|
||||||
|
FileHandle);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("NTDLL create section failed ");
|
||||||
|
ZwClose(FileHandle);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Map the NTDLL into the process */
|
||||||
|
InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)
|
||||||
|
+ sizeof(IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
|
||||||
|
Status = ZwMapViewOfSection(SectionHandle,
|
||||||
|
NtCurrentProcess(),
|
||||||
|
(PVOID *)&ImageBase,
|
||||||
|
0,
|
||||||
|
InitialViewSize,
|
||||||
|
NULL,
|
||||||
|
&InitialViewSize,
|
||||||
|
0,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("NTDLL map view of secion failed ");
|
||||||
|
ZwClose(FileHandle);
|
||||||
|
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
ZwClose(FileHandle);
|
||||||
|
|
||||||
|
(*Dll) = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DLL));
|
||||||
|
(*Dll)->Headers = NTHeaders;
|
||||||
|
(*Dll)->BaseAddress = (PVOID)ImageBase;
|
||||||
|
(*Dll)->Next = LdrDllListHead.Next;
|
||||||
|
(*Dll)->Prev = &LdrDllListHead;
|
||||||
|
LdrDllListHead.Next->Prev = (*Dll);
|
||||||
|
LdrDllListHead.Next = (*Dll);
|
||||||
|
|
||||||
|
LdrPEStartup(ImageBase, SectionHandle);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS LdrFindDll(PDLL* Dll, PCHAR Name)
|
||||||
|
{
|
||||||
|
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
||||||
|
DLL* current;
|
||||||
|
PIMAGE_OPTIONAL_HEADER OptionalHeader;
|
||||||
|
|
||||||
|
DPRINT("LdrFindDll(Name %s)\n",Name);
|
||||||
|
|
||||||
|
current = &LdrDllListHead;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
OptionalHeader = ¤t->Headers->OptionalHeader;
|
||||||
|
ExportDir = (PIMAGE_EXPORT_DIRECTORY)OptionalHeader->DataDirectory[
|
||||||
|
IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
|
||||||
|
ExportDir = (PIMAGE_EXPORT_DIRECTORY)
|
||||||
|
((ULONG)ExportDir + (ULONG)current->BaseAddress);
|
||||||
|
|
||||||
|
DPRINT("Scanning %x %x %x\n", ExportDir->Name,
|
||||||
|
current->BaseAddress, ExportDir->Name + current->BaseAddress);
|
||||||
|
DPRINT("Scanning %s\n", ExportDir->Name + current->BaseAddress);
|
||||||
|
if (strcmp(ExportDir->Name + current->BaseAddress, Name) == 0)
|
||||||
|
{
|
||||||
|
*Dll = current;
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
current = current->Next;
|
||||||
|
} while (current != &LdrDllListHead);
|
||||||
|
|
||||||
|
DPRINT("Failed to find dll %s\n",Name);
|
||||||
|
|
||||||
|
return(LdrLoadDll(Dll, Name));
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS LdrMapSections(PVOID ImageBase,
|
||||||
|
HANDLE SectionHandle,
|
||||||
|
PIMAGE_NT_HEADERS NTHeaders)
|
||||||
|
{
|
||||||
|
ULONG i;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
for (i=0; i<NTHeaders->FileHeader.NumberOfSections; i++)
|
||||||
|
{
|
||||||
|
PIMAGE_SECTION_HEADER Sections;
|
||||||
|
LARGE_INTEGER Offset;
|
||||||
|
ULONG Base;
|
||||||
|
|
||||||
|
Sections = (PIMAGE_SECTION_HEADER)SECHDROFFSET(ImageBase);
|
||||||
|
Base = (ULONG)(Sections[i].VirtualAddress + ImageBase);
|
||||||
|
SET_LARGE_INTEGER_HIGH_PART(Offset,0);
|
||||||
|
SET_LARGE_INTEGER_LOW_PART(Offset,Sections[i].PointerToRawData);
|
||||||
|
Status = ZwMapViewOfSection(SectionHandle,
|
||||||
|
NtCurrentProcess(),
|
||||||
|
(PVOID *)&Base,
|
||||||
|
0,
|
||||||
|
Sections[i].Misc.VirtualSize,
|
||||||
|
&Offset,
|
||||||
|
(PULONG)&Sections[i].Misc.VirtualSize,
|
||||||
|
0,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PVOID LdrGetExportByOrdinal(PDLL Module, ULONG Ordinal)
|
||||||
|
{
|
||||||
|
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
||||||
|
PDWORD* ExFunctions;
|
||||||
|
USHORT* ExOrdinals;
|
||||||
|
|
||||||
|
ExportDir = (Module->BaseAddress +
|
||||||
|
(Module->Headers->OptionalHeader.
|
||||||
|
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
|
||||||
|
|
||||||
|
ExOrdinals = (USHORT*)RVA(Module->BaseAddress,
|
||||||
|
ExportDir->AddressOfNameOrdinals);
|
||||||
|
ExFunctions = (PDWORD*)RVA(Module->BaseAddress,
|
||||||
|
ExportDir->AddressOfFunctions);
|
||||||
|
return(ExFunctions[ExOrdinals[Ordinal - ExportDir->Base]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PVOID LdrGetExportByName(PDLL Module, PUCHAR SymbolName)
|
||||||
|
{
|
||||||
|
PIMAGE_EXPORT_DIRECTORY ExportDir;
|
||||||
|
PDWORD* ExFunctions;
|
||||||
|
PDWORD* ExNames;
|
||||||
|
USHORT* ExOrdinals;
|
||||||
|
ULONG i;
|
||||||
|
PVOID ExName;
|
||||||
|
ULONG Ordinal;
|
||||||
|
|
||||||
|
DPRINT("LdrFindExport(Module %x, SymbolName %s)\n",
|
||||||
|
Module, SymbolName);
|
||||||
|
|
||||||
|
ExportDir = (Module->BaseAddress +
|
||||||
|
(Module->Headers->OptionalHeader.
|
||||||
|
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
|
||||||
|
|
||||||
|
/* Get header pointers */
|
||||||
|
ExNames = (PDWORD*)RVA(Module->BaseAddress, ExportDir->AddressOfNames);
|
||||||
|
ExOrdinals = (USHORT*)RVA(Module->BaseAddress,
|
||||||
|
ExportDir->AddressOfNameOrdinals);
|
||||||
|
ExFunctions = (PDWORD*)RVA(Module->BaseAddress,
|
||||||
|
ExportDir->AddressOfFunctions);
|
||||||
|
for (i=0; i<ExportDir->NumberOfFunctions; i++)
|
||||||
|
{
|
||||||
|
ExName = RVA(Module->BaseAddress, ExNames[i]);
|
||||||
|
if (strcmp(ExName,SymbolName) == 0)
|
||||||
|
{
|
||||||
|
Ordinal = ExOrdinals[i];
|
||||||
|
return(RVA(Module->BaseAddress, ExFunctions[Ordinal]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
|
||||||
|
PVOID ImageBase)
|
||||||
|
{
|
||||||
|
USHORT NumberOfEntries;
|
||||||
|
PUSHORT pValue16;
|
||||||
|
ULONG RelocationRVA;
|
||||||
|
ULONG Delta32, Offset;
|
||||||
|
PULONG pValue32;
|
||||||
|
PRELOCATION_DIRECTORY RelocationDir;
|
||||||
|
PRELOCATION_ENTRY RelocationBlock;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[
|
||||||
|
IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
|
||||||
|
if (RelocationRVA)
|
||||||
|
{
|
||||||
|
RelocationDir = (PRELOCATION_DIRECTORY)((PCHAR)ImageBase +
|
||||||
|
RelocationRVA);
|
||||||
|
while (RelocationDir->SizeOfBlock)
|
||||||
|
{
|
||||||
|
Delta32 = (unsigned long)(ImageBase -
|
||||||
|
NTHeaders->OptionalHeader.ImageBase);
|
||||||
|
RelocationBlock = (PRELOCATION_ENTRY)
|
||||||
|
(RelocationRVA + ImageBase + sizeof(RELOCATION_DIRECTORY));
|
||||||
|
NumberOfEntries =
|
||||||
|
(RelocationDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) /
|
||||||
|
sizeof(RELOCATION_ENTRY);
|
||||||
|
for (i = 0; i < NumberOfEntries; i++)
|
||||||
|
{
|
||||||
|
Offset = (RelocationBlock[i].TypeOffset & 0xfff) +
|
||||||
|
RelocationDir->VirtualAddress;
|
||||||
|
switch (RelocationBlock[i].TypeOffset >> 12)
|
||||||
|
{
|
||||||
|
case TYPE_RELOC_ABSOLUTE:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_RELOC_HIGH:
|
||||||
|
pValue16 = (PUSHORT) (ImageBase + Offset);
|
||||||
|
*pValue16 += Delta32 >> 16;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_RELOC_LOW:
|
||||||
|
pValue16 = (PUSHORT)(ImageBase + Offset);
|
||||||
|
*pValue16 += Delta32 & 0xffff;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_RELOC_HIGHLOW:
|
||||||
|
pValue32 = (PULONG) (ImageBase + Offset);
|
||||||
|
*pValue32 += Delta32;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TYPE_RELOC_HIGHADJ:
|
||||||
|
/* FIXME: do the highadjust fixup */
|
||||||
|
DPRINT("TYPE_RELOC_HIGHADJ fixup not implemented"
|
||||||
|
", sorry\n");
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
|
||||||
|
default:
|
||||||
|
DPRINT("unexpected fixup type\n");
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RelocationRVA += RelocationDir->SizeOfBlock;
|
||||||
|
RelocationDir = (PRELOCATION_DIRECTORY)(ImageBase +
|
||||||
|
RelocationRVA);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
|
||||||
|
PVOID ImageBase)
|
||||||
|
{
|
||||||
|
PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory;
|
||||||
|
ULONG Ordinal;
|
||||||
|
PDLL Module;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
/* Process each import module */
|
||||||
|
ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
|
||||||
|
(ImageBase + NTHeaders->OptionalHeader.
|
||||||
|
DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
|
||||||
|
while (ImportModuleDirectory->dwRVAModuleName)
|
||||||
|
{
|
||||||
|
PVOID *ImportAddressList;
|
||||||
|
PULONG FunctionNameList;
|
||||||
|
DWORD pName;
|
||||||
|
PWORD pHint;
|
||||||
|
|
||||||
|
Status = LdrFindDll(&Module,
|
||||||
|
(PCHAR)(ImageBase +
|
||||||
|
ImportModuleDirectory->dwRVAModuleName));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get the import address list */
|
||||||
|
ImportAddressList = (PVOID *)
|
||||||
|
(NTHeaders->OptionalHeader.ImageBase +
|
||||||
|
ImportModuleDirectory->dwRVAFunctionAddressList);
|
||||||
|
|
||||||
|
/* Get the list of functions to import */
|
||||||
|
if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
|
||||||
|
{
|
||||||
|
FunctionNameList = (PULONG) (ImageBase +
|
||||||
|
ImportModuleDirectory->dwRVAFunctionNameList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FunctionNameList = (PULONG) (ImageBase +
|
||||||
|
ImportModuleDirectory->dwRVAFunctionAddressList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Walk through function list and fixup addresses */
|
||||||
|
while(*FunctionNameList != 0L)
|
||||||
|
{
|
||||||
|
if ((*FunctionNameList) & 0x80000000)
|
||||||
|
{
|
||||||
|
Ordinal = (*FunctionNameList) & 0x7fffffff;
|
||||||
|
*ImportAddressList = LdrGetExportByOrdinal(Module, Ordinal);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pName = (DWORD)(ImageBase + *FunctionNameList + 2);
|
||||||
|
pHint = (PWORD)(ImageBase + *FunctionNameList);
|
||||||
|
|
||||||
|
*ImportAddressList = LdrGetExportByName(Module,
|
||||||
|
(PUCHAR)pName);
|
||||||
|
if ((*ImportAddressList) == NULL)
|
||||||
|
{
|
||||||
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ImportAddressList++;
|
||||||
|
FunctionNameList++;
|
||||||
|
}
|
||||||
|
ImportModuleDirectory++;
|
||||||
|
}
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
PEPFUNC LdrPEStartup(PVOID ImageBase, HANDLE SectionHandle)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
PEPFUNC EntryPoint;
|
||||||
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
|
PIMAGE_NT_HEADERS NTHeaders;
|
||||||
|
|
||||||
|
DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
|
||||||
|
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + DosHeader->e_lfanew);
|
||||||
|
|
||||||
|
/* Initialize Image sections */
|
||||||
|
LdrMapSections(ImageBase, SectionHandle, NTHeaders);
|
||||||
|
|
||||||
|
if (ImageBase != (PVOID)NTHeaders->OptionalHeader.ImageBase)
|
||||||
|
{
|
||||||
|
Status = LdrPerformRelocations(NTHeaders, ImageBase);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].
|
||||||
|
VirtualAddress != 0)
|
||||||
|
{
|
||||||
|
Status = LdrFixupImports(NTHeaders, ImageBase);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EntryPoint = (PEPFUNC)(ImageBase +
|
||||||
|
NTHeaders->OptionalHeader.AddressOfEntryPoint);
|
||||||
|
|
||||||
|
return(EntryPoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,14 @@
|
||||||
|
/*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/ntdll/main/dllmain.c
|
||||||
|
* PURPOSE:
|
||||||
|
* PROGRAMMER:
|
||||||
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <ntdll/ntdll.h>
|
#include <ntdll/ntdll.h>
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ OBJECTS = napi.o ldr/startup.o rtl/largeint.o rtl/namespc.o rtl/unicode.o \
|
||||||
string/strcat.o string/strcmp.o string/strcpy.o string/stricmp.o \
|
string/strcat.o string/strcmp.o string/strcpy.o string/stricmp.o \
|
||||||
string/strlen.o string/strncmp.o string/strncpy.o string/strnlen.o \
|
string/strlen.o string/strncmp.o string/strncpy.o string/strnlen.o \
|
||||||
string/strrchr.o string/wstring.o stubs/stubs.o rtl/heap.o \
|
string/strrchr.o string/wstring.o stubs/stubs.o rtl/heap.o \
|
||||||
rtl/critical.o rtl/mem.o
|
rtl/critical.o rtl/mem.o ldr/utils.o
|
||||||
|
|
||||||
ntdll.a: $(OBJECTS)
|
ntdll.a: $(OBJECTS)
|
||||||
$(AR) csr ntdll.a $(OBJECTS)
|
$(AR) csr ntdll.a $(OBJECTS)
|
||||||
|
@ -43,4 +43,5 @@ ntdll.dll: $(DLLMAIN) $(OBJECTS)
|
||||||
- $(RM) temp.exp
|
- $(RM) temp.exp
|
||||||
$(NM) --numeric-sort ntdll.dll > ntdll.sym
|
$(NM) --numeric-sort ntdll.dll > ntdll.sym
|
||||||
|
|
||||||
|
#WARNINGS_ARE_ERRORS = yes
|
||||||
include ../../rules.mak
|
include ../../rules.mak
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
/* INCLUDES ******************************************************************/
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <ntdll/rtl.h>
|
||||||
|
|
||||||
|
#include <ntdll/ntdll.h>
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
@ -37,5 +40,7 @@ VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||||
|
|
||||||
WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
for(;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <ntdll/rtl.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <ntdll/ntdll.h>
|
#include <ntdll/ntdll.h>
|
||||||
|
@ -656,7 +657,7 @@ PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, ULONG flags)
|
||||||
* Called by __VirtualInit to initialize the default process heap *
|
* Called by __VirtualInit to initialize the default process heap *
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
|
|
||||||
VOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize)
|
VOID WINAPI __RtlInitHeap(PVOID base, ULONG minsize, ULONG maxsize)
|
||||||
{
|
{
|
||||||
NTSTATUS Result;
|
NTSTATUS Result;
|
||||||
PHEAP NewHeap;
|
PHEAP NewHeap;
|
||||||
|
@ -952,7 +953,7 @@ UINT RtlCompactHeap(HANDLE hheap, DWORD flags)
|
||||||
/*********************************************************************
|
/*********************************************************************
|
||||||
* HeapSize -- KERNEL32 *
|
* HeapSize -- KERNEL32 *
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
DWORD WINAPI RtlSizeHeap(HANDLE hheap, DWORD flags, LPCVOID pmem)
|
DWORD WINAPI RtlSizeHeap(HANDLE hheap, DWORD flags, PVOID pmem)
|
||||||
{
|
{
|
||||||
PHEAP pheap=(PHEAP) hheap;
|
PHEAP pheap=(PHEAP) hheap;
|
||||||
PHEAP_BLOCK palloc=((PHEAP_BLOCK)pmem-1);
|
PHEAP_BLOCK palloc=((PHEAP_BLOCK)pmem-1);
|
||||||
|
@ -992,7 +993,7 @@ DWORD WINAPI RtlSizeHeap(HANDLE hheap, DWORD flags, LPCVOID pmem)
|
||||||
* *
|
* *
|
||||||
* NOTE: only implemented in NT *
|
* NOTE: only implemented in NT *
|
||||||
*********************************************************************/
|
*********************************************************************/
|
||||||
BOOL WINAPI RtlValidateHeap(HANDLE hheap, DWORD flags, LPCVOID pmem)
|
BOOL WINAPI RtlValidateHeap(HANDLE hheap, DWORD flags, PVOID pmem)
|
||||||
{
|
{
|
||||||
PHEAP pheap=(PHEAP)hheap;
|
PHEAP pheap=(PHEAP)hheap;
|
||||||
PHEAP_BLOCK pcheck;
|
PHEAP_BLOCK pcheck;
|
||||||
|
|
|
@ -48,7 +48,7 @@ VOID RtlCopyBytes(PVOID Destination,
|
||||||
RtlCopyMemory(Destination,Source,Length);
|
RtlCopyMemory(Destination,Source,Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length)
|
VOID RtlCopyMemory(VOID* Destination, CONST VOID* Source, ULONG Length)
|
||||||
{
|
{
|
||||||
DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n",
|
DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n",
|
||||||
Destination,Source,Length);
|
Destination,Source,Length);
|
||||||
|
|
|
@ -9,20 +9,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
#define Aa_Difference ('A'-'a')
|
#define Aa_Difference ('A'-'a')
|
||||||
|
|
||||||
PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest,
|
extern unsigned long simple_strtoul(const char *cp,
|
||||||
PUNICODE_STRING Src)
|
char **endp,
|
||||||
{
|
unsigned int base);
|
||||||
if (Dest==NULL)
|
|
||||||
{
|
|
||||||
// Dest=ExAllocatePool(NonPagedPool,sizeof(UNICODE_STRING));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WCHAR wtoupper(WCHAR c)
|
WCHAR wtoupper(WCHAR c)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +119,8 @@ NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
|
||||||
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);
|
||||||
};
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
||||||
{
|
{
|
||||||
|
@ -339,26 +338,27 @@ 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)
|
||||||
{
|
{
|
||||||
unsigned long i, DestSize;
|
unsigned long DestSize;
|
||||||
UNICODE_STRING Dest=*DestinationString;
|
|
||||||
|
|
||||||
if(SourceString==NULL) {
|
if (SourceString == NULL)
|
||||||
|
{
|
||||||
DestinationString->Length = 0;
|
DestinationString->Length = 0;
|
||||||
DestinationString->MaximumLength = 0;
|
DestinationString->MaximumLength = 0;
|
||||||
DestinationString->Buffer = NULL;
|
DestinationString->Buffer = NULL;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
DestSize = wcslen((PWSTR)SourceString);
|
DestSize = wcslen((PWSTR)SourceString);
|
||||||
DestinationString->Length = DestSize;
|
DestinationString->Length = DestSize;
|
||||||
DestinationString->MaximumLength = DestSize+1;
|
DestinationString->MaximumLength = DestSize+1;
|
||||||
|
|
||||||
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)
|
||||||
|
@ -366,17 +366,17 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
||||||
char *str;
|
char *str;
|
||||||
unsigned long len, i;
|
unsigned long len, i;
|
||||||
|
|
||||||
// str=ExAllocatePool(NonPagedPool, 1024);
|
str = RtlAllocateHeap(RtlGetProcessHeap, 0, 1024);
|
||||||
if(Base==16) {
|
if(Base==16) {
|
||||||
sprintf(str, "%x", Value);
|
sprintf(str, "%x", (unsigned int)Value);
|
||||||
} else
|
} else
|
||||||
if(Base==8) {
|
if(Base==8) {
|
||||||
sprintf(str, "%o", Value);
|
sprintf(str, "%o", (unsigned int)Value);
|
||||||
} else
|
} else
|
||||||
if(Base==2) {
|
if(Base==2) {
|
||||||
sprintf(str, "%b", Value);
|
// sprintf(str, "%b", Value);
|
||||||
} else {
|
} else {
|
||||||
sprintf(str, "%u", Value);
|
sprintf(str, "%u", (unsigned int)Value);
|
||||||
};
|
};
|
||||||
|
|
||||||
len=strlen(str);
|
len=strlen(str);
|
||||||
|
@ -394,7 +394,7 @@ 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,
|
||||||
|
@ -431,9 +431,10 @@ NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
|
||||||
unsigned long i, lenmin=0;
|
unsigned long i, lenmin=0;
|
||||||
BOOLEAN addneg=FALSE;
|
BOOLEAN addneg=FALSE;
|
||||||
|
|
||||||
// str=ExAllocatePool(NonPagedPool, String->Length+1);
|
str=RtlAllocateHeap(RtlGetProcessHeap(), 0, String->Length+1);
|
||||||
|
|
||||||
for(i=0; i<String->Length; i++) {
|
for(i=0; i<String->Length; i++)
|
||||||
|
{
|
||||||
*str=*String->Buffer;
|
*str=*String->Buffer;
|
||||||
|
|
||||||
if(*str=='b') { Base=2; lenmin++; } else
|
if(*str=='b') { Base=2; lenmin++; } else
|
||||||
|
@ -479,7 +480,8 @@ 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);
|
||||||
};
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
IN PUNICODE_STRING SourceString,
|
IN PUNICODE_STRING SourceString,
|
||||||
|
|
|
@ -16,9 +16,12 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
extern size_t strnlen(const char* string, size_t maxlen);
|
||||||
|
|
||||||
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
|
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
|
||||||
{
|
{
|
||||||
unsigned long result = 0,value;
|
unsigned long result = 0,value;
|
||||||
|
@ -70,8 +73,8 @@ __res = ((unsigned long) n) % (unsigned) base; \
|
||||||
n = ((unsigned long) n) / (unsigned) base; \
|
n = ((unsigned long) n) / (unsigned) base; \
|
||||||
__res; })
|
__res; })
|
||||||
|
|
||||||
static char * number(char * str, long num, int base, int size, int precision
|
static char * number(char * str, long num, int base, int size, int precision,
|
||||||
,int type)
|
int type)
|
||||||
{
|
{
|
||||||
char c,sign,tmp[66];
|
char c,sign,tmp[66];
|
||||||
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
|
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
|
||||||
|
@ -83,27 +86,38 @@ static char * number(char * str, long num, int base, int size, int precision
|
||||||
type &= ~ZEROPAD;
|
type &= ~ZEROPAD;
|
||||||
if (base < 2 || base > 36)
|
if (base < 2 || base > 36)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
c = (type & ZEROPAD) ? '0' : ' ';
|
c = (type & ZEROPAD) ? '0' : ' ';
|
||||||
sign = 0;
|
sign = 0;
|
||||||
if (type & SIGN) {
|
|
||||||
if (num < 0) {
|
if (type & SIGN)
|
||||||
|
{
|
||||||
|
if (num < 0)
|
||||||
|
{
|
||||||
sign = '-';
|
sign = '-';
|
||||||
num = -num;
|
num = -num;
|
||||||
size--;
|
size--;
|
||||||
} else if (type & PLUS) {
|
}
|
||||||
|
else if (type & PLUS)
|
||||||
|
{
|
||||||
sign = '+';
|
sign = '+';
|
||||||
size--;
|
size--;
|
||||||
} else if (type & SPACE) {
|
}
|
||||||
|
else if (type & SPACE)
|
||||||
|
{
|
||||||
sign = ' ';
|
sign = ' ';
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type & SPECIAL) {
|
|
||||||
|
if (type & SPECIAL)
|
||||||
|
{
|
||||||
if (base == 16)
|
if (base == 16)
|
||||||
size -= 2;
|
size -= 2;
|
||||||
else if (base == 8)
|
else if (base == 8)
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
if (num == 0)
|
if (num == 0)
|
||||||
tmp[i++]='0';
|
tmp[i++]='0';
|
||||||
|
@ -118,12 +132,17 @@ static char * number(char * str, long num, int base, int size, int precision
|
||||||
if (sign)
|
if (sign)
|
||||||
*str++ = sign;
|
*str++ = sign;
|
||||||
if (type & SPECIAL)
|
if (type & SPECIAL)
|
||||||
|
{
|
||||||
if (base==8)
|
if (base==8)
|
||||||
|
{
|
||||||
*str++ = '0';
|
*str++ = '0';
|
||||||
else if (base==16) {
|
}
|
||||||
|
else if (base==16)
|
||||||
|
{
|
||||||
*str++ = '0';
|
*str++ = '0';
|
||||||
*str++ = digits[33];
|
*str++ = digits[33];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (!(type & LEFT))
|
if (!(type & LEFT))
|
||||||
while (size-- > 0)
|
while (size-- > 0)
|
||||||
*str++ = c;
|
*str++ = c;
|
||||||
|
@ -351,6 +370,7 @@ int wsprintfA(char * buf, const char *fmt, ...)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
|
int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -361,7 +381,7 @@ int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
unsigned short towupper(unsigned short w)
|
unsigned short towupper(unsigned short w)
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,15 +14,17 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
|
||||||
static wchar_t * ___wcstok = NULL;
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
// static wchar_t * ___wcstok = NULL;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
int wcsicmp(const wchar_t* ws1, const wchar_t* ws2)
|
int wcsnicmp(const wchar_t* ws1, const wchar_t* ws2, size_t size)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int wcsnicmp(const wchar_t* ws1, const wchar_t* ws2, size_t size)
|
int wcsicmp(const wchar_t* ws1, const wchar_t* ws2)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,14 +43,13 @@ wchar_t* wcscat(wchar_t *dest, const wchar_t *src)
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
wchar_t *
|
wchar_t* wcschr(const wchar_t *str, wchar_t ch)
|
||||||
wcschr(const wchar_t *str, wchar_t ch)
|
|
||||||
{
|
{
|
||||||
while ((*str) != ((wchar_t) 0))
|
while ((*str) != ((wchar_t) 0))
|
||||||
{
|
{
|
||||||
if ((*str) == ch)
|
if ((*str) == ch)
|
||||||
{
|
{
|
||||||
return str;
|
return (wchar_t *)str;
|
||||||
}
|
}
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
|
@ -56,8 +57,7 @@ wcschr(const wchar_t *str, wchar_t ch)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int wcscmp(const wchar_t *cs, const wchar_t *ct)
|
||||||
wcscmp(const wchar_t *cs, const wchar_t *ct)
|
|
||||||
{
|
{
|
||||||
while (*cs != '\0' && *ct != '\0' && *cs == *ct)
|
while (*cs != '\0' && *ct != '\0' && *cs == *ct)
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,7 +62,6 @@ STUB(PfxInitialize)
|
||||||
STUB(PfxInsertPrefix)
|
STUB(PfxInsertPrefix)
|
||||||
STUB(PfxRemovePrefix)
|
STUB(PfxRemovePrefix)
|
||||||
STUB(RestoreEm87Context)
|
STUB(RestoreEm87Context)
|
||||||
STUB(RtlValidateHeap)
|
|
||||||
STUB(RtlValidateProcessHeaps)
|
STUB(RtlValidateProcessHeaps)
|
||||||
STUB(RtlWalkHeap)
|
STUB(RtlWalkHeap)
|
||||||
STUB(RtlZeroHeap)
|
STUB(RtlZeroHeap)
|
||||||
|
|
|
@ -14,7 +14,7 @@ include rules.mak
|
||||||
#
|
#
|
||||||
# Required to run the system
|
# Required to run the system
|
||||||
#
|
#
|
||||||
COMPONENTS = iface_native ntoskrnl kernel32 ntdll
|
COMPONENTS = iface_native ntoskrnl ntdll kernel32
|
||||||
|
|
||||||
#
|
#
|
||||||
# Select the server(s) you want to build
|
# Select the server(s) you want to build
|
||||||
|
|
|
@ -25,6 +25,7 @@ static ULONG CbHash(PDCCB Dccb, ULONG BlockNr)
|
||||||
return(BlockNr % Dccb->HashTblSize);
|
return(BlockNr % Dccb->HashTblSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb)
|
static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
|
@ -33,6 +34,7 @@ static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb)
|
||||||
Ccb->References--;
|
Ccb->References--;
|
||||||
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr)
|
static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr)
|
||||||
{
|
{
|
||||||
|
@ -49,6 +51,7 @@ static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr)
|
||||||
return(Ccb);
|
return(Ccb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb)
|
static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
|
@ -67,7 +70,7 @@ static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb)
|
||||||
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static BOOLEAN CbLockForWrite(PCCB Ccb)
|
static BOOLEAN CbLockForWrite(PCCB Ccb)
|
||||||
{
|
{
|
||||||
|
@ -126,11 +129,13 @@ static BOOLEAN CbLockForDelete(PDCCB Dccb, PCCB Ccb)
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static VOID CbUnlockForDelete(PDCCB Dccb, PCCB Ccb)
|
static VOID CbUnlockForDelete(PDCCB Dccb, PCCB Ccb)
|
||||||
{
|
{
|
||||||
Ccb->ActiveWriter = FALSE;
|
Ccb->ActiveWriter = FALSE;
|
||||||
KeSetEvent(&Ccb->FinishedNotify,IO_NO_INCREMENT,FALSE);
|
KeSetEvent(&Ccb->FinishedNotify,IO_NO_INCREMENT,FALSE);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VOID CbAcquireForDelete(PDCCB Dccb, PCCB Ccb)
|
VOID CbAcquireForDelete(PDCCB Dccb, PCCB Ccb)
|
||||||
/*
|
/*
|
||||||
|
@ -234,6 +239,7 @@ PCCB CbFindModifiedCcb(PDCCB Dccb, PCCB Start)
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static VOID CbDeleteAllCcbs(PDCCB Dccb)
|
static VOID CbDeleteAllCcbs(PDCCB Dccb)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Delete all the ccbs associated with a dccb
|
* FUNCTION: Delete all the ccbs associated with a dccb
|
||||||
|
@ -261,7 +267,9 @@ static VOID CbDeleteAllCcbs(PDCCB Dccb)
|
||||||
ExFreePool(Ccb);
|
ExFreePool(Ccb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb)
|
static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
|
@ -279,7 +287,9 @@ static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb)
|
||||||
KeReleaseSpinLock(&Dccb->CcbListLock,oldlvl);
|
KeReleaseSpinLock(&Dccb->CcbListLock,oldlvl);
|
||||||
ExFreePool(Ccb);
|
ExFreePool(Ccb);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
static VOID CbReclaimMemory(PDCCB Dccb)
|
static VOID CbReclaimMemory(PDCCB Dccb)
|
||||||
{
|
{
|
||||||
PCCB RedundantCcbs[25];
|
PCCB RedundantCcbs[25];
|
||||||
|
@ -323,7 +333,9 @@ static VOID CbReclaimMemory(PDCCB Dccb)
|
||||||
CbFreeCcb(Dccb,RedundantCcbs[i]);
|
CbFreeCcb(Dccb,RedundantCcbs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb)
|
static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Deletes a CCB
|
* FUNCTION: Deletes a CCB
|
||||||
|
@ -338,6 +350,7 @@ static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb)
|
||||||
CbAcquireForDelete(Dccb,Ccb);
|
CbAcquireForDelete(Dccb,Ccb);
|
||||||
Ccb->State = CCB_DELETE_PENDING;
|
Ccb->State = CCB_DELETE_PENDING;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
VOID CbReinitCcb(PDCCB Dccb, PCCB Ccb, ULONG BlockNr)
|
VOID CbReinitCcb(PDCCB Dccb, PCCB Ccb, ULONG BlockNr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -273,6 +273,7 @@ ZwCreateKey(PHANDLE KeyHandle,
|
||||||
|
|
||||||
NTSTATUS NtDeleteKey(HANDLE KeyHandle)
|
NTSTATUS NtDeleteKey(HANDLE KeyHandle)
|
||||||
{
|
{
|
||||||
|
return(ZwDeleteKey(KeyHandle));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS ZwDeleteKey(HANDLE KeyHandle)
|
NTSTATUS ZwDeleteKey(HANDLE KeyHandle)
|
||||||
|
@ -280,15 +281,23 @@ NTSTATUS ZwDeleteKey(HANDLE KeyHandle)
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS NtEnumerateKey(HANDLE KeyHandle, ULONG Index,
|
NTSTATUS NtEnumerateKey(HANDLE KeyHandle,
|
||||||
|
ULONG Index,
|
||||||
KEY_INFORMATION_CLASS KeyInformationClass,
|
KEY_INFORMATION_CLASS KeyInformationClass,
|
||||||
PVOID KeyInformation,
|
PVOID KeyInformation,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
PULONG ResultLength)
|
PULONG ResultLength)
|
||||||
{
|
{
|
||||||
|
return(ZwEnumerateKey(KeyHandle,
|
||||||
|
Index,
|
||||||
|
KeyInformationClass,
|
||||||
|
KeyInformation,
|
||||||
|
Length,
|
||||||
|
ResultLength));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS ZwEnumerateKey(HANDLE KeyHandle, ULONG Index,
|
NTSTATUS ZwEnumerateKey(HANDLE KeyHandle,
|
||||||
|
ULONG Index,
|
||||||
KEY_INFORMATION_CLASS KeyInformationClass,
|
KEY_INFORMATION_CLASS KeyInformationClass,
|
||||||
PVOID KeyInformation,
|
PVOID KeyInformation,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
|
|
|
@ -61,7 +61,7 @@ VOID ExReleaseFastMutex(PFAST_MUTEX FastMutex)
|
||||||
|
|
||||||
BOOLEAN ExTryToAcquireFastMutex(PFAST_MUTEX FastMutex)
|
BOOLEAN ExTryToAcquireFastMutex(PFAST_MUTEX FastMutex)
|
||||||
{
|
{
|
||||||
InterlockedCompareExchange(&(FastMutex->Count),0,0);
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,7 @@ ULONG ExGetSharedWaiterCount(PERESOURCE Resource)
|
||||||
|
|
||||||
NTSTATUS ExInitializeResource(PERESOURCE Resource)
|
NTSTATUS ExInitializeResource(PERESOURCE Resource)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
|
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
|
||||||
|
@ -81,10 +82,17 @@ NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
|
||||||
Resource->NumberOfExclusiveWaiters = 0;
|
Resource->NumberOfExclusiveWaiters = 0;
|
||||||
KeInitializeSpinLock(&Resource->SpinLock);
|
KeInitializeSpinLock(&Resource->SpinLock);
|
||||||
Resource->Flag=0;
|
Resource->Flag=0;
|
||||||
KeInitializeEvent(&Resource->ExclusiveWaiters,SynchronizationEvent,
|
Resource->ExclusiveWaiters = ExAllocatePool(NonPagedPool,
|
||||||
|
sizeof(KEVENT));
|
||||||
|
KeInitializeEvent(Resource->ExclusiveWaiters,
|
||||||
|
SynchronizationEvent,
|
||||||
FALSE);
|
FALSE);
|
||||||
KeInitializeSemaphore(&Resource->SharedWaiters,5,0);
|
Resource->SharedWaiters = ExAllocatePool(NonPagedPool,
|
||||||
|
sizeof(KSEMAPHORE));
|
||||||
|
KeInitializeSemaphore(Resource->SharedWaiters,5,0);
|
||||||
Resource->ActiveCount = 0;
|
Resource->ActiveCount = 0;
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource)
|
BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource)
|
||||||
|
|
|
@ -45,7 +45,7 @@ typedef struct
|
||||||
/*
|
/*
|
||||||
* PURPOSE: Queue of items waiting to be processed at normal priority
|
* PURPOSE: Queue of items waiting to be processed at normal priority
|
||||||
*/
|
*/
|
||||||
WORK_QUEUE normal_work_queue = {0,};
|
WORK_QUEUE normal_work_queue = {{0,}};
|
||||||
|
|
||||||
#define WAIT_INTERVAL (0)
|
#define WAIT_INTERVAL (0)
|
||||||
|
|
||||||
|
|
|
@ -27,8 +27,8 @@ ExAllocateFromNPagedLookasideList
|
||||||
ExAllocateFromPagedLookasideList
|
ExAllocateFromPagedLookasideList
|
||||||
ExAllocateFromZone
|
ExAllocateFromZone
|
||||||
ExAllocatePool
|
ExAllocatePool
|
||||||
ExAllocatePoolWithQuota
|
#ExAllocatePoolWithQuota
|
||||||
ExAllocatePoolWithQuotaTag
|
#ExAllocatePoolWithQuotaTag
|
||||||
ExAllocatePoolWithTag
|
ExAllocatePoolWithTag
|
||||||
ExConvertExclusiveToSharedLite
|
ExConvertExclusiveToSharedLite
|
||||||
ExDeleteNPagedLookasideList
|
ExDeleteNPagedLookasideList
|
||||||
|
@ -88,11 +88,11 @@ InterlockedCompareExchange
|
||||||
InterlockedExchange
|
InterlockedExchange
|
||||||
InterlockedExchangeAdd
|
InterlockedExchangeAdd
|
||||||
InterlockedIncrement
|
InterlockedIncrement
|
||||||
HalAllocateCommonBuffer
|
#HalAllocateCommonBuffer
|
||||||
HalAssignSlotResources
|
HalAssignSlotResources
|
||||||
HalExamineMBR
|
HalExamineMBR
|
||||||
HalFreeCommonBuffer
|
#HalFreeCommonBuffer
|
||||||
HalGetAdapter
|
#HalGetAdapter
|
||||||
HalGetBusData
|
HalGetBusData
|
||||||
HalGetBusDataByOffset
|
HalGetBusDataByOffset
|
||||||
HalGetDmaAlignmentRequirement
|
HalGetDmaAlignmentRequirement
|
||||||
|
@ -319,7 +319,7 @@ RtlFreeUnicodeString
|
||||||
RtlInitAnsiString
|
RtlInitAnsiString
|
||||||
RtlInitString
|
RtlInitString
|
||||||
RtlInitUnicodeString
|
RtlInitUnicodeString
|
||||||
RtlIntegerToUnicodeString
|
#RtlIntegerToUnicodeString
|
||||||
RtlLargeIntegerAdd
|
RtlLargeIntegerAdd
|
||||||
RtlLargeIntegerAnd
|
RtlLargeIntegerAnd
|
||||||
RtlLargeIntegerArithmeticShift
|
RtlLargeIntegerArithmeticShift
|
||||||
|
|
|
@ -50,6 +50,7 @@ ULONG HalGetDmaAlignmentRequirement()
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
PVOID HalAllocateCommonBuffer(PADAPTER_OBJECT AdapterObject,
|
PVOID HalAllocateCommonBuffer(PADAPTER_OBJECT AdapterObject,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
PPHYSICAL_ADDRESS LogicalAddress,
|
PPHYSICAL_ADDRESS LogicalAddress,
|
||||||
|
@ -115,6 +116,7 @@ PADAPTER_OBJECT HalGetAdapter(PDEVICE_DESCRIPTION DeviceDescription,
|
||||||
RtlCopyMemory(&adapter->desc,DeviceDescription,sizeof(DEVICE_DESCRIPTION));
|
RtlCopyMemory(&adapter->desc,DeviceDescription,sizeof(DEVICE_DESCRIPTION));
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ULONG HalReadDmaCounter(PADAPTER_OBJECT AdapterObject)
|
ULONG HalReadDmaCounter(PADAPTER_OBJECT AdapterObject)
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,6 +25,7 @@ static KIRQL CurrentIrql = HIGH_LEVEL;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
|
#if 0
|
||||||
static unsigned int HiGetCurrentPICMask(void)
|
static unsigned int HiGetCurrentPICMask(void)
|
||||||
{
|
{
|
||||||
unsigned int mask;
|
unsigned int mask;
|
||||||
|
@ -34,6 +35,7 @@ static unsigned int HiGetCurrentPICMask(void)
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static unsigned int HiSetCurrentPICMask(unsigned int mask)
|
static unsigned int HiSetCurrentPICMask(unsigned int mask)
|
||||||
{
|
{
|
||||||
|
|
|
@ -124,7 +124,7 @@ PHYSICAL_ADDRESS MmGetPhysicalAddress(PVOID vaddr)
|
||||||
* FUNCTION: Returns the physical address corresponding to a virtual address
|
* FUNCTION: Returns the physical address corresponding to a virtual address
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PHYSICAL_ADDRESS p;
|
PHYSICAL_ADDRESS p = INITIALIZE_LARGE_INTEGER;
|
||||||
|
|
||||||
DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr);
|
DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr);
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <internal/ke.h>
|
#include <internal/ke.h>
|
||||||
#include <internal/bitops.h>
|
#include <internal/bitops.h>
|
||||||
#include <internal/linkage.h>
|
#include <internal/linkage.h>
|
||||||
|
#include <string.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
|
||||||
#include <internal/i386/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
|
|
|
@ -46,7 +46,7 @@ BOOLEAN IoCancelIrp(PIRP Irp)
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
Irp->CancelRoutine(Irp->Stack[0].DeviceObject, Irp);
|
Irp->CancelRoutine(Irp->Stack[0].DeviceObject, Irp);
|
||||||
IoReleaseCancelSpinLock(&oldlvl);
|
IoReleaseCancelSpinLock(oldlvl);
|
||||||
return(TRUE);
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,7 +177,6 @@ NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
||||||
PWSTR RemainingPath,
|
PWSTR RemainingPath,
|
||||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)ObjectBody;
|
|
||||||
|
|
||||||
DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
||||||
ObjectBody, Parent, RemainingPath);
|
ObjectBody, Parent, RemainingPath);
|
||||||
|
|
|
@ -27,12 +27,14 @@ VOID MmUnlockPagableImageSection(PVOID ImageSectionHandle)
|
||||||
* MmLockPagableDataSection
|
* MmLockPagableDataSection
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
|
// MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmLockPagableSectionByHandle(PVOID ImageSectionHandle)
|
VOID MmLockPagableSectionByHandle(PVOID ImageSectionHandle)
|
||||||
{
|
{
|
||||||
MmLockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
|
// MmLockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID MmLockPagableCodeSection(PVOID AddressWithinSection)
|
PVOID MmLockPagableCodeSection(PVOID AddressWithinSection)
|
||||||
|
|
|
@ -17,116 +17,100 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtCreateIoCompletion(OUT PHANDLE CompletionPort,
|
||||||
STDCALL
|
|
||||||
NtCreateIoCompletion(
|
|
||||||
OUT PHANDLE CompletionPort,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN ULONG NumberOfConcurrentThreads
|
IN ULONG NumberOfConcurrentThreads)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwCreateIoCompletion(CompletionPort,
|
||||||
|
DesiredAccess,
|
||||||
|
IoStatusBlock,
|
||||||
|
NumberOfConcurrentThreads));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwCreateIoCompletion(OUT PHANDLE CompletionPort,
|
||||||
STDCALL
|
|
||||||
ZwCreateIoCompletion(
|
|
||||||
OUT PHANDLE CompletionPort,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN ULONG NumberOfConcurrentThreads
|
IN ULONG NumberOfConcurrentThreads)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtOpenIoCompletion(OUT PHANDLE CompletionPort,
|
||||||
STDCALL
|
|
||||||
NtOpenIoCompletion(
|
|
||||||
OUT PHANDLE CompetionPort,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes
|
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwOpenIoCompletion(CompletionPort,
|
||||||
|
DesiredAccess,
|
||||||
|
ObjectAttributes));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwOpenIoCompletion(OUT PHANDLE CompetionPort,
|
||||||
STDCALL
|
|
||||||
ZwOpenIoCompletion(
|
|
||||||
OUT PHANDLE CompetionPort,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes
|
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtQueryIoCompletion(IN HANDLE CompletionPort,
|
||||||
STDCALL
|
|
||||||
NtQueryIoCompletion(
|
|
||||||
IN HANDLE CompletionPort,
|
|
||||||
IN ULONG CompletionKey,
|
IN ULONG CompletionKey,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PULONG NumberOfBytesTransferred
|
OUT PULONG NumberOfBytesTransferred)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwQueryIoCompletion(CompletionPort,
|
||||||
return ZwQueryIoCompletion(CompletionPort,CompletionKey,IoStatusBlock,NumberOfBytesTransferred);
|
CompletionKey,
|
||||||
|
IoStatusBlock,
|
||||||
|
NumberOfBytesTransferred));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwQueryIoCompletion(IN HANDLE CompletionPort,
|
||||||
STDCALL
|
|
||||||
ZwQueryIoCompletion(
|
|
||||||
IN HANDLE CompletionPort,
|
|
||||||
IN ULONG CompletionKey,
|
IN ULONG CompletionKey,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PULONG NumberOfBytesTransferred
|
OUT PULONG NumberOfBytesTransferred)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
NTSTATUS STDCALL NtRemoveIoCompletion(IN HANDLE CompletionPort,
|
||||||
NtRemoveIoCompletion(
|
|
||||||
IN HANDLE CompletionPort,
|
|
||||||
OUT PULONG CompletionKey,
|
OUT PULONG CompletionKey,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PULONG CompletionStatus,
|
OUT PULONG CompletionStatus,
|
||||||
PLARGE_INTEGER WaitTime
|
PLARGE_INTEGER WaitTime)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwRemoveIoCompletion(CompletionPort,
|
||||||
|
CompletionKey,
|
||||||
|
IoStatusBlock,
|
||||||
|
CompletionStatus,
|
||||||
|
WaitTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwRemoveIoCompletion(IN HANDLE CompletionPort,
|
||||||
STDCALL
|
|
||||||
ZwRemoveIoCompletion(
|
|
||||||
IN HANDLE CompletionPort,
|
|
||||||
OUT PULONG CompletionKey,
|
OUT PULONG CompletionKey,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
OUT PULONG CompletionStatus,
|
OUT PULONG CompletionStatus,
|
||||||
PLARGE_INTEGER WaitTime
|
PLARGE_INTEGER WaitTime)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtSetIoCompletion(IN HANDLE CompletionPort,
|
||||||
STDCALL
|
|
||||||
NtSetIoCompletion(
|
|
||||||
IN HANDLE CompletionPort,
|
|
||||||
IN ULONG CompletionKey,
|
IN ULONG CompletionKey,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN ULONG NumberOfBytesToTransfer,
|
IN ULONG NumberOfBytesToTransfer,
|
||||||
OUT PULONG NumberOfBytesTransferred
|
OUT PULONG NumberOfBytesTransferred)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwSetIoCompletion(CompletionPort,
|
||||||
|
CompletionKey,
|
||||||
|
IoStatusBlock,
|
||||||
|
NumberOfBytesToTransfer,
|
||||||
|
NumberOfBytesTransferred));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwSetIoCompletion(IN HANDLE CompletionPort,
|
||||||
STDCALL
|
|
||||||
ZwSetIoCompletion(
|
|
||||||
IN HANDLE CompletionPort,
|
|
||||||
IN ULONG CompletionKey,
|
IN ULONG CompletionKey,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN ULONG NumberOfBytesToTransfer,
|
IN ULONG NumberOfBytesToTransfer,
|
||||||
OUT PULONG NumberOfBytesTransferred
|
OUT PULONG NumberOfBytesTransferred)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ VOID IoMarkIrpPending(PIRP Irp)
|
||||||
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
|
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
|
||||||
IoGetCurrentIrpStackLocation(Irp));
|
IoGetCurrentIrpStackLocation(Irp));
|
||||||
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
|
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
|
||||||
Irp->Tail.Overlay.Thread = KeGetCurrentThread();
|
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
||||||
DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n",
|
DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n",
|
||||||
IoGetCurrentIrpStackLocation(Irp)->Control);
|
IoGetCurrentIrpStackLocation(Irp)->Control);
|
||||||
DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED);
|
DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED);
|
||||||
|
@ -132,7 +132,7 @@ PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
|
||||||
Irp->CurrentLocation,
|
Irp->CurrentLocation,
|
||||||
Irp->StackCount);
|
Irp->StackCount);
|
||||||
|
|
||||||
return &Irp->Stack[Irp->CurrentLocation];
|
return &Irp->Stack[(ULONG)Irp->CurrentLocation];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -202,7 +202,8 @@ PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)
|
||||||
|
|
||||||
if (ChargeQuota)
|
if (ChargeQuota)
|
||||||
{
|
{
|
||||||
Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize));
|
// Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize));
|
||||||
|
Irp = ExAllocatePool(NonPagedPool,IoSizeOfIrp(StackSize));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,32 +17,33 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtCreateMailslotFile(OUT PHANDLE MailSlotFileHandle,
|
||||||
STDCALL
|
|
||||||
NtCreateMailslotFile(
|
|
||||||
OUT PHANDLE MailSlotFileHandle,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN ULONG FileAttributes,
|
IN ULONG FileAttributes,
|
||||||
IN ULONG ShareAccess,
|
IN ULONG ShareAccess,
|
||||||
IN ULONG MaxMessageSize,
|
IN ULONG MaxMessageSize,
|
||||||
IN PLARGE_INTEGER TimeOut
|
IN PLARGE_INTEGER TimeOut)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwCreateMailslotFile(MailSlotFileHandle,
|
||||||
|
DesiredAccess,
|
||||||
|
ObjectAttributes,
|
||||||
|
IoStatusBlock,
|
||||||
|
FileAttributes,
|
||||||
|
ShareAccess,
|
||||||
|
MaxMessageSize,
|
||||||
|
TimeOut));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwCreateMailslotFile(OUT PHANDLE MailSlotFileHandle,
|
||||||
STDCALL
|
|
||||||
ZwCreateMailslotFile(
|
|
||||||
OUT PHANDLE MailSlotFileHandle,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
IN ULONG FileAttributes,
|
IN ULONG FileAttributes,
|
||||||
IN ULONG ShareAccess,
|
IN ULONG ShareAccess,
|
||||||
IN ULONG MaxMessageSize,
|
IN ULONG MaxMessageSize,
|
||||||
IN PLARGE_INTEGER TimeOut
|
IN PLARGE_INTEGER TimeOut)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,9 @@ PMDL IoAllocateMdl(PVOID VirtualAddress,
|
||||||
|
|
||||||
if (ChargeQuota)
|
if (ChargeQuota)
|
||||||
{
|
{
|
||||||
Mdl = ExAllocatePoolWithQuota(NonPagedPool,
|
// Mdl = ExAllocatePoolWithQuota(NonPagedPool,
|
||||||
MmSizeOfMdl(VirtualAddress,Length));
|
// MmSizeOfMdl(VirtualAddress,Length));
|
||||||
|
Mdl = ExAllocatePool(NonPagedPool,MmSizeOfMdl(VirtualAddress,Length));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,10 +16,7 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
|
||||||
STDCALL
|
|
||||||
NtCreateNamedPipeFile(
|
|
||||||
OUT PHANDLE NamedPipeFileHandle,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
@ -32,15 +29,25 @@ NtCreateNamedPipeFile(
|
||||||
IN ULONG MaxInstances,
|
IN ULONG MaxInstances,
|
||||||
IN ULONG InBufferSize,
|
IN ULONG InBufferSize,
|
||||||
IN ULONG OutBufferSize,
|
IN ULONG OutBufferSize,
|
||||||
IN PLARGE_INTEGER TimeOut
|
IN PLARGE_INTEGER TimeOut)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwCreateNamedPipeFile(NamedPipeFileHandle,
|
||||||
|
DesiredAccess,
|
||||||
|
ObjectAttributes,
|
||||||
|
IoStatusBlock,
|
||||||
|
FileAttributes,
|
||||||
|
ShareAccess,
|
||||||
|
OpenMode,
|
||||||
|
PipeType,
|
||||||
|
PipeRead,
|
||||||
|
PipeWait,
|
||||||
|
MaxInstances,
|
||||||
|
InBufferSize,
|
||||||
|
OutBufferSize,
|
||||||
|
TimeOut));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
|
||||||
STDCALL
|
|
||||||
ZwCreateNamedPipeFile(
|
|
||||||
OUT PHANDLE NamedPipeFileHandle,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
@ -53,7 +60,7 @@ ZwCreateNamedPipeFile(
|
||||||
IN ULONG MaxInstances,
|
IN ULONG MaxInstances,
|
||||||
IN ULONG InBufferSize,
|
IN ULONG InBufferSize,
|
||||||
IN ULONG OutBufferSize,
|
IN ULONG OutBufferSize,
|
||||||
IN PLARGE_INTEGER TimeOut
|
IN PLARGE_INTEGER TimeOut)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ VOID IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject,
|
||||||
{
|
{
|
||||||
PKDEVICE_QUEUE_ENTRY entry;
|
PKDEVICE_QUEUE_ENTRY entry;
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
KIRQL oldirql;
|
|
||||||
|
|
||||||
entry = KeRemoveByKeyDeviceQueue(&DeviceObject->DeviceQueue,Key);
|
entry = KeRemoveByKeyDeviceQueue(&DeviceObject->DeviceQueue,Key);
|
||||||
|
|
||||||
|
@ -58,7 +57,6 @@ VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable)
|
||||||
{
|
{
|
||||||
PKDEVICE_QUEUE_ENTRY entry;
|
PKDEVICE_QUEUE_ENTRY entry;
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
KIRQL oldirql;
|
|
||||||
|
|
||||||
DPRINT("IoStartNextPacket(DeviceObject %x, Cancelable %d)\n",
|
DPRINT("IoStartNextPacket(DeviceObject %x, Cancelable %d)\n",
|
||||||
DeviceObject,Cancelable);
|
DeviceObject,Cancelable);
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
|
@ -40,6 +40,8 @@ NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject)
|
||||||
RtlZeroMemory(Vpb->VolumeLabel,sizeof(WCHAR)*MAXIMUM_VOLUME_LABEL_LENGTH);
|
RtlZeroMemory(Vpb->VolumeLabel,sizeof(WCHAR)*MAXIMUM_VOLUME_LABEL_LENGTH);
|
||||||
|
|
||||||
DeviceObject->Vpb = Vpb;
|
DeviceObject->Vpb = Vpb;
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,
|
PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ke/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@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/ke.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ BOOLEAN KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
|
||||||
CallbackRecord->Buffer=Buffer;
|
CallbackRecord->Buffer=Buffer;
|
||||||
CallbackRecord->Component=Component;
|
CallbackRecord->Component=Component;
|
||||||
CallbackRecord->CallbackRoutine=CallbackRoutine;
|
CallbackRecord->CallbackRoutine=CallbackRoutine;
|
||||||
|
return(TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID KeBugCheckEx(ULONG BugCheckCode,
|
VOID KeBugCheckEx(ULONG BugCheckCode,
|
||||||
|
|
|
@ -12,16 +12,16 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
NTSTATUS STDCALL NtRaiseHardError(VOID)
|
NTSTATUS STDCALL NtRaiseHardError(VOID)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
|
||||||
STDCALL
|
|
||||||
NtSetDefaultHardErrorPort(
|
|
||||||
IN HANDLE PortHandle
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -165,7 +165,7 @@ asmlinkage void _main(boot_param* _bp)
|
||||||
for (i=1;i<bp.nr_files;i++)
|
for (i=1;i<bp.nr_files;i++)
|
||||||
{
|
{
|
||||||
DPRINT("process module at %08lx\n", start);
|
DPRINT("process module at %08lx\n", start);
|
||||||
LdrProcessDriver(start);
|
LdrProcessDriver((PVOID)start);
|
||||||
start=start+PAGE_ROUND_UP(bp.module_length[i]);
|
start=start+PAGE_ROUND_UP(bp.module_length[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -494,9 +495,6 @@ void KeExpireTimers(void)
|
||||||
DPRINT("Finished KeExpireTimers()\n");
|
DPRINT("Finished KeExpireTimers()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
extern unsigned int nr_used_blocks;
|
|
||||||
extern unsigned int EiFreeNonPagedPool;
|
|
||||||
extern unsigned int EiUsedNonPagedPool;
|
|
||||||
|
|
||||||
BOOLEAN KiTimerInterrupt(VOID)
|
BOOLEAN KiTimerInterrupt(VOID)
|
||||||
/*
|
/*
|
||||||
|
@ -507,8 +505,9 @@ BOOLEAN KiTimerInterrupt(VOID)
|
||||||
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36);
|
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36);
|
||||||
int i;
|
int i;
|
||||||
int x,y;
|
int x,y;
|
||||||
extern ULONG PiNrThreads;
|
|
||||||
extern ULONG EiNrUsedBlocks;
|
extern ULONG EiNrUsedBlocks;
|
||||||
|
extern unsigned int EiFreeNonPagedPool;
|
||||||
|
extern unsigned int EiUsedNonPagedPool;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Increment the number of timers ticks
|
* Increment the number of timers ticks
|
||||||
|
@ -534,7 +533,8 @@ BOOLEAN KiTimerInterrupt(VOID)
|
||||||
}
|
}
|
||||||
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,ticks);
|
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,ticks);
|
||||||
memset(str, 0, sizeof(str));
|
memset(str, 0, sizeof(str));
|
||||||
sprintf(str,"%.8u %.8u",EiNrUsedBlocks,EiFreeNonPagedPool);
|
sprintf(str,"%.8u %.8u",(unsigned int)EiNrUsedBlocks,
|
||||||
|
(unsigned int)EiFreeNonPagedPool);
|
||||||
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool);
|
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool);
|
||||||
// sprintf(str,"%.8u %.8u",PiNrThreads,KiTimerTicks);
|
// sprintf(str,"%.8u %.8u",PiNrThreads,KiTimerTicks);
|
||||||
for (i=0;i<17;i++)
|
for (i=0;i<17;i++)
|
||||||
|
|
|
@ -306,6 +306,7 @@ LdrPEProcessDriver(PVOID ModuleLoadBase)
|
||||||
/* Copy image sections into virtual section */
|
/* Copy image sections into virtual section */
|
||||||
memcpy(DriverBase, ModuleLoadBase, PESectionHeaders[0].PointerToRawData);
|
memcpy(DriverBase, ModuleLoadBase, PESectionHeaders[0].PointerToRawData);
|
||||||
CurrentBase = (PVOID) ((DWORD)DriverBase + PESectionHeaders[0].PointerToRawData);
|
CurrentBase = (PVOID) ((DWORD)DriverBase + PESectionHeaders[0].PointerToRawData);
|
||||||
|
CurrentSize = 0;
|
||||||
for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
|
for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
|
||||||
{
|
{
|
||||||
/* Copy current section into current offset of virtual section */
|
/* Copy current section into current offset of virtual section */
|
||||||
|
@ -911,7 +912,6 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
|
||||||
OBJECT_ATTRIBUTES FileObjectAttributes;
|
OBJECT_ATTRIBUTES FileObjectAttributes;
|
||||||
HANDLE FileHandle, SectionHandle, ThreadHandle;
|
HANDLE FileHandle, SectionHandle, ThreadHandle;
|
||||||
CONTEXT Context;
|
CONTEXT Context;
|
||||||
ANSI_STRING AnsiString;
|
|
||||||
UNICODE_STRING DllPathname;
|
UNICODE_STRING DllPathname;
|
||||||
PIMAGE_DOS_HEADER DosHeader;
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
PIMAGE_NT_HEADERS NTHeaders;
|
||||||
|
@ -1020,7 +1020,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
|
||||||
0,
|
0,
|
||||||
Sections[i].Misc.VirtualSize,
|
Sections[i].Misc.VirtualSize,
|
||||||
&Offset,
|
&Offset,
|
||||||
&Sections[i].Misc.VirtualSize,
|
(PULONG)&Sections[i].Misc.VirtualSize,
|
||||||
0,
|
0,
|
||||||
MEM_COMMIT,
|
MEM_COMMIT,
|
||||||
PAGE_READWRITE);
|
PAGE_READWRITE);
|
||||||
|
@ -1152,12 +1152,12 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
|
||||||
DUPLICATE_SAME_ACCESS);
|
DUPLICATE_SAME_ACCESS);
|
||||||
|
|
||||||
ZwWriteVirtualMemory(ProcessHandle,
|
ZwWriteVirtualMemory(ProcessHandle,
|
||||||
STACK_TOP - 4,
|
(PVOID)(STACK_TOP - 4),
|
||||||
&ImageBase,
|
&ImageBase,
|
||||||
sizeof(ImageBase),
|
sizeof(ImageBase),
|
||||||
&BytesWritten);
|
&BytesWritten);
|
||||||
ZwWriteVirtualMemory(ProcessHandle,
|
ZwWriteVirtualMemory(ProcessHandle,
|
||||||
STACK_TOP - 8,
|
(PVOID)(STACK_TOP - 8),
|
||||||
&DupSectionHandle,
|
&DupSectionHandle,
|
||||||
sizeof(DupSectionHandle),
|
sizeof(DupSectionHandle),
|
||||||
&BytesWritten);
|
&BytesWritten);
|
||||||
|
@ -1200,10 +1200,13 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS LdrLoadInitialProcess(VOID)
|
NTSTATUS LdrLoadInitialProcess(VOID)
|
||||||
|
/*
|
||||||
|
* FIXME: The location of the initial process should be configurable,
|
||||||
|
* from command line or registry
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE ProcessHandle;
|
HANDLE ProcessHandle;
|
||||||
ANSI_STRING AnsiString;
|
|
||||||
UNICODE_STRING ProcessName;
|
UNICODE_STRING ProcessName;
|
||||||
|
|
||||||
Status = ZwCreateProcess(&ProcessHandle,
|
Status = ZwCreateProcess(&ProcessHandle,
|
||||||
|
@ -1220,12 +1223,8 @@ NTSTATUS LdrLoadInitialProcess(VOID)
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlInitAnsiString(&AnsiString, "\\??\\C:\\reactos\\system\\shell.exe");
|
RtlInitUnicodeString(&ProcessName, L"\\??\\C:\\reactos\\system\\shell.exe");
|
||||||
RtlAnsiStringToUnicodeString(&ProcessName, &AnsiString, TRUE);
|
|
||||||
|
|
||||||
Status = LdrLoadImage(ProcessHandle, &ProcessName);
|
Status = LdrLoadImage(ProcessHandle, &ProcessName);
|
||||||
|
|
||||||
RtlFreeUnicodeString(&ProcessName);
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,4 +143,5 @@ ex/napi.o: ex/napi.c ../include/ntdll/napi.h
|
||||||
|
|
||||||
#WITH_DEBUGGING = yes
|
#WITH_DEBUGGING = yes
|
||||||
WIN32_LEAN_AND_MEAN = yes
|
WIN32_LEAN_AND_MEAN = yes
|
||||||
|
WARNINGS_ARE_ERRORS = yes
|
||||||
include ../rules.mak
|
include ../rules.mak
|
||||||
|
|
|
@ -28,7 +28,6 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
ULONG i;
|
|
||||||
|
|
||||||
DbgPrint("MmDumpMemoryAreas()\n");
|
DbgPrint("MmDumpMemoryAreas()\n");
|
||||||
|
|
||||||
|
@ -45,9 +44,9 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
||||||
DbgPrint("Finished MmDumpMemoryAreas()\n");
|
DbgPrint("Finished MmDumpMemoryAreas()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmLockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
|
VOID MmLockMemoryAreaList(PVOID Address, PKIRQL oldlvl)
|
||||||
{
|
{
|
||||||
if (Address >= KERNEL_BASE)
|
if (Address >= (PVOID)KERNEL_BASE)
|
||||||
{
|
{
|
||||||
KeAcquireSpinLock(&SystemAreaListLock,oldlvl);
|
KeAcquireSpinLock(&SystemAreaListLock,oldlvl);
|
||||||
}
|
}
|
||||||
|
@ -59,9 +58,9 @@ VOID MmLockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmUnlockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
|
VOID MmUnlockMemoryAreaList(PVOID Address, PKIRQL oldlvl)
|
||||||
{
|
{
|
||||||
if (Address >= KERNEL_BASE)
|
if (Address >= (PVOID)KERNEL_BASE)
|
||||||
{
|
{
|
||||||
KeReleaseSpinLock(&SystemAreaListLock,*oldlvl);
|
KeReleaseSpinLock(&SystemAreaListLock,*oldlvl);
|
||||||
}
|
}
|
||||||
|
@ -102,9 +101,9 @@ VOID MmUnlockMemoryAreaListByMode(KPROCESSOR_MODE Mode, PKIRQL oldlvl)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, ULONG BaseAddress)
|
static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, PVOID BaseAddress)
|
||||||
{
|
{
|
||||||
if (BaseAddress >= KERNEL_BASE)
|
if (BaseAddress >= (PVOID)KERNEL_BASE)
|
||||||
{
|
{
|
||||||
return(&SystemAreaList);
|
return(&SystemAreaList);
|
||||||
}
|
}
|
||||||
|
@ -115,7 +114,7 @@ static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, ULONG BaseAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
||||||
ULONG Address)
|
PVOID Address)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
|
@ -153,7 +152,7 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
||||||
|
|
||||||
|
|
||||||
MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||||
ULONG Address,
|
PVOID Address,
|
||||||
ULONG Length)
|
ULONG Length)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -178,16 +177,16 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||||
current);
|
current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
Extent = current->BaseAddress + current->Length;
|
Extent = (ULONG)current->BaseAddress + current->Length;
|
||||||
if (Extent > Address &&
|
if (Extent > (ULONG)Address &&
|
||||||
Extent < (Address+Length))
|
Extent < (ULONG)(Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||||
current);
|
current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
if (current->BaseAddress <= Address &&
|
if (current->BaseAddress <= Address &&
|
||||||
Extent >= (Address+Length))
|
Extent >= (ULONG)(Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||||
current);
|
current);
|
||||||
|
@ -204,7 +203,8 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process, ULONG Address,
|
MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process,
|
||||||
|
PVOID Address,
|
||||||
ULONG Length)
|
ULONG Length)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
|
@ -223,7 +223,8 @@ MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process, ULONG Address,
|
||||||
|
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process,
|
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process,
|
||||||
ULONG Address, ULONG Length)
|
PVOID Address,
|
||||||
|
ULONG Length)
|
||||||
{
|
{
|
||||||
MEMORY_AREA* Result;
|
MEMORY_AREA* Result;
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
|
@ -249,7 +250,7 @@ MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address)
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(PEPROCESS Process,
|
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(PEPROCESS Process,
|
||||||
ULONG Address)
|
PVOID Address)
|
||||||
{
|
{
|
||||||
MEMORY_AREA* Result;
|
MEMORY_AREA* Result;
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
|
@ -323,7 +324,7 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
InsertTailList(ListHead,inserted_entry);
|
InsertTailList(ListHead,inserted_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG MmFindGapWithoutLock(PEPROCESS Process,
|
static PVOID MmFindGapWithoutLock(PEPROCESS Process,
|
||||||
KPROCESSOR_MODE Mode, ULONG Length)
|
KPROCESSOR_MODE Mode, ULONG Length)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
|
@ -366,7 +367,7 @@ static ULONG MmFindGapWithoutLock(PEPROCESS Process,
|
||||||
if (current_entry == ListHead)
|
if (current_entry == ListHead)
|
||||||
{
|
{
|
||||||
assert(Mode==UserMode);
|
assert(Mode==UserMode);
|
||||||
return(MM_LOWEST_USER_ADDRESS);
|
return((PVOID)MM_LOWEST_USER_ADDRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||||
|
@ -398,13 +399,13 @@ NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
||||||
DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x,"
|
DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x,"
|
||||||
"FreePages %d)\n",Process,BaseAddress,Length,FreePages);
|
"FreePages %d)\n",Process,BaseAddress,Length,FreePages);
|
||||||
|
|
||||||
MmLockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
MmLockMemoryAreaList(BaseAddress, &oldlvl);
|
||||||
|
|
||||||
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock(Process,
|
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock(Process,
|
||||||
(ULONG)BaseAddress);
|
BaseAddress);
|
||||||
if (MemoryArea==NULL)
|
if (MemoryArea==NULL)
|
||||||
{
|
{
|
||||||
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
MmUnlockMemoryAreaList(BaseAddress, &oldlvl);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
if (FreePages)
|
if (FreePages)
|
||||||
|
@ -419,20 +420,10 @@ NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
||||||
|
|
||||||
RemoveEntryList(&(MemoryArea->Entry));
|
RemoveEntryList(&(MemoryArea->Entry));
|
||||||
ExFreePool(MemoryArea);
|
ExFreePool(MemoryArea);
|
||||||
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
MmUnlockMemoryAreaList(BaseAddress, &oldlvl);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea)
|
|
||||||
{
|
|
||||||
MemoryArea->LockCount++;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea)
|
|
||||||
{
|
|
||||||
MemoryArea->LockCount--;
|
|
||||||
}
|
|
||||||
|
|
||||||
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
||||||
PMEMORY_AREA OriginalMemoryArea,
|
PMEMORY_AREA OriginalMemoryArea,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
|
@ -531,8 +522,9 @@ NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*BaseAddress) = PAGE_ROUND_DOWN((*BaseAddress));
|
(*BaseAddress) = (PVOID)PAGE_ROUND_DOWN((*BaseAddress));
|
||||||
if (MmOpenMemoryAreaByRegionWithoutLock(Process,*BaseAddress,
|
if (MmOpenMemoryAreaByRegionWithoutLock(Process,
|
||||||
|
*BaseAddress,
|
||||||
Length)!=NULL)
|
Length)!=NULL)
|
||||||
{
|
{
|
||||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
||||||
|
|
|
@ -68,7 +68,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
||||||
DPRINT("Writing %x with physical address %x\n",
|
DPRINT("Writing %x with physical address %x\n",
|
||||||
base+(i*PAGESIZE),mdl_pages[i]);
|
base+(i*PAGESIZE),mdl_pages[i]);
|
||||||
MmSetPage(NULL,
|
MmSetPage(NULL,
|
||||||
(DWORD)base+(i*PAGESIZE),
|
(PVOID)((DWORD)base+(i*PAGESIZE)),
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
mdl_pages[i]);
|
mdl_pages[i]);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
||||||
DPRINT("StartVa %x\n",Mdl->StartVa);
|
DPRINT("StartVa %x\n",Mdl->StartVa);
|
||||||
|
|
||||||
marea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),
|
marea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),
|
||||||
(ULONG)Mdl->StartVa);
|
Mdl->StartVa);
|
||||||
DPRINT("marea %x\n",marea);
|
DPRINT("marea %x\n",marea);
|
||||||
|
|
||||||
|
|
||||||
|
@ -240,8 +240,8 @@ VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
memset(MemoryDescriptorList,0,sizeof(MDL));
|
memset(MemoryDescriptorList,0,sizeof(MDL));
|
||||||
MemoryDescriptorList->StartVa = PAGE_ROUND_DOWN(Base);
|
MemoryDescriptorList->StartVa = (PVOID)PAGE_ROUND_DOWN(Base);
|
||||||
MemoryDescriptorList->ByteOffset = Base - PAGE_ROUND_DOWN(Base);
|
MemoryDescriptorList->ByteOffset = (ULONG)(Base - PAGE_ROUND_DOWN(Base));
|
||||||
MemoryDescriptorList->MdlFlags = 0;
|
MemoryDescriptorList->MdlFlags = 0;
|
||||||
MemoryDescriptorList->ByteCount = Length;
|
MemoryDescriptorList->ByteCount = Length;
|
||||||
MemoryDescriptorList->Size = sizeof(MDL) +
|
MemoryDescriptorList->Size = sizeof(MDL) +
|
||||||
|
|
|
@ -110,7 +110,7 @@ void MmInitialize(boot_param* bp)
|
||||||
i<PAGE_ROUND_DOWN(((int)&etext));i=i+PAGESIZE)
|
i<PAGE_ROUND_DOWN(((int)&etext));i=i+PAGESIZE)
|
||||||
{
|
{
|
||||||
MmSetPageProtect(NULL,
|
MmSetPageProtect(NULL,
|
||||||
i,
|
(PVOID)i,
|
||||||
PAGE_EXECUTE_READ);
|
PAGE_EXECUTE_READ);
|
||||||
}
|
}
|
||||||
DPRINT("end %x\n",(int)&end);
|
DPRINT("end %x\n",(int)&end);
|
||||||
|
@ -118,7 +118,7 @@ void MmInitialize(boot_param* bp)
|
||||||
i<(KERNEL_BASE+PAGE_TABLE_SIZE);i=i+PAGESIZE)
|
i<(KERNEL_BASE+PAGE_TABLE_SIZE);i=i+PAGESIZE)
|
||||||
{
|
{
|
||||||
MmSetPage(NULL,
|
MmSetPage(NULL,
|
||||||
i,
|
(PVOID)i,
|
||||||
PAGE_NOACCESS,
|
PAGE_NOACCESS,
|
||||||
0);
|
0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,8 +80,6 @@ ULONG EiNrUsedBlocks = 0;
|
||||||
*/
|
*/
|
||||||
static unsigned int alloc_map[ALLOC_MAP_SIZE/32]={0,};
|
static unsigned int alloc_map[ALLOC_MAP_SIZE/32]={0,};
|
||||||
|
|
||||||
static unsigned int pool_free_mem = 0;
|
|
||||||
|
|
||||||
unsigned int EiFreeNonPagedPool = 0;
|
unsigned int EiFreeNonPagedPool = 0;
|
||||||
unsigned int EiUsedNonPagedPool = 0;
|
unsigned int EiUsedNonPagedPool = 0;
|
||||||
|
|
||||||
|
@ -92,6 +90,7 @@ VOID ExInitNonPagedPool(ULONG BaseAddress)
|
||||||
kernel_pool_base=BaseAddress;
|
kernel_pool_base=BaseAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
static void validate_free_list(void)
|
static void validate_free_list(void)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Validate the integrity of the list of free blocks
|
* FUNCTION: Validate the integrity of the list of free blocks
|
||||||
|
@ -260,6 +259,7 @@ static void validate_kernel_pool(void)
|
||||||
current=current->next;
|
current=current->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void add_to_free_list(block_hdr* blk)
|
static void add_to_free_list(block_hdr* blk)
|
||||||
/*
|
/*
|
||||||
|
@ -431,7 +431,7 @@ static block_hdr* grow_kernel_pool(unsigned int size)
|
||||||
for (i=0;i<nr_pages;i++)
|
for (i=0;i<nr_pages;i++)
|
||||||
{
|
{
|
||||||
MmSetPage(NULL,
|
MmSetPage(NULL,
|
||||||
start + (i*PAGESIZE),
|
(PVOID)(start + (i*PAGESIZE)),
|
||||||
PAGE_READWRITE,
|
PAGE_READWRITE,
|
||||||
get_free_page());
|
get_free_page());
|
||||||
}
|
}
|
||||||
|
@ -567,44 +567,6 @@ asmlinkage VOID ExFreePool(PVOID block)
|
||||||
VALIDATE_POOL;
|
VALIDATE_POOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void defrag_free_list(void)
|
|
||||||
/*
|
|
||||||
* FUNCTION: defrag the list of free blocks
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
block_hdr* current=free_list_head,*current2;
|
|
||||||
ULONG addr1,addr2,max=0;
|
|
||||||
|
|
||||||
DPRINT("Begin defrag free,tot free=%d,tot used=%d\n"
|
|
||||||
,EiFreeNonPagedPool
|
|
||||||
,EiUsedNonPagedPool);
|
|
||||||
while (current)
|
|
||||||
{
|
|
||||||
addr1=(ULONG)current;
|
|
||||||
current2=current->next;
|
|
||||||
while(current2)
|
|
||||||
{
|
|
||||||
addr2=(ULONG)current2;
|
|
||||||
if(addr2==addr1+current->size+sizeof(block_hdr))
|
|
||||||
{
|
|
||||||
remove_from_free_list(current2);
|
|
||||||
current->size+=current2->size+sizeof(block_hdr);
|
|
||||||
if(current->size>max)max=current->size;
|
|
||||||
}
|
|
||||||
else if(addr1==addr2+current2->size+sizeof(block_hdr))
|
|
||||||
{
|
|
||||||
remove_from_free_list(current);
|
|
||||||
current2->size+=current->size+sizeof(block_hdr);
|
|
||||||
if(current2->size>max)max=current2->size;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
current2=current2->next;
|
|
||||||
}
|
|
||||||
current=current->next;
|
|
||||||
}
|
|
||||||
DPRINT("Finish To defrag free blocks,max=%d\n",max);
|
|
||||||
}
|
|
||||||
|
|
||||||
PVOID ExAllocateNonPagedPoolWithTag(ULONG type,
|
PVOID ExAllocateNonPagedPoolWithTag(ULONG type,
|
||||||
ULONG size,
|
ULONG size,
|
||||||
ULONG Tag,
|
ULONG Tag,
|
||||||
|
|
|
@ -48,7 +48,7 @@ PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG NumberOfBytes)
|
||||||
Block = ExAllocateNonPagedPoolWithTag(PoolType,
|
Block = ExAllocateNonPagedPoolWithTag(PoolType,
|
||||||
NumberOfBytes,
|
NumberOfBytes,
|
||||||
TAG_NONE,
|
TAG_NONE,
|
||||||
(&PoolType)[-1]);
|
(PVOID)(&PoolType)[-1]);
|
||||||
return(Block);
|
return(Block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ PVOID ExAllocatePoolWithTag(ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
|
||||||
Block = ExAllocateNonPagedPoolWithTag(PoolType,
|
Block = ExAllocateNonPagedPoolWithTag(PoolType,
|
||||||
NumberOfBytes,
|
NumberOfBytes,
|
||||||
Tag,
|
Tag,
|
||||||
(&PoolType)[-1]);
|
(PVOID)(&PoolType)[-1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PagedPool:
|
case PagedPool:
|
||||||
|
@ -91,31 +91,8 @@ PVOID ExAllocatePoolWithTag(ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
|
||||||
return(Block);
|
return(Block);
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID ExAllocatePoolWithQuotaTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
|
|
||||||
ULONG Tag)
|
|
||||||
{
|
|
||||||
PVOID Block;
|
|
||||||
PKTHREAD current = KeGetCurrentThread();
|
|
||||||
|
|
||||||
Block = ExAllocatePoolWithTag(PoolType,NumberOfBytes,Tag);
|
|
||||||
switch(PoolType)
|
|
||||||
{
|
|
||||||
case NonPagedPool:
|
|
||||||
case NonPagedPoolMustSucceed:
|
|
||||||
case NonPagedPoolCacheAligned:
|
|
||||||
case NonPagedPoolCacheAlignedMustS:
|
|
||||||
// current->NPagedPoolQuota = current->NPagedPoolQuota - NumberOfBytes;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case PagedPool:
|
|
||||||
case PagedPoolCacheAligned:
|
|
||||||
// current->PagedPoolQuota = current->PagedPoolQuota - NumberOfBytes;
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
return(Block);
|
|
||||||
}
|
|
||||||
|
|
||||||
PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes)
|
PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes)
|
||||||
{
|
{
|
||||||
return(ExAllocatePoolWithQuotaTag(PoolType,NumberOfBytes,TAG_NONE));
|
// return(ExAllocatePoolWithQuotaTag(PoolType,NumberOfBytes,TAG_NONE));
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
#include <internal/io.h>
|
#include <internal/io.h>
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
|
#include <wchar.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -31,9 +32,9 @@ VOID MmpDeleteSection(PVOID ObjectBody)
|
||||||
|
|
||||||
NTSTATUS MmpCreateSection(PVOID ObjectBody,
|
NTSTATUS MmpCreateSection(PVOID ObjectBody,
|
||||||
PVOID Parent,
|
PVOID Parent,
|
||||||
PWSTR RemainingPath)
|
PWSTR RemainingPath,
|
||||||
|
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)ObjectBody;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("MmpCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
DPRINT("MmpCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
PVOID MmAllocateSection(ULONG Length)
|
PVOID MmAllocateSection(ULONG Length)
|
||||||
{
|
{
|
||||||
ULONG Result;
|
PVOID Result;
|
||||||
MEMORY_AREA* marea;
|
MEMORY_AREA* marea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
@ -39,7 +39,7 @@ PVOID MmAllocateSection(ULONG Length)
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
DPRINT("Result %x\n",Result);
|
DPRINT("Result %p\n",Result);
|
||||||
for (i=0;i<=(Length/PAGESIZE);i++)
|
for (i=0;i<=(Length/PAGESIZE);i++)
|
||||||
{
|
{
|
||||||
MmSetPage(NULL,
|
MmSetPage(NULL,
|
||||||
|
@ -65,7 +65,7 @@ PVOID MmMapIoSpace(PHYSICAL_ADDRESS PhysicalAddress,
|
||||||
ULONG NumberOfBytes,
|
ULONG NumberOfBytes,
|
||||||
BOOLEAN CacheEnable)
|
BOOLEAN CacheEnable)
|
||||||
{
|
{
|
||||||
ULONG Result;
|
PVOID Result;
|
||||||
MEMORY_AREA* marea;
|
MEMORY_AREA* marea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
@ -106,7 +106,7 @@ VOID MmUnmapIoSpace(PVOID BaseAddress, ULONG NumberOfBytes)
|
||||||
|
|
||||||
PVOID MmAllocateNonCachedMemory(ULONG NumberOfBytes)
|
PVOID MmAllocateNonCachedMemory(ULONG NumberOfBytes)
|
||||||
{
|
{
|
||||||
ULONG Result;
|
PVOID Result;
|
||||||
MEMORY_AREA* marea;
|
MEMORY_AREA* marea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
|
@ -91,7 +91,7 @@ void VirtualInit(boot_param* bp)
|
||||||
MmInitSectionImplementation();
|
MmInitSectionImplementation();
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, ULONG Address)
|
ULONG MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
||||||
{
|
{
|
||||||
MmSetPage(PsGetCurrentProcess(),
|
MmSetPage(PsGetCurrentProcess(),
|
||||||
Address,
|
Address,
|
||||||
|
@ -208,7 +208,7 @@ asmlinkage int page_fault_handler(unsigned int cs,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEMORY_AREA_COMMIT:
|
case MEMORY_AREA_COMMIT:
|
||||||
stat = MmCommitedSectionHandleFault(MemoryArea,cr2);
|
stat = MmCommitedSectionHandleFault(MemoryArea,(PVOID)cr2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -669,7 +669,8 @@ NTSTATUS STDCALL ZwReadVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
|
|
||||||
for (i=0; i<(NumberOfBytesToRead/PAGESIZE); i++)
|
for (i=0; i<(NumberOfBytesToRead/PAGESIZE); i++)
|
||||||
{
|
{
|
||||||
CurrentEntry = MmGetPageEntry(Process, (DWORD)BaseAddress + (i*PAGESIZE));
|
CurrentEntry = MmGetPageEntry(Process,
|
||||||
|
(PVOID)((DWORD)BaseAddress + (i*PAGESIZE)));
|
||||||
RtlCopyMemory(Buffer + (i*PAGESIZE),
|
RtlCopyMemory(Buffer + (i*PAGESIZE),
|
||||||
(PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)),
|
(PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)),
|
||||||
PAGESIZE);
|
PAGESIZE);
|
||||||
|
@ -717,7 +718,6 @@ NTSTATUS STDCALL ZwWriteVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
OUT PULONG NumberOfBytesWritten)
|
OUT PULONG NumberOfBytesWritten)
|
||||||
{
|
{
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
PMEMORY_AREA InMemoryArea;
|
|
||||||
PMEMORY_AREA OutMemoryArea;
|
PMEMORY_AREA OutMemoryArea;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -759,8 +759,9 @@ NTSTATUS STDCALL ZwWriteVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
OutMemoryArea->Attributes,
|
OutMemoryArea->Attributes,
|
||||||
get_free_page());
|
get_free_page());
|
||||||
}
|
}
|
||||||
CurrentEntry = MmGetPageEntry(Process, (DWORD)BaseAddress +
|
CurrentEntry = MmGetPageEntry(Process,
|
||||||
(i*PAGESIZE));
|
(PVOID)((DWORD)BaseAddress +
|
||||||
|
(i*PAGESIZE)));
|
||||||
RtlCopyMemory((PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)) +
|
RtlCopyMemory((PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)) +
|
||||||
(((DWORD)BaseAddress)%PAGESIZE),
|
(((DWORD)BaseAddress)%PAGESIZE),
|
||||||
Buffer + (i*PAGESIZE),
|
Buffer + (i*PAGESIZE),
|
||||||
|
|
|
@ -130,6 +130,8 @@ NTSTATUS ExInitializeZone(PZONE_HEADER Zone, ULONG BlockSize,
|
||||||
PushEntryList(&Zone->FreeList,&entry->Entry);
|
PushEntryList(&Zone->FreeList,&entry->Entry);
|
||||||
entry = (PZONE_ENTRY)(((PVOID)entry) + sizeof(ZONE_ENTRY) + BlockSize);
|
entry = (PZONE_ENTRY)(((PVOID)entry) + sizeof(ZONE_ENTRY) + BlockSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID ExInterlockedFreeToZone(PZONE_HEADER Zone, PVOID Block,
|
PVOID ExInterlockedFreeToZone(PZONE_HEADER Zone, PVOID Block,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/nt/nt.c
|
* FILE: ntoskrnl/nt/nt.c
|
||||||
* PURPOSE: Initialization of system call interfaces
|
* PURPOSE: Initialization of system call interfaces
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
@ -11,6 +11,7 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/nt.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,7 @@
|
||||||
NTSTATUS STDCALL NtCancelTimer(IN HANDLE TimerHandle,
|
NTSTATUS STDCALL NtCancelTimer(IN HANDLE TimerHandle,
|
||||||
OUT PBOOLEAN CurrentState OPTIONAL)
|
OUT PBOOLEAN CurrentState OPTIONAL)
|
||||||
{
|
{
|
||||||
return(ZwCancelTimer(TimerHandle,
|
UNIMPLEMENTED;
|
||||||
CurrentState));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL ZwCancelTimer(IN HANDLE TimerHandle,
|
NTSTATUS STDCALL ZwCancelTimer(IN HANDLE TimerHandle,
|
||||||
|
|
|
@ -34,6 +34,40 @@ typedef struct
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
|
static PHANDLE_REP ObpGetObjectByHandle(PEPROCESS Process,
|
||||||
|
HANDLE h)
|
||||||
|
/*
|
||||||
|
* FUNCTION: Get the data structure for a handle
|
||||||
|
* ARGUMENTS:
|
||||||
|
* Process = Process to get the handle for
|
||||||
|
* h = Handle
|
||||||
|
* ARGUMENTS: A pointer to the information about the handle on success,
|
||||||
|
* NULL on failure
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
PLIST_ENTRY current;
|
||||||
|
unsigned int handle = ((unsigned int)h) - 1;
|
||||||
|
unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
|
||||||
|
HANDLE_BLOCK* blk = NULL;
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
DPRINT("ObpGetObjectByHandle(Process %x, h %x)\n",Process,h);
|
||||||
|
|
||||||
|
current = Process->Pcb.HandleTable.ListHead.Flink;
|
||||||
|
DPRINT("current %x\n",current);
|
||||||
|
|
||||||
|
for (i=0;i<count;i++)
|
||||||
|
{
|
||||||
|
current = current->Flink;
|
||||||
|
if (current==(&(Process->Pcb.HandleTable.ListHead)))
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blk = CONTAINING_RECORD(current,HANDLE_BLOCK,entry);
|
||||||
|
return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtDuplicateObject(IN HANDLE SourceProcessHandle,
|
NTSTATUS STDCALL NtDuplicateObject(IN HANDLE SourceProcessHandle,
|
||||||
IN PHANDLE SourceHandle,
|
IN PHANDLE SourceHandle,
|
||||||
|
@ -180,41 +214,6 @@ VOID ObCreateHandleTable(PEPROCESS Parent,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static PHANDLE_REP ObpGetObjectByHandle(PEPROCESS Process,
|
|
||||||
HANDLE h)
|
|
||||||
/*
|
|
||||||
* FUNCTION: Get the data structure for a handle
|
|
||||||
* ARGUMENTS:
|
|
||||||
* Process = Process to get the handle for
|
|
||||||
* h = Handle
|
|
||||||
* ARGUMENTS: A pointer to the information about the handle on success,
|
|
||||||
* NULL on failure
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
PLIST_ENTRY current;
|
|
||||||
unsigned int handle = ((unsigned int)h) - 1;
|
|
||||||
unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
|
|
||||||
HANDLE_BLOCK* blk = NULL;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
DPRINT("ObpGetObjectByHandle(Process %x, h %x)\n",Process,h);
|
|
||||||
|
|
||||||
current = Process->Pcb.HandleTable.ListHead.Flink;
|
|
||||||
DPRINT("current %x\n",current);
|
|
||||||
|
|
||||||
for (i=0;i<count;i++)
|
|
||||||
{
|
|
||||||
current = current->Flink;
|
|
||||||
if (current==(&(Process->Pcb.HandleTable.ListHead)))
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
blk = CONTAINING_RECORD(current,HANDLE_BLOCK,entry);
|
|
||||||
return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID ObDeleteHandle(HANDLE Handle)
|
VOID ObDeleteHandle(HANDLE Handle)
|
||||||
{
|
{
|
||||||
PHANDLE_REP Rep;
|
PHANDLE_REP Rep;
|
||||||
|
|
|
@ -133,7 +133,6 @@ PVOID ObpParseDirectory(PVOID Object, PWSTR* Path)
|
||||||
{
|
{
|
||||||
PWSTR end;
|
PWSTR end;
|
||||||
PVOID FoundObject;
|
PVOID FoundObject;
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
DPRINT("ObpParseDirectory(Object %x, Path %x, *Path %w)\n",
|
DPRINT("ObpParseDirectory(Object %x, Path %x, *Path %w)\n",
|
||||||
Object,Path,*Path);
|
Object,Path,*Path);
|
||||||
|
|
|
@ -11,18 +11,19 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
#include <internal/ke.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
/* GLOBALS *******************************************************************/
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
HANDLE IdleThreadHandle = NULL;
|
HANDLE PsIdleThreadHandle = NULL;
|
||||||
extern ULONG DpcQueueSize;
|
extern ULONG DpcQueueSize;
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
static VOID PsIdleThreadMain(PVOID Context)
|
static NTSTATUS PsIdleThreadMain(PVOID Context)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ VOID PsInitIdleThread(VOID)
|
||||||
{
|
{
|
||||||
KPRIORITY Priority;
|
KPRIORITY Priority;
|
||||||
|
|
||||||
PsCreateSystemThread(&IdleThreadHandle,
|
PsCreateSystemThread(&PsIdleThreadHandle,
|
||||||
THREAD_ALL_ACCESS,
|
THREAD_ALL_ACCESS,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -52,7 +53,7 @@ VOID PsInitIdleThread(VOID)
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
Priority = THREAD_PRIORITY_IDLE;
|
Priority = THREAD_PRIORITY_IDLE;
|
||||||
ZwSetInformationThread(IdleThreadHandle,
|
ZwSetInformationThread(PsIdleThreadHandle,
|
||||||
ThreadPriority,
|
ThreadPriority,
|
||||||
&Priority,
|
&Priority,
|
||||||
sizeof(Priority));
|
sizeof(Priority));
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ps/kill.c
|
* FILE: ntoskrnl/ps/kill.c
|
||||||
* PURPOSE: Terminating a thread
|
* PURPOSE: Terminating a thread
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||||
* UPDATE HISTORY:
|
* UPDATE HISTORY:
|
||||||
* Created 22/05/98
|
* Created 22/05/98
|
||||||
*/
|
*/
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/ps.h>
|
#include <internal/ps.h>
|
||||||
|
#include <internal/ke.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -62,7 +63,6 @@ NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
|
||||||
NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle,
|
NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle,
|
||||||
IN NTSTATUS ExitStatus)
|
IN NTSTATUS ExitStatus)
|
||||||
{
|
{
|
||||||
PETHREAD Thread;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/ob.h>
|
#include <internal/ob.h>
|
||||||
#include <internal/mm.h>
|
#include <internal/mm.h>
|
||||||
|
#include <internal/ke.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
|
||||||
|
@ -161,9 +162,6 @@ NTSTATUS STDCALL ZwCreateProcess(
|
||||||
PULONG CurrentPageDirectory;
|
PULONG CurrentPageDirectory;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
PKPROCESS KProcess;
|
PKPROCESS KProcess;
|
||||||
ULONG Base;
|
|
||||||
ULONG Length;
|
|
||||||
LARGE_INTEGER Offset;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("ZwCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
|
DPRINT("ZwCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
|
||||||
|
@ -196,10 +194,10 @@ NTSTATUS STDCALL ZwCreateProcess(
|
||||||
InheritObjectTable,
|
InheritObjectTable,
|
||||||
Process);
|
Process);
|
||||||
|
|
||||||
PageDirectory = physical_to_linear((ULONG)get_free_page());
|
PageDirectory = (PULONG)physical_to_linear((ULONG)get_free_page());
|
||||||
KProcess->PageTableDirectory = PageDirectory;
|
KProcess->PageTableDirectory = PageDirectory;
|
||||||
|
|
||||||
CurrentPageDirectory = get_page_directory();
|
CurrentPageDirectory = (PULONG)get_page_directory();
|
||||||
|
|
||||||
memset(PageDirectory,0,PAGESIZE);
|
memset(PageDirectory,0,PAGESIZE);
|
||||||
for (i=768;i<1024;i++)
|
for (i=768;i<1024;i++)
|
||||||
|
@ -260,10 +258,10 @@ NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
IN ULONG ProcessInformationLength,
|
IN ULONG ProcessInformationLength,
|
||||||
OUT PULONG ReturnLength)
|
OUT PULONG ReturnLength)
|
||||||
{
|
{
|
||||||
PEPROCESS Process;
|
// PEPROCESS Process;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
/* Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_QUERY_INFORMATION,
|
PROCESS_QUERY_INFORMATION,
|
||||||
PsProcessType,
|
PsProcessType,
|
||||||
UserMode,
|
UserMode,
|
||||||
|
@ -272,7 +270,7 @@ NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle,
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
switch (ProcessInformationClass)
|
switch (ProcessInformationClass)
|
||||||
{
|
{
|
||||||
|
@ -319,10 +317,10 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
IN PVOID ProcessInformation,
|
IN PVOID ProcessInformation,
|
||||||
IN ULONG ProcessInformationLength)
|
IN ULONG ProcessInformationLength)
|
||||||
{
|
{
|
||||||
PEPROCESS Process;
|
// PEPROCESS Process;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
/* Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||||
PROCESS_SET_INFORMATION,
|
PROCESS_SET_INFORMATION,
|
||||||
PsProcessType,
|
PsProcessType,
|
||||||
UserMode,
|
UserMode,
|
||||||
|
@ -331,7 +329,7 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle,
|
||||||
if (Status != STATUS_SUCCESS)
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
switch (ProcessInformationClass)
|
switch (ProcessInformationClass)
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,8 +210,6 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
ACCESS_MASK DesiredAccess,
|
ACCESS_MASK DesiredAccess,
|
||||||
POBJECT_ATTRIBUTES ThreadAttributes)
|
POBJECT_ATTRIBUTES ThreadAttributes)
|
||||||
{
|
{
|
||||||
ULONG ThreadId;
|
|
||||||
ULONG ProcessId;
|
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
@ -256,7 +254,8 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
||||||
UserMode);
|
UserMode);
|
||||||
InitializeListHead(Thread->Tcb.ApcList);
|
InitializeListHead(Thread->Tcb.ApcList);
|
||||||
InitializeListHead(&(Thread->IrpList));
|
InitializeListHead(&(Thread->IrpList));
|
||||||
Thread->Cid.UniqueThread=InterlockedIncrement(&NextThreadUniqueId);
|
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
|
||||||
|
&NextThreadUniqueId);
|
||||||
ObReferenceObjectByPointer(Thread,
|
ObReferenceObjectByPointer(Thread,
|
||||||
THREAD_ALL_ACCESS,
|
THREAD_ALL_ACCESS,
|
||||||
PsThreadType,
|
PsThreadType,
|
||||||
|
|
|
@ -45,7 +45,8 @@ NTSTATUS ZwSetInformationThread(HANDLE ThreadHandle,
|
||||||
ThreadBasicInformationP->TebBaseAddress = Thread->Tcb.Teb;
|
ThreadBasicInformationP->TebBaseAddress = Thread->Tcb.Teb;
|
||||||
ThreadBasicInformationP->AffinityMask = Thread->Tcb.Affinity;
|
ThreadBasicInformationP->AffinityMask = Thread->Tcb.Affinity;
|
||||||
ThreadBasicInformationP->BasePriority = Thread->Tcb.BasePriority;
|
ThreadBasicInformationP->BasePriority = Thread->Tcb.BasePriority;
|
||||||
ThreadBasicInformationP->UniqueThreadId = Thread->Cid.UniqueThread;
|
ThreadBasicInformationP->UniqueThreadId = (ULONG)
|
||||||
|
Thread->Cid.UniqueThread;
|
||||||
Status = STATUS_SUCCESS;
|
Status = STATUS_SUCCESS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -48,7 +48,7 @@ VOID RtlCopyBytes(PVOID Destination,
|
||||||
RtlCopyMemory(Destination,Source,Length);
|
RtlCopyMemory(Destination,Source,Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length)
|
VOID RtlCopyMemory(VOID* Destination, CONST VOID* Source, ULONG Length)
|
||||||
{
|
{
|
||||||
DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n",
|
DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n",
|
||||||
Destination,Source,Length);
|
Destination,Source,Length);
|
||||||
|
|
|
@ -16,12 +16,11 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
#undef memcpy
|
|
||||||
void *memcpy (void *to, const void *from, size_t count)
|
void *memcpy (void *to, const void *from, size_t count)
|
||||||
{
|
{
|
||||||
register char *f = from;
|
const char *f = from;
|
||||||
register char *t = to;
|
char *t = to;
|
||||||
register int i = count;
|
int i = count;
|
||||||
|
|
||||||
while (i-- > 0)
|
while (i-- > 0)
|
||||||
*t++ = *f++;
|
*t++ = *f++;
|
||||||
|
|
|
@ -16,8 +16,3 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID RtlGetCallersAddress(PVOID* CallersAddress)
|
|
||||||
{
|
|
||||||
PULONG stk = (PULONG)(&CallersAddress);
|
|
||||||
*CallersAddress = stk[-1];
|
|
||||||
}
|
|
||||||
|
|
|
@ -21,14 +21,8 @@
|
||||||
|
|
||||||
#define Aa_Difference ('A'-'a')
|
#define Aa_Difference ('A'-'a')
|
||||||
|
|
||||||
PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest,
|
extern unsigned long simple_strtoul(const char *cp, char **endp,
|
||||||
PUNICODE_STRING Src)
|
unsigned int base);
|
||||||
{
|
|
||||||
if (Dest==NULL)
|
|
||||||
{
|
|
||||||
Dest=ExAllocatePool(NonPagedPool,sizeof(UNICODE_STRING));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
|
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
|
||||||
{
|
{
|
||||||
|
@ -128,7 +122,8 @@ NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
|
||||||
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);
|
||||||
};
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
|
||||||
{
|
{
|
||||||
|
@ -348,7 +343,7 @@ VOID RtlInitString(IN OUT PSTRING DestinationString,
|
||||||
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
IN PCWSTR SourceString)
|
IN PCWSTR SourceString)
|
||||||
{
|
{
|
||||||
unsigned long i, DestSize;
|
unsigned long DestSize;
|
||||||
|
|
||||||
DPRINT("RtlInitUnicodeString(DestinationString %x, "
|
DPRINT("RtlInitUnicodeString(DestinationString %x, "
|
||||||
"SourceString %x)\n",DestinationString,SourceString);
|
"SourceString %x)\n",DestinationString,SourceString);
|
||||||
|
@ -368,6 +363,7 @@ VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
@ -384,7 +380,7 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
||||||
if(Base==2) {
|
if(Base==2) {
|
||||||
sprintf(str, "%b", Value);
|
sprintf(str, "%b", Value);
|
||||||
} else {
|
} else {
|
||||||
sprintf(str, "%u", Value);
|
sprintf(str, "%u", (unsigned int)Value);
|
||||||
};
|
};
|
||||||
|
|
||||||
len=strlen(str);
|
len=strlen(str);
|
||||||
|
@ -402,7 +398,8 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
||||||
ExFreePool(str);
|
ExFreePool(str);
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
};
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
||||||
IN PUNICODE_STRING SourceString,
|
IN PUNICODE_STRING SourceString,
|
||||||
|
@ -487,7 +484,8 @@ 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);
|
||||||
};
|
return(STATUS_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
IN PUNICODE_STRING SourceString,
|
IN PUNICODE_STRING SourceString,
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <wchar.h>
|
#include <wchar.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -62,7 +63,6 @@ wcschr(const wchar_t *str, wchar_t ch)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
wchar_t towupper(wchar_t w)
|
wchar_t towupper(wchar_t w)
|
||||||
{
|
{
|
||||||
if (w < L'A')
|
if (w < L'A')
|
||||||
|
@ -74,11 +74,10 @@ wchar_t towupper(wchar_t w)
|
||||||
return(w);
|
return(w);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int wcsicmp(const wchar_t* cs, const wchar_t* ct)
|
int wcsicmp(const wchar_t* cs, const wchar_t* ct)
|
||||||
{
|
{
|
||||||
while (*cs != '\0' && *ct != '\0' && wtoupper(*cs) == wtoupper(*ct))
|
while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct))
|
||||||
{
|
{
|
||||||
cs++;
|
cs++;
|
||||||
ct++;
|
ct++;
|
||||||
|
|
|
@ -68,6 +68,7 @@ NtSetSecurityObject(
|
||||||
IN PSECURITY_DESCRIPTOR SecurityDescriptor
|
IN PSECURITY_DESCRIPTOR SecurityDescriptor
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -79,6 +80,7 @@ NtSetInformationToken(
|
||||||
IN ULONG TokenInformationLength
|
IN ULONG TokenInformationLength
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -89,6 +91,7 @@ NtPrivilegeCheck(
|
||||||
IN PBOOLEAN Result
|
IN PBOOLEAN Result
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -101,6 +104,7 @@ NtPrivilegedServiceAuditAlarm(
|
||||||
IN BOOLEAN AccessGranted
|
IN BOOLEAN AccessGranted
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -112,8 +116,10 @@ NtPrivilegeObjectAuditAlarm(
|
||||||
IN ULONG DesiredAccess,
|
IN ULONG DesiredAccess,
|
||||||
IN PPRIVILEGE_SET Privileges,
|
IN PPRIVILEGE_SET Privileges,
|
||||||
IN BOOLEAN AccessGranted
|
IN BOOLEAN AccessGranted
|
||||||
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -131,6 +137,7 @@ NtOpenObjectAuditAlarm(
|
||||||
OUT PBOOLEAN GenerateOnClose
|
OUT PBOOLEAN GenerateOnClose
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -141,6 +148,7 @@ NtOpenProcessToken(
|
||||||
OUT PHANDLE TokenHandle
|
OUT PHANDLE TokenHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -152,71 +160,58 @@ NtOpenThreadToken(
|
||||||
OUT PHANDLE TokenHandle
|
OUT PHANDLE TokenHandle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtDuplicateToken(IN HANDLE ExistingToken,
|
||||||
STDCALL
|
|
||||||
NtDuplicateToken(
|
|
||||||
IN HANDLE ExistingToken,
|
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
|
IN SECURITY_IMPERSONATION_LEVEL
|
||||||
|
ImpersonationLevel,
|
||||||
IN TOKEN_TYPE TokenType,
|
IN TOKEN_TYPE TokenType,
|
||||||
OUT PHANDLE NewToken
|
OUT PHANDLE NewToken)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS STDCALL NtImpersonateClientOfPort(VOID)
|
NTSTATUS STDCALL NtImpersonateClientOfPort(VOID)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtImpersonateThread(IN HANDLE ThreadHandle,
|
||||||
STDCALL
|
|
||||||
NtImpersonateThread(
|
|
||||||
IN HANDLE ThreadHandle,
|
|
||||||
IN HANDLE ThreadToImpersonate,
|
IN HANDLE ThreadToImpersonate,
|
||||||
IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService
|
IN PSECURITY_QUALITY_OF_SERVICE
|
||||||
)
|
SecurityQualityOfService)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS STDCALL NtCreateToken(VOID)
|
NTSTATUS STDCALL NtCreateToken(VOID)
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtDeleteObjectAuditAlarm(IN PUNICODE_STRING SubsystemName,
|
||||||
STDCALL
|
|
||||||
NtDeleteObjectAuditAlarm (
|
|
||||||
IN PUNICODE_STRING SubsystemName,
|
|
||||||
IN PVOID HandleId,
|
IN PVOID HandleId,
|
||||||
IN BOOLEAN GenerateOnClose
|
IN BOOLEAN GenerateOnClose)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
|
||||||
STDCALL
|
|
||||||
NtAllocateLocallyUniqueId(
|
|
||||||
OUT LUID *LocallyUniqueId
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwAllocateLocallyUniqueId(LocallyUniqueId));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
|
||||||
STDCALL
|
|
||||||
ZwAllocateLocallyUniqueId(
|
|
||||||
OUT LUID *LocallyUniqueId
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtAccessCheckAndAuditAlarm(IN PUNICODE_STRING SubsystemName,
|
||||||
STDCALL
|
|
||||||
NtAccessCheckAndAuditAlarm(
|
|
||||||
IN PUNICODE_STRING SubsystemName,
|
|
||||||
IN PHANDLE ObjectHandle,
|
IN PHANDLE ObjectHandle,
|
||||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
IN ACCESS_MASK DesiredAccess,
|
IN ACCESS_MASK DesiredAccess,
|
||||||
|
@ -224,107 +219,98 @@ NtAccessCheckAndAuditAlarm(
|
||||||
IN BOOLEAN ObjectCreation,
|
IN BOOLEAN ObjectCreation,
|
||||||
OUT PULONG GrantedAccess,
|
OUT PULONG GrantedAccess,
|
||||||
OUT PBOOLEAN AccessStatus,
|
OUT PBOOLEAN AccessStatus,
|
||||||
OUT PBOOLEAN GenerateOnClose
|
OUT PBOOLEAN GenerateOnClose)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtAdjustGroupsToken(IN HANDLE TokenHandle,
|
||||||
STDCALL
|
|
||||||
NtAdjustGroupsToken(
|
|
||||||
IN HANDLE TokenHandle,
|
|
||||||
IN BOOLEAN ResetToDefault,
|
IN BOOLEAN ResetToDefault,
|
||||||
IN PTOKEN_GROUPS NewState,
|
IN PTOKEN_GROUPS NewState,
|
||||||
IN ULONG BufferLength,
|
IN ULONG BufferLength,
|
||||||
OUT PTOKEN_GROUPS PreviousState OPTIONAL,
|
OUT PTOKEN_GROUPS PreviousState OPTIONAL,
|
||||||
OUT PULONG ReturnLength
|
OUT PULONG ReturnLength)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtAdjustPrivilegesToken(IN HANDLE TokenHandle,
|
||||||
STDCALL
|
|
||||||
NtAdjustPrivilegesToken(
|
|
||||||
IN HANDLE TokenHandle,
|
|
||||||
IN BOOLEAN DisableAllPrivileges,
|
IN BOOLEAN DisableAllPrivileges,
|
||||||
IN PTOKEN_PRIVILEGES NewState,
|
IN PTOKEN_PRIVILEGES NewState,
|
||||||
IN ULONG BufferLength,
|
IN ULONG BufferLength,
|
||||||
OUT PTOKEN_PRIVILEGES PreviousState,
|
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||||
OUT PULONG ReturnLength
|
OUT PULONG ReturnLength)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwAdjustPrivilegesToken(TokenHandle,
|
||||||
|
DisableAllPrivileges,
|
||||||
|
NewState,
|
||||||
|
BufferLength,
|
||||||
|
PreviousState,
|
||||||
|
ReturnLength));
|
||||||
}
|
}
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
NTSTATUS STDCALL ZwAdjustPrivilegesToken(IN HANDLE TokenHandle,
|
||||||
ZwAdjustPrivilegesToken(
|
|
||||||
IN HANDLE TokenHandle,
|
|
||||||
IN BOOLEAN DisableAllPrivileges,
|
IN BOOLEAN DisableAllPrivileges,
|
||||||
IN PTOKEN_PRIVILEGES NewState,
|
IN PTOKEN_PRIVILEGES NewState,
|
||||||
IN ULONG BufferLength,
|
IN ULONG BufferLength,
|
||||||
OUT PTOKEN_PRIVILEGES PreviousState,
|
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||||
OUT PULONG ReturnLength
|
OUT PULONG ReturnLength)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtAllocateUuids(PLARGE_INTEGER Time,
|
||||||
STDCALL
|
|
||||||
NtAllocateUuids(
|
|
||||||
PLARGE_INTEGER Time,
|
|
||||||
PULONG Version, // ???
|
PULONG Version, // ???
|
||||||
PULONG ClockCycle
|
PULONG ClockCycle)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
return(ZwAllocateUuids(Time,
|
||||||
|
Version,
|
||||||
|
ClockCycle));
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL ZwAllocateUuids(PLARGE_INTEGER Time,
|
||||||
STDCALL
|
|
||||||
ZwAllocateUuids(
|
|
||||||
PLARGE_INTEGER Time,
|
|
||||||
PULONG Version, // ???
|
PULONG Version, // ???
|
||||||
PULONG ClockCycle
|
PULONG ClockCycle)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtCloseObjectAuditAlarm(IN PUNICODE_STRING SubsystemName,
|
||||||
STDCALL
|
|
||||||
NtCloseObjectAuditAlarm(
|
|
||||||
IN PUNICODE_STRING SubsystemName,
|
|
||||||
IN PVOID HandleId,
|
IN PVOID HandleId,
|
||||||
IN BOOLEAN GenerateOnClose
|
IN BOOLEAN GenerateOnClose)
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
STDCALL
|
IN HANDLE ClientToken,
|
||||||
NtAccessCheck(
|
IN ACCESS_MASK DesiredAccess,
|
||||||
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
IN PGENERIC_MAPPING GenericMapping,
|
||||||
|
OUT PRIVILEGE_SET PrivilegeSet,
|
||||||
|
OUT PULONG ReturnLength,
|
||||||
|
OUT PULONG GrantedAccess,
|
||||||
|
OUT PBOOLEAN AccessStatus)
|
||||||
|
{
|
||||||
|
return(ZwAccessCheck(SecurityDescriptor,
|
||||||
|
ClientToken,
|
||||||
|
DesiredAccess,
|
||||||
|
GenericMapping,
|
||||||
|
PrivilegeSet,
|
||||||
|
ReturnLength,
|
||||||
|
GrantedAccess,
|
||||||
|
AccessStatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ZwAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
IN HANDLE ClientToken,
|
IN HANDLE ClientToken,
|
||||||
IN ACCESS_MASK DesiredAcces,
|
IN ACCESS_MASK DesiredAcces,
|
||||||
IN PGENERIC_MAPPING GenericMapping,
|
IN PGENERIC_MAPPING GenericMapping,
|
||||||
OUT PRIVILEGE_SET PrivilegeSet,
|
OUT PRIVILEGE_SET PrivilegeSet,
|
||||||
OUT PULONG ReturnLength,
|
OUT PULONG ReturnLength,
|
||||||
OUT PULONG GrantedAccess,
|
OUT PULONG GrantedAccess,
|
||||||
OUT PBOOLEAN AccessStatus
|
OUT PBOOLEAN AccessStatus)
|
||||||
)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
STDCALL
|
|
||||||
ZwAccessCheck(
|
|
||||||
IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
|
||||||
IN HANDLE ClientToken,
|
|
||||||
IN ACCESS_MASK DesiredAcces,
|
|
||||||
IN PGENERIC_MAPPING GenericMapping,
|
|
||||||
OUT PRIVILEGE_SET PrivilegeSet,
|
|
||||||
OUT PULONG ReturnLength,
|
|
||||||
OUT PULONG GrantedAccess,
|
|
||||||
OUT PBOOLEAN AccessStatus
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
|
NTSTATUS RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||||
|
|
|
@ -77,7 +77,7 @@ int main(int argc, char* argv[])
|
||||||
fprintf(stdout,"{\"_%s\",(unsigned int)%s},\n",sym[j],sym[j]);
|
fprintf(stdout,"{\"_%s\",(unsigned int)%s},\n",sym[j],sym[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf(stdout,"{NULL,NULL},\n");
|
fprintf(stdout,"{(char *)NULL,0},\n");
|
||||||
fprintf(stdout,"};\n");
|
fprintf(stdout,"};\n");
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
|
|
|
@ -40,6 +40,10 @@ else
|
||||||
DEBUGGING_CFLAGS =
|
DEBUGGING_CFLAGS =
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(WARNINGS_ARE_ERRORS),yes)
|
||||||
|
EXTRA_CFLAGS = -Werror
|
||||||
|
endif
|
||||||
|
|
||||||
DEFINES = -DDBG -DCOMPILER_LARGE_INTEGERS
|
DEFINES = -DDBG -DCOMPILER_LARGE_INTEGERS
|
||||||
|
|
||||||
ifeq ($(WIN32_LEAN_AND_MEAN),yes)
|
ifeq ($(WIN32_LEAN_AND_MEAN),yes)
|
||||||
|
@ -52,7 +56,8 @@ CC = $(PREFIX)gcc
|
||||||
NATIVE_CC = gcc
|
NATIVE_CC = gcc
|
||||||
CFLAGS = -O2 -I../../../include -I../../include \
|
CFLAGS = -O2 -I../../../include -I../../include \
|
||||||
-I../include -fno-builtin $(LEAN_AND_MEAN_DEFINE) \
|
-I../include -fno-builtin $(LEAN_AND_MEAN_DEFINE) \
|
||||||
$(DEFINES) -Wall -Wstrict-prototypes $(DEBUGGING_CFLAGS)
|
$(DEFINES) -Wall -Wstrict-prototypes $(DEBUGGING_CFLAGS) \
|
||||||
|
$(EXTRA_CFLAGS)
|
||||||
CXXFLAGS = $(CFLAGS)
|
CXXFLAGS = $(CFLAGS)
|
||||||
NFLAGS = -i../../include/ -i../include/ -pinternal/asm.inc -f$(NASM_FORMAT) -d$(NASM_FORMAT)
|
NFLAGS = -i../../include/ -i../include/ -pinternal/asm.inc -f$(NASM_FORMAT) -d$(NASM_FORMAT)
|
||||||
LD = $(PREFIX)ld
|
LD = $(PREFIX)ld
|
||||||
|
|
Loading…
Reference in a new issue