mirror of
https://github.com/reactos/reactos.git
synced 2025-05-04 05:03:22 +00:00
Began converting minix fsd to work with new caching mechanism
Implemented user-mode APCs (still some bugs) Began implementing shared memory, still some locking issues svn path=/trunk/; revision=792
This commit is contained in:
parent
e510811de7
commit
b986ce1cac
81 changed files with 1974 additions and 2776 deletions
|
@ -41,7 +41,7 @@ FS_DRIVERS = vfat
|
|||
# FS_DRIVERS = minix ext2 template
|
||||
KERNEL_SERVICES = $(DEVICE_DRIVERS) $(FS_DRIVERS)
|
||||
|
||||
APPS = args hello shell test cat bench
|
||||
APPS = args hello shell test cat bench apc shm
|
||||
# APPS = cmd
|
||||
|
||||
all: buildno $(COMPONENTS) $(DLLS) $(SUBSYS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
|
||||
|
|
97
reactos/apps/tests/apc/apc.c
Normal file
97
reactos/apps/tests/apc/apc.c
Normal file
|
@ -0,0 +1,97 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
VOID STDCALL ApcRoutine(PVOID Context,
|
||||
PIO_STATUS_BLOCK IoStatus,
|
||||
ULONG Reserved)
|
||||
{
|
||||
printf("(apc.exe) ApcRoutine(Context %x)\n", Context);
|
||||
}
|
||||
|
||||
void main(int argc, char* argv[])
|
||||
{
|
||||
int i;
|
||||
NTSTATUS Status;
|
||||
HANDLE FileHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING FileName;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
CHAR Buffer[256];
|
||||
HANDLE EventHandle;
|
||||
|
||||
AllocConsole();
|
||||
InputHandle = GetStdHandle(STD_INPUT_HANDLE);
|
||||
OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
|
||||
printf("APC test program\n");
|
||||
|
||||
EventHandle = CreateEventW(NULL,
|
||||
FALSE,
|
||||
FALSE,
|
||||
NULL);
|
||||
if (EventHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Failed to create event\n");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("Opening file\n");
|
||||
RtlInitUnicodeString(&FileName,
|
||||
L"\\C:\\a.txt");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&FileName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
printf("Creating file\n");
|
||||
FileHandle = CreateFileW(L"C:\\a.txt",
|
||||
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
|
||||
0,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
NULL);
|
||||
if (FileHandle == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
printf("Open failed\n");
|
||||
return;
|
||||
}
|
||||
printf("Reading file\n");
|
||||
Status = ZwReadFile(FileHandle,
|
||||
NULL,
|
||||
ApcRoutine,
|
||||
0xdeadbeef,
|
||||
&IoStatus,
|
||||
Buffer,
|
||||
256,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
printf("Read failed\n");
|
||||
}
|
||||
printf("Waiting\n");
|
||||
WaitForSingleObjectEx(EventHandle, INFINITE, TRUE);
|
||||
printf("Returned from wait\n");
|
||||
ZwClose(FileHandle);
|
||||
printf("Program finished\n");
|
||||
for(;;);
|
||||
}
|
||||
|
44
reactos/apps/tests/apc/makefile
Normal file
44
reactos/apps/tests/apc/makefile
Normal file
|
@ -0,0 +1,44 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
OBJECTS= ../common/crt0.o apc.o
|
||||
PROGS= apc.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
LIBS = ../../lib/crtdll/crtdll.a ../../lib/kernel32/kernel32.a \
|
||||
../../lib/ntdll/ntdll.a
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) apc.o
|
||||
- $(RM) apc.exe
|
||||
- $(RM) apc.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
floppy: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
ifeq ($(DOSCLI),yes)
|
||||
$(CP) $* $(FLOPPY_DIR)\apps\$*
|
||||
else
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
endif
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
ifeq ($(DOSCLI),yes)
|
||||
$(CP) $* ..\..\$(DIST_DIR)\apps\$*
|
||||
else
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
endif
|
||||
|
||||
apc.exe: $(OBJECTS) $(LIBS)
|
||||
$(LD) $(OBJECTS) $(LIBS) -o apc.exe
|
||||
$(NM) --numeric-sort apc.exe > apc.sym
|
||||
|
||||
include ../../rules.mak
|
51
reactos/apps/tests/shm/makefile
Normal file
51
reactos/apps/tests/shm/makefile
Normal file
|
@ -0,0 +1,51 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
SRV_OBJECTS= ../common/crt0.o shmsrv.o
|
||||
CLT_OBJECTS= ../common/crt0.o shmclt.o
|
||||
|
||||
PROGS= shmsrv.exe shmclt.exe
|
||||
|
||||
BASE_CFLAGS = -I../../include
|
||||
LIBS = ../../lib/crtdll/crtdll.a ../../lib/kernel32/kernel32.a \
|
||||
../../lib/ntdll/ntdll.a
|
||||
|
||||
all: $(PROGS)
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) shmsrv.o
|
||||
- $(RM) shmsrv.exe
|
||||
- $(RM) shmsrv.sym
|
||||
|
||||
.phony: clean
|
||||
|
||||
floppy: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
|
||||
ifeq ($(DOSCLI),yes)
|
||||
$(CP) $* $(FLOPPY_DIR)\apps\$*
|
||||
else
|
||||
$(CP) $* $(FLOPPY_DIR)/apps/$*
|
||||
endif
|
||||
|
||||
dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
|
||||
|
||||
$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
|
||||
ifeq ($(DOSCLI),yes)
|
||||
$(CP) $* ..\..\$(DIST_DIR)\apps\$*
|
||||
else
|
||||
$(CP) $* ../../$(DIST_DIR)/apps/$*
|
||||
endif
|
||||
|
||||
shmsrv.exe: $(SRV_OBJECTS) $(LIBS)
|
||||
$(LD) $(SRV_OBJECTS) $(LIBS) -o shmsrv.exe
|
||||
$(NM) --numeric-sort shmsrv.exe > shmsrv.sym
|
||||
|
||||
shmclt.exe: $(CLT_OBJECTS) $(LIBS)
|
||||
$(LD) $(CLT_OBJECTS) $(LIBS) -o shmclt.exe
|
||||
$(NM) --numeric-sort shmsrv.exe > shmclt.sym
|
||||
|
||||
|
||||
include ../../rules.mak
|
53
reactos/apps/tests/shm/shmclt.c
Normal file
53
reactos/apps/tests/shm/shmclt.c
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
void main(int argc, char* argv[])
|
||||
{
|
||||
HANDLE Section;
|
||||
PVOID BaseAddress;
|
||||
char buffer[256];
|
||||
|
||||
printf("Shm test server\n");
|
||||
|
||||
Section = OpenFileMappingW(PAGE_EXECUTE_READWRITE,
|
||||
FALSE,
|
||||
L"\\TestSection");
|
||||
if (Section == NULL)
|
||||
{
|
||||
printf("Failed to open section");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseAddress = MapViewOfFile(Section,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
8192);
|
||||
printf("BaseAddress %x\n", BaseAddress);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to map section\n");
|
||||
}
|
||||
printf("Copying from section\n");
|
||||
strcpy(buffer, BaseAddress);
|
||||
printf("Copyed <%s>\n", buffer);
|
||||
|
||||
// for(;;);
|
||||
}
|
||||
|
63
reactos/apps/tests/shm/shmsrv.c
Normal file
63
reactos/apps/tests/shm/shmsrv.c
Normal file
|
@ -0,0 +1,63 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
HANDLE OutputHandle;
|
||||
HANDLE InputHandle;
|
||||
|
||||
void debug_printf(char* fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char buffer[255];
|
||||
|
||||
va_start(args,fmt);
|
||||
vsprintf(buffer,fmt,args);
|
||||
WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
VOID STDCALL ApcRoutine(PVOID Context,
|
||||
PIO_STATUS_BLOCK IoStatus,
|
||||
ULONG Reserved)
|
||||
{
|
||||
printf("(apc.exe) ApcRoutine(Context %x)\n", Context);
|
||||
}
|
||||
|
||||
void main(int argc, char* argv[])
|
||||
{
|
||||
HANDLE Section;
|
||||
PVOID BaseAddress;
|
||||
|
||||
printf("Shm test server\n");
|
||||
|
||||
Section = CreateFileMappingW(NULL,
|
||||
NULL,
|
||||
PAGE_EXECUTE_READWRITE,
|
||||
0,
|
||||
8192,
|
||||
L"\\TestSection");
|
||||
if (Section == NULL)
|
||||
{
|
||||
printf("Failed to create section");
|
||||
return;
|
||||
}
|
||||
|
||||
BaseAddress = MapViewOfFile(Section,
|
||||
FILE_MAP_ALL_ACCESS,
|
||||
0,
|
||||
0,
|
||||
8192);
|
||||
printf("BaseAddress %x\n", BaseAddress);
|
||||
if (BaseAddress == NULL)
|
||||
{
|
||||
printf("Failed to map section\n");
|
||||
}
|
||||
|
||||
printf("Copying to section\n");
|
||||
printf("Copying %s\n", GetCommandLineA());
|
||||
strcpy(BaseAddress, GetCommandLineA());
|
||||
|
||||
for(;;);
|
||||
}
|
||||
|
|
@ -18,15 +18,23 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
static unsigned int MinixGetBlock(PMINIX_DEVICE_EXTENSION DeviceExt,
|
||||
static unsigned int MinixGetBlock(PDEVICE_OBJECT DeviceObject,
|
||||
PMINIX_DEVICE_EXTENSION DeviceExt,
|
||||
struct minix_inode* inode,
|
||||
int blk)
|
||||
ULONG FileOffset)
|
||||
{
|
||||
int block;
|
||||
PCCB Ccb;
|
||||
PVOID BaseAddress;
|
||||
PCACHE_SEGMENT CacheSeg;
|
||||
ULONG blk;
|
||||
|
||||
DPRINT("MinixGetBlock(inode %x, blk %d)\n",inode,blk);
|
||||
|
||||
blk = FileOffset / BLOCKSIZE;
|
||||
|
||||
/*
|
||||
* The first few blocks are available in the inode
|
||||
*/
|
||||
if (blk < 7)
|
||||
{
|
||||
block = inode->i_zone[blk];
|
||||
|
@ -34,43 +42,76 @@ static unsigned int MinixGetBlock(PMINIX_DEVICE_EXTENSION DeviceExt,
|
|||
}
|
||||
blk = blk - 7;
|
||||
|
||||
/*
|
||||
* Retrieve a single-indirect block
|
||||
*/
|
||||
if (blk < 512)
|
||||
{
|
||||
block = inode->i_zone[7];
|
||||
Ccb = CbAcquireForRead(&DeviceExt->Dccb,block);
|
||||
block = ((PUSHORT)Ccb->Buffer)[blk];
|
||||
CbReleaseFromRead(&DeviceExt->Dccb,Ccb);
|
||||
|
||||
MinixRequestCacheBlock(DeviceObject,
|
||||
DeviceExt->Bcb,
|
||||
block * BLOCKSIZE,
|
||||
&BaseAddress,
|
||||
&CacheSeg);
|
||||
|
||||
block = ((PUSHORT)BaseAddress)[blk];
|
||||
|
||||
CcReleaseCachePage(DeviceExt->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
|
||||
return(block);
|
||||
}
|
||||
|
||||
/*
|
||||
* Get a double indirect block
|
||||
*/
|
||||
blk = blk - 512;
|
||||
block = inode->i_zone[8];
|
||||
|
||||
MinixRequestCacheBlock(DeviceObject,
|
||||
DeviceExt->Bcb,
|
||||
block * BLOCKSIZE,
|
||||
&BaseAddress,
|
||||
&CacheSeg);
|
||||
|
||||
Ccb = CbAcquireForRead(&DeviceExt->Dccb,block);
|
||||
block = ((PUSHORT)Ccb->Buffer)[(blk>>9)&511];
|
||||
CbReleaseFromRead(&DeviceExt->Dccb,Ccb);
|
||||
block = ((PUSHORT)BaseAddress)[(blk>>9)&511];
|
||||
|
||||
CcReleaseCachePage(DeviceExt->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
|
||||
Ccb = CbAcquireForRead(&DeviceExt->Dccb,block);
|
||||
block = ((PUSHORT)Ccb->Buffer)[blk&512];
|
||||
CbReleaseFromRead(&DeviceExt->Dccb,Ccb);
|
||||
MinixRequestCacheBlock(DeviceObject,
|
||||
DeviceExt->Bcb,
|
||||
block * BLOCKSIZE,
|
||||
&BaseAddress,
|
||||
&CacheSeg);
|
||||
|
||||
block = ((PUSHORT)BaseAddress)[blk&512];
|
||||
|
||||
CcReleaseCachePage(DeviceExt->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
|
||||
|
||||
return(block);
|
||||
}
|
||||
|
||||
NTSTATUS MinixReadBlock(PMINIX_DEVICE_EXTENSION DeviceExt,
|
||||
NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
|
||||
PMINIX_DEVICE_EXTENSION DeviceExt,
|
||||
struct minix_inode* inode,
|
||||
int blk,
|
||||
PCCB* Ccb)
|
||||
ULONG FileOffset,
|
||||
PULONG DiskOffset)
|
||||
{
|
||||
unsigned int block;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("DeviceExt %x\n",DeviceExt);
|
||||
DPRINT("inode %x\n",inode);
|
||||
DPRINT("blk %d\n",blk);
|
||||
DPRINT("Ccb %x\n",Ccb);
|
||||
DPRINT("MinixReadBlock(DeviceExt %x, inode %x, blk %d, Ccb %x)\n",
|
||||
DeviceExt,inode,blk,Ccb);
|
||||
DPRINT("MinixReadBlock()\n");
|
||||
|
||||
block = MinixGetBlock(DeviceExt,inode,blk);
|
||||
(*Ccb) = CbAcquireForRead(&DeviceExt->Dccb,block);
|
||||
block = MinixGetBlock(DeviceObject, DeviceExt,inode, FileOffset);
|
||||
|
||||
(*DiskOffset) = block * BLOCKSIZE;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -20,6 +20,26 @@
|
|||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
BOLEAN MinixReadPage(PDEVICE_OBJECT DeviceObject,
|
||||
ULONG Offset,
|
||||
PVOID Buffer)
|
||||
{
|
||||
ULONG i;
|
||||
BOOLEAN Result;
|
||||
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
Result = MinixReadSector(DeviceObject,
|
||||
(Offset + (i * PAGESIZE)) / BLOCKSIZE,
|
||||
(Buffer + (i * PAGESIZE)));
|
||||
if (!Result)
|
||||
{
|
||||
return(Result);
|
||||
}
|
||||
}
|
||||
return(True);
|
||||
}
|
||||
|
||||
BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
|
||||
IN ULONG DiskSector,
|
||||
IN UCHAR* Buffer)
|
||||
|
|
45
reactos/drivers/fs/minix/cache.c
Normal file
45
reactos/drivers/fs/minix/cache.c
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/minix/cache.c
|
||||
* PURPOSE: Minix FSD
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <ddk/ntifs.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
#include "minix.h"
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS MinixRequestCacheBlock(PDEVICE_OBJECT DeviceObject,
|
||||
PBCB Bcb,
|
||||
ULONG FileOffset,
|
||||
PVOID* BaseAddress,
|
||||
PCACHE_SEGMENT* CacheSeg)
|
||||
{
|
||||
BOOLEAN UptoDate;
|
||||
|
||||
CcRequestCachePage(Bcb,
|
||||
FileOffset,
|
||||
BaseAddress,
|
||||
&UptoDate,
|
||||
CacheSeg);
|
||||
if (!UptoDate)
|
||||
{
|
||||
MinixReadPage(DeviceObject,
|
||||
PAGE_ROUND_DOWN(FileOffset),
|
||||
BaseAddress);
|
||||
}
|
||||
BaseAddress = BaseAddress + (FileOffset % PAGESIZE);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
@ -98,8 +98,8 @@ ULONG MinixDirLookup(PMINIX_DEVICE_EXTENSION DeviceExt,
|
|||
|
||||
NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
||||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
||||
PWSTR DeviceName,
|
||||
struct minix_inode* result,
|
||||
PFILE_OBJECT FileObject;
|
||||
PMINIX_FSCONTEXT result,
|
||||
PULONG Information)
|
||||
{
|
||||
PWSTR current;
|
||||
|
@ -107,11 +107,15 @@ NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
|||
PWSTR string = DeviceName;
|
||||
struct minix_inode current_dir;
|
||||
unsigned int current_ino;
|
||||
PWSTR DeviceName;
|
||||
|
||||
DeviceName = FileObject->FileName.Buffer;
|
||||
|
||||
DbgPrint("MinixOpen(DeviceObject %x, DeviceName %w, result %x)\n",
|
||||
DeviceObject,DeviceName,result);
|
||||
DPRINT("DeviceName %x\n",DeviceName);
|
||||
|
||||
|
||||
next = &string[0];
|
||||
current = next+1;
|
||||
|
||||
|
@ -142,7 +146,12 @@ NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
|
|||
(*Information) = FILE_DOES_NOT_EXIST;
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
memcpy(result,¤t_dir,sizeof(struct minix_inode));
|
||||
|
||||
result = ExAllocatePool(NonPagedPool, sizeof(MINIX_FSCONTEXT));
|
||||
memcpy(&result->inode,¤t_dir,sizeof(struct minix_inode));
|
||||
CcInitializeFileCache(FileObject,
|
||||
&result->Bcb);
|
||||
|
||||
DPRINT("MinxOpen() = STATUS_SUCCESS\n",0);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -198,11 +207,13 @@ NTSTATUS MinixCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
DeviceExt = (MINIX_DEVICE_EXTENSION *)DeviceObject->DeviceExtension;
|
||||
result = ExAllocatePool(NonPagedPool,sizeof(struct minix_inode));
|
||||
DPRINT("result %x\n",result);
|
||||
Status = MinixOpen(DeviceExt->AttachedDevice,DeviceExt,
|
||||
FileObject->FileName.Buffer,result,
|
||||
Status = MinixOpen(DeviceExt->AttachedDevice,
|
||||
DeviceExt,
|
||||
FileObject,
|
||||
result,
|
||||
&Irp->IoStatus.Information);
|
||||
|
||||
if (Status==STATUS_SUCCESS)
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
FileObject->FsContext=result;
|
||||
}
|
||||
|
|
|
@ -109,6 +109,10 @@ NTSTATUS MinixReadInode(PDEVICE_OBJECT DeviceObject,
|
|||
PCCB Ccb;
|
||||
int block;
|
||||
struct minix_inode* inodes;
|
||||
NTSTATUS Status;
|
||||
PVOID BaseAddress;
|
||||
BOOLEAN UptoDate;
|
||||
PCACHE_SEGMENT* CacheSeg;
|
||||
|
||||
DPRINT("MinixReadInode(ino %x, result %x)\n",ino,result);
|
||||
|
||||
|
@ -117,16 +121,29 @@ NTSTATUS MinixReadInode(PDEVICE_OBJECT DeviceObject,
|
|||
DPRINT("Reading block %x offset %x\n",block,block*BLOCKSIZE);
|
||||
DPRINT("Index %x\n",(ino-1)%MINIX_INODES_PER_BLOCK);
|
||||
|
||||
Ccb = CbAcquireForRead(&DeviceExt->Dccb,
|
||||
block);
|
||||
inodes = (struct minix_inode *)Ccb->Buffer;
|
||||
Status = CcRequestCachePage(DeviceExt->Bcb,
|
||||
block,
|
||||
&BaseAddress,
|
||||
&UptoDate,
|
||||
&CacheSeg);
|
||||
|
||||
if (!UptoDate)
|
||||
{
|
||||
MinixReadPage(DeviceExt,
|
||||
PAGE_ROUND_DOWN(block),
|
||||
BaseAddress);
|
||||
}
|
||||
|
||||
inodes = (struct minix_inode *)(BaseAddress + ((block % 4) * 512));
|
||||
|
||||
memcpy(result,&inodes[(ino-1)%MINIX_INODES_PER_BLOCK],
|
||||
sizeof(struct minix_inode));
|
||||
DPRINT("result->i_uid %x\n",result->i_uid);
|
||||
DPRINT("result->i_size %x\n",result->i_size);
|
||||
|
||||
CbReleaseFromRead(&DeviceExt->Dccb,Ccb);
|
||||
CcFreeCacheSegment(DeviceExt->FileObject,
|
||||
DeviceExt->Bcb,
|
||||
CacheSeg);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
BASE_CFLAGS = -I../../../include
|
||||
|
||||
all: minix.sys
|
||||
all: minixfs.sys
|
||||
|
||||
OBJECTS = block.o rw.o inode.o dir.o mount.o blockdev.o \
|
||||
OBJECTS = block.o rw.o inode.o dir.o mount.o blockdev.o cache.o \
|
||||
../../../ntoskrnl/ntoskrnl.a
|
||||
|
||||
.phony: all
|
||||
|
@ -18,23 +18,23 @@ clean:
|
|||
- $(RM) junk.tmp
|
||||
- $(RM) base.tmp
|
||||
- $(RM) temp.exp
|
||||
- $(RM) minix.sys
|
||||
- $(RM) minixfs.sys
|
||||
|
||||
.phony: clean
|
||||
|
||||
minix.o: $(OBJECTS)
|
||||
$(LD) -r $(OBJECTS) -o minix.o
|
||||
|
||||
minix.sys: $(OBJECTS)
|
||||
minixfs.sys: $(OBJECTS)
|
||||
$(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \
|
||||
-Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
|
||||
-Wl,--base-file,base.tmp $(OBJECTS)
|
||||
- $(RM) junk.tmp
|
||||
$(DLLTOOL) --dllname minix.sys --base-file base.tmp \
|
||||
$(DLLTOOL) --dllname minixfs.sys --base-file base.tmp \
|
||||
--output-exp temp.exp
|
||||
- $(RM) base.tmp
|
||||
$(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \
|
||||
-specs=../../svc_specs -mdll -o minix.sys $(OBJECTS) -Wl,temp.exp
|
||||
-specs=../../svc_specs -mdll -o minixfs.sys $(OBJECTS) -Wl,temp.exp
|
||||
- $(RM) temp.exp
|
||||
|
||||
WIN32_LEAN_AND_MEAN = yes
|
||||
|
|
|
@ -93,9 +93,16 @@ typedef struct
|
|||
struct minix_inode root_inode;
|
||||
char superblock_buf[BLOCKSIZE];
|
||||
struct minix_super_block* sb;
|
||||
DCCB Dccb;
|
||||
PFILE_OBJECT FileObject;
|
||||
PBCB Bcb;
|
||||
} MINIX_DEVICE_EXTENSION, *PMINIX_DEVICE_EXTENSION;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PBCB Bcb;
|
||||
struct minix_inode inode;
|
||||
} MINIX_FSCONTEXT, *PMINIX_FSCONTEXT;
|
||||
|
||||
NTSTATUS MinixCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS MinixClose(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
NTSTATUS MinixWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp);
|
||||
|
@ -116,7 +123,15 @@ NTSTATUS MinixDeleteInode(PDEVICE_OBJECT Volume,
|
|||
MINIX_DEVICE_EXTENSION* DeviceExt,
|
||||
ULONG ino);
|
||||
|
||||
NTSTATUS MinixReadBlock(PMINIX_DEVICE_EXTENSION DeviceExt,
|
||||
NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
|
||||
PMINIX_DEVICE_EXTENSION DeviceExt,
|
||||
struct minix_inode* inode,
|
||||
int blk,
|
||||
PCCB* Ccb);
|
||||
ULONG FileOffset,
|
||||
PULONG DiskOffset);
|
||||
|
||||
|
||||
NTSTATUS MinixRequestCacheBlock(PDEVICE_OBJECT DeviceObject,
|
||||
PBCB Bcb,
|
||||
ULONG FileOffset,
|
||||
PVOID* BaseAddress,
|
||||
PCACHE_SEGMENT* CacheSeg);
|
||||
|
|
|
@ -43,8 +43,9 @@ VOID MinixMount(PDEVICE_OBJECT DeviceToMount)
|
|||
|
||||
DeviceExt->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
||||
DeviceToMount);
|
||||
CbInitDccb(&DeviceExt->Dccb,DeviceExt->AttachedDevice,
|
||||
BLOCKSIZE,2880,10);
|
||||
DeviceExt->FileObject = IoCreateStreamFileObject(NULL, DeviceObject);
|
||||
CcInitializeFileCache(DeviceExt->FileObject,
|
||||
&DeviceExt->Bcb);
|
||||
}
|
||||
|
||||
NTSTATUS MinixFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
|
@ -100,14 +101,12 @@ NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT _DriverObject,
|
|||
PDEVICE_OBJECT DeviceObject;
|
||||
NTSTATUS ret;
|
||||
UNICODE_STRING ustr;
|
||||
ANSI_STRING astr;
|
||||
|
||||
DbgPrint("Minix FSD 0.0.1\n");
|
||||
|
||||
DriverObject = _DriverObject;
|
||||
|
||||
RtlInitAnsiString(&astr,"\\Device\\Minix");
|
||||
RtlAnsiStringToUnicodeString(&ustr,&astr,TRUE);
|
||||
RtlInitUnicodeString(&ustr, L"\\Device\\Minux");
|
||||
ret = IoCreateDevice(DriverObject,0,&ustr,
|
||||
FILE_DEVICE_PARALLEL_PORT,0,FALSE,&DeviceObject);
|
||||
if (ret!=STATUS_SUCCESS)
|
||||
|
|
|
@ -28,6 +28,45 @@ NTSTATUS MinixWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
static NTSTATUS MinixReadFilePage(PDEVICE_OBJECT DeviceObject,
|
||||
PMINIX_DEVICE_EXTENSION DeviceExt,
|
||||
PMINIX_FSCONTEXT FsContext,
|
||||
ULONG Offset,
|
||||
PVOID* Buffer,
|
||||
PCACHE_SEGMENT* CacheSeg)
|
||||
{
|
||||
BOOLEAN UptoDate;
|
||||
NTSTATUS Status;
|
||||
ULONG i;
|
||||
ULONG DiskOffset;
|
||||
|
||||
Status = CcRequestCachePage(FsContext->Bcb,
|
||||
Offset,
|
||||
Buffer,
|
||||
&UptoDate,
|
||||
CacheSeg);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (!UptoDate)
|
||||
{
|
||||
for (i=0; i<4; i++)
|
||||
{
|
||||
Status = MinixReadBlock(DeviceObject,
|
||||
DeviceExt,
|
||||
&FsContext->inode,
|
||||
Offset + (i * BLOCKSIZE),
|
||||
&DiskOffset);
|
||||
MinixReadSector(DeviceObject,
|
||||
DiskOffset / BLOCKSIZE,
|
||||
(*Buffer) + (i * BLOCKSIZE));
|
||||
}
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
ULONG Length;
|
||||
|
@ -37,9 +76,10 @@ NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
|
||||
PFILE_OBJECT FileObject = Stack->FileObject;
|
||||
MINIX_DEVICE_EXTENSION* DeviceExt = DeviceObject->DeviceExtension;
|
||||
struct minix_inode* inode = (struct minix_inode *)FileObject->FsContext;
|
||||
PMINIX_FSCONTEXT FsContext = (PMINIX_FSCONTEXT)FileObject->FsContext;
|
||||
unsigned int i;
|
||||
PCCB Ccb = NULL;
|
||||
PVOID DiskBuffer;
|
||||
PCACHE_SEGMENT CacheSeg;
|
||||
|
||||
DPRINT("MinixRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
|
@ -53,60 +93,86 @@ NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
DPRINT("inode->i_size %d\n",inode->i_size);
|
||||
|
||||
if (Offset > inode->i_size)
|
||||
if (Offset > FsContext->inode.i_size)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
||||
Irp->IoStatus.Information = 0;
|
||||
IoCompleteRequest(Irp,IO_NO_INCREMENT);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
if ((Offset+Length) > inode->i_size)
|
||||
if ((Offset+Length) > FsContext->inode.i_size)
|
||||
{
|
||||
Length = inode->i_size - Offset;
|
||||
Length = FsContext->inode.i_size - Offset;
|
||||
}
|
||||
|
||||
if ((Offset%BLOCKSIZE)!=0)
|
||||
if ((Offset%PAGESIZE)!=0)
|
||||
{
|
||||
CHECKPOINT;
|
||||
CurrentOffset = Offset - (Offset%PAGESIZE);
|
||||
|
||||
CurrentOffset = Offset - (Offset%BLOCKSIZE);
|
||||
MinixReadFilePage(DeviceObject,
|
||||
DeviceExt,
|
||||
FsContext,
|
||||
CurrentOffset,
|
||||
&DiskBuffer,
|
||||
&CacheSeg);
|
||||
|
||||
memcpy(Buffer,
|
||||
DiskBuffer+(Offset%PAGESIZE),
|
||||
min(PAGESIZE - (Offset%PAGESIZE),Length));
|
||||
|
||||
CcReleaseCachePage(FsContext->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
|
||||
MinixReadBlock(DeviceExt,inode,
|
||||
CurrentOffset/BLOCKSIZE,
|
||||
&Ccb);
|
||||
memcpy(Buffer,Ccb->Buffer+(Offset%BLOCKSIZE),
|
||||
min(BLOCKSIZE - (Offset%BLOCKSIZE),Length));
|
||||
DPRINT("(BLOCKSIZE - (Offset%BLOCKSIZE)) %d\n",
|
||||
(BLOCKSIZE - (Offset%BLOCKSIZE)));
|
||||
DPRINT("Length %d\n",Length);
|
||||
CurrentOffset = CurrentOffset + BLOCKSIZE;
|
||||
Buffer = Buffer + BLOCKSIZE - (Offset%BLOCKSIZE);
|
||||
Length = Length - min(BLOCKSIZE - (Offset%BLOCKSIZE),Length);
|
||||
CurrentOffset = CurrentOffset + PAGESIZE;
|
||||
Buffer = Buffer + PAGESIZE - (Offset%PAGESIZE);
|
||||
Length = Length - min(PAGESIZE - (Offset%PAGESIZE),Length);
|
||||
DPRINT("CurrentOffset %d Buffer %x Length %d\n",CurrentOffset,Buffer,
|
||||
Length);
|
||||
}
|
||||
for (i=0;i<(Length/BLOCKSIZE);i++)
|
||||
for (i=0;i<(Length/PAGESIZE);i++)
|
||||
{
|
||||
CHECKPOINT;
|
||||
|
||||
DPRINT("Length %d\n",Length);
|
||||
|
||||
MinixReadBlock(DeviceExt,inode,
|
||||
CurrentOffset/BLOCKSIZE,&Ccb);
|
||||
memcpy(Buffer,Ccb->Buffer,BLOCKSIZE);
|
||||
CurrentOffset = CurrentOffset + BLOCKSIZE;
|
||||
Buffer = Buffer + BLOCKSIZE;
|
||||
MinixReadFilePage(DeviceObject,
|
||||
DeviceExt,
|
||||
FsContext,
|
||||
CurrentOffset,
|
||||
&DiskBuffer,
|
||||
&CacheSeg);
|
||||
memcpy(Buffer, DiskBuffer, PAGESIZE);
|
||||
|
||||
CcReleaseCachePage(FsContext->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
|
||||
CurrentOffset = CurrentOffset + PAGESIZE;
|
||||
Buffer = Buffer + PAGESIZE;
|
||||
}
|
||||
if ((Length%BLOCKSIZE) > 0)
|
||||
if ((Length%PAGESIZE) > 0)
|
||||
{
|
||||
CHECKPOINT;
|
||||
|
||||
DPRINT("Length %x Buffer %x\n",(Length%BLOCKSIZE),Buffer);
|
||||
DPRINT("Length %x Buffer %x\n",(Length%PAGESIZE),Buffer);
|
||||
|
||||
MinixReadBlock(DeviceExt,inode,
|
||||
CurrentOffset/BLOCKSIZE,
|
||||
&Ccb);
|
||||
memcpy(Buffer,Ccb->Buffer,(Length%BLOCKSIZE));
|
||||
MinixReadFilePage(DeviceObject,
|
||||
DeviceExt,
|
||||
FsContext,
|
||||
CurrentOffset,
|
||||
&DiskBuffer,
|
||||
&CacheSeg);
|
||||
|
||||
memcpy(Buffer, DiskBuffer, (Length%PAGESIZE));
|
||||
|
||||
CcReleaseCachePage(FsContext->Bcb,
|
||||
CacheSeg,
|
||||
TRUE);
|
||||
|
||||
}
|
||||
|
||||
Irp->IoStatus.Status = STATUS_SUCCESS;
|
||||
|
|
40
reactos/drivers/fs/np/Makefile
Normal file
40
reactos/drivers/fs/np/Makefile
Normal file
|
@ -0,0 +1,40 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
|
||||
BASE_CFLAGS = -I../../../include
|
||||
|
||||
OBJECTS = super.o blockdev.o inode.o file.o dir.o rw.o quota.o security.o \
|
||||
attr.o ../../../ntoskrnl/ntoskrnl.a
|
||||
|
||||
all: ext2fs.sys
|
||||
|
||||
.phony: all
|
||||
|
||||
clean:
|
||||
- $(RM) super.o
|
||||
- $(RM) blockdev.o
|
||||
- $(RM) inode.o
|
||||
- $(RM) file.o
|
||||
- $(RM) dir.o
|
||||
- $(RM) rw.o
|
||||
- $(RM) junk.tmp
|
||||
- $(RM) base.tmp
|
||||
- $(RM) temp.exp
|
||||
- $(RM) ext2fs.sys
|
||||
|
||||
.phony: clean
|
||||
|
||||
ext2fs.sys: $(OBJECTS)
|
||||
$(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \
|
||||
-Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
|
||||
-Wl,--base-file,base.tmp $(OBJECTS)
|
||||
$(RM) junk.tmp
|
||||
$(DLLTOOL) --dllname ext2fs.sys --base-file base.tmp \
|
||||
--output-exp temp.exp
|
||||
$(RM) base.tmp
|
||||
$(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry \
|
||||
-specs=../../svc_specs -mdll -o ext2fs.sys $(OBJECTS) -Wl,temp.exp
|
||||
$(RM) temp.exp
|
||||
|
||||
include ../../../rules.mak
|
70
reactos/drivers/fs/np/create.c
Normal file
70
reactos/drivers/fs/np/create.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/np/create.c
|
||||
* PURPOSE: Named pipe filesystem
|
||||
* PROGRAMMER: David Welch <welch@cwcom.net>
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
#include "np.h"
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS NpfsCreatePipe(PNPFS_DEVICE_EXTENSION DeviceExt,
|
||||
PFILE_OBJECT FileObject)
|
||||
{
|
||||
PWSTR PipeName;
|
||||
PNPFS_FSCONTEXT PipeDescr;
|
||||
NTSTATUS Status;
|
||||
|
||||
PipeName = wcsrchr(FileObject->FileName.Buffer, L'\\');
|
||||
if (PipeName == NULL)
|
||||
{
|
||||
PipeName = FileObject->FileName.Buffer;
|
||||
}
|
||||
|
||||
PipeDescr = ExAllocatePool(NonPagedPool, sizeof(NPFS_FSCONTEXT));
|
||||
if (PipeDescr == NULL)
|
||||
{
|
||||
return(STATUS_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
Status = NpfsCreateEntry(PipeName, PipeDescr);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePool(PipeDescr);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
FileObject->FsContext = PipeDescr;
|
||||
|
||||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
PFILE_OBJECT FileObject;
|
||||
NTSTATUS Status;
|
||||
PNPFS_DEVICE_EXTENSION DeviceExt;
|
||||
|
||||
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
FileObject = IoStack->FileObject;
|
||||
|
||||
Status = NpfsCreatePipe(DeviceExt, FileObject);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return(Status);
|
||||
}
|
124
reactos/drivers/fs/np/mount.c
Normal file
124
reactos/drivers/fs/np/mount.c
Normal file
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/np/mount.c
|
||||
* PURPOSE: Named pipe filesystem
|
||||
* PROGRAMMER: David Welch <welch@cwcom.net>
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
#include "np.h"
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
static PDRIVER_OBJECT DriverObject;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS NpfsMount(PDEVICE_OBJECT DeviceToMount)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PNPFS_DEVICE_EXTENSION DeviceExt;
|
||||
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
sizeof(NPFS_DEVICE_EXTENSION),
|
||||
NULL,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
|
||||
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
|
||||
DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
|
||||
DeviceToMount);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
PVPB Vpb = IoStack->Parameters.Mount.Vpb;
|
||||
PDEVICE_OBJECT DeviceToMount = IoStack->Parameters.Mount.DeviceObject;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = NpfsMount(DeviceToMount);
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return(Status);
|
||||
|
||||
}
|
||||
|
||||
NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
|
||||
PUNICODE_STRING RegistryPath)
|
||||
{
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
NTSTATUS Status;
|
||||
UNICODE_STRING DeviceName;
|
||||
|
||||
DbgPrint("Named Pipe Filesystem\n");
|
||||
|
||||
DriverObject = _DriverObject;
|
||||
|
||||
RtlInitUnicodeString(&DeviceName, L"\\Device\\Npfs");
|
||||
Status = IoCreateDevice(DriverObject,
|
||||
0,
|
||||
&DeviceName,
|
||||
FILE_DEVICE_FILE_SYSTEM,
|
||||
0,
|
||||
FALSE,
|
||||
&DeviceObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DeviceObject->Flags = 0;
|
||||
DeviceObject->MajorFunction[IRP_MJ_CLOSE] = NpfsClose;
|
||||
DeviceObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
|
||||
DeviceObject->MajorFunction[IRP_MJ_READ] = NpfsRead;
|
||||
DeviceObject->MajorFunction[IRP_MJ_WRITE] = NpfsWrite;
|
||||
DeviceObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
|
||||
NpfsFileSystemControl;
|
||||
DeviceObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
|
||||
NpfsDirectoryControl;
|
||||
DeviceObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
|
||||
NpfsQueryInformation;
|
||||
DeviceObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
|
||||
NpfsSetInformation;
|
||||
DeviceObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers;
|
||||
DeviceObject->MajorFunction[IRP_MJ_SHUTDOWN] = NpfsShutdown;
|
||||
DeviceObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup;
|
||||
DeviceObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
|
||||
NpfsQuerySecurity;
|
||||
DeviceObject->MajorFunction[IRP_MJ_SET_SECURITY] =
|
||||
NpfsSetSecurity;
|
||||
DeviceObject->MajorFunction[IRP_MJ_QUERY_QUOTA] =
|
||||
NpfsQueryQuota;
|
||||
DeviceObject->MajorFunction[IRP_MJ_SET_QUOTA] =
|
||||
NpfsSetQuota;
|
||||
|
||||
DriverObject->DriverUnload = NULL;
|
||||
|
||||
IoRegisterFileSystem(DeviceObject);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
25
reactos/drivers/fs/np/npfs.h
Normal file
25
reactos/drivers/fs/np/npfs.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#ifndef __SERVICES_FS_NP_NPFS_H
|
||||
#define __SERVICES_FS_NP_NPFS_H
|
||||
|
||||
typedef struct
|
||||
{
|
||||
PDEVICE_OBJECT StorageDevice;
|
||||
} NPFS_DEVICE_EXTENSION, *PNPFS_DEVICE_EXTENSION;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
PVOID Buffer;
|
||||
ULONG Length;
|
||||
} NPFS_MSG, *PNPFS_MSG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LIST_ENTRY DirectoryListEntry;
|
||||
LIST_ENTRY GlobalListEntry;
|
||||
ULONG Flags;
|
||||
LIST_ENTRY MsgListHead;
|
||||
KPSIN_LOCK MsgListLock;
|
||||
} NPFS_FSCONTEXT, *PNPFS_FSCONTEXT;
|
||||
|
||||
#endif /* __SERVICES_FS_NP_NPFS_H */
|
|
@ -1,12 +1,12 @@
|
|||
#
|
||||
#
|
||||
#
|
||||
TARGET=vfatfsd
|
||||
TARGET=vfatfs
|
||||
OBJECTS = blockdev.o dir.o dirwr.o iface.o ../../../ntoskrnl/ntoskrnl.a
|
||||
|
||||
BASE_CFLAGS = -I../../../include
|
||||
|
||||
all: vfatfsd.sys
|
||||
all: vfatfs.sys
|
||||
|
||||
.phony: all
|
||||
|
||||
|
@ -19,9 +19,9 @@ ifeq ($(DOSCLI),yes)
|
|||
- $(RM) junk.tmp
|
||||
- $(RM) base.tmp
|
||||
- $(RM) temp.exp
|
||||
- $(RM) vfatfsd.sys
|
||||
- $(RM) vfatfs.sys
|
||||
else
|
||||
- $(RM) blockdev.o dir.o dirwr.o iface.o junk.tmp base.tmp temp.exp vfatfsd.sys
|
||||
- $(RM) blockdev.o dir.o dirwr.o iface.o junk.tmp base.tmp temp.exp vfatfs.sys
|
||||
endif
|
||||
|
||||
.phony: clean
|
||||
|
@ -44,16 +44,17 @@ else
|
|||
$(CP) $(TARGET).sys ../../../$(DIST_DIR)/drivers/$(TARGET).sys
|
||||
endif
|
||||
|
||||
vfatfsd.sys: $(OBJECTS)
|
||||
vfatfs.sys: $(OBJECTS)
|
||||
$(CC) -specs=../../svc_specs -mdll -o junk.tmp -Wl,--defsym,_end=end \
|
||||
-Wl,--defsym,_edata=__data_end__ -Wl,--defsym,_etext=etext \
|
||||
-Wl,--base-file,base.tmp $(OBJECTS)
|
||||
-Wl,--base-file,base.tmp -Wl,"-h vfatfs.sys" $(OBJECTS)
|
||||
- $(RM) junk.tmp
|
||||
$(DLLTOOL) --dllname vfatfsd.sys --base-file base.tmp \
|
||||
--output-exp temp.exp
|
||||
$(DLLTOOL) --dllname vfatfs.sys --base-file base.tmp \
|
||||
--output-exp temp.exp --def vfatfs.def
|
||||
- $(RM) base.tmp
|
||||
$(CC) --verbose -Wl,--image-base,0x10000 -Wl,-e,_DriverEntry@8 \
|
||||
-specs=../../svc_specs -mdll -o vfatfsd.sys $(OBJECTS) -Wl,temp.exp
|
||||
-specs=../../svc_specs -mdll -o vfatfs.sys $(OBJECTS) \
|
||||
-Wl,temp.exp -Wl,"-h vfatfs.sys"
|
||||
- $(RM) temp.exp
|
||||
|
||||
|
||||
|
|
1
reactos/drivers/fs/vfat/vfatfs.def
Normal file
1
reactos/drivers/fs/vfat/vfatfs.def
Normal file
|
@ -0,0 +1 @@
|
|||
LIBRARY VFATFS.SYS
|
|
@ -3,26 +3,12 @@
|
|||
|
||||
/* EXECUTIVE ROUTINES ******************************************************/
|
||||
|
||||
VOID
|
||||
ExAcquireFastMutex (
|
||||
PFAST_MUTEX FastMutex
|
||||
);
|
||||
VOID
|
||||
ExAcquireFastMutexUnsafe (
|
||||
PFAST_MUTEX FastMutex
|
||||
);
|
||||
BOOLEAN
|
||||
ExAcquireResourceExclusive (
|
||||
PERESOURCE Resource,
|
||||
BOOLEAN Wait
|
||||
);
|
||||
BOOLEAN
|
||||
ExAcquireResourceExclusiveLite (
|
||||
PERESOURCE Resource,
|
||||
BOOLEAN Wait
|
||||
);
|
||||
BOOLEAN
|
||||
ExAcquireResourceSharedLite (
|
||||
VOID ExReleaseResourceLite(PERESOURCE Resource);
|
||||
VOID ExAcquireFastMutex (PFAST_MUTEX FastMutex);
|
||||
VOID ExAcquireFastMutexUnsafe (PFAST_MUTEX FastMutex);
|
||||
BOOLEAN ExAcquireResourceExclusive (PERESOURCE Resource, BOOLEAN Wait);
|
||||
BOOLEAN ExAcquireResourceExclusiveLite (PERESOURCE Resource, BOOLEAN Wait);
|
||||
BOOLEAN ExAcquireResourceSharedLite (
|
||||
PERESOURCE Resource,
|
||||
BOOLEAN Wait
|
||||
);
|
||||
|
|
|
@ -65,7 +65,7 @@ typedef struct _KTIMER
|
|||
LIST_ENTRY TimerListEntry;
|
||||
struct _KDPC* Dpc;
|
||||
LONG Period;
|
||||
} KTIMER, *PKTIMER;
|
||||
} KTIMER, *PKTIMER;
|
||||
|
||||
/*
|
||||
typedef struct _KTIMER
|
||||
|
@ -124,7 +124,7 @@ typedef struct
|
|||
UCHAR State;
|
||||
} KBUGCHECK_CALLBACK_RECORD, *PKBUGCHECK_CALLBACK_RECORD;
|
||||
|
||||
typedef struct
|
||||
typedef struct _KMUTEX
|
||||
{
|
||||
DISPATCHER_HEADER Header;
|
||||
LIST_ENTRY MutantListEntry;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
|
||||
|
||||
HANDLE PsGetCurrentProcessId(VOID);
|
||||
|
||||
/*
|
||||
* FUNCTION: Creates a thread which executes in kernel mode
|
||||
|
@ -25,7 +26,11 @@ NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
PKSTART_ROUTINE StartRoutine,
|
||||
PVOID StartContext);
|
||||
NTSTATUS PsTerminateSystemThread(NTSTATUS ExitStatus);
|
||||
ULONG PsSuspendThread(PETHREAD Thread);
|
||||
ULONG PsResumeThread(PETHREAD Thread);
|
||||
ULONG PsSuspendThread(PETHREAD Thread,
|
||||
PNTSTATUS WaitStatus,
|
||||
UCHAR Alertable,
|
||||
ULONG WaitMode);
|
||||
ULONG PsResumeThread(PETHREAD Thread,
|
||||
PNTSTATUS WaitStatus);
|
||||
PETHREAD PsGetCurrentThread(VOID);
|
||||
struct _EPROCESS* PsGetCurrentProcess(VOID);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: zw.h,v 1.19 1999/10/16 12:38:25 ekohl Exp $
|
||||
/* $Id: zw.h,v 1.20 1999/11/24 11:51:42 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -5150,38 +5150,6 @@ ZwYieldExecution(
|
|||
* These prototypes are unknown as yet
|
||||
* (stack sizes by Peter-Michael Hager)
|
||||
*/
|
||||
#ifndef PROTO_LPC
|
||||
NTSTATUS STDCALL NtAcceptConnectPort(VOID);
|
||||
NTSTATUS STDCALL NtCompleteConnectPort(VOID);
|
||||
//NTSTATUS STDCALL NtConnectPort(VOID);
|
||||
NTSTATUS STDCALL NtConnectPort(PHANDLE Handle,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes);
|
||||
|
||||
NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
DWORD a3,
|
||||
DWORD a4);
|
||||
|
||||
NTSTATUS STDCALL NtImpersonateClientOfPort(VOID);
|
||||
//NTSTATUS STDCALL NtListenPort(VOID);
|
||||
NTSTATUS STDCALL NtListenPort(HANDLE PortHandle,
|
||||
PLARGE_INTEGER Timeout,
|
||||
PPORT_MSG_DATA Msg);
|
||||
NTSTATUS STDCALL NtQueryInformationPort(VOID);
|
||||
NTSTATUS STDCALL NtReplyPort(VOID);
|
||||
NTSTATUS STDCALL NtReplyWaitReceivePort(VOID);
|
||||
NTSTATUS STDCALL NtReplyWaitReplyPort(VOID);
|
||||
//NTSTATUS STDCALL NtRequestPort(VOID);
|
||||
NTSTATUS STDCALL NtRequestPort(HANDLE PortHandle,
|
||||
ULONG DataLength,
|
||||
PVOID Data,
|
||||
ULONG Options,
|
||||
PHANDLE ReplyPortHandle);
|
||||
NTSTATUS STDCALL NtRequestWaitReplyPort(VOID);
|
||||
NTSTATUS STDCALL NtReadRequestData(VOID);
|
||||
NTSTATUS STDCALL NtWriteRequestData(VOID);
|
||||
#else
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtAcceptConnectPort ( /* @24 */
|
||||
|
@ -5199,25 +5167,30 @@ NtCompleteConnectPort ( /* @4 */
|
|||
);
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtConnectPort ( /* @32 */
|
||||
NtConnectPort (
|
||||
OUT PHANDLE PortHandle,
|
||||
IN PUNICODE_STRING PortName,
|
||||
IN PVOID Unknown2,
|
||||
IN POBJECT_ATTRIBUTES PortAttributes,
|
||||
IN DWORD Unknown3,
|
||||
IN DWORD Unknown4,
|
||||
IN DWORD Unknown5,
|
||||
IN DWORD Unknown6,
|
||||
IN UINT Flags /* ??? */
|
||||
IN ULONG Flags
|
||||
);
|
||||
NTSTATUS
|
||||
/*NTSTATUS
|
||||
STDCALL
|
||||
NtCreatePort ( /* @20 */
|
||||
NtCreatePort (
|
||||
IN POBJECT_ATTRIBUTES PortAttributes OPTIONAL,
|
||||
OUT PHANDLE PortHandle,
|
||||
IN ACCESS_MASK GrantedAccess,
|
||||
IN DWORD Unknown3,
|
||||
IN ULONG Flags
|
||||
);
|
||||
);*/
|
||||
NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
DWORD a3,
|
||||
DWORD a4);
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtImpersonateClientOfPort ( /* @8 */
|
||||
|
@ -5292,7 +5265,7 @@ NtWriteRequestData ( /* @24 */
|
|||
DWORD a4,
|
||||
DWORD a5
|
||||
);
|
||||
#endif /* ndef PROTO_LPC */
|
||||
|
||||
|
||||
/* --- REGISTRY --- */
|
||||
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
#ifndef __INCLUDE_DDK_ZWTYPES_H
|
||||
#define __INCLUDE_DDK_ZWTYPES_H
|
||||
|
||||
#ifndef PROTO_LPC
|
||||
/* Added by David Welch at 09/04/99 */
|
||||
typedef struct _PORT_MSG_DATA
|
||||
{
|
||||
ULONG DataLength;
|
||||
PVOID Data;
|
||||
HANDLE ReplyPort;
|
||||
} PORT_MSG_DATA, *PPORT_MSG_DATA;
|
||||
|
||||
#else
|
||||
/* Added by EA on 199906160051 */
|
||||
typedef
|
||||
enum {
|
||||
LpcMessageTypeUnknown, /* invalid */
|
||||
|
@ -38,7 +27,7 @@ struct _LPC_MESSAGE
|
|||
DWORD Flags; /* To be defined */
|
||||
|
||||
} LPC_MESSAGE, * PLPC_MESSAGE;
|
||||
#endif /* ndef PROTO_LPC */
|
||||
|
||||
|
||||
#define NtCurrentProcess() ( (HANDLE) 0xFFFFFFFF )
|
||||
#define NtCurrentThread() ( (HANDLE) 0xFFFFFFFE )
|
||||
|
|
|
@ -130,6 +130,7 @@ VOID HalQueryDisplayParameters(PULONG DispSizeX,
|
|||
PULONG CursorPosY);
|
||||
|
||||
VOID HalQueryRealTimeClock(PTIME_FIELDS pTime);
|
||||
VOID HalSetRealTimeClock(PTIME_FIELDS Time);
|
||||
|
||||
VOID HalQuerySystemInformation(VOID);
|
||||
|
||||
|
|
|
@ -82,4 +82,5 @@ NTSTATUS HalRegisterServiceTable(DWORD Mask,
|
|||
VOID HalInitializeDisplay (boot_param *bp);
|
||||
VOID HalResetDisplay (VOID);
|
||||
|
||||
|
||||
#endif /* __INTERNAL_HAL_HAL_H */
|
||||
|
|
|
@ -59,5 +59,6 @@ PIRP IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction,
|
|||
PLARGE_INTEGER StartingOffset,
|
||||
PKEVENT Event,
|
||||
PIO_STATUS_BLOCK IoStatusBlock);
|
||||
VOID IoShutdownIoManager(VOID);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,7 @@ VOID KeInitializeDispatcherHeader(DISPATCHER_HEADER* Header, ULONG Type,
|
|||
VOID KeDumpStackFrames(ULONG DummyArg, ULONG NrFrames);
|
||||
ULONG KeAllocateGdtSelector(ULONG Desc[2]);
|
||||
VOID KeFreeGdtSelector(ULONG Entry);
|
||||
BOOLEAN KiTestAlert(PKTHREAD Thread, PCONTEXT UserContext);
|
||||
|
||||
/* INITIALIZATION FUNCTIONS *************************************************/
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ typedef struct
|
|||
ULONG SectionPageProtection;
|
||||
ULONG AllocateAttributes;
|
||||
PFILE_OBJECT FileObject;
|
||||
LIST_ENTRY ViewListHead;
|
||||
KSPIN_LOCK ViewListLock;
|
||||
} SECTION_OBJECT, *PSECTION_OBJECT;
|
||||
|
||||
typedef struct
|
||||
|
@ -44,12 +46,14 @@ typedef struct
|
|||
ULONG Attributes;
|
||||
LIST_ENTRY Entry;
|
||||
ULONG LockCount;
|
||||
PEPROCESS Process;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
SECTION_OBJECT* Section;
|
||||
ULONG ViewOffset;
|
||||
LIST_ENTRY ViewListEntry;
|
||||
} SectionData;
|
||||
} Data;
|
||||
} MEMORY_AREA, *PMEMORY_AREA;
|
||||
|
@ -102,5 +106,11 @@ NTSTATUS IoPageRead(PFILE_OBJECT FileObject,
|
|||
PIO_STATUS_BLOCK StatusBlock);
|
||||
VOID MmBuildMdlFromPages(PMDL Mdl);
|
||||
PVOID MmGetMdlPageAddress(PMDL Mdl, PVOID Offset);
|
||||
VOID MiShutdownMemoryManager(VOID);
|
||||
ULONG MmGetPhysicalAddressForProcess(PEPROCESS Process,
|
||||
PVOID Address);
|
||||
NTSTATUS MmUnmapViewOfSection(PEPROCESS Process,
|
||||
PMEMORY_AREA MemoryArea);
|
||||
PVOID MiTryToSharePageInSection(PSECTION_OBJECT Section, ULONG Offset);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,8 +36,11 @@ typedef struct _MODULE_OBJECT
|
|||
CSHORT ObjectType;
|
||||
CSHORT ObjectSize;
|
||||
PVOID Base;
|
||||
ULONG Length;
|
||||
unsigned int Flags;
|
||||
PVOID EntryPoint;
|
||||
LIST_ENTRY ListEntry;
|
||||
PWSTR Name;
|
||||
union
|
||||
{
|
||||
struct
|
||||
|
|
|
@ -11,6 +11,8 @@ extern POBJECT_TYPE PsThreadType;
|
|||
extern POBJECT_TYPE PsProcessType;
|
||||
extern PETHREAD CurrentThread;
|
||||
|
||||
VOID PiInitProcessManager(VOID);
|
||||
VOID PiShutdownProcessManager(VOID);
|
||||
VOID PsInitThreadManagment(VOID);
|
||||
VOID PsInitProcessManagment(VOID);
|
||||
VOID PsInitIdleThread(VOID);
|
||||
|
@ -20,6 +22,8 @@ VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus);
|
|||
VOID PsReleaseThread(PETHREAD Thread);
|
||||
VOID PsBeginThread(PKSTART_ROUTINE StartRoutine, PVOID StartContext);
|
||||
VOID PsBeginThreadWithContextInternal(VOID);
|
||||
VOID PiKillMostProcesses(VOID);
|
||||
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process, NTSTATUS ExitStatus);
|
||||
|
||||
#define THREAD_STATE_INVALID (0)
|
||||
#define THREAD_STATE_RUNNABLE (1)
|
||||
|
|
|
@ -3,7 +3,7 @@ mkdir -p $1/reactos/system32
|
|||
mkdir -p $1/reactos/system32/drivers
|
||||
mkdir -p $1/reactos/bin
|
||||
cp ntoskrnl/ntoskrnl.exe $1
|
||||
cp services/fs/vfat/vfatfsd.sys $1
|
||||
cp services/fs/vfat/vfatfs.sys $1
|
||||
cp services/dd/ide/ide.sys $1
|
||||
cp services/dd/keyboard/keyboard.sys $1/reactos/system32/drivers
|
||||
cp services/dd/blue/blue.sys $1/reactos/system32/drivers
|
||||
|
@ -19,3 +19,6 @@ cp apps/bench/bench-thread.exe $1/reactos/bin
|
|||
cp apps/cat/cat.exe $1/reactos/bin
|
||||
cp subsys/smss/smss.exe $1/reactos/system32
|
||||
cp subsys/win32k/win32k.sys $1/reactos/system32/drivers
|
||||
cp apps/apc/apc.exe $1/reactos/bin
|
||||
cp apps/shm/shmsrv.exe $1/reactos/bin
|
||||
cp apps/shm/shmclt.exe $1/reactos/bin
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: section.c,v 1.6 1999/11/17 21:20:15 ariadne Exp $
|
||||
/* $Id: section.c,v 1.7 1999/11/24 11:51:44 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -119,16 +119,12 @@ CreateFileMappingW (
|
|||
}
|
||||
|
||||
|
||||
LPVOID
|
||||
STDCALL
|
||||
MapViewOfFileEx (
|
||||
HANDLE hFileMappingObject,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwFileOffsetHigh,
|
||||
DWORD dwFileOffsetLow,
|
||||
DWORD dwNumberOfBytesToMap,
|
||||
LPVOID lpBaseAddress
|
||||
)
|
||||
LPVOID STDCALL MapViewOfFileEx(HANDLE hFileMappingObject,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwFileOffsetHigh,
|
||||
DWORD dwFileOffsetLow,
|
||||
DWORD dwNumberOfBytesToMap,
|
||||
LPVOID lpBaseAddress)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
LARGE_INTEGER SectionOffset;
|
||||
|
@ -139,17 +135,26 @@ MapViewOfFileEx (
|
|||
SectionOffset.u.LowPart = dwFileOffsetLow;
|
||||
SectionOffset.u.HighPart = dwFileOffsetHigh;
|
||||
|
||||
if ( ( dwDesiredAccess & FILE_MAP_WRITE ) == FILE_MAP_WRITE )
|
||||
if ( ( dwDesiredAccess & FILE_MAP_WRITE) == FILE_MAP_WRITE)
|
||||
Protect = PAGE_READWRITE;
|
||||
else if ( ( dwDesiredAccess & FILE_MAP_READ ) == FILE_MAP_READ )
|
||||
else if ((dwDesiredAccess & FILE_MAP_READ) == FILE_MAP_READ)
|
||||
Protect = PAGE_READONLY;
|
||||
else if ( ( dwDesiredAccess & FILE_MAP_ALL_ACCESS ) == FILE_MAP_ALL_ACCESS )
|
||||
else if ((dwDesiredAccess & FILE_MAP_ALL_ACCESS) == FILE_MAP_ALL_ACCESS)
|
||||
Protect = PAGE_READWRITE;
|
||||
else if ( ( dwDesiredAccess & FILE_MAP_COPY ) == FILE_MAP_COPY )
|
||||
else if ((dwDesiredAccess & FILE_MAP_COPY) == FILE_MAP_COPY)
|
||||
Protect = PAGE_WRITECOPY;
|
||||
else
|
||||
Protect = PAGE_READWRITE;
|
||||
|
||||
Protect = PAGE_READWRITE;
|
||||
|
||||
if (lpBaseAddress == NULL)
|
||||
{
|
||||
BaseAddress = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
BaseAddress = lpBaseAddress;
|
||||
}
|
||||
|
||||
Status = ZwMapViewOfSection(hFileMappingObject,
|
||||
NtCurrentProcess(),
|
||||
&BaseAddress,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.12 1999/10/13 22:35:55 ekohl Exp $
|
||||
/* $Id: create.c,v 1.13 1999/11/24 11:51:45 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -24,7 +24,7 @@
|
|||
#include <internal/teb.h>
|
||||
#include <ntdll/base.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#define NDEBUG
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
@ -526,4 +526,4 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
/* EOF */
|
||||
|
|
|
@ -13,81 +13,82 @@
|
|||
#include <wchar.h>
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
SetEvent(
|
||||
HANDLE hEvent
|
||||
)
|
||||
WINBOOL STDCALL SetEvent(HANDLE hEvent)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
ULONG Count;
|
||||
errCode = NtSetEvent(hEvent,&Count);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
NTSTATUS errCode;
|
||||
ULONG Count;
|
||||
|
||||
errCode = NtSetEvent(hEvent,&Count);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
ResetEvent(
|
||||
HANDLE hEvent
|
||||
)
|
||||
WINBOOL STDCALL ResetEvent(HANDLE hEvent)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
ULONG Count;
|
||||
errCode = NtResetEvent(hEvent, &Count);
|
||||
if ( !NT_SUCCESS(errCode) ) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
NTSTATUS errCode;
|
||||
ULONG Count;
|
||||
|
||||
errCode = NtResetEvent(hEvent, &Count);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
CreateEventW(
|
||||
LPSECURITY_ATTRIBUTES lpEventAttributes,
|
||||
WINBOOL bManualReset,
|
||||
WINBOOL bInitialState,
|
||||
LPCWSTR lpName
|
||||
)
|
||||
HANDLE STDCALL CreateEventW(LPSECURITY_ATTRIBUTES lpEventAttributes,
|
||||
WINBOOL bManualReset,
|
||||
WINBOOL bInitialState,
|
||||
LPCWSTR lpName)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
HANDLE hEvent;
|
||||
UNICODE_STRING EventNameString;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
NTSTATUS errCode;
|
||||
HANDLE hEvent;
|
||||
UNICODE_STRING EventNameString;
|
||||
POBJECT_ATTRIBUTES PtrObjectAttributes;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
|
||||
if (lpName != NULL)
|
||||
{
|
||||
PtrObjectAttributes = &ObjectAttributes;
|
||||
ObjectAttributes.Attributes = 0;
|
||||
if ( lpEventAttributes != NULL ) {
|
||||
ObjectAttributes.SecurityDescriptor = lpEventAttributes->lpSecurityDescriptor;
|
||||
if ( lpEventAttributes->bInheritHandle == TRUE )
|
||||
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||
|
||||
}
|
||||
|
||||
if (lpEventAttributes != NULL)
|
||||
{
|
||||
ObjectAttributes.SecurityDescriptor =
|
||||
lpEventAttributes->lpSecurityDescriptor;
|
||||
if ( lpEventAttributes->bInheritHandle == TRUE )
|
||||
ObjectAttributes.Attributes |= OBJ_INHERIT;
|
||||
}
|
||||
|
||||
if(lpName != NULL) {
|
||||
EventNameString.Buffer = (WCHAR *)lpName;
|
||||
EventNameString.Length = lstrlenW(lpName)*sizeof(WCHAR);
|
||||
EventNameString.MaximumLength = EventNameString.Length;
|
||||
ObjectAttributes.ObjectName = &EventNameString;
|
||||
}
|
||||
else
|
||||
ObjectAttributes.ObjectName = NULL;
|
||||
|
||||
EventNameString.Buffer = (WCHAR *)lpName;
|
||||
EventNameString.Length = lstrlenW(lpName)*sizeof(WCHAR);
|
||||
EventNameString.MaximumLength = EventNameString.Length;
|
||||
ObjectAttributes.ObjectName = &EventNameString;
|
||||
}
|
||||
else
|
||||
{
|
||||
PtrObjectAttributes = NULL;
|
||||
}
|
||||
|
||||
|
||||
errCode = NtCreateEvent(&hEvent,STANDARD_RIGHTS_ALL|EVENT_READ_ACCESS|EVENT_WRITE_ACCESS,&ObjectAttributes,bManualReset,bInitialState);
|
||||
if(!NT_SUCCESS(errCode)) {
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return hEvent;
|
||||
errCode = NtCreateEvent(&hEvent,
|
||||
STANDARD_RIGHTS_ALL|EVENT_READ_ACCESS|EVENT_WRITE_ACCESS,
|
||||
PtrObjectAttributes,
|
||||
bManualReset,
|
||||
bInitialState);
|
||||
if (!NT_SUCCESS(errCode))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(errCode));
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return hEvent;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,40 +15,35 @@
|
|||
|
||||
|
||||
|
||||
HANDLE CreateWaitableTimerW(
|
||||
LPSECURITY_ATTRIBUTES lpTimerAttributes,
|
||||
WINBOOL bManualReset,
|
||||
LPWSTR lpTimerName
|
||||
)
|
||||
HANDLE CreateWaitableTimerW(LPSECURITY_ATTRIBUTES lpTimerAttributes,
|
||||
WINBOOL bManualReset,
|
||||
LPWSTR lpTimerName)
|
||||
{
|
||||
NTSTATUS errCode;
|
||||
HANDLE TimerHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING UnicodeName;
|
||||
|
||||
NTSTATUS errCode;
|
||||
HANDLE TimerHandle;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
UNICODE_STRING UnicodeName;
|
||||
ULONG TimerType;
|
||||
|
||||
if (bManualReset)
|
||||
TimerType = 1;
|
||||
else
|
||||
TimerType = 2;
|
||||
|
||||
ULONG TimerType;
|
||||
|
||||
if ( bManualReset )
|
||||
TimerType = 1;
|
||||
else
|
||||
TimerType = 2;
|
||||
|
||||
RtlInitUnicodeString(&UnicodeName, lpTimerName);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
RtlInitUnicodeString(&UnicodeName, lpTimerName);
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&UnicodeName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
//TIMER_ALL_ACCESS
|
||||
errCode = NtCreateTimer(
|
||||
&TimerHandle,
|
||||
0,
|
||||
&ObjectAttributes,
|
||||
TimerType
|
||||
);
|
||||
//TIMER_ALL_ACCESS
|
||||
errCode = NtCreateTimer(&TimerHandle,
|
||||
0,
|
||||
&ObjectAttributes,
|
||||
TimerType);
|
||||
|
||||
return TimerHandle;
|
||||
return TimerHandle;
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,4 +159,4 @@ WINBOOL CancelWaitableTimer(HANDLE hTimer)
|
|||
}
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: startup.c,v 1.10 1999/09/29 23:12:49 ekohl Exp $
|
||||
/* $Id: startup.c,v 1.11 1999/11/24 11:51:45 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -21,6 +21,7 @@
|
|||
#include <ntdll/ldr.h>
|
||||
#include <ntdll/rtl.h>
|
||||
|
||||
#undef DBG_NTDLL_LDR_STARTUP
|
||||
#ifndef DBG_NTDLL_LDR_STARTUP
|
||||
#define NDEBUG
|
||||
#endif
|
||||
|
@ -110,7 +111,7 @@ VOID LdrStartup(HANDLE SectionHandle,
|
|||
PEDosHeader->e_lfanew == 0L ||
|
||||
*(PULONG)((PUCHAR)ImageBase + PEDosHeader->e_lfanew) != IMAGE_PE_MAGIC)
|
||||
{
|
||||
DPRINT("Image has bad header\n");
|
||||
dprintf("Image has bad header\n");
|
||||
ZwTerminateProcess(NULL,STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
|
@ -129,7 +130,7 @@ VOID LdrStartup(HANDLE SectionHandle,
|
|||
ZwTerminateProcess(NtCurrentProcess(),STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
dprintf("Transferring control to image at %x\n",EntryPoint);
|
||||
// dprintf("Transferring control to image at %x\n",EntryPoint);
|
||||
Status = EntryPoint();
|
||||
ZwTerminateProcess(NtCurrentProcess(),Status);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: utils.c,v 1.15 1999/11/17 21:32:57 ariadne Exp $
|
||||
/* $Id: utils.c,v 1.16 1999/11/24 11:51:45 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -145,7 +145,8 @@ LdrLoadDll (
|
|||
);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Dll open failed: Status = 0x%08x\n", Status);
|
||||
dprintf("Dll open of %s failed: Status = 0x%08x\n",
|
||||
fqname, Status);
|
||||
return Status;
|
||||
}
|
||||
Status = ZwReadFile(
|
||||
|
@ -356,7 +357,7 @@ LdrFindDll (
|
|||
|
||||
} while (current != & LdrDllListHead);
|
||||
|
||||
dprintf("Failed to find dll %s\n",Name);
|
||||
DPRINT("Failed to find dll %s\n",Name);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
@ -905,7 +906,7 @@ LdrPEStartup (
|
|||
ImageBase
|
||||
+ NTHeaders->OptionalHeader.AddressOfEntryPoint
|
||||
);
|
||||
dprintf("LdrPEStartup() = %x\n",EntryPoint);
|
||||
DPRINT("LdrPEStartup() = %x\n",EntryPoint);
|
||||
return EntryPoint;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,546 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/cc/block.c
|
||||
* PURPOSE: Cache manager
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* Created 22/05/98
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <ddk/ntifs.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
static ULONG CbHash(PDCCB Dccb, ULONG BlockNr)
|
||||
{
|
||||
DPRINT("CbHash(Dccb %x, BlockNr %d\n",Dccb,BlockNr);
|
||||
DPRINT("CbHash() = %d\n",BlockNr % Dccb->HashTblSize);
|
||||
return(BlockNr % Dccb->HashTblSize);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VOID CbDereferenceCcb(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
KeAcquireSpinLock(&Dccb->HashTblLock,&oldlvl);
|
||||
Ccb->References--;
|
||||
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
||||
}
|
||||
#endif
|
||||
|
||||
static PCCB CbGetCcbFromHashTable(PDCCB Dccb, ULONG BlockNr)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PCCB Ccb;
|
||||
|
||||
KeAcquireSpinLock(&Dccb->HashTblLock,&oldlvl);
|
||||
Ccb = Dccb->HashTbl[CbHash(Dccb,BlockNr)];
|
||||
if (Ccb!=NULL)
|
||||
{
|
||||
Ccb->References++;
|
||||
}
|
||||
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
||||
return(Ccb);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static BOOLEAN CbRemoveCcbFromHashTable(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
BOOLEAN Status;
|
||||
|
||||
KeAcquireSpinLock(&Dccb->HashTblLock,&oldlvl);
|
||||
if (Ccb->References == 0)
|
||||
{
|
||||
Dccb->HashTbl[CbHash(Dccb,Ccb->BlockNr)]=NULL;
|
||||
Status = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = FALSE;
|
||||
}
|
||||
KeReleaseSpinLock(&Dccb->HashTblLock,oldlvl);
|
||||
return(Status);
|
||||
}
|
||||
#endif
|
||||
|
||||
static BOOLEAN CbLockForWrite(PCCB Ccb)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
KeAcquireSpinLock(&Ccb->Lock,&oldlvl);
|
||||
if (Ccb->ActiveWriter || Ccb->ActiveReaders > 0)
|
||||
{
|
||||
KeReleaseSpinLock(&Ccb->Lock,oldlvl);
|
||||
return(FALSE);
|
||||
}
|
||||
Ccb->ActiveWriter = TRUE;
|
||||
KeReleaseSpinLock(&Ccb->Lock,oldlvl);
|
||||
return(TRUE);
|
||||
|
||||
}
|
||||
|
||||
static BOOLEAN CbLockForRead(PCCB Ccb)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
KeAcquireSpinLock(&Ccb->Lock,&oldlvl);
|
||||
if (Ccb->ActiveWriter)
|
||||
{
|
||||
KeReleaseSpinLock(&Ccb->Lock,oldlvl);
|
||||
return(FALSE);
|
||||
}
|
||||
Ccb->ActiveReaders++;
|
||||
Ccb->References++;
|
||||
KeReleaseSpinLock(&Ccb->Lock,oldlvl);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
static BOOLEAN CbLockForDelete(PDCCB Dccb, PCCB Ccb)
|
||||
/*
|
||||
* FUNCTION: Attempts to lock a ccb for delete
|
||||
* ARGUMENTS:
|
||||
* Ccb = CCB to lock
|
||||
* RETURNS: True if the lock succeeded
|
||||
* False otherwise
|
||||
* NOTE: This routine always defers to anyone waiting for a another type of
|
||||
* lock
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
KeAcquireSpinLock(&Ccb->Lock,&oldlvl);
|
||||
if (Ccb->ActiveWriter || Ccb->WriteInProgress || Ccb->ActiveReaders
|
||||
|| Ccb->References > 0)
|
||||
{
|
||||
KeReleaseSpinLock(&Ccb->Lock,oldlvl);
|
||||
return(FALSE);
|
||||
}
|
||||
Ccb->ActiveWriter = TRUE;
|
||||
KeReleaseSpinLock(&Ccb->Lock,oldlvl);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VOID CbUnlockForDelete(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
Ccb->ActiveWriter = FALSE;
|
||||
KeSetEvent(&Ccb->FinishedNotify,IO_NO_INCREMENT,FALSE);
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID CbAcquireForDelete(PDCCB Dccb, PCCB Ccb)
|
||||
/*
|
||||
* FUNCTION: Acquire the ccb for deletion
|
||||
* ARGUMENTS:
|
||||
* Dccb = DCCB for the target device
|
||||
* Ccb = Ccb to acquire
|
||||
*/
|
||||
{
|
||||
while (!CbLockForDelete(Dccb,Ccb))
|
||||
{
|
||||
KeWaitForSingleObject(&Ccb->FinishedNotify,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static NTSTATUS CbReadBlock(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
PIRP Irp;
|
||||
LARGE_INTEGER Offset;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
NTSTATUS Status;
|
||||
KEVENT Event;
|
||||
|
||||
DPRINT("CbReadBlock(Dccb %x, Ccb %x)\n",Dccb,Ccb);
|
||||
|
||||
if (Ccb->Buffer==NULL)
|
||||
{
|
||||
Ccb->Buffer=ExAllocatePool(NonPagedPool,Dccb->SectorSize);
|
||||
}
|
||||
|
||||
Offset.u.LowPart = Ccb->BlockNr * Dccb->SectorSize;
|
||||
Offset.u.HighPart = 0;
|
||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
||||
Dccb->DeviceObject,
|
||||
Ccb->Buffer,
|
||||
Dccb->SectorSize,
|
||||
&Offset,
|
||||
&Event,
|
||||
&IoStatusBlock);
|
||||
Status = IoCallDriver(Dccb->DeviceObject, Irp);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(&Event,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
Status = IoStatusBlock.Status;
|
||||
}
|
||||
Ccb->Modified=FALSE;
|
||||
Ccb->State = CCB_CACHED;
|
||||
return(Status);
|
||||
}
|
||||
|
||||
static NTSTATUS CbWriteBlock(PDCCB Dccb, PCCB Ccb)
|
||||
/*
|
||||
* FUNCTION: Writes the block mapped by a CCB back to disk
|
||||
* ARGUMENTS:
|
||||
* Dccb = DCCB for the device the CCB maps
|
||||
* Ccb = CCB to write
|
||||
* RETURNS: Status
|
||||
* NOTE: It is the caller responsibility to acquire the appropiate locks
|
||||
*/
|
||||
{
|
||||
PIRP Irp;
|
||||
LARGE_INTEGER Offset;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
NTSTATUS Status;
|
||||
KEVENT Event;
|
||||
|
||||
Offset.u.LowPart = Ccb->BlockNr * Dccb->SectorSize;
|
||||
Offset.u.HighPart = 0;
|
||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
|
||||
Dccb->DeviceObject,
|
||||
Ccb->Buffer,
|
||||
Dccb->SectorSize,
|
||||
&Offset,
|
||||
&Event,
|
||||
&IoStatusBlock);
|
||||
Status = IoCallDriver(Dccb->DeviceObject, Irp);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(&Event,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
Status = IoStatusBlock.Status;
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
PCCB CbFindModifiedCcb(PDCCB Dccb, PCCB Start)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static VOID CbDeleteAllCcbs(PDCCB Dccb)
|
||||
/*
|
||||
* FUNCTION: Delete all the ccbs associated with a dccb
|
||||
* ARGUMENTS:
|
||||
* Dccb = DCCB to delete
|
||||
* NOTE: There must be no other cache activity during this call
|
||||
*/
|
||||
{
|
||||
PCCB Ccb;
|
||||
|
||||
ExFreePool(Dccb->HashTbl);
|
||||
|
||||
while (Dccb->CcbListHead.Flink != &Dccb->CcbListHead)
|
||||
{
|
||||
Ccb = CONTAINING_RECORD(Dccb->CcbListHead.Flink,CCB,Entry);
|
||||
if (Ccb->Modified)
|
||||
{
|
||||
CbWriteBlock(Dccb,Ccb);
|
||||
}
|
||||
if (Ccb->Buffer != NULL)
|
||||
{
|
||||
ExFreePool(Ccb->Buffer);
|
||||
}
|
||||
Dccb->CcbListHead.Flink = Dccb->CcbListHead.Flink->Flink;
|
||||
ExFreePool(Ccb);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static VOID CbFreeCcb(PDCCB Dccb, PCCB Ccb)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
if (Ccb->Buffer != NULL && Ccb->Modified)
|
||||
{
|
||||
CbWriteBlock(Dccb,Ccb);
|
||||
}
|
||||
if (Ccb->Buffer != NULL)
|
||||
{
|
||||
ExFreePool(Ccb->Buffer);
|
||||
}
|
||||
KeAcquireSpinLock(&Dccb->CcbListLock,&oldlvl);
|
||||
RemoveEntryList(&Ccb->Entry);
|
||||
KeReleaseSpinLock(&Dccb->CcbListLock,oldlvl);
|
||||
ExFreePool(Ccb);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static VOID CbReclaimMemory(PDCCB Dccb)
|
||||
{
|
||||
PCCB RedundantCcbs[25];
|
||||
ULONG NrRedundantCcbs;
|
||||
PCCB Ccb;
|
||||
PLIST_ENTRY CurrentEntry;
|
||||
KIRQL oldlvl;
|
||||
ULONG i;
|
||||
|
||||
NrRedundantCcbs=0;
|
||||
|
||||
KeAcquireSpinLock(&Dccb->CcbListLock,&oldlvl);
|
||||
CurrentEntry = Dccb->CcbListHead.Flink;
|
||||
while (CurrentEntry != &Dccb->CcbListHead &&
|
||||
NrRedundantCcbs < 25)
|
||||
{
|
||||
Ccb = CONTAINING_RECORD(CurrentEntry,CCB,Entry);
|
||||
if (CbLockForDelete(Dccb,Ccb))
|
||||
{
|
||||
if (CbRemoveCcbFromHashTable(Dccb,Ccb))
|
||||
{
|
||||
if (Ccb->Modified)
|
||||
{
|
||||
CbWriteBlock(Dccb,Ccb);
|
||||
}
|
||||
Ccb->State = CCB_DELETE_PENDING;
|
||||
RedundantCcbs[NrRedundantCcbs]=Ccb;
|
||||
NrRedundantCcbs++;
|
||||
}
|
||||
else
|
||||
{
|
||||
CbUnlockForDelete(Dccb,Ccb);
|
||||
}
|
||||
}
|
||||
CurrentEntry = CurrentEntry->Flink;
|
||||
}
|
||||
KeReleaseSpinLock(&Dccb->CcbListLock,oldlvl);
|
||||
|
||||
for (i=0;i<NrRedundantCcbs;i++)
|
||||
{
|
||||
CbFreeCcb(Dccb,RedundantCcbs[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static VOID CbDeleteCcb(PDCCB Dccb, PCCB Ccb)
|
||||
/*
|
||||
* FUNCTION: Deletes a CCB
|
||||
* ARGUMENTS:
|
||||
* Dccb = DCCB for the target device
|
||||
* Ccb = CCB to delete
|
||||
* NOTE: This function is implemented so that other ccb requests override
|
||||
* a deletion. Filesystems that delete CCBs during normal operation should be
|
||||
* aware of the possibility of starvation.
|
||||
*/
|
||||
{
|
||||
CbAcquireForDelete(Dccb,Ccb);
|
||||
Ccb->State = CCB_DELETE_PENDING;
|
||||
}
|
||||
#endif
|
||||
|
||||
VOID CbReinitCcb(PDCCB Dccb, PCCB Ccb, ULONG BlockNr)
|
||||
{
|
||||
DPRINT("CbReinitCcb(Dccb %x, Ccb %x, BlockNr %d\n",Dccb,Ccb,BlockNr);
|
||||
|
||||
Ccb->BlockNr = BlockNr;
|
||||
Ccb->State = CCB_NOT_CACHED;
|
||||
Ccb->Buffer = NULL;
|
||||
Ccb->ActiveReaders = 0;
|
||||
Ccb->ActiveWriter = FALSE;
|
||||
KeInitializeEvent(&Ccb->FinishedNotify,SynchronizationEvent,FALSE);
|
||||
Ccb->Modified=FALSE;
|
||||
}
|
||||
|
||||
VOID CbInitCcb(PDCCB Dccb, PCCB Ccb, ULONG BlockNr)
|
||||
/*
|
||||
* FUNCTION: Initializes a ccb and adds it to the dccb hash table
|
||||
* ARGUMENTS:
|
||||
* Dccb = Device cache to initialize the ccb for
|
||||
* Ccb = Caller allocated CCB
|
||||
* BlockNr = Block that the ccb will map
|
||||
*/
|
||||
{
|
||||
DPRINT("CbInitCcb(Dccb %x, Ccb %x, BlockNr %d)\n",Dccb,Ccb,BlockNr);
|
||||
|
||||
CbReinitCcb(Dccb,Ccb,BlockNr);
|
||||
Dccb->HashTbl[CbHash(Dccb,BlockNr)] = Ccb;
|
||||
ExInterlockedInsertTailList(&Dccb->CcbListHead,&Ccb->Entry,
|
||||
&Dccb->CcbListLock);
|
||||
}
|
||||
|
||||
VOID CbInitDccb(PDCCB Dccb, PDEVICE_OBJECT DeviceObject, ULONG SectorSize,
|
||||
ULONG NrSectors, ULONG PercentageToCache)
|
||||
/*
|
||||
* FUNCTION: Initializes a dccb for a device
|
||||
* ARGUMENTS:
|
||||
* Dccb = Caller allocated DCCB
|
||||
* DeviceObject = Device associated with the DCCB
|
||||
* SectorSize = Sector size of the device
|
||||
* NrSectors = Number of sectors on the device
|
||||
* PercentageToCache = Maximum percentage of the device that will
|
||||
* be in the cache at any one time
|
||||
* NOTE: The PercentageToCache parameter only effects the size of the DCCB
|
||||
* hash table not the amount of physical memory used to cache actual sectors
|
||||
*/
|
||||
{
|
||||
DPRINT("CbInitDccb(Dccb %x, DeviceObject %x, SectorSize %d, "
|
||||
"NrSectors %d, PercentageToCache %d)\n",Dccb,DeviceObject,
|
||||
SectorSize,NrSectors,PercentageToCache);
|
||||
|
||||
Dccb->HashTblSize = (NrSectors / 100) * PercentageToCache;
|
||||
Dccb->HashTbl = ExAllocatePool(NonPagedPool,sizeof(PCCB)*
|
||||
Dccb->HashTblSize);
|
||||
Dccb->DeviceObject = DeviceObject;
|
||||
Dccb->SectorSize = SectorSize;
|
||||
Dccb->NrCcbs = 0;
|
||||
Dccb->NrModifiedCcbs = 0;
|
||||
InitializeListHead(&Dccb->CcbListHead);
|
||||
KeInitializeSpinLock(&Dccb->CcbListLock);
|
||||
}
|
||||
|
||||
|
||||
VOID CbReleaseFromRead(PDCCB Dccb, PCCB Ccb)
|
||||
/*
|
||||
* FUNCTION: Releases a CCB that the caller had acquired for reading
|
||||
* ARGUMENTS:
|
||||
* Dccb = DCCB for the device the CCB maps a block on
|
||||
* Ccb = CCB to release
|
||||
*/
|
||||
{
|
||||
DPRINT("CbReleaseFromRead(Dccb %x, Ccb %x)\n",Dccb,Ccb);
|
||||
|
||||
Ccb->ActiveReaders--;
|
||||
if (Ccb->ActiveReaders==0)
|
||||
{
|
||||
KeSetEvent(&Ccb->FinishedNotify,IO_NO_INCREMENT,FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
VOID CbReleaseFromWrite(PDCCB Dccb, PCCB Ccb, BOOLEAN Modified,
|
||||
BOOLEAN WriteThrough)
|
||||
/*
|
||||
* FUNCTION: Release a ccb acquired for writing
|
||||
* ARGUMENTS:
|
||||
* Dccb = DCCB for the CCB
|
||||
* Ccb = CCB to release
|
||||
* Modified = True if the caller modified the block while it was locked
|
||||
* WriteThrough = True if the block should be written back to disk
|
||||
*/
|
||||
{
|
||||
DPRINT("CbReleaseFromWrite(Dccb %x, Ccb %x, Modified %d, "
|
||||
"WriteThrough %d)\n",Dccb,Ccb,Modified,WriteThrough);
|
||||
|
||||
if (Modified)
|
||||
{
|
||||
Ccb->Modified=TRUE;
|
||||
}
|
||||
if (WriteThrough)
|
||||
{
|
||||
CbWriteBlock(Dccb,Ccb);
|
||||
}
|
||||
|
||||
Ccb->ActiveWriter=FALSE;
|
||||
KeSetEvent(&Ccb->FinishedNotify,IO_NO_INCREMENT,FALSE);
|
||||
}
|
||||
|
||||
static PCCB CbCheckCcb(PDCCB Dccb, ULONG BlockNr)
|
||||
/*
|
||||
* FUNCTION: Return a CCB that maps a block
|
||||
* ARGUMENTS:
|
||||
* Dccb = DCCB for the device the block is on
|
||||
* BlockNr = Block to map
|
||||
* RETURNS: The CCB
|
||||
* NOTE: The caller must lock the returned ccb
|
||||
*/
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PCCB Ccb;
|
||||
|
||||
DPRINT("CbCheckCcb(Dccb %x, BlockNr %d)\n",Dccb,BlockNr);
|
||||
|
||||
KeAcquireSpinLock(&Dccb->CcbListLock,&oldlvl);
|
||||
Ccb = CbGetCcbFromHashTable(Dccb,BlockNr);
|
||||
if (Ccb == NULL)
|
||||
{
|
||||
Ccb = ExAllocatePool(NonPagedPool,sizeof(CCB));
|
||||
CbInitCcb(Dccb,Ccb,BlockNr);
|
||||
}
|
||||
KeReleaseSpinLock(&Dccb->CcbListLock,oldlvl);
|
||||
if (Ccb->BlockNr != BlockNr)
|
||||
{
|
||||
CbAcquireForDelete(Dccb,Ccb);
|
||||
if (Ccb->Modified)
|
||||
{
|
||||
CbWriteBlock(Dccb,Ccb);
|
||||
}
|
||||
CbReinitCcb(Dccb,Ccb,BlockNr);
|
||||
}
|
||||
return(Ccb);
|
||||
}
|
||||
|
||||
PCCB CbAcquireForWrite(PDCCB Dccb, ULONG BlockNr)
|
||||
{
|
||||
PCCB Ccb;
|
||||
|
||||
DPRINT("CbAcquireForWrite(Dccb %x, BlockNr %d)\n",Dccb,BlockNr);
|
||||
|
||||
Ccb = CbCheckCcb(Dccb,BlockNr);
|
||||
while (!CbLockForWrite(Ccb))
|
||||
{
|
||||
KeWaitForSingleObject(&Ccb->FinishedNotify,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
}
|
||||
if (Ccb->State != CCB_CACHED)
|
||||
{
|
||||
CbReadBlock(Dccb,Ccb);
|
||||
}
|
||||
return(Ccb);
|
||||
}
|
||||
|
||||
PCCB CbAcquireForRead(PDCCB Dccb, ULONG BlockNr)
|
||||
/*
|
||||
* FUNCTION: Acquires a ccb for reading
|
||||
* ARGUMENTS:
|
||||
* Dccb = DCCB for the device
|
||||
* BlockNr = Block the CCB should map
|
||||
* RETURNS: The acquired CCB
|
||||
*/
|
||||
{
|
||||
PCCB Ccb;
|
||||
|
||||
DPRINT("CbAcquireForRead(Dccb %x, BlockNr %d)\n",Dccb,BlockNr);
|
||||
|
||||
Ccb = CbCheckCcb(Dccb,BlockNr);
|
||||
while (!CbLockForRead(Ccb))
|
||||
{
|
||||
KeWaitForSingleObject(&Ccb->FinishedNotify,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if (Ccb->State != CCB_CACHED)
|
||||
{
|
||||
CbReadBlock(Dccb,Ccb);
|
||||
}
|
||||
return(Ccb);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: registry.c,v 1.20 1999/10/26 04:52:38 rex Exp $
|
||||
/* $Id: registry.c,v 1.21 1999/11/24 11:51:46 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -18,7 +18,7 @@
|
|||
//#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* #define PROTO_REG 1 /* Comment out to disable */
|
||||
// #define PROTO_REG 1 /* Comment out to disable */
|
||||
|
||||
/* ----------------------------------------------------- Typedefs */
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/hal/io.h>
|
||||
#include <internal/ps.h>
|
||||
#include <internal/io.h>
|
||||
#include <internal/mm.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
@ -24,40 +27,32 @@ NTSTATUS STDCALL NtSetSystemPowerState(VOID)
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtShutdownSystem (
|
||||
IN SHUTDOWN_ACTION Action
|
||||
)
|
||||
NTSTATUS STDCALL NtShutdownSystem(IN SHUTDOWN_ACTION Action)
|
||||
{
|
||||
if (Action > ShutdownPowerOff)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* FIXME: notify all registered drivers (MJ_SHUTDOWN) */
|
||||
|
||||
/* FIXME: notify configuration manager (Registry) */
|
||||
|
||||
/* FIXME: notify memory manager */
|
||||
|
||||
/* FIXME: notify all file system drivers (MJ_SHUTDOWN) */
|
||||
|
||||
if (Action == ShutdownNoReboot)
|
||||
{
|
||||
if (Action > ShutdownPowerOff)
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
PiShutdownProcessManager();
|
||||
MiShutdownMemoryManager();
|
||||
IoShutdownIoManager();
|
||||
|
||||
if (Action == ShutdownNoReboot)
|
||||
{
|
||||
#if 0
|
||||
/* Switch off */
|
||||
HalReturnToFirmware (FIRMWARE_OFF);
|
||||
#endif
|
||||
}
|
||||
else if (Action == ShutdownReboot)
|
||||
{
|
||||
}
|
||||
else if (Action == ShutdownReboot)
|
||||
{
|
||||
HalReturnToFirmware (FIRMWARE_REBOOT);
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
HalReturnToFirmware (FIRMWARE_HALT);
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -45,7 +45,7 @@ NtSetSystemTime (
|
|||
IN PLARGE_INTEGER NewSystemTime OPTIONAL
|
||||
)
|
||||
{
|
||||
HalSetRealTimeClock ((PTIME)SystemTime);
|
||||
// HalSetRealTimeClock ((PTIME)SystemTime);
|
||||
// UNIMPLEMENTED;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,396 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/hal/x86/exp.c
|
||||
* PURPOSE: Handling exceptions
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
* REVISION HISTORY:
|
||||
* ??/??/??: Created
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/symbol.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/mmhal.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
asmlinkage int page_fault_handler(unsigned int cs,
|
||||
unsigned int eip);
|
||||
|
||||
static exception_hook* exception_hooks[256]={NULL,};
|
||||
|
||||
#define _STR(x) #x
|
||||
#define STR(x) _STR(x)
|
||||
|
||||
extern void interrupt_handler2e(void);
|
||||
|
||||
extern ULONG init_stack;
|
||||
extern ULONG init_stack_top;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
#define EXCEPTION_HANDLER_WITH_ERROR(x,y) \
|
||||
void exception_handler##y (void); \
|
||||
void tmp_exception_handler##y (void) { \
|
||||
__asm__("\n\t_exception_handler"##x":\n\t" \
|
||||
"pushl %gs\n\t" \
|
||||
"pushl %fs\n\t" \
|
||||
"pushl %es\n\t" \
|
||||
"pushl %ds\n\t" \
|
||||
"pushl $"##x"\n\t" \
|
||||
"pusha\n\t" \
|
||||
"movw $"STR(KERNEL_DS)",%ax\n\t" \
|
||||
"movw %ax,%ds\n\t" \
|
||||
"movw %ax,%es\n\t" \
|
||||
"movw %ax,%fs\n\t" \
|
||||
"movw %ax,%gs\n\t" \
|
||||
"call _exception_handler\n\t" \
|
||||
"popa\n\t" \
|
||||
"addl $4,%esp\n\t" \
|
||||
"popl %ds\n\t" \
|
||||
"popl %es\n\t" \
|
||||
"popl %fs\n\t" \
|
||||
"popl %gs\n\t" \
|
||||
"addl $4,%esp\n\t" \
|
||||
"iret\n\t"); }
|
||||
|
||||
#define EXCEPTION_HANDLER_WITHOUT_ERROR(x,y) \
|
||||
asmlinkage void exception_handler##y (void); \
|
||||
void tmp_exception_handler##y (void) { \
|
||||
__asm__("\n\t_exception_handler"##x":\n\t" \
|
||||
"pushl $0\n\t" \
|
||||
"pushl %gs\n\t" \
|
||||
"pushl %fs\n\t" \
|
||||
"pushl %es\n\t" \
|
||||
"pushl %ds\n\t" \
|
||||
"pushl $"##x"\n\t" \
|
||||
"pusha\n\t" \
|
||||
"movw $"STR(KERNEL_DS)",%ax\n\t" \
|
||||
"movw %ax,%ds\n\t" \
|
||||
"movw %ax,%es\n\t" \
|
||||
"movw %ax,%fs\n\t" \
|
||||
"movw %ax,%gs\n\t" \
|
||||
"call _exception_handler\n\t" \
|
||||
"popa\n\t" \
|
||||
"addl $4,%esp\n\t" \
|
||||
"popl %ds\n\t" \
|
||||
"popl %es\n\t" \
|
||||
"popl %fs\n\t" \
|
||||
"popl %gs\n\t" \
|
||||
"addl $4,%esp\n\t" \
|
||||
"iret\n\t"); }
|
||||
|
||||
asmlinkage void exception_handler_unknown(void);
|
||||
asmlinkage void tmp_exception_handler_unknown(void)
|
||||
{
|
||||
__asm__("\n\t_exception_handler_unknown:\n\t"
|
||||
"pushl $0\n\t"
|
||||
"pushl %gs\n\t"
|
||||
"pushl %fs\n\t"
|
||||
"pushl %es\n\t"
|
||||
"pushl %ds\n\t"
|
||||
"pushl %ds\n\t"
|
||||
"pushl $0xff\n\t"
|
||||
"pusha\n\t"
|
||||
"movw $"STR(KERNEL_DS)",%ax\n\t"
|
||||
"movw %ax,%ds\n\t"
|
||||
"movw %ax,%es\n\t"
|
||||
"movw %ax,%fs\n\t"
|
||||
"movw %ax,%gs\n\t"
|
||||
"call _exception_handler\n\t"
|
||||
"popa\n\t"
|
||||
"addl $8,%esp\n\t"
|
||||
"iret\n\t");
|
||||
}
|
||||
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("0",0);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("1",1);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("2",2);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("3",3);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("4",4);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("5",5);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("6",6);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("7",7);
|
||||
EXCEPTION_HANDLER_WITH_ERROR("8",8);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("9",9);
|
||||
EXCEPTION_HANDLER_WITH_ERROR("10",10);
|
||||
EXCEPTION_HANDLER_WITH_ERROR("11",11);
|
||||
EXCEPTION_HANDLER_WITH_ERROR("12",12);
|
||||
EXCEPTION_HANDLER_WITH_ERROR("13",13);
|
||||
EXCEPTION_HANDLER_WITH_ERROR("14",14);
|
||||
EXCEPTION_HANDLER_WITH_ERROR("15",15);
|
||||
EXCEPTION_HANDLER_WITHOUT_ERROR("16",16);
|
||||
|
||||
extern unsigned int stext, etext;
|
||||
|
||||
asmlinkage void exception_handler(unsigned int edi,
|
||||
unsigned int esi, unsigned int ebp,
|
||||
unsigned int esp, unsigned int ebx,
|
||||
unsigned int edx, unsigned int ecx,
|
||||
unsigned int eax,
|
||||
unsigned int type,
|
||||
unsigned int ds,
|
||||
unsigned int es,
|
||||
unsigned int fs,
|
||||
unsigned int gs,
|
||||
unsigned int error_code,
|
||||
unsigned int eip,
|
||||
unsigned int cs, unsigned int eflags,
|
||||
unsigned int esp0, unsigned int ss0)
|
||||
/*
|
||||
* FUNCTION: Called by the lowlevel execption handlers to print an amusing
|
||||
* message and halt the computer
|
||||
* ARGUMENTS:
|
||||
* Complete CPU context
|
||||
*/
|
||||
{
|
||||
unsigned int cr2, cr3;
|
||||
unsigned int i, j, sym;
|
||||
unsigned int* stack;
|
||||
static char *TypeStrings[] =
|
||||
{
|
||||
"Divide Error",
|
||||
"Debug Trap",
|
||||
"Unknown(2)",
|
||||
"Breakpoint",
|
||||
"Overflow",
|
||||
"BOUND range exceeded",
|
||||
"Invalid Opcode",
|
||||
"No Math Coprocessor",
|
||||
"Double Fault",
|
||||
"Unknown(9)",
|
||||
"Invalid TSS",
|
||||
"Segment Not Present",
|
||||
"Stack Segment Fault",
|
||||
"General Protection",
|
||||
"Page Fault",
|
||||
"Math Fault",
|
||||
"Alignment Check",
|
||||
"Machine Check"
|
||||
};
|
||||
|
||||
__asm__("cli\n\t");
|
||||
|
||||
if (type==14)
|
||||
{
|
||||
if (page_fault_handler(cs&0xffff,eip))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (type==1)
|
||||
{
|
||||
DbgPrint("Trap at CS:EIP %x:%x\n",cs&0xffff,eip);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Activate any hook for the exception
|
||||
*/
|
||||
if (exception_hooks[type]!=NULL)
|
||||
{
|
||||
exception_hooks[type](NULL,type);
|
||||
}
|
||||
|
||||
/*
|
||||
* Print out the CPU registers
|
||||
*/
|
||||
if (type < 19)
|
||||
{
|
||||
DbgPrint("%s Exception: %d(%x)\n",TypeStrings[type],type,
|
||||
error_code&0xffff);
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint("Exception: %d(%x)\n",type,error_code&0xffff);
|
||||
}
|
||||
DbgPrint("CS:EIP %x:%x\n",cs&0xffff,eip);
|
||||
__asm__("movl %%cr2,%0\n\t"
|
||||
: "=d" (cr2));
|
||||
__asm__("movl %%cr3,%0\n\t"
|
||||
: "=d" (cr3));
|
||||
DbgPrint("cr2 %x cr3 %x\n",cr2,cr3);
|
||||
// for(;;);
|
||||
DbgPrint("Process: %x\n",PsGetCurrentProcess());
|
||||
if (PsGetCurrentProcess() != NULL)
|
||||
{
|
||||
DbgPrint("Process id: %x\n", PsGetCurrentProcess()->UniqueProcessId);
|
||||
}
|
||||
if (PsGetCurrentThread() != NULL)
|
||||
{
|
||||
DbgPrint("Thread: %x Thread id: %x\n",
|
||||
PsGetCurrentThread(),
|
||||
PsGetCurrentThread()->Cid.UniqueThread);
|
||||
}
|
||||
DbgPrint("DS %x ES %x FS %x GS %x\n",ds&0xffff,es&0xffff,fs&0xffff,
|
||||
gs&0xfff);
|
||||
DbgPrint("EAX: %.8x EBX: %.8x ECX: %.8x\n",eax,ebx,ecx);
|
||||
DbgPrint("EDX: %.8x EBP: %.8x ESI: %.8x\n",edx,ebp,esi);
|
||||
DbgPrint("EDI: %.8x EFLAGS: %.8x ",edi,eflags);
|
||||
if ((cs&0xffff) == KERNEL_CS)
|
||||
{
|
||||
DbgPrint("kESP %.8x\n",esp);
|
||||
if (PsGetCurrentThread() != NULL)
|
||||
{
|
||||
DbgPrint("kernel stack base %x\n",
|
||||
PsGetCurrentThread()->Tcb.Context.KernelStackBase);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint("kernel ESP %.8x\n",esp);
|
||||
}
|
||||
for(;;);
|
||||
if ((cs & 0xffff) == KERNEL_CS)
|
||||
{
|
||||
DbgPrint("ESP %x\n",esp);
|
||||
stack = (unsigned int *) (esp + 24);
|
||||
|
||||
DbgPrint("Stack:\n");
|
||||
for (i = 0; i < 16; i = i + 4)
|
||||
{
|
||||
DbgPrint("%.8x %.8x %.8x %.8x\n",
|
||||
stack[i],
|
||||
stack[i+1],
|
||||
stack[i+2],
|
||||
stack[i+3]);
|
||||
}
|
||||
DbgPrint("Frames:\n");
|
||||
for (i = 0; i < 32; i++)
|
||||
{
|
||||
if (stack[i] > ((unsigned int) &stext) &&
|
||||
!(stack[i] >= ((ULONG)&init_stack) &&
|
||||
stack[i] <= ((ULONG)&init_stack_top)))
|
||||
{
|
||||
DbgPrint(" %.8x",
|
||||
stack[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DbgPrint("SS:ESP %x:%x\n",ss0,esp0);
|
||||
stack=(unsigned int *)(esp0);
|
||||
|
||||
DbgPrint("Stack:\n");
|
||||
for (i=0; i<16; i++)
|
||||
{
|
||||
if (MmIsPagePresent(NULL,&stack[i]))
|
||||
{
|
||||
DbgPrint("%.8x ",stack[i]);
|
||||
if (((i+1)%4) == 0)
|
||||
{
|
||||
DbgPrint("\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DPRINT1("Killing current task\n");
|
||||
for(;;);
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
if ((cs&0xffff) == USER_CS)
|
||||
{
|
||||
ZwTerminateProcess(NtCurrentProcess(),
|
||||
STATUS_NONCONTINUABLE_EXCEPTION);
|
||||
}
|
||||
|
||||
for(;;);
|
||||
}
|
||||
|
||||
VOID KeDumpStackFrames(ULONG DummyArg, ULONG NrFrames)
|
||||
{
|
||||
PULONG Stack = &((&DummyArg)[-1]);
|
||||
ULONG i;
|
||||
|
||||
Stack = (PVOID)(((ULONG)Stack) & (~0x3));
|
||||
|
||||
DbgPrint("Frames:\n");
|
||||
for (i=0; i<NrFrames; i++)
|
||||
{
|
||||
// if (Stack[i] > KERNEL_BASE && Stack[i] < ((ULONG)&etext))
|
||||
if (Stack[i] > KERNEL_BASE)
|
||||
{
|
||||
DbgPrint("%.8x ",Stack[i]);
|
||||
}
|
||||
if (Stack[i] == 0xceafbeef)
|
||||
{
|
||||
DbgPrint("IRQ ");
|
||||
}
|
||||
}
|
||||
DbgPrint("\n");
|
||||
}
|
||||
|
||||
static void set_system_call_gate(unsigned int sel, unsigned int func)
|
||||
{
|
||||
DPRINT("sel %x %d\n",sel,sel);
|
||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||
(KERNEL_CS << 16);
|
||||
KiIdt[sel].b = 0xef00 + (((int)func)&0xffff0000);
|
||||
DPRINT("idt[sel].b %x\n",KiIdt[sel].b);
|
||||
}
|
||||
|
||||
static void set_interrupt_gate(unsigned int sel, unsigned int func)
|
||||
{
|
||||
DPRINT("set_interrupt_gate(sel %d, func %x)\n",sel,func);
|
||||
KiIdt[sel].a = (((int)func)&0xffff) +
|
||||
(KERNEL_CS << 16);
|
||||
KiIdt[sel].b = 0x8f00 + (((int)func)&0xffff0000);
|
||||
}
|
||||
|
||||
asmlinkage unsigned int ExHookException(exception_hook fn, unsigned int exp)
|
||||
/*
|
||||
* FUNCTION: Hook an exception
|
||||
*/
|
||||
{
|
||||
if (exp>=256)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
exception_hooks[exp]=fn;
|
||||
return(0);
|
||||
}
|
||||
|
||||
asmlinkage void KeInitExceptions(void)
|
||||
/*
|
||||
* FUNCTION: Initalize CPU exception handling
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
|
||||
DPRINT("KeInitExceptions()\n",0);
|
||||
|
||||
set_interrupt_gate(0,(int)exception_handler0);
|
||||
set_interrupt_gate(1,(int)exception_handler1);
|
||||
set_interrupt_gate(2,(int)exception_handler2);
|
||||
set_interrupt_gate(3,(int)exception_handler3);
|
||||
set_interrupt_gate(4,(int)exception_handler4);
|
||||
set_interrupt_gate(5,(int)exception_handler5);
|
||||
set_interrupt_gate(6,(int)exception_handler6);
|
||||
set_interrupt_gate(7,(int)exception_handler7);
|
||||
set_interrupt_gate(8,(int)exception_handler8);
|
||||
set_interrupt_gate(9,(int)exception_handler9);
|
||||
set_interrupt_gate(10,(int)exception_handler10);
|
||||
set_interrupt_gate(11,(int)exception_handler11);
|
||||
set_interrupt_gate(12,(int)exception_handler12);
|
||||
set_interrupt_gate(13,(int)exception_handler13);
|
||||
set_interrupt_gate(14,(int)exception_handler14);
|
||||
set_interrupt_gate(15,(int)exception_handler15);
|
||||
set_interrupt_gate(16,(int)exception_handler16);
|
||||
|
||||
for (i=17;i<256;i++)
|
||||
{
|
||||
set_interrupt_gate(i,(int)exception_handler_unknown);
|
||||
}
|
||||
|
||||
set_system_call_gate(0x2e,(int)interrupt_handler2e);
|
||||
}
|
|
@ -1,263 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/i386/page.c
|
||||
* PURPOSE: low level memory managment manipulation
|
||||
* PROGRAMER: David Welch (welch@cwcom.net)
|
||||
* UPDATE HISTORY:
|
||||
* 9/3/98: Created
|
||||
*/
|
||||
|
||||
/* INCLUDES ***************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/mmhal.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/ex.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
#define PA_BIT_PRESENT (0)
|
||||
#define PA_BIT_READWRITE (1)
|
||||
#define PA_BIT_USER (2)
|
||||
|
||||
#define PA_PRESENT (1<<PA_BIT_PRESENT)
|
||||
|
||||
#define PAGETABLE_MAP (0xf0000000)
|
||||
#define PAGEDIRECTORY_MAP (0xf0000000 + (PAGETABLE_MAP / (1024)))
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
static ULONG ProtectToPTE(ULONG flProtect)
|
||||
{
|
||||
ULONG Attributes = 0;
|
||||
|
||||
if (flProtect & PAGE_NOACCESS || flProtect & PAGE_GUARD)
|
||||
{
|
||||
Attributes = 0;
|
||||
}
|
||||
if (flProtect & PAGE_READWRITE || flProtect & PAGE_EXECUTE_READWRITE)
|
||||
{
|
||||
Attributes = PA_WRITE | PA_USER;
|
||||
}
|
||||
if (flProtect & PAGE_READONLY || flProtect & PAGE_EXECUTE ||
|
||||
flProtect & PAGE_EXECUTE_READ)
|
||||
{
|
||||
Attributes = PA_READ | PA_USER;
|
||||
}
|
||||
return(Attributes);
|
||||
}
|
||||
|
||||
#define ADDR_TO_PDE(v) (PULONG)(PAGEDIRECTORY_MAP + \
|
||||
(((ULONG)v / (1024 * 1024))&(~0x3)))
|
||||
#define ADDR_TO_PTE(v) (PULONG)(PAGETABLE_MAP + ((ULONG)v / 1024))
|
||||
|
||||
NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process)
|
||||
{
|
||||
DPRINT("Mmi386ReleaseMmInfo(Process %x)\n",Process);
|
||||
|
||||
MmFreePage(Process->Pcb.PageTableDirectory, 1);
|
||||
Process->Pcb.PageTableDirectory = NULL;
|
||||
|
||||
DPRINT("Finished Mmi386ReleaseMmInfo()\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MmCopyMmInfo(PEPROCESS Src, PEPROCESS Dest)
|
||||
{
|
||||
PULONG PhysPageDirectory;
|
||||
PULONG PageDirectory;
|
||||
PULONG CurrentPageDirectory;
|
||||
PKPROCESS KProcess = &Dest->Pcb;
|
||||
ULONG i;
|
||||
|
||||
DPRINT("MmCopyMmInfo(Src %x, Dest %x)\n", Src, Dest);
|
||||
|
||||
PageDirectory = ExAllocatePage();
|
||||
if (PageDirectory == NULL)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
PhysPageDirectory = (PULONG)(MmGetPhysicalAddress(PageDirectory)).u.LowPart;
|
||||
KProcess->PageTableDirectory = PhysPageDirectory;
|
||||
CurrentPageDirectory = (PULONG)PAGEDIRECTORY_MAP;
|
||||
|
||||
memset(PageDirectory,0,PAGESIZE);
|
||||
for (i=768; i<896; i++)
|
||||
{
|
||||
PageDirectory[i] = CurrentPageDirectory[i];
|
||||
}
|
||||
DPRINT("Addr %x\n",0xf0000000 / (4*1024*1024));
|
||||
PageDirectory[0xf0000000 / (4*1024*1024)] = (ULONG)PhysPageDirectory | 0x7;
|
||||
|
||||
ExUnmapPage(PageDirectory);
|
||||
|
||||
DPRINT("Finished MmCopyMmInfo()\n");
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
VOID MmDeletePageTable(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
*(ADDR_TO_PDE(Address)) = 0;
|
||||
FLUSH_TLB;
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
}
|
||||
|
||||
ULONG MmGetPageEntryForProcess(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
ULONG Entry;
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
Entry = *MmGetPageEntry(Address);
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
return(Entry);
|
||||
}
|
||||
|
||||
VOID MmDeletePageEntry(PEPROCESS Process, PVOID Address, BOOL FreePage)
|
||||
{
|
||||
PULONG page_tlb;
|
||||
PULONG page_dir;
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
page_dir = ADDR_TO_PDE(Address);
|
||||
if ((*page_dir) == 0)
|
||||
{
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
return;
|
||||
}
|
||||
page_tlb = ADDR_TO_PTE(Address);
|
||||
if (FreePage && PAGE_MASK(*page_tlb) != 0)
|
||||
{
|
||||
MmFreePage((PVOID)PAGE_MASK(*page_tlb),1);
|
||||
}
|
||||
*page_tlb = 0;
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PULONG MmGetPageEntry(PVOID PAddress)
|
||||
/*
|
||||
* FUNCTION: Get a pointer to the page table entry for a virtual address
|
||||
*/
|
||||
{
|
||||
PULONG page_tlb;
|
||||
PULONG page_dir;
|
||||
ULONG Address = (ULONG)PAddress;
|
||||
|
||||
DPRINT("MmGetPageEntry(Address %x)\n", Address);
|
||||
|
||||
page_dir = ADDR_TO_PDE(Address);
|
||||
DPRINT("page_dir %x *page_dir %x\n",page_dir,*page_dir);
|
||||
if ((*page_dir) == 0)
|
||||
{
|
||||
(*page_dir) = ((ULONG)MmAllocPage()) | 0x7;
|
||||
FLUSH_TLB;
|
||||
}
|
||||
page_tlb = ADDR_TO_PTE(Address);
|
||||
DPRINT("page_tlb %x\n",page_tlb);
|
||||
return(page_tlb);
|
||||
}
|
||||
|
||||
BOOLEAN MmIsPagePresent(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
return((MmGetPageEntryForProcess(Process, Address)) & PA_PRESENT);
|
||||
}
|
||||
|
||||
|
||||
VOID MmSetPage(PEPROCESS Process,
|
||||
PVOID Address,
|
||||
ULONG flProtect,
|
||||
ULONG PhysicalAddress)
|
||||
{
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
ULONG Attributes = 0;
|
||||
|
||||
DPRINT("MmSetPage(Process %x, Address %x, flProtect %x, "
|
||||
"PhysicalAddress %x)\n",Process,Address,flProtect,
|
||||
PhysicalAddress);
|
||||
|
||||
Attributes = ProtectToPTE(flProtect);
|
||||
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
(*MmGetPageEntry(Address)) = PhysicalAddress | Attributes;
|
||||
FLUSH_TLB;
|
||||
if (Process != NULL && Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
}
|
||||
|
||||
VOID MmSetPageProtect(PEPROCESS Process,
|
||||
PVOID Address,
|
||||
ULONG flProtect)
|
||||
{
|
||||
ULONG Attributes = 0;
|
||||
PULONG PageEntry;
|
||||
PEPROCESS CurrentProcess = PsGetCurrentProcess();
|
||||
|
||||
Attributes = ProtectToPTE(flProtect);
|
||||
|
||||
if (Process != CurrentProcess)
|
||||
{
|
||||
KeAttachProcess(Process);
|
||||
}
|
||||
PageEntry = MmGetPageEntry(Address);
|
||||
(*PageEntry) = PAGE_MASK(*PageEntry) | Attributes;
|
||||
FLUSH_TLB;
|
||||
if (Process != CurrentProcess)
|
||||
{
|
||||
KeDetachProcess();
|
||||
}
|
||||
}
|
||||
|
||||
PHYSICAL_ADDRESS MmGetPhysicalAddress(PVOID vaddr)
|
||||
/*
|
||||
* FUNCTION: Returns the physical address corresponding to a virtual address
|
||||
*/
|
||||
{
|
||||
PHYSICAL_ADDRESS p;
|
||||
|
||||
p.QuadPart = 0;
|
||||
|
||||
DPRINT("MmGetPhysicalAddress(vaddr %x)\n", vaddr);
|
||||
|
||||
p.u.LowPart = PAGE_MASK(*MmGetPageEntry(vaddr));
|
||||
p.u.HighPart = 0;
|
||||
|
||||
return p;
|
||||
}
|
|
@ -1,372 +0,0 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/hal/x86/printk.c
|
||||
* PURPOSE: Writing to the console
|
||||
* PROGRAMMER: David Welch (welch@mcmail.com)
|
||||
* UPDATE HISTORY:
|
||||
* ??/??/??: Created
|
||||
* 05/06/98: Implemented BSOD
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/mmhal.h>
|
||||
#include <internal/halio.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
|
||||
//#define BOCHS_DEBUGGING 1
|
||||
//#define SERIAL_DEBUGGING
|
||||
#define SERIAL_PORT 0x03f8
|
||||
#define SERIAL_BAUD_RATE 19200
|
||||
#define SERIAL_LINE_CONTROL (SR_LCR_CS8 | SR_LCR_ST1 | SR_LCR_PNO)
|
||||
|
||||
|
||||
#if 1
|
||||
#define IDMAP_BASE (0xd0000000)
|
||||
|
||||
/*
|
||||
* Return a linear address which can be used to access the physical memory
|
||||
* starting at x
|
||||
*/
|
||||
extern inline unsigned int physical_to_linear(unsigned int x)
|
||||
{
|
||||
return(x+IDMAP_BASE);
|
||||
}
|
||||
|
||||
extern inline unsigned int linear_to_physical(unsigned int x)
|
||||
{
|
||||
return(x-IDMAP_BASE);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef BOCHS_DEBUGGING
|
||||
#define BOCHS_LOGGER_PORT (0x3ed)
|
||||
#endif
|
||||
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
#define SER_RBR SERIAL_PORT + 0
|
||||
#define SER_THR SERIAL_PORT + 0
|
||||
#define SER_DLL SERIAL_PORT + 0
|
||||
#define SER_IER SERIAL_PORT + 1
|
||||
#define SER_DLM SERIAL_PORT + 1
|
||||
#define SER_IIR SERIAL_PORT + 2
|
||||
#define SER_LCR SERIAL_PORT + 3
|
||||
#define SR_LCR_CS5 0x00
|
||||
#define SR_LCR_CS6 0x01
|
||||
#define SR_LCR_CS7 0x02
|
||||
#define SR_LCR_CS8 0x03
|
||||
#define SR_LCR_ST1 0x00
|
||||
#define SR_LCR_ST2 0x04
|
||||
#define SR_LCR_PNO 0x00
|
||||
#define SR_LCR_POD 0x08
|
||||
#define SR_LCR_PEV 0x18
|
||||
#define SR_LCR_PMK 0x28
|
||||
#define SR_LCR_PSP 0x38
|
||||
#define SR_LCR_BRK 0x40
|
||||
#define SR_LCR_DLAB 0x80
|
||||
#define SER_MCR SERIAL_PORT + 4
|
||||
#define SR_MCR_DTR 0x01
|
||||
#define SR_MCR_RTS 0x02
|
||||
#define SER_LSR SERIAL_PORT + 5
|
||||
#define SR_LSR_TBE 0x20
|
||||
#define SER_MSR SERIAL_PORT + 6
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PURPOSE: Current cursor position
|
||||
*/
|
||||
static unsigned int cursorx=0, cursory=0;
|
||||
static unsigned int lines_seen = 0;
|
||||
static unsigned char CharAttribute = 0x17;
|
||||
|
||||
//#define NR_ROWS 25
|
||||
#define NR_ROWS 50
|
||||
#define NR_COLUMNS 80
|
||||
#define VIDMEM_BASE 0xb8000
|
||||
|
||||
/*
|
||||
* PURPOSE: Points to the base of text mode video memory
|
||||
*/
|
||||
static char* vidmem = (char *)(VIDMEM_BASE + IDMAP_BASE);
|
||||
|
||||
#define CRTC_COMMAND 0x3d4
|
||||
#define CRTC_DATA 0x3d5
|
||||
#define CRTC_CURLO 0x0f
|
||||
#define CRTC_CURHI 0x0e
|
||||
|
||||
/*
|
||||
* PURPOSE: This flag is set to true if the system is in HAL managed
|
||||
* console mode. This is initially true then once the graphics drivers
|
||||
* initialize, it is turned off, HAL console mode is reentered if a fatal
|
||||
* error occurs or on system shutdown
|
||||
*/
|
||||
static unsigned int in_hal_console = 1;
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
|
||||
void __putchar(char c);
|
||||
|
||||
|
||||
void HalSwitchToBlueScreen(void)
|
||||
/*
|
||||
* FUNCTION: Switches the monitor to text mode and writes a blue background
|
||||
* NOTE: This function is entirely self contained and can be used from any
|
||||
* graphics mode.
|
||||
*/
|
||||
{
|
||||
/*
|
||||
* Sanity check
|
||||
*/
|
||||
if (in_hal_console)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reset the cursor position
|
||||
*/
|
||||
cursorx=0;
|
||||
cursory=0;
|
||||
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
outb_p(CRTC_DATA, 0);
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
outb_p(CRTC_DATA, 0);
|
||||
|
||||
/*
|
||||
* This code section is taken from the sample routines by
|
||||
* Jeff Morgan (kinfira@hotmail.com)
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtDisplayString(IN PUNICODE_STRING DisplayString)
|
||||
{
|
||||
// DbgPrint("NtDisplayString(%w)\n",DisplayString->Buffer);
|
||||
DbgPrint("%w",DisplayString->Buffer);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
void HalDisplayString(char* string)
|
||||
/*
|
||||
* FUNCTION: Switches the screen to HAL console mode (BSOD) if not there
|
||||
* already and displays a string
|
||||
* ARGUMENT:
|
||||
* string = ASCII string to display
|
||||
* NOTE: Use with care because there is no support for returning from BSOD
|
||||
* mode
|
||||
*/
|
||||
{
|
||||
char* str=string;
|
||||
|
||||
if (!in_hal_console)
|
||||
{
|
||||
HalSwitchToBlueScreen();
|
||||
}
|
||||
|
||||
while ((*str)!=0)
|
||||
{
|
||||
__putchar(*str);
|
||||
str++;
|
||||
}
|
||||
}
|
||||
|
||||
void __putchar(char c)
|
||||
/*
|
||||
* FUNCTION: Writes a character to the console and updates the cursor position
|
||||
* ARGUMENTS:
|
||||
* c = the character to write
|
||||
* NOTE: This function handles newlines as well
|
||||
*/
|
||||
{
|
||||
int offset;
|
||||
int i;
|
||||
|
||||
#ifdef BOCHS_DEBUGGING
|
||||
outb_p(BOCHS_LOGGER_PORT,c);
|
||||
#endif
|
||||
|
||||
outb_p(0xe9, c);
|
||||
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
while ((inb_p(SER_LSR) & SR_LSR_TBE) == 0)
|
||||
;
|
||||
outb_p(SER_THR, c);
|
||||
#endif
|
||||
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
offset = inb_p(CRTC_DATA)<<8;
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
offset += inb_p(CRTC_DATA);
|
||||
|
||||
cursory = offset / NR_COLUMNS;
|
||||
cursorx = offset % NR_COLUMNS;
|
||||
|
||||
switch(c)
|
||||
{
|
||||
case '\n':
|
||||
cursory++;
|
||||
cursorx = 0;
|
||||
lines_seen++;
|
||||
break;
|
||||
|
||||
default:
|
||||
vidmem[(cursorx * 2) + (cursory * 80 * 2)] = c;
|
||||
vidmem[(cursorx * 2) + (cursory * 80 * 2) + 1] = CharAttribute;
|
||||
cursorx++;
|
||||
if (cursorx >= NR_COLUMNS)
|
||||
{
|
||||
cursory++;
|
||||
lines_seen++;
|
||||
cursorx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (cursory >= NR_ROWS)
|
||||
{
|
||||
unsigned short *LinePtr;
|
||||
|
||||
memcpy(vidmem,
|
||||
&vidmem[NR_COLUMNS * 2],
|
||||
NR_COLUMNS * (NR_ROWS - 1) * 2);
|
||||
LinePtr = (unsigned short *) &vidmem[NR_COLUMNS * (NR_ROWS - 1) * 2];
|
||||
for (i = 0; i < NR_COLUMNS; i++)
|
||||
{
|
||||
LinePtr[i] = CharAttribute << 8;
|
||||
}
|
||||
cursory = NR_ROWS - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the cursor position
|
||||
*/
|
||||
|
||||
offset = (cursory * NR_COLUMNS) + cursorx;
|
||||
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
outb_p(CRTC_DATA, offset);
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
offset >>= 8;
|
||||
outb_p(CRTC_DATA, offset);
|
||||
|
||||
#if 0
|
||||
if (lines_seen == 22)
|
||||
{
|
||||
lines_seen = 0;
|
||||
printk("---- press escape to continue\n");
|
||||
|
||||
while (inb_p(0x60)!=0x1);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Because this is used by almost every subsystem including irqs it
|
||||
* must be atomic. The following code sequence disables interrupts after
|
||||
* saving the previous state of the interrupt flag
|
||||
*/
|
||||
__asm__("pushf\n\tpop %0\n\tcli\n\t"
|
||||
: "=m" (eflags)
|
||||
: /* */);
|
||||
|
||||
/*
|
||||
* Process the format string into a fixed length buffer using the
|
||||
* standard C RTL function
|
||||
*/
|
||||
va_start(ap,fmt);
|
||||
vsprintf(buffer,fmt,ap);
|
||||
va_end(ap);
|
||||
|
||||
while ((*str)!=0)
|
||||
{
|
||||
__putchar(*str);
|
||||
str++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Restore the interrupt flag
|
||||
*/
|
||||
__asm__("push %0\n\tpopf\n\t"
|
||||
:
|
||||
: "m" (eflags));
|
||||
}
|
||||
|
||||
|
||||
ULONG DbgPrint(PCH Format, ...)
|
||||
{
|
||||
char buffer[256];
|
||||
va_list ap;
|
||||
unsigned int eflags;
|
||||
|
||||
/*
|
||||
* Because this is used by almost every subsystem including irqs it
|
||||
* must be atomic. The following code sequence disables interrupts after
|
||||
* saving the previous state of the interrupt flag
|
||||
*/
|
||||
__asm__("pushf\n\tpop %0\n\tcli\n\t"
|
||||
: "=m" (eflags)
|
||||
: /* */);
|
||||
|
||||
/*
|
||||
* Process the format string into a fixed length buffer using the
|
||||
* standard C RTL function
|
||||
*/
|
||||
va_start(ap,Format);
|
||||
vsprintf(buffer,Format,ap);
|
||||
va_end(ap);
|
||||
|
||||
HalDisplayString (buffer);
|
||||
|
||||
/*
|
||||
* Restore the interrupt flag
|
||||
*/
|
||||
__asm__("push %0\n\tpopf\n\t"
|
||||
:
|
||||
: "m" (eflags));
|
||||
return(strlen(buffer));
|
||||
}
|
||||
|
||||
void HalInitConsole(boot_param* bp)
|
||||
/*
|
||||
* FUNCTION: Initalize the console
|
||||
* ARGUMENTS:
|
||||
* bp = Parameters setup by the boot loader
|
||||
*/
|
||||
{
|
||||
|
||||
#ifdef SERIAL_DEBUGGING
|
||||
/* turn on DTR and RTS */
|
||||
outb_p(SER_MCR, SR_MCR_DTR | SR_MCR_RTS);
|
||||
/* set baud rate, line control */
|
||||
outb_p(SER_LCR, SERIAL_LINE_CONTROL | SR_LCR_DLAB);
|
||||
outb_p(SER_DLL, (115200 / SERIAL_BAUD_RATE) & 0xff);
|
||||
outb_p(SER_DLM, ((115200 / SERIAL_BAUD_RATE) >> 8) & 0xff);
|
||||
outb_p(SER_LCR, SERIAL_LINE_CONTROL);
|
||||
#endif
|
||||
|
||||
/* Set cursor position */
|
||||
|
||||
cursorx=bp->cursorx;
|
||||
cursory=bp->cursory;
|
||||
|
||||
#if 0
|
||||
offset = (cursory * NR_COLUMNS) + cursorx;
|
||||
outb_p(CRTC_COMMAND, CRTC_CURLO);
|
||||
outb_p(CRTC_DATA, offset);
|
||||
outb_p(CRTC_COMMAND, CRTC_CURHI);
|
||||
offset >>= 8;
|
||||
outb_p(CRTC_DATA, offset);
|
||||
#endif
|
||||
}
|
|
@ -1,166 +0,0 @@
|
|||
/* $Id: usercall.c,v 1.5 1999/11/02 08:55:39 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/hal/x86/usercall.c
|
||||
* PURPOSE: 2E interrupt handler
|
||||
* PROGRAMMER: ???
|
||||
* UPDATE HISTORY:
|
||||
* ???
|
||||
*/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/ke.h>
|
||||
#include <internal/symbol.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/mmhal.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
#include <internal/service.h>
|
||||
|
||||
#include <ddk/defines.h>
|
||||
|
||||
extern SERVICE_TABLE _SystemServiceTable[];
|
||||
|
||||
/* The service dispatcher will take the service number passed in
|
||||
* by the user mode process, logical and it with ServiceNumberMask
|
||||
* and compare the resulting value with ServiceNumberValue. If the
|
||||
* value matches, The passed service number will be and'ed with the
|
||||
* inverse of ServiceNumberMask to obtain the index into the ServiceTable
|
||||
* for the service to call
|
||||
*/
|
||||
typedef struct _HAL_DISPATCH_TABLE_ENTRY
|
||||
{
|
||||
DWORD ServiceNumberMask;
|
||||
DWORD ServiceNumberValue;
|
||||
PSERVICE_TABLE ServiceTable;
|
||||
DWORD TableCount;
|
||||
} HAL_DISPATCH_TABLE_ENTRY, *PHAL_DISPATCH_TABLE_ENTRY;
|
||||
|
||||
static KSPIN_LOCK DispatchTableLock = {0,};
|
||||
static DWORD DispatchTableCount = 0;
|
||||
static HAL_DISPATCH_TABLE_ENTRY DispatchTables[16];
|
||||
|
||||
NTSTATUS HalRegisterServiceTable(DWORD Mask,
|
||||
DWORD Value,
|
||||
PSERVICE_TABLE Table,
|
||||
DWORD Count)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
KIRQL OldLvl;
|
||||
|
||||
KeAcquireSpinLock(&DispatchTableLock, &OldLvl);
|
||||
|
||||
Status = STATUS_SUCCESS;
|
||||
|
||||
/* FIXME: should check for invalid/overlapping service tables */
|
||||
DispatchTables[DispatchTableCount].ServiceNumberMask = Mask;
|
||||
DispatchTables[DispatchTableCount].ServiceNumberValue = Value;
|
||||
DispatchTables[DispatchTableCount].ServiceTable = Table;
|
||||
DispatchTables[DispatchTableCount].TableCount = Count;
|
||||
DispatchTableCount++;
|
||||
|
||||
KeReleaseSpinLock(&DispatchTableLock, OldLvl);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
#define _STR(x) #x
|
||||
#define STR(x) _STR(x)
|
||||
|
||||
void PsBeginThreadWithContextInternal(void);
|
||||
__asm__(
|
||||
"\n\t.global _PsBeginThreadWithContextInternal\n\t"
|
||||
"_PsBeginThreadWithContextInternal:\n\t"
|
||||
// "pushl $1\n\t"
|
||||
// "call _KeLowerIrql\n\t"
|
||||
"call _PiBeforeBeginThread\n\t"
|
||||
// "popl %eax\n\t"
|
||||
"popl %eax\n\t"
|
||||
"popl %eax\n\t"
|
||||
"popl %eax\n\t"
|
||||
"popl %eax\n\t"
|
||||
"popl %eax\n\t"
|
||||
"popl %eax\n\t"
|
||||
"popl %eax\n\t"
|
||||
"addl $112,%esp\n\t"
|
||||
"popl %gs\n\t"
|
||||
"popl %fs\n\t"
|
||||
"popl %es\n\t"
|
||||
"popl %ds\n\t"
|
||||
"popl %edi\n\t"
|
||||
"popl %esi\n\t"
|
||||
"popl %ebx\n\t"
|
||||
"popl %edx\n\t"
|
||||
"popl %ecx\n\t"
|
||||
"popl %eax\n\t"
|
||||
"popl %ebp\n\t"
|
||||
"iret\n\t");
|
||||
|
||||
VOID KiSystemCallHook(ULONG Nr)
|
||||
{
|
||||
// DbgPrint("KiSystemCallHook(Nr %d) %d\n", Nr, KeGetCurrentIrql());
|
||||
// DbgPrint("SystemCall %x\n", _SystemServiceTable[Nr].Function);
|
||||
assert_irql(PASSIVE_LEVEL);
|
||||
}
|
||||
|
||||
void interrupt_handler2e(void);
|
||||
__asm__("\n\t.global _interrupt_handler2e\n\t"
|
||||
"_interrupt_handler2e:\n\t"
|
||||
|
||||
/* Save the users context */
|
||||
"pushl %ds\n\t"
|
||||
"pushl %es\n\t"
|
||||
"pushl %esi\n\t"
|
||||
"pushl %edi\n\t"
|
||||
"pushl %ebp\n\t"
|
||||
"pushl %ebx\n\t"
|
||||
|
||||
/* Set ES to kernel segment */
|
||||
"movw $"STR(KERNEL_DS)",%bx\n\t"
|
||||
"movw %bx,%es\n\t"
|
||||
|
||||
/* Allocate new Kernel stack frame */
|
||||
"movl %esp,%ebp\n\t"
|
||||
|
||||
/* Users's current stack frame pointer is source */
|
||||
"movl %edx,%esi\n\t"
|
||||
|
||||
/* FIXME: determine system service table to use */
|
||||
/* FIXME: chech to see if SS is valid/inrange */
|
||||
|
||||
/* Allocate room for argument list from kernel stack */
|
||||
"movl %es:__SystemServiceTable(,%eax,8),%ecx\n\t"
|
||||
"subl %ecx,%esp\n\t"
|
||||
|
||||
/* Copy the arguments from the user stack to the kernel stack */
|
||||
"movl %esp,%edi\n\t"
|
||||
"rep\n\tmovsb\n\t"
|
||||
|
||||
/* DS is now also kernel segment */
|
||||
"movw %bx,%ds\n\t"
|
||||
|
||||
/* Call system call hook */
|
||||
"pushl %eax\n\t"
|
||||
"call _KiSystemCallHook\n\t"
|
||||
"popl %eax\n\t"
|
||||
|
||||
/* Make the system service call */
|
||||
"movl %ds:__SystemServiceTable+4(,%eax,8),%eax\n\t"
|
||||
"call *%eax\n\t"
|
||||
|
||||
/* Deallocate the kernel stack frame */
|
||||
"movl %ebp,%esp\n\t"
|
||||
|
||||
/* Restore the user context */
|
||||
"popl %ebx\n\t"
|
||||
"popl %ebp\n\t"
|
||||
"popl %edi\n\t"
|
||||
"popl %esi\n\t"
|
||||
"popl %es\n\t"
|
||||
"popl %ds\n\t"
|
||||
"iret\n\t");
|
||||
|
||||
|
|
@ -21,6 +21,15 @@
|
|||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID IopCompleteRequest1(struct _KAPC* Apc,
|
||||
PKNORMAL_ROUTINE* NormalRoutine,
|
||||
PVOID* NormalContext,
|
||||
PVOID* SystemArgument1,
|
||||
PVOID* SystemArgument2)
|
||||
{
|
||||
DPRINT("IopCompleteRequest1()\n");
|
||||
IoFreeIrp((PIRP)(*SystemArgument1));
|
||||
}
|
||||
|
||||
VOID IoDeviceControlCompletion(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp,
|
||||
|
@ -135,6 +144,9 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost)
|
|||
PDEVICE_OBJECT DeviceObject;
|
||||
PFILE_OBJECT FileObject;
|
||||
|
||||
DPRINT("IoSecondStageCompletion(Irp %x, PriorityBoost %d)\n",
|
||||
Irp, PriorityBoost);
|
||||
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
||||
DeviceObject = IoStack->DeviceObject;
|
||||
|
@ -163,7 +175,30 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost)
|
|||
|
||||
default:
|
||||
}
|
||||
|
||||
|
||||
if (Irp->Overlay.AsynchronousParameters.UserApcRoutine != NULL)
|
||||
{
|
||||
PKTHREAD Thread;
|
||||
|
||||
DPRINT("Dispatching APC\n");
|
||||
Thread = &Irp->Tail.Overlay.Thread->Tcb;
|
||||
KeInitializeApc(&Irp->Tail.Apc,
|
||||
Thread,
|
||||
0,
|
||||
IopCompleteRequest1,
|
||||
NULL,
|
||||
(PKNORMAL_ROUTINE)
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine,
|
||||
UserMode,
|
||||
(PVOID)
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext);
|
||||
KeInsertQueueApc(&Irp->Tail.Apc,
|
||||
Irp,
|
||||
NULL,
|
||||
KernelMode);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Irp->UserIosb!=NULL)
|
||||
{
|
||||
*Irp->UserIosb=Irp->IoStatus;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: device.c,v 1.12 1999/11/12 12:01:13 dwelch Exp $
|
||||
/* $Id: device.c,v 1.13 1999/11/24 11:51:50 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <internal/io.h>
|
||||
#include <internal/ob.h>
|
||||
#include <internal/ldr.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ NTSTATUS
|
|||
STDCALL
|
||||
NtQueryDirectoryFile(
|
||||
IN HANDLE FileHandle,
|
||||
IN HANDLE Event OPTIONAL,
|
||||
IN HANDLE PEvent OPTIONAL,
|
||||
IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
|
||||
IN PVOID ApcContext OPTIONAL,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
|
|
|
@ -31,6 +31,8 @@ VOID IopCloseFile(PVOID ObjectBody, ULONG HandleCount)
|
|||
PIO_STACK_LOCATION StackPtr;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("IopCloseFile()\n");
|
||||
|
||||
if (HandleCount > 0)
|
||||
{
|
||||
return;
|
||||
|
@ -61,6 +63,8 @@ VOID IopDeleteFile(PVOID ObjectBody)
|
|||
PIO_STACK_LOCATION StackPtr;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("IopDeleteFile()\n");
|
||||
|
||||
ObReferenceObjectByPointer(ObjectBody,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
IoFileType,
|
||||
|
@ -84,6 +88,10 @@ VOID IopDeleteFile(PVOID ObjectBody)
|
|||
}
|
||||
}
|
||||
|
||||
VOID IoShutdownIoManager(VOID)
|
||||
{
|
||||
}
|
||||
|
||||
VOID IoInit(VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES attr;
|
||||
|
|
|
@ -81,8 +81,8 @@ VOID IoMarkIrpPending(PIRP Irp)
|
|||
* Irp = Irp to mark
|
||||
*/
|
||||
{
|
||||
DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
|
||||
IoGetCurrentIrpStackLocation(Irp));
|
||||
// DPRINT("IoGetCurrentIrpStackLocation(Irp) %x\n",
|
||||
// IoGetCurrentIrpStackLocation(Irp));
|
||||
IoGetCurrentIrpStackLocation(Irp)->Control |= SL_PENDING_RETURNED;
|
||||
}
|
||||
|
||||
|
@ -123,10 +123,10 @@ PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
|
|||
* RETURNS: A pointer to the stack location
|
||||
*/
|
||||
{
|
||||
DPRINT("IoGetCurrentIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
||||
Irp,
|
||||
Irp->CurrentLocation,
|
||||
Irp->StackCount);
|
||||
// DPRINT("IoGetCurrentIrpStackLocation: Irp %08lx CurLoc %d StkCnt %d\n",
|
||||
// Irp,
|
||||
// Irp->CurrentLocation,
|
||||
// Irp->StackCount);
|
||||
|
||||
return(&Irp->Stack[(ULONG)Irp->CurrentLocation]);
|
||||
}
|
||||
|
@ -146,10 +146,10 @@ PIO_STACK_LOCATION IoGetNextIrpStackLocation(PIRP Irp)
|
|||
* RETURNS: A pointer to the stack location
|
||||
*/
|
||||
{
|
||||
DPRINT("IoGetNextIrpStackLocation(Irp %x)\n",Irp);
|
||||
// DPRINT("IoGetNextIrpStackLocation(Irp %x)\n",Irp);
|
||||
|
||||
assert(Irp!=NULL);
|
||||
DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
|
||||
// DPRINT("Irp %x Irp->StackPtr %x\n",Irp,Irp->CurrentLocation);
|
||||
return(&Irp->Stack[Irp->CurrentLocation-1]);
|
||||
}
|
||||
|
||||
|
@ -162,7 +162,7 @@ NTSTATUS IoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
PDRIVER_OBJECT DriverObject;
|
||||
PIO_STACK_LOCATION Param;
|
||||
|
||||
DPRINT("IoCallDriver(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||
// DPRINT("IoCallDriver(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
|
||||
|
||||
DriverObject = DeviceObject->DriverObject;
|
||||
Param = IoGetNextIrpStackLocation(Irp);
|
||||
|
@ -170,9 +170,9 @@ NTSTATUS IoCallDriver(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
Irp->Tail.Overlay.CurrentStackLocation--;
|
||||
Irp->CurrentLocation--;
|
||||
|
||||
DPRINT("MajorFunction %d\n",param->MajorFunction);
|
||||
DPRINT("DriverObject->MajorFunction[Param->MajorFunction] %x\n",
|
||||
DriverObject->MajorFunction[Param->MajorFunction]);
|
||||
// DPRINT("MajorFunction %d\n", Param->MajorFunction);
|
||||
// DPRINT("DriverObject->MajorFunction[Param->MajorFunction] %x\n",
|
||||
// DriverObject->MajorFunction[Param->MajorFunction]);
|
||||
Status = DriverObject->MajorFunction[Param->MajorFunction](DeviceObject,
|
||||
Irp);
|
||||
return Status;
|
||||
|
@ -213,7 +213,7 @@ PIRP IoAllocateIrp(CCHAR StackSize, BOOLEAN ChargeQuota)
|
|||
|
||||
IoInitializeIrp(Irp, IoSizeOfIrp(StackSize), StackSize);
|
||||
|
||||
DPRINT("Irp %x Irp->StackPtr %d\n", Irp, Irp->CurrentLocation);
|
||||
// DPRINT("Irp %x Irp->StackPtr %d\n", Irp, Irp->CurrentLocation);
|
||||
|
||||
return Irp;
|
||||
}
|
||||
|
@ -249,7 +249,10 @@ VOID IopCompleteRequest(struct _KAPC* Apc,
|
|||
PVOID* SystemArgument1,
|
||||
PVOID* SystemArgument2)
|
||||
{
|
||||
IoSecondStageCompletion((PIRP)(*NormalContext),
|
||||
DPRINT("IopCompleteRequest(Apc %x, SystemArgument1 %x, "
|
||||
"(*SystemArgument1) %x\n", Apc, SystemArgument1,
|
||||
*SystemArgument1);
|
||||
IoSecondStageCompletion((PIRP)(*SystemArgument1),
|
||||
IO_NO_INCREMENT);
|
||||
}
|
||||
|
||||
|
@ -291,6 +294,7 @@ VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
|
|||
|
||||
if (Irp->PendingReturned)
|
||||
{
|
||||
DPRINT("Dispatching APC\n");
|
||||
Thread = &Irp->Tail.Overlay.Thread->Tcb;
|
||||
KeInitializeApc(&Irp->Tail.Apc,
|
||||
Thread,
|
||||
|
@ -299,15 +303,17 @@ VOID IoCompleteRequest(PIRP Irp, CCHAR PriorityBoost)
|
|||
NULL,
|
||||
(PKNORMAL_ROUTINE)
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine,
|
||||
KernelMode,
|
||||
(PVOID)Irp);
|
||||
UserMode,
|
||||
(PVOID)
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext);
|
||||
KeInsertQueueApc(&Irp->Tail.Apc,
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext,
|
||||
Irp,
|
||||
NULL,
|
||||
KernelMode);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("Calling completion routine directly\n");
|
||||
IoSecondStageCompletion(Irp,PriorityBoost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
extern VOID KeApcProlog(VOID);
|
||||
extern KSPIN_LOCK PiThreadListLock;
|
||||
|
||||
/* PROTOTYPES ****************************************************************/
|
||||
|
||||
VOID KeApcProlog3(PKAPC Apc);
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
BOOLEAN KiTestAlert(PKTHREAD Thread,
|
||||
|
@ -38,30 +42,62 @@ BOOLEAN KiTestAlert(PKTHREAD Thread,
|
|||
PKAPC Apc;
|
||||
PULONG Esp = (PULONG)UserContext->Esp;
|
||||
|
||||
DPRINT("KiTestAlert(Thread %x, UserContext %x)\n");
|
||||
|
||||
current_entry = Thread->ApcState.ApcListHead[1].Flink;
|
||||
|
||||
if (current_entry == &Thread->ApcState.ApcListHead[1])
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
while (current_entry != &Thread->ApcState.ApcListHead[1])
|
||||
{
|
||||
Apc = CONTAINING_RECORD(current_entry, KAPC, ApcListEntry);
|
||||
|
||||
DPRINT("Esp %x\n", Esp);
|
||||
DPRINT("Apc->NormalContext %x\n", Apc->NormalContext);
|
||||
DPRINT("Apc->SystemArgument1 %x\n", Apc->SystemArgument1);
|
||||
DPRINT("Apc->SystemArgument2 %x\n", Apc->SystemArgument2);
|
||||
DPRINT("UserContext->Eip %x\n", UserContext->Eip);
|
||||
|
||||
Esp = Esp - 16;
|
||||
Esp[0] = (ULONG)Apc->SystemArgument2;
|
||||
Esp[1] = (ULONG)Apc->SystemArgument1;
|
||||
Esp[2] = (ULONG)Apc->NormalContext;
|
||||
Esp[3] = UserContext->Eip;
|
||||
Esp[3] = (ULONG)Apc->SystemArgument2;
|
||||
Esp[2] = (ULONG)Apc->SystemArgument1;
|
||||
Esp[1] = (ULONG)Apc->NormalContext;
|
||||
Esp[0] = UserContext->Eip;
|
||||
UserContext->Eip = (ULONG)Apc->NormalRoutine;
|
||||
|
||||
current_entry = current_entry->Flink;
|
||||
|
||||
/*
|
||||
* Now call for the kernel routine for the APC, which will free
|
||||
* the APC data structure
|
||||
*/
|
||||
KeApcProlog3(Apc);
|
||||
}
|
||||
UserContext->Esp = (ULONG)Esp;
|
||||
InitializeListHead(&Thread->ApcState.ApcListHead[1]);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
VOID KeApcProlog2(PKAPC Apc)
|
||||
{
|
||||
KeApcProlog3(Apc);
|
||||
PsSuspendThread(CONTAINING_RECORD(Apc->Thread,ETHREAD,Tcb),
|
||||
NULL,
|
||||
Apc->Thread->Alertable,
|
||||
Apc->Thread->WaitMode);
|
||||
}
|
||||
|
||||
VOID KeApcProlog3(PKAPC Apc)
|
||||
/*
|
||||
* FUNCTION: This is called from the prolog proper (in assembly) to deliver
|
||||
* a kernel APC
|
||||
*/
|
||||
{
|
||||
|
||||
|
||||
DPRINT("KeApcProlog2(Apc %x)\n",Apc);
|
||||
KeEnterCriticalRegion();
|
||||
Apc->Thread->ApcState.KernelApcInProgress++;
|
||||
|
@ -70,11 +106,10 @@ VOID KeApcProlog2(PKAPC Apc)
|
|||
Apc->KernelRoutine(Apc,
|
||||
&Apc->NormalRoutine,
|
||||
&Apc->NormalContext,
|
||||
&Apc->SystemArgument2,
|
||||
&Apc->SystemArgument1,
|
||||
&Apc->SystemArgument2);
|
||||
Apc->Thread->ApcState.KernelApcInProgress--;
|
||||
KeLeaveCriticalRegion();
|
||||
PsSuspendThread(CONTAINING_RECORD(Apc->Thread,ETHREAD,Tcb));
|
||||
KeLeaveCriticalRegion();
|
||||
}
|
||||
|
||||
VOID KeDeliverKernelApc(PKAPC Apc)
|
||||
|
@ -92,11 +127,7 @@ VOID KeDeliverKernelApc(PKAPC Apc)
|
|||
|
||||
if (TargetThread == KeGetCurrentThread())
|
||||
{
|
||||
Apc->KernelRoutine(Apc,
|
||||
&Apc->NormalRoutine,
|
||||
&Apc->NormalContext,
|
||||
&Apc->SystemArgument2,
|
||||
&Apc->SystemArgument2);
|
||||
KeApcProlog3(Apc);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -129,7 +160,8 @@ VOID KeDeliverKernelApc(PKAPC Apc)
|
|||
TargetThread->Context.eax = (ULONG)Apc;
|
||||
}
|
||||
|
||||
PsResumeThread(CONTAINING_RECORD(TargetThread,ETHREAD,Tcb));
|
||||
PsResumeThread(CONTAINING_RECORD(TargetThread,ETHREAD,Tcb),
|
||||
NULL);
|
||||
}
|
||||
|
||||
VOID KeInsertQueueApc(PKAPC Apc,
|
||||
|
@ -153,6 +185,9 @@ VOID KeInsertQueueApc(PKAPC Apc,
|
|||
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
|
||||
|
||||
Apc->SystemArgument1 = SystemArgument1;
|
||||
Apc->SystemArgument2 = SystemArgument2;
|
||||
|
||||
if (Apc->Inserted)
|
||||
{
|
||||
DbgPrint("KeInsertQueueApc(): multiple APC insertations\n");
|
||||
|
@ -170,6 +205,7 @@ VOID KeInsertQueueApc(PKAPC Apc,
|
|||
{
|
||||
InsertTailList(&TargetThread->ApcState.ApcListHead[1],
|
||||
&Apc->ApcListEntry);
|
||||
TargetThread->ApcState.KernelApcPending++;
|
||||
TargetThread->ApcState.UserApcPending++;
|
||||
}
|
||||
Apc->Inserted = TRUE;
|
||||
|
@ -185,6 +221,17 @@ VOID KeInsertQueueApc(PKAPC Apc,
|
|||
{
|
||||
DPRINT("Queuing APC for later delivery\n");
|
||||
}
|
||||
if (Apc->ApcMode == UserMode && TargetThread->Alertable == TRUE &&
|
||||
TargetThread->WaitMode == UserMode)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("Resuming thread for user APC\n");
|
||||
|
||||
Status = STATUS_USER_APC;
|
||||
PsResumeThread((PETHREAD)TargetThread,
|
||||
&Status);
|
||||
}
|
||||
KeLowerIrql(oldlvl);
|
||||
}
|
||||
|
||||
|
@ -209,7 +256,7 @@ VOID KeInitializeApc(PKAPC Apc,
|
|||
* Mode = APC mode
|
||||
* Context = Parameter to be passed to the APC routine
|
||||
*/
|
||||
{
|
||||
{
|
||||
DPRINT("KeInitializeApc(Apc %x, Thread %x, StateIndex %d, "
|
||||
"KernelRoutine %x, RundownRoutine %x, NormalRoutine %x, Mode %d, "
|
||||
"Context %x)\n",Apc,Thread,StateIndex,KernelRoutine,RundownRoutine,
|
||||
|
@ -224,19 +271,22 @@ VOID KeInitializeApc(PKAPC Apc,
|
|||
Apc->NormalContext = Context;
|
||||
Apc->Inserted = FALSE;
|
||||
Apc->ApcStateIndex = StateIndex;
|
||||
Apc->ApcMode = Mode;
|
||||
if (Apc->NormalRoutine != NULL)
|
||||
{
|
||||
Apc->ApcMode = Mode;
|
||||
}
|
||||
else
|
||||
{
|
||||
Apc->ApcMode = KernelMode;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtQueueApcThread (
|
||||
HANDLE ThreadHandle,
|
||||
PKNORMAL_ROUTINE ApcRoutine,
|
||||
PVOID NormalContext,
|
||||
PVOID SystemArgument1,
|
||||
PVOID SystemArgument2
|
||||
)
|
||||
NTSTATUS STDCALL NtQueueApcThread(HANDLE ThreadHandle,
|
||||
PKNORMAL_ROUTINE ApcRoutine,
|
||||
PVOID NormalContext,
|
||||
PVOID SystemArgument1,
|
||||
PVOID SystemArgument2)
|
||||
{
|
||||
PKAPC Apc;
|
||||
PETHREAD Thread;
|
||||
|
@ -278,13 +328,8 @@ NtQueueApcThread (
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtTestAlert(VOID)
|
||||
NTSTATUS STDCALL NtTestAlert(VOID)
|
||||
{
|
||||
KiTestAlert(
|
||||
KeGetCurrentThread(),
|
||||
NULL /* ?? */
|
||||
);
|
||||
return(STATUS_SUCCESS);
|
||||
KiTestAlert(KeGetCurrentThread(),NULL);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <internal/symbol.h>
|
||||
#include <internal/i386/segment.h>
|
||||
#include <internal/mmhal.h>
|
||||
#include <internal/module.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
@ -131,6 +132,31 @@ EXCEPTION_HANDLER_WITHOUT_ERROR("16",16);
|
|||
|
||||
extern unsigned int stext, etext;
|
||||
|
||||
static void print_address(PVOID address)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
PMODULE_OBJECT current;
|
||||
extern LIST_ENTRY ModuleListHead;
|
||||
|
||||
current_entry = ModuleListHead.Flink;
|
||||
|
||||
while (current_entry != &ModuleListHead)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry, MODULE_OBJECT, ListEntry);
|
||||
|
||||
if (address >= current->Base &&
|
||||
address < (current->Base + current->Length))
|
||||
{
|
||||
DbgPrint("<%w: %x>\n", current->Name,
|
||||
address - current->Base);
|
||||
return;
|
||||
}
|
||||
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
DbgPrint("<%x>\n", address);
|
||||
}
|
||||
|
||||
asmlinkage void exception_handler(unsigned int edi,
|
||||
unsigned int esi, unsigned int ebp,
|
||||
unsigned int esp, unsigned int ebx,
|
||||
|
@ -153,7 +179,8 @@ asmlinkage void exception_handler(unsigned int edi,
|
|||
*/
|
||||
{
|
||||
unsigned int cr2, cr3;
|
||||
unsigned int i, j, sym;
|
||||
unsigned int i;
|
||||
// unsigned int j, sym;
|
||||
unsigned int* stack;
|
||||
static char *TypeStrings[] =
|
||||
{
|
||||
|
@ -213,6 +240,8 @@ asmlinkage void exception_handler(unsigned int edi,
|
|||
DbgPrint("Exception: %d(%x)\n",type,error_code&0xffff);
|
||||
}
|
||||
DbgPrint("CS:EIP %x:%x\n",cs&0xffff,eip);
|
||||
DbgPrint("CS:EIP %x");
|
||||
print_address(eip);
|
||||
__asm__("movl %%cr2,%0\n\t"
|
||||
: "=d" (cr2));
|
||||
__asm__("movl %%cr3,%0\n\t"
|
||||
|
@ -249,7 +278,6 @@ asmlinkage void exception_handler(unsigned int edi,
|
|||
{
|
||||
DbgPrint("kernel ESP %.8x\n",esp);
|
||||
}
|
||||
for(;;);
|
||||
if ((cs & 0xffff) == KERNEL_CS)
|
||||
{
|
||||
DbgPrint("ESP %x\n",esp);
|
||||
|
@ -271,8 +299,8 @@ asmlinkage void exception_handler(unsigned int edi,
|
|||
!(stack[i] >= ((ULONG)&init_stack) &&
|
||||
stack[i] <= ((ULONG)&init_stack_top)))
|
||||
{
|
||||
DbgPrint(" %.8x",
|
||||
stack[i]);
|
||||
// DbgPrint(" %.8x", stack[i]);
|
||||
print_address(stack[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: usercall.c,v 1.1 1999/11/12 12:01:16 dwelch Exp $
|
||||
/* $Id: usercall.c,v 1.2 1999/11/24 11:51:51 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -106,6 +106,16 @@ VOID KiSystemCallHook(ULONG Nr)
|
|||
assert_irql(PASSIVE_LEVEL);
|
||||
}
|
||||
|
||||
ULONG KiAfterSystemCallHook(ULONG NtStatus, PCONTEXT Context)
|
||||
{
|
||||
if (NtStatus != STATUS_USER_APC)
|
||||
{
|
||||
return(NtStatus);
|
||||
}
|
||||
KiTestAlert(KeGetCurrentThread(), Context);
|
||||
return(NtStatus);
|
||||
}
|
||||
|
||||
void interrupt_handler2e(void);
|
||||
__asm__("\n\t.global _interrupt_handler2e\n\t"
|
||||
"_interrupt_handler2e:\n\t"
|
||||
|
@ -175,9 +185,11 @@ void interrupt_handler2e(void);
|
|||
/* Deallocate the kernel stack frame */
|
||||
"movl %ebp,%esp\n\t"
|
||||
|
||||
/* Remove pointer to user context from stack */
|
||||
"addl $4,%esp\n\t"
|
||||
|
||||
/* Call the post system call hook and deliver any pending APCs */
|
||||
"pushl %eax\n\t"
|
||||
"call _KiAfterSystemCallHook\n\t"
|
||||
"addl $8,%esp\n\t"
|
||||
|
||||
/* Restore the user context */
|
||||
"addl $4,%esp\n\t" /* UserContext */
|
||||
"addl $24,%esp\n\t" /* Dr[0-3,6-7] */
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <internal/ke.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
@ -28,9 +28,7 @@ VOID KeInit(VOID)
|
|||
/*
|
||||
* Allow interrupts
|
||||
*/
|
||||
CHECKPOINT;
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
|
||||
CHECKPOINT;
|
||||
KeCalibrateTimerLoop();
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: main.c,v 1.30 1999/11/12 12:01:15 dwelch Exp $
|
||||
/* $Id: main.c,v 1.31 1999/11/24 11:51:50 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -107,6 +107,7 @@ void set_breakpoint(unsigned int i, unsigned int addr, unsigned int type,
|
|||
extern int edata;
|
||||
extern int end;
|
||||
|
||||
#if 0
|
||||
static char * INIData =
|
||||
"[HKEY_LOCAL_MACHINE\\HARDWARE]\r\n"
|
||||
"\r\n"
|
||||
|
@ -121,6 +122,7 @@ static char * INIData =
|
|||
"\r\n"
|
||||
"\r\n"
|
||||
"";
|
||||
#endif
|
||||
|
||||
unsigned int old_idt[256][2];
|
||||
//extern unsigned int idt[];
|
||||
|
@ -128,7 +130,7 @@ unsigned int old_idt_valid = 1;
|
|||
|
||||
ERESOURCE TestResource;
|
||||
|
||||
VOID thread_main(PVOID param)
|
||||
NTSTATUS thread_main(PVOID param)
|
||||
{
|
||||
ULONG Id;
|
||||
|
||||
|
@ -141,6 +143,8 @@ VOID thread_main(PVOID param)
|
|||
ExAcquireResourceExclusiveLite(&TestResource, TRUE);
|
||||
|
||||
DbgPrint("THREAD(%d) Acquired resource for shared access\n", Id);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
VOID resource_test(VOID)
|
||||
|
@ -253,13 +257,14 @@ asmlinkage void _main(boot_param* _bp)
|
|||
DPRINT("ObInit()\n");
|
||||
ObInit();
|
||||
DPRINT("PsInit()\n");
|
||||
PsInit();
|
||||
PiInitProcessManager();
|
||||
DPRINT("IoInit()\n");
|
||||
IoInit();
|
||||
DPRINT("LdrInitModuleManagement()\n");
|
||||
LdrInitModuleManagement();
|
||||
CmInitializeRegistry();
|
||||
|
||||
NtInit();
|
||||
|
||||
memcpy(old_idt, KiIdt, sizeof(old_idt));
|
||||
old_idt_valid = 0;
|
||||
|
||||
|
|
|
@ -35,6 +35,7 @@ LONG KeReleaseMutex(PKMUTEX Mutex, BOOLEAN Wait)
|
|||
KeAcquireDispatcherDatabaseLock(Wait);
|
||||
KeDispatcherObjectWake(&Mutex->Header);
|
||||
KeReleaseDispatcherDatabaseLock(Wait);
|
||||
return(0);
|
||||
}
|
||||
|
||||
NTSTATUS KeWaitForMutexObject(PKMUTEX Mutex,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: timer.c,v 1.20 1999/11/12 12:01:15 dwelch Exp $
|
||||
/* $Id: timer.c,v 1.21 1999/11/24 11:51:50 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -81,8 +81,6 @@ extern ULONG PiNrRunnableThreads;
|
|||
#define CALIBRATE_PERIOD (MICROSECONDS_PER_TICK * TICKS_TO_CALIBRATE)
|
||||
#define SYSTEM_TIME_UNITS_PER_MSEC (10000)
|
||||
|
||||
static unsigned int loops_per_microsecond = 100;
|
||||
|
||||
static BOOLEAN TimerInitDone = FALSE;
|
||||
|
||||
/* FUNCTIONS **************************************************************/
|
||||
|
@ -426,7 +424,7 @@ VOID KiTimerInterrupt(VOID)
|
|||
char* vidmem=(char *)physical_to_linear(0xb8000 + 160 - 36);
|
||||
int i;
|
||||
int x,y;
|
||||
extern ULONG EiNrUsedBlocks;
|
||||
// extern ULONG EiNrUsedBlocks;
|
||||
extern unsigned int EiFreeNonPagedPool;
|
||||
extern unsigned int EiUsedNonPagedPool;
|
||||
extern ULONG MiNrFreePages;
|
||||
|
@ -459,7 +457,8 @@ VOID KiTimerInterrupt(VOID)
|
|||
// (unsigned int)EiFreeNonPagedPool);
|
||||
// sprintf(str,"%.8u %.8u",EiFreeNonPagedPool,EiUsedNonPagedPool);
|
||||
// sprintf(str,"%.8u %.8u",PiNrRunnableThreads,KiTimerTicks);
|
||||
sprintf(str,"%.8u %.8u",PiNrRunnableThreads,MiNrFreePages);
|
||||
sprintf(str,"%.8u %.8u", (unsigned int)PiNrRunnableThreads,
|
||||
(unsigned int)MiNrFreePages);
|
||||
for (i=0;i<17;i++)
|
||||
{
|
||||
*vidmem=str[i];
|
||||
|
@ -467,8 +466,6 @@ VOID KiTimerInterrupt(VOID)
|
|||
*vidmem=0x7;
|
||||
vidmem++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: udelay.c,v 1.1 1999/11/12 12:01:15 dwelch Exp $
|
||||
/* $Id: udelay.c,v 1.2 1999/11/24 11:51:50 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -36,11 +36,11 @@ extern ULONGLONG KiTimerTicks;
|
|||
|
||||
VOID KeCalibrateTimerLoop(VOID)
|
||||
{
|
||||
unsigned int start_tick;
|
||||
// unsigned int start_tick;
|
||||
// unsigned int end_tick;
|
||||
// unsigned int nr_ticks;
|
||||
unsigned int i;
|
||||
unsigned int microseconds;
|
||||
// unsigned int i;
|
||||
// unsigned int microseconds;
|
||||
|
||||
#if 0
|
||||
for (i=0;i<20;i++)
|
||||
|
|
|
@ -179,7 +179,8 @@ static BOOLEAN KeDispatcherObjectWakeAll(DISPATCHER_HEADER* hdr)
|
|||
|
||||
KiSideEffectsBeforeWake(hdr);
|
||||
|
||||
PsResumeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb));
|
||||
PsResumeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb),
|
||||
NULL);
|
||||
};
|
||||
return(TRUE);
|
||||
}
|
||||
|
@ -244,7 +245,8 @@ static BOOLEAN KeDispatcherObjectWakeOne(DISPATCHER_HEADER* hdr)
|
|||
|
||||
KiSideEffectsBeforeWake(hdr);
|
||||
|
||||
PsResumeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb));
|
||||
PsResumeThread(CONTAINING_RECORD(current->Thread,ETHREAD,Tcb),
|
||||
NULL);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
@ -325,12 +327,19 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
|
|||
DISPATCHER_HEADER* hdr = (DISPATCHER_HEADER *)Object;
|
||||
KWAIT_BLOCK blk;
|
||||
PKTHREAD CurrentThread;
|
||||
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("Entering KeWaitForSingleObject(Object %x) "
|
||||
"PsGetCurrentThread() %x\n",Object,PsGetCurrentThread());
|
||||
|
||||
CurrentThread = KeGetCurrentThread();
|
||||
|
||||
|
||||
if (Alertable && !IsListEmpty(&CurrentThread->ApcState.ApcListHead[1]))
|
||||
{
|
||||
DPRINT("Thread is alertable and user APCs are pending\n");
|
||||
return(STATUS_USER_APC);
|
||||
}
|
||||
|
||||
KeAcquireDispatcherDatabaseLock(FALSE);
|
||||
|
||||
DPRINT("hdr->SignalState %d\n", hdr->SignalState);
|
||||
|
@ -360,7 +369,10 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
|
|||
KeReleaseDispatcherDatabaseLock(FALSE);
|
||||
DPRINT("Waiting at %s:%d with irql %d\n", __FILE__, __LINE__,
|
||||
KeGetCurrentIrql());
|
||||
PsSuspendThread(PsGetCurrentThread());
|
||||
PsSuspendThread(PsGetCurrentThread(),
|
||||
&Status,
|
||||
(UCHAR)Alertable,
|
||||
WaitMode);
|
||||
|
||||
if (Timeout != NULL)
|
||||
{
|
||||
|
@ -368,8 +380,16 @@ NTSTATUS KeWaitForSingleObject(PVOID Object,
|
|||
if (KeReadStateTimer(&KeGetCurrentThread()->Timer))
|
||||
return(STATUS_TIMEOUT);
|
||||
}
|
||||
|
||||
if (Alertable &&
|
||||
!IsListEmpty(&CurrentThread->ApcState.ApcListHead[1]))
|
||||
{
|
||||
DPRINT("Current thread is alertable and APCs are pending\n");
|
||||
return(STATUS_USER_APC);
|
||||
}
|
||||
|
||||
DPRINT("Returning from KeWaitForSingleObject()\n");
|
||||
return(STATUS_WAIT_0);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -382,12 +402,13 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
|
|||
PLARGE_INTEGER Timeout,
|
||||
PKWAIT_BLOCK WaitBlockArray)
|
||||
{
|
||||
DISPATCHER_HEADER* hdr;
|
||||
PKWAIT_BLOCK blk;
|
||||
PKTHREAD CurrentThread;
|
||||
ULONG CountSignaled;
|
||||
ULONG i;
|
||||
|
||||
DISPATCHER_HEADER* hdr;
|
||||
PKWAIT_BLOCK blk;
|
||||
PKTHREAD CurrentThread;
|
||||
ULONG CountSignaled;
|
||||
ULONG i;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("Entering KeWaitForMultipleObjects(Count %lu Object[] %p) "
|
||||
"PsGetCurrentThread() %x\n",Count,Object,PsGetCurrentThread());
|
||||
|
||||
|
@ -479,7 +500,10 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
|
|||
|
||||
DPRINT("Waiting at %s:%d with irql %d\n", __FILE__, __LINE__,
|
||||
KeGetCurrentIrql());
|
||||
PsSuspendThread(PsGetCurrentThread());
|
||||
PsSuspendThread(PsGetCurrentThread(),
|
||||
&Status,
|
||||
Alertable,
|
||||
WaitMode);
|
||||
|
||||
if (Timeout != NULL)
|
||||
{
|
||||
|
@ -499,7 +523,7 @@ NTSTATUS KeWaitForMultipleObjects(ULONG Count,
|
|||
}
|
||||
}
|
||||
|
||||
return(STATUS_WAIT_0);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
VOID KeInitializeDispatcher(VOID)
|
||||
|
@ -593,6 +617,8 @@ NTSTATUS STDCALL NtWaitForSingleObject (IN HANDLE Object,
|
|||
|
||||
ObDereferenceObject(ObjectPtr);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
|
||||
static NTSTATUS LdrCreatePeb(HANDLE ProcessHandle)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PVOID PebBase;
|
||||
ULONG PebSize;
|
||||
NT_PEB Peb;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: loader.c,v 1.37 1999/11/02 08:55:41 dwelch Exp $
|
||||
/* $Id: loader.c,v 1.38 1999/11/24 11:51:51 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -44,6 +44,7 @@ NTSTATUS IoInitializeDriver(PDRIVER_INITIALIZE DriverEntry);
|
|||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
LIST_ENTRY ModuleListHead;
|
||||
POBJECT_TYPE ObModuleType = NULL;
|
||||
|
||||
/* FORWARD DECLARATIONS ******************************************************/
|
||||
|
@ -140,9 +141,13 @@ VOID LdrInitModuleManagement(VOID)
|
|||
ObModuleType);
|
||||
assert(ModuleObject != NULL);
|
||||
|
||||
/* Initialize ModuleObject data */
|
||||
InitializeListHead(&ModuleListHead);
|
||||
|
||||
/* Initialize ModuleObject data */
|
||||
ModuleObject->Base = (PVOID) KERNEL_BASE;
|
||||
ModuleObject->Flags = MODULE_FLAG_PE;
|
||||
InsertTailList(&ModuleListHead, &ModuleObject->ListEntry);
|
||||
ModuleObject->Name = wcsdup(L"ntoskrnl.exe");
|
||||
DosHeader = (PIMAGE_DOS_HEADER) KERNEL_BASE;
|
||||
ModuleObject->Image.PE.FileHeader =
|
||||
(PIMAGE_FILE_HEADER) ((DWORD) ModuleObject->Base +
|
||||
|
@ -154,7 +159,8 @@ VOID LdrInitModuleManagement(VOID)
|
|||
ModuleObject->EntryPoint = (PVOID) ((DWORD) ModuleObject->Base +
|
||||
ModuleObject->Image.PE.OptionalHeader->AddressOfEntryPoint);
|
||||
DPRINT("ModuleObject:%08x entrypoint at %x\n", ModuleObject, ModuleObject->EntryPoint);
|
||||
|
||||
ModuleObject->Length = ModuleObject->Image.PE.OptionalHeader->SizeOfImage;
|
||||
|
||||
/* FIXME: Add fake module entry for HAL */
|
||||
|
||||
}
|
||||
|
@ -546,8 +552,8 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
|
|||
DPRINT1("Module is at base %x\n",DriverBase);
|
||||
|
||||
/* Copy image sections into virtual section */
|
||||
memcpy(DriverBase, ModuleLoadBase, PESectionHeaders[0].PointerToRawData);
|
||||
CurrentBase = (PVOID) ((DWORD)DriverBase + PESectionHeaders[0].PointerToRawData);
|
||||
// memcpy(DriverBase, ModuleLoadBase, PESectionHeaders[0].PointerToRawData);
|
||||
// CurrentBase = (PVOID) ((DWORD)DriverBase + PESectionHeaders[0].PointerToRawData);
|
||||
CurrentSize = 0;
|
||||
for (Idx = 0; Idx < PEFileHeader->NumberOfSections; Idx++)
|
||||
{
|
||||
|
@ -570,9 +576,9 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
|
|||
}
|
||||
CurrentSize += ROUND_UP(PESectionHeaders[Idx].SizeOfRawData,
|
||||
PEOptionalHeader->SectionAlignment);
|
||||
CurrentBase = (PVOID)((DWORD)CurrentBase +
|
||||
ROUND_UP(PESectionHeaders[Idx].SizeOfRawData,
|
||||
PEOptionalHeader->SectionAlignment));
|
||||
// CurrentBase = (PVOID)((DWORD)CurrentBase +
|
||||
// ROUND_UP(PESectionHeaders[Idx].SizeOfRawData,
|
||||
// PEOptionalHeader->SectionAlignment));
|
||||
}
|
||||
|
||||
/* Perform relocation fixups */
|
||||
|
@ -778,8 +784,11 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
|
|||
/* Initialize ModuleObject data */
|
||||
ModuleObject->Base = DriverBase;
|
||||
ModuleObject->Flags = MODULE_FLAG_PE;
|
||||
InsertTailList(&ModuleListHead, &ModuleObject->ListEntry);
|
||||
ModuleObject->Name = wcsdup(NameBuffer);
|
||||
ModuleObject->EntryPoint = (PVOID) ((DWORD)DriverBase +
|
||||
PEOptionalHeader->AddressOfEntryPoint);
|
||||
ModuleObject->Length = DriverSize;
|
||||
DPRINT("entrypoint at %x\n", ModuleObject->EntryPoint);
|
||||
ModuleObject->Image.PE.FileHeader =
|
||||
(PIMAGE_FILE_HEADER) ((unsigned int) DriverBase +
|
||||
|
|
|
@ -135,6 +135,20 @@ ULONG MmGetPageEntryForProcess(PEPROCESS Process, PVOID Address)
|
|||
return(Entry);
|
||||
}
|
||||
|
||||
ULONG MmGetPhysicalAddressForProcess(PEPROCESS Process,
|
||||
PVOID Address)
|
||||
{
|
||||
ULONG PageEntry;
|
||||
|
||||
PageEntry = MmGetPageEntryForProcess(Process, Address);
|
||||
|
||||
if (!(PageEntry & PA_PRESENT))
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
return(PAGE_MASK(PageEntry));
|
||||
}
|
||||
|
||||
VOID MmDeletePageEntry(PEPROCESS Process, PVOID Address, BOOL FreePage)
|
||||
{
|
||||
PULONG page_tlb;
|
||||
|
@ -167,6 +181,7 @@ VOID MmDeletePageEntry(PEPROCESS Process, PVOID Address, BOOL FreePage)
|
|||
}
|
||||
|
||||
|
||||
|
||||
PULONG MmGetPageEntry(PVOID PAddress)
|
||||
/*
|
||||
* FUNCTION: Get a pointer to the page table entry for a virtual address
|
||||
|
|
|
@ -487,6 +487,7 @@ PMEMORY_AREA MmSplitMemoryArea(PEPROCESS Process,
|
|||
Result->Length=Length;
|
||||
Result->Attributes=NewAttributes;
|
||||
Result->LockCount=0;
|
||||
Result->Process = Process;
|
||||
|
||||
MmLockMemoryAreaList(OriginalMemoryArea->BaseAddress,&oldlvl);
|
||||
|
||||
|
@ -596,6 +597,7 @@ NTSTATUS MmCreateMemoryArea(KPROCESSOR_MODE Mode,
|
|||
(*Result)->Length=Length;
|
||||
(*Result)->Attributes=Attributes;
|
||||
(*Result)->LockCount=0;
|
||||
(*Result)->Process = Process;
|
||||
|
||||
MmInsertMemoryAreaWithoutLock(Process,*Result);
|
||||
MmUnlockMemoryAreaList(*BaseAddress,&oldlvl);
|
||||
|
|
|
@ -123,7 +123,7 @@ VOID MmBuildMdlFromPages(PMDL Mdl)
|
|||
|
||||
for (i=0;i<(PAGE_ROUND_UP(Mdl->ByteOffset+Mdl->ByteCount)/PAGESIZE);i++)
|
||||
{
|
||||
mdl_pages[i] = MmAllocPage();
|
||||
mdl_pages[i] = (ULONG)MmAllocPage();
|
||||
DPRINT("mdl_pages[i] %x\n",mdl_pages[i]);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,10 @@ static KSPIN_LOCK MiPageFaultLock;
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
VOID MiShutdownMemoryManager(VOID)
|
||||
{
|
||||
}
|
||||
|
||||
VOID MmInitVirtualMemory(boot_param* bp)
|
||||
/*
|
||||
* FUNCTION: Intialize the memory areas list
|
||||
|
@ -137,23 +141,41 @@ NTSTATUS MmSectionHandleFault(MEMORY_AREA* MemoryArea, PVOID Address)
|
|||
|
||||
DPRINT("MmSectionHandleFault(MemoryArea %x, Address %x)\n",
|
||||
MemoryArea,Address);
|
||||
|
||||
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
|
||||
MmBuildMdlFromPages(Mdl);
|
||||
|
||||
Page = MmGetMdlPageAddress(Mdl, 0);
|
||||
|
||||
|
||||
Offset.QuadPart = (Address - MemoryArea->BaseAddress) +
|
||||
MemoryArea->Data.SectionData.ViewOffset;
|
||||
|
||||
DPRINT("MemoryArea->Data.SectionData.Section->FileObject %x\n",
|
||||
MemoryArea->Data.SectionData.Section->FileObject);
|
||||
DPRINT("MemoryArea->Data.SectionData.ViewOffset %x\n",
|
||||
MemoryArea->Data.SectionData.ViewOffset);
|
||||
DPRINT("Offset.QuadPart %x\n", (ULONG)Offset.QuadPart);
|
||||
DPRINT("MemoryArea->BaseAddress %x\n", MemoryArea->BaseAddress);
|
||||
|
||||
if (MemoryArea->Data.SectionData.Section->FileObject == NULL)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
ULONG Page;
|
||||
|
||||
Page = MiTryToSharePageInSection(MemoryArea->Data.SectionData.Section,
|
||||
(ULONG)Offset.QuadPart);
|
||||
|
||||
if (Page == 0)
|
||||
{
|
||||
Page = (ULONG)MmAllocPage();
|
||||
}
|
||||
|
||||
MmSetPage(PsGetCurrentProcess(),
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
Page);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
|
||||
MmBuildMdlFromPages(Mdl);
|
||||
|
||||
Page = MmGetMdlPageAddress(Mdl, 0);
|
||||
|
||||
IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||
Mdl,
|
||||
&Offset,
|
||||
|
|
|
@ -137,7 +137,7 @@ VOID ExInitNonPagedPool(ULONG BaseAddress)
|
|||
KeInitializeSpinLock(&AllocMapLock);
|
||||
}
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
static void validate_free_list(void)
|
||||
/*
|
||||
* FUNCTION: Validate the integrity of the list of free blocks
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: section.c,v 1.15 1999/11/12 12:01:16 dwelch Exp $
|
||||
/* $Id: section.c,v 1.16 1999/11/24 11:51:52 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -27,6 +27,46 @@ POBJECT_TYPE MmSectionType = NULL;
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
PVOID MiTryToSharePageInSection(PSECTION_OBJECT Section,
|
||||
ULONG Offset)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
PLIST_ENTRY current_entry;
|
||||
PMEMORY_AREA current;
|
||||
PVOID Address;
|
||||
ULONG PhysPage;
|
||||
|
||||
DPRINT("MiTryToSharePageInSection(Section %x, Offset %x)\n",
|
||||
Section, Offset);
|
||||
|
||||
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
||||
|
||||
current_entry = Section->ViewListHead.Flink;
|
||||
|
||||
while (current_entry != &Section->ViewListHead)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry, MEMORY_AREA,
|
||||
Data.SectionData.ViewListEntry);
|
||||
|
||||
if (current->Data.SectionData.ViewOffset <= Offset &&
|
||||
(current->Data.SectionData.ViewOffset + current->Length) >= Offset)
|
||||
{
|
||||
Address = current->BaseAddress +
|
||||
(Offset - current->Data.SectionData.ViewOffset);
|
||||
|
||||
PhysPage = MmGetPhysicalAddressForProcess(current->Process,
|
||||
Address);
|
||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||
return((PVOID)PhysPage);
|
||||
}
|
||||
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
VOID MmpDeleteSection(PVOID ObjectBody)
|
||||
{
|
||||
}
|
||||
|
@ -95,17 +135,13 @@ NTSTATUS MmInitSectionImplementation(VOID)
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCreateSection (
|
||||
OUT PHANDLE SectionHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
|
||||
IN PLARGE_INTEGER MaximumSize OPTIONAL,
|
||||
IN ULONG SectionPageProtection OPTIONAL,
|
||||
IN ULONG AllocationAttributes,
|
||||
IN HANDLE FileHandle OPTIONAL
|
||||
)
|
||||
NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
|
||||
IN PLARGE_INTEGER MaximumSize OPTIONAL,
|
||||
IN ULONG SectionPageProtection OPTIONAL,
|
||||
IN ULONG AllocationAttributes,
|
||||
IN HANDLE FileHandle OPTIONAL)
|
||||
/*
|
||||
* FUNCTION: Creates a section object.
|
||||
* ARGUMENTS:
|
||||
|
@ -155,6 +191,8 @@ NtCreateSection (
|
|||
}
|
||||
Section->SectionPageProtection = SectionPageProtection;
|
||||
Section->AllocateAttributes = AllocationAttributes;
|
||||
InitializeListHead(&Section->ViewListHead);
|
||||
KeInitializeSpinLock(&Section->ViewListLock);
|
||||
|
||||
if (FileHandle != NULL)
|
||||
{
|
||||
|
@ -166,6 +204,7 @@ NtCreateSection (
|
|||
NULL);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
// Delete section object
|
||||
DPRINT("NtCreateSection() = %x\n",Status);
|
||||
return(Status);
|
||||
}
|
||||
|
@ -198,42 +237,35 @@ NtCreateSection (
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtOpenSection (
|
||||
PHANDLE SectionHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes
|
||||
)
|
||||
NTSTATUS STDCALL NtOpenSection(PHANDLE SectionHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
PVOID Object;
|
||||
NTSTATUS Status;
|
||||
PVOID Object;
|
||||
NTSTATUS Status;
|
||||
|
||||
*SectionHandle = 0;
|
||||
*SectionHandle = 0;
|
||||
|
||||
Status = ObReferenceObjectByName(
|
||||
ObjectAttributes->ObjectName,
|
||||
ObjectAttributes->Attributes,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
MmSectionType,
|
||||
UserMode,
|
||||
NULL,
|
||||
& Object
|
||||
);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = ObCreateHandle(
|
||||
PsGetCurrentProcess(),
|
||||
Object,
|
||||
DesiredAccess,
|
||||
FALSE,
|
||||
SectionHandle
|
||||
);
|
||||
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
|
||||
ObjectAttributes->Attributes,
|
||||
NULL,
|
||||
DesiredAccess,
|
||||
MmSectionType,
|
||||
UserMode,
|
||||
NULL,
|
||||
&Object);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = ObCreateHandle(PsGetCurrentProcess(),
|
||||
Object,
|
||||
DesiredAccess,
|
||||
FALSE,
|
||||
SectionHandle);
|
||||
ObDereferenceObject(Object);
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -284,123 +316,126 @@ NtOpenSection (
|
|||
* RETURN VALUE
|
||||
* Status.
|
||||
*/
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtMapViewOfSection (
|
||||
HANDLE SectionHandle,
|
||||
HANDLE ProcessHandle,
|
||||
PVOID * BaseAddress,
|
||||
ULONG ZeroBits,
|
||||
ULONG CommitSize,
|
||||
PLARGE_INTEGER SectionOffset,
|
||||
PULONG ViewSize,
|
||||
SECTION_INHERIT InheritDisposition,
|
||||
ULONG AllocationType,
|
||||
ULONG Protect
|
||||
)
|
||||
NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
||||
HANDLE ProcessHandle,
|
||||
PVOID* BaseAddress,
|
||||
ULONG ZeroBits,
|
||||
ULONG CommitSize,
|
||||
PLARGE_INTEGER SectionOffset,
|
||||
PULONG ViewSize,
|
||||
SECTION_INHERIT InheritDisposition,
|
||||
ULONG AllocationType,
|
||||
ULONG Protect)
|
||||
{
|
||||
PSECTION_OBJECT Section;
|
||||
PEPROCESS Process;
|
||||
MEMORY_AREA * Result;
|
||||
NTSTATUS Status;
|
||||
PSECTION_OBJECT Section;
|
||||
PEPROCESS Process;
|
||||
MEMORY_AREA * Result;
|
||||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
ULONG ViewOffset;
|
||||
|
||||
DPRINT(
|
||||
"NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
|
||||
" Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
|
||||
" SectionOffs:%08lx, *ViewSize:%08lx, InheritDisp:%08lx,\n"
|
||||
" AllocType:%08lx, Protect:%08lx)\n",
|
||||
SectionHandle,
|
||||
ProcessHandle,
|
||||
BaseAddress,
|
||||
ZeroBits,
|
||||
CommitSize,
|
||||
SectionOffset,
|
||||
*ViewSize,
|
||||
InheritDisposition,
|
||||
AllocationType,
|
||||
Protect
|
||||
);
|
||||
DPRINT("NtMapViewOfSection(Section:%08lx, Process:%08lx,\n"
|
||||
" Base:%08lx, ZeroBits:%08lx, CommitSize:%08lx,\n"
|
||||
" SectionOffs:%08lx, *ViewSize:%08lx, InheritDisp:%08lx,\n"
|
||||
" AllocType:%08lx, Protect:%08lx)\n",
|
||||
SectionHandle, ProcessHandle, BaseAddress, ZeroBits,
|
||||
CommitSize, SectionOffset, *ViewSize, InheritDisposition,
|
||||
AllocationType, Protect);
|
||||
|
||||
DPRINT(" *Base:%08lx\n", *BaseAddress);
|
||||
DPRINT(" *Base:%08lx\n", *BaseAddress);
|
||||
|
||||
Status = ObReferenceObjectByHandle(
|
||||
SectionHandle,
|
||||
SECTION_MAP_READ,
|
||||
MmSectionType,
|
||||
UserMode,
|
||||
(PVOID *) & Section,
|
||||
NULL
|
||||
);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
Status = ObReferenceObjectByHandle(SectionHandle,
|
||||
SECTION_MAP_READ,
|
||||
MmSectionType,
|
||||
UserMode,
|
||||
(PVOID*)&Section,
|
||||
NULL);
|
||||
if (!(NT_SUCCESS(Status)))
|
||||
{
|
||||
DPRINT("ObReference failed rc=%x\n",Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("Section %x\n",Section);
|
||||
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_VM_OPERATION,
|
||||
PsProcessType,
|
||||
UserMode,
|
||||
(PVOID*)&Process,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ObDereferenceObject(Section);
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("Process %x\n", Process);
|
||||
DPRINT("ViewSize %x\n",ViewSize);
|
||||
|
||||
if (SectionOffset == NULL)
|
||||
{
|
||||
ViewOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
ViewOffset = SectionOffset->u.LowPart;
|
||||
}
|
||||
|
||||
if (((*ViewSize)+ViewOffset) > Section->MaximumSize.u.LowPart)
|
||||
{
|
||||
DPRINT("ObReference failed rc=%x\n",Status);
|
||||
|
||||
return Status;
|
||||
(*ViewSize) = Section->MaximumSize.u.LowPart - ViewOffset;
|
||||
}
|
||||
|
||||
DPRINT("Section %x\n",Section);
|
||||
|
||||
Status = ObReferenceObjectByHandle(
|
||||
ProcessHandle,
|
||||
PROCESS_VM_OPERATION,
|
||||
PsProcessType,
|
||||
UserMode,
|
||||
(PVOID *) & Process,
|
||||
NULL
|
||||
);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
ObDereferenceObject(Section);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("ViewSize %x\n",ViewSize);
|
||||
|
||||
if ((*ViewSize) > Section->MaximumSize.u.LowPart)
|
||||
{
|
||||
(*ViewSize) = Section->MaximumSize.u.LowPart;
|
||||
}
|
||||
|
||||
Status = MmCreateMemoryArea(
|
||||
UserMode,
|
||||
Process,
|
||||
MEMORY_AREA_SECTION_VIEW_COMMIT,
|
||||
BaseAddress,
|
||||
*ViewSize,
|
||||
Protect,
|
||||
& Result
|
||||
);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("NtMapViewOfSection() = %x\n",Status);
|
||||
|
||||
ObDereferenceObject(Process);
|
||||
ObDereferenceObject(Section);
|
||||
|
||||
return Status;
|
||||
}
|
||||
Result->Data.SectionData.Section = Section;
|
||||
|
||||
DPRINT("SectionOffset %x\n",SectionOffset);
|
||||
|
||||
if (SectionOffset == NULL)
|
||||
{
|
||||
Result->Data.SectionData.ViewOffset = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Result->Data.SectionData.ViewOffset =
|
||||
SectionOffset->u.LowPart;
|
||||
}
|
||||
|
||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||
ObDereferenceObject(Process);
|
||||
DPRINT("Creating memory area\n");
|
||||
Status = MmCreateMemoryArea(UserMode,
|
||||
Process,
|
||||
MEMORY_AREA_SECTION_VIEW_COMMIT,
|
||||
BaseAddress,
|
||||
*ViewSize,
|
||||
Protect,
|
||||
&Result);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("NtMapViewOfSection() = %x\n",Status);
|
||||
|
||||
ObDereferenceObject(Process);
|
||||
ObDereferenceObject(Section);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
return Status;
|
||||
}
|
||||
|
||||
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
||||
InsertTailList(&Section->ViewListHead,
|
||||
&Result->Data.SectionData.ViewListEntry);
|
||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||
|
||||
Result->Data.SectionData.Section = Section;
|
||||
Result->Data.SectionData.ViewOffset = ViewOffset;
|
||||
|
||||
DPRINT("SectionOffset %x\n",SectionOffset);
|
||||
|
||||
|
||||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||
ObDereferenceObject(Process);
|
||||
ObDereferenceObject(Section);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MmUnmapViewOfSection(PEPROCESS Process,
|
||||
PMEMORY_AREA MemoryArea)
|
||||
{
|
||||
PSECTION_OBJECT Section;
|
||||
KIRQL oldIrql;
|
||||
|
||||
Section = MemoryArea->Data.SectionData.Section;
|
||||
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
||||
RemoveEntryList(&MemoryArea->Data.SectionData.ViewListEntry);
|
||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* NAME EXPORTED
|
||||
|
@ -419,49 +454,45 @@ NtMapViewOfSection (
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtUnmapViewOfSection (
|
||||
HANDLE ProcessHandle,
|
||||
PVOID BaseAddress
|
||||
)
|
||||
NTSTATUS STDCALL NtUnmapViewOfSection (HANDLE ProcessHandle,
|
||||
PVOID BaseAddress)
|
||||
{
|
||||
PEPROCESS Process;
|
||||
NTSTATUS Status;
|
||||
PEPROCESS Process;
|
||||
NTSTATUS Status;
|
||||
PMEMORY_AREA MemoryArea;
|
||||
|
||||
Status = ObReferenceObjectByHandle(
|
||||
ProcessHandle,
|
||||
PROCESS_VM_OPERATION,
|
||||
PsProcessType,
|
||||
UserMode,
|
||||
(PVOID *) & Process,
|
||||
NULL
|
||||
);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
Status = MmFreeMemoryArea(
|
||||
Process,
|
||||
BaseAddress,
|
||||
0,
|
||||
TRUE
|
||||
);
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_VM_OPERATION,
|
||||
PsProcessType,
|
||||
UserMode,
|
||||
(PVOID*)&Process,
|
||||
NULL);
|
||||
|
||||
MemoryArea = MmOpenMemoryAreaByAddress(Process, BaseAddress);
|
||||
if (MemoryArea == NULL)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
Status = MmUnmapViewOfSection(Process, MemoryArea);
|
||||
|
||||
Status = MmFreeMemoryArea(Process,
|
||||
BaseAddress,
|
||||
0,
|
||||
TRUE);
|
||||
|
||||
ObDereferenceObject(Process);
|
||||
|
||||
return Status;
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtQuerySection (
|
||||
IN HANDLE SectionHandle,
|
||||
IN CINT SectionInformationClass,
|
||||
OUT PVOID SectionInformation,
|
||||
IN ULONG Length,
|
||||
OUT PULONG ResultLength
|
||||
)
|
||||
NTSTATUS STDCALL NtQuerySection (IN HANDLE SectionHandle,
|
||||
IN CINT SectionInformationClass,
|
||||
OUT PVOID SectionInformation,
|
||||
IN ULONG Length,
|
||||
OUT PULONG ResultLength)
|
||||
/*
|
||||
* FUNCTION: Queries the information of a section object.
|
||||
* ARGUMENTS:
|
||||
|
@ -475,18 +506,14 @@ NtQuerySection (
|
|||
*
|
||||
*/
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtExtendSection (
|
||||
IN HANDLE SectionHandle,
|
||||
IN ULONG NewMaximumSize
|
||||
)
|
||||
NTSTATUS STDCALL NtExtendSection(IN HANDLE SectionHandle,
|
||||
IN ULONG NewMaximumSize)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,13 @@ NTSTATUS MmReleaseMemoryArea(PEPROCESS Process, PMEMORY_AREA Marea)
|
|||
|
||||
DPRINT("Releasing %x between %x %x\n",
|
||||
Marea, Marea->BaseAddress, Marea->BaseAddress + Marea->Length);
|
||||
|
||||
if (Marea->Type == MEMORY_AREA_SECTION_VIEW_COMMIT ||
|
||||
Marea->Type == MEMORY_AREA_SECTION_VIEW_RESERVE)
|
||||
{
|
||||
MmUnmapViewOfSection(Process, Marea);
|
||||
}
|
||||
|
||||
for (i = Marea->BaseAddress;
|
||||
i < (Marea->BaseAddress + Marea->Length);
|
||||
i = i+PAGESIZE)
|
||||
|
|
|
@ -46,9 +46,7 @@ VOID NtInitializeEventImplementation(VOID)
|
|||
ExEventType->OkayToClose = NULL;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtClearEvent (IN HANDLE EventHandle)
|
||||
NTSTATUS STDCALL NtClearEvent (IN HANDLE EventHandle)
|
||||
{
|
||||
PKEVENT Event;
|
||||
NTSTATUS Status;
|
||||
|
@ -69,15 +67,11 @@ NtClearEvent (IN HANDLE EventHandle)
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCreateEvent (
|
||||
OUT PHANDLE EventHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN BOOLEAN ManualReset,
|
||||
IN BOOLEAN InitialState
|
||||
)
|
||||
NTSTATUS STDCALL NtCreateEvent (OUT PHANDLE EventHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
IN BOOLEAN ManualReset,
|
||||
IN BOOLEAN InitialState)
|
||||
{
|
||||
PKEVENT Event;
|
||||
|
||||
|
@ -97,13 +91,9 @@ NtCreateEvent (
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtOpenEvent (
|
||||
OUT PHANDLE EventHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes
|
||||
)
|
||||
NTSTATUS STDCALL NtOpenEvent (OUT PHANDLE EventHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PKEVENT Event;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: port.c,v 1.8 1999/10/16 12:38:53 ekohl Exp $
|
||||
/* $Id: port.c,v 1.9 1999/11/24 11:51:53 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -29,23 +29,28 @@
|
|||
|
||||
/* TYPES ********************************************************************/
|
||||
|
||||
struct _EPORT;
|
||||
#define EPORT_WAIT_FOR_CONNECT (1)
|
||||
#define EPORT_WAIT_FOR_ACCEPT (2)
|
||||
#define EPORT_WAIT_FOR_COMPLETE (3)
|
||||
#define EPORT_CONNECTED (4)
|
||||
|
||||
typedef struct _PORT_MSG
|
||||
typedef struct _QUEUED_MESSAGE
|
||||
{
|
||||
ULONG DataLength;
|
||||
PVOID Data;
|
||||
LIST_ENTRY ListEntry;
|
||||
struct _EPORT* ReplyPort;
|
||||
PMDL Mdl;
|
||||
} EPORT_MSG, *PEPORT_MSG;
|
||||
LPC_MESSAGE_TYPE Type;
|
||||
ULONG Length;
|
||||
PVOID Buffer;
|
||||
DWORD Flags;
|
||||
PEPROCESS Sender;
|
||||
PMDL BufferMdl;
|
||||
} QUEUED_MESSAGE, *PQUEUED_MESSAGE;
|
||||
|
||||
typedef struct _EPORT
|
||||
{
|
||||
PEPROCESS Owner;
|
||||
LIST_ENTRY MsgQueueHead;
|
||||
KEVENT MsgNotify;
|
||||
KSPIN_LOCK PortLock;
|
||||
KSPIN_LOCK Lock;
|
||||
ULONG State;
|
||||
KEVENT Event;
|
||||
struct _EPORT* ForeignPort;
|
||||
QUEUED_MESSAGE Msg;
|
||||
} EPORT, *PEPORT;
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
@ -53,7 +58,8 @@ typedef struct _EPORT
|
|||
POBJECT_TYPE ExPortType = NULL;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
#ifndef PROTO_LPC
|
||||
|
||||
|
||||
NTSTATUS NiInitPort(VOID)
|
||||
{
|
||||
ExPortType = ExAllocatePool(NonPagedPool,sizeof(OBJECT_TYPE));
|
||||
|
@ -78,9 +84,6 @@ NTSTATUS NiInitPort(VOID)
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
//NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
||||
// ACCESS_MASK DesiredAccess,
|
||||
// POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
||||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
|
@ -97,141 +100,152 @@ NTSTATUS STDCALL NtCreatePort(PHANDLE PortHandle,
|
|||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
InitializeListHead(&Port->MsgQueueHead);
|
||||
KeInitializeEvent(&Port->MsgNotify, NotificationEvent, FALSE);
|
||||
KeInitializeSpinLock(&Port->PortLock);
|
||||
Port->Owner = PsGetCurrentProcess();
|
||||
|
||||
KeInitializeSpinLock(&Port->Lock);
|
||||
KeInitializeEvent(&Port->Event, NotificationEvent, FALSE);
|
||||
Port->State = EPORT_WAIT_FOR_CONNECT;
|
||||
Port->ForeignPort = NULL;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtAcceptConnectPort(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtCompleteConnectPort(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtConnectPort(PHANDLE PortHandle,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
NTSTATUS STDCALL NtAcceptConnectPort (IN HANDLE PortHandle,
|
||||
OUT PHANDLE ConnectedPort,
|
||||
DWORD a2,
|
||||
DWORD a3,
|
||||
DWORD a4,
|
||||
DWORD a5)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PEPORT Port;
|
||||
PEPORT Port;
|
||||
|
||||
Status = ObReferenceObjectByHandle(PortHandle,
|
||||
0, /* AccessRequired */
|
||||
ExPortType,
|
||||
UserMode,
|
||||
(PVOID*)&Port,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
if (Port->State != EPORT_WAIT_FOR_ACCEPT)
|
||||
{
|
||||
return(STATUS_INVALID_PARAMETER);
|
||||
}
|
||||
|
||||
Status = ObCreateHandle(PsGetCurrentProcess(),
|
||||
Port->ForeignPort,
|
||||
0, /* DesiredAccess */
|
||||
FALSE,
|
||||
ConnectedPort);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
KeSetEvent(&Port->ForeignPort->Event, IO_NO_INCREMENT, FALSE);
|
||||
|
||||
Port->ForeignPort->State = EPORT_WAIT_FOR_COMPLETE;
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
|
||||
ObjectAttributes->Attributes,
|
||||
|
||||
NTSTATUS STDCALL NtCompleteConnectPort (HANDLE PortHandle)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PEPORT Port;
|
||||
|
||||
Status = ObReferenceObjectByHandle(PortHandle,
|
||||
0, /* AccessRequired */
|
||||
ExPortType,
|
||||
UserMode,
|
||||
(PVOID*)&Port,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
Port->ForeignPort->State = EPORT_CONNECTED;
|
||||
Port->State = EPORT_CONNECTED;
|
||||
|
||||
KeSetEvent(&Port->ForeignPort->Event, IO_NO_INCREMENT, FALSE);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort,
|
||||
IN PUNICODE_STRING PortName,
|
||||
IN POBJECT_ATTRIBUTES PortAttributes,
|
||||
IN DWORD a3,
|
||||
IN DWORD a4,
|
||||
IN DWORD a5,
|
||||
IN DWORD a6,
|
||||
IN ULONG Flags)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PEPORT ForeignPort;
|
||||
PEPORT Port;
|
||||
|
||||
Status = ObReferenceObjectByName(PortName,
|
||||
0,
|
||||
NULL,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
0, /* DesiredAccess */
|
||||
ExPortType,
|
||||
UserMode,
|
||||
NULL,
|
||||
(PVOID*)&Port);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
Status = ObCreateHandle(PsGetCurrentProcess(),
|
||||
Port,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
FALSE,
|
||||
PortHandle);
|
||||
ObDereferenceObject(Port);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtListenPort(HANDLE PortHandle,
|
||||
PLARGE_INTEGER Timeout,
|
||||
PPORT_MSG_DATA Msg)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PEPORT Port;
|
||||
KIRQL oldIrql;
|
||||
PEPORT_MSG KMsg;
|
||||
PVOID Data;
|
||||
|
||||
Status = ObReferenceObjectByHandle(PortHandle,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
ExPortType,
|
||||
UserMode,
|
||||
(PVOID*)&Port,
|
||||
NULL);
|
||||
(PVOID*)&ForeignPort);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
Status = KeWaitForSingleObject(&Port->MsgNotify, 0,
|
||||
KernelMode, FALSE, Timeout);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
KeAcquireSpinLock(&Port->PortLock, &oldIrql);
|
||||
KMsg = CONTAINING_RECORD(RemoveHeadList(&Port->MsgQueueHead),
|
||||
EPORT_MSG,
|
||||
ListEntry);
|
||||
KeReleaseSpinLock(&Port->PortLock, oldIrql);
|
||||
|
||||
if (KMsg->DataLength > Msg->DataLength)
|
||||
if (ForeignPort->State != EPORT_WAIT_FOR_CONNECT)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
Msg->DataLength = KMsg->DataLength;
|
||||
Data = MmGetSystemAddressForMdl(KMsg->Mdl);
|
||||
memcpy(Msg->Data, Data, KMsg->DataLength);
|
||||
MmUnmapLockedPages(Data, KMsg->Mdl);
|
||||
Status = ObCreateHandle(PsGetCurrentProcess(),
|
||||
KMsg->ReplyPort,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
FALSE,
|
||||
&Msg->ReplyPort);
|
||||
ObDereferenceObject(PortHandle);
|
||||
return(Status);
|
||||
|
||||
Port = ObCreateObject(ConnectedPort,
|
||||
0, /* DesiredAccess */
|
||||
PortAttributes,
|
||||
ExPortType);
|
||||
if (Port == NULL)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
KeInitializeSpinLock(&Port->Lock);
|
||||
KeInitializeEvent(&Port->Event, NotificationEvent, FALSE);
|
||||
Port->State = EPORT_WAIT_FOR_ACCEPT;
|
||||
Port->ForeignPort = ForeignPort;
|
||||
|
||||
ForeignPort->State = EPORT_WAIT_FOR_ACCEPT;
|
||||
|
||||
KeSetEvent(&ForeignPort->Event, IO_NO_INCREMENT, FALSE);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtReplyPort(VOID)
|
||||
|
||||
NTSTATUS STDCALL NtImpersonateClientOfPort (IN HANDLE PortHandle,
|
||||
IN PCLIENT_ID ClientId)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtReplyWaitReceivePort(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtReplyWaitReplyPort(VOID)
|
||||
NTSTATUS STDCALL NtListenPort (IN HANDLE PortHandle,
|
||||
IN DWORD QueueSize /* guess */)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtRequestPort(HANDLE PortHandle,
|
||||
ULONG DataLength,
|
||||
PVOID Data,
|
||||
ULONG Options,
|
||||
PHANDLE ReplyPortHandle)
|
||||
/*
|
||||
* FUNCTION: Send a request to a port
|
||||
* ARGUMENTS:
|
||||
* PortHandle = Handle to the destination port
|
||||
* DataLength = Length of the data to send
|
||||
* Data = Data to send
|
||||
* Option = Send options
|
||||
* ReplyPortHandle = Optional port for reply
|
||||
*/
|
||||
{
|
||||
PEPORT Port;
|
||||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
PEPORT_MSG Msg;
|
||||
PEPORT Port;
|
||||
|
||||
Status = ObReferenceObjectByHandle(PortHandle,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
0, /* AccessRequired */
|
||||
ExPortType,
|
||||
UserMode,
|
||||
(PVOID*)&Port,
|
||||
|
@ -241,216 +255,89 @@ NTSTATUS STDCALL NtRequestPort(HANDLE PortHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
Msg = ExAllocatePool(NonPagedPool, sizeof(EPORT_MSG));
|
||||
Msg->DataLength = DataLength;
|
||||
Msg->Mdl = MmCreateMdl(NULL,
|
||||
Data,
|
||||
Msg->DataLength);
|
||||
MmProbeAndLockPages(Msg->Mdl,
|
||||
UserMode,
|
||||
IoReadAccess);
|
||||
Status = KeWaitForSingleObject(&Port->Event,
|
||||
UserRequest,
|
||||
UserMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
|
||||
if (ReplyPortHandle != NULL)
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtQueryInformationPort (IN HANDLE PortHandle,
|
||||
IN CINT PortInformationClass, /* guess */
|
||||
OUT PVOID PortInformation, /* guess */
|
||||
IN ULONG PortInformationLength, /* guess */
|
||||
OUT PULONG ReturnLength /* guess */)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtReplyPort (IN HANDLE PortHandle,
|
||||
IN PLPC_REPLY LpcReply /* guess */)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtReplyWaitReceivePort ( IN HANDLE PortHandle,
|
||||
IN PLPC_REPLY LpcReply, /* guess */
|
||||
OUT PLPC_MESSAGE LpcMessage, /* guess */
|
||||
OUT PULONG MessageLength /* guess */)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtReplyWaitReplyPort (IN HANDLE PortHandle,
|
||||
IN OUT PLPC_REPLY LpcReply /* guess */)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle,
|
||||
IN PLPC_MESSAGE LpcMessage /* guess */)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PEPORT Port;
|
||||
|
||||
Status = ObReferenceObjectByHandle(PortHandle,
|
||||
0, /* AccessRequired */
|
||||
ExPortType,
|
||||
UserMode,
|
||||
(PVOID*)&Port,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
NtCreatePort(ReplyPortHandle,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
NULL,
|
||||
0,
|
||||
0);
|
||||
Status = ObReferenceObjectByHandle(*ReplyPortHandle,
|
||||
STANDARD_RIGHTS_REQUIRED,
|
||||
ExPortType,
|
||||
UserMode,
|
||||
(PVOID*)&Msg->ReplyPort,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
ExFreePool(Msg);
|
||||
return(Status);
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
KeAcquireSpinLock(&Port->PortLock, &oldIrql);
|
||||
InsertHeadList(&Port->MsgQueueHead, &Msg->ListEntry);
|
||||
KeReleaseSpinLock(&Port->PortLock, oldIrql);
|
||||
KeSetEvent(&Port->MsgNotify, 0, FALSE);
|
||||
Port->Msg.Type = LpcMessage->Type;
|
||||
Port->Msg.Length = LpcMessage->Length;
|
||||
Port->Msg.Buffer = LpcMessage->Buffer;
|
||||
Port->Msg.Flags = LpcMessage->Flags;
|
||||
Port->Msg.Sender = PsGetCurrentProcess();
|
||||
Port->Msg.BufferMdl = MmCreateMdl(NULL,
|
||||
LpcMessage->Buffer,
|
||||
LpcMessage->Length);
|
||||
MmProbeAndLockPages(Port->Msg.BufferMdl,
|
||||
UserMode,
|
||||
IoReadAccess);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtRequestWaitReplyPort(VOID)
|
||||
|
||||
NTSTATUS STDCALL NtRequestWaitReplyPort(IN HANDLE PortHandle,
|
||||
IN OUT PLPC_REPLY LpcReply, /* guess */
|
||||
IN TIME* TimeToWait /* guess */)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtQueryInformationPort(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtReadRequestData(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtWriteRequestData(VOID)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
#else
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtAcceptConnectPort ( /* @24 */
|
||||
IN HANDLE PortHandle,
|
||||
OUT PHANDLE ConnectedPort,
|
||||
DWORD a2,
|
||||
DWORD a3,
|
||||
DWORD a4,
|
||||
DWORD a5
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCompleteConnectPort ( /* @4 */
|
||||
HANDLE PortHandle
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtConnectPort ( /* @32 */
|
||||
OUT PHANDLE ConnectedPort,
|
||||
IN PUNICODE_STRING PortName,
|
||||
IN POBJECT_ATTRIBUTES PortAttributes,
|
||||
IN DWORD a3,
|
||||
IN DWORD a4,
|
||||
IN DWORD a5,
|
||||
IN DWORD a6,
|
||||
IN ULONG Flags
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCreatePort ( /* @20 */
|
||||
OUT PHANDLE PortHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL,
|
||||
IN DWORD a3, /* unknown */
|
||||
IN DWORD a4 /* unknown */
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtImpersonateClientOfPort ( /* @8 */
|
||||
IN HANDLE PortHandle,
|
||||
IN PCLIENT_ID ClientId
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtListenPort ( /* @8 */
|
||||
IN HANDLE PortHAndle,
|
||||
IN DWORD QueueSize /* guess */
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtQueryInformationPort ( /* @20 */
|
||||
IN HANDLE PortHandle,
|
||||
IN CINT PortInformationClass, /* guess */
|
||||
OUT PVOID PortInformation, /* guess */
|
||||
IN ULONG PortInformationLength, /* guess */
|
||||
OUT PULONG ReturnLength /* guess */
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtReplyPort ( /* @8 */
|
||||
IN HANDLE PortHandle,
|
||||
IN PLPC_REPLY LpcReply /* guess */
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtReplyWaitReceivePort ( /* @16 */
|
||||
IN HANDLE PortHandle,
|
||||
IN PLPC_REPLY LpcReply, /* guess */
|
||||
OUT PLPC_MESSAGE LpcMessage, /* guess */
|
||||
OUT PULONG MessageLength /* guess */
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtReplyWaitReplyPort ( /* @8 */
|
||||
IN HANDLE PortHandle,
|
||||
IN OUT PLPC_REPLY LpcReply /* guess */
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtRequestPort ( /* @8 */
|
||||
IN HANDLE PortHandle,
|
||||
IN PLPC_MESSAGE LpcMessage /* guess */
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtRequestWaitReplyPort ( /* @12 */
|
||||
IN HANDLE PortHandle,
|
||||
IN OUT PLPC_REPLY LpcReply, /* guess */
|
||||
IN TIME * TimeToWait /* guess */
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME SYSTEM
|
||||
|
@ -470,16 +357,12 @@ NtRequestWaitReplyPort ( /* @12 */
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtReadRequestData ( /* @24 */
|
||||
DWORD a0,
|
||||
DWORD a1,
|
||||
DWORD a2,
|
||||
DWORD a3,
|
||||
DWORD a4,
|
||||
DWORD a5
|
||||
)
|
||||
NTSTATUS STDCALL NtReadRequestData (DWORD a0,
|
||||
DWORD a1,
|
||||
DWORD a2,
|
||||
DWORD a3,
|
||||
DWORD a4,
|
||||
DWORD a5)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
@ -503,19 +386,12 @@ NtReadRequestData ( /* @24 */
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtWriteRequestData ( /* @24 */
|
||||
DWORD a0,
|
||||
DWORD a1,
|
||||
DWORD a2,
|
||||
DWORD a3,
|
||||
DWORD a4,
|
||||
DWORD a5
|
||||
)
|
||||
NTSTATUS STDCALL NtWriteRequestData (DWORD a0,
|
||||
DWORD a1,
|
||||
DWORD a2,
|
||||
DWORD a3,
|
||||
DWORD a4,
|
||||
DWORD a5)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
#endif /* ndef PROTO_LPC */
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.def,v 1.26 1999/11/20 21:44:34 ekohl Exp $
|
||||
; $Id: ntoskrnl.def,v 1.27 1999/11/24 11:51:46 dwelch Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -129,8 +129,8 @@ NtAllocateUuids@12
|
|||
NtAllocateVirtualMemory@24
|
||||
;NtBuildNumber <--- variable?
|
||||
NtClose@4
|
||||
;NtConnectPort@32
|
||||
NtConnectPort@8
|
||||
NtConnectPort@32
|
||||
;NtConnectPort@8
|
||||
NtCreateEvent@20
|
||||
NtCreateFile@44
|
||||
NtCreateSection@28
|
||||
|
@ -162,8 +162,8 @@ NtQueryVolumeInformationFile@20
|
|||
NtReadFile@36
|
||||
;NtRequestPort@8
|
||||
NtRequestPort@20
|
||||
;NtRequestWaitReplyPort@8
|
||||
NtRequestWaitReplyPort@0
|
||||
NtRequestWaitReplyPort@12
|
||||
;NtRequestWaitReplyPort@0
|
||||
NtSetEvent@8
|
||||
NtSetInformationFile@20
|
||||
NtSetInformationProcess@16
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.edf,v 1.13 1999/11/20 21:44:34 ekohl Exp $
|
||||
; $Id: ntoskrnl.edf,v 1.14 1999/11/24 11:51:46 dwelch Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -129,8 +129,8 @@ NtAllocateUuids=NtAllocateUuids@12
|
|||
NtAllocateVirtualMemory=NtAllocateVirtualMemory@24
|
||||
;NtBuildNumber <--- variable
|
||||
NtClose=NtClose@4
|
||||
;NtConnectPort@32
|
||||
NtConnectPort=NtConnectPort@8
|
||||
NtConnectPort=NtConnectPort@32
|
||||
;NtConnectPort=NtConnectPort@8
|
||||
NtCreateEvent=NtCreateEvent@20
|
||||
NtCreateFile=NtCreateFile@44
|
||||
NtCreateSection=NtCreateSection@28
|
||||
|
@ -160,10 +160,10 @@ NtQuerySecurityObject=NtQuerySecurityObject@20
|
|||
NtQuerySystemTime=NtQuerySystemTime@4
|
||||
NtQueryVolumeInformationFile=NtQueryVolumeInformationFile@20
|
||||
NtReadFile=NtReadFile@36
|
||||
;NtRequestPort@8
|
||||
NtRequestPort=NtRequestPort@20
|
||||
;NtRequestWaitReplyPort@8
|
||||
NtRequestWaitReplyPort=NtRequestWaitReplyPort@0
|
||||
NtRequestPort=NtRequestPort@8
|
||||
;NtRequestPort=NtRequestPort@20
|
||||
NtRequestWaitReplyPort@12
|
||||
;NtRequestWaitReplyPort=NtRequestWaitReplyPort@0
|
||||
NtSetEvent=NtSetEvent@8
|
||||
NtSetInformationFile=NtSetInformationFile@20
|
||||
NtSetInformationProcess=NtSetInformationProcess@16
|
||||
|
|
|
@ -80,13 +80,28 @@ VOID PsTerminateOtherThread(PETHREAD Thread, NTSTATUS ExitStatus)
|
|||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL PiTerminateProcess(PEPROCESS Process,
|
||||
NTSTATUS ExitStatus)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
|
||||
DPRINT("PsTerminateProcess(Process %x, ExitStatus %x)\n",
|
||||
Process, ExitStatus);
|
||||
|
||||
PiTerminateProcessThreads(Process, ExitStatus);
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
|
||||
Process->Pcb.ProcessState = PROCESS_STATE_TERMINATED;
|
||||
Process->Pcb.DispatcherHeader.SignalState = TRUE;
|
||||
KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
|
||||
KeLowerIrql(oldlvl);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
|
||||
IN NTSTATUS ExitStatus)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PEPROCESS Process;
|
||||
KIRQL oldlvl;
|
||||
|
||||
DPRINT("NtTerminateProcess(ProcessHandle %x, ExitStatus %x)\n",
|
||||
ProcessHandle, ExitStatus);
|
||||
|
@ -102,18 +117,12 @@ NTSTATUS STDCALL NtTerminateProcess(IN HANDLE ProcessHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
PiTerminateProcessThreads(Process, ExitStatus);
|
||||
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
|
||||
Process->Pcb.ProcessState = PROCESS_STATE_TERMINATED;
|
||||
Process->Pcb.DispatcherHeader.SignalState = TRUE;
|
||||
KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
|
||||
PiTerminateProcess(Process, ExitStatus);
|
||||
if (PsGetCurrentThread()->ThreadsProcess == Process)
|
||||
{
|
||||
KeLowerIrql(oldlvl);
|
||||
ObDereferenceObject(Process);
|
||||
PsTerminateCurrentThread(ExitStatus);
|
||||
}
|
||||
KeLowerIrql(oldlvl);
|
||||
ObDereferenceObject(Process);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,31 @@ static ULONG PiNextProcessUniqueId = 0;
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID PiKillMostProcesses(VOID)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
PLIST_ENTRY current_entry;
|
||||
PEPROCESS current;
|
||||
|
||||
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
||||
|
||||
current_entry = PsProcessListHead.Flink;
|
||||
while (current_entry != &PsProcessListHead)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry, EPROCESS,
|
||||
Pcb.ProcessListEntry);
|
||||
current_entry = current_entry->Flink;
|
||||
|
||||
if (current->UniqueProcessId != SystemProcess->UniqueProcessId &&
|
||||
current->UniqueProcessId != (ULONG)PsGetCurrentProcessId())
|
||||
{
|
||||
PiTerminateProcess(current, STATUS_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&PsProcessListLock, oldIrql);
|
||||
}
|
||||
|
||||
VOID PsInitProcessManagment(VOID)
|
||||
{
|
||||
ANSI_STRING AnsiString;
|
||||
|
@ -111,8 +136,7 @@ VOID PiDeleteProcess(PVOID ObjectBody)
|
|||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
PsCreatePeb(HANDLE ProcessHandle)
|
||||
static NTSTATUS PsCreatePeb(HANDLE ProcessHandle)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PVOID PebBase;
|
||||
|
@ -141,8 +165,7 @@ PsCreatePeb(HANDLE ProcessHandle)
|
|||
sizeof(Peb),
|
||||
&BytesWritten);
|
||||
|
||||
DbgPrint ("PsCreatePeb: Peb created at %x\n", PebBase);
|
||||
// DPRINT("PsCreatePeb: Peb created at %x\n", PebBase);
|
||||
DPRINT("PsCreatePeb: Peb created at %x\n", PebBase);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -156,6 +179,11 @@ PKPROCESS KeGetCurrentProcess(VOID)
|
|||
return(&(PsGetCurrentProcess()->Pcb));
|
||||
}
|
||||
|
||||
HANDLE PsGetCurrentProcessId(VOID)
|
||||
{
|
||||
return((HANDLE)PsGetCurrentProcess()->UniqueProcessId);
|
||||
}
|
||||
|
||||
struct _EPROCESS* PsGetCurrentProcess(VOID)
|
||||
/*
|
||||
* FUNCTION: Returns a pointer to the current process
|
||||
|
@ -244,7 +272,6 @@ NtCreateProcess (
|
|||
InheritObjectTable,
|
||||
Process);
|
||||
MmCopyMmInfo(ParentProcess, Process);
|
||||
Process->UniqueProcessId = InterlockedIncrement(&PiNextProcessUniqueId);
|
||||
|
||||
KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
|
||||
InsertHeadList(&PsProcessListHead, &KProcess->ProcessListEntry);
|
||||
|
|
|
@ -11,9 +11,18 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <internal/ps.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID PsInit(VOID)
|
||||
VOID PiShutdownProcessManager(VOID)
|
||||
{
|
||||
DPRINT("PiShutdownMemoryManager()\n");
|
||||
|
||||
PiKillMostProcesses();
|
||||
}
|
||||
|
||||
VOID PiInitProcessManager(VOID)
|
||||
{
|
||||
PsInitProcessManagment();
|
||||
PsInitThreadManagment();
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: thread.c,v 1.30 1999/11/12 12:01:17 dwelch Exp $
|
||||
/* $Id: thread.c,v 1.31 1999/11/24 11:51:53 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -72,7 +72,6 @@ VOID PiTerminateProcessThreads(PEPROCESS Process, NTSTATUS ExitStatus)
|
|||
KIRQL oldlvl;
|
||||
PLIST_ENTRY current_entry;
|
||||
PETHREAD current;
|
||||
ULONG i;
|
||||
|
||||
KeAcquireSpinLock(&PiThreadListLock, &oldlvl);
|
||||
|
||||
|
@ -233,7 +232,6 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
|||
{
|
||||
PETHREAD Thread;
|
||||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
|
||||
PiNrThreads++;
|
||||
|
||||
|
@ -299,7 +297,8 @@ NTSTATUS PsInitializeThread(HANDLE ProcessHandle,
|
|||
}
|
||||
|
||||
|
||||
ULONG PsResumeThread(PETHREAD Thread)
|
||||
ULONG PsResumeThread(PETHREAD Thread,
|
||||
PNTSTATUS WaitStatus)
|
||||
{
|
||||
ULONG r;
|
||||
KIRQL oldIrql;
|
||||
|
@ -314,6 +313,10 @@ ULONG PsResumeThread(PETHREAD Thread)
|
|||
{
|
||||
// DPRINT("Marking thread %x as runnable\n",Thread);
|
||||
Thread->Tcb.State = THREAD_STATE_RUNNABLE;
|
||||
if (WaitStatus != NULL)
|
||||
{
|
||||
Thread->Tcb.WaitStatus = *WaitStatus;
|
||||
}
|
||||
PsInsertIntoThreadList(Thread->Tcb.BasePriority, Thread);
|
||||
PiNrRunnableThreads++;
|
||||
}
|
||||
|
@ -324,7 +327,10 @@ ULONG PsResumeThread(PETHREAD Thread)
|
|||
}
|
||||
|
||||
|
||||
ULONG PsSuspendThread(PETHREAD Thread)
|
||||
ULONG PsSuspendThread(PETHREAD Thread,
|
||||
PNTSTATUS WaitStatus,
|
||||
UCHAR Alertable,
|
||||
ULONG WaitMode)
|
||||
{
|
||||
ULONG r;
|
||||
KIRQL oldIrql;
|
||||
|
@ -338,21 +344,29 @@ ULONG PsSuspendThread(PETHREAD Thread)
|
|||
|
||||
if (r > 0)
|
||||
{
|
||||
if (Thread != CurrentThread)
|
||||
if (Thread != PsGetCurrentThread())
|
||||
{
|
||||
if (Thread->Tcb.State == THREAD_STATE_RUNNABLE)
|
||||
{
|
||||
RemoveEntryList(&Thread->Tcb.QueueListEntry);
|
||||
}
|
||||
Thread->Tcb.State = THREAD_STATE_SUSPENDED;
|
||||
Thread->Tcb.Alertable = Alertable;
|
||||
Thread->Tcb.WaitMode = WaitMode;
|
||||
PiNrRunnableThreads--;
|
||||
KeReleaseSpinLock(&PiThreadListLock, oldIrql);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("Suspending current thread\n");
|
||||
Thread->Tcb.Alertable = Alertable;
|
||||
Thread->Tcb.WaitMode = WaitMode;
|
||||
PiNrRunnableThreads--;
|
||||
PsDispatchThreadNoLock(THREAD_STATE_SUSPENDED);
|
||||
if (WaitStatus != NULL)
|
||||
{
|
||||
*WaitStatus = PsGetCurrentThread()->Tcb.WaitStatus;
|
||||
}
|
||||
KeLowerIrql(oldIrql);
|
||||
}
|
||||
}
|
||||
|
@ -582,7 +596,7 @@ NtCreateThread (
|
|||
if (!CreateSuspended)
|
||||
{
|
||||
DPRINT("Not creating suspended\n");
|
||||
PsResumeThread(Thread);
|
||||
PsResumeThread(Thread, NULL);
|
||||
}
|
||||
DPRINT("Finished PsCreateThread()\n");
|
||||
return(STATUS_SUCCESS);
|
||||
|
@ -638,7 +652,7 @@ NTSTATUS PsCreateSystemThread(PHANDLE ThreadHandle,
|
|||
*ClientId=Thread->Cid;
|
||||
}
|
||||
|
||||
PsResumeThread(Thread);
|
||||
PsResumeThread(Thread, NULL);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
@ -667,16 +681,35 @@ KPRIORITY KeSetPriorityThread(PKTHREAD Thread, KPRIORITY Priority)
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtAlertResumeThread(IN HANDLE ThreadHandle,
|
||||
OUT PULONG SuspendCount)
|
||||
NTSTATUS STDCALL NtAlertResumeThread(IN HANDLE ThreadHandle,
|
||||
OUT PULONG SuspendCount)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS STDCALL NtAlertThread (IN HANDLE ThreadHandle)
|
||||
NTSTATUS STDCALL NtAlertThread (IN HANDLE ThreadHandle)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
PETHREAD Thread;
|
||||
NTSTATUS Status;
|
||||
NTSTATUS ThreadStatus;
|
||||
|
||||
Status = ObReferenceObjectByHandle(ThreadHandle,
|
||||
THREAD_SUSPEND_RESUME,
|
||||
PsThreadType,
|
||||
UserMode,
|
||||
(PVOID*)&Thread,
|
||||
NULL);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
ThreadStatus = STATUS_ALERTED;
|
||||
(VOID)PsResumeThread(Thread, &ThreadStatus);
|
||||
|
||||
ObDereferenceObject(Thread);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
@ -723,7 +756,7 @@ NTSTATUS STDCALL NtResumeThread (IN HANDLE ThreadHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
(*SuspendCount) = PsResumeThread(Thread);
|
||||
(*SuspendCount) = PsResumeThread(Thread, NULL);
|
||||
|
||||
ObDereferenceObject(Thread);
|
||||
return(STATUS_SUCCESS);
|
||||
|
@ -767,7 +800,10 @@ NTSTATUS STDCALL NtSuspendThread (IN HANDLE ThreadHandle,
|
|||
return(Status);
|
||||
}
|
||||
|
||||
(*PreviousSuspendCount) = PsSuspendThread(Thread);
|
||||
(*PreviousSuspendCount) = PsSuspendThread(Thread,
|
||||
NULL,
|
||||
FALSE,
|
||||
UserMode);
|
||||
|
||||
ObDereferenceObject(Thread);
|
||||
return(STATUS_SUCCESS);
|
||||
|
|
|
@ -124,6 +124,10 @@ NtQueryInformationThread (
|
|||
UNIMPLEMENTED
|
||||
}
|
||||
|
||||
VOID KeSetPreviousMode(ULONG Mode)
|
||||
{
|
||||
PsGetCurrentThread()->Tcb.PreviousMode = Mode;
|
||||
}
|
||||
|
||||
ULONG KeGetPreviousMode(VOID)
|
||||
{
|
||||
|
|
|
@ -170,23 +170,12 @@ NtDuplicateToken (
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtImpersonateClientOfPort(VOID)
|
||||
NTSTATUS STDCALL NtImpersonateThread (IN HANDLE ThreadHandle,
|
||||
IN HANDLE ThreadToImpersonate,
|
||||
IN PSECURITY_QUALITY_OF_SERVICE
|
||||
SecurityQualityOfService)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtImpersonateThread (
|
||||
IN HANDLE ThreadHandle,
|
||||
IN HANDLE ThreadToImpersonate,
|
||||
IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService
|
||||
)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
UNIMPLEMENTED;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue