Cleaned up code a bit

svn path=/trunk/; revision=339
This commit is contained in:
David Welch 1999-03-25 00:37:06 +00:00
parent 3f0a7424cb
commit 8688a2a272
80 changed files with 1191 additions and 1213 deletions

View file

@ -184,8 +184,8 @@ typedef NTSTATUS (*PDRIVER_INITIALIZE)(struct _DRIVER_OBJECT* DriverObject,
/* /*
* Driver cancel declaration * Driver cancel declaration
*/ */
typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DRIVER_OBJECT* DriverObject, typedef NTSTATUS (*PDRIVER_CANCEL)(struct _DEVICE_OBJECT* DeviceObject,
PUNICODE_STRING RegistryPath); struct _IRP* RegistryPath);
typedef struct _SECTION_OBJECT_POINTERS typedef struct _SECTION_OBJECT_POINTERS

View file

@ -13,6 +13,7 @@
#define SET_LARGE_INTEGER_LOW_PART(LI, LP) \ #define SET_LARGE_INTEGER_LOW_PART(LI, LP) \
( (LI) = ((LI) & 0xFFFFFFFF00000000L) | (LP) ) ( (LI) = ((LI) & 0xFFFFFFFF00000000L) | (LP) )
#define LARGE_INTEGER_QUAD_PART(LI) (LI) #define LARGE_INTEGER_QUAD_PART(LI) (LI)
#define INITIALIZE_LARGE_INTEGER (0)
typedef long long int LONGLONG, *PLONGLONG; typedef long long int LONGLONG, *PLONGLONG;
typedef unsigned long long int ULONGLONG, *PULONGLONG; typedef unsigned long long int ULONGLONG, *PULONGLONG;
@ -26,6 +27,7 @@ typedef unsigned long long int ULONGLONG, *PULONGLONG;
#define SET_LARGE_INTEGER_LOW_PART(LargeInteger,Unsigned_Long) \ #define SET_LARGE_INTEGER_LOW_PART(LargeInteger,Unsigned_Long) \
((LargeInteger).LowPart = (Unsigned_Long)) ((LargeInteger).LowPart = (Unsigned_Long))
#define LARGE_INTEGER_QUAD_PART(LI) (*(LONGLONG *)(&(LI))) #define LARGE_INTEGER_QUAD_PART(LI) (*(LONGLONG *)(&(LI)))
#define INITIALIZE_LARGE_INTEGER ({0,0})
typedef double LONGLONG, *PLONGLONG; typedef double LONGLONG, *PLONGLONG;
typedef double ULONGLONG, *PULONGLONG; typedef double ULONGLONG, *PULONGLONG;

View file

@ -145,7 +145,7 @@ LONG RtlCompareUnicodeString(PUNICODE_STRING String1,
LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger); LARGE_INTEGER RtlConvertLongToLargeInteger(LONG SignedInteger);
LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger); LARGE_INTEGER RtlConvertUlongToLargeInteger(ULONG UnsignedInteger);
VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length); VOID RtlCopyBytes(PVOID Destination, CONST VOID* Source, ULONG Length);
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length); VOID RtlCopyMemory(VOID* Destination, CONST VOID* Source, ULONG Length);
VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString); VOID RtlCopyString(PSTRING DestinationString, PSTRING SourceString);
VOID RtlCopyUnicodeString(PUNICODE_STRING DestinationString, VOID RtlCopyUnicodeString(PUNICODE_STRING DestinationString,
PUNICODE_STRING SourceString); PUNICODE_STRING SourceString);

View file

@ -30,6 +30,7 @@ NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
VOID IoInitCancelHandling(VOID); VOID IoInitCancelHandling(VOID);
VOID IoInitSymbolicLinkImplementation(VOID); VOID IoInitSymbolicLinkImplementation(VOID);
VOID IoInitFileSystemImplementation(VOID);
NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject); NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject);
POBJECT IoOpenSymlink(POBJECT SymbolicLink); POBJECT IoOpenSymlink(POBJECT SymbolicLink);
@ -54,5 +55,6 @@ NTSTATUS IopCreateDevice(PVOID ObjectBody,
PVOID Parent, PVOID Parent,
PWSTR RemainingPath, PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes); POBJECT_ATTRIBUTES ObjectAttributes);
NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject);
#endif #endif

View file

@ -18,6 +18,7 @@
VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait); VOID KeAcquireDispatcherDatabaseLock(BOOLEAN Wait);
VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait); VOID KeReleaseDispatcherDatabaseLock(BOOLEAN Wait);
VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr); VOID KeDispatcherObjectWake(DISPATCHER_HEADER* hdr);
VOID KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr);
VOID KiInterruptDispatch(ULONG irq); VOID KiInterruptDispatch(ULONG irq);
VOID KiDispatchInterrupt(ULONG irq); VOID KiDispatchInterrupt(ULONG irq);
@ -36,10 +37,10 @@ VOID KeInitExceptions(VOID);
VOID KeInitIRQ(VOID); VOID KeInitIRQ(VOID);
VOID KeInitTimer(VOID); VOID KeInitTimer(VOID);
VOID KeInitDpc(VOID); VOID KeInitDpc(VOID);
VOID KeInitBugCheck(VOID);
VOID KeInitDispatcher(VOID); VOID KeInitDispatcher(VOID);
VOID KeCalibrateTimerLoop(VOID); VOID KeCalibrateTimerLoop(VOID);
VOID KeInitializeDispatcher(VOID); VOID KeInitializeDispatcher(VOID);
VOID KeInitializeTimerImpl(VOID); VOID KeInitializeTimerImpl(VOID);
VOID KeInitializeBugCheck(VOID);
#endif #endif

View file

@ -2,5 +2,7 @@
NTSTATUS LdrLoadDriver(PUNICODE_STRING Filename); NTSTATUS LdrLoadDriver(PUNICODE_STRING Filename);
NTSTATUS LdrLoadInitialProcess(VOID); NTSTATUS LdrLoadInitialProcess(VOID);
VOID LdrLoadAutoConfigDrivers(VOID); VOID LdrLoadAutoConfigDrivers(VOID);
VOID LdrInitModuleManagement(VOID);
NTSTATUS LdrProcessDriver(PVOID ModuleLoadBase);

View file

@ -0,0 +1 @@
VOID NtInitializeEventImplementation(VOID);

View file

@ -60,6 +60,7 @@ PVOID ObCreateObject(PHANDLE Handle,
POBJECT_ATTRIBUTES ObjectAttributes, POBJECT_ATTRIBUTES ObjectAttributes,
POBJECT_TYPE Type); POBJECT_TYPE Type);
VOID ObRemoveEntry(POBJECT_HEADER Header); VOID ObRemoveEntry(POBJECT_HEADER Header);
NTSTATUS ObPerformRetentionChecks(POBJECT_HEADER Header);
/* /*
* FUNCTION: Creates an entry within a directory * FUNCTION: Creates an entry within a directory
@ -106,6 +107,9 @@ NTSTATUS ObCreateHandle(PEPROCESS Process,
VOID ObCreateHandleTable(PEPROCESS Parent, VOID ObCreateHandleTable(PEPROCESS Parent,
BOOLEAN Inherit, BOOLEAN Inherit,
PEPROCESS Process); PEPROCESS Process);
NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
PVOID* ReturnedObject,
PWSTR* RemainingPath);
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */ #endif /* __INCLUDE_INTERNAL_OBJMGR_H */

View file

@ -14,6 +14,8 @@ VOID PsInitProcessManagment(VOID);
VOID PsInitIdleThread(VOID); VOID PsInitIdleThread(VOID);
VOID PsDispatchThread(VOID); VOID PsDispatchThread(VOID);
VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus); VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus);
VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus);
VOID PsReleaseThread(PETHREAD Thread);
/* /*
* PURPOSE: Thread states * PURPOSE: Thread states
@ -54,5 +56,6 @@ void HalInitFirstTask(PETHREAD thread);
BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext); BOOLEAN HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext);
void HalTaskSwitch(PKTHREAD thread); void HalTaskSwitch(PKTHREAD thread);
NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context); NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context);
NTSTATUS HalReleaseTask(PETHREAD Thread);
#endif #endif

View file

@ -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 */

View 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);

View file

@ -1,5 +1,7 @@
extern void dprintf(char* fmt,...); extern void dprintf(char* fmt,...);
#define UNIMPLEMENTED dprintf("%s in %s:%d is unimplemented\n",__FUNCTION__,__FILE__,__LINE__);
#ifdef NDEBUG #ifdef NDEBUG
#define DPRINT(args...) #define DPRINT(args...)
#else #else

View 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);

View file

@ -433,8 +433,8 @@ RtlUnlockHeap@4
RtlValidateHeap@12 RtlValidateHeap@12
RtlInitAnsiString RtlInitAnsiString
RtlInitUnicodeString RtlInitUnicodeString
RtlLargeIntegerDivide
RtlLargeIntegerAdd RtlLargeIntegerAdd
RtlLargeIntegerDivide
RtlEnlargedIntegerMultiply RtlEnlargedIntegerMultiply
RtlEnlargedUnsignedMultiply RtlEnlargedUnsignedMultiply
RtlExtendedIntegerMultiply RtlExtendedIntegerMultiply
@ -455,9 +455,9 @@ wcscpy
wcschr wcschr
wcscat wcscat
wcscmp wcscmp
wcsicmp
wcsnicmp
wcsncpy wcsncpy
wcslen wcslen
wcsrchr wcsrchr
wcsicmp
wcsnicmp
vsprintf vsprintf

View file

@ -14,221 +14,20 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <pe.h> #include <pe.h>
#include <string.h> #include <string.h>
#include <internal/string.h>
#include <wchar.h> #include <wchar.h>
#include <ntdll/ldr.h>
#include <ntdll/rtl.h>
//#define NDEBUG //#define NDEBUG
#include <ntdll/ntdll.h> #include <ntdll/ntdll.h>
PVOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize);
/* MACROS ********************************************************************/
#define RVA(m, b) ((ULONG)b + m)
/* TYPEDEFS ******************************************************************/
typedef NTSTATUS (*PEPFUNC)(VOID);
typedef struct _DLL
{
PIMAGE_NT_HEADERS Headers;
PVOID BaseAddress;
struct _DLL* Prev;
struct _DLL* Next;
} DLL, *PDLL;
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
static DLL DllListHead; DLL LdrDllListHead;
extern unsigned int _image_base__;
#define HEAP_BASE (0xa0000000)
/* FORWARD DECLARATIONS ******************************************************/
static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle);
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
static NTSTATUS LdrMapSections(PVOID ImageBase, HANDLE SectionHandle,
PIMAGE_NT_HEADERS NTHeaders)
{
ULONG i;
NTSTATUS Status;
for (i=0; i<NTHeaders->FileHeader.NumberOfSections; i++)
{
PIMAGE_SECTION_HEADER Sections;
LARGE_INTEGER Offset;
ULONG Base;
Sections = (PIMAGE_SECTION_HEADER)SECHDROFFSET(ImageBase);
Base = Sections[i].VirtualAddress + ImageBase;
SET_LARGE_INTEGER_HIGH_PART(Offset,0);
SET_LARGE_INTEGER_LOW_PART(Offset,Sections[i].PointerToRawData);
Status = ZwMapViewOfSection(SectionHandle,
NtCurrentProcess(),
(PVOID *)&Base,
0,
Sections[i].Misc.VirtualSize,
&Offset,
&Sections[i].Misc.VirtualSize,
0,
MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
return Status;
}
}
return(STATUS_SUCCESS);
}
static NTSTATUS LdrLoadDll(PDLL* Base, PCHAR Name)
{
char fqname[255] = "\\??\\C:\\reactos\\system\\";
ANSI_STRING AnsiString;
UNICODE_STRING UnicodeString;
OBJECT_ATTRIBUTES FileObjectAttributes;
char BlockBuffer[1024];
PIMAGE_DOS_HEADER DosHeader;
NTSTATUS Status;
PIMAGE_NT_HEADERS NTHeaders;
PEPFUNC DllStartupAddr;
ULONG ImageBase, ImageSize, InitialViewSize;
HANDLE FileHandle, SectionHandle;
PDLL DllDesc;
DPRINT("LdrLoadDll(Base %x, Name %s)\n",Base,Name);
strcat(fqname, Name);
DPRINT("fqname %s\n",fqname);
RtlInitAnsiString(&AnsiString,fqname);
RtlAnsiStringToUnicodeString(&UnicodeString,&AnsiString,TRUE);
InitializeObjectAttributes(&FileObjectAttributes,
&UnicodeString,
0,
NULL,
NULL);
DPRINT("Opening dll\n");
Status = ZwOpenFile(&FileHandle, FILE_ALL_ACCESS, &FileObjectAttributes,
NULL, 0, 0);
if (!NT_SUCCESS(Status))
{
DPRINT("Dll open failed ");
return Status;
}
Status = ZwReadFile(FileHandle, 0, 0, 0, 0, BlockBuffer, 1024, 0, 0);
if (!NT_SUCCESS(Status))
{
DPRINT("Dll header read failed ");
ZwClose(FileHandle);
return Status;
}
DosHeader = (PIMAGE_DOS_HEADER) BlockBuffer;
if (DosHeader->e_magic != IMAGE_DOS_MAGIC ||
DosHeader->e_lfanew == 0L ||
*(PULONG)((PUCHAR)BlockBuffer + DosHeader->e_lfanew) != IMAGE_PE_MAGIC)
{
DPRINT("NTDLL format invalid\n");
ZwClose(FileHandle);
return STATUS_UNSUCCESSFUL;
}
NTHeaders = (PIMAGE_NT_HEADERS)(BlockBuffer + DosHeader->e_lfanew);
ImageBase = NTHeaders->OptionalHeader.ImageBase;
ImageSize = NTHeaders->OptionalHeader.SizeOfImage;
DPRINT("ImageBase %x\n",ImageBase);
DllStartupAddr = ImageBase + NTHeaders->OptionalHeader.AddressOfEntryPoint;
/* Create a section for NTDLL */
Status = ZwCreateSection(&SectionHandle,
SECTION_ALL_ACCESS,
NULL,
NULL,
PAGE_READWRITE,
MEM_COMMIT,
FileHandle);
if (!NT_SUCCESS(Status))
{
DPRINT("NTDLL create section failed ");
ZwClose(FileHandle);
return Status;
}
/* Map the NTDLL into the process */
InitialViewSize = DosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS)
+ sizeof(IMAGE_SECTION_HEADER) * NTHeaders->FileHeader.NumberOfSections;
Status = ZwMapViewOfSection(SectionHandle,
NtCurrentProcess(),
(PVOID *)&ImageBase,
0,
InitialViewSize,
NULL,
&InitialViewSize,
0,
MEM_COMMIT,
PAGE_READWRITE);
if (!NT_SUCCESS(Status))
{
DPRINT("NTDLL map view of secion failed ");
ZwClose(FileHandle);
return Status;
}
ZwClose(FileHandle);
DllDesc = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(DLL));
DllDesc->Headers = NTHeaders;
DllDesc->BaseAddress = ImageBase;
DllDesc->Next = DllListHead.Next;
DllDesc->Prev = &DllListHead;
DllListHead.Next->Prev = DllDesc;
DllListHead.Next = DllDesc;
LdrPEStartup(ImageBase, SectionHandle);
*Base = DllDesc;
return(STATUS_SUCCESS);
}
static NTSTATUS LdrFindDll(PDLL* Base, PCHAR Name)
{
PIMAGE_EXPORT_DIRECTORY ExportDir;
DLL* current;
PIMAGE_OPTIONAL_HEADER OptionalHeader;
DPRINT("LdrFindDll(Name %s)\n",Name);
current = &DllListHead;
do
{
OptionalHeader = &current->Headers->OptionalHeader;
ExportDir = (PIMAGE_EXPORT_DIRECTORY)OptionalHeader->DataDirectory[
IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress;
ExportDir = ((ULONG)ExportDir + (ULONG)current->BaseAddress);
DPRINT("Scanning %s\n",ExportDir->Name + current->BaseAddress);
if (strcmp(ExportDir->Name + current->BaseAddress, Name) == 0)
{
*Base = current;
return(STATUS_SUCCESS);
}
current = current->Next;
} while (current != &DllListHead);
DPRINT("Failed to find dll %s\n",Name);
return(LdrLoadDll(Base, Name));
}
/* LdrStartup /* LdrStartup
* FUNCTION: * FUNCTION:
* Handles Process Startup Activities. * Handles Process Startup Activities.
@ -245,12 +44,14 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
DPRINT("LdrStartup(ImageBase %x, SectionHandle %x)\n",ImageBase, DPRINT("LdrStartup(ImageBase %x, SectionHandle %x)\n",ImageBase,
SectionHandle); SectionHandle);
DllListHead.BaseAddress = 0x80000000; DPRINT("&_image_base__ %x\n",&_image_base__);
DllListHead.Prev = &DllListHead; LdrDllListHead.BaseAddress = (PVOID)&_image_base__;
DllListHead.Next = &DllListHead; LdrDllListHead.Prev = &LdrDllListHead;
PEDosHeader = (PIMAGE_DOS_HEADER)DllListHead.BaseAddress; LdrDllListHead.Next = &LdrDllListHead;
DllListHead.Headers = (PIMAGE_NT_HEADERS)(DllListHead.BaseAddress + LdrDllListHead.SectionHandle = SectionHandle;
PEDosHeader->e_lfanew); PEDosHeader = (PIMAGE_DOS_HEADER)LdrDllListHead.BaseAddress;
LdrDllListHead.Headers = (PIMAGE_NT_HEADERS)(LdrDllListHead.BaseAddress +
PEDosHeader->e_lfanew);
/* If MZ header exists */ /* If MZ header exists */
PEDosHeader = (PIMAGE_DOS_HEADER) ImageBase; PEDosHeader = (PIMAGE_DOS_HEADER) ImageBase;
@ -263,10 +64,10 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
} }
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew); NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew);
__RtlInitHeap(HEAP_BASE, __RtlInitHeap((PVOID)HEAP_BASE,
NTHeaders->OptionalHeader.SizeOfHeapCommit, NTHeaders->OptionalHeader.SizeOfHeapCommit,
NTHeaders->OptionalHeader.SizeOfHeapReserve); NTHeaders->OptionalHeader.SizeOfHeapReserve);
EntryPoint = LdrPEStartup(ImageBase, SectionHandle); EntryPoint = LdrPEStartup((PVOID)ImageBase, SectionHandle);
if (EntryPoint == NULL) if (EntryPoint == NULL)
{ {
@ -278,234 +79,3 @@ VOID LdrStartup(HANDLE SectionHandle, DWORD ImageBase)
Status = EntryPoint(); Status = EntryPoint();
ZwTerminateProcess(NtCurrentProcess(),Status); ZwTerminateProcess(NtCurrentProcess(),Status);
} }
static PVOID LdrGetExportByOrdinal(PDLL Module, ULONG Ordinal)
{
PIMAGE_EXPORT_DIRECTORY ExportDir;
USHORT* ExOrdinals;
ExportDir = (Module->BaseAddress +
(Module->Headers->OptionalHeader.
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
ExOrdinals = (USHORT*)RVA(Module->BaseAddress,
ExportDir->AddressOfNameOrdinals);
return(ExOrdinals[Ordinal - ExportDir->Base]);
}
static PVOID LdrGetExportByName(PDLL Module, PUCHAR SymbolName)
{
PIMAGE_EXPORT_DIRECTORY ExportDir;
PDWORD* ExFunctions;
PDWORD* ExNames;
USHORT* ExOrdinals;
ULONG i;
PVOID ExName;
ULONG Ordinal;
DPRINT("LdrFindExport(Module %x, SymbolName %s)\n",
Module, SymbolName);
ExportDir = (Module->BaseAddress +
(Module->Headers->OptionalHeader.
DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress));
/* Get header pointers */
ExNames = (PDWORD*)RVA(Module->BaseAddress, ExportDir->AddressOfNames);
ExOrdinals = (USHORT*)RVA(Module->BaseAddress,
ExportDir->AddressOfNameOrdinals);
ExFunctions = (PDWORD*)RVA(Module->BaseAddress,
ExportDir->AddressOfFunctions);
for (i=0; i<ExportDir->NumberOfFunctions; i++)
{
ExName = RVA(Module->BaseAddress, ExNames[i]);
if (strcmp(ExName,SymbolName) == 0)
{
Ordinal = ExOrdinals[i];
return(RVA(Module->BaseAddress, ExFunctions[Ordinal]));
}
}
return(NULL);
}
static NTSTATUS LdrPerformRelocations(PIMAGE_NT_HEADERS NTHeaders,
DWORD ImageBase)
{
USHORT NumberOfEntries;
PUSHORT pValue16;
ULONG RelocationRVA;
ULONG Delta32, Offset;
PULONG pValue32;
PRELOCATION_DIRECTORY RelocationDir;
PRELOCATION_ENTRY RelocationBlock;
int i;
RelocationRVA = NTHeaders->OptionalHeader.DataDirectory[
IMAGE_DIRECTORY_ENTRY_BASERELOC].VirtualAddress;
if (RelocationRVA)
{
RelocationDir = (PRELOCATION_DIRECTORY)((PCHAR)ImageBase +
RelocationRVA);
while (RelocationDir->SizeOfBlock)
{
Delta32 = (unsigned long)(ImageBase -
NTHeaders->OptionalHeader.ImageBase);
RelocationBlock = (PRELOCATION_ENTRY)
(RelocationRVA + ImageBase + sizeof(RELOCATION_DIRECTORY));
NumberOfEntries =
(RelocationDir->SizeOfBlock - sizeof(RELOCATION_DIRECTORY)) /
sizeof(RELOCATION_ENTRY);
for (i = 0; i < NumberOfEntries; i++)
{
Offset = (RelocationBlock[i].TypeOffset & 0xfff) +
RelocationDir->VirtualAddress;
switch (RelocationBlock[i].TypeOffset >> 12)
{
case TYPE_RELOC_ABSOLUTE:
break;
case TYPE_RELOC_HIGH:
pValue16 = (PUSHORT) (ImageBase + Offset);
*pValue16 += Delta32 >> 16;
break;
case TYPE_RELOC_LOW:
pValue16 = (PUSHORT)(ImageBase + Offset);
*pValue16 += Delta32 & 0xffff;
break;
case TYPE_RELOC_HIGHLOW:
pValue32 = (PULONG) (ImageBase + Offset);
*pValue32 += Delta32;
break;
case TYPE_RELOC_HIGHADJ:
/* FIXME: do the highadjust fixup */
DPRINT("TYPE_RELOC_HIGHADJ fixup not implemented"
", sorry\n");
return(STATUS_UNSUCCESSFUL);
default:
DPRINT("unexpected fixup type\n");
return(STATUS_UNSUCCESSFUL);
}
}
RelocationRVA += RelocationDir->SizeOfBlock;
RelocationDir = (PRELOCATION_DIRECTORY)(ImageBase +
RelocationRVA);
}
}
return(STATUS_SUCCESS);
}
static NTSTATUS LdrFixupImports(PIMAGE_NT_HEADERS NTHeaders,
DWORD ImageBase)
{
PIMAGE_IMPORT_MODULE_DIRECTORY ImportModuleDirectory;
ULONG Ordinal;
PDLL Module;
NTSTATUS Status;
/* Process each import module */
ImportModuleDirectory = (PIMAGE_IMPORT_MODULE_DIRECTORY)
(ImageBase + NTHeaders->OptionalHeader.
DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
while (ImportModuleDirectory->dwRVAModuleName)
{
PVOID *ImportAddressList;
PULONG FunctionNameList;
DWORD pName;
PWORD pHint;
Status = LdrFindDll(&Module,
(PCHAR)(ImageBase +
ImportModuleDirectory->dwRVAModuleName));
if (!NT_SUCCESS(Status))
{
return 0;
}
/* Get the import address list */
ImportAddressList = (PVOID *)
(NTHeaders->OptionalHeader.ImageBase +
ImportModuleDirectory->dwRVAFunctionAddressList);
/* Get the list of functions to import */
if (ImportModuleDirectory->dwRVAFunctionNameList != 0)
{
FunctionNameList = (PULONG) (ImageBase +
ImportModuleDirectory->dwRVAFunctionNameList);
}
else
{
FunctionNameList = (PULONG) (ImageBase +
ImportModuleDirectory->dwRVAFunctionAddressList);
}
/* Walk through function list and fixup addresses */
while(*FunctionNameList != 0L)
{
if ((*FunctionNameList) & 0x80000000)
{
Ordinal = (*FunctionNameList) & 0x7fffffff;
*ImportAddressList = LdrGetExportByOrdinal(Module, Ordinal);
}
else
{
pName = (DWORD)(ImageBase + *FunctionNameList + 2);
pHint = (PWORD)(ImageBase + *FunctionNameList);
*ImportAddressList = LdrGetExportByName(Module,pName);
if ((*ImportAddressList) == NULL)
{
return(STATUS_UNSUCCESSFUL);
}
}
ImportAddressList++;
FunctionNameList++;
}
ImportModuleDirectory++;
}
return(STATUS_SUCCESS);
}
static PEPFUNC LdrPEStartup(DWORD ImageBase, HANDLE SectionHandle)
{
NTSTATUS Status;
PEPFUNC EntryPoint;
PIMAGE_DOS_HEADER DosHeader;
PIMAGE_NT_HEADERS NTHeaders;
DosHeader = (PIMAGE_DOS_HEADER) ImageBase;
NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + DosHeader->e_lfanew);
/* Initialize Image sections */
LdrMapSections(ImageBase, SectionHandle, NTHeaders);
if (ImageBase != (DWORD) NTHeaders->OptionalHeader.ImageBase)
{
Status = LdrPerformRelocations(NTHeaders, ImageBase);
if (!NT_SUCCESS(Status))
{
return(NULL);
}
}
if (NTHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].
VirtualAddress != 0)
{
Status = LdrFixupImports(NTHeaders, ImageBase);
if (!NT_SUCCESS(Status))
{
return(NULL);
}
}
EntryPoint = ImageBase + NTHeaders->OptionalHeader.AddressOfEntryPoint;
return(EntryPoint);
}

View 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 = &current->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);
}

View file

@ -1,6 +1,14 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
* FILE: lib/ntdll/main/dllmain.c
* PURPOSE:
* PROGRAMMER:
*/
#include <windows.h> #include <windows.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntdll/ntdll.h> #include <ntdll/ntdll.h>

View file

@ -19,7 +19,7 @@ OBJECTS = napi.o ldr/startup.o rtl/largeint.o rtl/namespc.o rtl/unicode.o \
string/strcat.o string/strcmp.o string/strcpy.o string/stricmp.o \ string/strcat.o string/strcmp.o string/strcpy.o string/stricmp.o \
string/strlen.o string/strncmp.o string/strncpy.o string/strnlen.o \ string/strlen.o string/strncmp.o string/strncpy.o string/strnlen.o \
string/strrchr.o string/wstring.o stubs/stubs.o rtl/heap.o \ string/strrchr.o string/wstring.o stubs/stubs.o rtl/heap.o \
rtl/critical.o rtl/mem.o rtl/critical.o rtl/mem.o ldr/utils.o
ntdll.a: $(OBJECTS) ntdll.a: $(OBJECTS)
$(AR) csr ntdll.a $(OBJECTS) $(AR) csr ntdll.a $(OBJECTS)
@ -43,4 +43,5 @@ ntdll.dll: $(DLLMAIN) $(OBJECTS)
- $(RM) temp.exp - $(RM) temp.exp
$(NM) --numeric-sort ntdll.dll > ntdll.sym $(NM) --numeric-sort ntdll.dll > ntdll.sym
#WARNINGS_ARE_ERRORS = yes
include ../../rules.mak include ../../rules.mak

View file

@ -10,6 +10,9 @@
/* INCLUDES ******************************************************************/ /* INCLUDES ******************************************************************/
#include <windows.h> #include <windows.h>
#include <ntdll/rtl.h>
#include <ntdll/ntdll.h>
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -37,5 +40,7 @@ VOID RtlLeaveCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection) WINBOOL RtlTryEntryCriticalSection(LPCRITICAL_SECTION lpCriticalSection)
{ {
UNIMPLEMENTED;
for(;;);
} }

View file

@ -28,6 +28,7 @@
#include <string.h> #include <string.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <ntdll/rtl.h>
#define NDEBUG #define NDEBUG
#include <ntdll/ntdll.h> #include <ntdll/ntdll.h>
@ -656,7 +657,7 @@ PHEAP __HeapPrepare(LPVOID base, ULONG minsize, ULONG maxsize, ULONG flags)
* Called by __VirtualInit to initialize the default process heap * * Called by __VirtualInit to initialize the default process heap *
*********************************************************************/ *********************************************************************/
VOID WINAPI __RtlInitHeap(LPVOID base, ULONG minsize, ULONG maxsize) VOID WINAPI __RtlInitHeap(PVOID base, ULONG minsize, ULONG maxsize)
{ {
NTSTATUS Result; NTSTATUS Result;
PHEAP NewHeap; PHEAP NewHeap;
@ -952,7 +953,7 @@ UINT RtlCompactHeap(HANDLE hheap, DWORD flags)
/********************************************************************* /*********************************************************************
* HeapSize -- KERNEL32 * * HeapSize -- KERNEL32 *
*********************************************************************/ *********************************************************************/
DWORD WINAPI RtlSizeHeap(HANDLE hheap, DWORD flags, LPCVOID pmem) DWORD WINAPI RtlSizeHeap(HANDLE hheap, DWORD flags, PVOID pmem)
{ {
PHEAP pheap=(PHEAP) hheap; PHEAP pheap=(PHEAP) hheap;
PHEAP_BLOCK palloc=((PHEAP_BLOCK)pmem-1); PHEAP_BLOCK palloc=((PHEAP_BLOCK)pmem-1);
@ -992,7 +993,7 @@ DWORD WINAPI RtlSizeHeap(HANDLE hheap, DWORD flags, LPCVOID pmem)
* * * *
* NOTE: only implemented in NT * * NOTE: only implemented in NT *
*********************************************************************/ *********************************************************************/
BOOL WINAPI RtlValidateHeap(HANDLE hheap, DWORD flags, LPCVOID pmem) BOOL WINAPI RtlValidateHeap(HANDLE hheap, DWORD flags, PVOID pmem)
{ {
PHEAP pheap=(PHEAP)hheap; PHEAP pheap=(PHEAP)hheap;
PHEAP_BLOCK pcheck; PHEAP_BLOCK pcheck;

View file

@ -48,7 +48,7 @@ VOID RtlCopyBytes(PVOID Destination,
RtlCopyMemory(Destination,Source,Length); RtlCopyMemory(Destination,Source,Length);
} }
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length) VOID RtlCopyMemory(VOID* Destination, CONST VOID* Source, ULONG Length)
{ {
DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n", DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n",
Destination,Source,Length); Destination,Source,Length);

View file

@ -9,20 +9,18 @@
*/ */
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
#define Aa_Difference ('A'-'a') #define Aa_Difference ('A'-'a')
PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest, extern unsigned long simple_strtoul(const char *cp,
PUNICODE_STRING Src) char **endp,
{ unsigned int base);
if (Dest==NULL)
{
// Dest=ExAllocatePool(NonPagedPool,sizeof(UNICODE_STRING));
}
}
WCHAR wtoupper(WCHAR c) WCHAR wtoupper(WCHAR c)
{ {
@ -120,8 +118,9 @@ NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value) NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
{ {
*Value=simple_strtoul((const char *)String, NULL, Base); *Value = simple_strtoul((const char *)String, NULL, Base);
}; return(STATUS_SUCCESS);
}
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive) LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
{ {
@ -339,26 +338,27 @@ VOID RtlInitString(IN OUT PSTRING DestinationString,
DestinationString->Length=strlen((char *)SourceString); DestinationString->Length=strlen((char *)SourceString);
DestinationString->MaximumLength=strlen((char *)SourceString)+1; DestinationString->MaximumLength=strlen((char *)SourceString)+1;
DestinationString->Buffer=SourceString; DestinationString->Buffer=SourceString;
}; }
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString) IN PCWSTR SourceString)
{ {
unsigned long i, DestSize; unsigned long DestSize;
UNICODE_STRING Dest=*DestinationString;
if (SourceString == NULL)
if(SourceString==NULL) { {
DestinationString->Length=0; DestinationString->Length = 0;
DestinationString->MaximumLength=0; DestinationString->MaximumLength = 0;
DestinationString->Buffer=NULL; DestinationString->Buffer = NULL;
} else { }
DestSize=wcslen((PWSTR)SourceString); else
DestinationString->Length=DestSize; {
DestinationString->MaximumLength=DestSize+1; DestSize = wcslen((PWSTR)SourceString);
DestinationString->Length = DestSize;
DestinationString->Buffer=(PWSTR)SourceString; DestinationString->MaximumLength = DestSize+1;
}; DestinationString->Buffer = (PWSTR)SourceString;
}; }
}
NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */
IN OUT PUNICODE_STRING String) IN OUT PUNICODE_STRING String)
@ -366,17 +366,17 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
char *str; char *str;
unsigned long len, i; unsigned long len, i;
// str=ExAllocatePool(NonPagedPool, 1024); str = RtlAllocateHeap(RtlGetProcessHeap, 0, 1024);
if(Base==16) { if(Base==16) {
sprintf(str, "%x", Value); sprintf(str, "%x", (unsigned int)Value);
} else } else
if(Base==8) { if(Base==8) {
sprintf(str, "%o", Value); sprintf(str, "%o", (unsigned int)Value);
} else } else
if(Base==2) { if(Base==2) {
sprintf(str, "%b", Value); // sprintf(str, "%b", Value);
} else { } else {
sprintf(str, "%u", Value); sprintf(str, "%u", (unsigned int)Value);
}; };
len=strlen(str); len=strlen(str);
@ -394,7 +394,7 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
// ExFreePool(str); // ExFreePool(str);
return STATUS_SUCCESS; return STATUS_SUCCESS;
}; }
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString, NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString, IN PUNICODE_STRING SourceString,
@ -427,59 +427,61 @@ NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base, NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
OUT PULONG Value) OUT PULONG Value)
{ {
char *str; char *str;
unsigned long i, lenmin=0; unsigned long i, lenmin=0;
BOOLEAN addneg=FALSE; BOOLEAN addneg=FALSE;
// str=ExAllocatePool(NonPagedPool, String->Length+1); str=RtlAllocateHeap(RtlGetProcessHeap(), 0, String->Length+1);
for(i=0; i<String->Length; i++) { for(i=0; i<String->Length; i++)
*str=*String->Buffer; {
*str=*String->Buffer;
if(*str=='b') { Base=2; lenmin++; } else
if(*str=='o') { Base=8; lenmin++; } else if(*str=='b') { Base=2; lenmin++; } else
if(*str=='d') { Base=10; lenmin++; } else if(*str=='o') { Base=8; lenmin++; } else
if(*str=='x') { Base=16; lenmin++; } else if(*str=='d') { Base=10; lenmin++; } else
if(*str=='+') { lenmin++; } else if(*str=='x') { Base=16; lenmin++; } else
if(*str=='-') { addneg=TRUE; lenmin++; } else if(*str=='+') { lenmin++; } else
if((*str>'1') && (Base==2)) { if(*str=='-') { addneg=TRUE; lenmin++; } else
String->Buffer-=i; if((*str>'1') && (Base==2)) {
*Value=0; String->Buffer-=i;
return STATUS_INVALID_PARAMETER; *Value=0;
} else return STATUS_INVALID_PARAMETER;
if(((*str>'7') || (*str<'0')) && (Base==8)) { } else
String->Buffer-=i; if(((*str>'7') || (*str<'0')) && (Base==8)) {
*Value=0; String->Buffer-=i;
return STATUS_INVALID_PARAMETER; *Value=0;
} else return STATUS_INVALID_PARAMETER;
if(((*str>'9') || (*str<'0')) && (Base==10)) { } else
String->Buffer-=i; if(((*str>'9') || (*str<'0')) && (Base==10)) {
*Value=0; String->Buffer-=i;
return STATUS_INVALID_PARAMETER; *Value=0;
} else return STATUS_INVALID_PARAMETER;
if((((*str>'9') || (*str<'0')) || } else
((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16)) if((((*str>'9') || (*str<'0')) ||
{ ((toupper(*str)>'F') || (toupper(*str)<'A'))) && (Base==16))
String->Buffer-=i; {
*Value=0; String->Buffer-=i;
return STATUS_INVALID_PARAMETER; *Value=0;
} else return STATUS_INVALID_PARAMETER;
str++; } else
str++;
String->Buffer++;
String->Buffer++;
}; };
*str=0; *str=0;
String->Buffer-=String->Length; String->Buffer-=String->Length;
str-=(String->Length-lenmin); str-=(String->Length-lenmin);
if(addneg==TRUE) { if(addneg==TRUE) {
*Value=simple_strtoul(str, NULL, Base)*-1; *Value=simple_strtoul(str, NULL, Base)*-1;
} else } else
*Value=simple_strtoul(str, NULL, Base); *Value=simple_strtoul(str, NULL, Base);
// ExFreePool(str); // ExFreePool(str);
}; return(STATUS_SUCCESS);
}
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString, NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString, IN PUNICODE_STRING SourceString,

View file

@ -16,9 +16,12 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <string.h>
#include <internal/debug.h> #include <internal/debug.h>
extern size_t strnlen(const char* string, size_t maxlen);
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base) unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base)
{ {
unsigned long result = 0,value; unsigned long result = 0,value;
@ -70,70 +73,86 @@ __res = ((unsigned long) n) % (unsigned) base; \
n = ((unsigned long) n) / (unsigned) base; \ n = ((unsigned long) n) / (unsigned) base; \
__res; }) __res; })
static char * number(char * str, long num, int base, int size, int precision static char * number(char * str, long num, int base, int size, int precision,
,int type) int type)
{ {
char c,sign,tmp[66]; char c,sign,tmp[66];
const char *digits="0123456789abcdefghijklmnopqrstuvwxyz"; const char *digits="0123456789abcdefghijklmnopqrstuvwxyz";
int i; int i;
if (type & LARGE) if (type & LARGE)
digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
if (type & LEFT) if (type & LEFT)
type &= ~ZEROPAD; type &= ~ZEROPAD;
if (base < 2 || base > 36) if (base < 2 || base > 36)
return 0; return 0;
c = (type & ZEROPAD) ? '0' : ' ';
sign = 0; c = (type & ZEROPAD) ? '0' : ' ';
if (type & SIGN) { sign = 0;
if (num < 0) {
sign = '-'; if (type & SIGN)
num = -num; {
size--; if (num < 0)
} else if (type & PLUS) { {
sign = '+'; sign = '-';
size--; num = -num;
} else if (type & SPACE) { size--;
sign = ' '; }
size--; else if (type & PLUS)
} {
} sign = '+';
if (type & SPECIAL) { size--;
if (base == 16) }
size -= 2; else if (type & SPACE)
else if (base == 8) {
size--; sign = ' ';
} size--;
i = 0; }
if (num == 0) }
tmp[i++]='0';
else while (num != 0) if (type & SPECIAL)
tmp[i++] = digits[do_div(num,base)]; {
if (i > precision) if (base == 16)
precision = i; size -= 2;
size -= precision; else if (base == 8)
if (!(type&(ZEROPAD+LEFT))) size--;
while(size-->0) }
*str++ = ' ';
if (sign) i = 0;
*str++ = sign; if (num == 0)
if (type & SPECIAL) tmp[i++]='0';
if (base==8) else while (num != 0)
*str++ = '0'; tmp[i++] = digits[do_div(num,base)];
else if (base==16) { if (i > precision)
*str++ = '0'; precision = i;
*str++ = digits[33]; size -= precision;
} if (!(type&(ZEROPAD+LEFT)))
if (!(type & LEFT)) while(size-->0)
while (size-- > 0) *str++ = ' ';
*str++ = c; if (sign)
while (i < precision--) *str++ = sign;
*str++ = '0'; if (type & SPECIAL)
while (i-- > 0) {
*str++ = tmp[i]; if (base==8)
while (size-- > 0) {
*str++ = ' '; *str++ = '0';
return str; }
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) int vsprintf(char *buf, const char *fmt, va_list args)
@ -351,17 +370,18 @@ int wsprintfA(char * buf, const char *fmt, ...)
return i; return i;
} }
#if 0
int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...) int wsprintfW(unsigned short * buf, const unsigned short *fmt, ...)
{ {
va_list args; va_list args;
int i; int i;
va_start(args, fmt); va_start(args, fmt);
//i=vsprintf(buf,fmt,args); //i=vsprintf(buf,fmt,args);
va_end(args); va_end(args);
return i; return i;
} }
#endif
unsigned short towupper(unsigned short w) unsigned short towupper(unsigned short w)
{ {

View file

@ -14,15 +14,17 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <wchar.h> #include <wchar.h>
static wchar_t * ___wcstok = NULL; /* GLOBALS *******************************************************************/
// static wchar_t * ___wcstok = NULL;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
int wcsicmp(const wchar_t* ws1, const wchar_t* ws2) int wcsnicmp(const wchar_t* ws1, const wchar_t* ws2, size_t size)
{ {
} }
int wcsnicmp(const wchar_t* ws1, const wchar_t* ws2, size_t size) int wcsicmp(const wchar_t* ws1, const wchar_t* ws2)
{ {
} }
@ -41,14 +43,13 @@ wchar_t* wcscat(wchar_t *dest, const wchar_t *src)
return dest; return dest;
} }
wchar_t * wchar_t* wcschr(const wchar_t *str, wchar_t ch)
wcschr(const wchar_t *str, wchar_t ch)
{ {
while ((*str) != ((wchar_t) 0)) while ((*str) != ((wchar_t) 0))
{ {
if ((*str) == ch) if ((*str) == ch)
{ {
return str; return (wchar_t *)str;
} }
str++; str++;
} }
@ -56,8 +57,7 @@ wcschr(const wchar_t *str, wchar_t ch)
return NULL; return NULL;
} }
int int wcscmp(const wchar_t *cs, const wchar_t *ct)
wcscmp(const wchar_t *cs, const wchar_t *ct)
{ {
while (*cs != '\0' && *ct != '\0' && *cs == *ct) while (*cs != '\0' && *ct != '\0' && *cs == *ct)
{ {

View file

@ -62,7 +62,6 @@ STUB(PfxInitialize)
STUB(PfxInsertPrefix) STUB(PfxInsertPrefix)
STUB(PfxRemovePrefix) STUB(PfxRemovePrefix)
STUB(RestoreEm87Context) STUB(RestoreEm87Context)
STUB(RtlValidateHeap)
STUB(RtlValidateProcessHeaps) STUB(RtlValidateProcessHeaps)
STUB(RtlWalkHeap) STUB(RtlWalkHeap)
STUB(RtlZeroHeap) STUB(RtlZeroHeap)

View file

@ -14,7 +14,7 @@ include rules.mak
# #
# Required to run the system # Required to run the system
# #
COMPONENTS = iface_native ntoskrnl kernel32 ntdll COMPONENTS = iface_native ntoskrnl ntdll kernel32
# #
# Select the server(s) you want to build # Select the server(s) you want to build

View file

@ -25,6 +25,7 @@ static ULONG CbHash(PDCCB Dccb, ULONG BlockNr)
return(BlockNr % Dccb->HashTblSize); return(BlockNr % Dccb->HashTblSize);
} }
#if 0
static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb) static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb)
{ {
KIRQL oldlvl; KIRQL oldlvl;
@ -33,6 +34,7 @@ static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb)
Ccb->References--; Ccb->References--;
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl); KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
} }
#endif
static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr) static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr)
{ {
@ -49,6 +51,7 @@ static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr)
return(Ccb); return(Ccb);
} }
#if 0
static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb) static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb)
{ {
KIRQL oldlvl; KIRQL oldlvl;
@ -67,7 +70,7 @@ static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb)
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl); KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
return(Status); return(Status);
} }
#endif
static BOOLEAN CbLockForWrite(PCCB Ccb) static BOOLEAN CbLockForWrite(PCCB Ccb)
{ {
@ -126,11 +129,13 @@ static BOOLEAN CbLockForDelete(PDCCB Dccb, PCCB Ccb)
return(TRUE); return(TRUE);
} }
#if 0
static VOID CbUnlockForDelete(PDCCB Dccb, PCCB Ccb) static VOID CbUnlockForDelete(PDCCB Dccb, PCCB Ccb)
{ {
Ccb->ActiveWriter = FALSE; Ccb->ActiveWriter = FALSE;
KeSetEvent(&Ccb->FinishedNotify,IO_NO_INCREMENT,FALSE); KeSetEvent(&Ccb->FinishedNotify,IO_NO_INCREMENT,FALSE);
} }
#endif
VOID CbAcquireForDelete(PDCCB Dccb, PCCB Ccb) VOID CbAcquireForDelete(PDCCB Dccb, PCCB Ccb)
/* /*
@ -234,6 +239,7 @@ PCCB CbFindModifiedCcb(PDCCB Dccb, PCCB Start)
UNIMPLEMENTED; UNIMPLEMENTED;
} }
#if 0
static VOID CbDeleteAllCcbs(PDCCB Dccb) static VOID CbDeleteAllCcbs(PDCCB Dccb)
/* /*
* FUNCTION: Delete all the ccbs associated with a dccb * FUNCTION: Delete all the ccbs associated with a dccb
@ -261,7 +267,9 @@ static VOID CbDeleteAllCcbs(PDCCB Dccb)
ExFreePool(Ccb); ExFreePool(Ccb);
} }
} }
#endif
#if 0
static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb) static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb)
{ {
KIRQL oldlvl; KIRQL oldlvl;
@ -279,7 +287,9 @@ static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb)
KeReleaseSpinLock(&Dccb->CcbListLock,oldlvl); KeReleaseSpinLock(&Dccb->CcbListLock,oldlvl);
ExFreePool(Ccb); ExFreePool(Ccb);
} }
#endif
#if 0
static VOID CbReclaimMemory(PDCCB Dccb) static VOID CbReclaimMemory(PDCCB Dccb)
{ {
PCCB RedundantCcbs[25]; PCCB RedundantCcbs[25];
@ -323,7 +333,9 @@ static VOID CbReclaimMemory(PDCCB Dccb)
CbFreeCcb(Dccb,RedundantCcbs[i]); CbFreeCcb(Dccb,RedundantCcbs[i]);
} }
} }
#endif
#if 0
static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb) static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb)
/* /*
* FUNCTION: Deletes a CCB * FUNCTION: Deletes a CCB
@ -338,6 +350,7 @@ static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb)
CbAcquireForDelete(Dccb,Ccb); CbAcquireForDelete(Dccb,Ccb);
Ccb->State = CCB_DELETE_PENDING; Ccb->State = CCB_DELETE_PENDING;
} }
#endif
VOID CbReinitCcb(PDCCB Dccb, PCCB Ccb, ULONG BlockNr) VOID CbReinitCcb(PDCCB Dccb, PCCB Ccb, ULONG BlockNr)
{ {

View file

@ -273,6 +273,7 @@ ZwCreateKey(PHANDLE KeyHandle,
NTSTATUS NtDeleteKey(HANDLE KeyHandle) NTSTATUS NtDeleteKey(HANDLE KeyHandle)
{ {
return(ZwDeleteKey(KeyHandle));
} }
NTSTATUS ZwDeleteKey(HANDLE KeyHandle) NTSTATUS ZwDeleteKey(HANDLE KeyHandle)
@ -280,15 +281,23 @@ NTSTATUS ZwDeleteKey(HANDLE KeyHandle)
UNIMPLEMENTED; UNIMPLEMENTED;
} }
NTSTATUS NtEnumerateKey(HANDLE KeyHandle, ULONG Index, NTSTATUS NtEnumerateKey(HANDLE KeyHandle,
ULONG Index,
KEY_INFORMATION_CLASS KeyInformationClass, KEY_INFORMATION_CLASS KeyInformationClass,
PVOID KeyInformation, PVOID KeyInformation,
ULONG Length, ULONG Length,
PULONG ResultLength) PULONG ResultLength)
{ {
return(ZwEnumerateKey(KeyHandle,
Index,
KeyInformationClass,
KeyInformation,
Length,
ResultLength));
} }
NTSTATUS ZwEnumerateKey(HANDLE KeyHandle, ULONG Index, NTSTATUS ZwEnumerateKey(HANDLE KeyHandle,
ULONG Index,
KEY_INFORMATION_CLASS KeyInformationClass, KEY_INFORMATION_CLASS KeyInformationClass,
PVOID KeyInformation, PVOID KeyInformation,
ULONG Length, ULONG Length,

View file

@ -61,7 +61,7 @@ VOID ExReleaseFastMutex(PFAST_MUTEX FastMutex)
BOOLEAN ExTryToAcquireFastMutex(PFAST_MUTEX FastMutex) BOOLEAN ExTryToAcquireFastMutex(PFAST_MUTEX FastMutex)
{ {
InterlockedCompareExchange(&(FastMutex->Count),0,0); UNIMPLEMENTED;
} }

View file

@ -73,6 +73,7 @@ ULONG ExGetSharedWaiterCount(PERESOURCE Resource)
NTSTATUS ExInitializeResource(PERESOURCE Resource) NTSTATUS ExInitializeResource(PERESOURCE Resource)
{ {
UNIMPLEMENTED;
} }
NTSTATUS ExInitializeResourceLite(PERESOURCE Resource) NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
@ -81,10 +82,17 @@ NTSTATUS ExInitializeResourceLite(PERESOURCE Resource)
Resource->NumberOfExclusiveWaiters = 0; Resource->NumberOfExclusiveWaiters = 0;
KeInitializeSpinLock(&Resource->SpinLock); KeInitializeSpinLock(&Resource->SpinLock);
Resource->Flag=0; Resource->Flag=0;
KeInitializeEvent(&Resource->ExclusiveWaiters,SynchronizationEvent, Resource->ExclusiveWaiters = ExAllocatePool(NonPagedPool,
sizeof(KEVENT));
KeInitializeEvent(Resource->ExclusiveWaiters,
SynchronizationEvent,
FALSE); FALSE);
KeInitializeSemaphore(&Resource->SharedWaiters,5,0); Resource->SharedWaiters = ExAllocatePool(NonPagedPool,
sizeof(KSEMAPHORE));
KeInitializeSemaphore(Resource->SharedWaiters,5,0);
Resource->ActiveCount = 0; Resource->ActiveCount = 0;
return(STATUS_SUCCESS);
} }
BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource) BOOLEAN ExIsResourceAcquiredExclusiveLite(PERESOURCE Resource)

View file

@ -45,7 +45,7 @@ typedef struct
/* /*
* PURPOSE: Queue of items waiting to be processed at normal priority * PURPOSE: Queue of items waiting to be processed at normal priority
*/ */
WORK_QUEUE normal_work_queue = {0,}; WORK_QUEUE normal_work_queue = {{0,}};
#define WAIT_INTERVAL (0) #define WAIT_INTERVAL (0)

View file

@ -27,8 +27,8 @@ ExAllocateFromNPagedLookasideList
ExAllocateFromPagedLookasideList ExAllocateFromPagedLookasideList
ExAllocateFromZone ExAllocateFromZone
ExAllocatePool ExAllocatePool
ExAllocatePoolWithQuota #ExAllocatePoolWithQuota
ExAllocatePoolWithQuotaTag #ExAllocatePoolWithQuotaTag
ExAllocatePoolWithTag ExAllocatePoolWithTag
ExConvertExclusiveToSharedLite ExConvertExclusiveToSharedLite
ExDeleteNPagedLookasideList ExDeleteNPagedLookasideList
@ -88,11 +88,11 @@ InterlockedCompareExchange
InterlockedExchange InterlockedExchange
InterlockedExchangeAdd InterlockedExchangeAdd
InterlockedIncrement InterlockedIncrement
HalAllocateCommonBuffer #HalAllocateCommonBuffer
HalAssignSlotResources HalAssignSlotResources
HalExamineMBR HalExamineMBR
HalFreeCommonBuffer #HalFreeCommonBuffer
HalGetAdapter #HalGetAdapter
HalGetBusData HalGetBusData
HalGetBusDataByOffset HalGetBusDataByOffset
HalGetDmaAlignmentRequirement HalGetDmaAlignmentRequirement
@ -319,7 +319,7 @@ RtlFreeUnicodeString
RtlInitAnsiString RtlInitAnsiString
RtlInitString RtlInitString
RtlInitUnicodeString RtlInitUnicodeString
RtlIntegerToUnicodeString #RtlIntegerToUnicodeString
RtlLargeIntegerAdd RtlLargeIntegerAdd
RtlLargeIntegerAnd RtlLargeIntegerAnd
RtlLargeIntegerArithmeticShift RtlLargeIntegerArithmeticShift

View file

@ -50,6 +50,7 @@ ULONG HalGetDmaAlignmentRequirement()
return(1); return(1);
} }
#if 0
PVOID HalAllocateCommonBuffer(PADAPTER_OBJECT AdapterObject, PVOID HalAllocateCommonBuffer(PADAPTER_OBJECT AdapterObject,
ULONG Length, ULONG Length,
PPHYSICAL_ADDRESS LogicalAddress, PPHYSICAL_ADDRESS LogicalAddress,
@ -115,6 +116,7 @@ PADAPTER_OBJECT HalGetAdapter(PDEVICE_DESCRIPTION DeviceDescription,
RtlCopyMemory(&adapter->desc,DeviceDescription,sizeof(DEVICE_DESCRIPTION)); RtlCopyMemory(&adapter->desc,DeviceDescription,sizeof(DEVICE_DESCRIPTION));
*/ */
} }
#endif
ULONG HalReadDmaCounter(PADAPTER_OBJECT AdapterObject) ULONG HalReadDmaCounter(PADAPTER_OBJECT AdapterObject)
{ {

View file

@ -25,6 +25,7 @@ static KIRQL CurrentIrql = HIGH_LEVEL;
/* FUNCTIONS ****************************************************************/ /* FUNCTIONS ****************************************************************/
#if 0
static unsigned int HiGetCurrentPICMask(void) static unsigned int HiGetCurrentPICMask(void)
{ {
unsigned int mask; unsigned int mask;
@ -34,6 +35,7 @@ static unsigned int HiGetCurrentPICMask(void)
return mask; return mask;
} }
#endif
static unsigned int HiSetCurrentPICMask(unsigned int mask) static unsigned int HiSetCurrentPICMask(unsigned int mask)
{ {

View file

@ -124,7 +124,7 @@ PHYSICAL_ADDRESS MmGetPhysicalAddress(PVOID vaddr)
* FUNCTION: Returns the physical address corresponding to a virtual address * FUNCTION: Returns the physical address corresponding to a virtual address
*/ */
{ {
PHYSICAL_ADDRESS p; PHYSICAL_ADDRESS p = INITIALIZE_LARGE_INTEGER;
DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr); DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr);

View file

@ -13,6 +13,7 @@
#include <internal/ke.h> #include <internal/ke.h>
#include <internal/bitops.h> #include <internal/bitops.h>
#include <internal/linkage.h> #include <internal/linkage.h>
#include <string.h>
#include <internal/string.h> #include <internal/string.h>
#include <internal/i386/segment.h> #include <internal/i386/segment.h>

View file

@ -41,12 +41,12 @@ BOOLEAN IoCancelIrp(PIRP Irp)
IoAcquireCancelSpinLock(&oldlvl); IoAcquireCancelSpinLock(&oldlvl);
Irp->Cancel = TRUE; Irp->Cancel = TRUE;
if (Irp->CancelRoutine==NULL) if (Irp->CancelRoutine == NULL)
{ {
return(FALSE); return(FALSE);
} }
Irp->CancelRoutine(Irp->Stack[0].DeviceObject,Irp); Irp->CancelRoutine(Irp->Stack[0].DeviceObject, Irp);
IoReleaseCancelSpinLock(&oldlvl); IoReleaseCancelSpinLock(oldlvl);
return(TRUE); return(TRUE);
} }

View file

@ -177,7 +177,6 @@ NTSTATUS IopCreateDevice(PVOID ObjectBody,
PWSTR RemainingPath, PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes) POBJECT_ATTRIBUTES ObjectAttributes)
{ {
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)ObjectBody;
DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n", DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",
ObjectBody, Parent, RemainingPath); ObjectBody, Parent, RemainingPath);

View file

@ -27,12 +27,14 @@ VOID MmUnlockPagableImageSection(PVOID ImageSectionHandle)
* MmLockPagableDataSection * MmLockPagableDataSection
*/ */
{ {
MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle); // MmUnlockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
UNIMPLEMENTED;
} }
VOID MmLockPagableSectionByHandle(PVOID ImageSectionHandle) VOID MmLockPagableSectionByHandle(PVOID ImageSectionHandle)
{ {
MmLockMemoryArea((MEMORY_AREA *)ImageSectionHandle); // MmLockMemoryArea((MEMORY_AREA *)ImageSectionHandle);
UNIMPLEMENTED;
} }
PVOID MmLockPagableCodeSection(PVOID AddressWithinSection) PVOID MmLockPagableCodeSection(PVOID AddressWithinSection)

View file

@ -17,116 +17,100 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS NTSTATUS STDCALL NtCreateIoCompletion(OUT PHANDLE CompletionPort,
STDCALL IN ACCESS_MASK DesiredAccess,
NtCreateIoCompletion( OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PHANDLE CompletionPort, IN ULONG NumberOfConcurrentThreads)
IN ACCESS_MASK DesiredAccess,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG NumberOfConcurrentThreads
)
{ {
return(ZwCreateIoCompletion(CompletionPort,
DesiredAccess,
IoStatusBlock,
NumberOfConcurrentThreads));
} }
NTSTATUS NTSTATUS STDCALL ZwCreateIoCompletion(OUT PHANDLE CompletionPort,
STDCALL IN ACCESS_MASK DesiredAccess,
ZwCreateIoCompletion( OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PHANDLE CompletionPort, IN ULONG NumberOfConcurrentThreads)
IN ACCESS_MASK DesiredAccess,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG NumberOfConcurrentThreads
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtOpenIoCompletion(OUT PHANDLE CompletionPort,
STDCALL IN ACCESS_MASK DesiredAccess,
NtOpenIoCompletion( IN POBJECT_ATTRIBUTES ObjectAttributes)
OUT PHANDLE CompetionPort,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
)
{ {
return(ZwOpenIoCompletion(CompletionPort,
DesiredAccess,
ObjectAttributes));
} }
NTSTATUS NTSTATUS STDCALL ZwOpenIoCompletion(OUT PHANDLE CompetionPort,
STDCALL IN ACCESS_MASK DesiredAccess,
ZwOpenIoCompletion( IN POBJECT_ATTRIBUTES ObjectAttributes)
OUT PHANDLE CompetionPort,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes
)
{ {
return(STATUS_SUCCESS);
} }
NTSTATUS NTSTATUS STDCALL NtQueryIoCompletion(IN HANDLE CompletionPort,
STDCALL IN ULONG CompletionKey,
NtQueryIoCompletion( OUT PIO_STATUS_BLOCK IoStatusBlock,
IN HANDLE CompletionPort, OUT PULONG NumberOfBytesTransferred)
IN ULONG CompletionKey,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PULONG NumberOfBytesTransferred
)
{ {
return(ZwQueryIoCompletion(CompletionPort,
return ZwQueryIoCompletion(CompletionPort,CompletionKey,IoStatusBlock,NumberOfBytesTransferred); CompletionKey,
IoStatusBlock,
NumberOfBytesTransferred));
} }
NTSTATUS NTSTATUS STDCALL ZwQueryIoCompletion(IN HANDLE CompletionPort,
STDCALL IN ULONG CompletionKey,
ZwQueryIoCompletion( OUT PIO_STATUS_BLOCK IoStatusBlock,
IN HANDLE CompletionPort, OUT PULONG NumberOfBytesTransferred)
IN ULONG CompletionKey,
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PULONG NumberOfBytesTransferred
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS
STDCALL NTSTATUS STDCALL NtRemoveIoCompletion(IN HANDLE CompletionPort,
NtRemoveIoCompletion( OUT PULONG CompletionKey,
IN HANDLE CompletionPort, OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PULONG CompletionKey, OUT PULONG CompletionStatus,
OUT PIO_STATUS_BLOCK IoStatusBlock, PLARGE_INTEGER WaitTime)
OUT PULONG CompletionStatus,
PLARGE_INTEGER WaitTime
)
{ {
return(ZwRemoveIoCompletion(CompletionPort,
CompletionKey,
IoStatusBlock,
CompletionStatus,
WaitTime));
} }
NTSTATUS NTSTATUS STDCALL ZwRemoveIoCompletion(IN HANDLE CompletionPort,
STDCALL OUT PULONG CompletionKey,
ZwRemoveIoCompletion( OUT PIO_STATUS_BLOCK IoStatusBlock,
IN HANDLE CompletionPort, OUT PULONG CompletionStatus,
OUT PULONG CompletionKey, PLARGE_INTEGER WaitTime)
OUT PIO_STATUS_BLOCK IoStatusBlock,
OUT PULONG CompletionStatus,
PLARGE_INTEGER WaitTime
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtSetIoCompletion(IN HANDLE CompletionPort,
STDCALL IN ULONG CompletionKey,
NtSetIoCompletion( OUT PIO_STATUS_BLOCK IoStatusBlock,
IN HANDLE CompletionPort, IN ULONG NumberOfBytesToTransfer,
IN ULONG CompletionKey, OUT PULONG NumberOfBytesTransferred)
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG NumberOfBytesToTransfer,
OUT PULONG NumberOfBytesTransferred
)
{ {
return(ZwSetIoCompletion(CompletionPort,
CompletionKey,
IoStatusBlock,
NumberOfBytesToTransfer,
NumberOfBytesTransferred));
} }
NTSTATUS NTSTATUS STDCALL ZwSetIoCompletion(IN HANDLE CompletionPort,
STDCALL IN ULONG CompletionKey,
ZwSetIoCompletion( OUT PIO_STATUS_BLOCK IoStatusBlock,
IN HANDLE CompletionPort, IN ULONG NumberOfBytesToTransfer,
IN ULONG CompletionKey, OUT PULONG NumberOfBytesTransferred)
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG NumberOfBytesToTransfer,
OUT PULONG NumberOfBytesTransferred
)
{ {
UNIMPLEMENTED;
} }

View file

@ -84,7 +84,7 @@ VOID IoMarkIrpPending(PIRP Irp)
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n", DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
IoGetCurrentIrpStackLocation(Irp)); IoGetCurrentIrpStackLocation(Irp));
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED; IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
Irp->Tail.Overlay.Thread = KeGetCurrentThread(); Irp->Tail.Overlay.Thread = PsGetCurrentThread();
DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n", DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n",
IoGetCurrentIrpStackLocation(Irp)->Control); IoGetCurrentIrpStackLocation(Irp)->Control);
DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED); DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED);
@ -132,7 +132,7 @@ PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
Irp->CurrentLocation, Irp->CurrentLocation,
Irp->StackCount); Irp->StackCount);
return &Irp->Stack[Irp->CurrentLocation]; return &Irp->Stack[(ULONG)Irp->CurrentLocation];
} }
@ -202,7 +202,8 @@ PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)
if (ChargeQuota) if (ChargeQuota)
{ {
Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize)); // Irp = ExAllocatePoolWithQuota(NonPagedPool,IoSizeOfIrp(StackSize));
Irp = ExAllocatePool(NonPagedPool,IoSizeOfIrp(StackSize));
} }
else else
{ {

View file

@ -17,32 +17,33 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS NTSTATUS STDCALL NtCreateMailslotFile(OUT PHANDLE MailSlotFileHandle,
STDCALL IN ACCESS_MASK DesiredAccess,
NtCreateMailslotFile( IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PHANDLE MailSlotFileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ACCESS_MASK DesiredAccess, IN ULONG FileAttributes,
IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG ShareAccess,
OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG MaxMessageSize,
IN ULONG FileAttributes, IN PLARGE_INTEGER TimeOut)
IN ULONG ShareAccess,
IN ULONG MaxMessageSize,
IN PLARGE_INTEGER TimeOut
)
{ {
return(ZwCreateMailslotFile(MailSlotFileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
FileAttributes,
ShareAccess,
MaxMessageSize,
TimeOut));
} }
NTSTATUS NTSTATUS STDCALL ZwCreateMailslotFile(OUT PHANDLE MailSlotFileHandle,
STDCALL IN ACCESS_MASK DesiredAccess,
ZwCreateMailslotFile( IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PHANDLE MailSlotFileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ACCESS_MASK DesiredAccess, IN ULONG FileAttributes,
IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG ShareAccess,
OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG MaxMessageSize,
IN ULONG FileAttributes, IN PLARGE_INTEGER TimeOut)
IN ULONG ShareAccess,
IN ULONG MaxMessageSize,
IN PLARGE_INTEGER TimeOut
)
{ {
UNIMPLEMENTED;
} }

View file

@ -27,8 +27,9 @@ PMDL IoAllocateMdl(PVOID VirtualAddress,
if (ChargeQuota) if (ChargeQuota)
{ {
Mdl = ExAllocatePoolWithQuota(NonPagedPool, // Mdl = ExAllocatePoolWithQuota(NonPagedPool,
MmSizeOfMdl(VirtualAddress,Length)); // MmSizeOfMdl(VirtualAddress,Length));
Mdl = ExAllocatePool(NonPagedPool,MmSizeOfMdl(VirtualAddress,Length));
} }
else else
{ {

View file

@ -16,44 +16,51 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS NTSTATUS STDCALL NtCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
STDCALL IN ACCESS_MASK DesiredAccess,
NtCreateNamedPipeFile( IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PHANDLE NamedPipeFileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ACCESS_MASK DesiredAccess, IN ULONG FileAttributes,
IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG ShareAccess,
OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG OpenMode,
IN ULONG FileAttributes, IN ULONG PipeType,
IN ULONG ShareAccess, IN ULONG PipeRead,
IN ULONG OpenMode, IN ULONG PipeWait,
IN ULONG PipeType, IN ULONG MaxInstances,
IN ULONG PipeRead, IN ULONG InBufferSize,
IN ULONG PipeWait, IN ULONG OutBufferSize,
IN ULONG MaxInstances, IN PLARGE_INTEGER TimeOut)
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 NTSTATUS STDCALL ZwCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
STDCALL IN ACCESS_MASK DesiredAccess,
ZwCreateNamedPipeFile( IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PHANDLE NamedPipeFileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ACCESS_MASK DesiredAccess, IN ULONG FileAttributes,
IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG ShareAccess,
OUT PIO_STATUS_BLOCK IoStatusBlock, IN ULONG OpenMode,
IN ULONG FileAttributes, IN ULONG PipeType,
IN ULONG ShareAccess, IN ULONG PipeRead,
IN ULONG OpenMode, IN ULONG PipeWait,
IN ULONG PipeType, IN ULONG MaxInstances,
IN ULONG PipeRead, IN ULONG InBufferSize,
IN ULONG PipeWait, IN ULONG OutBufferSize,
IN ULONG MaxInstances, IN PLARGE_INTEGER TimeOut)
IN ULONG InBufferSize,
IN ULONG OutBufferSize,
IN PLARGE_INTEGER TimeOut
)
{ {
UNIMPLEMENTED;
} }

View file

@ -31,7 +31,6 @@ VOID IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject,
{ {
PKDEVICE_QUEUE_ENTRY entry; PKDEVICE_QUEUE_ENTRY entry;
PIRP Irp; PIRP Irp;
KIRQL oldirql;
entry = KeRemoveByKeyDeviceQueue(&DeviceObject->DeviceQueue,Key); entry = KeRemoveByKeyDeviceQueue(&DeviceObject->DeviceQueue,Key);
@ -58,7 +57,6 @@ VOID IoStartNextPacket(PDEVICE_OBJECT DeviceObject, BOOLEAN Cancelable)
{ {
PKDEVICE_QUEUE_ENTRY entry; PKDEVICE_QUEUE_ENTRY entry;
PIRP Irp; PIRP Irp;
KIRQL oldirql;
DPRINT("IoStartNextPacket(DeviceObject %x, Cancelable %d)\n", DPRINT("IoStartNextPacket(DeviceObject %x, Cancelable %d)\n",
DeviceObject,Cancelable); DeviceObject,Cancelable);

View file

@ -12,6 +12,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ob.h> #include <internal/ob.h>
#include <wchar.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>

View file

@ -40,6 +40,8 @@ NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject)
RtlZeroMemory(Vpb->VolumeLabel,sizeof(WCHAR)*MAXIMUM_VOLUME_LABEL_LENGTH); RtlZeroMemory(Vpb->VolumeLabel,sizeof(WCHAR)*MAXIMUM_VOLUME_LABEL_LENGTH);
DeviceObject->Vpb = Vpb; DeviceObject->Vpb = Vpb;
return(STATUS_SUCCESS);
} }
PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction, PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,

View file

@ -3,7 +3,7 @@
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ke/bug.c * FILE: ntoskrnl/ke/bug.c
* PURPOSE: Graceful system shutdown if a bug is detected * PURPOSE: Graceful system shutdown if a bug is detected
* PROGRAMMER: David Welch (welch@mcmail.com) * PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY: * UPDATE HISTORY:
* Created 22/05/98 * Created 22/05/98
*/ */
@ -11,6 +11,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ke.h>
#include <internal/debug.h> #include <internal/debug.h>
@ -46,6 +47,7 @@ BOOLEAN KeRegisterBugCheckCallback(PKBUGCHECK_CALLBACK_RECORD CallbackRecord,
CallbackRecord->Buffer=Buffer; CallbackRecord->Buffer=Buffer;
CallbackRecord->Component=Component; CallbackRecord->Component=Component;
CallbackRecord->CallbackRoutine=CallbackRoutine; CallbackRecord->CallbackRoutine=CallbackRoutine;
return(TRUE);
} }
VOID KeBugCheckEx(ULONG BugCheckCode, VOID KeBugCheckEx(ULONG BugCheckCode,

View file

@ -12,16 +12,16 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/debug.h>
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
NTSTATUS STDCALL NtRaiseHardError(VOID) NTSTATUS STDCALL NtRaiseHardError(VOID)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtSetDefaultHardErrorPort(IN HANDLE PortHandle)
STDCALL
NtSetDefaultHardErrorPort(
IN HANDLE PortHandle
)
{ {
UNIMPLEMENTED;
} }

View file

@ -165,7 +165,7 @@ asmlinkage void _main(boot_param* _bp)
for (i=1;i<bp.nr_files;i++) for (i=1;i<bp.nr_files;i++)
{ {
DPRINT("process module at %08lx\n", start); DPRINT("process module at %08lx\n", start);
LdrProcessDriver(start); LdrProcessDriver((PVOID)start);
start=start+PAGE_ROUND_UP(bp.module_length[i]); start=start+PAGE_ROUND_UP(bp.module_length[i]);
} }

View file

@ -19,6 +19,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <string.h> #include <string.h>
#include <internal/string.h> #include <internal/string.h>
#include <stdio.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -494,9 +495,6 @@ void KeExpireTimers(void)
DPRINT("Finished KeExpireTimers()\n"); DPRINT("Finished KeExpireTimers()\n");
} }
extern unsigned int nr_used_blocks;
extern unsigned int EiFreeNonPagedPool;
extern unsigned int EiUsedNonPagedPool;
BOOLEAN KiTimerInterrupt(VOID) BOOLEAN KiTimerInterrupt(VOID)
/* /*
@ -507,8 +505,9 @@ BOOLEAN KiTimerInterrupt(VOID)
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36); char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36);
int i; int i;
int x,y; int x,y;
extern ULONG PiNrThreads;
extern ULONG EiNrUsedBlocks; extern ULONG EiNrUsedBlocks;
extern unsigned int EiFreeNonPagedPool;
extern unsigned int EiUsedNonPagedPool;
/* /*
* Increment the number of timers ticks * Increment the number of timers ticks
@ -534,7 +533,8 @@ BOOLEAN KiTimerInterrupt(VOID)
} }
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,ticks); // sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,ticks);
memset(str, 0, sizeof(str)); memset(str, 0, sizeof(str));
sprintf(str,"%.8u %.8u",EiNrUsedBlocks,EiFreeNonPagedPool); sprintf(str,"%.8u %.8u",(unsigned int)EiNrUsedBlocks,
(unsigned int)EiFreeNonPagedPool);
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool); // sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool);
// sprintf(str,"%.8u %.8u",PiNrThreads,KiTimerTicks); // sprintf(str,"%.8u %.8u",PiNrThreads,KiTimerTicks);
for (i=0;i<17;i++) for (i=0;i<17;i++)

View file

@ -306,6 +306,7 @@ LdrPEProcessDriver(PVOID ModuleLoadBase)
/* Copy image sections into virtual section */ /* Copy image sections into virtual section */
memcpy(DriverBase, ModuleLoadBase, PESectionHeaders[0].PointerToRawData); memcpy(DriverBase, ModuleLoadBase, PESectionHeaders[0].PointerToRawData);
CurrentBase = (PVOID) ((DWORD)DriverBase + PESectionHeaders[0].PointerToRawData); CurrentBase = (PVOID) ((DWORD)DriverBase + PESectionHeaders[0].PointerToRawData);
CurrentSize = 0;
for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++) for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
{ {
/* Copy current section into current offset of virtual section */ /* Copy current section into current offset of virtual section */
@ -911,7 +912,6 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
OBJECT_ATTRIBUTES FileObjectAttributes; OBJECT_ATTRIBUTES FileObjectAttributes;
HANDLE FileHandle, SectionHandle, ThreadHandle; HANDLE FileHandle, SectionHandle, ThreadHandle;
CONTEXT Context; CONTEXT Context;
ANSI_STRING AnsiString;
UNICODE_STRING DllPathname; UNICODE_STRING DllPathname;
PIMAGE_DOS_HEADER DosHeader; PIMAGE_DOS_HEADER DosHeader;
PIMAGE_NT_HEADERS NTHeaders; PIMAGE_NT_HEADERS NTHeaders;
@ -1020,7 +1020,7 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
0, 0,
Sections[i].Misc.VirtualSize, Sections[i].Misc.VirtualSize,
&Offset, &Offset,
&Sections[i].Misc.VirtualSize, (PULONG)&Sections[i].Misc.VirtualSize,
0, 0,
MEM_COMMIT, MEM_COMMIT,
PAGE_READWRITE); PAGE_READWRITE);
@ -1152,12 +1152,12 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
DUPLICATE_SAME_ACCESS); DUPLICATE_SAME_ACCESS);
ZwWriteVirtualMemory(ProcessHandle, ZwWriteVirtualMemory(ProcessHandle,
STACK_TOP - 4, (PVOID)(STACK_TOP - 4),
&ImageBase, &ImageBase,
sizeof(ImageBase), sizeof(ImageBase),
&BytesWritten); &BytesWritten);
ZwWriteVirtualMemory(ProcessHandle, ZwWriteVirtualMemory(ProcessHandle,
STACK_TOP - 8, (PVOID)(STACK_TOP - 8),
&DupSectionHandle, &DupSectionHandle,
sizeof(DupSectionHandle), sizeof(DupSectionHandle),
&BytesWritten); &BytesWritten);
@ -1200,10 +1200,13 @@ NTSTATUS LdrLoadImage(HANDLE ProcessHandle, PUNICODE_STRING Filename)
} }
NTSTATUS LdrLoadInitialProcess(VOID) NTSTATUS LdrLoadInitialProcess(VOID)
/*
* FIXME: The location of the initial process should be configurable,
* from command line or registry
*/
{ {
NTSTATUS Status; NTSTATUS Status;
HANDLE ProcessHandle; HANDLE ProcessHandle;
ANSI_STRING AnsiString;
UNICODE_STRING ProcessName; UNICODE_STRING ProcessName;
Status = ZwCreateProcess(&ProcessHandle, Status = ZwCreateProcess(&ProcessHandle,
@ -1216,16 +1219,12 @@ NTSTATUS LdrLoadInitialProcess(VOID)
NULL); NULL);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DbgPrint("Could not create process\n"); DbgPrint("Could not create process\n");
return Status; return Status;
} }
RtlInitAnsiString(&AnsiString, "\\??\\C:\\reactos\\system\\shell.exe"); RtlInitUnicodeString(&ProcessName, L"\\??\\C:\\reactos\\system\\shell.exe");
RtlAnsiStringToUnicodeString(&ProcessName, &AnsiString, TRUE);
Status = LdrLoadImage(ProcessHandle, &ProcessName); Status = LdrLoadImage(ProcessHandle, &ProcessName);
RtlFreeUnicodeString(&ProcessName);
return Status; return Status;
} }

View file

@ -143,4 +143,5 @@ ex/napi.o: ex/napi.c ../include/ntdll/napi.h
#WITH_DEBUGGING = yes #WITH_DEBUGGING = yes
WIN32_LEAN_AND_MEAN = yes WIN32_LEAN_AND_MEAN = yes
WARNINGS_ARE_ERRORS = yes
include ../rules.mak include ../rules.mak

View file

@ -28,7 +28,6 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
{ {
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
MEMORY_AREA* current; MEMORY_AREA* current;
ULONG i;
DbgPrint("MmDumpMemoryAreas()\n"); DbgPrint("MmDumpMemoryAreas()\n");
@ -45,9 +44,9 @@ VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
DbgPrint("Finished MmDumpMemoryAreas()\n"); DbgPrint("Finished MmDumpMemoryAreas()\n");
} }
VOID MmLockMemoryAreaList(ULONG Address, PKIRQL oldlvl) VOID MmLockMemoryAreaList(PVOID Address, PKIRQL oldlvl)
{ {
if (Address >= KERNEL_BASE) if (Address >= (PVOID)KERNEL_BASE)
{ {
KeAcquireSpinLock(&SystemAreaListLock,oldlvl); KeAcquireSpinLock(&SystemAreaListLock,oldlvl);
} }
@ -59,9 +58,9 @@ VOID MmLockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
} }
} }
VOID MmUnlockMemoryAreaList(ULONG Address, PKIRQL oldlvl) VOID MmUnlockMemoryAreaList(PVOID Address, PKIRQL oldlvl)
{ {
if (Address >= KERNEL_BASE) if (Address >= (PVOID)KERNEL_BASE)
{ {
KeReleaseSpinLock(&SystemAreaListLock,*oldlvl); KeReleaseSpinLock(&SystemAreaListLock,*oldlvl);
} }
@ -102,9 +101,9 @@ VOID MmUnlockMemoryAreaListByMode(KPROCESSOR_MODE Mode, PKIRQL oldlvl)
} }
static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, ULONG BaseAddress) static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, PVOID BaseAddress)
{ {
if (BaseAddress >= KERNEL_BASE) if (BaseAddress >= (PVOID)KERNEL_BASE)
{ {
return(&SystemAreaList); return(&SystemAreaList);
} }
@ -115,7 +114,7 @@ static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, ULONG BaseAddress)
} }
static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead, static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
ULONG Address) PVOID Address)
{ {
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
MEMORY_AREA* current; MEMORY_AREA* current;
@ -153,7 +152,7 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead, MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
ULONG Address, PVOID Address,
ULONG Length) ULONG Length)
{ {
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
@ -178,16 +177,16 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
current); current);
return(current); return(current);
} }
Extent = current->BaseAddress + current->Length; Extent = (ULONG)current->BaseAddress + current->Length;
if (Extent > Address && if (Extent > (ULONG)Address &&
Extent < (Address+Length)) Extent < (ULONG)(Address+Length))
{ {
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n", DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
current); current);
return(current); return(current);
} }
if (current->BaseAddress <= Address && if (current->BaseAddress <= Address &&
Extent >= (Address+Length)) Extent >= (ULONG)(Address+Length))
{ {
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n", DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
current); current);
@ -204,7 +203,8 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
return(NULL); return(NULL);
} }
MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process, ULONG Address, MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process,
PVOID Address,
ULONG Length) ULONG Length)
{ {
KIRQL oldlvl; KIRQL oldlvl;
@ -223,7 +223,8 @@ MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process, ULONG Address,
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process, MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process,
ULONG Address, ULONG Length) PVOID Address,
ULONG Length)
{ {
MEMORY_AREA* Result; MEMORY_AREA* Result;
PLIST_ENTRY ListHead; PLIST_ENTRY ListHead;
@ -249,13 +250,13 @@ MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address)
} }
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(PEPROCESS Process, MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(PEPROCESS Process,
ULONG Address) PVOID Address)
{ {
MEMORY_AREA* Result; MEMORY_AREA* Result;
PLIST_ENTRY ListHead; PLIST_ENTRY ListHead;
ListHead = MmGetRelatedListHead(Process, Address); ListHead = MmGetRelatedListHead(Process, Address);
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address); Result = MmInternalOpenMemoryAreaByAddress(ListHead, Address);
return(Result); return(Result);
} }
@ -323,7 +324,7 @@ static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
InsertTailList(ListHead,inserted_entry); InsertTailList(ListHead,inserted_entry);
} }
static ULONG MmFindGapWithoutLock(PEPROCESS Process, static PVOID MmFindGapWithoutLock(PEPROCESS Process,
KPROCESSOR_MODE Mode, ULONG Length) KPROCESSOR_MODE Mode, ULONG Length)
{ {
PLIST_ENTRY ListHead; PLIST_ENTRY ListHead;
@ -366,7 +367,7 @@ static ULONG MmFindGapWithoutLock(PEPROCESS Process,
if (current_entry == ListHead) if (current_entry == ListHead)
{ {
assert(Mode==UserMode); assert(Mode==UserMode);
return(MM_LOWEST_USER_ADDRESS); return((PVOID)MM_LOWEST_USER_ADDRESS);
} }
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry); current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
@ -398,13 +399,13 @@ NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x," DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x,"
"FreePages %d)\n",Process,BaseAddress,Length,FreePages); "FreePages %d)\n",Process,BaseAddress,Length,FreePages);
MmLockMemoryAreaList((ULONG)BaseAddress,&oldlvl); MmLockMemoryAreaList(BaseAddress, &oldlvl);
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock(Process, MemoryArea = MmOpenMemoryAreaByAddressWithoutLock(Process,
(ULONG)BaseAddress); BaseAddress);
if (MemoryArea==NULL) if (MemoryArea==NULL)
{ {
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl); MmUnlockMemoryAreaList(BaseAddress, &oldlvl);
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
if (FreePages) if (FreePages)
@ -419,20 +420,10 @@ NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
RemoveEntryList(&(MemoryArea->Entry)); RemoveEntryList(&(MemoryArea->Entry));
ExFreePool(MemoryArea); ExFreePool(MemoryArea);
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl); MmUnlockMemoryAreaList(BaseAddress, &oldlvl);
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS MmLockMemoryArea(MEMORY_AREA* MemoryArea)
{
MemoryArea->LockCount++;
}
NTSTATUS MmUnlockMemoryArea(MEMORY_AREA* MemoryArea)
{
MemoryArea->LockCount--;
}
PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process, PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
PMEMORY_AREA OriginalMemoryArea, PMEMORY_AREA OriginalMemoryArea,
PVOID BaseAddress, PVOID BaseAddress,
@ -531,8 +522,9 @@ NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
} }
else else
{ {
(*BaseAddress) = PAGE_ROUND_DOWN((*BaseAddress)); (*BaseAddress) = (PVOID)PAGE_ROUND_DOWN((*BaseAddress));
if (MmOpenMemoryAreaByRegionWithoutLock(Process,*BaseAddress, if (MmOpenMemoryAreaByRegionWithoutLock(Process,
*BaseAddress,
Length)!=NULL) Length)!=NULL)
{ {
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl); MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);

View file

@ -68,7 +68,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
DPRINT("Writing %x with physical address %x\n", DPRINT("Writing %x with physical address %x\n",
base+(i*PAGESIZE),mdl_pages[i]); base+(i*PAGESIZE),mdl_pages[i]);
MmSetPage(NULL, MmSetPage(NULL,
(DWORD)base+(i*PAGESIZE), (PVOID)((DWORD)base+(i*PAGESIZE)),
PAGE_READWRITE, PAGE_READWRITE,
mdl_pages[i]); mdl_pages[i]);
} }
@ -119,7 +119,7 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
DPRINT("StartVa %x\n",Mdl->StartVa); DPRINT("StartVa %x\n",Mdl->StartVa);
marea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(), marea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),
(ULONG)Mdl->StartVa); Mdl->StartVa);
DPRINT("marea %x\n",marea); DPRINT("marea %x\n",marea);
@ -240,8 +240,8 @@ VOID MmInitializeMdl(PMDL MemoryDescriptorList, PVOID Base, ULONG Length)
*/ */
{ {
memset(MemoryDescriptorList,0,sizeof(MDL)); memset(MemoryDescriptorList,0,sizeof(MDL));
MemoryDescriptorList->StartVa = PAGE_ROUND_DOWN(Base); MemoryDescriptorList->StartVa = (PVOID)PAGE_ROUND_DOWN(Base);
MemoryDescriptorList->ByteOffset = Base - PAGE_ROUND_DOWN(Base); MemoryDescriptorList->ByteOffset = (ULONG)(Base - PAGE_ROUND_DOWN(Base));
MemoryDescriptorList->MdlFlags = 0; MemoryDescriptorList->MdlFlags = 0;
MemoryDescriptorList->ByteCount = Length; MemoryDescriptorList->ByteCount = Length;
MemoryDescriptorList->Size = sizeof(MDL) + MemoryDescriptorList->Size = sizeof(MDL) +

View file

@ -110,7 +110,7 @@ void MmInitialize(boot_param* bp)
i<PAGE_ROUND_DOWN(((int)&etext));i=i+PAGESIZE) i<PAGE_ROUND_DOWN(((int)&etext));i=i+PAGESIZE)
{ {
MmSetPageProtect(NULL, MmSetPageProtect(NULL,
i, (PVOID)i,
PAGE_EXECUTE_READ); PAGE_EXECUTE_READ);
} }
DPRINT("end %x\n",(int)&end); DPRINT("end %x\n",(int)&end);
@ -118,7 +118,7 @@ void MmInitialize(boot_param* bp)
i<(KERNEL_BASE+PAGE_TABLE_SIZE);i=i+PAGESIZE) i<(KERNEL_BASE+PAGE_TABLE_SIZE);i=i+PAGESIZE)
{ {
MmSetPage(NULL, MmSetPage(NULL,
i, (PVOID)i,
PAGE_NOACCESS, PAGE_NOACCESS,
0); 0);
} }

View file

@ -80,8 +80,6 @@ ULONG EiNrUsedBlocks = 0;
*/ */
static unsigned int alloc_map[ALLOC_MAP_SIZE/32]={0,}; static unsigned int alloc_map[ALLOC_MAP_SIZE/32]={0,};
static unsigned int pool_free_mem = 0;
unsigned int EiFreeNonPagedPool = 0; unsigned int EiFreeNonPagedPool = 0;
unsigned int EiUsedNonPagedPool = 0; unsigned int EiUsedNonPagedPool = 0;
@ -92,6 +90,7 @@ VOID ExInitNonPagedPool(ULONG BaseAddress)
kernel_pool_base=BaseAddress; kernel_pool_base=BaseAddress;
} }
#if 0
static void validate_free_list(void) static void validate_free_list(void)
/* /*
* FUNCTION: Validate the integrity of the list of free blocks * FUNCTION: Validate the integrity of the list of free blocks
@ -260,6 +259,7 @@ static void validate_kernel_pool(void)
current=current->next; current=current->next;
} }
} }
#endif
static void add_to_free_list(block_hdr* blk) static void add_to_free_list(block_hdr* blk)
/* /*
@ -431,7 +431,7 @@ static block_hdr* grow_kernel_pool(unsigned int size)
for (i=0;i<nr_pages;i++) for (i=0;i<nr_pages;i++)
{ {
MmSetPage(NULL, MmSetPage(NULL,
start + (i*PAGESIZE), (PVOID)(start + (i*PAGESIZE)),
PAGE_READWRITE, PAGE_READWRITE,
get_free_page()); get_free_page());
} }
@ -567,44 +567,6 @@ asmlinkage VOID ExFreePool(PVOID block)
VALIDATE_POOL; VALIDATE_POOL;
} }
static void defrag_free_list(void)
/*
* FUNCTION: defrag the list of free blocks
*/
{
block_hdr* current=free_list_head,*current2;
ULONG addr1,addr2,max=0;
DPRINT("Begin defrag free,tot free=%d,tot used=%d\n"
,EiFreeNonPagedPool
,EiUsedNonPagedPool);
while (current)
{
addr1=(ULONG)current;
current2=current->next;
while(current2)
{
addr2=(ULONG)current2;
if(addr2==addr1+current->size+sizeof(block_hdr))
{
remove_from_free_list(current2);
current->size+=current2->size+sizeof(block_hdr);
if(current->size>max)max=current->size;
}
else if(addr1==addr2+current2->size+sizeof(block_hdr))
{
remove_from_free_list(current);
current2->size+=current->size+sizeof(block_hdr);
if(current2->size>max)max=current2->size;
break;
}
current2=current2->next;
}
current=current->next;
}
DPRINT("Finish To defrag free blocks,max=%d\n",max);
}
PVOID ExAllocateNonPagedPoolWithTag(ULONG type, PVOID ExAllocateNonPagedPoolWithTag(ULONG type,
ULONG size, ULONG size,
ULONG Tag, ULONG Tag,

View file

@ -48,7 +48,7 @@ PVOID ExAllocatePool(POOL_TYPE PoolType, ULONG NumberOfBytes)
Block = ExAllocateNonPagedPoolWithTag(PoolType, Block = ExAllocateNonPagedPoolWithTag(PoolType,
NumberOfBytes, NumberOfBytes,
TAG_NONE, TAG_NONE,
(&PoolType)[-1]); (PVOID)(&PoolType)[-1]);
return(Block); return(Block);
} }
@ -71,7 +71,7 @@ PVOID ExAllocatePoolWithTag(ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
Block = ExAllocateNonPagedPoolWithTag(PoolType, Block = ExAllocateNonPagedPoolWithTag(PoolType,
NumberOfBytes, NumberOfBytes,
Tag, Tag,
(&PoolType)[-1]); (PVOID)(&PoolType)[-1]);
break; break;
case PagedPool: case PagedPool:
@ -90,32 +90,9 @@ PVOID ExAllocatePoolWithTag(ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
} }
return(Block); return(Block);
} }
PVOID ExAllocatePoolWithQuotaTag(POOL_TYPE PoolType, ULONG NumberOfBytes,
ULONG Tag)
{
PVOID Block;
PKTHREAD current = KeGetCurrentThread();
Block = ExAllocatePoolWithTag(PoolType,NumberOfBytes,Tag);
switch(PoolType)
{
case NonPagedPool:
case NonPagedPoolMustSucceed:
case NonPagedPoolCacheAligned:
case NonPagedPoolCacheAlignedMustS:
// current->NPagedPoolQuota = current->NPagedPoolQuota - NumberOfBytes;
break;
case PagedPool:
case PagedPoolCacheAligned:
// current->PagedPoolQuota = current->PagedPoolQuota - NumberOfBytes;
break;
};
return(Block);
}
PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes) PVOID ExAllocatePoolWithQuota(POOL_TYPE PoolType, ULONG NumberOfBytes)
{ {
return(ExAllocatePoolWithQuotaTag(PoolType,NumberOfBytes,TAG_NONE)); // return(ExAllocatePoolWithQuotaTag(PoolType,NumberOfBytes,TAG_NONE));
UNIMPLEMENTED;
} }

View file

@ -15,6 +15,7 @@
#include <internal/ob.h> #include <internal/ob.h>
#include <internal/io.h> #include <internal/io.h>
#include <internal/ps.h> #include <internal/ps.h>
#include <wchar.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -31,9 +32,9 @@ VOID MmpDeleteSection(PVOID ObjectBody)
NTSTATUS MmpCreateSection(PVOID ObjectBody, NTSTATUS MmpCreateSection(PVOID ObjectBody,
PVOID Parent, PVOID Parent,
PWSTR RemainingPath) PWSTR RemainingPath,
POBJECT_ATTRIBUTES ObjectAttributes)
{ {
PDEVICE_OBJECT DeviceObject = (PDEVICE_OBJECT)ObjectBody;
NTSTATUS Status; NTSTATUS Status;
DPRINT("MmpCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n", DPRINT("MmpCreateDevice(ObjectBody %x, Parent %x, RemainingPath %w)\n",

View file

@ -20,7 +20,7 @@
PVOID MmAllocateSection(ULONG Length) PVOID MmAllocateSection(ULONG Length)
{ {
ULONG Result; PVOID Result;
MEMORY_AREA* marea; MEMORY_AREA* marea;
NTSTATUS Status; NTSTATUS Status;
ULONG i; ULONG i;
@ -39,7 +39,7 @@ PVOID MmAllocateSection(ULONG Length)
{ {
return(NULL); return(NULL);
} }
DPRINT("Result %x\n",Result); DPRINT("Result %p\n",Result);
for (i=0;i<=(Length/PAGESIZE);i++) for (i=0;i<=(Length/PAGESIZE);i++)
{ {
MmSetPage(NULL, MmSetPage(NULL,
@ -65,13 +65,13 @@ PVOID MmMapIoSpace(PHYSICAL_ADDRESS PhysicalAddress,
ULONG NumberOfBytes, ULONG NumberOfBytes,
BOOLEAN CacheEnable) BOOLEAN CacheEnable)
{ {
ULONG Result; PVOID Result;
MEMORY_AREA* marea; MEMORY_AREA* marea;
NTSTATUS Status; NTSTATUS Status;
ULONG i; ULONG i;
ULONG Attributes; ULONG Attributes;
Result=0; Result = 0;
Status = MmCreateMemoryArea(KernelMode, Status = MmCreateMemoryArea(KernelMode,
PsGetCurrentProcess(), PsGetCurrentProcess(),
MEMORY_AREA_IO_MAPPING, MEMORY_AREA_IO_MAPPING,
@ -106,12 +106,12 @@ VOID MmUnmapIoSpace(PVOID BaseAddress, ULONG NumberOfBytes)
PVOID MmAllocateNonCachedMemory(ULONG NumberOfBytes) PVOID MmAllocateNonCachedMemory(ULONG NumberOfBytes)
{ {
ULONG Result; PVOID Result;
MEMORY_AREA* marea; MEMORY_AREA* marea;
NTSTATUS Status; NTSTATUS Status;
ULONG i; ULONG i;
Result=0; Result = 0;
Status = MmCreateMemoryArea(KernelMode, Status = MmCreateMemoryArea(KernelMode,
PsGetCurrentProcess(), PsGetCurrentProcess(),
MEMORY_AREA_NO_CACHE, MEMORY_AREA_NO_CACHE,

View file

@ -91,7 +91,7 @@ void VirtualInit(boot_param* bp)
MmInitSectionImplementation(); MmInitSectionImplementation();
} }
ULONG MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, ULONG Address) ULONG MmCommitedSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
{ {
MmSetPage(PsGetCurrentProcess(), MmSetPage(PsGetCurrentProcess(),
Address, Address,
@ -208,7 +208,7 @@ asmlinkage int page_fault_handler(unsigned int cs,
break; break;
case MEMORY_AREA_COMMIT: case MEMORY_AREA_COMMIT:
stat = MmCommitedSectionHandleFault(MemoryArea,cr2); stat = MmCommitedSectionHandleFault(MemoryArea,(PVOID)cr2);
break; break;
default: default:
@ -669,7 +669,8 @@ NTSTATUS STDCALL ZwReadVirtualMemory(IN HANDLE ProcessHandle,
for (i=0; i<(NumberOfBytesToRead/PAGESIZE); i++) for (i=0; i<(NumberOfBytesToRead/PAGESIZE); i++)
{ {
CurrentEntry = MmGetPageEntry(Process, (DWORD)BaseAddress + (i*PAGESIZE)); CurrentEntry = MmGetPageEntry(Process,
(PVOID)((DWORD)BaseAddress + (i*PAGESIZE)));
RtlCopyMemory(Buffer + (i*PAGESIZE), RtlCopyMemory(Buffer + (i*PAGESIZE),
(PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)), (PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)),
PAGESIZE); PAGESIZE);
@ -717,7 +718,6 @@ NTSTATUS STDCALL ZwWriteVirtualMemory(IN HANDLE ProcessHandle,
OUT PULONG NumberOfBytesWritten) OUT PULONG NumberOfBytesWritten)
{ {
PEPROCESS Process; PEPROCESS Process;
PMEMORY_AREA InMemoryArea;
PMEMORY_AREA OutMemoryArea; PMEMORY_AREA OutMemoryArea;
ULONG i; ULONG i;
NTSTATUS Status; NTSTATUS Status;
@ -759,8 +759,9 @@ NTSTATUS STDCALL ZwWriteVirtualMemory(IN HANDLE ProcessHandle,
OutMemoryArea->Attributes, OutMemoryArea->Attributes,
get_free_page()); get_free_page());
} }
CurrentEntry = MmGetPageEntry(Process, (DWORD)BaseAddress + CurrentEntry = MmGetPageEntry(Process,
(i*PAGESIZE)); (PVOID)((DWORD)BaseAddress +
(i*PAGESIZE)));
RtlCopyMemory((PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)) + RtlCopyMemory((PVOID)physical_to_linear(PAGE_MASK(*CurrentEntry)) +
(((DWORD)BaseAddress)%PAGESIZE), (((DWORD)BaseAddress)%PAGESIZE),
Buffer + (i*PAGESIZE), Buffer + (i*PAGESIZE),

View file

@ -130,6 +130,8 @@ NTSTATUS ExInitializeZone(PZONE_HEADER Zone, ULONG BlockSize,
PushEntryList(&Zone->FreeList,&entry->Entry); PushEntryList(&Zone->FreeList,&entry->Entry);
entry = (PZONE_ENTRY)(((PVOID)entry) + sizeof(ZONE_ENTRY) + BlockSize); entry = (PZONE_ENTRY)(((PVOID)entry) + sizeof(ZONE_ENTRY) + BlockSize);
} }
return(STATUS_SUCCESS);
} }
PVOID ExInterlockedFreeToZone(PZONE_HEADER Zone, PVOID Block, PVOID ExInterlockedFreeToZone(PZONE_HEADER Zone, PVOID Block,

View file

@ -3,7 +3,7 @@
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/nt/nt.c * FILE: ntoskrnl/nt/nt.c
* PURPOSE: Initialization of system call interfaces * PURPOSE: Initialization of system call interfaces
* PROGRAMMER: David Welch (welch@mcmail.com) * PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY: * UPDATE HISTORY:
* Created 22/05/98 * Created 22/05/98
*/ */
@ -11,6 +11,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/nt.h>
#include <internal/debug.h> #include <internal/debug.h>

View file

@ -19,8 +19,7 @@
NTSTATUS STDCALL NtCancelTimer(IN HANDLE TimerHandle, NTSTATUS STDCALL NtCancelTimer(IN HANDLE TimerHandle,
OUT PBOOLEAN CurrentState OPTIONAL) OUT PBOOLEAN CurrentState OPTIONAL)
{ {
return(ZwCancelTimer(TimerHandle, UNIMPLEMENTED;
CurrentState));
} }
NTSTATUS STDCALL ZwCancelTimer(IN HANDLE TimerHandle, NTSTATUS STDCALL ZwCancelTimer(IN HANDLE TimerHandle,

View file

@ -34,6 +34,40 @@ typedef struct
/* FUNCTIONS ***************************************************************/ /* FUNCTIONS ***************************************************************/
static PHANDLE_REP ObpGetObjectByHandle(PEPROCESS Process,
HANDLE h)
/*
* FUNCTION: Get the data structure for a handle
* ARGUMENTS:
* Process = Process to get the handle for
* h = Handle
* ARGUMENTS: A pointer to the information about the handle on success,
* NULL on failure
*/
{
PLIST_ENTRY current;
unsigned int handle = ((unsigned int)h) - 1;
unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
HANDLE_BLOCK* blk = NULL;
unsigned int i;
DPRINT("ObpGetObjectByHandle(Process %x, h %x)\n",Process,h);
current = Process->Pcb.HandleTable.ListHead.Flink;
DPRINT("current %x\n",current);
for (i=0;i<count;i++)
{
current = current->Flink;
if (current==(&(Process->Pcb.HandleTable.ListHead)))
{
return(NULL);
}
}
blk = CONTAINING_RECORD(current,HANDLE_BLOCK,entry);
return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
}
NTSTATUS STDCALL NtDuplicateObject(IN HANDLE SourceProcessHandle, NTSTATUS STDCALL NtDuplicateObject(IN HANDLE SourceProcessHandle,
IN PHANDLE SourceHandle, IN PHANDLE SourceHandle,
@ -180,41 +214,6 @@ VOID ObCreateHandleTable(PEPROCESS Parent,
} }
} }
static PHANDLE_REP ObpGetObjectByHandle(PEPROCESS Process,
HANDLE h)
/*
* FUNCTION: Get the data structure for a handle
* ARGUMENTS:
* Process = Process to get the handle for
* h = Handle
* ARGUMENTS: A pointer to the information about the handle on success,
* NULL on failure
*/
{
PLIST_ENTRY current;
unsigned int handle = ((unsigned int)h) - 1;
unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
HANDLE_BLOCK* blk = NULL;
unsigned int i;
DPRINT("ObpGetObjectByHandle(Process %x, h %x)\n",Process,h);
current = Process->Pcb.HandleTable.ListHead.Flink;
DPRINT("current %x\n",current);
for (i=0;i<count;i++)
{
current = current->Flink;
if (current==(&(Process->Pcb.HandleTable.ListHead)))
{
return(NULL);
}
}
blk = CONTAINING_RECORD(current,HANDLE_BLOCK,entry);
return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
}
VOID ObDeleteHandle(HANDLE Handle) VOID ObDeleteHandle(HANDLE Handle)
{ {
PHANDLE_REP Rep; PHANDLE_REP Rep;

View file

@ -133,7 +133,6 @@ PVOID ObpParseDirectory(PVOID Object, PWSTR* Path)
{ {
PWSTR end; PWSTR end;
PVOID FoundObject; PVOID FoundObject;
NTSTATUS Status;
DPRINT("ObpParseDirectory(Object %x, Path %x, *Path %w)\n", DPRINT("ObpParseDirectory(Object %x, Path %x, *Path %w)\n",
Object,Path,*Path); Object,Path,*Path);

View file

@ -11,18 +11,19 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ke.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
HANDLE IdleThreadHandle = NULL; HANDLE PsIdleThreadHandle = NULL;
extern ULONG DpcQueueSize; extern ULONG DpcQueueSize;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
static VOID PsIdleThreadMain(PVOID Context) static NTSTATUS PsIdleThreadMain(PVOID Context)
{ {
KIRQL oldlvl; KIRQL oldlvl;
@ -43,7 +44,7 @@ VOID PsInitIdleThread(VOID)
{ {
KPRIORITY Priority; KPRIORITY Priority;
PsCreateSystemThread(&IdleThreadHandle, PsCreateSystemThread(&PsIdleThreadHandle,
THREAD_ALL_ACCESS, THREAD_ALL_ACCESS,
NULL, NULL,
NULL, NULL,
@ -52,7 +53,7 @@ VOID PsInitIdleThread(VOID)
NULL); NULL);
Priority = THREAD_PRIORITY_IDLE; Priority = THREAD_PRIORITY_IDLE;
ZwSetInformationThread(IdleThreadHandle, ZwSetInformationThread(PsIdleThreadHandle,
ThreadPriority, ThreadPriority,
&Priority, &Priority,
sizeof(Priority)); sizeof(Priority));

View file

@ -3,7 +3,7 @@
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
* FILE: ntoskrnl/ps/kill.c * FILE: ntoskrnl/ps/kill.c
* PURPOSE: Terminating a thread * PURPOSE: Terminating a thread
* PROGRAMMER: David Welch (welch@mcmail.com) * PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY: * UPDATE HISTORY:
* Created 22/05/98 * Created 22/05/98
*/ */
@ -12,6 +12,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ps.h> #include <internal/ps.h>
#include <internal/ke.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -62,7 +63,6 @@ NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle, NTSTATUS STDCALL ZwTerminateProcess(IN HANDLE ProcessHandle,
IN NTSTATUS ExitStatus) IN NTSTATUS ExitStatus)
{ {
PETHREAD Thread;
NTSTATUS Status; NTSTATUS Status;
PEPROCESS Process; PEPROCESS Process;
KIRQL oldlvl; KIRQL oldlvl;

View file

@ -13,6 +13,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <internal/ob.h> #include <internal/ob.h>
#include <internal/mm.h> #include <internal/mm.h>
#include <internal/ke.h>
#include <string.h> #include <string.h>
#include <internal/string.h> #include <internal/string.h>
@ -161,9 +162,6 @@ NTSTATUS STDCALL ZwCreateProcess(
PULONG CurrentPageDirectory; PULONG CurrentPageDirectory;
ULONG i; ULONG i;
PKPROCESS KProcess; PKPROCESS KProcess;
ULONG Base;
ULONG Length;
LARGE_INTEGER Offset;
NTSTATUS Status; NTSTATUS Status;
DPRINT("ZwCreateProcess(ObjectAttributes %x)\n",ObjectAttributes); DPRINT("ZwCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
@ -196,10 +194,10 @@ NTSTATUS STDCALL ZwCreateProcess(
InheritObjectTable, InheritObjectTable,
Process); Process);
PageDirectory = physical_to_linear((ULONG)get_free_page()); PageDirectory = (PULONG)physical_to_linear((ULONG)get_free_page());
KProcess->PageTableDirectory = PageDirectory; KProcess->PageTableDirectory = PageDirectory;
CurrentPageDirectory = get_page_directory(); CurrentPageDirectory = (PULONG)get_page_directory();
memset(PageDirectory,0,PAGESIZE); memset(PageDirectory,0,PAGESIZE);
for (i=768;i<1024;i++) for (i=768;i<1024;i++)
@ -260,10 +258,10 @@ NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle,
IN ULONG ProcessInformationLength, IN ULONG ProcessInformationLength,
OUT PULONG ReturnLength) OUT PULONG ReturnLength)
{ {
PEPROCESS Process; // PEPROCESS Process;
NTSTATUS Status; NTSTATUS Status;
Status = ObReferenceObjectByHandle(ProcessHandle, /* Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_QUERY_INFORMATION, PROCESS_QUERY_INFORMATION,
PsProcessType, PsProcessType,
UserMode, UserMode,
@ -272,7 +270,7 @@ NTSTATUS STDCALL ZwQueryInformationProcess(IN HANDLE ProcessHandle,
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
{ {
return(Status); return(Status);
} }*/
switch (ProcessInformationClass) switch (ProcessInformationClass)
{ {
@ -319,10 +317,10 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle,
IN PVOID ProcessInformation, IN PVOID ProcessInformation,
IN ULONG ProcessInformationLength) IN ULONG ProcessInformationLength)
{ {
PEPROCESS Process; // PEPROCESS Process;
NTSTATUS Status; NTSTATUS Status;
Status = ObReferenceObjectByHandle(ProcessHandle, /* Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_SET_INFORMATION, PROCESS_SET_INFORMATION,
PsProcessType, PsProcessType,
UserMode, UserMode,
@ -331,7 +329,7 @@ NTSTATUS STDCALL ZwSetInformationProcess(IN HANDLE ProcessHandle,
if (Status != STATUS_SUCCESS) if (Status != STATUS_SUCCESS)
{ {
return(Status); return(Status);
} }*/
switch (ProcessInformationClass) switch (ProcessInformationClass)
{ {

View file

@ -210,8 +210,6 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ThreadAttributes) POBJECT_ATTRIBUTES ThreadAttributes)
{ {
ULONG ThreadId;
ULONG ProcessId;
PETHREAD Thread; PETHREAD Thread;
NTSTATUS Status; NTSTATUS Status;
@ -256,7 +254,8 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
UserMode); UserMode);
InitializeListHead(Thread->Tcb.ApcList); InitializeListHead(Thread->Tcb.ApcList);
InitializeListHead(&(Thread->IrpList)); InitializeListHead(&(Thread->IrpList));
Thread->Cid.UniqueThread=InterlockedIncrement(&NextThreadUniqueId); Thread->Cid.UniqueThread = (HANDLE)InterlockedIncrement(
&NextThreadUniqueId);
ObReferenceObjectByPointer(Thread, ObReferenceObjectByPointer(Thread,
THREAD_ALL_ACCESS, THREAD_ALL_ACCESS,
PsThreadType, PsThreadType,

View file

@ -45,7 +45,8 @@ NTSTATUS ZwSetInformationThread(HANDLE ThreadHandle,
ThreadBasicInformationP->TebBaseAddress = Thread->Tcb.Teb; ThreadBasicInformationP->TebBaseAddress = Thread->Tcb.Teb;
ThreadBasicInformationP->AffinityMask = Thread->Tcb.Affinity; ThreadBasicInformationP->AffinityMask = Thread->Tcb.Affinity;
ThreadBasicInformationP->BasePriority = Thread->Tcb.BasePriority; ThreadBasicInformationP->BasePriority = Thread->Tcb.BasePriority;
ThreadBasicInformationP->UniqueThreadId = Thread->Cid.UniqueThread; ThreadBasicInformationP->UniqueThreadId = (ULONG)
Thread->Cid.UniqueThread;
Status = STATUS_SUCCESS; Status = STATUS_SUCCESS;
break; break;

View file

@ -48,7 +48,7 @@ VOID RtlCopyBytes(PVOID Destination,
RtlCopyMemory(Destination,Source,Length); RtlCopyMemory(Destination,Source,Length);
} }
VOID RtlCopyMemory(VOID* Destination, VOID* Source, ULONG Length) VOID RtlCopyMemory(VOID* Destination, CONST VOID* Source, ULONG Length)
{ {
DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n", DPRINT("RtlCopyMemory(Destination %x Source %x Length %d\n",
Destination,Source,Length); Destination,Source,Length);

View file

@ -16,12 +16,11 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
#undef memcpy
void *memcpy (void *to, const void *from, size_t count) void *memcpy (void *to, const void *from, size_t count)
{ {
register char *f = from; const char *f = from;
register char *t = to; char *t = to;
register int i = count; int i = count;
while (i-- > 0) while (i-- > 0)
*t++ = *f++; *t++ = *f++;

View file

@ -16,8 +16,3 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID RtlGetCallersAddress(PVOID* CallersAddress)
{
PULONG stk = (PULONG)(&CallersAddress);
*CallersAddress = stk[-1];
}

View file

@ -21,14 +21,8 @@
#define Aa_Difference ('A'-'a') #define Aa_Difference ('A'-'a')
PUNICODE_STRING RtlDuplicateUnicodeString(PUNICODE_STRING Dest, extern unsigned long simple_strtoul(const char *cp, char **endp,
PUNICODE_STRING Src) unsigned int base);
{
if (Dest==NULL)
{
Dest=ExAllocatePool(NonPagedPool,sizeof(UNICODE_STRING));
}
}
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString) VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString)
{ {
@ -127,8 +121,9 @@ NTSTATUS RtlAppendUnicodeToString(IN OUT PUNICODE_STRING Destination,
NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value) NTSTATUS RtlCharToInteger(IN PCSZ String, IN ULONG Base, IN OUT PULONG Value)
{ {
*Value=simple_strtoul((const char *)String, NULL, Base); *Value=simple_strtoul((const char *)String, NULL, Base);
}; return(STATUS_SUCCESS);
}
LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive) LONG RtlCompareString(PSTRING String1, PSTRING String2, BOOLEAN CaseInsensitive)
{ {
@ -348,7 +343,7 @@ VOID RtlInitString(IN OUT PSTRING DestinationString,
VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString, VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PCWSTR SourceString) IN PCWSTR SourceString)
{ {
unsigned long i, DestSize; unsigned long DestSize;
DPRINT("RtlInitUnicodeString(DestinationString %x, " DPRINT("RtlInitUnicodeString(DestinationString %x, "
"SourceString %x)\n",DestinationString,SourceString); "SourceString %x)\n",DestinationString,SourceString);
@ -368,6 +363,7 @@ VOID RtlInitUnicodeString(IN OUT PUNICODE_STRING DestinationString,
} }
} }
#if 0
NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base, /* optional */
IN OUT PUNICODE_STRING String) IN OUT PUNICODE_STRING String)
{ {
@ -384,7 +380,7 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
if(Base==2) { if(Base==2) {
sprintf(str, "%b", Value); sprintf(str, "%b", Value);
} else { } else {
sprintf(str, "%u", Value); sprintf(str, "%u", (unsigned int)Value);
}; };
len=strlen(str); len=strlen(str);
@ -402,7 +398,8 @@ NTSTATUS RtlIntegerToUnicodeString(IN ULONG Value, IN ULONG Base,
ExFreePool(str); ExFreePool(str);
return STATUS_SUCCESS; return STATUS_SUCCESS;
}; }
#endif
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString, NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
IN PUNICODE_STRING SourceString, IN PUNICODE_STRING SourceString,
@ -487,7 +484,8 @@ NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
*Value=simple_strtoul(str, NULL, Base); *Value=simple_strtoul(str, NULL, Base);
ExFreePool(str); ExFreePool(str);
}; return(STATUS_SUCCESS);
}
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString, NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
IN PUNICODE_STRING SourceString, IN PUNICODE_STRING SourceString,

View file

@ -18,6 +18,7 @@
#include <internal/debug.h> #include <internal/debug.h>
#include <string.h> #include <string.h>
#include <internal/string.h> #include <internal/string.h>
#include <ctype.h>
#include <ddk/ntddk.h> #include <ddk/ntddk.h>

View file

@ -13,6 +13,7 @@
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
#include <wchar.h> #include <wchar.h>
#include <ctype.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>
@ -62,7 +63,6 @@ wcschr(const wchar_t *str, wchar_t ch)
return NULL; return NULL;
} }
#if 0
wchar_t towupper(wchar_t w) wchar_t towupper(wchar_t w)
{ {
if (w < L'A') if (w < L'A')
@ -74,11 +74,10 @@ wchar_t towupper(wchar_t w)
return(w); return(w);
} }
} }
#endif
int wcsicmp(const wchar_t* cs, const wchar_t* ct) int wcsicmp(const wchar_t* cs, const wchar_t* ct)
{ {
while (*cs != '\0' && *ct != '\0' && wtoupper(*cs) == wtoupper(*ct)) while (*cs != '\0' && *ct != '\0' && towupper(*cs) == towupper(*ct))
{ {
cs++; cs++;
ct++; ct++;

View file

@ -68,6 +68,7 @@ NtSetSecurityObject(
IN PSECURITY_DESCRIPTOR SecurityDescriptor IN PSECURITY_DESCRIPTOR SecurityDescriptor
) )
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS
@ -79,6 +80,7 @@ NtSetInformationToken(
IN ULONG TokenInformationLength IN ULONG TokenInformationLength
) )
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS
@ -89,6 +91,7 @@ NtPrivilegeCheck(
IN PBOOLEAN Result IN PBOOLEAN Result
) )
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS
@ -101,6 +104,7 @@ NtPrivilegedServiceAuditAlarm(
IN BOOLEAN AccessGranted IN BOOLEAN AccessGranted
) )
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS
@ -112,8 +116,10 @@ NtPrivilegeObjectAuditAlarm(
IN ULONG DesiredAccess, IN ULONG DesiredAccess,
IN PPRIVILEGE_SET Privileges, IN PPRIVILEGE_SET Privileges,
IN BOOLEAN AccessGranted IN BOOLEAN AccessGranted
)
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS
@ -131,6 +137,7 @@ NtOpenObjectAuditAlarm(
OUT PBOOLEAN GenerateOnClose OUT PBOOLEAN GenerateOnClose
) )
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS
@ -141,6 +148,7 @@ NtOpenProcessToken(
OUT PHANDLE TokenHandle OUT PHANDLE TokenHandle
) )
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS
@ -152,179 +160,157 @@ NtOpenThreadToken(
OUT PHANDLE TokenHandle OUT PHANDLE TokenHandle
) )
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtDuplicateToken(IN HANDLE ExistingToken,
STDCALL IN ACCESS_MASK DesiredAccess,
NtDuplicateToken( IN POBJECT_ATTRIBUTES ObjectAttributes,
IN HANDLE ExistingToken, IN SECURITY_IMPERSONATION_LEVEL
IN ACCESS_MASK DesiredAccess, ImpersonationLevel,
IN POBJECT_ATTRIBUTES ObjectAttributes, IN TOKEN_TYPE TokenType,
IN SECURITY_IMPERSONATION_LEVEL ImpersonationLevel, OUT PHANDLE NewToken)
IN TOKEN_TYPE TokenType,
OUT PHANDLE NewToken
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS STDCALL NtImpersonateClientOfPort(VOID) NTSTATUS STDCALL NtImpersonateClientOfPort(VOID)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtImpersonateThread(IN HANDLE ThreadHandle,
STDCALL IN HANDLE ThreadToImpersonate,
NtImpersonateThread( IN PSECURITY_QUALITY_OF_SERVICE
IN HANDLE ThreadHandle, SecurityQualityOfService)
IN HANDLE ThreadToImpersonate,
IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS STDCALL NtCreateToken(VOID) NTSTATUS STDCALL NtCreateToken(VOID)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtDeleteObjectAuditAlarm(IN PUNICODE_STRING SubsystemName,
STDCALL IN PVOID HandleId,
NtDeleteObjectAuditAlarm ( IN BOOLEAN GenerateOnClose)
IN PUNICODE_STRING SubsystemName,
IN PVOID HandleId,
IN BOOLEAN GenerateOnClose
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
STDCALL
NtAllocateLocallyUniqueId(
OUT LUID *LocallyUniqueId
)
{ {
return(ZwAllocateLocallyUniqueId(LocallyUniqueId));
} }
NTSTATUS NTSTATUS STDCALL ZwAllocateLocallyUniqueId(OUT LUID *LocallyUniqueId)
STDCALL
ZwAllocateLocallyUniqueId(
OUT LUID *LocallyUniqueId
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtAccessCheckAndAuditAlarm(IN PUNICODE_STRING SubsystemName,
STDCALL IN PHANDLE ObjectHandle,
NtAccessCheckAndAuditAlarm( IN POBJECT_ATTRIBUTES ObjectAttributes,
IN PUNICODE_STRING SubsystemName, IN ACCESS_MASK DesiredAccess,
IN PHANDLE ObjectHandle, IN PGENERIC_MAPPING GenericMapping,
IN POBJECT_ATTRIBUTES ObjectAttributes, IN BOOLEAN ObjectCreation,
IN ACCESS_MASK DesiredAccess, OUT PULONG GrantedAccess,
IN PGENERIC_MAPPING GenericMapping, OUT PBOOLEAN AccessStatus,
IN BOOLEAN ObjectCreation, OUT PBOOLEAN GenerateOnClose)
OUT PULONG GrantedAccess,
OUT PBOOLEAN AccessStatus,
OUT PBOOLEAN GenerateOnClose
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtAdjustGroupsToken(IN HANDLE TokenHandle,
STDCALL IN BOOLEAN ResetToDefault,
NtAdjustGroupsToken( IN PTOKEN_GROUPS NewState,
IN HANDLE TokenHandle, IN ULONG BufferLength,
IN BOOLEAN ResetToDefault, OUT PTOKEN_GROUPS PreviousState OPTIONAL,
IN PTOKEN_GROUPS NewState, OUT PULONG ReturnLength)
IN ULONG BufferLength,
OUT PTOKEN_GROUPS PreviousState OPTIONAL,
OUT PULONG ReturnLength
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtAdjustPrivilegesToken(IN HANDLE TokenHandle,
STDCALL IN BOOLEAN DisableAllPrivileges,
NtAdjustPrivilegesToken( IN PTOKEN_PRIVILEGES NewState,
IN HANDLE TokenHandle, IN ULONG BufferLength,
IN BOOLEAN DisableAllPrivileges, OUT PTOKEN_PRIVILEGES PreviousState,
IN PTOKEN_PRIVILEGES NewState, OUT PULONG ReturnLength)
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
)
{ {
return(ZwAdjustPrivilegesToken(TokenHandle,
DisableAllPrivileges,
NewState,
BufferLength,
PreviousState,
ReturnLength));
} }
NTSTATUS NTSTATUS STDCALL ZwAdjustPrivilegesToken(IN HANDLE TokenHandle,
STDCALL IN BOOLEAN DisableAllPrivileges,
NtAllocateUuids( IN PTOKEN_PRIVILEGES NewState,
PLARGE_INTEGER Time, IN ULONG BufferLength,
PULONG Version, // ??? OUT PTOKEN_PRIVILEGES PreviousState,
PULONG ClockCycle OUT PULONG ReturnLength)
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtAllocateUuids(PLARGE_INTEGER Time,
STDCALL PULONG Version, // ???
ZwAllocateUuids( PULONG ClockCycle)
PLARGE_INTEGER Time,
PULONG Version, // ???
PULONG ClockCycle
)
{ {
return(ZwAllocateUuids(Time,
Version,
ClockCycle));
} }
NTSTATUS NTSTATUS STDCALL ZwAllocateUuids(PLARGE_INTEGER Time,
STDCALL PULONG Version, // ???
NtCloseObjectAuditAlarm( PULONG ClockCycle)
IN PUNICODE_STRING SubsystemName,
IN PVOID HandleId,
IN BOOLEAN GenerateOnClose
)
{ {
UNIMPLEMENTED;
} }
NTSTATUS NTSTATUS STDCALL NtCloseObjectAuditAlarm(IN PUNICODE_STRING SubsystemName,
STDCALL IN PVOID HandleId,
NtAccessCheck( IN BOOLEAN GenerateOnClose)
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 NTSTATUS STDCALL NtAccessCheck(IN PSECURITY_DESCRIPTOR SecurityDescriptor,
STDCALL IN HANDLE ClientToken,
ZwAccessCheck( IN ACCESS_MASK DesiredAccess,
IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN PGENERIC_MAPPING GenericMapping,
IN HANDLE ClientToken, OUT PRIVILEGE_SET PrivilegeSet,
IN ACCESS_MASK DesiredAcces, OUT PULONG ReturnLength,
IN PGENERIC_MAPPING GenericMapping, OUT PULONG GrantedAccess,
OUT PRIVILEGE_SET PrivilegeSet, OUT PBOOLEAN AccessStatus)
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, NTSTATUS RtlCreateSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor,

View file

@ -77,7 +77,7 @@ int main(int argc, char* argv[])
fprintf(stdout,"{\"_%s\",(unsigned int)%s},\n",sym[j],sym[j]); fprintf(stdout,"{\"_%s\",(unsigned int)%s},\n",sym[j],sym[j]);
} }
fprintf(stdout,"{NULL,NULL},\n"); fprintf(stdout,"{(char *)NULL,0},\n");
fprintf(stdout,"};\n"); fprintf(stdout,"};\n");
return(0); return(0);

View file

@ -40,6 +40,10 @@ else
DEBUGGING_CFLAGS = DEBUGGING_CFLAGS =
endif endif
ifeq ($(WARNINGS_ARE_ERRORS),yes)
EXTRA_CFLAGS = -Werror
endif
DEFINES = -DDBG -DCOMPILER_LARGE_INTEGERS DEFINES = -DDBG -DCOMPILER_LARGE_INTEGERS
ifeq ($(WIN32_LEAN_AND_MEAN),yes) ifeq ($(WIN32_LEAN_AND_MEAN),yes)
@ -52,7 +56,8 @@ CC = $(PREFIX)gcc
NATIVE_CC = gcc NATIVE_CC = gcc
CFLAGS = -O2 -I../../../include -I../../include \ CFLAGS = -O2 -I../../../include -I../../include \
-I../include -fno-builtin $(LEAN_AND_MEAN_DEFINE) \ -I../include -fno-builtin $(LEAN_AND_MEAN_DEFINE) \
$(DEFINES) -Wall -Wstrict-prototypes $(DEBUGGING_CFLAGS) $(DEFINES) -Wall -Wstrict-prototypes $(DEBUGGING_CFLAGS) \
$(EXTRA_CFLAGS)
CXXFLAGS = $(CFLAGS) CXXFLAGS = $(CFLAGS)
NFLAGS = -i../../include/ -i../include/ -pinternal/asm.inc -f$(NASM_FORMAT) -d$(NASM_FORMAT) NFLAGS = -i../../include/ -i../include/ -pinternal/asm.inc -f$(NASM_FORMAT) -d$(NASM_FORMAT)
LD = $(PREFIX)ld LD = $(PREFIX)ld