mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +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
|
||||
*/
|
||||
typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject,
|
||||
PUNICODE_STRING RegistryPath);
|
||||
typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DEVICE_OBJECT* DeviceObject,
|
||||
struct _IRP* RegistryPath);
|
||||
|
||||
|
||||
typedef struct _SECTION_OBJECT_POINTERS
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#define SET_LARGE_INTEGER_LOW_PART(LI, LP) \
|
||||
( (LI) = ((LI) & 0xFFFFFFFF00000000L) | (LP) )
|
||||
#define LARGE_INTEGER_QUAD_PART(LI) (LI)
|
||||
#define INITIALIZE_LARGE_INTEGER (0)
|
||||
|
||||
typedef long long int LONGLONG, *PLONGLONG;
|
||||
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) \
|
||||
((LargeInteger).LowPart = (Unsigned_Long))
|
||||
#define LARGE_INTEGER_QUAD_PART(LI) (*(LONGLONG *)(&(LI)))
|
||||
#define INITIALIZE_LARGE_INTEGER ({0,0})
|
||||
|
||||
typedef double LONGLONG, *PLONGLONG;
|
||||
typedef double ULONGLONG, *PULONGLONG;
|
||||
|
|
|
@ -145,7 +145,7 @@ LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
|
|||
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
|
||||
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
|
||||
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 RtlCopyUnicodeString(PUNICODE_STRING DestinationString,
|
||||
PUNICODE_STRING SourceString);
|
||||
|
|
|
@ -30,6 +30,7 @@ NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
|
|||
|
||||
VOID IoInitCancelHandling(VOID);
|
||||
VOID IoInitSymbolicLinkImplementation(VOID);
|
||||
VOID IoInitFileSystemImplementation(VOID);
|
||||
|
||||
NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject);
|
||||
POBJECT IoOpenSymlink(POBJECT SymbolicLink);
|
||||
|
@ -54,5 +55,6 @@ NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
|||
PVOID Parent,
|
||||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||
NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait);
|
||||
VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
|
||||
VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
|
||||
VOID KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr);
|
||||
|
||||
VOID KiInterruptDispatch(ULONG irq);
|
||||
VOID KiDispatchInterrupt(ULONG irq);
|
||||
|
@ -36,10 +37,10 @@ VOID KeInitExceptions(VOID);
|
|||
VOID KeInitIRQ(VOID);
|
||||
VOID KeInitTimer(VOID);
|
||||
VOID KeInitDpc(VOID);
|
||||
VOID KeInitBugCheck(VOID);
|
||||
VOID KeInitDispatcher(VOID);
|
||||
VOID KeCalibrateTimerLoop(VOID);
|
||||
VOID KeInitializeDispatcher(VOID);
|
||||
VOID KeInitializeTimerImpl(VOID);
|
||||
VOID KeInitializeBugCheck(VOID);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,5 +2,7 @@
|
|||
NTSTATUS LdrLoadDriver(PUNICODE_STRING Filename);
|
||||
NTSTATUS LdrLoadInitialProcess(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_TYPE Type);
|
||||
VOID ObRemoveEntry(POBJECT_HEADER Header);
|
||||
NTSTATUS ObPerformRetentionChecks(POBJECT_HEADER Header);
|
||||
|
||||
/*
|
||||
* FUNCTION: Creates an entry within a directory
|
||||
|
@ -106,6 +107,9 @@ NTSTATUS ObCreateHandle(PEPROCESS Process,
|
|||
VOID ObCreateHandleTable(PEPROCESS Parent,
|
||||
BOOLEAN Inherit,
|
||||
PEPROCESS Process);
|
||||
NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
PVOID* ReturnedObject,
|
||||
PWSTR* RemainingPath);
|
||||
|
||||
|
||||
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */
|
||||
|
|
|
@ -14,6 +14,8 @@ VOID PsInitProcessManagment(VOID);
|
|||
VOID PsInitIdleThread(VOID);
|
||||
VOID PsDispatchThread(VOID);
|
||||
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus);
|
||||
VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus);
|
||||
VOID PsReleaseThread(PETHREAD Thread);
|
||||
|
||||
/*
|
||||
* PURPOSE: Thread states
|
||||
|
@ -54,5 +56,6 @@ void HalInitFirstTask(PETHREAD thread);
|
|||
BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
|
||||
void HalTaskSwitch(PKTHREAD thread);
|
||||
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context);
|
||||
NTSTATUS HalReleaseTask(PETHREAD Thread);
|
||||
|
||||
#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,...);
|
||||
|
||||
#define UNIMPLEMENTED dprintf("%s in %s:%d is unimplemented\n",__FUNCTION__,__FILE__,__LINE__);
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define DPRINT(args...)
|
||||
#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
|
||||
RtlInitAnsiString
|
||||
RtlInitUnicodeString
|
||||
RtlLargeIntegerDivide
|
||||
RtlLargeIntegerAdd
|
||||
RtlLargeIntegerDivide
|
||||
RtlEnlargedIntegerMultiply
|
||||
RtlEnlargedUnsignedMultiply
|
||||
RtlExtendedIntegerMultiply
|
||||
|
@ -455,9 +455,9 @@ wcscpy
|
|||
wcschr
|
||||
wcscat
|
||||
wcscmp
|
||||
wcsicmp
|
||||
wcsnicmp
|
||||
wcsncpy
|
||||
wcslen
|
||||
wcsrchr
|
||||
wcsicmp
|
||||
wcsnicmp
|
||||
vsprintf
|
||||
|
|
|
@ -14,221 +14,20 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <pe.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
#include <wchar.h>
|
||||
#include <ntdll/ldr.h>
|
||||
#include <ntdll/rtl.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#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 *******************************************************************/
|
||||
|
||||
static DLL DllListHead;
|
||||
|
||||
#define HEAP_BASE (0xa0000000)
|
||||
|
||||
/* FORWARD DECLARATIONS ******************************************************/
|
||||
|
||||
static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle);
|
||||
DLL LdrDllListHead;
|
||||
extern unsigned int _image_base__;
|
||||
|
||||
/* 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
|
||||
* FUNCTION:
|
||||
* Handles Process Startup Activities.
|
||||
|
@ -245,12 +44,14 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
|
|||
DPRINT("LdrStartup(ImageBase %x, SectionHandle %x)\n",ImageBase,
|
||||
SectionHandle);
|
||||
|
||||
DllListHead.BaseAddress = 0x80000000;
|
||||
DllListHead.Prev = &DllListHead;
|
||||
DllListHead.Next = &DllListHead;
|
||||
PEDosHeader = (PIMAGE_DOS_HEADER)DllListHead.BaseAddress;
|
||||
DllListHead.Headers = (PIMAGE_NT_HEADERS)(DllListHead.BaseAddress +
|
||||
PEDosHeader->e_lfanew);
|
||||
DPRINT("&_image_base__ %x\n",&_image_base__);
|
||||
LdrDllListHead.BaseAddress = (PVOID)&_image_base__;
|
||||
LdrDllListHead.Prev = &LdrDllListHead;
|
||||
LdrDllListHead.Next = &LdrDllListHead;
|
||||
LdrDllListHead.SectionHandle = SectionHandle;
|
||||
PEDosHeader = (PIMAGE_DOS_HEADER)LdrDllListHead.BaseAddress;
|
||||
LdrDllListHead.Headers = (PIMAGE_NT_HEADERS)(LdrDllListHead.BaseAddress +
|
||||
PEDosHeader->e_lfanew);
|
||||
|
||||
/* If MZ header exists */
|
||||
PEDosHeader = (PIMAGE_DOS_HEADER) ImageBase;
|
||||
|
@ -263,10 +64,10 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
|
|||
}
|
||||
|
||||
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew);
|
||||
__RtlInitHeap(HEAP_BASE,
|
||||
__RtlInitHeap((PVOID)HEAP_BASE,
|
||||
NTHeaders->OptionalHeader.SizeOfHeapCommit,
|
||||
NTHeaders->OptionalHeader.SizeOfHeapReserve);
|
||||
EntryPoint = LdrPEStartup(ImageBase, SectionHandle);
|
||||
EntryPoint = LdrPEStartup((PVOID)ImageBase, SectionHandle);
|
||||
|
||||
if (EntryPoint == NULL)
|
||||
{
|
||||
|
@ -278,234 +79,3 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
|
|||
Status = EntryPoint();
|
||||
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 <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <ddk/ntddk.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/strlen.o string/strncmp.o string/strncpy.o string/strnlen.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)
|
||||
$(AR) csr ntdll.a $(OBJECTS)
|
||||
|
@ -43,4 +43,5 @@ ntdll.dll: $(DLLMAIN) $(OBJECTS)
|
|||
- $(RM) temp.exp
|
||||
$(NM) --numeric-sort ntdll.dll > ntdll.sym
|
||||
|
||||
#WARNINGS_ARE_ERRORS = yes
|
||||
include ../../rules.mak
|
||||
|
|
|
@ -10,6 +10,9 @@
|
|||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <windows.h>
|
||||
#include <ntdll/rtl.h>
|
||||
|
||||
#include <ntdll/ntdll.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
@ -37,5 +40,7 @@ VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
|||
|
||||
WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
for(;;);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <string.h>
|
||||
#include <ddk/ntddk.h>
|
||||
#include <ntdll/rtl.h>
|
||||
|
||||
#define NDEBUG
|
||||
#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 *
|
||||
*********************************************************************/
|
||||
|
||||
VOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize)
|
||||
VOID WINAPI __RtlInitHeap(PVOID base, ULONG minsize, ULONG maxsize)
|
||||
{
|
||||
NTSTATUS Result;
|
||||
PHEAP NewHeap;
|
||||
|
@ -952,7 +953,7 @@ UINT RtlCompactHeap(HANDLE hheap, DWORD flags)
|
|||
/*********************************************************************
|
||||
* 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_BLOCK palloc=((PHEAP_BLOCK)pmem-1);
|
||||
|
@ -992,7 +993,7 @@ DWORD WINAPI RtlSizeHeap(HANDLE hheap, DWORD flags, LPCVOID pmem)
|
|||
* *
|
||||
* 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_BLOCK pcheck;
|
||||
|
|
|
@ -48,7 +48,7 @@ VOID RtlCopyBytes(PVOID Destination,
|
|||
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",
|
||||
Destination,Source,Length);
|
||||
|
|
|
@ -9,20 +9,18 @@
|
|||
*/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
#define Aa_Difference ('A'-'a')
|
||||
|
||||
PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest,
|
||||
PUNICODE_STRING Src)
|
||||
{
|
||||
if (Dest==NULL)
|
||||
{
|
||||
// Dest=ExAllocatePool(NonPagedPool,sizeof(UNICODE_STRING));
|
||||
}
|
||||
}
|
||||
extern unsigned long simple_strtoul(const char *cp,
|
||||
char **endp,
|
||||
unsigned int base);
|
||||
|
||||
WCHAR wtoupper(WCHAR c)
|
||||
{
|
||||
|
@ -120,8 +118,9 @@ NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -339,26 +338,27 @@ VOID RtlInitString(IN OUT PSTRING DestinationString,
|
|||
DestinationString->Length=strlen((char *)SourceString);
|
||||
DestinationString->MaximumLength=strlen((char *)SourceString)+1;
|
||||
DestinationString->Buffer=SourceString;
|
||||
};
|
||||
}
|
||||
|
||||
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||
IN PCWSTR SourceString)
|
||||
{
|
||||
unsigned long i, DestSize;
|
||||
UNICODE_STRING Dest=*DestinationString;
|
||||
|
||||
if(SourceString==NULL) {
|
||||
DestinationString->Length=0;
|
||||
DestinationString->MaximumLength=0;
|
||||
DestinationString->Buffer=NULL;
|
||||
} else {
|
||||
DestSize=wcslen((PWSTR)SourceString);
|
||||
DestinationString->Length=DestSize;
|
||||
DestinationString->MaximumLength=DestSize+1;
|
||||
|
||||
DestinationString->Buffer=(PWSTR)SourceString;
|
||||
};
|
||||
};
|
||||
unsigned long DestSize;
|
||||
|
||||
if (SourceString == NULL)
|
||||
{
|
||||
DestinationString->Length = 0;
|
||||
DestinationString->MaximumLength = 0;
|
||||
DestinationString->Buffer = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
DestSize = wcslen((PWSTR)SourceString);
|
||||
DestinationString->Length = DestSize;
|
||||
DestinationString->MaximumLength = DestSize+1;
|
||||
DestinationString->Buffer = (PWSTR)SourceString;
|
||||
}
|
||||
}
|
||||
|
||||
NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */
|
||||
IN OUT PUNICODE_STRING String)
|
||||
|
@ -366,17 +366,17 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
|||
char *str;
|
||||
unsigned long len, i;
|
||||
|
||||
// str=ExAllocatePool(NonPagedPool, 1024);
|
||||
str = RtlAllocateHeap(RtlGetProcessHeap, 0, 1024);
|
||||
if(Base==16) {
|
||||
sprintf(str, "%x", Value);
|
||||
sprintf(str, "%x", (unsigned int)Value);
|
||||
} else
|
||||
if(Base==8) {
|
||||
sprintf(str, "%o", Value);
|
||||
sprintf(str, "%o", (unsigned int)Value);
|
||||
} else
|
||||
if(Base==2) {
|
||||
sprintf(str, "%b", Value);
|
||||
// sprintf(str, "%b", Value);
|
||||
} else {
|
||||
sprintf(str, "%u", Value);
|
||||
sprintf(str, "%u", (unsigned int)Value);
|
||||
};
|
||||
|
||||
len=strlen(str);
|
||||
|
@ -394,7 +394,7 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
|||
// ExFreePool(str);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
};
|
||||
}
|
||||
|
||||
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
||||
IN PUNICODE_STRING SourceString,
|
||||
|
@ -427,59 +427,61 @@ NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
|||
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
|
||||
OUT PULONG Value)
|
||||
{
|
||||
char *str;
|
||||
unsigned long i, lenmin=0;
|
||||
BOOLEAN addneg=FALSE;
|
||||
|
||||
// str=ExAllocatePool(NonPagedPool, String->Length+1);
|
||||
|
||||
for(i=0; i<String->Length; i++) {
|
||||
*str=*String->Buffer;
|
||||
|
||||
if(*str=='b') { Base=2; lenmin++; } else
|
||||
if(*str=='o') { Base=8; lenmin++; } else
|
||||
if(*str=='d') { Base=10; lenmin++; } else
|
||||
if(*str=='x') { Base=16; lenmin++; } else
|
||||
if(*str=='+') { lenmin++; } else
|
||||
if(*str=='-') { addneg=TRUE; lenmin++; } else
|
||||
if((*str>'1') && (Base==2)) {
|
||||
String->Buffer-=i;
|
||||
*Value=0;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
} else
|
||||
if(((*str>'7') || (*str<'0')) && (Base==8)) {
|
||||
String->Buffer-=i;
|
||||
*Value=0;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
} else
|
||||
if(((*str>'9') || (*str<'0')) && (Base==10)) {
|
||||
String->Buffer-=i;
|
||||
*Value=0;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
} else
|
||||
if((((*str>'9') || (*str<'0')) ||
|
||||
((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16))
|
||||
{
|
||||
String->Buffer-=i;
|
||||
*Value=0;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
} else
|
||||
str++;
|
||||
|
||||
String->Buffer++;
|
||||
char *str;
|
||||
unsigned long i, lenmin=0;
|
||||
BOOLEAN addneg=FALSE;
|
||||
|
||||
str=RtlAllocateHeap(RtlGetProcessHeap(), 0, String->Length+1);
|
||||
|
||||
for(i=0; i<String->Length; i++)
|
||||
{
|
||||
*str=*String->Buffer;
|
||||
|
||||
if(*str=='b') { Base=2; lenmin++; } else
|
||||
if(*str=='o') { Base=8; lenmin++; } else
|
||||
if(*str=='d') { Base=10; lenmin++; } else
|
||||
if(*str=='x') { Base=16; lenmin++; } else
|
||||
if(*str=='+') { lenmin++; } else
|
||||
if(*str=='-') { addneg=TRUE; lenmin++; } else
|
||||
if((*str>'1') && (Base==2)) {
|
||||
String->Buffer-=i;
|
||||
*Value=0;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
} else
|
||||
if(((*str>'7') || (*str<'0')) && (Base==8)) {
|
||||
String->Buffer-=i;
|
||||
*Value=0;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
} else
|
||||
if(((*str>'9') || (*str<'0')) && (Base==10)) {
|
||||
String->Buffer-=i;
|
||||
*Value=0;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
} else
|
||||
if((((*str>'9') || (*str<'0')) ||
|
||||
((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16))
|
||||
{
|
||||
String->Buffer-=i;
|
||||
*Value=0;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
} else
|
||||
str++;
|
||||
|
||||
String->Buffer++;
|
||||
};
|
||||
|
||||
*str=0;
|
||||
String->Buffer-=String->Length;
|
||||
str-=(String->Length-lenmin);
|
||||
|
||||
if(addneg==TRUE) {
|
||||
*Value=simple_strtoul(str, NULL, Base)*-1;
|
||||
|
||||
*str=0;
|
||||
String->Buffer-=String->Length;
|
||||
str-=(String->Length-lenmin);
|
||||
|
||||
if(addneg==TRUE) {
|
||||
*Value=simple_strtoul(str, NULL, Base)*-1;
|
||||
} else
|
||||
*Value=simple_strtoul(str, NULL, Base);
|
||||
|
||||
// ExFreePool(str);
|
||||
};
|
||||
*Value=simple_strtoul(str, NULL, Base);
|
||||
|
||||
// ExFreePool(str);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||
IN PUNICODE_STRING SourceString,
|
||||
|
|
|
@ -16,9 +16,12 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.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 result = 0,value;
|
||||
|
@ -70,70 +73,86 @@ __res = ((unsigned long) n) % (unsigned) base; \
|
|||
n = ((unsigned long) n) / (unsigned) base; \
|
||||
__res; })
|
||||
|
||||
static char * number(char * str, long num, int base, int size, int precision
|
||||
,int type)
|
||||
static char * number(char * str, long num, int base, int size, int precision,
|
||||
int type)
|
||||
{
|
||||
char c,sign,tmp[66];
|
||||
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
int i;
|
||||
|
||||
if (type & LARGE)
|
||||
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
if (type & SIGN) {
|
||||
if (num < 0) {
|
||||
sign = '-';
|
||||
num = -num;
|
||||
size--;
|
||||
} else if (type & PLUS) {
|
||||
sign = '+';
|
||||
size--;
|
||||
} else if (type & SPACE) {
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
if (type & SPECIAL) {
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
else if (base == 8)
|
||||
size--;
|
||||
}
|
||||
i = 0;
|
||||
if (num == 0)
|
||||
tmp[i++]='0';
|
||||
else while (num != 0)
|
||||
tmp[i++] = digits[do_div(num,base)];
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT)))
|
||||
while(size-->0)
|
||||
*str++ = ' ';
|
||||
if (sign)
|
||||
*str++ = sign;
|
||||
if (type & SPECIAL)
|
||||
if (base==8)
|
||||
*str++ = '0';
|
||||
else if (base==16) {
|
||||
*str++ = '0';
|
||||
*str++ = digits[33];
|
||||
}
|
||||
if (!(type & LEFT))
|
||||
while (size-- > 0)
|
||||
*str++ = c;
|
||||
while (i < precision--)
|
||||
*str++ = '0';
|
||||
while (i-- > 0)
|
||||
*str++ = tmp[i];
|
||||
while (size-- > 0)
|
||||
*str++ = ' ';
|
||||
return str;
|
||||
char c,sign,tmp[66];
|
||||
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
int i;
|
||||
|
||||
if (type & LARGE)
|
||||
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
if (type & LEFT)
|
||||
type &= ~ZEROPAD;
|
||||
if (base < 2 || base > 36)
|
||||
return 0;
|
||||
|
||||
c = (type & ZEROPAD) ? '0' : ' ';
|
||||
sign = 0;
|
||||
|
||||
if (type & SIGN)
|
||||
{
|
||||
if (num < 0)
|
||||
{
|
||||
sign = '-';
|
||||
num = -num;
|
||||
size--;
|
||||
}
|
||||
else if (type & PLUS)
|
||||
{
|
||||
sign = '+';
|
||||
size--;
|
||||
}
|
||||
else if (type & SPACE)
|
||||
{
|
||||
sign = ' ';
|
||||
size--;
|
||||
}
|
||||
}
|
||||
|
||||
if (type & SPECIAL)
|
||||
{
|
||||
if (base == 16)
|
||||
size -= 2;
|
||||
else if (base == 8)
|
||||
size--;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
if (num == 0)
|
||||
tmp[i++]='0';
|
||||
else while (num != 0)
|
||||
tmp[i++] = digits[do_div(num,base)];
|
||||
if (i > precision)
|
||||
precision = i;
|
||||
size -= precision;
|
||||
if (!(type&(ZEROPAD+LEFT)))
|
||||
while(size-->0)
|
||||
*str++ = ' ';
|
||||
if (sign)
|
||||
*str++ = sign;
|
||||
if (type & SPECIAL)
|
||||
{
|
||||
if (base==8)
|
||||
{
|
||||
*str++ = '0';
|
||||
}
|
||||
else if (base==16)
|
||||
{
|
||||
*str++ = '0';
|
||||
*str++ = digits[33];
|
||||
}
|
||||
}
|
||||
if (!(type & LEFT))
|
||||
while (size-- > 0)
|
||||
*str++ = c;
|
||||
while (i < precision--)
|
||||
*str++ = '0';
|
||||
while (i-- > 0)
|
||||
*str++ = tmp[i];
|
||||
while (size-- > 0)
|
||||
*str++ = ' ';
|
||||
return str;
|
||||
}
|
||||
|
||||
int vsprintf(char *buf, const char *fmt, va_list args)
|
||||
|
@ -351,17 +370,18 @@ int wsprintfA(char * buf, const char *fmt, ...)
|
|||
return i;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
//i=vsprintf(buf,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, fmt);
|
||||
//i=vsprintf(buf,fmt,args);
|
||||
va_end(args);
|
||||
return i;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
unsigned short towupper(unsigned short w)
|
||||
{
|
||||
|
|
|
@ -14,15 +14,17 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
|
||||
static wchar_t * ___wcstok = NULL;
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
// static wchar_t * ___wcstok = NULL;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
wchar_t *
|
||||
wcschr(const wchar_t *str, wchar_t ch)
|
||||
wchar_t* wcschr(const wchar_t *str, wchar_t ch)
|
||||
{
|
||||
while ((*str) != ((wchar_t) 0))
|
||||
{
|
||||
if ((*str) == ch)
|
||||
{
|
||||
return str;
|
||||
return (wchar_t *)str;
|
||||
}
|
||||
str++;
|
||||
}
|
||||
|
@ -56,8 +57,7 @@ wcschr(const wchar_t *str, wchar_t ch)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int
|
||||
wcscmp(const wchar_t *cs, const wchar_t *ct)
|
||||
int wcscmp(const wchar_t *cs, const wchar_t *ct)
|
||||
{
|
||||
while (*cs != '\0' && *ct != '\0' && *cs == *ct)
|
||||
{
|
||||
|
|
|
@ -62,7 +62,6 @@ STUB(PfxInitialize)
|
|||
STUB(PfxInsertPrefix)
|
||||
STUB(PfxRemovePrefix)
|
||||
STUB(RestoreEm87Context)
|
||||
STUB(RtlValidateHeap)
|
||||
STUB(RtlValidateProcessHeaps)
|
||||
STUB(RtlWalkHeap)
|
||||
STUB(RtlZeroHeap)
|
||||
|
|
|
@ -14,7 +14,7 @@ include rules.mak
|
|||
#
|
||||
# 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
|
||||
|
|
|
@ -25,6 +25,7 @@ static ULONG CbHash(PDCCB Dccb, ULONG BlockNr)
|
|||
return(BlockNr % Dccb->HashTblSize);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
@ -33,6 +34,7 @@ static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb)
|
|||
Ccb->References--;
|
||||
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
||||
}
|
||||
#endif
|
||||
|
||||
static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr)
|
||||
{
|
||||
|
@ -49,6 +51,7 @@ static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr)
|
|||
return(Ccb);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
@ -67,7 +70,7 @@ static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb)
|
|||
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static BOOLEAN CbLockForWrite(PCCB Ccb)
|
||||
{
|
||||
|
@ -126,11 +129,13 @@ static BOOLEAN CbLockForDelete(PDCCB Dccb, PCCB Ccb)
|
|||
return(TRUE);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VOID CbUnlockForDelete(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
Ccb->ActiveWriter = FALSE;
|
||||
KeSetEvent(&Ccb->FinishedNotify,IO_NO_INCREMENT,FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID CbAcquireForDelete(PDCCB Dccb, PCCB Ccb)
|
||||
/*
|
||||
|
@ -234,6 +239,7 @@ PCCB CbFindModifiedCcb(PDCCB Dccb, PCCB Start)
|
|||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VOID CbDeleteAllCcbs(PDCCB Dccb)
|
||||
/*
|
||||
* FUNCTION: Delete all the ccbs associated with a dccb
|
||||
|
@ -261,7 +267,9 @@ static VOID CbDeleteAllCcbs(PDCCB Dccb)
|
|||
ExFreePool(Ccb);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
@ -279,7 +287,9 @@ static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb)
|
|||
KeReleaseSpinLock(&Dccb->CcbListLock,oldlvl);
|
||||
ExFreePool(Ccb);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static VOID CbReclaimMemory(PDCCB Dccb)
|
||||
{
|
||||
PCCB RedundantCcbs[25];
|
||||
|
@ -323,7 +333,9 @@ static VOID CbReclaimMemory(PDCCB Dccb)
|
|||
CbFreeCcb(Dccb,RedundantCcbs[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb)
|
||||
/*
|
||||
* FUNCTION: Deletes a CCB
|
||||
|
@ -338,6 +350,7 @@ static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb)
|
|||
CbAcquireForDelete(Dccb,Ccb);
|
||||
Ccb->State = CCB_DELETE_PENDING;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID CbReinitCcb(PDCCB Dccb, PCCB Ccb, ULONG BlockNr)
|
||||
{
|
||||
|
|
|
@ -273,6 +273,7 @@ ZwCreateKey(PHANDLE KeyHandle,
|
|||
|
||||
NTSTATUS NtDeleteKey(HANDLE KeyHandle)
|
||||
{
|
||||
return(ZwDeleteKey(KeyHandle));
|
||||
}
|
||||
|
||||
NTSTATUS ZwDeleteKey(HANDLE KeyHandle)
|
||||
|
@ -280,15 +281,23 @@ NTSTATUS ZwDeleteKey(HANDLE KeyHandle)
|
|||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS NtEnumerateKey(HANDLE KeyHandle, ULONG Index,
|
||||
NTSTATUS NtEnumerateKey(HANDLE KeyHandle,
|
||||
ULONG Index,
|
||||
KEY_INFORMATION_CLASS KeyInformationClass,
|
||||
PVOID KeyInformation,
|
||||
ULONG Length,
|
||||
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,
|
||||
PVOID KeyInformation,
|
||||
ULONG Length,
|
||||
|
|
|
@ -61,7 +61,7 @@ VOID ExReleaseFastMutex(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)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
|
||||
|
@ -81,10 +82,17 @@ NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
|
|||
Resource->NumberOfExclusiveWaiters = 0;
|
||||
KeInitializeSpinLock(&Resource->SpinLock);
|
||||
Resource->Flag=0;
|
||||
KeInitializeEvent(&Resource->ExclusiveWaiters,SynchronizationEvent,
|
||||
Resource->ExclusiveWaiters = ExAllocatePool(NonPagedPool,
|
||||
sizeof(KEVENT));
|
||||
KeInitializeEvent(Resource->ExclusiveWaiters,
|
||||
SynchronizationEvent,
|
||||
FALSE);
|
||||
KeInitializeSemaphore(&Resource->SharedWaiters,5,0);
|
||||
Resource->SharedWaiters = ExAllocatePool(NonPagedPool,
|
||||
sizeof(KSEMAPHORE));
|
||||
KeInitializeSemaphore(Resource->SharedWaiters,5,0);
|
||||
Resource->ActiveCount = 0;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource)
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef struct
|
|||
/*
|
||||
* 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)
|
||||
|
||||
|
|
|
@ -27,8 +27,8 @@ ExAllocateFromNPagedLookasideList
|
|||
ExAllocateFromPagedLookasideList
|
||||
ExAllocateFromZone
|
||||
ExAllocatePool
|
||||
ExAllocatePoolWithQuota
|
||||
ExAllocatePoolWithQuotaTag
|
||||
#ExAllocatePoolWithQuota
|
||||
#ExAllocatePoolWithQuotaTag
|
||||
ExAllocatePoolWithTag
|
||||
ExConvertExclusiveToSharedLite
|
||||
ExDeleteNPagedLookasideList
|
||||
|
@ -88,11 +88,11 @@ InterlockedCompareExchange
|
|||
InterlockedExchange
|
||||
InterlockedExchangeAdd
|
||||
InterlockedIncrement
|
||||
HalAllocateCommonBuffer
|
||||
#HalAllocateCommonBuffer
|
||||
HalAssignSlotResources
|
||||
HalExamineMBR
|
||||
HalFreeCommonBuffer
|
||||
HalGetAdapter
|
||||
#HalFreeCommonBuffer
|
||||
#HalGetAdapter
|
||||
HalGetBusData
|
||||
HalGetBusDataByOffset
|
||||
HalGetDmaAlignmentRequirement
|
||||
|
@ -319,7 +319,7 @@ RtlFreeUnicodeString
|
|||
RtlInitAnsiString
|
||||
RtlInitString
|
||||
RtlInitUnicodeString
|
||||
RtlIntegerToUnicodeString
|
||||
#RtlIntegerToUnicodeString
|
||||
RtlLargeIntegerAdd
|
||||
RtlLargeIntegerAnd
|
||||
RtlLargeIntegerArithmeticShift
|
||||
|
|
|
@ -50,6 +50,7 @@ ULONG HalGetDmaAlignmentRequirement()
|
|||
return(1);
|
||||
}
|
||||
|
||||
#if 0
|
||||
PVOID HalAllocateCommonBuffer(PADAPTER_OBJECT AdapterObject,
|
||||
ULONG Length,
|
||||
PPHYSICAL_ADDRESS LogicalAddress,
|
||||
|
@ -115,6 +116,7 @@ PADAPTER_OBJECT HalGetAdapter(PDEVICE_DESCRIPTION DeviceDescription,
|
|||
RtlCopyMemory(&adapter->desc,DeviceDescription,sizeof(DEVICE_DESCRIPTION));
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
|
||||
ULONG HalReadDmaCounter(PADAPTER_OBJECT AdapterObject)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@ static KIRQL CurrentIrql = HIGH_LEVEL;
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
#if 0
|
||||
static unsigned int HiGetCurrentPICMask(void)
|
||||
{
|
||||
unsigned int mask;
|
||||
|
@ -34,6 +35,7 @@ static unsigned int HiGetCurrentPICMask(void)
|
|||
|
||||
return mask;
|
||||
}
|
||||
#endif
|
||||
|
||||
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
|
||||
*/
|
||||
{
|
||||
PHYSICAL_ADDRESS p;
|
||||
PHYSICAL_ADDRESS p = INITIALIZE_LARGE_INTEGER;
|
||||
|
||||
DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <internal/ke.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/linkage.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
#include <internal/i386/segment.h>
|
||||
|
|
|
@ -41,12 +41,12 @@ BOOLEAN IoCancelIrp(PIRP Irp)
|
|||
|
||||
IoAcquireCancelSpinLock(&oldlvl);
|
||||
Irp->Cancel = TRUE;
|
||||
if (Irp->CancelRoutine==NULL)
|
||||
if (Irp->CancelRoutine == NULL)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
Irp->CancelRoutine(Irp->Stack[0].DeviceObject,Irp);
|
||||
IoReleaseCancelSpinLock(&oldlvl);
|
||||
Irp->CancelRoutine(Irp->Stack[0].DeviceObject, Irp);
|
||||
IoReleaseCancelSpinLock(oldlvl);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -177,7 +177,6 @@ NTSTATUS IopCreateDevice(PVOID ObjectBody,
|
|||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)ObjectBody;
|
||||
|
||||
DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
||||
ObjectBody, Parent, RemainingPath);
|
||||
|
|
|
@ -27,12 +27,14 @@ VOID MmUnlockPagableImageSection(PVOID ImageSectionHandle)
|
|||
* MmLockPagableDataSection
|
||||
*/
|
||||
{
|
||||
MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
|
||||
// MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
VOID MmLockPagableSectionByHandle(PVOID ImageSectionHandle)
|
||||
{
|
||||
MmLockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
|
||||
// MmLockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
PVOID MmLockPagableCodeSection(PVOID AddressWithinSection)
|
||||
|
|
|
@ -17,116 +17,100 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCreateIoCompletion(
|
||||
OUT PHANDLE CompletionPort,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG NumberOfConcurrentThreads
|
||||
)
|
||||
NTSTATUS STDCALL NtCreateIoCompletion(OUT PHANDLE CompletionPort,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG NumberOfConcurrentThreads)
|
||||
{
|
||||
return(ZwCreateIoCompletion(CompletionPort,
|
||||
DesiredAccess,
|
||||
IoStatusBlock,
|
||||
NumberOfConcurrentThreads));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwCreateIoCompletion(
|
||||
OUT PHANDLE CompletionPort,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG NumberOfConcurrentThreads
|
||||
)
|
||||
NTSTATUS STDCALL ZwCreateIoCompletion(OUT PHANDLE CompletionPort,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG NumberOfConcurrentThreads)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtOpenIoCompletion(
|
||||
OUT PHANDLE CompetionPort,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes
|
||||
)
|
||||
NTSTATUS STDCALL NtOpenIoCompletion(OUT PHANDLE CompletionPort,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
return(ZwOpenIoCompletion(CompletionPort,
|
||||
DesiredAccess,
|
||||
ObjectAttributes));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwOpenIoCompletion(
|
||||
OUT PHANDLE CompetionPort,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes
|
||||
)
|
||||
NTSTATUS STDCALL ZwOpenIoCompletion(OUT PHANDLE CompetionPort,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtQueryIoCompletion(
|
||||
IN HANDLE CompletionPort,
|
||||
IN ULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PULONG NumberOfBytesTransferred
|
||||
)
|
||||
NTSTATUS STDCALL NtQueryIoCompletion(IN HANDLE CompletionPort,
|
||||
IN ULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PULONG NumberOfBytesTransferred)
|
||||
{
|
||||
|
||||
return ZwQueryIoCompletion(CompletionPort,CompletionKey,IoStatusBlock,NumberOfBytesTransferred);
|
||||
|
||||
return(ZwQueryIoCompletion(CompletionPort,
|
||||
CompletionKey,
|
||||
IoStatusBlock,
|
||||
NumberOfBytesTransferred));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwQueryIoCompletion(
|
||||
IN HANDLE CompletionPort,
|
||||
IN ULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PULONG NumberOfBytesTransferred
|
||||
)
|
||||
NTSTATUS STDCALL ZwQueryIoCompletion(IN HANDLE CompletionPort,
|
||||
IN ULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PULONG NumberOfBytesTransferred)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtRemoveIoCompletion(
|
||||
IN HANDLE CompletionPort,
|
||||
OUT PULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PULONG CompletionStatus,
|
||||
PLARGE_INTEGER WaitTime
|
||||
)
|
||||
|
||||
NTSTATUS STDCALL NtRemoveIoCompletion(IN HANDLE CompletionPort,
|
||||
OUT PULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PULONG CompletionStatus,
|
||||
PLARGE_INTEGER WaitTime)
|
||||
{
|
||||
return(ZwRemoveIoCompletion(CompletionPort,
|
||||
CompletionKey,
|
||||
IoStatusBlock,
|
||||
CompletionStatus,
|
||||
WaitTime));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwRemoveIoCompletion(
|
||||
IN HANDLE CompletionPort,
|
||||
OUT PULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PULONG CompletionStatus,
|
||||
PLARGE_INTEGER WaitTime
|
||||
)
|
||||
NTSTATUS STDCALL ZwRemoveIoCompletion(IN HANDLE CompletionPort,
|
||||
OUT PULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
OUT PULONG CompletionStatus,
|
||||
PLARGE_INTEGER WaitTime)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtSetIoCompletion(
|
||||
IN HANDLE CompletionPort,
|
||||
IN ULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG NumberOfBytesToTransfer,
|
||||
OUT PULONG NumberOfBytesTransferred
|
||||
)
|
||||
NTSTATUS STDCALL NtSetIoCompletion(IN HANDLE CompletionPort,
|
||||
IN ULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG NumberOfBytesToTransfer,
|
||||
OUT PULONG NumberOfBytesTransferred)
|
||||
{
|
||||
return(ZwSetIoCompletion(CompletionPort,
|
||||
CompletionKey,
|
||||
IoStatusBlock,
|
||||
NumberOfBytesToTransfer,
|
||||
NumberOfBytesTransferred));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwSetIoCompletion(
|
||||
IN HANDLE CompletionPort,
|
||||
IN ULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG NumberOfBytesToTransfer,
|
||||
OUT PULONG NumberOfBytesTransferred
|
||||
)
|
||||
NTSTATUS STDCALL ZwSetIoCompletion(IN HANDLE CompletionPort,
|
||||
IN ULONG CompletionKey,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG NumberOfBytesToTransfer,
|
||||
OUT PULONG NumberOfBytesTransferred)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ VOID IoMarkIrpPending(PIRP Irp)
|
|||
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
|
||||
IoGetCurrentIrpStackLocation(Irp));
|
||||
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
|
||||
Irp->Tail.Overlay.Thread = KeGetCurrentThread();
|
||||
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
||||
DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n",
|
||||
IoGetCurrentIrpStackLocation(Irp)->Control);
|
||||
DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED);
|
||||
|
@ -132,7 +132,7 @@ PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
|
|||
Irp->CurrentLocation,
|
||||
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)
|
||||
{
|
||||
Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize));
|
||||
// Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize));
|
||||
Irp = ExAllocatePool(NonPagedPool,IoSizeOfIrp(StackSize));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -17,32 +17,33 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCreateMailslotFile(
|
||||
OUT PHANDLE MailSlotFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG MaxMessageSize,
|
||||
IN PLARGE_INTEGER TimeOut
|
||||
)
|
||||
NTSTATUS STDCALL NtCreateMailslotFile(OUT PHANDLE MailSlotFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG MaxMessageSize,
|
||||
IN PLARGE_INTEGER TimeOut)
|
||||
{
|
||||
return(ZwCreateMailslotFile(MailSlotFileHandle,
|
||||
DesiredAccess,
|
||||
ObjectAttributes,
|
||||
IoStatusBlock,
|
||||
FileAttributes,
|
||||
ShareAccess,
|
||||
MaxMessageSize,
|
||||
TimeOut));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwCreateMailslotFile(
|
||||
OUT PHANDLE MailSlotFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG MaxMessageSize,
|
||||
IN PLARGE_INTEGER TimeOut
|
||||
)
|
||||
NTSTATUS STDCALL ZwCreateMailslotFile(OUT PHANDLE MailSlotFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG MaxMessageSize,
|
||||
IN PLARGE_INTEGER TimeOut)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,9 @@ PMDL IoAllocateMdl(PVOID VirtualAddress,
|
|||
|
||||
if (ChargeQuota)
|
||||
{
|
||||
Mdl = ExAllocatePoolWithQuota(NonPagedPool,
|
||||
MmSizeOfMdl(VirtualAddress,Length));
|
||||
// Mdl = ExAllocatePoolWithQuota(NonPagedPool,
|
||||
// MmSizeOfMdl(VirtualAddress,Length));
|
||||
Mdl = ExAllocatePool(NonPagedPool,MmSizeOfMdl(VirtualAddress,Length));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -16,44 +16,51 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCreateNamedPipeFile(
|
||||
OUT PHANDLE NamedPipeFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG OpenMode,
|
||||
IN ULONG PipeType,
|
||||
IN ULONG PipeRead,
|
||||
IN ULONG PipeWait,
|
||||
IN ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER TimeOut
|
||||
)
|
||||
NTSTATUS STDCALL NtCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG OpenMode,
|
||||
IN ULONG PipeType,
|
||||
IN ULONG PipeRead,
|
||||
IN ULONG PipeWait,
|
||||
IN ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER TimeOut)
|
||||
{
|
||||
return(ZwCreateNamedPipeFile(NamedPipeFileHandle,
|
||||
DesiredAccess,
|
||||
ObjectAttributes,
|
||||
IoStatusBlock,
|
||||
FileAttributes,
|
||||
ShareAccess,
|
||||
OpenMode,
|
||||
PipeType,
|
||||
PipeRead,
|
||||
PipeWait,
|
||||
MaxInstances,
|
||||
InBufferSize,
|
||||
OutBufferSize,
|
||||
TimeOut));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwCreateNamedPipeFile(
|
||||
OUT PHANDLE NamedPipeFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG OpenMode,
|
||||
IN ULONG PipeType,
|
||||
IN ULONG PipeRead,
|
||||
IN ULONG PipeWait,
|
||||
IN ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER TimeOut
|
||||
)
|
||||
NTSTATUS STDCALL ZwCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG OpenMode,
|
||||
IN ULONG PipeType,
|
||||
IN ULONG PipeRead,
|
||||
IN ULONG PipeWait,
|
||||
IN ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER TimeOut)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ VOID IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject,
|
|||
{
|
||||
PKDEVICE_QUEUE_ENTRY entry;
|
||||
PIRP Irp;
|
||||
KIRQL oldirql;
|
||||
|
||||
entry = KeRemoveByKeyDeviceQueue(&DeviceObject->DeviceQueue,Key);
|
||||
|
||||
|
@ -58,7 +57,6 @@ VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable)
|
|||
{
|
||||
PKDEVICE_QUEUE_ENTRY entry;
|
||||
PIRP Irp;
|
||||
KIRQL oldirql;
|
||||
|
||||
DPRINT("IoStartNextPacket(DeviceObject %x, Cancelable %d)\n",
|
||||
DeviceObject,Cancelable);
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ob.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
|
|
@ -40,6 +40,8 @@ NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject)
|
|||
RtlZeroMemory(Vpb->VolumeLabel,sizeof(WCHAR)*MAXIMUM_VOLUME_LABEL_LENGTH);
|
||||
|
||||
DeviceObject->Vpb = Vpb;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ke/bug.c
|
||||
* PURPOSE: Graceful system shutdown if a bug is detected
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
@ -11,6 +11,7 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ke.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
@ -46,6 +47,7 @@ BOOLEAN KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
|
|||
CallbackRecord->Buffer=Buffer;
|
||||
CallbackRecord->Component=Component;
|
||||
CallbackRecord->CallbackRoutine=CallbackRoutine;
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
VOID KeBugCheckEx(ULONG BugCheckCode,
|
||||
|
|
|
@ -12,16 +12,16 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
NTSTATUS STDCALL NtRaiseHardError(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtSetDefaultHardErrorPort(
|
||||
IN HANDLE PortHandle
|
||||
)
|
||||
NTSTATUS STDCALL NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ asmlinkage void _main(boot_param* _bp)
|
|||
for (i=1;i<bp.nr_files;i++)
|
||||
{
|
||||
DPRINT("process module at %08lx\n", start);
|
||||
LdrProcessDriver(start);
|
||||
LdrProcessDriver((PVOID)start);
|
||||
start=start+PAGE_ROUND_UP(bp.module_length[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -494,9 +495,6 @@ void KeExpireTimers(void)
|
|||
DPRINT("Finished KeExpireTimers()\n");
|
||||
}
|
||||
|
||||
extern unsigned int nr_used_blocks;
|
||||
extern unsigned int EiFreeNonPagedPool;
|
||||
extern unsigned int EiUsedNonPagedPool;
|
||||
|
||||
BOOLEAN KiTimerInterrupt(VOID)
|
||||
/*
|
||||
|
@ -507,8 +505,9 @@ BOOLEAN KiTimerInterrupt(VOID)
|
|||
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36);
|
||||
int i;
|
||||
int x,y;
|
||||
extern ULONG PiNrThreads;
|
||||
extern ULONG EiNrUsedBlocks;
|
||||
extern unsigned int EiFreeNonPagedPool;
|
||||
extern unsigned int EiUsedNonPagedPool;
|
||||
|
||||
/*
|
||||
* Increment the number of timers ticks
|
||||
|
@ -534,7 +533,8 @@ BOOLEAN KiTimerInterrupt(VOID)
|
|||
}
|
||||
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,ticks);
|
||||
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",PiNrThreads,KiTimerTicks);
|
||||
for (i=0;i<17;i++)
|
||||
|
|
|
@ -306,6 +306,7 @@ LdrPEProcessDriver(PVOID ModuleLoadBase)
|
|||
/* Copy image sections into virtual section */
|
||||
memcpy(DriverBase, ModuleLoadBase, PESectionHeaders[0].PointerToRawData);
|
||||
CurrentBase = (PVOID) ((DWORD)DriverBase + PESectionHeaders[0].PointerToRawData);
|
||||
CurrentSize = 0;
|
||||
for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
|
||||
{
|
||||
/* Copy current section into current offset of virtual section */
|
||||
|
@ -911,7 +912,6 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
|
|||
OBJECT_ATTRIBUTES FileObjectAttributes;
|
||||
HANDLE FileHandle, SectionHandle, ThreadHandle;
|
||||
CONTEXT Context;
|
||||
ANSI_STRING AnsiString;
|
||||
UNICODE_STRING DllPathname;
|
||||
PIMAGE_DOS_HEADER DosHeader;
|
||||
PIMAGE_NT_HEADERS NTHeaders;
|
||||
|
@ -1020,7 +1020,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
|
|||
0,
|
||||
Sections[i].Misc.VirtualSize,
|
||||
&Offset,
|
||||
&Sections[i].Misc.VirtualSize,
|
||||
(PULONG)&Sections[i].Misc.VirtualSize,
|
||||
0,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
|
@ -1152,12 +1152,12 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
|
|||
DUPLICATE_SAME_ACCESS);
|
||||
|
||||
ZwWriteVirtualMemory(ProcessHandle,
|
||||
STACK_TOP - 4,
|
||||
(PVOID)(STACK_TOP - 4),
|
||||
&ImageBase,
|
||||
sizeof(ImageBase),
|
||||
&BytesWritten);
|
||||
ZwWriteVirtualMemory(ProcessHandle,
|
||||
STACK_TOP - 8,
|
||||
(PVOID)(STACK_TOP - 8),
|
||||
&DupSectionHandle,
|
||||
sizeof(DupSectionHandle),
|
||||
&BytesWritten);
|
||||
|
@ -1200,10 +1200,13 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
|
|||
}
|
||||
|
||||
NTSTATUS LdrLoadInitialProcess(VOID)
|
||||
/*
|
||||
* FIXME: The location of the initial process should be configurable,
|
||||
* from command line or registry
|
||||
*/
|
||||
{
|
||||
NTSTATUS Status;
|
||||
HANDLE ProcessHandle;
|
||||
ANSI_STRING AnsiString;
|
||||
UNICODE_STRING ProcessName;
|
||||
|
||||
Status = ZwCreateProcess(&ProcessHandle,
|
||||
|
@ -1216,16 +1219,12 @@ NTSTATUS LdrLoadInitialProcess(VOID)
|
|||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DbgPrint("Could not create process\n");
|
||||
return Status;
|
||||
DbgPrint("Could not create process\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
RtlInitAnsiString(&AnsiString, "\\??\\C:\\reactos\\system\\shell.exe");
|
||||
RtlAnsiStringToUnicodeString(&ProcessName, &AnsiString, TRUE);
|
||||
|
||||
RtlInitUnicodeString(&ProcessName, L"\\??\\C:\\reactos\\system\\shell.exe");
|
||||
Status = LdrLoadImage(ProcessHandle, &ProcessName);
|
||||
|
||||
RtlFreeUnicodeString(&ProcessName);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -143,4 +143,5 @@ ex/napi.o: ex/napi.c ../include/ntdll/napi.h
|
|||
|
||||
#WITH_DEBUGGING = yes
|
||||
WIN32_LEAN_AND_MEAN = yes
|
||||
WARNINGS_ARE_ERRORS = yes
|
||||
include ../rules.mak
|
||||
|
|
|
@ -28,7 +28,6 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
|||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
MEMORY_AREA* current;
|
||||
ULONG i;
|
||||
|
||||
DbgPrint("MmDumpMemoryAreas()\n");
|
||||
|
||||
|
@ -45,9 +44,9 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
|||
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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -115,7 +114,7 @@ static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, ULONG BaseAddress)
|
|||
}
|
||||
|
||||
static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
||||
ULONG Address)
|
||||
PVOID Address)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
MEMORY_AREA* current;
|
||||
|
@ -153,7 +152,7 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
|||
|
||||
|
||||
MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||
ULONG Address,
|
||||
PVOID Address,
|
||||
ULONG Length)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
|
@ -178,16 +177,16 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
|||
current);
|
||||
return(current);
|
||||
}
|
||||
Extent = current->BaseAddress + current->Length;
|
||||
if (Extent > Address &&
|
||||
Extent < (Address+Length))
|
||||
Extent = (ULONG)current->BaseAddress + current->Length;
|
||||
if (Extent > (ULONG)Address &&
|
||||
Extent < (ULONG)(Address+Length))
|
||||
{
|
||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||
current);
|
||||
return(current);
|
||||
}
|
||||
if (current->BaseAddress <= Address &&
|
||||
Extent >= (Address+Length))
|
||||
Extent >= (ULONG)(Address+Length))
|
||||
{
|
||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||
current);
|
||||
|
@ -204,7 +203,8 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
|||
return(NULL);
|
||||
}
|
||||
|
||||
MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process, ULONG Address,
|
||||
MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process,
|
||||
PVOID Address,
|
||||
ULONG Length)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
@ -223,7 +223,8 @@ MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process, ULONG Address,
|
|||
|
||||
|
||||
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process,
|
||||
ULONG Address, ULONG Length)
|
||||
PVOID Address,
|
||||
ULONG Length)
|
||||
{
|
||||
MEMORY_AREA* Result;
|
||||
PLIST_ENTRY ListHead;
|
||||
|
@ -249,13 +250,13 @@ MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address)
|
|||
}
|
||||
|
||||
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(PEPROCESS Process,
|
||||
ULONG Address)
|
||||
PVOID Address)
|
||||
{
|
||||
MEMORY_AREA* Result;
|
||||
PLIST_ENTRY ListHead;
|
||||
|
||||
ListHead = MmGetRelatedListHead(Process, Address);
|
||||
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address);
|
||||
Result = MmInternalOpenMemoryAreaByAddress(ListHead, Address);
|
||||
return(Result);
|
||||
}
|
||||
|
||||
|
@ -323,7 +324,7 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
|||
InsertTailList(ListHead,inserted_entry);
|
||||
}
|
||||
|
||||
static ULONG MmFindGapWithoutLock(PEPROCESS Process,
|
||||
static PVOID MmFindGapWithoutLock(PEPROCESS Process,
|
||||
KPROCESSOR_MODE Mode, ULONG Length)
|
||||
{
|
||||
PLIST_ENTRY ListHead;
|
||||
|
@ -366,7 +367,7 @@ static ULONG MmFindGapWithoutLock(PEPROCESS Process,
|
|||
if (current_entry == ListHead)
|
||||
{
|
||||
assert(Mode==UserMode);
|
||||
return(MM_LOWEST_USER_ADDRESS);
|
||||
return((PVOID)MM_LOWEST_USER_ADDRESS);
|
||||
}
|
||||
|
||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||
|
@ -398,13 +399,13 @@ NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
|||
DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x,"
|
||||
"FreePages %d)\n",Process,BaseAddress,Length,FreePages);
|
||||
|
||||
MmLockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
||||
MmLockMemoryAreaList(BaseAddress, &oldlvl);
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock(Process,
|
||||
(ULONG)BaseAddress);
|
||||
BaseAddress);
|
||||
if (MemoryArea==NULL)
|
||||
{
|
||||
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
||||
MmUnlockMemoryAreaList(BaseAddress, &oldlvl);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if (FreePages)
|
||||
|
@ -419,20 +420,10 @@ NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
|||
|
||||
RemoveEntryList(&(MemoryArea->Entry));
|
||||
ExFreePool(MemoryArea);
|
||||
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
||||
MmUnlockMemoryAreaList(BaseAddress, &oldlvl);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea)
|
||||
{
|
||||
MemoryArea->LockCount++;
|
||||
}
|
||||
|
||||
NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea)
|
||||
{
|
||||
MemoryArea->LockCount--;
|
||||
}
|
||||
|
||||
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
||||
PMEMORY_AREA OriginalMemoryArea,
|
||||
PVOID BaseAddress,
|
||||
|
@ -531,8 +522,9 @@ NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
|||
}
|
||||
else
|
||||
{
|
||||
(*BaseAddress) = PAGE_ROUND_DOWN((*BaseAddress));
|
||||
if (MmOpenMemoryAreaByRegionWithoutLock(Process,*BaseAddress,
|
||||
(*BaseAddress) = (PVOID)PAGE_ROUND_DOWN((*BaseAddress));
|
||||
if (MmOpenMemoryAreaByRegionWithoutLock(Process,
|
||||
*BaseAddress,
|
||||
Length)!=NULL)
|
||||
{
|
||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
||||
|
|
|
@ -68,7 +68,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
|||
DPRINT("Writing %x with physical address %x\n",
|
||||
base+(i*PAGESIZE),mdl_pages[i]);
|
||||
MmSetPage(NULL,
|
||||
(DWORD)base+(i*PAGESIZE),
|
||||
(PVOID)((DWORD)base+(i*PAGESIZE)),
|
||||
PAGE_READWRITE,
|
||||
mdl_pages[i]);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
|||
DPRINT("StartVa %x\n",Mdl->StartVa);
|
||||
|
||||
marea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),
|
||||
(ULONG)Mdl->StartVa);
|
||||
Mdl->StartVa);
|
||||
DPRINT("marea %x\n",marea);
|
||||
|
||||
|
||||
|
@ -240,8 +240,8 @@ VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
|
|||
*/
|
||||
{
|
||||
memset(MemoryDescriptorList,0,sizeof(MDL));
|
||||
MemoryDescriptorList->StartVa = PAGE_ROUND_DOWN(Base);
|
||||
MemoryDescriptorList->ByteOffset = Base - PAGE_ROUND_DOWN(Base);
|
||||
MemoryDescriptorList->StartVa = (PVOID)PAGE_ROUND_DOWN(Base);
|
||||
MemoryDescriptorList->ByteOffset = (ULONG)(Base - PAGE_ROUND_DOWN(Base));
|
||||
MemoryDescriptorList->MdlFlags = 0;
|
||||
MemoryDescriptorList->ByteCount = Length;
|
||||
MemoryDescriptorList->Size = sizeof(MDL) +
|
||||
|
|
|
@ -110,7 +110,7 @@ void MmInitialize(boot_param* bp)
|
|||
i<PAGE_ROUND_DOWN(((int)&etext));i=i+PAGESIZE)
|
||||
{
|
||||
MmSetPageProtect(NULL,
|
||||
i,
|
||||
(PVOID)i,
|
||||
PAGE_EXECUTE_READ);
|
||||
}
|
||||
DPRINT("end %x\n",(int)&end);
|
||||
|
@ -118,7 +118,7 @@ void MmInitialize(boot_param* bp)
|
|||
i<(KERNEL_BASE+PAGE_TABLE_SIZE);i=i+PAGESIZE)
|
||||
{
|
||||
MmSetPage(NULL,
|
||||
i,
|
||||
(PVOID)i,
|
||||
PAGE_NOACCESS,
|
||||
0);
|
||||
}
|
||||
|
|
|
@ -80,8 +80,6 @@ ULONG EiNrUsedBlocks = 0;
|
|||
*/
|
||||
static unsigned int alloc_map[ALLOC_MAP_SIZE/32]={0,};
|
||||
|
||||
static unsigned int pool_free_mem = 0;
|
||||
|
||||
unsigned int EiFreeNonPagedPool = 0;
|
||||
unsigned int EiUsedNonPagedPool = 0;
|
||||
|
||||
|
@ -92,6 +90,7 @@ VOID ExInitNonPagedPool(ULONG BaseAddress)
|
|||
kernel_pool_base=BaseAddress;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void validate_free_list(void)
|
||||
/*
|
||||
* FUNCTION: Validate the integrity of the list of free blocks
|
||||
|
@ -260,6 +259,7 @@ static void validate_kernel_pool(void)
|
|||
current=current->next;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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++)
|
||||
{
|
||||
MmSetPage(NULL,
|
||||
start + (i*PAGESIZE),
|
||||
(PVOID)(start + (i*PAGESIZE)),
|
||||
PAGE_READWRITE,
|
||||
get_free_page());
|
||||
}
|
||||
|
@ -567,44 +567,6 @@ asmlinkage VOID ExFreePool(PVOID block)
|
|||
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,
|
||||
ULONG size,
|
||||
ULONG Tag,
|
||||
|
|
|
@ -48,7 +48,7 @@ PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG NumberOfBytes)
|
|||
Block = ExAllocateNonPagedPoolWithTag(PoolType,
|
||||
NumberOfBytes,
|
||||
TAG_NONE,
|
||||
(&PoolType)[-1]);
|
||||
(PVOID)(&PoolType)[-1]);
|
||||
return(Block);
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ PVOID ExAllocatePoolWithTag(ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
|
|||
Block = ExAllocateNonPagedPoolWithTag(PoolType,
|
||||
NumberOfBytes,
|
||||
Tag,
|
||||
(&PoolType)[-1]);
|
||||
(PVOID)(&PoolType)[-1]);
|
||||
break;
|
||||
|
||||
case PagedPool:
|
||||
|
@ -90,32 +90,9 @@ PVOID ExAllocatePoolWithTag(ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
|
|||
}
|
||||
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)
|
||||
{
|
||||
return(ExAllocatePoolWithQuotaTag(PoolType,NumberOfBytes,TAG_NONE));
|
||||
// return(ExAllocatePoolWithQuotaTag(PoolType,NumberOfBytes,TAG_NONE));
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <internal/ob.h>
|
||||
#include <internal/io.h>
|
||||
#include <internal/ps.h>
|
||||
#include <wchar.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -31,9 +32,9 @@ VOID MmpDeleteSection(PVOID ObjectBody)
|
|||
|
||||
NTSTATUS MmpCreateSection(PVOID ObjectBody,
|
||||
PVOID Parent,
|
||||
PWSTR RemainingPath)
|
||||
PWSTR RemainingPath,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)ObjectBody;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("MmpCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
PVOID MmAllocateSection(ULONG Length)
|
||||
{
|
||||
ULONG Result;
|
||||
PVOID Result;
|
||||
MEMORY_AREA* marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
|
@ -39,7 +39,7 @@ PVOID MmAllocateSection(ULONG Length)
|
|||
{
|
||||
return(NULL);
|
||||
}
|
||||
DPRINT("Result %x\n",Result);
|
||||
DPRINT("Result %p\n",Result);
|
||||
for (i=0;i<=(Length/PAGESIZE);i++)
|
||||
{
|
||||
MmSetPage(NULL,
|
||||
|
@ -65,13 +65,13 @@ PVOID MmMapIoSpace(PHYSICAL_ADDRESS PhysicalAddress,
|
|||
ULONG NumberOfBytes,
|
||||
BOOLEAN CacheEnable)
|
||||
{
|
||||
ULONG Result;
|
||||
PVOID Result;
|
||||
MEMORY_AREA* marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
ULONG Attributes;
|
||||
|
||||
Result=0;
|
||||
Result = 0;
|
||||
Status = MmCreateMemoryArea(KernelMode,
|
||||
PsGetCurrentProcess(),
|
||||
MEMORY_AREA_IO_MAPPING,
|
||||
|
@ -106,12 +106,12 @@ VOID MmUnmapIoSpace(PVOID BaseAddress, ULONG NumberOfBytes)
|
|||
|
||||
PVOID MmAllocateNonCachedMemory(ULONG NumberOfBytes)
|
||||
{
|
||||
ULONG Result;
|
||||
PVOID Result;
|
||||
MEMORY_AREA* marea;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
|
||||
Result=0;
|
||||
Result = 0;
|
||||
Status = MmCreateMemoryArea(KernelMode,
|
||||
PsGetCurrentProcess(),
|
||||
MEMORY_AREA_NO_CACHE,
|
||||
|
|
|
@ -91,7 +91,7 @@ void VirtualInit(boot_param* bp)
|
|||
MmInitSectionImplementation();
|
||||
}
|
||||
|
||||
ULONG MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, ULONG Address)
|
||||
ULONG MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
||||
{
|
||||
MmSetPage(PsGetCurrentProcess(),
|
||||
Address,
|
||||
|
@ -208,7 +208,7 @@ asmlinkage int page_fault_handler(unsigned int cs,
|
|||
break;
|
||||
|
||||
case MEMORY_AREA_COMMIT:
|
||||
stat = MmCommitedSectionHandleFault(MemoryArea,cr2);
|
||||
stat = MmCommitedSectionHandleFault(MemoryArea,(PVOID)cr2);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -669,7 +669,8 @@ NTSTATUS STDCALL ZwReadVirtualMemory(IN HANDLE ProcessHandle,
|
|||
|
||||
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),
|
||||
(PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)),
|
||||
PAGESIZE);
|
||||
|
@ -717,7 +718,6 @@ NTSTATUS STDCALL ZwWriteVirtualMemory(IN HANDLE ProcessHandle,
|
|||
OUT PULONG NumberOfBytesWritten)
|
||||
{
|
||||
PEPROCESS Process;
|
||||
PMEMORY_AREA InMemoryArea;
|
||||
PMEMORY_AREA OutMemoryArea;
|
||||
ULONG i;
|
||||
NTSTATUS Status;
|
||||
|
@ -759,8 +759,9 @@ NTSTATUS STDCALL ZwWriteVirtualMemory(IN HANDLE ProcessHandle,
|
|||
OutMemoryArea->Attributes,
|
||||
get_free_page());
|
||||
}
|
||||
CurrentEntry = MmGetPageEntry(Process, (DWORD)BaseAddress +
|
||||
(i*PAGESIZE));
|
||||
CurrentEntry = MmGetPageEntry(Process,
|
||||
(PVOID)((DWORD)BaseAddress +
|
||||
(i*PAGESIZE)));
|
||||
RtlCopyMemory((PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)) +
|
||||
(((DWORD)BaseAddress)%PAGESIZE),
|
||||
Buffer + (i*PAGESIZE),
|
||||
|
|
|
@ -130,6 +130,8 @@ NTSTATUS ExInitializeZone(PZONE_HEADER Zone, ULONG BlockSize,
|
|||
PushEntryList(&Zone->FreeList,&entry->Entry);
|
||||
entry = (PZONE_ENTRY)(((PVOID)entry) + sizeof(ZONE_ENTRY) + BlockSize);
|
||||
}
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
PVOID ExInterlockedFreeToZone(PZONE_HEADER Zone, PVOID Block,
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/nt/nt.c
|
||||
* PURPOSE: Initialization of system call interfaces
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
@ -11,6 +11,7 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/nt.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
|
|
@ -19,8 +19,7 @@
|
|||
NTSTATUS STDCALL NtCancelTimer(IN HANDLE TimerHandle,
|
||||
OUT PBOOLEAN CurrentState OPTIONAL)
|
||||
{
|
||||
return(ZwCancelTimer(TimerHandle,
|
||||
CurrentState));
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL ZwCancelTimer(IN HANDLE TimerHandle,
|
||||
|
|
|
@ -34,6 +34,40 @@ typedef struct
|
|||
|
||||
/* 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,
|
||||
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)
|
||||
{
|
||||
PHANDLE_REP Rep;
|
||||
|
|
|
@ -133,7 +133,6 @@ PVOID ObpParseDirectory(PVOID Object, PWSTR* Path)
|
|||
{
|
||||
PWSTR end;
|
||||
PVOID FoundObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("ObpParseDirectory(Object %x, Path %x, *Path %w)\n",
|
||||
Object,Path,*Path);
|
||||
|
|
|
@ -11,18 +11,19 @@
|
|||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ke.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
HANDLE IdleThreadHandle = NULL;
|
||||
HANDLE PsIdleThreadHandle = NULL;
|
||||
extern ULONG DpcQueueSize;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
static VOID PsIdleThreadMain(PVOID Context)
|
||||
static NTSTATUS PsIdleThreadMain(PVOID Context)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
|
@ -43,7 +44,7 @@ VOID PsInitIdleThread(VOID)
|
|||
{
|
||||
KPRIORITY Priority;
|
||||
|
||||
PsCreateSystemThread(&IdleThreadHandle,
|
||||
PsCreateSystemThread(&PsIdleThreadHandle,
|
||||
THREAD_ALL_ACCESS,
|
||||
NULL,
|
||||
NULL,
|
||||
|
@ -52,7 +53,7 @@ VOID PsInitIdleThread(VOID)
|
|||
NULL);
|
||||
|
||||
Priority = THREAD_PRIORITY_IDLE;
|
||||
ZwSetInformationThread(IdleThreadHandle,
|
||||
ZwSetInformationThread(PsIdleThreadHandle,
|
||||
ThreadPriority,
|
||||
&Priority,
|
||||
sizeof(Priority));
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/ps/kill.c
|
||||
* PURPOSE: Terminating a thread
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
@ -12,6 +12,7 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ps.h>
|
||||
#include <internal/ke.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -62,7 +63,6 @@ NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
|
|||
NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle,
|
||||
IN NTSTATUS ExitStatus)
|
||||
{
|
||||
PETHREAD Thread;
|
||||
NTSTATUS Status;
|
||||
PEPROCESS Process;
|
||||
KIRQL oldlvl;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <internal/ob.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/ke.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
|
@ -161,9 +162,6 @@ NTSTATUS STDCALL ZwCreateProcess(
|
|||
PULONG CurrentPageDirectory;
|
||||
ULONG i;
|
||||
PKPROCESS KProcess;
|
||||
ULONG Base;
|
||||
ULONG Length;
|
||||
LARGE_INTEGER Offset;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("ZwCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
|
||||
|
@ -196,10 +194,10 @@ NTSTATUS STDCALL ZwCreateProcess(
|
|||
InheritObjectTable,
|
||||
Process);
|
||||
|
||||
PageDirectory = physical_to_linear((ULONG)get_free_page());
|
||||
PageDirectory = (PULONG)physical_to_linear((ULONG)get_free_page());
|
||||
KProcess->PageTableDirectory = PageDirectory;
|
||||
|
||||
CurrentPageDirectory = get_page_directory();
|
||||
CurrentPageDirectory = (PULONG)get_page_directory();
|
||||
|
||||
memset(PageDirectory,0,PAGESIZE);
|
||||
for (i=768;i<1024;i++)
|
||||
|
@ -260,10 +258,10 @@ NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle,
|
|||
IN ULONG ProcessInformationLength,
|
||||
OUT PULONG ReturnLength)
|
||||
{
|
||||
PEPROCESS Process;
|
||||
// PEPROCESS Process;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
/* Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_QUERY_INFORMATION,
|
||||
PsProcessType,
|
||||
UserMode,
|
||||
|
@ -272,7 +270,7 @@ NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle,
|
|||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}*/
|
||||
|
||||
switch (ProcessInformationClass)
|
||||
{
|
||||
|
@ -319,10 +317,10 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle,
|
|||
IN PVOID ProcessInformation,
|
||||
IN ULONG ProcessInformationLength)
|
||||
{
|
||||
PEPROCESS Process;
|
||||
// PEPROCESS Process;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
/* Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_SET_INFORMATION,
|
||||
PsProcessType,
|
||||
UserMode,
|
||||
|
@ -331,7 +329,7 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle,
|
|||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}*/
|
||||
|
||||
switch (ProcessInformationClass)
|
||||
{
|
||||
|
|
|
@ -210,8 +210,6 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
|||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ThreadAttributes)
|
||||
{
|
||||
ULONG ThreadId;
|
||||
ULONG ProcessId;
|
||||
PETHREAD Thread;
|
||||
NTSTATUS Status;
|
||||
|
||||
|
@ -256,7 +254,8 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
|||
UserMode);
|
||||
InitializeListHead(Thread->Tcb.ApcList);
|
||||
InitializeListHead(&(Thread->IrpList));
|
||||
Thread->Cid.UniqueThread=InterlockedIncrement(&NextThreadUniqueId);
|
||||
Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
|
||||
&NextThreadUniqueId);
|
||||
ObReferenceObjectByPointer(Thread,
|
||||
THREAD_ALL_ACCESS,
|
||||
PsThreadType,
|
||||
|
|
|
@ -45,7 +45,8 @@ NTSTATUS ZwSetInformationThread(HANDLE ThreadHandle,
|
|||
ThreadBasicInformationP->TebBaseAddress = Thread->Tcb.Teb;
|
||||
ThreadBasicInformationP->AffinityMask = Thread->Tcb.Affinity;
|
||||
ThreadBasicInformationP->BasePriority = Thread->Tcb.BasePriority;
|
||||
ThreadBasicInformationP->UniqueThreadId = Thread->Cid.UniqueThread;
|
||||
ThreadBasicInformationP->UniqueThreadId = (ULONG)
|
||||
Thread->Cid.UniqueThread;
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ VOID RtlCopyBytes(PVOID Destination,
|
|||
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",
|
||||
Destination,Source,Length);
|
||||
|
|
|
@ -16,12 +16,11 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
#undef memcpy
|
||||
void *memcpy (void *to, const void *from, size_t count)
|
||||
{
|
||||
register char *f = from;
|
||||
register char *t = to;
|
||||
register int i = count;
|
||||
const char *f = from;
|
||||
char *t = to;
|
||||
int i = count;
|
||||
|
||||
while (i-- > 0)
|
||||
*t++ = *f++;
|
||||
|
|
|
@ -16,8 +16,3 @@
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID RtlGetCallersAddress(PVOID* CallersAddress)
|
||||
{
|
||||
PULONG stk = (PULONG)(&CallersAddress);
|
||||
*CallersAddress = stk[-1];
|
||||
}
|
||||
|
|
|
@ -21,14 +21,8 @@
|
|||
|
||||
#define Aa_Difference ('A'-'a')
|
||||
|
||||
PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest,
|
||||
PUNICODE_STRING Src)
|
||||
{
|
||||
if (Dest==NULL)
|
||||
{
|
||||
Dest=ExAllocatePool(NonPagedPool,sizeof(UNICODE_STRING));
|
||||
}
|
||||
}
|
||||
extern unsigned long simple_strtoul(const char *cp, char **endp,
|
||||
unsigned int base);
|
||||
|
||||
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
|
||||
{
|
||||
|
@ -127,8 +121,9 @@ NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
|
|||
|
||||
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)
|
||||
{
|
||||
|
@ -348,7 +343,7 @@ VOID RtlInitString(IN OUT PSTRING DestinationString,
|
|||
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||
IN PCWSTR SourceString)
|
||||
{
|
||||
unsigned long i, DestSize;
|
||||
unsigned long DestSize;
|
||||
|
||||
DPRINT("RtlInitUnicodeString(DestinationString %x, "
|
||||
"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 */
|
||||
IN OUT PUNICODE_STRING String)
|
||||
{
|
||||
|
@ -384,7 +380,7 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
|||
if(Base==2) {
|
||||
sprintf(str, "%b", Value);
|
||||
} else {
|
||||
sprintf(str, "%u", Value);
|
||||
sprintf(str, "%u", (unsigned int)Value);
|
||||
};
|
||||
|
||||
len=strlen(str);
|
||||
|
@ -402,7 +398,8 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
|
|||
ExFreePool(str);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
||||
IN PUNICODE_STRING SourceString,
|
||||
|
@ -487,7 +484,8 @@ NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
|
|||
*Value=simple_strtoul(str, NULL, Base);
|
||||
|
||||
ExFreePool(str);
|
||||
};
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||
IN PUNICODE_STRING SourceString,
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <internal/debug.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <wchar.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -62,7 +63,6 @@ wcschr(const wchar_t *str, wchar_t ch)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
wchar_t towupper(wchar_t w)
|
||||
{
|
||||
if (w < L'A')
|
||||
|
@ -74,11 +74,10 @@ wchar_t towupper(wchar_t w)
|
|||
return(w);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
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++;
|
||||
ct++;
|
||||
|
|
|
@ -68,6 +68,7 @@ NtSetSecurityObject(
|
|||
IN PSECURITY_DESCRIPTOR SecurityDescriptor
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -79,6 +80,7 @@ NtSetInformationToken(
|
|||
IN ULONG TokenInformationLength
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -89,6 +91,7 @@ NtPrivilegeCheck(
|
|||
IN PBOOLEAN Result
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -101,6 +104,7 @@ NtPrivilegedServiceAuditAlarm(
|
|||
IN BOOLEAN AccessGranted
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -112,8 +116,10 @@ NtPrivilegeObjectAuditAlarm(
|
|||
IN ULONG DesiredAccess,
|
||||
IN PPRIVILEGE_SET Privileges,
|
||||
IN BOOLEAN AccessGranted
|
||||
)
|
||||
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -131,6 +137,7 @@ NtOpenObjectAuditAlarm(
|
|||
OUT PBOOLEAN GenerateOnClose
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -141,6 +148,7 @@ NtOpenProcessToken(
|
|||
OUT PHANDLE TokenHandle
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
|
@ -152,179 +160,157 @@ NtOpenThreadToken(
|
|||
OUT PHANDLE TokenHandle
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtDuplicateToken(
|
||||
IN HANDLE ExistingToken,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel,
|
||||
IN TOKEN_TYPE TokenType,
|
||||
OUT PHANDLE NewToken
|
||||
)
|
||||
NTSTATUS STDCALL NtDuplicateToken(IN HANDLE ExistingToken,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN SECURITY_IMPERSONATION_LEVEL
|
||||
ImpersonationLevel,
|
||||
IN TOKEN_TYPE TokenType,
|
||||
OUT PHANDLE NewToken)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtImpersonateClientOfPort(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtImpersonateThread(
|
||||
IN HANDLE ThreadHandle,
|
||||
IN HANDLE ThreadToImpersonate,
|
||||
IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService
|
||||
)
|
||||
NTSTATUS STDCALL NtImpersonateThread(IN HANDLE ThreadHandle,
|
||||
IN HANDLE ThreadToImpersonate,
|
||||
IN PSECURITY_QUALITY_OF_SERVICE
|
||||
SecurityQualityOfService)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtCreateToken(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtDeleteObjectAuditAlarm (
|
||||
IN PUNICODE_STRING SubsystemName,
|
||||
IN PVOID HandleId,
|
||||
IN BOOLEAN GenerateOnClose
|
||||
)
|
||||
NTSTATUS STDCALL NtDeleteObjectAuditAlarm(IN PUNICODE_STRING SubsystemName,
|
||||
IN PVOID HandleId,
|
||||
IN BOOLEAN GenerateOnClose)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtAllocateLocallyUniqueId(
|
||||
OUT LUID *LocallyUniqueId
|
||||
)
|
||||
NTSTATUS STDCALL NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
|
||||
{
|
||||
return(ZwAllocateLocallyUniqueId(LocallyUniqueId));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwAllocateLocallyUniqueId(
|
||||
OUT LUID *LocallyUniqueId
|
||||
)
|
||||
NTSTATUS STDCALL ZwAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtAccessCheckAndAuditAlarm(
|
||||
IN PUNICODE_STRING SubsystemName,
|
||||
IN PHANDLE ObjectHandle,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN PGENERIC_MAPPING GenericMapping,
|
||||
IN BOOLEAN ObjectCreation,
|
||||
OUT PULONG GrantedAccess,
|
||||
OUT PBOOLEAN AccessStatus,
|
||||
OUT PBOOLEAN GenerateOnClose
|
||||
)
|
||||
NTSTATUS STDCALL NtAccessCheckAndAuditAlarm(IN PUNICODE_STRING SubsystemName,
|
||||
IN PHANDLE ObjectHandle,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN PGENERIC_MAPPING GenericMapping,
|
||||
IN BOOLEAN ObjectCreation,
|
||||
OUT PULONG GrantedAccess,
|
||||
OUT PBOOLEAN AccessStatus,
|
||||
OUT PBOOLEAN GenerateOnClose)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtAdjustGroupsToken(
|
||||
IN HANDLE TokenHandle,
|
||||
IN BOOLEAN ResetToDefault,
|
||||
IN PTOKEN_GROUPS NewState,
|
||||
IN ULONG BufferLength,
|
||||
OUT PTOKEN_GROUPS PreviousState OPTIONAL,
|
||||
OUT PULONG ReturnLength
|
||||
)
|
||||
NTSTATUS STDCALL NtAdjustGroupsToken(IN HANDLE TokenHandle,
|
||||
IN BOOLEAN ResetToDefault,
|
||||
IN PTOKEN_GROUPS NewState,
|
||||
IN ULONG BufferLength,
|
||||
OUT PTOKEN_GROUPS PreviousState OPTIONAL,
|
||||
OUT PULONG ReturnLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtAdjustPrivilegesToken(
|
||||
IN HANDLE TokenHandle,
|
||||
IN BOOLEAN DisableAllPrivileges,
|
||||
IN PTOKEN_PRIVILEGES NewState,
|
||||
IN ULONG BufferLength,
|
||||
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||
OUT PULONG ReturnLength
|
||||
)
|
||||
{
|
||||
}
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwAdjustPrivilegesToken(
|
||||
IN HANDLE TokenHandle,
|
||||
IN BOOLEAN DisableAllPrivileges,
|
||||
IN PTOKEN_PRIVILEGES NewState,
|
||||
IN ULONG BufferLength,
|
||||
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||
OUT PULONG ReturnLength
|
||||
)
|
||||
NTSTATUS STDCALL NtAdjustPrivilegesToken(IN HANDLE TokenHandle,
|
||||
IN BOOLEAN DisableAllPrivileges,
|
||||
IN PTOKEN_PRIVILEGES NewState,
|
||||
IN ULONG BufferLength,
|
||||
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||
OUT PULONG ReturnLength)
|
||||
{
|
||||
return(ZwAdjustPrivilegesToken(TokenHandle,
|
||||
DisableAllPrivileges,
|
||||
NewState,
|
||||
BufferLength,
|
||||
PreviousState,
|
||||
ReturnLength));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtAllocateUuids(
|
||||
PLARGE_INTEGER Time,
|
||||
PULONG Version, // ???
|
||||
PULONG ClockCycle
|
||||
)
|
||||
NTSTATUS STDCALL ZwAdjustPrivilegesToken(IN HANDLE TokenHandle,
|
||||
IN BOOLEAN DisableAllPrivileges,
|
||||
IN PTOKEN_PRIVILEGES NewState,
|
||||
IN ULONG BufferLength,
|
||||
OUT PTOKEN_PRIVILEGES PreviousState,
|
||||
OUT PULONG ReturnLength)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwAllocateUuids(
|
||||
PLARGE_INTEGER Time,
|
||||
PULONG Version, // ???
|
||||
PULONG ClockCycle
|
||||
)
|
||||
NTSTATUS STDCALL NtAllocateUuids(PLARGE_INTEGER Time,
|
||||
PULONG Version, // ???
|
||||
PULONG ClockCycle)
|
||||
{
|
||||
return(ZwAllocateUuids(Time,
|
||||
Version,
|
||||
ClockCycle));
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCloseObjectAuditAlarm(
|
||||
IN PUNICODE_STRING SubsystemName,
|
||||
IN PVOID HandleId,
|
||||
IN BOOLEAN GenerateOnClose
|
||||
)
|
||||
NTSTATUS STDCALL ZwAllocateUuids(PLARGE_INTEGER Time,
|
||||
PULONG Version, // ???
|
||||
PULONG ClockCycle)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtAccessCheck(
|
||||
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
|
||||
)
|
||||
NTSTATUS STDCALL NtCloseObjectAuditAlarm(IN PUNICODE_STRING SubsystemName,
|
||||
IN PVOID HandleId,
|
||||
IN BOOLEAN GenerateOnClose)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
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
|
||||
)
|
||||
NTSTATUS STDCALL NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
|
||||
IN HANDLE ClientToken,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
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 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,
|
||||
|
|
|
@ -77,7 +77,7 @@ int main(int argc, char* argv[])
|
|||
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");
|
||||
|
||||
return(0);
|
||||
|
|
|
@ -40,6 +40,10 @@ else
|
|||
DEBUGGING_CFLAGS =
|
||||
endif
|
||||
|
||||
ifeq ($(WARNINGS_ARE_ERRORS),yes)
|
||||
EXTRA_CFLAGS = -Werror
|
||||
endif
|
||||
|
||||
DEFINES = -DDBG -DCOMPILER_LARGE_INTEGERS
|
||||
|
||||
ifeq ($(WIN32_LEAN_AND_MEAN),yes)
|
||||
|
@ -52,7 +56,8 @@ CC = $(PREFIX)gcc
|
|||
NATIVE_CC = gcc
|
||||
CFLAGS = -O2 -I../../../include -I../../include \
|
||||
-I../include -fno-builtin $(LEAN_AND_MEAN_DEFINE) \
|
||||
$(DEFINES) -Wall -Wstrict-prototypes $(DEBUGGING_CFLAGS)
|
||||
$(DEFINES) -Wall -Wstrict-prototypes $(DEBUGGING_CFLAGS) \
|
||||
$(EXTRA_CFLAGS)
|
||||
CXXFLAGS = $(CFLAGS)
|
||||
NFLAGS = -i../../include/ -i../include/ -pinternal/asm.inc -f$(NASM_FORMAT) -d$(NASM_FORMAT)
|
||||
LD = $(PREFIX)ld
|
||||
|
|
Loading…
Reference in a new issue