mirror of
https://github.com/reactos/reactos.git
synced 2024-06-29 01:12:06 +00:00
brings code in line with release 12
svn path=/trunk/; revision=55
This commit is contained in:
parent
ee81c811cd
commit
3f988bd286
|
@ -127,6 +127,42 @@ typedef struct _IO_STACK_LOCATION
|
||||||
struct _VPB* Vpb;
|
struct _VPB* Vpb;
|
||||||
struct _DEVICE_OBJECT* DeviceObject;
|
struct _DEVICE_OBJECT* DeviceObject;
|
||||||
} Mount;
|
} Mount;
|
||||||
|
struct {
|
||||||
|
ULONG Length;
|
||||||
|
FILE_INFORMATION_CLASS FileInformationClass;
|
||||||
|
} QueryFile;
|
||||||
|
struct {
|
||||||
|
ULONG Length;
|
||||||
|
FS_INFORMATION_CLASS FileInformationClass;
|
||||||
|
} QueryVolume;
|
||||||
|
struct {
|
||||||
|
ULONG Length;
|
||||||
|
FS_INFORMATION_CLASS FileInformationClass;
|
||||||
|
} SetVolume;
|
||||||
|
struct {
|
||||||
|
ULONG Length;
|
||||||
|
FILE_INFORMATION_CLASS FileInformationClass;
|
||||||
|
struct FILE_OBJECT* FileObject;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
BOOLEAN ReplaceIfExists;
|
||||||
|
BOOLEAN AdvanceOnly;
|
||||||
|
} d;
|
||||||
|
ULONG ClusterCount;
|
||||||
|
HANDLE DeleteHandle;
|
||||||
|
} u;
|
||||||
|
} SetFile;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is a guess
|
||||||
|
*/
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
FILE_INFORMATION_CLASS FileInformationClass;
|
||||||
|
BOOLEAN ReturnSingleEntry;
|
||||||
|
PUNICODE_STRING FileName;
|
||||||
|
BOOLEAN RestartScan;
|
||||||
|
} QueryDirectory;
|
||||||
} Parameters;
|
} Parameters;
|
||||||
|
|
||||||
PIO_COMPLETION_ROUTINE CompletionRoutine;
|
PIO_COMPLETION_ROUTINE CompletionRoutine;
|
||||||
|
|
|
@ -299,5 +299,30 @@ RtlFreeHeap(
|
||||||
PVOID Address
|
PVOID Address
|
||||||
);
|
);
|
||||||
|
|
||||||
|
NTSTATUS RtlUnicodeStringToAnsiString(IN OUT PANSI_STRING DestinationString,
|
||||||
|
IN PUNICODE_STRING SourceString,
|
||||||
|
IN BOOLEAN AllocateDestinationString);
|
||||||
|
NTSTATUS RtlUnicodeStringToInteger(IN PUNICODE_STRING String, IN ULONG Base,
|
||||||
|
OUT PULONG Value);
|
||||||
|
NTSTATUS RtlUpcaseUnicodeString(IN OUT PUNICODE_STRING DestinationString,
|
||||||
|
IN PUNICODE_STRING SourceString,
|
||||||
|
IN BOOLEAN AllocateDestinationString);
|
||||||
|
VOID RtlUpperString(PSTRING DestinationString, PSTRING SourceString);
|
||||||
|
BOOLEAN RtlValidSecurityDescriptor(PSECURITY_DESCRIPTOR SecurityDescriptor);
|
||||||
|
NTSTATUS RtlWriteRegistryValue(ULONG RelativeTo,
|
||||||
|
PWSTR Path,
|
||||||
|
PWSTR ValueName,
|
||||||
|
ULONG ValueType,
|
||||||
|
PVOID ValueData,
|
||||||
|
ULONG ValueLength);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
VOID RtlStoreUlong(PULONG Address,
|
||||||
|
ULONG Value);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __DDK_RTL_H */
|
#endif /* __DDK_RTL_H */
|
||||||
|
|
|
@ -23,15 +23,17 @@
|
||||||
#define DPRINT1(x)
|
#define DPRINT1(x)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is umimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
|
#define UNIMPLEMENTED do {DbgPrint("%s at %s:%d is unimplemented, have a nice day\n",__FUNCTION__,__FILE__,__LINE__); for(;;); } while(0);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#define DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); ExAllocatePool(NonPagedPool, 0); } while(0);
|
#define OLD_DPRINT(fmt,args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(fmt,args); } while(0);
|
||||||
|
#define DPRINT(args...) do { DbgPrint("(%s:%d) ",__FILE__,__LINE__); DbgPrint(args); ExAllocatePool(NonPagedPool,0); } while(0);
|
||||||
//#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
|
//#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); (*((unsigned int *)0))=1; for (;;); }
|
||||||
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
|
#define assert(x) if (!(x)) {DbgPrint("Assertion "#x" failed at %s:%d\n", __FILE__,__LINE__); for (;;); }
|
||||||
#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
|
#define CHECKPOINT do { DbgPrint("%s:%d\n",__FILE__,__LINE__); ExAllocatePool(NonPagedPool,0); } while(0);
|
||||||
#else
|
#else
|
||||||
#define DPRINT(fmt,args...)
|
#define DPRINT(args...)
|
||||||
|
#define OLD_DPRINT(args...)
|
||||||
#define assert(x)
|
#define assert(x)
|
||||||
#define CHECKPOINT
|
#define CHECKPOINT
|
||||||
#endif /* NDEBUG */
|
#endif /* NDEBUG */
|
||||||
|
|
|
@ -567,10 +567,10 @@ l8:
|
||||||
dw 0x00eb,0x00eb ; jmp $+2, jmp $+2
|
dw 0x00eb,0x00eb ; jmp $+2, jmp $+2
|
||||||
out 0A0h,al ; and to 8259A-2
|
out 0A0h,al ; and to 8259A-2
|
||||||
dw 0x00eb,0x00eb
|
dw 0x00eb,0x00eb
|
||||||
mov al,020h ; start of hardware int's (0x20)
|
mov al,040h ; start of hardware int's (0x20)
|
||||||
out 021h,al
|
out 021h,al
|
||||||
dw 0x00eb,0x00eb
|
dw 0x00eb,0x00eb
|
||||||
mov al,028h ; start of hardware int's 2 (0x28)
|
mov al,048h ; start of hardware int's 2 (0x28)
|
||||||
out 0A1h,al
|
out 0A1h,al
|
||||||
dw 0x00eb,0x00eb
|
dw 0x00eb,0x00eb
|
||||||
mov al,04h ; 8259-1 is master
|
mov al,04h ; 8259-1 is master
|
||||||
|
@ -626,6 +626,7 @@ next:
|
||||||
mov ss,ax
|
mov ss,ax
|
||||||
mov es,ax
|
mov es,ax
|
||||||
mov fs,ax
|
mov fs,ax
|
||||||
|
mov gs,ax
|
||||||
|
|
||||||
;
|
;
|
||||||
; Initalize eflags
|
; Initalize eflags
|
||||||
|
|
|
@ -15,7 +15,7 @@ include rules.mak
|
||||||
#
|
#
|
||||||
# Required to run the system
|
# Required to run the system
|
||||||
#
|
#
|
||||||
COMPONENTS = kernel lib
|
COMPONENTS = iface_native ntoskrnl kernel32 ntdll crtdll mingw32
|
||||||
|
|
||||||
#
|
#
|
||||||
# Select the server(s) you want to build
|
# Select the server(s) you want to build
|
||||||
|
@ -30,55 +30,79 @@ LOADERS = dos
|
||||||
#
|
#
|
||||||
# Select the device drivers and filesystems you want
|
# Select the device drivers and filesystems you want
|
||||||
#
|
#
|
||||||
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test minix
|
KERNEL_SERVICES = parallel keyboard null mouse serial sound ide test sdisk \
|
||||||
|
minix vfat
|
||||||
|
|
||||||
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES)
|
APPS = hello shell
|
||||||
|
|
||||||
|
all: $(COMPONENTS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
|
||||||
|
|
||||||
|
clean: dummy
|
||||||
|
make -C iface/native clean
|
||||||
|
|
||||||
|
#
|
||||||
|
# Applications
|
||||||
|
#
|
||||||
|
hello: dummy
|
||||||
|
make -C apps/hello
|
||||||
|
|
||||||
|
cmd: dummy
|
||||||
|
make -C apps/cmd
|
||||||
|
|
||||||
|
shell: dummy
|
||||||
|
make -C apps/shell
|
||||||
|
|
||||||
|
#
|
||||||
|
# Interfaces
|
||||||
|
#
|
||||||
|
iface_native: dummy
|
||||||
|
make -C iface/native
|
||||||
|
|
||||||
#
|
#
|
||||||
# Device driver rules
|
# Device driver rules
|
||||||
#
|
#
|
||||||
|
vfat: dummy
|
||||||
|
make -C services/fs/vfat
|
||||||
|
|
||||||
sdisk: dummy
|
sdisk: dummy
|
||||||
make -C services/sdisk
|
make -C services/dd/sdisk
|
||||||
|
|
||||||
minix: dummy
|
minix: dummy
|
||||||
make -C services/fs/minix
|
make -C services/fs/minix
|
||||||
|
|
||||||
|
template: dummy
|
||||||
|
make -C services/fs/template
|
||||||
|
|
||||||
|
|
||||||
ide-test: dummy
|
ide-test: dummy
|
||||||
make -C services/ide-test
|
make -C services/dd/ide-test
|
||||||
|
|
||||||
ide: dummy
|
ide: dummy
|
||||||
make -C services/ide
|
make -C services/dd/ide
|
||||||
|
|
||||||
test: dummy
|
test: dummy
|
||||||
make -C services/test
|
make -C services/dd/test
|
||||||
|
|
||||||
test1: dummy
|
test1: dummy
|
||||||
make -C services/test1
|
make -C services/dd/test1
|
||||||
|
|
||||||
null: dummy
|
null: dummy
|
||||||
make -C services/null
|
make -C services/dd/null
|
||||||
|
|
||||||
parallel: dummy
|
parallel: dummy
|
||||||
make -C services/parallel
|
make -C services/dd/parallel
|
||||||
|
|
||||||
keyboard: dummy
|
keyboard: dummy
|
||||||
make -C services/keyboard
|
make -C services/dd/keyboard
|
||||||
|
|
||||||
mouse: dummy
|
mouse: dummy
|
||||||
make -C services/mouse
|
make -C services/dd/mouse
|
||||||
|
|
||||||
serial: dummy
|
serial: dummy
|
||||||
make -C services/serial
|
make -C services/dd/serial
|
||||||
|
|
||||||
sound: dummy
|
sound: dummy
|
||||||
make -C services/sound
|
make -C services/dd/sound
|
||||||
|
|
||||||
ide: dummy
|
|
||||||
make -C services/ide
|
|
||||||
|
|
||||||
ide-test: dummy
|
|
||||||
make -C services/ide-test
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Kernel loaders
|
# Kernel loaders
|
||||||
|
@ -91,10 +115,19 @@ dos: dummy
|
||||||
# Required system components
|
# Required system components
|
||||||
#
|
#
|
||||||
|
|
||||||
kernel: dummy
|
ntoskrnl: dummy
|
||||||
make -C ntoskrnl
|
make -C ntoskrnl
|
||||||
|
|
||||||
lib: dummy
|
kernel32: dummy
|
||||||
make -C lib
|
make -C lib/kernel32
|
||||||
|
|
||||||
|
ntdll: dummy
|
||||||
|
make -C lib/ntdll
|
||||||
|
|
||||||
|
crtdll: dummy
|
||||||
|
make -C lib/crtdll
|
||||||
|
|
||||||
|
mingw32: dummy
|
||||||
|
make -C lib/mingw32
|
||||||
|
|
||||||
dummy:
|
dummy:
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: mkernel/hal/irql.c
|
* FILE: ntoskrnl/hal/x86/irql.c
|
||||||
* PURPOSE: Implements IRQLs
|
* PURPOSE: Implements IRQLs
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
*/
|
*/
|
||||||
|
@ -122,8 +122,8 @@ VOID KeRaiseIrql(KIRQL NewIrql, PKIRQL OldIrql)
|
||||||
OldIrql);
|
OldIrql);
|
||||||
if (NewIrql < CurrentIrql)
|
if (NewIrql < CurrentIrql)
|
||||||
{
|
{
|
||||||
DbgPrint("%s:%d CurrentIrql %x NewIrql %x OldIrql %x\n",__FILE__,__LINE__,
|
DbgPrint("%s:%d CurrentIrql %x NewIrql %x OldIrql %x\n",
|
||||||
CurrentIrql,NewIrql,OldIrql);
|
__FILE__,__LINE__,CurrentIrql,NewIrql,OldIrql);
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,13 @@
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
NTSTATUS IoPrepareIrpBuffer(PIRP Irp,
|
||||||
|
PDEVICE_OBJECT DeviceObject,
|
||||||
|
PVOID Buffer,
|
||||||
|
PVOID Length)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
||||||
PDEVICE_OBJECT DeviceObject,
|
PDEVICE_OBJECT DeviceObject,
|
||||||
PKEVENT UserEvent,
|
PKEVENT UserEvent,
|
||||||
|
@ -27,6 +34,10 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
* MinorFunction = Type of filesystem control
|
* MinorFunction = Type of filesystem control
|
||||||
* DeviceObject = Device object to send the request to
|
* DeviceObject = Device object to send the request to
|
||||||
|
* UserEvent = Event used to notify the caller of completion
|
||||||
|
* IoStatusBlock (OUT) = Used to return the status of the operation
|
||||||
|
* DeviceToMount = Device to mount (for the IRP_MN_MOUNT_DEVICE
|
||||||
|
* request)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
|
@ -48,9 +59,23 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction,
|
||||||
StackPtr->Control = 0;
|
StackPtr->Control = 0;
|
||||||
StackPtr->DeviceObject = DeviceObject;
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
StackPtr->FileObject = NULL;
|
StackPtr->FileObject = NULL;
|
||||||
|
|
||||||
|
switch(MinorFunction)
|
||||||
|
{
|
||||||
|
case IRP_MN_USER_FS_REQUEST:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IRP_MN_MOUNT_VOLUME:
|
||||||
StackPtr->Parameters.Mount.Vpb = DeviceObject->Vpb;
|
StackPtr->Parameters.Mount.Vpb = DeviceObject->Vpb;
|
||||||
StackPtr->Parameters.Mount.DeviceObject = DeviceToMount;
|
StackPtr->Parameters.Mount.DeviceObject = DeviceToMount;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IRP_MN_VERIFY_VOLUME:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case IRP_MN_LOAD_FILE_SYSTEM:
|
||||||
|
break;
|
||||||
|
}
|
||||||
return(Irp);
|
return(Irp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +102,10 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
||||||
PIRP Irp;
|
PIRP Irp;
|
||||||
PIO_STACK_LOCATION StackPtr;
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
|
||||||
|
DPRINT("IoBuildAsynchronousFsdRequest(MajorFunction %x, DeviceObject %x, "
|
||||||
|
"Buffer %x, Length %x, StartingOffset %x, "
|
||||||
|
"IoStatusBlock %x\n",MajorFunction,DeviceObject,Buffer,Length,
|
||||||
|
StartingOffset,IoStatusBlock);
|
||||||
|
|
||||||
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
||||||
if (Irp==NULL)
|
if (Irp==NULL)
|
||||||
|
@ -84,6 +113,17 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->MajorFunction = MajorFunction;
|
||||||
|
StackPtr->MinorFunction = 0;
|
||||||
|
StackPtr->Flags = 0;
|
||||||
|
StackPtr->Control = 0;
|
||||||
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
|
StackPtr->FileObject = NULL;
|
||||||
|
StackPtr->Parameters.Write.Length = Length;
|
||||||
|
|
||||||
|
if (MajorFunction == IRP_MJ_READ || MajorFunction == IRP_MJ_WRITE)
|
||||||
|
{
|
||||||
Irp->UserBuffer = (LPVOID)Buffer;
|
Irp->UserBuffer = (LPVOID)Buffer;
|
||||||
if (DeviceObject->Flags&DO_BUFFERED_IO)
|
if (DeviceObject->Flags&DO_BUFFERED_IO)
|
||||||
{
|
{
|
||||||
|
@ -94,7 +134,6 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
||||||
{
|
{
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
Irp->UserBuffer = NULL;
|
|
||||||
}
|
}
|
||||||
if (DeviceObject->Flags&DO_DIRECT_IO)
|
if (DeviceObject->Flags&DO_DIRECT_IO)
|
||||||
{
|
{
|
||||||
|
@ -105,17 +144,6 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
||||||
Irp->UserBuffer = NULL;
|
Irp->UserBuffer = NULL;
|
||||||
Irp->AssociatedIrp.SystemBuffer = NULL;
|
Irp->AssociatedIrp.SystemBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->UserIosb = IoStatusBlock;
|
|
||||||
|
|
||||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
|
||||||
StackPtr->MajorFunction = MajorFunction;
|
|
||||||
StackPtr->MinorFunction = 0;
|
|
||||||
StackPtr->Flags = 0;
|
|
||||||
StackPtr->Control = 0;
|
|
||||||
StackPtr->DeviceObject = DeviceObject;
|
|
||||||
StackPtr->FileObject = NULL;
|
|
||||||
StackPtr->Parameters.Write.Length = Length;
|
|
||||||
if (StartingOffset!=NULL)
|
if (StartingOffset!=NULL)
|
||||||
{
|
{
|
||||||
StackPtr->Parameters.Write.ByteOffset.LowPart =
|
StackPtr->Parameters.Write.ByteOffset.LowPart =
|
||||||
|
@ -128,6 +156,9 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
||||||
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
|
StackPtr->Parameters.Write.ByteOffset.LowPart = 0;
|
||||||
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
|
StackPtr->Parameters.Write.ByteOffset.HighPart = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Irp->UserIosb = IoStatusBlock;
|
||||||
|
|
||||||
return(Irp);
|
return(Irp);
|
||||||
}
|
}
|
||||||
|
@ -215,9 +246,6 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction,
|
||||||
Irp->AssociatedIrp.SystemBuffer = NULL;
|
Irp->AssociatedIrp.SystemBuffer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Irp->UserIosb = IoStatusBlock;
|
|
||||||
Irp->UserEvent = Event;
|
|
||||||
|
|
||||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
StackPtr->MajorFunction = MajorFunction;
|
StackPtr->MajorFunction = MajorFunction;
|
||||||
StackPtr->MinorFunction = 0;
|
StackPtr->MinorFunction = 0;
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
/* INCLUDES ****************************************************************/
|
/* INCLUDES ****************************************************************/
|
||||||
|
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
#include <internal/io.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
//#define NDEBUG
|
||||||
|
@ -79,7 +80,12 @@ VOID IoMarkIrpPending(PIRP Irp)
|
||||||
* Irp = Irp to mark
|
* Irp = Irp to mark
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
|
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
|
||||||
|
IoGetCurrentIrpStackLocation(Irp));
|
||||||
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
|
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
|
||||||
|
DPRINT("IoGetCurrentIrpStackLocation(Irp)->Control %x\n",
|
||||||
|
IoGetCurrentIrpStackLocation(Irp)->Control);
|
||||||
|
DPRINT("SL_PENDING_RETURNED %x\n",SL_PENDING_RETURNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
USHORT IoSizeOfIrp(CCHAR StackSize)
|
USHORT IoSizeOfIrp(CCHAR StackSize)
|
||||||
|
@ -156,7 +162,6 @@ NTSTATUS IoCallDriver(PDEVICE_OBJECT DevObject, PIRP irp)
|
||||||
DPRINT("Io stack address %x\n",param);
|
DPRINT("Io stack address %x\n",param);
|
||||||
DPRINT("Function %d Routine %x\n",param->MajorFunction,
|
DPRINT("Function %d Routine %x\n",param->MajorFunction,
|
||||||
drv->MajorFunction[param->MajorFunction]);
|
drv->MajorFunction[param->MajorFunction]);
|
||||||
DPRINT("IRP_MJ_CREATE %d\n",IRP_MJ_CREATE);
|
|
||||||
|
|
||||||
return(drv->MajorFunction[param->MajorFunction](DevObject,irp));
|
return(drv->MajorFunction[param->MajorFunction](DevObject,irp));
|
||||||
}
|
}
|
||||||
|
@ -208,7 +213,7 @@ VOID IoSetCompletionRoutine(PIRP Irp,
|
||||||
param->CompletionContext=Context;
|
param->CompletionContext=Context;
|
||||||
if (InvokeOnSuccess)
|
if (InvokeOnSuccess)
|
||||||
{
|
{
|
||||||
param->Control = SL_INVOKE_ON_SUCCESS;
|
param->Control = param->Control | SL_INVOKE_ON_SUCCESS;
|
||||||
}
|
}
|
||||||
if (InvokeOnError)
|
if (InvokeOnError)
|
||||||
{
|
{
|
||||||
|
@ -220,6 +225,16 @@ VOID IoSetCompletionRoutine(PIRP Irp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID IopCompleteRequest(struct _KAPC* Apc,
|
||||||
|
PKNORMAL_ROUTINE* NormalRoutine,
|
||||||
|
PVOID* NormalContext,
|
||||||
|
PVOID* SystemArgument1,
|
||||||
|
PVOID* SystemArgument2)
|
||||||
|
{
|
||||||
|
IoSecondStageCompletion((PIRP)(*NormalContext),
|
||||||
|
IO_NO_INCREMENT);
|
||||||
|
}
|
||||||
|
|
||||||
VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
|
VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Indicates the caller has finished all processing for a given
|
* FUNCTION: Indicates the caller has finished all processing for a given
|
||||||
|
@ -231,20 +246,47 @@ VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d)\n",
|
DPRINT("IoCompleteRequest(Irp %x, PriorityBoost %d)\n",
|
||||||
Irp,PriorityBoost);
|
Irp,PriorityBoost);
|
||||||
|
|
||||||
for (i=0;i<Irp->StackCount;i++)
|
for (i=0;i<Irp->StackCount;i++)
|
||||||
{
|
{
|
||||||
|
DPRINT("&Irp->Stack[i] %x\n",&Irp->Stack[i]);
|
||||||
if (Irp->Stack[i].CompletionRoutine!=NULL)
|
if (Irp->Stack[i].CompletionRoutine!=NULL)
|
||||||
{
|
{
|
||||||
Irp->Stack[i].CompletionRoutine(Irp->Stack[i].DeviceObject,Irp,
|
Status = Irp->Stack[i].CompletionRoutine(
|
||||||
|
Irp->Stack[i].DeviceObject,
|
||||||
|
Irp,
|
||||||
Irp->Stack[i].CompletionContext);
|
Irp->Stack[i].CompletionContext);
|
||||||
|
if (Status == STATUS_MORE_PROCESSING_REQUIRED)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DPRINT("Irp->Stack[i].Control %x\n",Irp->Stack[i].Control);
|
||||||
|
if (Irp->Stack[i].Control & SL_PENDING_RETURNED)
|
||||||
|
{
|
||||||
|
DPRINT("Setting PendingReturned flag\n");
|
||||||
|
Irp->PendingReturned = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Irp->UserEvent!=NULL)
|
if (Irp->PendingReturned)
|
||||||
{
|
{
|
||||||
KeSetEvent(Irp->UserEvent,PriorityBoost,FALSE);
|
KeInitializeApc(&Irp->Tail.Apc,
|
||||||
|
&Irp->Tail.Overlay.Thread->Tcb,
|
||||||
|
0,
|
||||||
|
IopCompleteRequest,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
0,
|
||||||
|
Irp);
|
||||||
|
KeInsertQueueApc(&Irp->Tail.Apc,NULL,NULL,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
IoSecondStageCompletion(Irp,PriorityBoost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,39 +21,25 @@
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
static VOID IoSecondStageCompletion(PIRP Irp,
|
NTSTATUS NtReadFile(HANDLE FileHandle,
|
||||||
BOOLEAN FromDevice,
|
HANDLE EventHandle,
|
||||||
PDEVICE_OBJECT DeviceObject,
|
PIO_APC_ROUTINE ApcRoutine,
|
||||||
|
PVOID ApcContext,
|
||||||
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
PVOID Buffer,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
PVOID Buffer)
|
PLARGE_INTEGER ByteOffset,
|
||||||
/*
|
PULONG Key)
|
||||||
* FUNCTION: Performs the second stage of irp completion for read/write irps
|
|
||||||
* ARGUMENTS:
|
|
||||||
* Irp = Irp to completion
|
|
||||||
* FromDevice = True if the operation transfered data from the device
|
|
||||||
*/
|
|
||||||
{
|
{
|
||||||
if (Irp->UserIosb!=NULL)
|
return(ZwReadFile(FileHandle,
|
||||||
{
|
EventHandle,
|
||||||
*Irp->UserIosb=Irp->IoStatus;
|
ApcRoutine,
|
||||||
}
|
ApcContext,
|
||||||
|
IoStatusBlock,
|
||||||
if (DeviceObject->Flags & DO_BUFFERED_IO && FromDevice)
|
Buffer,
|
||||||
{
|
Length,
|
||||||
memcpy(Buffer,Irp->AssociatedIrp.SystemBuffer,Length);
|
ByteOffset,
|
||||||
}
|
Key));
|
||||||
if (DeviceObject->Flags & DO_DIRECT_IO)
|
|
||||||
{
|
|
||||||
if (Irp->MdlAddress->MappedSystemVa!=NULL)
|
|
||||||
{
|
|
||||||
MmUnmapLockedPages(Irp->MdlAddress->MappedSystemVa,
|
|
||||||
Irp->MdlAddress);
|
|
||||||
}
|
|
||||||
MmUnlockPages(Irp->MdlAddress);
|
|
||||||
ExFreePool(Irp->MdlAddress);
|
|
||||||
}
|
|
||||||
|
|
||||||
IoFreeIrp(Irp);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS ZwReadFile(HANDLE FileHandle,
|
NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||||
|
@ -77,10 +63,15 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||||
"IoStatusBlock %x)\n",
|
"IoStatusBlock %x)\n",
|
||||||
FileHandle,Buffer,Length,ByteOffset,IoStatusBlock);
|
FileHandle,Buffer,Length,ByteOffset,IoStatusBlock);
|
||||||
|
|
||||||
if (hdr==NULL)
|
Status = ObReferenceObjectByHandle(FileHandle,
|
||||||
|
FILE_READ_DATA,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
&FileObject,
|
||||||
|
NULL);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT("%s() = STATUS_INVALID_HANDLE\n",__FUNCTION__);
|
return(Status);
|
||||||
return(STATUS_INVALID_HANDLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ByteOffset==NULL)
|
if (ByteOffset==NULL)
|
||||||
|
@ -89,6 +80,7 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||||
|
DPRINT("FileObject %x\n",FileObject);
|
||||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
||||||
FileObject->DeviceObject,
|
FileObject->DeviceObject,
|
||||||
Buffer,
|
Buffer,
|
||||||
|
@ -136,6 +128,27 @@ NTSTATUS ZwReadFile(HANDLE FileHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS NtWriteFile(HANDLE FileHandle,
|
||||||
|
HANDLE EventHandle,
|
||||||
|
PIO_APC_ROUTINE ApcRoutine,
|
||||||
|
PVOID ApcContext,
|
||||||
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
PVOID Buffer,
|
||||||
|
ULONG Length,
|
||||||
|
PLARGE_INTEGER ByteOffset,
|
||||||
|
PULONG Key)
|
||||||
|
{
|
||||||
|
return(ZwWriteFile(FileHandle,
|
||||||
|
EventHandle,
|
||||||
|
ApcRoutine,
|
||||||
|
ApcContext,
|
||||||
|
IoStatusBlock,
|
||||||
|
Buffer,
|
||||||
|
Length,
|
||||||
|
ByteOffset,
|
||||||
|
Key));
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS ZwWriteFile(HANDLE FileHandle,
|
NTSTATUS ZwWriteFile(HANDLE FileHandle,
|
||||||
HANDLE EventHandle,
|
HANDLE EventHandle,
|
||||||
PIO_APC_ROUTINE ApcRoutine,
|
PIO_APC_ROUTINE ApcRoutine,
|
||||||
|
@ -168,7 +181,7 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle,
|
||||||
IoStatusBlock);
|
IoStatusBlock);
|
||||||
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||||
Status = IoCallDriver(FileObject->DeviceObject,Irp);
|
Status = IoCallDriver(FileObject->DeviceObject,Irp);
|
||||||
if (Status==STATUS_PENDING)
|
if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||||
{
|
{
|
||||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||||
Status = Irp->IoStatus.Status;
|
Status = Irp->IoStatus.Status;
|
||||||
|
@ -176,3 +189,71 @@ NTSTATUS ZwWriteFile(HANDLE FileHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtReadFileScatter(IN HANDLE FileHandle,
|
||||||
|
IN HANDLE Event OPTIONAL,
|
||||||
|
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
|
||||||
|
IN PVOID UserApcContext OPTIONAL,
|
||||||
|
OUT PIO_STATUS_BLOCK UserIoStatusBlock,
|
||||||
|
IN FILE_SEGMENT_ELEMENT BufferDescription[],
|
||||||
|
IN ULONG BufferLength,
|
||||||
|
IN PLARGE_INTEGER ByteOffset,
|
||||||
|
IN PULONG Key OPTIONAL)
|
||||||
|
{
|
||||||
|
return(ZwReadFileScatter(FileHandle,
|
||||||
|
Event,
|
||||||
|
UserApcRoutine,
|
||||||
|
UserApcContext,
|
||||||
|
UserIoStatusBlock,
|
||||||
|
BufferDescription,
|
||||||
|
BufferLength,
|
||||||
|
ByteOffset,
|
||||||
|
Key));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ZwReadFileScatter(IN HANDLE FileHandle,
|
||||||
|
IN HANDLE Event OPTIONAL,
|
||||||
|
IN PIO_APC_ROUTINE UserApcRoutine OPTIONAL,
|
||||||
|
IN PVOID UserApcContext OPTIONAL,
|
||||||
|
OUT PIO_STATUS_BLOCK UserIoStatusBlock,
|
||||||
|
IN FILE_SEGMENT_ELEMENT BufferDescription[],
|
||||||
|
IN ULONG BufferLength,
|
||||||
|
IN PLARGE_INTEGER ByteOffset,
|
||||||
|
IN PULONG Key OPTIONAL)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtWriteFileGather(IN HANDLE FileHandle,
|
||||||
|
IN HANDLE Event OPTIONAL,
|
||||||
|
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
||||||
|
IN PVOID ApcContext OPTIONAL,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN FILE_SEGMENT_ELEMENT BufferDescription[],
|
||||||
|
IN ULONG BufferLength,
|
||||||
|
IN PLARGE_INTEGER ByteOffset,
|
||||||
|
IN PULONG Key OPTIONAL)
|
||||||
|
{
|
||||||
|
return(ZwWriteFileGather(FileHandle,
|
||||||
|
Event,
|
||||||
|
ApcRoutine,
|
||||||
|
ApcContext,
|
||||||
|
IoStatusBlock,
|
||||||
|
BufferDescription,
|
||||||
|
BufferLength,
|
||||||
|
ByteOffset,
|
||||||
|
Key));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL ZwWriteFileGather(IN HANDLE FileHandle,
|
||||||
|
IN HANDLE Event OPTIONAL,
|
||||||
|
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
||||||
|
IN PVOID ApcContext OPTIONAL,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
IN FILE_SEGMENT_ELEMENT BufferDescription[],
|
||||||
|
IN ULONG BufferLength,
|
||||||
|
IN PLARGE_INTEGER ByteOffset,
|
||||||
|
IN PULONG Key OPTIONAL)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/io/vpb.c
|
* FILE: ntoskrnl/io/vpb.c
|
||||||
* PURPOSE: Volume Parameters Block managment
|
* PURPOSE: Volume Parameter Block managment
|
||||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||||
* 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/string.h>
|
#include <internal/string.h>
|
||||||
|
#include <internal/ob.h>
|
||||||
|
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
|
@ -39,3 +40,189 @@ NTSTATUS IoAttachVpb(PDEVICE_OBJECT DeviceObject)
|
||||||
|
|
||||||
DeviceObject->Vpb = Vpb;
|
DeviceObject->Vpb = Vpb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PIRP IoBuildVolumeInformationIrp(ULONG MajorFunction,
|
||||||
|
PFILE_OBJECT FileObject,
|
||||||
|
PVOID FSInformation,
|
||||||
|
ULONG Length,
|
||||||
|
CINT FSInformationClass,
|
||||||
|
PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
PKEVENT Event)
|
||||||
|
{
|
||||||
|
PIRP Irp;
|
||||||
|
PIO_STACK_LOCATION StackPtr;
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
|
||||||
|
DeviceObject = FileObject->DeviceObject;
|
||||||
|
|
||||||
|
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
||||||
|
if (Irp==NULL)
|
||||||
|
{
|
||||||
|
return(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Irp->AssociatedIrp.SystemBuffer = FSInformation;
|
||||||
|
|
||||||
|
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||||
|
StackPtr->MajorFunction = MajorFunction;
|
||||||
|
StackPtr->MinorFunction = 0;
|
||||||
|
StackPtr->Flags = 0;
|
||||||
|
StackPtr->Control = 0;
|
||||||
|
StackPtr->DeviceObject = DeviceObject;
|
||||||
|
StackPtr->FileObject = FileObject;
|
||||||
|
Irp->UserEvent = Event;
|
||||||
|
Irp->UserIosb = IoStatusBlock;
|
||||||
|
|
||||||
|
if (MajorFunction == IRP_MJ_QUERY_VOLUME_INFORMATION)
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.SetVolume.Length = Length;
|
||||||
|
StackPtr->Parameters.SetVolume.FileInformationClass =
|
||||||
|
FSInformationClass;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StackPtr->Parameters.QueryVolume.Length = Length;
|
||||||
|
StackPtr->Parameters.QueryVolume.FileInformationClass =
|
||||||
|
FSInformationClass;
|
||||||
|
}
|
||||||
|
return(Irp);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS STDCALL NtQueryVolumeInformationFile(
|
||||||
|
IN HANDLE FileHandle,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
OUT PVOID FSInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN CINT FSInformationClass)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* FUNCTION: Queries the volume information
|
||||||
|
* ARGUMENTS:
|
||||||
|
* FileHandle = Handle to a file object on the target volume
|
||||||
|
* ReturnLength = DataWritten
|
||||||
|
* FSInformation = Caller should supply storage for the information
|
||||||
|
* structure.
|
||||||
|
* Length = Size of the information structure
|
||||||
|
* FSInformationClass = Index to a information structure
|
||||||
|
*
|
||||||
|
* FileFsVolumeInformation FILE_FS_VOLUME_INFORMATION
|
||||||
|
* FileFsLabelInformation FILE_FS_LABEL_INFORMATION
|
||||||
|
* FileFsSizeInformation FILE_FS_SIZE_INFORMATION
|
||||||
|
* FileFsDeviceInformation FILE_FS_DEVICE_INFORMATION
|
||||||
|
* FileFsAttributeInformation FILE_FS_ATTRIBUTE_INFORMATION
|
||||||
|
* FileFsControlInformation
|
||||||
|
* FileFsQuotaQueryInformation --
|
||||||
|
* FileFsQuotaSetInformation --
|
||||||
|
* FileFsMaximumInformation
|
||||||
|
*
|
||||||
|
* RETURNS: Status
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
return(ZwQueryVolumeInformationFile(FileHandle,IoStatusBlock,FSInformation,
|
||||||
|
Length,FSInformationClass));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwQueryVolumeInformationFile(
|
||||||
|
IN HANDLE FileHandle,
|
||||||
|
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||||
|
OUT PVOID FSInformation,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN CINT FSInformationClass)
|
||||||
|
{
|
||||||
|
PFILE_OBJECT FileObject;
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
PIRP Irp;
|
||||||
|
KEVENT Event;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(FileHandle,
|
||||||
|
FILE_READ_ATTRIBUTES,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&FileObject,
|
||||||
|
NULL);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceObject = FileObject->DeviceObject;
|
||||||
|
|
||||||
|
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||||
|
|
||||||
|
Irp = IoBuildVolumeInformationIrp(IRP_MJ_QUERY_VOLUME_INFORMATION,
|
||||||
|
FileObject,
|
||||||
|
FSInformation,
|
||||||
|
Length,
|
||||||
|
FSInformationClass,
|
||||||
|
IoStatusBlock,
|
||||||
|
&Event);
|
||||||
|
Status = IoCallDriver(DeviceObject,Irp);
|
||||||
|
if (Status == STATUS_PENDING)
|
||||||
|
{
|
||||||
|
KeWaitForSingleObject(&Event,UserRequest,KernelMode,FALSE,NULL);
|
||||||
|
Status = IoStatusBlock->Status;
|
||||||
|
}
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
NtSetVolumeInformationFile(
|
||||||
|
IN HANDLE FileHandle,
|
||||||
|
IN CINT VolumeInformationClass,
|
||||||
|
PVOID VolumeInformation,
|
||||||
|
ULONG Length
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return(ZwSetVolumeInformationFile(FileHandle,VolumeInformationClass,
|
||||||
|
VolumeInformation,Length));
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
STDCALL
|
||||||
|
ZwSetVolumeInformationFile(
|
||||||
|
IN HANDLE FileHandle,
|
||||||
|
IN CINT VolumeInformationClass,
|
||||||
|
PVOID VolumeInformation,
|
||||||
|
ULONG Length
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
PFILE_OBJECT FileObject;
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
PIRP Irp;
|
||||||
|
KEVENT Event;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = ObReferenceObjectByHandle(FileHandle,
|
||||||
|
FILE_WRITE_ATTRIBUTES,
|
||||||
|
NULL,
|
||||||
|
UserMode,
|
||||||
|
(PVOID*)&FileObject,
|
||||||
|
NULL);
|
||||||
|
if (Status != STATUS_SUCCESS)
|
||||||
|
{
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceObject = FileObject->DeviceObject;
|
||||||
|
|
||||||
|
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||||
|
|
||||||
|
Irp = IoBuildVolumeInformationIrp(IRP_MJ_SET_VOLUME_INFORMATION,
|
||||||
|
FileObject,
|
||||||
|
VolumeInformation,
|
||||||
|
Length,
|
||||||
|
VolumeInformationClass,
|
||||||
|
NULL,
|
||||||
|
&Event);
|
||||||
|
Status = IoCallDriver(DeviceObject,Irp);
|
||||||
|
if (Status == STATUS_PENDING)
|
||||||
|
{
|
||||||
|
KeWaitForSingleObject(&Event,UserRequest,KernelMode,FALSE,NULL);
|
||||||
|
}
|
||||||
|
return(Status);
|
||||||
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
#include <internal/symbol.h>
|
#include <internal/symbol.h>
|
||||||
#include <internal/module.h>
|
#include <internal/module.h>
|
||||||
|
|
||||||
#include <internal/hal/page.h>
|
#include <internal/mmhal.h>
|
||||||
#include <internal/hal/segment.h>
|
#include <internal/i386/segment.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
//#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -134,7 +134,9 @@ asmlinkage void _main(boot_param* _bp)
|
||||||
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
start = KERNEL_BASE + PAGE_ROUND_UP(bp.module_length[0]);
|
||||||
if (start < ((int)&end))
|
if (start < ((int)&end))
|
||||||
{
|
{
|
||||||
|
DbgPrint("start %x end %x\n",start,(int)&end);
|
||||||
DbgPrint("Kernel booted incorrectly, aborting\n");
|
DbgPrint("Kernel booted incorrectly, aborting\n");
|
||||||
|
DbgPrint("Reduce the amount of uninitialized data\n");
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
DPRINT("MmGetPhysicalAddress(start) = %x\n",MmGetPhysicalAddress(start));
|
DPRINT("MmGetPhysicalAddress(start) = %x\n",MmGetPhysicalAddress(start));
|
||||||
|
@ -187,5 +189,5 @@ asmlinkage void _main(boot_param* _bp)
|
||||||
* Enter idle loop
|
* Enter idle loop
|
||||||
*/
|
*/
|
||||||
printk("Finished main()\n");
|
printk("Finished main()\n");
|
||||||
for (;;);
|
PsTerminateSystemThread(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,7 @@ static unsigned int get_symbol_value_by_name(module* mod, char* sname,
|
||||||
for (i=0; i<mod->nsyms; i++)
|
for (i=0; i<mod->nsyms; i++)
|
||||||
{
|
{
|
||||||
get_symbol_name(mod,i,name);
|
get_symbol_name(mod,i,name);
|
||||||
// DPRINT("Scanning %s Value %x\n",name,mod->sym_list[i].e_value);
|
DPRINT("Scanning %s Value %x\n",name,mod->sym_list[i].e_value);
|
||||||
if (strcmp(name,sname)==0)
|
if (strcmp(name,sname)==0)
|
||||||
{
|
{
|
||||||
DPRINT("Returning %x\n",mod->sym_list[i].e_value);
|
DPRINT("Returning %x\n",mod->sym_list[i].e_value);
|
||||||
|
@ -368,7 +368,7 @@ BOOLEAN process_boot_module(unsigned int start)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Allocate base: %x\n",mod->base);
|
DbgPrint("Module base: %x\n",mod->base);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the entry point
|
* Find the entry point
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
all: kimage
|
all: kimage
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -6,6 +5,10 @@ all: kimage
|
||||||
#
|
#
|
||||||
include hal/x86/sources
|
include hal/x86/sources
|
||||||
|
|
||||||
|
NT_OBJECTS = nt/port.o nt/channel.o nt/ntevent.o nt/nttimer.o nt/atom.o \
|
||||||
|
nt/evtpair.o nt/ntsem.o nt/mutant.o nt/misc.o nt/plugplay.o \
|
||||||
|
nt/profile.o
|
||||||
|
|
||||||
RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \
|
RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \
|
||||||
rtl/time.o rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \
|
rtl/time.o rtl/unalign.o rtl/mem.o rtl/largeint.o rtl/ctype.o \
|
||||||
rtl/list.o rtl/slist.o rtl/interlck.o rtl/return.o \
|
rtl/list.o rtl/slist.o rtl/interlck.o rtl/return.o \
|
||||||
|
@ -14,11 +17,11 @@ RTL_OBJECTS = rtl/vsprintf.o rtl/lookas.o rtl/unicode.o rtl/strtok.o \
|
||||||
KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o ke/exports.o \
|
KE_OBJECTS = ke/main.o ke/timer.o ke/error.o ke/catch.o ke/exports.o \
|
||||||
ke/module.o ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
|
ke/module.o ke/dpc.o ke/wait.o ke/kqueue.o ke/dispatch.o \
|
||||||
ke/sem.o ke/critical.o ke/event.o ke/apc.o ke/bug.o \
|
ke/sem.o ke/critical.o ke/event.o ke/apc.o ke/bug.o \
|
||||||
ke/mutex.o ke/kernel.o
|
ke/mutex.o ke/kernel.o ke/ldt.o ke/apchelp.o
|
||||||
|
|
||||||
MM_OBJECTS = mm/mm.o mm/freelist.o mm/pool.o mm/pageflt.o mm/virtual.o \
|
MM_OBJECTS = mm/mm.o mm/freelist.o mm/pool.o mm/virtual.o \
|
||||||
mm/mdl.o mm/zone.o mm/special.o \
|
mm/mdl.o mm/zone.o mm/special.o mm/paging.o \
|
||||||
mm/section.o mm/marea.o
|
mm/section.o mm/marea.o mm/ppool.o mm/npool.o
|
||||||
|
|
||||||
|
|
||||||
IO_OBJECTS = io/iomgr.o io/create.o io/irp.o io/device.o io/rw.o \
|
IO_OBJECTS = io/iomgr.o io/create.o io/irp.o io/device.o io/rw.o \
|
||||||
|
@ -26,18 +29,21 @@ IO_OBJECTS = io/iomgr.o io/create.o io/irp.o io/device.o io/rw.o \
|
||||||
io/shutdown.o io/fdisk.o io/cancel.o io/error.o io/arc.o \
|
io/shutdown.o io/fdisk.o io/cancel.o io/error.o io/arc.o \
|
||||||
io/dpc.o io/symlink.o io/adapter.o io/cntrller.o io/mdl.o \
|
io/dpc.o io/symlink.o io/adapter.o io/cntrller.o io/mdl.o \
|
||||||
io/resource.o io/event.o io/process.o io/file.o io/ioctrl.o \
|
io/resource.o io/event.o io/process.o io/file.o io/ioctrl.o \
|
||||||
io/fs.o io/vpb.o io/buildirp.o
|
io/fs.o io/vpb.o io/buildirp.o io/flush.o io/dir.o io/iocomp.o \
|
||||||
|
io/mailslot.o io/npipe.o io/lock.o io/page.o io/cleanup.o
|
||||||
|
|
||||||
OB_OBJECTS = ob/object.o ob/handle.o ob/namespc.o
|
OB_OBJECTS = ob/object.o ob/handle.o ob/namespc.o
|
||||||
|
|
||||||
PS_OBJECTS = ps/psmgr.o ps/thread.o ps/process.o ps/idle.o
|
PS_OBJECTS = ps/psmgr.o ps/thread.o ps/process.o ps/idle.o ps/kill.o \
|
||||||
|
ps/tinfo.o
|
||||||
|
|
||||||
EX_OBJECTS = ex/work.o ex/fmutex.o ex/resource.o ex/time.o ex/interlck.o \
|
EX_OBJECTS = ex/work.o ex/fmutex.o ex/resource.o ex/time.o ex/interlck.o \
|
||||||
ex/callback.o
|
ex/callback.o ex/napi.o ex/power.o ex/sysinfo.o ex/locale.o \
|
||||||
|
ex/stamp.o
|
||||||
|
|
||||||
SE_OBJECTS = se/semgr.o
|
SE_OBJECTS = se/semgr.o
|
||||||
|
|
||||||
CFG_OBJECTS = cfg/registry.o
|
CM_OBJECTS = cm/registry.o
|
||||||
|
|
||||||
TST_OBJECTS = tst/test.o tst/sshell.o tst/readline.o
|
TST_OBJECTS = tst/test.o tst/sshell.o tst/readline.o
|
||||||
|
|
||||||
|
@ -45,9 +51,55 @@ DBG_OBJECTS = dbg/brkpoint.o
|
||||||
|
|
||||||
LDR_OBJECTS = ldr/loader.o
|
LDR_OBJECTS = ldr/loader.o
|
||||||
|
|
||||||
OBJECTS = $(HAL_OBJECTS) $(KE_OBJECTS) $(RTL_OBJECTS) $(MM_OBJECTS) \
|
CC_OBJECTS = cc/cacheman.o cc/block.o
|
||||||
$(IO_OBJECTS) $(OB_OBJECTS) $(PS_OBJECTS) $(EX_OBJECTS) \
|
|
||||||
$(SE_OBJECTS) $(CFG_OBJECTS) $(TST_OBJECTS) $(DBG_OBJECTS)
|
objects/hal.o: $(HAL_OBJECTS)
|
||||||
|
$(LD) -r $(HAL_OBJECTS) -o objects/hal.o
|
||||||
|
|
||||||
|
objects/io.o: $(IO_OBJECTS)
|
||||||
|
$(LD) -r $(IO_OBJECTS) -o objects/io.o
|
||||||
|
|
||||||
|
objects/ke.o: $(KE_OBJECTS)
|
||||||
|
$(LD) -r $(KE_OBJECTS) -o objects/ke.o
|
||||||
|
|
||||||
|
objects/rtl.o: $(RTL_OBJECTS)
|
||||||
|
$(LD) -r $(RTL_OBJECTS) -o objects/rtl.o
|
||||||
|
|
||||||
|
objects/mm.o: $(MM_OBJECTS)
|
||||||
|
$(LD) -r $(MM_OBJECTS) -o objects/mm.o
|
||||||
|
|
||||||
|
objects/ob.o: $(OB_OBJECTS)
|
||||||
|
$(LD) -r $(OB_OBJECTS) -o objects/ob.o
|
||||||
|
|
||||||
|
objects/ps.o: $(PS_OBJECTS)
|
||||||
|
$(LD) -r $(PS_OBJECTS) -o objects/ps.o
|
||||||
|
|
||||||
|
objects/ex.o: $(EX_OBJECTS)
|
||||||
|
$(LD) -r $(EX_OBJECTS) -o objects/ex.o
|
||||||
|
|
||||||
|
objects/se.o: $(SE_OBJECTS)
|
||||||
|
$(LD) -r $(SE_OBJECTS) -o objects/se.o
|
||||||
|
|
||||||
|
objects/cm.o: $(CM_OBJECTS)
|
||||||
|
$(LD) -r $(CM_OBJECTS) -o objects/cm.o
|
||||||
|
|
||||||
|
objects/tst.o: $(TST_OBJECTS)
|
||||||
|
$(LD) -r $(TST_OBJECTS) -o objects/tst.o
|
||||||
|
|
||||||
|
objects/dbg.o: $(DBG_OBJECTS)
|
||||||
|
$(LD) -r $(DBG_OBJECTS) -o objects/dbg.o
|
||||||
|
|
||||||
|
objects/nt.o: $(NT_OBJECTS)
|
||||||
|
$(LD) -r $(NT_OBJECTS) -o objects/nt.o
|
||||||
|
|
||||||
|
objects/cc.o: $(CC_OBJECTS)
|
||||||
|
$(LD) -r $(CC_OBJECTS) -o objects/cc.o
|
||||||
|
|
||||||
|
OBJECTS = objects/hal.o objects/ke.o objects/rtl.o objects/mm.o \
|
||||||
|
objects/io.o objects/ob.o objects/ps.o objects/ex.o \
|
||||||
|
objects/se.o objects/cm.o objects/tst.o objects/dbg.o\
|
||||||
|
objects/nt.o objects/cc.o
|
||||||
|
|
||||||
|
|
||||||
utils/export/export$(EXE_POSTFIX): utils/export/export.c
|
utils/export/export$(EXE_POSTFIX): utils/export/export.c
|
||||||
$(NATIVE_CC) -g utils/export/export.c -o utils/export/export$(EXE_POSTFIX)
|
$(NATIVE_CC) -g utils/export/export.c -o utils/export/export$(EXE_POSTFIX)
|
||||||
|
@ -57,10 +109,18 @@ ke/exports.o: exports.lst utils/export/export$(EXE_POSTFIX)
|
||||||
$(CC) $(CFLAGS) -c ke/exports.c -o ke/exports.o
|
$(CC) $(CFLAGS) -c ke/exports.c -o ke/exports.o
|
||||||
|
|
||||||
kimage: $(OBJECTS)
|
kimage: $(OBJECTS)
|
||||||
$(LD) --defsym _end=end --defsym _etext=etext --oformat=$(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) libgcc.a -o kimage
|
$(LD) --defsym _end=end --defsym _etext=etext --oformat=$(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) $(LIBGCC) -o kimage
|
||||||
|
$(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin
|
||||||
|
|
||||||
|
old_kimage: $(OBJECTS)
|
||||||
|
$(LD) --defsym _end=end --defsym _etext=etext --oformat=$(KERNEL_BFD_TARGET) -Ttext c0000000 $(LDFLAGS) $(OBJECTS) $(LIBGCC) -o kimage
|
||||||
$(NM) --numeric-sort kimage > kernel.sym
|
$(NM) --numeric-sort kimage > kernel.sym
|
||||||
$(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin
|
$(OBJCOPY) -S --gap-fill=0 -O binary kimage kimage.bin
|
||||||
|
|
||||||
dummy:
|
dummy:
|
||||||
|
|
||||||
|
ex/napi.o: ex/napi.c ../include/ntdll/napi.h
|
||||||
|
|
||||||
|
WITH_DEBUGGING = yes
|
||||||
|
WIN32_LEAN_AND_MEAN = yes
|
||||||
include ../rules.mak
|
include ../rules.mak
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/mm.h>
|
#include <internal/mm.h>
|
||||||
#include <internal/hal/page.h>
|
#include <internal/mmhal.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -24,23 +24,25 @@ static KSPIN_LOCK SystemAreaListLock = {0,};
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
VOID MmDumpMemoryAreas(VOID)
|
VOID MmDumpMemoryAreas(PLIST_ENTRY ListHead)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
PLIST_ENTRY ListHead = &SystemAreaList;
|
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
||||||
|
DbgPrint("MmDumpMemoryAreas()\n");
|
||||||
|
|
||||||
current_entry = ListHead->Flink;
|
current_entry = ListHead->Flink;
|
||||||
while (current_entry!=ListHead)
|
while (current_entry!=ListHead)
|
||||||
{
|
{
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||||
DPRINT("Base %x Length %x End %x Attributes %x Flink %x\n",
|
DbgPrint("Base %x Length %x End %x Attributes %x Flink %x\n",
|
||||||
current->BaseAddress,current->Length,
|
current->BaseAddress,current->Length,
|
||||||
current->BaseAddress+current->Length,current->Attributes,
|
current->BaseAddress+current->Length,current->Attributes,
|
||||||
current->Entry.Flink);
|
current->Entry.Flink);
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
|
DbgPrint("Finished MmDumpMemoryAreas()\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmLockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
|
VOID MmLockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
|
||||||
|
@ -71,8 +73,36 @@ VOID MmUnlockMemoryAreaList(ULONG Address, PKIRQL oldlvl)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID MmLockMemoryAreaListByMode(KPROCESSOR_MODE Mode, PKIRQL oldlvl)
|
||||||
|
{
|
||||||
|
if (Mode == KernelMode)
|
||||||
|
{
|
||||||
|
KeAcquireSpinLock(&SystemAreaListLock,oldlvl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PKPROCESS CurrentProcess = KeGetCurrentProcess();
|
||||||
|
|
||||||
static PLIST_ENTRY MmGetRelatedListHead(ULONG BaseAddress)
|
KeAcquireSpinLock(&(CurrentProcess->SpinLock),oldlvl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MmUnlockMemoryAreaListByMode(KPROCESSOR_MODE Mode, PKIRQL oldlvl)
|
||||||
|
{
|
||||||
|
if (Mode == KernelMode)
|
||||||
|
{
|
||||||
|
KeReleaseSpinLock(&SystemAreaListLock,*oldlvl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PKPROCESS CurrentProcess = KeGetCurrentProcess();
|
||||||
|
KeReleaseSpinLock(&(CurrentProcess->SpinLock),*oldlvl);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static PLIST_ENTRY MmGetRelatedListHead(PEPROCESS Process, ULONG BaseAddress)
|
||||||
{
|
{
|
||||||
if (BaseAddress >= KERNEL_BASE)
|
if (BaseAddress >= KERNEL_BASE)
|
||||||
{
|
{
|
||||||
|
@ -80,12 +110,7 @@ static PLIST_ENTRY MmGetRelatedListHead(ULONG BaseAddress)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
return(&(Process->Pcb.MemoryAreaList));
|
||||||
if (CurrentProcess==NULL)
|
|
||||||
{
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
return(&(CurrentProcess->Pcb.MemoryAreaList));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +120,7 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
|
|
||||||
MmDumpMemoryAreas();
|
// MmDumpMemoryAreas();
|
||||||
|
|
||||||
DPRINT("MmInternalOpenMemoryAreaByAddress(ListHead %x, Address %x)\n",
|
DPRINT("MmInternalOpenMemoryAreaByAddress(ListHead %x, Address %x)\n",
|
||||||
ListHead,Address);
|
ListHead,Address);
|
||||||
|
@ -112,14 +137,17 @@ static MEMORY_AREA* MmInternalOpenMemoryAreaByAddress(PLIST_ENTRY ListHead,
|
||||||
if (current->BaseAddress <= Address &&
|
if (current->BaseAddress <= Address &&
|
||||||
(current->BaseAddress + current->Length) > Address)
|
(current->BaseAddress + current->Length) > Address)
|
||||||
{
|
{
|
||||||
|
DPRINT("%s() = %x\n",__FUNCTION__,current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
if (current->BaseAddress > Address)
|
if (current->BaseAddress > Address)
|
||||||
{
|
{
|
||||||
|
DPRINT("%s() = NULL\n",__FUNCTION__);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
|
DPRINT("%s() = NULL\n",__FUNCTION__);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,69 +160,80 @@ MEMORY_AREA* MmInternalOpenMemoryAreaByRegion(PLIST_ENTRY ListHead,
|
||||||
MEMORY_AREA* current;
|
MEMORY_AREA* current;
|
||||||
ULONG Extent;
|
ULONG Extent;
|
||||||
|
|
||||||
DPRINT("MmInternalOpenMemoryAreaByRegion()\n",0);
|
DPRINT("MmInternalOpenMemoryAreaByRegion(ListHead %x, Address %x, "
|
||||||
|
"Length %x)\n",ListHead,Address,Length);
|
||||||
|
|
||||||
MmDumpMemoryAreas();
|
// MmDumpMemoryAreas();
|
||||||
|
|
||||||
current_entry = ListHead->Flink;
|
current_entry = ListHead->Flink;
|
||||||
while (current_entry!=ListHead)
|
while (current_entry!=ListHead)
|
||||||
{
|
{
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||||
|
DPRINT("current->BaseAddress %x current->Length %x\n",
|
||||||
|
current->BaseAddress,current->Length);
|
||||||
if (current->BaseAddress >= Address &&
|
if (current->BaseAddress >= Address &&
|
||||||
current->BaseAddress <= (Address+Length))
|
current->BaseAddress <= (Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
|
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||||
|
current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
Extent = current->BaseAddress + current->Length;
|
Extent = current->BaseAddress + current->Length;
|
||||||
if (Extent > Address &&
|
if (Extent > Address &&
|
||||||
Extent < (Address+Length))
|
Extent < (Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
|
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||||
|
current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
if (current->BaseAddress <= Address &&
|
if (current->BaseAddress <= Address &&
|
||||||
Extent >= (Address+Length))
|
Extent >= (Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
|
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = %x\n",
|
||||||
|
current);
|
||||||
return(current);
|
return(current);
|
||||||
}
|
}
|
||||||
if (current->BaseAddress >= (Address+Length))
|
if (current->BaseAddress >= (Address+Length))
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
|
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()= NULL\n",0);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
DPRINT("Finished MmInternalOpenMemoryAreaByRegion()\n",0);
|
DPRINT("Finished MmInternalOpenMemoryAreaByRegion() = NULL\n",0);
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByRegion(ULONG Address, ULONG Length)
|
MEMORY_AREA* MmOpenMemoryAreaByRegion(PEPROCESS Process, ULONG Address,
|
||||||
|
ULONG Length)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
MEMORY_AREA* Result;
|
MEMORY_AREA* Result;
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
|
|
||||||
|
DPRINT("MmOpenMemoryByRegion(Process %x, Address %x, Length %x)\n",
|
||||||
|
Process,Address,Length);
|
||||||
|
|
||||||
MmLockMemoryAreaList(Address,&oldlvl);
|
MmLockMemoryAreaList(Address,&oldlvl);
|
||||||
ListHead = MmGetRelatedListHead(Address);
|
ListHead = MmGetRelatedListHead(Process,Address);
|
||||||
Result = MmInternalOpenMemoryAreaByRegion(ListHead,Address,Length);
|
Result = MmInternalOpenMemoryAreaByRegion(ListHead,Address,Length);
|
||||||
MmUnlockMemoryAreaList(Address,&oldlvl);
|
MmUnlockMemoryAreaList(Address,&oldlvl);
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(ULONG Address, ULONG Length)
|
MEMORY_AREA* MmOpenMemoryAreaByRegionWithoutLock(PEPROCESS Process,
|
||||||
|
ULONG Address, ULONG Length)
|
||||||
{
|
{
|
||||||
MEMORY_AREA* Result;
|
MEMORY_AREA* Result;
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
|
|
||||||
ListHead = MmGetRelatedListHead(Address);
|
ListHead = MmGetRelatedListHead(Process, Address);
|
||||||
Result = MmInternalOpenMemoryAreaByRegion(ListHead,Address,Length);
|
Result = MmInternalOpenMemoryAreaByRegion(ListHead,Address,Length);
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByAddress(ULONG Address)
|
MEMORY_AREA* MmOpenMemoryAreaByAddress(PEPROCESS Process, PVOID Address)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
MEMORY_AREA* Result;
|
MEMORY_AREA* Result;
|
||||||
|
@ -203,23 +242,25 @@ MEMORY_AREA* MmOpenMemoryAreaByAddress(ULONG Address)
|
||||||
DPRINT("MmOpenMemoryAreaByAddress(Address %x)\n",Address);
|
DPRINT("MmOpenMemoryAreaByAddress(Address %x)\n",Address);
|
||||||
|
|
||||||
MmLockMemoryAreaList(Address,&oldlvl);
|
MmLockMemoryAreaList(Address,&oldlvl);
|
||||||
ListHead = MmGetRelatedListHead(Address);
|
ListHead = MmGetRelatedListHead(Process, Address);
|
||||||
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address);
|
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address);
|
||||||
MmUnlockMemoryAreaList(Address,&oldlvl);
|
MmUnlockMemoryAreaList(Address,&oldlvl);
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(ULONG Address)
|
MEMORY_AREA* MmOpenMemoryAreaByAddressWithoutLock(PEPROCESS Process,
|
||||||
|
ULONG Address)
|
||||||
{
|
{
|
||||||
MEMORY_AREA* Result;
|
MEMORY_AREA* Result;
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
|
|
||||||
ListHead = MmGetRelatedListHead(Address);
|
ListHead = MmGetRelatedListHead(Process, Address);
|
||||||
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address);
|
Result = MmInternalOpenMemoryAreaByAddress(ListHead,Address);
|
||||||
return(Result);
|
return(Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID MmInsertMemoryAreaWithoutLock(MEMORY_AREA* marea)
|
static VOID MmInsertMemoryAreaWithoutLock(PEPROCESS Process,
|
||||||
|
MEMORY_AREA* marea)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -231,7 +272,7 @@ static VOID MmInsertMemoryAreaWithoutLock(MEMORY_AREA* marea)
|
||||||
DPRINT("marea->BaseAddress %x\n",marea->BaseAddress);
|
DPRINT("marea->BaseAddress %x\n",marea->BaseAddress);
|
||||||
DPRINT("marea->Length %x\n",marea->Length);
|
DPRINT("marea->Length %x\n",marea->Length);
|
||||||
|
|
||||||
ListHead=MmGetRelatedListHead(marea->BaseAddress);
|
ListHead=MmGetRelatedListHead(Process,marea->BaseAddress);
|
||||||
current_entry = ListHead->Flink;
|
current_entry = ListHead->Flink;
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
if (IsListEmpty(ListHead))
|
if (IsListEmpty(ListHead))
|
||||||
|
@ -257,11 +298,13 @@ static VOID MmInsertMemoryAreaWithoutLock(MEMORY_AREA* marea)
|
||||||
// CHECKPOINT;
|
// CHECKPOINT;
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||||
next = CONTAINING_RECORD(current_entry->Flink,MEMORY_AREA,Entry);
|
next = CONTAINING_RECORD(current_entry->Flink,MEMORY_AREA,Entry);
|
||||||
|
assert(current->BaseAddress != marea->BaseAddress);
|
||||||
|
assert(next->BaseAddress != marea->BaseAddress);
|
||||||
if (current->BaseAddress < marea->BaseAddress &&
|
if (current->BaseAddress < marea->BaseAddress &&
|
||||||
current->Entry.Flink==ListHead)
|
current->Entry.Flink==ListHead)
|
||||||
{
|
{
|
||||||
current_entry->Flink = inserted_entry;
|
current_entry->Flink = inserted_entry;
|
||||||
inserted_entry->Flink=&ListHead;
|
inserted_entry->Flink=ListHead;
|
||||||
inserted_entry->Blink=current_entry;
|
inserted_entry->Blink=current_entry;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -280,7 +323,8 @@ static VOID MmInsertMemoryAreaWithoutLock(MEMORY_AREA* marea)
|
||||||
InsertTailList(ListHead,inserted_entry);
|
InsertTailList(ListHead,inserted_entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ULONG MmFindGapWithoutLock(KPROCESSOR_MODE Mode, ULONG Length)
|
static ULONG MmFindGapWithoutLock(PEPROCESS Process,
|
||||||
|
KPROCESSOR_MODE Mode, ULONG Length)
|
||||||
{
|
{
|
||||||
PLIST_ENTRY ListHead;
|
PLIST_ENTRY ListHead;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -290,13 +334,14 @@ static ULONG MmFindGapWithoutLock(KPROCESSOR_MODE Mode, ULONG Length)
|
||||||
|
|
||||||
DPRINT("MmFindGapWithoutLock(Mode %x Length %x)\n",Mode,Length);
|
DPRINT("MmFindGapWithoutLock(Mode %x Length %x)\n",Mode,Length);
|
||||||
|
|
||||||
|
|
||||||
if (Mode == KernelMode)
|
if (Mode == KernelMode)
|
||||||
{
|
{
|
||||||
ListHead = &SystemAreaList;
|
ListHead = &SystemAreaList;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ListHead = &(KeGetCurrentProcess()->MemoryAreaList);
|
ListHead = &(Process->Pcb.MemoryAreaList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,6 +362,13 @@ static ULONG MmFindGapWithoutLock(KPROCESSOR_MODE Mode, ULONG Length)
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (current_entry == ListHead)
|
||||||
|
{
|
||||||
|
assert(Mode==UserMode);
|
||||||
|
return(MM_LOWEST_USER_ADDRESS);
|
||||||
|
}
|
||||||
|
|
||||||
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
current = CONTAINING_RECORD(current_entry,MEMORY_AREA,Entry);
|
||||||
//DbgPrint("current %x returning %x\n",current,current->BaseAddress+
|
//DbgPrint("current %x returning %x\n",current,current->BaseAddress+
|
||||||
// current->Length);
|
// current->Length);
|
||||||
|
@ -334,7 +386,8 @@ NTSTATUS MmInitMemoryAreas(VOID)
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
|
NTSTATUS MmFreeMemoryArea(PEPROCESS Process,
|
||||||
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
BOOLEAN FreePages)
|
BOOLEAN FreePages)
|
||||||
{
|
{
|
||||||
|
@ -342,10 +395,14 @@ NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
|
||||||
ULONG i;
|
ULONG i;
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
|
|
||||||
|
DPRINT("MmFreeMemoryArea(Process %x, BaseAddress %x, Length %x,"
|
||||||
|
"FreePages %d)\n",Process,BaseAddress,Length,FreePages);
|
||||||
|
|
||||||
MmLockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
MmLockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
||||||
|
|
||||||
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock((ULONG)BaseAddress);
|
MemoryArea = MmOpenMemoryAreaByAddressWithoutLock(Process,
|
||||||
if (MemoryArea!=NULL)
|
(ULONG)BaseAddress);
|
||||||
|
if (MemoryArea==NULL)
|
||||||
{
|
{
|
||||||
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
MmUnlockMemoryAreaList((ULONG)BaseAddress,&oldlvl);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
|
@ -365,9 +422,81 @@ NTSTATUS MmFreeMemoryArea(PVOID BaseAddress,
|
||||||
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 OriginalMemoryArea,
|
||||||
|
PVOID BaseAddress,
|
||||||
|
ULONG Length,
|
||||||
|
ULONG NewType,
|
||||||
|
ULONG NewAttributes)
|
||||||
|
{
|
||||||
|
KIRQL oldlvl;
|
||||||
|
PMEMORY_AREA Result;
|
||||||
|
PMEMORY_AREA Split;
|
||||||
|
|
||||||
|
Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
||||||
|
RtlZeroMemory(Result,sizeof(MEMORY_AREA));
|
||||||
|
Result->Type=NewType;
|
||||||
|
Result->BaseAddress=BaseAddress;
|
||||||
|
Result->Length=Length;
|
||||||
|
Result->Attributes=NewAttributes;
|
||||||
|
Result->LockCount=0;
|
||||||
|
|
||||||
|
MmLockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||||
|
|
||||||
|
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
||||||
|
|
||||||
|
if (BaseAddress == OriginalMemoryArea->BaseAddress)
|
||||||
|
{
|
||||||
|
OriginalMemoryArea->BaseAddress = BaseAddress + Length;
|
||||||
|
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
|
||||||
|
MmInsertMemoryAreaWithoutLock(Process,Result);
|
||||||
|
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||||
|
|
||||||
|
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
||||||
|
|
||||||
|
return(Result);
|
||||||
|
}
|
||||||
|
if ((BaseAddress + Length) ==
|
||||||
|
(OriginalMemoryArea->BaseAddress + OriginalMemoryArea->Length))
|
||||||
|
{
|
||||||
|
OriginalMemoryArea->Length = OriginalMemoryArea->Length - Length;
|
||||||
|
MmInsertMemoryAreaWithoutLock(Process,Result);
|
||||||
|
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||||
|
|
||||||
|
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
||||||
|
|
||||||
|
return(Result);
|
||||||
|
}
|
||||||
|
|
||||||
|
Split = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
||||||
|
RtlCopyMemory(Split,OriginalMemoryArea,sizeof(MEMORY_AREA));
|
||||||
|
Split->BaseAddress = BaseAddress + Length;
|
||||||
|
Split->Length = OriginalMemoryArea->Length - (((ULONG)BaseAddress)
|
||||||
|
+ Length);
|
||||||
|
|
||||||
|
OriginalMemoryArea->Length = BaseAddress - OriginalMemoryArea->BaseAddress;
|
||||||
|
|
||||||
|
MmUnlockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||||
|
|
||||||
|
// MmDumpMemoryAreas(MmGetRelatedListHead(Process,BaseAddress));
|
||||||
|
|
||||||
|
return(Split);
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
||||||
|
PEPROCESS Process,
|
||||||
ULONG Type,
|
ULONG Type,
|
||||||
PULONG BaseAddress,
|
PVOID* BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
ULONG Attributes,
|
ULONG Attributes,
|
||||||
MEMORY_AREA** Result)
|
MEMORY_AREA** Result)
|
||||||
|
@ -377,48 +506,50 @@ NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
||||||
DPRINT("MmCreateMemoryArea(Mode %x, Type %d, BaseAddress %x,"
|
DPRINT("MmCreateMemoryArea(Mode %x, Type %d, BaseAddress %x,"
|
||||||
"*BaseAddress %x, Length %x, Attributes %x, Result %x)\n",
|
"*BaseAddress %x, Length %x, Attributes %x, Result %x)\n",
|
||||||
Mode,Type,BaseAddress,*BaseAddress,Length,Attributes,Result);
|
Mode,Type,BaseAddress,*BaseAddress,Length,Attributes,Result);
|
||||||
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
|
|
||||||
MmLockMemoryAreaList(*BaseAddress,&oldlvl);
|
|
||||||
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
|
|
||||||
if ((*BaseAddress)==0)
|
if ((*BaseAddress)==0)
|
||||||
{
|
{
|
||||||
*BaseAddress = MmFindGapWithoutLock(Mode,PAGE_ROUND_UP(Length)
|
MmLockMemoryAreaListByMode(Mode,&oldlvl);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MmLockMemoryAreaList(*BaseAddress,&oldlvl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((*BaseAddress)==0)
|
||||||
|
{
|
||||||
|
*BaseAddress = MmFindGapWithoutLock(Process,Mode,PAGE_ROUND_UP(Length)
|
||||||
+(PAGESIZE*2));
|
+(PAGESIZE*2));
|
||||||
if ((*BaseAddress)==0)
|
if ((*BaseAddress)==0)
|
||||||
{
|
{
|
||||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
MmUnlockMemoryAreaListByMode(Mode,&oldlvl);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
(*BaseAddress)=(*BaseAddress)+PAGESIZE;
|
(*BaseAddress)=(*BaseAddress)+PAGESIZE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (MmOpenMemoryAreaByRegionWithoutLock(*BaseAddress,Length)!=NULL)
|
(*BaseAddress) = PAGE_ROUND_DOWN((*BaseAddress));
|
||||||
|
if (MmOpenMemoryAreaByRegionWithoutLock(Process,*BaseAddress,
|
||||||
|
Length)!=NULL)
|
||||||
{
|
{
|
||||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
||||||
return(STATUS_UNSUCCESSFUL);
|
return(STATUS_UNSUCCESSFUL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
|
|
||||||
*Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
*Result = ExAllocatePool(NonPagedPool,sizeof(MEMORY_AREA));
|
||||||
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
|
|
||||||
RtlZeroMemory(*Result,sizeof(MEMORY_AREA));
|
RtlZeroMemory(*Result,sizeof(MEMORY_AREA));
|
||||||
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
|
|
||||||
(*Result)->Type=Type;
|
(*Result)->Type=Type;
|
||||||
(*Result)->BaseAddress=*BaseAddress;
|
(*Result)->BaseAddress=*BaseAddress;
|
||||||
(*Result)->Length=Length;
|
(*Result)->Length=Length;
|
||||||
(*Result)->Attributes=Attributes;
|
(*Result)->Attributes=Attributes;
|
||||||
DPRINT("&SystemAreaList %x ",&SystemAreaList);
|
(*Result)->LockCount=0;
|
||||||
DPRINT("SystemAreaList.Flink %x ",SystemAreaList.Flink);
|
|
||||||
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
|
MmInsertMemoryAreaWithoutLock(Process,*Result);
|
||||||
MmInsertMemoryAreaWithoutLock(*Result);
|
|
||||||
// DbgPrint("(%s:%d) Start1 %x\n",__FILE__,__LINE__,
|
|
||||||
// *((unsigned int *)0xc0017000));
|
|
||||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
||||||
// DbgPrint("Start1 %x\n",*((unsigned int *)0xc0017000));
|
|
||||||
DPRINT("SystemAreaList.Flink %x ",SystemAreaList.Flink);
|
|
||||||
DPRINT("(*Result)->Entry.Flink %x\n",(*Result)->Entry.Flink);
|
|
||||||
MmDumpMemoryAreas();
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/mm.h>
|
#include <internal/mm.h>
|
||||||
#include <internal/hal/page.h>
|
#include <internal/mmhal.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
@ -31,7 +31,7 @@ VOID MmUnlockPages(PMDL MemoryDescriptorList)
|
||||||
* MDL is updated
|
* MDL is updated
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
/* It is harmless to leave this one as a stub */
|
||||||
}
|
}
|
||||||
|
|
||||||
PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
||||||
|
@ -54,6 +54,7 @@ PVOID MmMapLockedPages(PMDL Mdl, KPROCESSOR_MODE AccessMode)
|
||||||
PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);
|
PAGE_ROUND_UP(Mdl->ByteCount)/PAGESIZE);
|
||||||
|
|
||||||
MmCreateMemoryArea(KernelMode,
|
MmCreateMemoryArea(KernelMode,
|
||||||
|
PsGetCurrentProcess(),
|
||||||
MEMORY_AREA_MDL_MAPPING,
|
MEMORY_AREA_MDL_MAPPING,
|
||||||
&base,
|
&base,
|
||||||
Mdl->ByteCount + Mdl->ByteOffset,
|
Mdl->ByteCount + Mdl->ByteOffset,
|
||||||
|
@ -65,15 +66,14 @@ 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]);
|
||||||
DPRINT("&((PULONG)(Mdl+1))[i] %x\n",&mdl_pages[i]);
|
set_page(base+(i*PAGESIZE),PA_READ + PA_SYSTEM,mdl_pages[i]);
|
||||||
set_page(base+(i*PAGESIZE),PA_READ + PA_SYSTEM,
|
|
||||||
mdl_pages[i]);
|
|
||||||
}
|
}
|
||||||
DPRINT("base %x\n",base);
|
DPRINT("base %x\n",base);
|
||||||
|
Mdl->MdlFlags = Mdl->MdlFlags | MDL_MAPPED_TO_SYSTEM_VA;
|
||||||
return(base + Mdl->ByteOffset);
|
return(base + Mdl->ByteOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList)
|
VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
|
||||||
/*
|
/*
|
||||||
* FUNCTION: Releases a mapping set up by a preceding call to MmMapLockedPages
|
* FUNCTION: Releases a mapping set up by a preceding call to MmMapLockedPages
|
||||||
* ARGUMENTS:
|
* ARGUMENTS:
|
||||||
|
@ -81,7 +81,8 @@ VOID MmUnmapLockedPages(PVOID BaseAddress, PMDL MemoryDescriptorList)
|
||||||
* MemoryDescriptorList = MDL describing the mapped pages
|
* MemoryDescriptorList = MDL describing the mapped pages
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
(void)MmFreeMemoryArea(BaseAddress,MemoryDescriptorList->ByteCount,FALSE);
|
(void)MmFreeMemoryArea(PsGetCurrentProcess(),BaseAddress-Mdl->ByteOffset,
|
||||||
|
Mdl->ByteCount,FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID MmPrepareMdlForReuse(PMDL Mdl)
|
VOID MmPrepareMdlForReuse(PMDL Mdl)
|
||||||
|
@ -113,7 +114,8 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
||||||
DPRINT("MmProbeAndLockPages(Mdl %x)\n",Mdl);
|
DPRINT("MmProbeAndLockPages(Mdl %x)\n",Mdl);
|
||||||
DPRINT("StartVa %x\n",Mdl->StartVa);
|
DPRINT("StartVa %x\n",Mdl->StartVa);
|
||||||
|
|
||||||
marea = MmOpenMemoryAreaByAddress((ULONG)Mdl->StartVa);
|
marea = MmOpenMemoryAreaByAddress(PsGetCurrentProcess(),
|
||||||
|
(ULONG)Mdl->StartVa);
|
||||||
DPRINT("marea %x\n",marea);
|
DPRINT("marea %x\n",marea);
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,35 +129,6 @@ VOID MmProbeAndLockPages(PMDL Mdl, KPROCESSOR_MODE AccessMode,
|
||||||
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Check the permissions
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
switch(Operation)
|
|
||||||
{
|
|
||||||
case IoReadAccess:
|
|
||||||
if (marea->access&PAGE_GUARD || marea->access&PAGE_NOACCESS)
|
|
||||||
{
|
|
||||||
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case IoWriteAccess:
|
|
||||||
case IoModifyAccess:
|
|
||||||
if (marea->access&PAGE_GUARD || marea->access&PAGE_READONLY)
|
|
||||||
{
|
|
||||||
printk("Invalid area protections\n");
|
|
||||||
ExRaiseStatus(STATUS_INVALID_PARAMETER);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
printk("Invalid operation type at %s:%d in %s\n",__FILE__,__LINE__,
|
|
||||||
__FUNCTION__);
|
|
||||||
KeBugCheck(UNEXPECTED_KERNEL_MODE_TRAP);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Lock the memory area
|
* Lock the memory area
|
||||||
* (We can't allow it to be freed while an I/O operation to it is
|
* (We can't allow it to be freed while an I/O operation to it is
|
||||||
|
@ -244,6 +217,7 @@ VOID MmBuildMdlForNonPagedPool(PMDL Mdl)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
int va;
|
int va;
|
||||||
|
Mdl->MdlFlags = Mdl->MdlFlags | MDL_SOURCE_IS_NONPAGED_POOL;
|
||||||
for (va=0; va<Mdl->Size; va++)
|
for (va=0; va<Mdl->Size; va++)
|
||||||
{
|
{
|
||||||
((PULONG)(Mdl + 1))[va] = MmGetPhysicalAddress(
|
((PULONG)(Mdl + 1))[va] = MmGetPhysicalAddress(
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include <internal/linkage.h>
|
#include <internal/linkage.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
|
||||||
typedef long long int LLI, *PLLI;
|
typedef long long int LLI, *PLLI;
|
||||||
|
@ -112,10 +113,17 @@ RtlLargeIntegerAdd(LARGE_INTEGER Addend1,
|
||||||
{
|
{
|
||||||
LLI RC, A1, A2;
|
LLI RC, A1, A2;
|
||||||
|
|
||||||
|
DPRINT("Addend1.LowPart %d Addend1.HighPart %d\n",
|
||||||
|
Addend1.LowPart,Addend1.HighPart);
|
||||||
|
DPRINT("Addend2.LowPart %d Addend2.HighPart %d\n",
|
||||||
|
Addend2.LowPart,Addend2.HighPart);
|
||||||
|
|
||||||
A1 = LLIFromLI(Addend1);
|
A1 = LLIFromLI(Addend1);
|
||||||
A2 = LLIFromLI(Addend2);
|
A2 = LLIFromLI(Addend2);
|
||||||
RC = A1 + A2;
|
RC = A1 + A2;
|
||||||
|
|
||||||
|
DPRINT("RC %d\n",(unsigned int)RC);
|
||||||
|
|
||||||
return LIFromLLI(RC);
|
return LIFromLLI(RC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,10 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <internal/string.h>
|
#include <internal/string.h>
|
||||||
|
#include <internal/mm.h>
|
||||||
|
#include <internal/mmhal.h>
|
||||||
|
#include <internal/i386/segment.h>
|
||||||
|
#include <internal/ps.h>
|
||||||
|
|
||||||
//#define NDEBUG
|
//#define NDEBUG
|
||||||
#include <internal/debug.h>
|
#include <internal/debug.h>
|
||||||
|
@ -49,12 +53,10 @@ NTSTATUS TstFirstThread(PVOID start)
|
||||||
|
|
||||||
printk("Beginning Thread A\n");
|
printk("Beginning Thread A\n");
|
||||||
for (;;)
|
for (;;)
|
||||||
// for (i=0;i<10;i++)
|
|
||||||
{
|
{
|
||||||
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
||||||
printk("AAA ");
|
printk("AAA ");
|
||||||
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
|
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
|
||||||
for (i=0;i<10000;i++);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +66,10 @@ NTSTATUS TstSecondThread(PVOID start)
|
||||||
|
|
||||||
printk("Beginning Thread B\n");
|
printk("Beginning Thread B\n");
|
||||||
for(;;)
|
for(;;)
|
||||||
// for (i=0;i<10;i++)
|
|
||||||
{
|
{
|
||||||
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
KeWaitForSingleObject(&event,Executive,KernelMode,FALSE,NULL);
|
||||||
printk("BBB ");
|
printk("BBB ");
|
||||||
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
|
KeSetEvent(&event,IO_NO_INCREMENT,FALSE);
|
||||||
for (i=0;i<100000;i++);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,81 +84,91 @@ NTSTATUS TstThreadSupport()
|
||||||
for(;;);
|
for(;;);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TstGeneralWrite(VOID)
|
VOID ExExecuteShell(VOID)
|
||||||
{
|
|
||||||
OBJECT_ATTRIBUTES attr;
|
|
||||||
HANDLE hfile;
|
|
||||||
char buf[512];
|
|
||||||
ANSI_STRING afilename;
|
|
||||||
UNICODE_STRING ufilename;
|
|
||||||
|
|
||||||
DbgPrint("Opening test device\n");
|
|
||||||
RtlInitAnsiString(&afilename,"\\Device\\SDisk");
|
|
||||||
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
|
||||||
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
|
||||||
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
|
|
||||||
if (hfile==NULL)
|
|
||||||
{
|
|
||||||
DbgPrint("Failed to open test device\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ZwReadFile(hfile,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
buf,
|
|
||||||
512,
|
|
||||||
0,
|
|
||||||
0);
|
|
||||||
DbgPrint("buf %s\n",buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TstParallelPortWrite(VOID)
|
|
||||||
{
|
|
||||||
HANDLE hfile;
|
|
||||||
|
|
||||||
DbgPrint("Opening parallel port\n");
|
|
||||||
// hfile = CreateFile("\\Device\\Parallel",0,0,0,0,0,0);
|
|
||||||
if (hfile==NULL)
|
|
||||||
{
|
|
||||||
DbgPrint("Failed to open parallel port\n");
|
|
||||||
}
|
|
||||||
// WriteFile(hfile,"hello world",strlen("hello world"),NULL,NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TstKeyboardRead(VOID)
|
|
||||||
{
|
{
|
||||||
|
HANDLE ShellHandle;
|
||||||
|
HANDLE ThreadHandle;
|
||||||
|
PVOID BaseAddress;
|
||||||
|
HANDLE SectionHandle;
|
||||||
OBJECT_ATTRIBUTES attr;
|
OBJECT_ATTRIBUTES attr;
|
||||||
HANDLE hfile;
|
HANDLE hfile;
|
||||||
ANSI_STRING afilename;
|
ANSI_STRING afilename;
|
||||||
UNICODE_STRING ufilename;
|
UNICODE_STRING ufilename;
|
||||||
KEY_EVENT_RECORD key[2];
|
LARGE_INTEGER SectionOffset;
|
||||||
|
ULONG Size;
|
||||||
|
CONTEXT Context;
|
||||||
|
|
||||||
DbgPrint("Opening keyboard\n");
|
ZwCreateProcess(&ShellHandle,
|
||||||
RtlInitAnsiString(&afilename,"\\Device\\Keyboard");
|
PROCESS_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
SystemProcessHandle,
|
||||||
|
FALSE,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
RtlInitAnsiString(&afilename,"\\??\\C:\\reactos\\system\\shell.bin");
|
||||||
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
||||||
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
||||||
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
|
ZwOpenFile(&hfile,FILE_ALL_ACCESS,&attr,NULL,0,0);
|
||||||
if (hfile==NULL)
|
if (hfile==NULL)
|
||||||
{
|
{
|
||||||
DbgPrint("Failed to open keyboard\n");
|
DbgPrint("Failed to open file\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(;;)
|
|
||||||
{
|
ZwCreateSection(&SectionHandle,
|
||||||
ZwReadFile(hfile,
|
SECTION_ALL_ACCESS,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
PAGE_READWRITE,
|
||||||
NULL,
|
MEM_COMMIT,
|
||||||
&key[0],
|
hfile);
|
||||||
sizeof(KEY_EVENT_RECORD)*2,
|
|
||||||
|
BaseAddress = (PVOID)0x10000;
|
||||||
|
SectionOffset.HighPart = 0;
|
||||||
|
SectionOffset.LowPart = 0;
|
||||||
|
Size = 0x6000;
|
||||||
|
ZwMapViewOfSection(SectionHandle,
|
||||||
|
ShellHandle,
|
||||||
|
&BaseAddress,
|
||||||
0,
|
0,
|
||||||
0);
|
0x6000,
|
||||||
DbgPrint("%c",key[0].AsciiChar);
|
&SectionOffset,
|
||||||
// DbgPrint("%c",key[1].AsciiChar);
|
&Size,
|
||||||
}
|
0,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
|
||||||
|
memset(&Context,0,sizeof(CONTEXT));
|
||||||
|
|
||||||
|
Context.SegSs = USER_DS;
|
||||||
|
Context.Esp = 0x2000;
|
||||||
|
Context.EFlags = 0x202;
|
||||||
|
Context.SegCs = USER_CS;
|
||||||
|
Context.Eip = 0x10000;
|
||||||
|
Context.SegDs = USER_DS;
|
||||||
|
Context.SegEs = USER_DS;
|
||||||
|
Context.SegFs = USER_DS;
|
||||||
|
Context.SegGs = USER_DS;
|
||||||
|
|
||||||
|
BaseAddress = 0x1000;
|
||||||
|
ZwAllocateVirtualMemory(ShellHandle,
|
||||||
|
&BaseAddress,
|
||||||
|
0,
|
||||||
|
PAGESIZE,
|
||||||
|
MEM_COMMIT,
|
||||||
|
PAGE_READWRITE);
|
||||||
|
|
||||||
|
|
||||||
|
ZwCreateThread(&ThreadHandle,
|
||||||
|
THREAD_ALL_ACCESS,
|
||||||
|
NULL,
|
||||||
|
ShellHandle,
|
||||||
|
NULL,
|
||||||
|
&Context,
|
||||||
|
NULL,
|
||||||
|
FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IDE TEST STUFF ***********************************************************/
|
/* IDE TEST STUFF ***********************************************************/
|
||||||
|
@ -204,43 +214,6 @@ typedef struct _ROOT_DIR_ENTRY {
|
||||||
|
|
||||||
#define ENTRIES_PER_BLOCK (512 / sizeof(ROOT_DIR_ENTRY))
|
#define ENTRIES_PER_BLOCK (512 / sizeof(ROOT_DIR_ENTRY))
|
||||||
|
|
||||||
void TstFileRead(VOID)
|
|
||||||
{
|
|
||||||
OBJECT_ATTRIBUTES attr;
|
|
||||||
HANDLE hfile;
|
|
||||||
ANSI_STRING afilename;
|
|
||||||
UNICODE_STRING ufilename;
|
|
||||||
char ch;
|
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
|
||||||
|
|
||||||
DbgPrint("Opening file\n");
|
|
||||||
RtlInitAnsiString(&afilename,"\\??\\C:\\my_other_directory\\..\\"
|
|
||||||
"my_valid_directory\\apc.txt");
|
|
||||||
RtlAnsiStringToUnicodeString(&ufilename,&afilename,TRUE);
|
|
||||||
InitializeObjectAttributes(&attr,&ufilename,0,NULL,NULL);
|
|
||||||
ZwOpenFile(&hfile,0,&attr,NULL,0,0);
|
|
||||||
if (hfile==NULL)
|
|
||||||
{
|
|
||||||
DbgPrint("Failed to open file\n");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (1)
|
|
||||||
{
|
|
||||||
// CHECKPOINT;
|
|
||||||
ZwReadFile(hfile,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
&IoStatusBlock,
|
|
||||||
&ch,
|
|
||||||
1,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
DbgPrint("%c",ch);
|
|
||||||
}
|
|
||||||
CHECKPOINT;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TstIDERead(void)
|
void TstIDERead(void)
|
||||||
{
|
{
|
||||||
BOOLEAN TestFailed;
|
BOOLEAN TestFailed;
|
||||||
|
@ -462,11 +435,12 @@ static char SectorBuffer[512 * 10];
|
||||||
|
|
||||||
void TstBegin()
|
void TstBegin()
|
||||||
{
|
{
|
||||||
|
ExExecuteShell();
|
||||||
// TstFileRead();
|
// TstFileRead();
|
||||||
// TstGeneralWrite();
|
// TstGeneralWrite();
|
||||||
// TstThreadSupport();
|
// TstThreadSupport();
|
||||||
// TstKeyboardRead();
|
// TstKeyboardRead();
|
||||||
TstIDERead();
|
// TstIDERead();
|
||||||
// TstKeyboardRead();
|
// TstKeyboardRead();
|
||||||
// TstShell();
|
// TstShell();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,31 @@
|
||||||
#
|
#
|
||||||
# Choose various options
|
# Choose various options
|
||||||
#
|
#
|
||||||
|
ifeq ($(HOST),elf-linux)
|
||||||
|
NASM_FORMAT = elf
|
||||||
|
PREFIX =
|
||||||
|
KERNEL_BFD_TARGET = elf32-i386
|
||||||
|
EXE_POSTFIX =
|
||||||
|
CP = cp
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST),djgpp-linux)
|
ifeq ($(HOST),djgpp-linux)
|
||||||
NASM_FORMAT = coff
|
NASM_FORMAT = coff
|
||||||
PREFIX = dos-
|
PREFIX = dos-
|
||||||
KERNEL_BFD_TARGET = coff-i386
|
KERNEL_BFD_TARGET = coff-i386
|
||||||
EXE_POSTFIX =
|
EXE_POSTFIX =
|
||||||
CP = cp
|
CP = cp
|
||||||
|
LIBGCC = ./libgcc.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST),mingw32-linux)
|
ifeq ($(HOST),mingw32-linux)
|
||||||
NASM_FORMAT = win32
|
NASM_FORMAT = win32
|
||||||
PREFIX = i386-mingw32
|
PREFIX = /opt/gnu/bin/i386-mingw32-
|
||||||
KERNEL_BFD_TARGET = pe-i386
|
KERNEL_BFD_TARGET = pe-i386
|
||||||
EXE_POSTFIX
|
EXE_POSTFIX =
|
||||||
CP = cp
|
CP = cp
|
||||||
|
DLLTOOL = $(PREFIX)dlltool --as=$(PREFIX)as
|
||||||
|
LIBGCC = /opt/gnu/lib/gcc-lib/i386-mingw32/2.8.0/libgcc.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST),djgpp-msdos)
|
ifeq ($(HOST),djgpp-msdos)
|
||||||
|
@ -29,6 +40,7 @@ PREFIX =
|
||||||
KERNEL_BFD_TARGET = coff-go32
|
KERNEL_BFD_TARGET = coff-go32
|
||||||
EXE_POSTFIX = .exe
|
EXE_POSTFIX = .exe
|
||||||
CP = copy
|
CP = copy
|
||||||
|
LIBGCC = libgcc.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(HOST),mingw32-windows)
|
ifeq ($(HOST),mingw32-windows)
|
||||||
|
@ -42,24 +54,39 @@ endif
|
||||||
#
|
#
|
||||||
# Create variables for all the compiler tools
|
# Create variables for all the compiler tools
|
||||||
#
|
#
|
||||||
DEFINES = -DCHECKED_BUILD -DWIN32_LEAN_AND_MEAN -DDBG
|
ifeq ($(WITH_DEBUGGING),yes)
|
||||||
|
DEBUGGING_CFLAGS = -g
|
||||||
|
else
|
||||||
|
DEBUGGING_CFLAGS =
|
||||||
|
endif
|
||||||
|
|
||||||
|
DEFINES = -DDBG
|
||||||
|
|
||||||
|
ifeq ($(WIN32_LEAN_AND_MEAN),yes)
|
||||||
|
LEAN_AND_MEAN_DEFINE = -DWIN32_LEAN_AND_MEAN
|
||||||
|
else
|
||||||
|
LEAN_AND_MEAN_DEFINE =
|
||||||
|
endif
|
||||||
|
|
||||||
CC = $(PREFIX)gcc
|
CC = $(PREFIX)gcc
|
||||||
NATIVE_CC = gcc
|
NATIVE_CC = gcc
|
||||||
CFLAGS = -O2 -I../../../include -I../../include -I../include -fno-builtin $(DEFINES) -Wall -Wstrict-prototypes
|
CFLAGS = -O2 -I../../../include -I../../include -I../include -fno-builtin \
|
||||||
|
$(LEAN_AND_MEAN_DEFINE) $(DEFINES) -Wall -Wstrict-prototypes $(DEBUGGING_CFLAGS)
|
||||||
CXXFLAGS = $(CFLAGS)
|
CXXFLAGS = $(CFLAGS)
|
||||||
ASM = nasm
|
NASM_CMD = nasm
|
||||||
NFLAGS = -i../include/ -f$(NASM_FORMAT)
|
NFLAGS = -i../../include/ -i../include/ -pinternal/asm.inc -f$(NASM_FORMAT) -d$(NASM_FORMAT)
|
||||||
LD = $(PREFIX)ld
|
LD = $(PREFIX)ld
|
||||||
NM = $(PREFIX)nm
|
NM = $(PREFIX)nm
|
||||||
OBJCOPY = $(PREFIX)objcopy
|
OBJCOPY = $(PREFIX)objcopy
|
||||||
STRIP = $(PREFIX)strip
|
STRIP = $(PREFIX)strip
|
||||||
AS = $(PREFIX)gcc -c -x assembler-with-cpp
|
AS = $(PREFIX)gcc -c -x assembler-with-cpp
|
||||||
CPP = $(PREFIX)cpp
|
CPP = $(PREFIX)cpp
|
||||||
|
AR = $(PREFIX)ar
|
||||||
|
|
||||||
%.o: %.cc
|
%.o: %.cc
|
||||||
$(CC) $(CFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
%.o: %.asm
|
%.o: %.asm
|
||||||
$(ASM) $(NFLAGS) $< -o $@
|
$(NASM_CMD) $(NFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
RULES_MAK_INCLUDED = 1
|
RULES_MAK_INCLUDED = 1
|
||||||
|
|
Loading…
Reference in a new issue