mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Some fixes.
Began work on implementing named pipes. svn path=/trunk/; revision=1151
This commit is contained in:
parent
1d034b8c4e
commit
d173c588c7
53 changed files with 1987 additions and 1039 deletions
|
@ -234,6 +234,7 @@ $(SUBSYS:%=%_dist): %_dist:
|
|||
install: all
|
||||
./install.sh /mnt/hda1
|
||||
./install.sh /mnt/hda4
|
||||
./install.bochs
|
||||
|
||||
make_floppy_dirs:
|
||||
ifeq ($(DOSCLI),yes)
|
||||
|
|
99
reactos/apps/tests/nptest/npclient.c
Normal file
99
reactos/apps/tests/nptest/npclient.c
Normal file
|
@ -0,0 +1,99 @@
|
|||
#include <windows.h>
|
||||
|
||||
VOID MyErrExit(LPTSTR Message)
|
||||
{
|
||||
MessageBox(NULL, Message, NULL, MB_OK);
|
||||
ExitProcess(0);
|
||||
}
|
||||
|
||||
DWORD main(int argc, char *argv[])
|
||||
{
|
||||
HANDLE hPipe;
|
||||
LPVOID lpvMessage;
|
||||
CHAR chBuf[512];
|
||||
BOOL fSuccess;
|
||||
DWORD cbRead, cbWritten, dwMode;
|
||||
LPTSTR lpszPipename = "\\\\.\\pipe\\mynamedpipe";
|
||||
|
||||
// Try to open a named pipe; wait for it, if necessary.
|
||||
|
||||
while (1)
|
||||
{
|
||||
hPipe = CreateFile(
|
||||
lpszPipename, // pipe name
|
||||
GENERIC_READ | // read and write access
|
||||
GENERIC_WRITE,
|
||||
0, // no sharing
|
||||
NULL, // no security attributes
|
||||
OPEN_EXISTING, // opens existing pipe
|
||||
0, // default attributes
|
||||
NULL); // no template file
|
||||
|
||||
// Break if the pipe handle is valid.
|
||||
|
||||
if (hPipe != INVALID_HANDLE_VALUE)
|
||||
break;
|
||||
|
||||
// Exit if an error other than ERROR_PIPE_BUSY occurs.
|
||||
|
||||
if (GetLastError() != ERROR_PIPE_BUSY)
|
||||
MyErrExit("Could not open pipe");
|
||||
|
||||
// All pipe instances are busy, so wait for 20 seconds.
|
||||
|
||||
if (! WaitNamedPipe(lpszPipename, 20000) )
|
||||
MyErrExit("Could not open pipe");
|
||||
}
|
||||
|
||||
// The pipe connected; change to message-read mode.
|
||||
|
||||
dwMode = PIPE_READMODE_MESSAGE;
|
||||
fSuccess = SetNamedPipeHandleState(
|
||||
hPipe, // pipe handle
|
||||
&dwMode, // new pipe mode
|
||||
NULL, // don't set maximum bytes
|
||||
NULL); // don't set maximum time
|
||||
if (!fSuccess)
|
||||
MyErrExit("SetNamedPipeHandleState");
|
||||
|
||||
// Send a message to the pipe server.
|
||||
|
||||
lpvMessage = (argc > 1) ? argv[1] : "default message";
|
||||
|
||||
fSuccess = WriteFile(
|
||||
hPipe, // pipe handle
|
||||
lpvMessage, // message
|
||||
strlen(lpvMessage) + 1, // message length
|
||||
&cbWritten, // bytes written
|
||||
NULL); // not overlapped
|
||||
if (! fSuccess)
|
||||
MyErrExit("WriteFile");
|
||||
|
||||
do
|
||||
{
|
||||
// Read from the pipe.
|
||||
|
||||
fSuccess = ReadFile(
|
||||
hPipe, // pipe handle
|
||||
chBuf, // buffer to receive reply
|
||||
512, // size of buffer
|
||||
&cbRead, // number of bytes read
|
||||
NULL); // not overlapped
|
||||
|
||||
if (! fSuccess && GetLastError() != ERROR_MORE_DATA)
|
||||
break;
|
||||
|
||||
// Reply from the pipe is written to STDOUT.
|
||||
|
||||
if (! WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),
|
||||
chBuf, cbRead, &cbWritten, NULL))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
} while (! fSuccess); // repeat loop if ERROR_MORE_DATA
|
||||
|
||||
CloseHandle(hPipe);
|
||||
|
||||
return 0;
|
||||
}
|
90
reactos/apps/tests/nptest/npserver.c
Normal file
90
reactos/apps/tests/nptest/npserver.c
Normal file
|
@ -0,0 +1,90 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <windows.h>
|
||||
|
||||
VOID InstanceThread (LPVOID);
|
||||
|
||||
VOID GetAnswerToRequest (LPTSTR, LPTSTR, LPDWORD)
|
||||
{
|
||||
}
|
||||
|
||||
int xx = 0;
|
||||
|
||||
DWORD main (VOID)
|
||||
{
|
||||
BOOL fConnected;
|
||||
DWORD dwThreadId;
|
||||
HANDLE hPipe, hThread;
|
||||
LPTSTR lpszPipename = "\\\\.\\pipe\\mynamedpipe";
|
||||
|
||||
for (;;)
|
||||
{
|
||||
hPipe = CreateNamedPipe (lpszPipename,
|
||||
PIPE_ACCESS_DUPLEX,
|
||||
PIPE_TYPE_MESSAGE |
|
||||
PIPE_READMODE_MESSAGE |
|
||||
PIPE_WAIT,
|
||||
PIPE_UNLIMITED_INSTANCES,
|
||||
BUFSIZE,
|
||||
BUFSIZE,
|
||||
PIPE_TIMEOUT,
|
||||
NULL);
|
||||
if (hPipe == INVALID_HANDLE_VALUE)
|
||||
MyErrExit ("CreatePipe");
|
||||
|
||||
fConnected = ConnectNamedPipe (hPipe,
|
||||
NULL) ? TRUE : (GetLastError () ==
|
||||
ERROR_PIPE_CONNECTED);
|
||||
if (fConnected)
|
||||
{
|
||||
hThread = CreateThread (NULL,
|
||||
0,
|
||||
(LPTHREAD_START_ROUTINE) InstanceThread,
|
||||
(LPVOID) hPipe,
|
||||
0,
|
||||
&dwThreadId);
|
||||
if (hThread == NULL)
|
||||
MyErrExit ("CreateThread");
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseHandle (hPipe);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
VOID InstanceThread (LPVOID lpvParam)
|
||||
{
|
||||
CHAR chRequest[BUFSIZE];
|
||||
CHAR chReply[BUFSIZE];
|
||||
DWORD cbBytesRead, cbReplyBytes, cbWritten;
|
||||
BOOL fSuccess;
|
||||
HANDLE hPipe;
|
||||
|
||||
hPipe = (HANDLE) lpvParam;
|
||||
while (1)
|
||||
{
|
||||
fSuccess = ReadFile (hPipe,
|
||||
chRequest,
|
||||
BUFSIZE,
|
||||
&cbBytesRead,
|
||||
NULL);
|
||||
if (!fSuccess || cbBytesRead == 0)
|
||||
break;
|
||||
GetAnswerToRequest (chRequest, chReply, &cbReplyBytes);
|
||||
|
||||
fSuccess = WriteFile (hPipe,
|
||||
chReply,
|
||||
cbReplyBytes,
|
||||
&cbWritten,
|
||||
NULL);
|
||||
if (!fSuccess || cbReplyBytes != cbWritten)
|
||||
break;
|
||||
}
|
||||
|
||||
FlushFileBuffers(hPipe);
|
||||
DisconnectNamedPipe (hPipe);
|
||||
CloseHandle (hPipe);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: shmsrv.c,v 1.3 1999/12/30 01:51:36 dwelch Exp $
|
||||
/* $Id: shmsrv.c,v 1.4 2000/05/13 13:50:54 dwelch Exp $
|
||||
*
|
||||
* FILE : reactos/apps/shm/shmsrv.c
|
||||
* AUTHOR: David Welch
|
||||
|
@ -45,7 +45,7 @@ int main(int argc, char* argv[])
|
|||
printf("Copying %s\n", GetCommandLineA());
|
||||
strcpy(BaseAddress, GetCommandLineA());
|
||||
|
||||
for(;;);
|
||||
Sleep(INFINITE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.3 2000/03/26 22:00:09 dwelch Exp $
|
||||
/* $Id: create.c,v 1.4 2000/05/13 13:51:08 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -16,11 +16,102 @@
|
|||
|
||||
#include "npfs.h"
|
||||
|
||||
/* GLOBALS *******************************************************************/
|
||||
|
||||
static LIST_ENTRY PipeListHead;
|
||||
static KMUTEX PipeListLock;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID NpfsInitPipeList(VOID)
|
||||
{
|
||||
InitializeListHead(&PipeListHead);
|
||||
KeInitializeMutex(&PipeListLock, 0);
|
||||
}
|
||||
|
||||
NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
PFILE_OBJECT FileObject;
|
||||
NTSTATUS Status;
|
||||
PNPFS_PIPE Pipe;
|
||||
PNPFS_FCB Fcb;
|
||||
PWSTR PipeName;
|
||||
PNPFS_PIPE current;
|
||||
PLIST_ENTRY current_entry;
|
||||
|
||||
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
FileObject = IoStack->FileObject;
|
||||
|
||||
PipeName = FileObject->FileName.Buffer;
|
||||
|
||||
Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
|
||||
if (Fcb == NULL)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_NO_MEMORY;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return(STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
KeLockMutex(&PipeListLock);
|
||||
current_entry = PipeListHead.Flink;
|
||||
while (current_entry != &PipeListHead)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry,
|
||||
PipeListEntry,
|
||||
NPFS_PIPE);
|
||||
|
||||
if (wcscmp(Pipe->Name, current->Name) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
|
||||
if (current_entry == PipeListHead)
|
||||
{
|
||||
ExFreePool(Fcb);
|
||||
KeUnlockMutex(&PipeListLock);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
Pipe = current;
|
||||
|
||||
KeAcquireSpinLock(&Pipe->FcbListHead, &oldIrql);
|
||||
InsertTailList(&Pipe->FcbListHead, &Fcb->FcbListEntry);
|
||||
KeReleaseSpinLock(&Pipe->FcbListHead, oldIrql);
|
||||
Fcb->WriteModeMessage = FALSE;
|
||||
Fcb->ReadModeMessage = FALSE;
|
||||
Fcb->NonBlocking = FALSE;
|
||||
Fcb->InBufferSize = PAGESIZE;
|
||||
Fcb->OutBufferSize = PAGESIZE;
|
||||
Fcb->Pipe = Pipe;
|
||||
Fcb->IsServer = FALSE;
|
||||
Fcb->OtherSide = NULL;
|
||||
|
||||
Pipe->ReferenceCount++;
|
||||
|
||||
KeUnlockMutex(&PipeListLock);
|
||||
|
||||
FileObject->FsContext = Fcb;
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
@ -31,11 +122,12 @@ NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
NTSTATUS Status;
|
||||
PNPFS_DEVICE_EXTENSION DeviceExt;
|
||||
PWSTR PipeName;
|
||||
PNPFS_FSCONTEXT PipeDescr;
|
||||
PNPFS_PIPE Pipe;
|
||||
PNPFS_FCB Fcb;
|
||||
NTSTATUS Status;
|
||||
KIRQL oldIrql;
|
||||
PLIST_ENTRY current_entry;
|
||||
PNPFS_CONTEXT current;
|
||||
PNPFS_PIPE current;
|
||||
|
||||
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
|
@ -43,8 +135,8 @@ NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
PipeName = FileObject->FileName.Buffer;
|
||||
|
||||
PipeDescr = ExAllocatePool(NonPagedPool, sizeof(NPFS_FSCONTEXT));
|
||||
if (PipeDescr == NULL)
|
||||
Pipe = ExAllocatePool(NonPagedPool, sizeof(NPFS_PIPE));
|
||||
if (Pipe == NULL)
|
||||
{
|
||||
Irp->IoStatus.Status = STATUS_NO_MEMORY;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
@ -53,72 +145,85 @@ NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
|||
|
||||
return(STATUS_NO_MEMORY);
|
||||
}
|
||||
PipeDescr->Name = ExAllocatePool(NonPagedPool,
|
||||
(wcslen(PipeName) + 1) * sizeof(WCHAR));
|
||||
if (PipeDescr->Name == NULL)
|
||||
|
||||
Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
|
||||
if (Fcb == NULL)
|
||||
{
|
||||
ExFreePool(PipeDescr);
|
||||
ExFreePool(Pipe);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NO_MEMORY;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
|
||||
return(STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
wcscpy(PipeDescr->Name, PipeName);
|
||||
PipeDescr->FileAttributes =
|
||||
IoStack->Parameters.CreateNamedPipe.FileAttributes;
|
||||
PipeDescr->OpenMode =
|
||||
IoStack->Parameters.CreateNamedPipe.OpenMode;
|
||||
PipeDescr->PipeType =
|
||||
IoStack->Parameters.CreateNamedPipe.PipeType;
|
||||
PipeDescr->PipeRead =
|
||||
IoStack->Parameters.CreateNamedPipe.PipeRead;
|
||||
PipeDescr->PipeWait =
|
||||
IoStack->Parameters.CreateNamedPipe.PipeWait;
|
||||
PipeDescr->MaxInstances =
|
||||
IoStack->Parameters.CreateNamedPipe.MaxInstances;
|
||||
PipeDescr->InBufferSize =
|
||||
IoStack->Parameters.CreateNamedPipe.InBufferSize;
|
||||
PipeDescr->OutBufferSize =
|
||||
IoStack->Parameters.CreateNamedPipe.OutBufferSize;
|
||||
PipeDescr->Timeout =
|
||||
IoStack->Parameters.CreateNamedPipe.Timeout;
|
||||
KeInitializeSpinLock(&PipeDescr->MsgListLock);
|
||||
InitializeListHead(&PipeDescr->MsgListHead);
|
||||
Pipe->Name = ExAllocatePool(NonPagedPool,
|
||||
(wcslen(PipeName) + 1) * sizeof(WCHAR));
|
||||
if (Pipe->Name == NULL)
|
||||
{
|
||||
ExFreePool(Pipe);
|
||||
ExFreePool(Fcb);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_NO_MEMORY;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check for duplicate names
|
||||
*/
|
||||
KeAcquireSpinLock(&PipeListLock, &oldIrql);
|
||||
wcscpy(Pipe->Name, PipeName);
|
||||
Pipe->ReferenceCount = 0;
|
||||
InitializeListHead(&Pipe->FcbListHead);
|
||||
KeInitializeSpinLock(&Pipe->FcbListLock);
|
||||
Pipe->MaxInstances = IoStack->Parameters.CreateNamedPipe.MaxInstances;
|
||||
Pipe->TimeOut = IoStack->Parameters.CreateNamedPipe.TimeOut;
|
||||
|
||||
KeLockMutex(&PipeListLock);
|
||||
current_entry = PipeListHead.Flink;
|
||||
while (current_entry != &PipeListHead)
|
||||
{
|
||||
current = CONTAINING_RECORD(current_entry,
|
||||
NPFS_FSCONTEXT,
|
||||
ListEntry);
|
||||
PipeListEntry,
|
||||
NPFS_PIPE);
|
||||
|
||||
if (wcscmp(current->Name, PipeDescr->Name) == 0)
|
||||
if (wcscmp(Pipe->Name, current->Name) == 0)
|
||||
{
|
||||
KeReleaseSpinLock(&PipeListLock, oldIrql);
|
||||
ExFreePool(PipeDescr->Name);
|
||||
ExFreePool(PipeDescr);
|
||||
|
||||
Irp->IoStatus.Status = STATUS_OBJECT_NAME_COLLISION;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
break;
|
||||
}
|
||||
|
||||
current_entry = current_entry->Flink;
|
||||
}
|
||||
InsertTailList(&PipeListHead,
|
||||
&PipeDescr->ListEntry);
|
||||
KeReleaseSpinLock(&PipeListLock, oldIrql);
|
||||
|
||||
if (current_entry != &PipeListHead)
|
||||
{
|
||||
ExFreePool(Pipe->Name);
|
||||
ExFreePool(Pipe);
|
||||
|
||||
Pipe = current;
|
||||
}
|
||||
else
|
||||
{
|
||||
InsertTailList(&PipeListHead, &Pipe->PipeListEntry);
|
||||
}
|
||||
Pipe->ReferenceCount++;
|
||||
|
||||
KeAcquireSpinLock(&Pipe->FcbListHead, &oldIrql);
|
||||
InsertTailList(&Pipe->FcbListHead, &Fcb->FcbListEntry);
|
||||
KeReleaseSpinLock(&Pipe->FcbListHead, oldIrql);
|
||||
Fcb->WriteModeMessage =
|
||||
IoStack->Parameters.CreateNamedPipe.WriteModeMessage;
|
||||
Fcb->ReadModeMessage = IoStack->Parameters.CreateNamedPipe.ReadModeMessage;
|
||||
Fcb->NonBlocking = IoStack->Parameters.CreateNamedPipe.NonBlocking;
|
||||
Fcb->InBufferSize = IoStack->Parameters.CreateNamedPipe.InBufferSize;
|
||||
Fcb->OutBufferSize = IoStack->Parameters.CreateNamedPipe.OutBufferSize;
|
||||
Fcb->Pipe = Pipe;
|
||||
Fcb->IsServer = TRUE;
|
||||
Fcb->OtherSide = NULL;
|
||||
|
||||
FileObject->FsContext = PipeDescr;
|
||||
KeUnlockMutex(PipeListLock);
|
||||
|
||||
FileObject->FsContext = Fcb;
|
||||
|
||||
Irp->IoStatus.Status = Status;
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
|
59
reactos/drivers/fs/np/fsctrl.c
Normal file
59
reactos/drivers/fs/np/fsctrl.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/* $Id: fsctrl.c,v 1.1 2000/05/13 13:51:08 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: services/fs/np/fsctrl.c
|
||||
* PURPOSE: Named pipe filesystem
|
||||
* PROGRAMMER: David Welch <welch@cwcom.net>
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
//#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
#include "npfs.h"
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
|
||||
{
|
||||
PIO_STACK_LOCATION IoStack;
|
||||
PFILE_OBJECT FileObject;
|
||||
NTSTATUS Status;
|
||||
PNPFS_DEVICE_EXTENSION DeviceExt;
|
||||
PNPFS_PIPE Pipe;
|
||||
PNPFS_FCB Fcb;
|
||||
|
||||
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
|
||||
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
||||
FileObject = IoStack->FileObject;
|
||||
Fcb = FileObject->FsContext;
|
||||
Pipe = Fcb->Pipe;
|
||||
|
||||
switch (stk->Parameters.FileSystemControl.IoControlCode)
|
||||
{
|
||||
case FSCTL_WAIT_PIPE:
|
||||
break;
|
||||
|
||||
case FSCTL_LISTEN:
|
||||
break;
|
||||
|
||||
case FSCTL_SET_STATE:
|
||||
break;
|
||||
|
||||
case FSCTL_GET_STATE:
|
||||
{
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: mount.c,v 1.3 2000/03/26 22:00:09 dwelch Exp $
|
||||
/* $Id: mount.c,v 1.4 2000/05/13 13:51:08 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -20,9 +20,6 @@
|
|||
|
||||
static PDRIVER_OBJECT DriverObject;
|
||||
|
||||
LIST_ENTRY PipeListHead;
|
||||
KSPIN_LOCK PipeListLock;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
|
||||
|
@ -74,9 +71,13 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
|
|||
NpfsQuerySecurity;
|
||||
DeviceObject->MajorFunction[IRP_MJ_SET_SECURITY] =
|
||||
NpfsSetSecurity;
|
||||
DeviceObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
|
||||
NpfsFileSystemControl;
|
||||
|
||||
DriverObject->DriverUnload = NULL;
|
||||
|
||||
NpfsInitPipeList();
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,29 +8,36 @@ typedef struct
|
|||
|
||||
typedef struct
|
||||
{
|
||||
PVOID Buffer;
|
||||
ULONG Size;
|
||||
LIST_ENTRY ListEntry;
|
||||
} NPFS_MSG, *PNPFS_MSG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
PWSTR Name;
|
||||
ULONG FileAttributes;
|
||||
ULONG OpenMode;
|
||||
ULONG PipeType;
|
||||
ULONG PipeRead;
|
||||
ULONG PipeWait;
|
||||
PWCHAR Name;
|
||||
LIST_ENTRY PipeListEntry;
|
||||
KSPIN_LOCK FcbListLock;
|
||||
LIST_ENTRY FcbListHead;
|
||||
ULONG ReferenceCount;
|
||||
ULONG MaxInstances;
|
||||
LARGE_INTEGER TimeOut;
|
||||
} NPFS_PIPE, *PNPFS_PIPE;
|
||||
|
||||
typedef struct _NPFS_FCB
|
||||
{
|
||||
LIST_ENTRY FcbListEntry;
|
||||
BOOLEAN WriteModeMessage;
|
||||
BOOLEAN ReadModeMessage;
|
||||
BOOLEAN NonBlocking;
|
||||
ULONG InBufferSize;
|
||||
ULONG OutBufferSize;
|
||||
LARGE_INTEGER Timeout;
|
||||
KSPIN_LOCK MsgListLock;
|
||||
LIST_ENTRY MsgListHead;
|
||||
} NPFS_FSCONTEXT, *PNPFS_FSCONTEXT;
|
||||
PNPFS_PIPE Pipe;
|
||||
struct _NPFS_FCB* OtherSide;
|
||||
BOOLEAN IsServer;
|
||||
} NPFS_FCB, *PNPFS_FCB;
|
||||
|
||||
extern LIST_ENTRY PipeListHead;
|
||||
extern KSPIN_LOCK PipeListLock;
|
||||
VOID NpfsPipeList(VOID);
|
||||
|
||||
#define KeLockMutex(x) KeWaitForSingleObject(x, \
|
||||
UserRequest, \
|
||||
KernelMode, \
|
||||
FALSE, \
|
||||
NULL);
|
||||
|
||||
#define KeUnlockMutex(x) KeReleaseMutex(x, FALSE);
|
||||
|
||||
#endif /* __SERVICES_FS_NP_NPFS_H */
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: iotypes.h,v 1.16 2000/05/09 16:12:47 ekohl Exp $
|
||||
/* $Id: iotypes.h,v 1.17 2000/05/13 13:50:55 dwelch Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
|
@ -142,6 +142,13 @@ typedef struct _IO_STACK_LOCATION
|
|||
ULONG IoControlCode;
|
||||
PVOID Type3InputBuffer;
|
||||
} DeviceIoControl;
|
||||
struct
|
||||
{
|
||||
ULONG OutputBufferLength;
|
||||
ULONG InputBufferLength;
|
||||
ULONG IoControlCode;
|
||||
PVOID Type3InputBuffer;
|
||||
} FileSystemControl;
|
||||
struct
|
||||
{
|
||||
struct _VPB* Vpb;
|
||||
|
@ -181,15 +188,16 @@ typedef struct _IO_STACK_LOCATION
|
|||
} QueryDirectory;
|
||||
struct
|
||||
{
|
||||
ULONG FileAttributes;
|
||||
ULONG OpenMode;
|
||||
ULONG PipeType;
|
||||
ULONG PipeRead;
|
||||
ULONG PipeWait;
|
||||
ULONG CreateDisposition;
|
||||
ULONG CreateOptions;
|
||||
ULONG ShareAccess;
|
||||
BOOLEAN WriteModeMessage;
|
||||
BOOLEAN ReadModeMessage;
|
||||
BOOLEAN NonBlocking;
|
||||
ULONG MaxInstances;
|
||||
ULONG InBufferSize;
|
||||
ULONG OutBufferSize;
|
||||
LARGE_INTEGER Timeout;
|
||||
LARGE_INTEGER TimeOut;
|
||||
} CreateNamedPipe;
|
||||
} Parameters;
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
/* $Id: zw.h,v 1.29 2000/04/25 23:22:49 ea Exp $
|
||||
/* $Id: zw.h,v 1.30 2000/05/13 13:50:55 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -18,7 +18,8 @@
|
|||
#define __DDK_ZW_H
|
||||
|
||||
#include <security.h>
|
||||
|
||||
#include <napi/npipe.h>
|
||||
|
||||
#define LCID ULONG
|
||||
//#define SECURITY_INFORMATION ULONG
|
||||
//typedef ULONG SECURITY_INFORMATION;
|
||||
|
@ -336,17 +337,13 @@ ZwAllocateVirtualMemory (
|
|||
* RETURN Status
|
||||
*/
|
||||
//FIXME: this function might need 3 parameters
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCallbackReturn(
|
||||
VOID
|
||||
);
|
||||
NTSTATUS STDCALL NtCallbackReturn(PVOID Result,
|
||||
ULONG ResultLength,
|
||||
NTSTATUS Status);
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwCallbackReturn(
|
||||
VOID
|
||||
);
|
||||
NTSTATUS STDCALL ZwCallbackReturn(PVOID Result,
|
||||
ULONG ResultLength,
|
||||
NTSTATUS Status);
|
||||
|
||||
/*
|
||||
* FUNCTION: Cancels a IO request
|
||||
|
@ -731,66 +728,6 @@ ZwCreateMutant(
|
|||
IN BOOLEAN InitialOwner
|
||||
);
|
||||
|
||||
/*
|
||||
* FUNCTION: Creates a named pipe
|
||||
* ARGUMENTS:
|
||||
* NamedPipeFileHandle (OUT) = Caller supplied storage for the resulting handle
|
||||
* DesiredAccess = Specifies the allowed or desired access to the mutex
|
||||
* ObjectAttributes = Contains the name of the mutex.
|
||||
* IoStatusBlock =
|
||||
* FileAttributes =
|
||||
* ShareAccess =
|
||||
* OpenMode =
|
||||
* PipeType =
|
||||
* PipeRead =
|
||||
* PipeWait =
|
||||
* MaxInstances =
|
||||
* InBufferSize =
|
||||
* OutBufferSize =
|
||||
* TimeOut =
|
||||
* REMARKS: This funciton maps to the win32 function CreateNamedPipe
|
||||
* RETURNS:
|
||||
* Status
|
||||
*/
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtCreateNamedPipeFile(
|
||||
OUT PHANDLE NamedPipeFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG OpenMode,
|
||||
IN ULONG PipeType,
|
||||
IN ULONG PipeRead,
|
||||
IN ULONG PipeWait,
|
||||
IN ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER TimeOut
|
||||
);
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
ZwCreateNamedPipeFile(
|
||||
OUT PHANDLE NamedPipeFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG OpenMode,
|
||||
IN ULONG PipeType,
|
||||
IN ULONG PipeRead,
|
||||
IN ULONG PipeWait,
|
||||
IN ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER TimeOut
|
||||
);
|
||||
|
||||
|
||||
/*
|
||||
* FUNCTION: Creates a paging file.
|
||||
|
|
|
@ -34,6 +34,7 @@ VOID KeFreeGdtSelector(ULONG Entry);
|
|||
BOOLEAN KiTestAlert(PKTHREAD Thread, PCONTEXT UserContext);
|
||||
VOID KeCallApcsThread(VOID);
|
||||
VOID KeRemoveAllWaitsThread(PETHREAD Thread, NTSTATUS WaitStatus);
|
||||
PULONG KeGetStackTopThread(PETHREAD Thread);
|
||||
|
||||
/* INITIALIZATION FUNCTIONS *************************************************/
|
||||
|
||||
|
|
|
@ -170,5 +170,12 @@ NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
|
|||
ULONG Address);
|
||||
NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
|
||||
ULONG Address);
|
||||
NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||
MEMORY_AREA* MemoryArea,
|
||||
PVOID Address);
|
||||
NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||
MEMORY_AREA* MemoryArea,
|
||||
PVOID Address);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
* Various useful prototypes
|
||||
*/
|
||||
|
||||
#ifndef __KERNEL_H
|
||||
#define __KERNEL_H
|
||||
#ifndef __INCLUDE_INTERNAL_NTOSKRNL_H
|
||||
#define __INCLUDE_INTERNAL_NTOSKRNL_H
|
||||
|
||||
#ifndef __ASM__
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -89,4 +91,11 @@ VOID CmInitializeRegistry(VOID);
|
|||
VOID CmImportHive(PCHAR);
|
||||
VOID KdInitSystem(ULONG Reserved, boot_param* BootParam);
|
||||
|
||||
#endif
|
||||
#endif /* __ASM__ */
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
#define MM_STACK_SIZE (3*4096)
|
||||
|
||||
#endif /* INCLUDE_INTERNAL_NTOSKRNL_H */
|
||||
|
|
|
@ -91,7 +91,7 @@ typedef struct _PEB
|
|||
PVOID FastPebLockRoutine; // 20h
|
||||
PVOID FastPebUnlockRoutine; // 24h
|
||||
ULONG EnvironmentUpdateCount; // 28h
|
||||
PVOID KernelCallbackTable; // 2Ch
|
||||
PVOID* KernelCallbackTable; // 2Ch
|
||||
PVOID EventLogSection; // 30h
|
||||
PVOID EventLog; // 34h
|
||||
PPEB_FREE_BLOCK FreeList; // 38h
|
||||
|
|
19
reactos/include/napi/core.h
Normal file
19
reactos/include/napi/core.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef __INCLUDE_NAPI_CORE_H
|
||||
#define __INCLUDE_NAPI_CORE_H
|
||||
|
||||
#define MM_CORE_DUMP_HEADER_MAGIC (0xdeafbead)
|
||||
#define MM_CORE_DUMP_HEADER_VERSION (0x1)
|
||||
|
||||
typedef struct _MM_CORE_DUMP_HEADER
|
||||
{
|
||||
ULONG Magic;
|
||||
ULONG Version;
|
||||
CONTEXT Context;
|
||||
ULONG DumpLength;
|
||||
ULONG BugCode;
|
||||
ULONG ExceptionCode;
|
||||
ULONG Cr2;
|
||||
ULONG Cr3;
|
||||
} MM_CORE_DUMP_HEADER, *PMM_CORE_DUMP_HEADER;
|
||||
|
||||
#endif /* __INCLUDE_NAPI_CORE_H */
|
126
reactos/include/napi/npipe.h
Normal file
126
reactos/include/napi/npipe.h
Normal file
|
@ -0,0 +1,126 @@
|
|||
#ifndef __INCLUDE_NAPI_NPIPE_H
|
||||
#define __INCLUDE_NAPI_NPIPE_H
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
|
||||
/*
|
||||
* FUNCTION: ZwCreateNamedPipeFile creates named pipe
|
||||
* ARGUMENTS:
|
||||
* NamedPipeFileHandle (OUT) = Caller supplied storage for the
|
||||
* resulting handle
|
||||
* DesiredAccess = Specifies the type of access that the caller
|
||||
* requires to the file boject
|
||||
* ObjectAttributes = Points to a structure that specifies the
|
||||
* object attributes.
|
||||
* IoStatusBlock = Points to a variable that receives the final
|
||||
* completion status and information
|
||||
* ShareAccess = Specifies the limitations on sharing of the file.
|
||||
* This parameter can be zero or any compatible
|
||||
* combination of the following flags
|
||||
* FILE_SHARE_READ
|
||||
* FILE_SHARE_WRITE
|
||||
* CreateDisposition = Specifies what to do depending on whether
|
||||
* the file already exists. This must be one of
|
||||
* the following values
|
||||
* FILE_OPEN
|
||||
* FILE_CREATE
|
||||
* FILE_OPEN_IF
|
||||
* CreateOptions = Specifies the options to be applied when
|
||||
* creating or opening the file, as a compatible
|
||||
* combination of the following flags
|
||||
* FILE_WRITE_THROUGH
|
||||
* FILE_SYNCHRONOUS_IO_ALERT
|
||||
* FILE_SYNCHRONOUS_IO_NONALERT
|
||||
* TypeMessage = Specifies whether the data written to the pipe is
|
||||
* interpreted as a sequence of messages or as a
|
||||
* stream of bytes
|
||||
* ReadModeMessage = Specifies whether the data read from the pipe
|
||||
* is interpreted as a sequence of messages or as
|
||||
* a stream of bytes
|
||||
* NonBlocking = Specifies whether non-blocking mode is enabled
|
||||
* MaxInstances = Specifies the maximum number of instancs that can
|
||||
* be created for this pipe
|
||||
* InBufferSize = Specifies the number of bytes to reserve for the
|
||||
* input buffer
|
||||
* OutBufferSize = Specifies the number of bytes to reserve for the
|
||||
* output buffer
|
||||
* DefaultTimeout = Optionally points to a variable that specifies
|
||||
* the default timeout value in units of
|
||||
* 100-nanoseconds.
|
||||
* REMARKS: This funciton maps to the win32 function CreateNamedPipe
|
||||
* RETURNS:
|
||||
* Status
|
||||
*/
|
||||
|
||||
NTSTATUS STDCALL NtCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG CreateDisposition,
|
||||
IN ULONG CreateOptions,
|
||||
IN BOOLEAN WriteModeMessage,
|
||||
IN BOOLEAN ReadModeMessage,
|
||||
IN BOOLEAN NonBlocking,
|
||||
IN ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER DefaultTimeOut);
|
||||
NTSTATUS STDCALL ZwCreateNamedPipeFile(OUT PHANDLE NamedPipeFileHandle,
|
||||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG CreateDisposition,
|
||||
IN ULONG CreateOptions,
|
||||
IN BOOLEAN WriteModeMessage,
|
||||
IN BOOLEAN ReadModeMessage,
|
||||
IN BOOLEAN NonBlocking,
|
||||
IN ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER DefaultTimeOut);
|
||||
|
||||
|
||||
#define FSCTL_WAIT_PIPE \
|
||||
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 1, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define FSCTL_LISTEN \
|
||||
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 2, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define FSCTL_SET_STATE \
|
||||
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 3, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
#define FSCTL_GET_STATE \
|
||||
CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 4, METHOD_BUFFERED, FILE_ANY_ACCESS)
|
||||
|
||||
typedef struct _NPFS_WAIT_PIPE
|
||||
{
|
||||
LARGE_INTEGER Timeout;
|
||||
} NPFS_WAIT_PIPE, *PNPFS_WAIT_PIPE;
|
||||
|
||||
typedef struct _NPFS_LISTEN
|
||||
{
|
||||
} NPFS_LISTEN, *PNPFS_LISTEN;
|
||||
|
||||
typedef struct _NPFS_SET_STATE
|
||||
{
|
||||
BOOLEAN WriteModeMessage;
|
||||
BOOLEAN ReadModeMessage;
|
||||
BOOLEAN NonBlocking;
|
||||
ULONG InBufferSize;
|
||||
ULONG OutBufferSize;
|
||||
LARGE_INTEGER Timeout;
|
||||
} NPFS_SET_STATE, *PNPFS_SET_STATE;
|
||||
|
||||
typedef struct _NPFS_GET_STATE
|
||||
{
|
||||
BOOLEAN WriteModeMessage;
|
||||
BOOLEAN ReadModeMessage;
|
||||
BOOLEAN NonBlocking;
|
||||
ULONG InBufferSize;
|
||||
ULONG OutBufferSize;
|
||||
LARGE_INTEGER Timeout;
|
||||
} NPFS_GET_STATE, *PNPFS_GET_STATE;
|
||||
|
||||
#endif /* __INCLUDE_NAPI_NPIPE_H */
|
|
@ -1,35 +1,5 @@
|
|||
#ifndef __INCLUDE_SERVICES_SERVICES_H
|
||||
#define __INCLUDE_SERVICES_SERVICES_H
|
||||
|
||||
#define SCM_OPEN_MANAGER (1)
|
||||
#define SCM_LOCK_MANAGER (10)
|
||||
#define SCM_UNLOCK_MANAGER (11)
|
||||
|
||||
#define SCM_CREATE_SERVICE (2)
|
||||
#define SCM_OPEN_SERVICE (3)
|
||||
#define SCM_CHANGE_CONFIG_SERVICE (4)
|
||||
#define SCM_CONTROL_SERVICE (5)
|
||||
#define SCM_DELETE_SERVICE (6)
|
||||
#define SCM_SERVICES_STATUS (7)
|
||||
#define SCM_GET_DISPLAY_NAME_SERVICE (8)
|
||||
#define SCM_GET_KEY_NAME_SERVICE (9)
|
||||
#define SCM_QUERY_CONFIG_SERVICE (12)
|
||||
#define SCM_QUERY_LOCK_STATUS_SERVICE (13)
|
||||
#define SCM_QUERY_STATUS_SERVICE (14)
|
||||
#define SCM_START_SERVICE (15)
|
||||
|
||||
#define SCM_REGISTER_CHANDLER (16)
|
||||
#define SCM_SET_STATUS_SERVICE (17)
|
||||
#define SCM_START_CDISPATCHER (18)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG Type;
|
||||
} SCM_API_REQUEST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ULONG Status;
|
||||
} SCM_API_REPLY;
|
||||
|
||||
#endif /* __INCLUDE_SERVICES_SERVICES_H */
|
||||
|
|
16
reactos/include/services/services.idl
Normal file
16
reactos/include/services/services.idl
Normal file
|
@ -0,0 +1,16 @@
|
|||
[
|
||||
uuid(?),
|
||||
version(1.0),
|
||||
pointer_default(?)
|
||||
]
|
||||
interface SCM
|
||||
{
|
||||
handle_t SvcOpenSCManagerW([in, string] wchar_t* lpMachineName,
|
||||
[in, string] wchar_t* lpDatabaseName,
|
||||
[in] unsigned int dwDesiredAccess);
|
||||
handle_t SvcOpenSCManagerA([in, string] char* lpMachineName,
|
||||
[in, string] char* lpDatabaseName,
|
||||
[in] unsigned int dwDesiredAccess);
|
||||
bool SvcClose([in] handle_t hSCObject);
|
||||
}
|
||||
|
|
@ -2,8 +2,8 @@ mkdir -p $1/reactos
|
|||
mkdir -p $1/reactos/system32
|
||||
mkdir -p $1/reactos/system32/drivers
|
||||
mkdir -p $1/reactos/bin
|
||||
cp fdisk.exe $1
|
||||
cp format.exe $1
|
||||
#cp fdisk.exe $1
|
||||
#cp format.exe $1
|
||||
cp loaders/dos/loadros.com $1
|
||||
cp ntoskrnl/ntoskrnl.exe $1
|
||||
cp services/fs/vfat/vfatfs.sys $1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.19 2000/03/14 23:09:23 ekohl Exp $
|
||||
/* $Id: create.c,v 1.20 2000/05/13 13:50:56 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -23,140 +23,132 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
CreateFileA (
|
||||
LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile
|
||||
)
|
||||
HANDLE STDCALL CreateFileA (LPCSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile)
|
||||
{
|
||||
UNICODE_STRING FileNameU;
|
||||
ANSI_STRING FileName;
|
||||
HANDLE FileHandle;
|
||||
UNICODE_STRING FileNameU;
|
||||
ANSI_STRING FileName;
|
||||
HANDLE FileHandle;
|
||||
|
||||
DPRINT("CreateFileA(lpFileName %s)\n",lpFileName);
|
||||
|
||||
RtlInitAnsiString (&FileName,
|
||||
(LPSTR)lpFileName);
|
||||
|
||||
/* convert ansi (or oem) string to unicode */
|
||||
if (bIsFileApiAnsi)
|
||||
RtlAnsiStringToUnicodeString (&FileNameU,
|
||||
&FileName,
|
||||
TRUE);
|
||||
else
|
||||
RtlOemStringToUnicodeString (&FileNameU,
|
||||
&FileName,
|
||||
TRUE);
|
||||
|
||||
DPRINT("CreateFileA(lpFileName %s)\n",lpFileName);
|
||||
|
||||
RtlInitAnsiString (&FileName,
|
||||
(LPSTR)lpFileName);
|
||||
|
||||
/* convert ansi (or oem) string to unicode */
|
||||
if (bIsFileApiAnsi)
|
||||
RtlAnsiStringToUnicodeString (&FileNameU,
|
||||
&FileName,
|
||||
TRUE);
|
||||
else
|
||||
RtlOemStringToUnicodeString (&FileNameU,
|
||||
&FileName,
|
||||
TRUE);
|
||||
|
||||
FileHandle = CreateFileW (FileNameU.Buffer,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
lpSecurityAttributes,
|
||||
dwCreationDisposition,
|
||||
dwFlagsAndAttributes,
|
||||
hTemplateFile);
|
||||
|
||||
RtlFreeHeap (RtlGetProcessHeap (),
|
||||
0,
|
||||
FileNameU.Buffer);
|
||||
|
||||
return FileHandle;
|
||||
FileHandle = CreateFileW (FileNameU.Buffer,
|
||||
dwDesiredAccess,
|
||||
dwShareMode,
|
||||
lpSecurityAttributes,
|
||||
dwCreationDisposition,
|
||||
dwFlagsAndAttributes,
|
||||
hTemplateFile);
|
||||
|
||||
RtlFreeHeap (RtlGetProcessHeap (),
|
||||
0,
|
||||
FileNameU.Buffer);
|
||||
|
||||
return FileHandle;
|
||||
}
|
||||
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
CreateFileW (
|
||||
LPCWSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile
|
||||
)
|
||||
HANDLE STDCALL CreateFileW (LPCWSTR lpFileName,
|
||||
DWORD dwDesiredAccess,
|
||||
DWORD dwShareMode,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition,
|
||||
DWORD dwFlagsAndAttributes,
|
||||
HANDLE hTemplateFile)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
UNICODE_STRING NtPathU;
|
||||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
ULONG Flags = 0;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
UNICODE_STRING NtPathU;
|
||||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
ULONG Flags = 0;
|
||||
|
||||
switch (dwCreationDisposition)
|
||||
{
|
||||
case CREATE_NEW:
|
||||
dwCreationDisposition = FILE_CREATE;
|
||||
break;
|
||||
switch (dwCreationDisposition)
|
||||
{
|
||||
case CREATE_NEW:
|
||||
dwCreationDisposition = FILE_CREATE;
|
||||
break;
|
||||
|
||||
case CREATE_ALWAYS:
|
||||
dwCreationDisposition = FILE_OVERWRITE_IF;
|
||||
break;
|
||||
|
||||
case OPEN_EXISTING:
|
||||
dwCreationDisposition = FILE_OPEN;
|
||||
break;
|
||||
|
||||
case OPEN_ALWAYS:
|
||||
dwCreationDisposition = OPEN_ALWAYS;
|
||||
break;
|
||||
|
||||
case CREATE_ALWAYS:
|
||||
dwCreationDisposition = FILE_OVERWRITE_IF;
|
||||
break;
|
||||
|
||||
case OPEN_EXISTING:
|
||||
dwCreationDisposition = FILE_OPEN;
|
||||
break;
|
||||
|
||||
case OPEN_ALWAYS:
|
||||
dwCreationDisposition = OPEN_ALWAYS;
|
||||
break;
|
||||
|
||||
case TRUNCATE_EXISTING:
|
||||
dwCreationDisposition = FILE_OVERWRITE;
|
||||
}
|
||||
|
||||
DPRINT("CreateFileW(lpFileName %S)\n",lpFileName);
|
||||
|
||||
if (dwDesiredAccess & GENERIC_READ)
|
||||
dwDesiredAccess |= FILE_GENERIC_READ;
|
||||
|
||||
if (dwDesiredAccess & GENERIC_WRITE)
|
||||
dwDesiredAccess |= FILE_GENERIC_WRITE;
|
||||
|
||||
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
|
||||
{
|
||||
Flags |= FILE_SYNCHRONOUS_IO_ALERT;
|
||||
}
|
||||
|
||||
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFileName,
|
||||
&NtPathU,
|
||||
NULL,
|
||||
NULL))
|
||||
return FALSE;
|
||||
|
||||
DPRINT("NtPathU \'%S\'\n", NtPathU.Buffer);
|
||||
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
ObjectAttributes.ObjectName = &NtPathU;
|
||||
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE;
|
||||
ObjectAttributes.SecurityDescriptor = NULL;
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
Status = NtCreateFile (&FileHandle,
|
||||
dwDesiredAccess,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
dwFlagsAndAttributes,
|
||||
dwShareMode,
|
||||
dwCreationDisposition,
|
||||
Flags,
|
||||
NULL,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError (RtlNtStatusToDosError (Status));
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return FileHandle;
|
||||
case TRUNCATE_EXISTING:
|
||||
dwCreationDisposition = FILE_OVERWRITE;
|
||||
}
|
||||
|
||||
DPRINT("CreateFileW(lpFileName %S)\n",lpFileName);
|
||||
|
||||
if (dwDesiredAccess & GENERIC_READ)
|
||||
dwDesiredAccess |= FILE_GENERIC_READ;
|
||||
|
||||
if (dwDesiredAccess & GENERIC_WRITE)
|
||||
dwDesiredAccess |= FILE_GENERIC_WRITE;
|
||||
|
||||
if (!(dwFlagsAndAttributes & FILE_FLAG_OVERLAPPED))
|
||||
{
|
||||
Flags |= FILE_SYNCHRONOUS_IO_ALERT;
|
||||
}
|
||||
|
||||
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFileName,
|
||||
&NtPathU,
|
||||
NULL,
|
||||
NULL))
|
||||
return FALSE;
|
||||
|
||||
DPRINT("NtPathU \'%S\'\n", NtPathU.Buffer);
|
||||
|
||||
ObjectAttributes.Length = sizeof(OBJECT_ATTRIBUTES);
|
||||
ObjectAttributes.RootDirectory = NULL;
|
||||
ObjectAttributes.ObjectName = &NtPathU;
|
||||
ObjectAttributes.Attributes = OBJ_CASE_INSENSITIVE;
|
||||
ObjectAttributes.SecurityDescriptor = NULL;
|
||||
ObjectAttributes.SecurityQualityOfService = NULL;
|
||||
|
||||
Status = NtCreateFile (&FileHandle,
|
||||
dwDesiredAccess,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
dwFlagsAndAttributes,
|
||||
dwShareMode,
|
||||
dwCreationDisposition,
|
||||
Flags,
|
||||
NULL,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError (RtlNtStatusToDosError (Status));
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
return FileHandle;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
376
reactos/lib/kernel32/file/npipe.c
Normal file
376
reactos/lib/kernel32/file/npipe.c
Normal file
|
@ -0,0 +1,376 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
* FILE: lib/kernel32/file/npipe.c
|
||||
* PURPOSE: Directory functions
|
||||
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
||||
* UPDATE HISTORY:
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <windows.h>
|
||||
#include <wchar.h>
|
||||
#include <string.h>
|
||||
#include <ntdll/rtl.h>
|
||||
|
||||
#include <kernel32/kernel32.h>
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
HANDLE CreateNamedPipeA(LPCSTR lpName,
|
||||
DWORD dwOpenMode,
|
||||
DWORD dwPipeMode,
|
||||
DWORD nMaxInstances,
|
||||
DWORD nOutBufferSize,
|
||||
DWORD nInBufferSize,
|
||||
DWORD nDefaultTimeOut,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
{
|
||||
HANDLE NamedPipeHandle;
|
||||
UNICODE_STRING NameU;
|
||||
ANSI_STRING NameA;
|
||||
|
||||
RtlInitAnsiString(&NameA, (LPSTR)lpName);
|
||||
RtlAnsiStringToUnicodeString(&NameU, &NameA, TRUE);
|
||||
|
||||
NamedPipeHandle = CreateNamedPipeW(NameU.Buffer,
|
||||
dwOpenMode,
|
||||
dwPipeMode,
|
||||
nMaxInstances,
|
||||
nOutBufferSize,
|
||||
nInBufferSize,
|
||||
nDefaultTimeOut,
|
||||
lpSecurityAttributes);
|
||||
|
||||
RtlFreeUnicodeString(&NameU);
|
||||
|
||||
return(NamedPipeHandle);
|
||||
}
|
||||
|
||||
HANDLE CreateNamedPipeW(LPCWSTR lpName,
|
||||
DWORD dwOpenMode,
|
||||
DWORD dwPipeMode,
|
||||
DWORD nMaxInstances,
|
||||
DWORD nOutBufferSize,
|
||||
DWORD nInBufferSize,
|
||||
DWORD nDefaultTimeOut,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
{
|
||||
UNICODE_STRING NamedPipeName;
|
||||
BOOL Result;
|
||||
NTSTATUS Status;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE PipeHandle;
|
||||
ACCESS_MASK DesiredAccess;
|
||||
ULONG CreateOptions;
|
||||
ULONG CreateDisposition;
|
||||
BOOLEAN WriteModeMessage;
|
||||
BOOLEAN ReadModeMessage;
|
||||
BOOLEAN NonBlocking;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
ULONG ShareAccess;
|
||||
LARGE_INTEGER DefaultTimeOut;
|
||||
|
||||
Result = RtlDosPathNameToNtPathName_U((LPWSTR)lpName,
|
||||
&NamedPipeName,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (!Result)
|
||||
{
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
}
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&NamedPipeName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
DesiredAccess = 0;
|
||||
|
||||
ShareAccess = 0;
|
||||
|
||||
CreateDisposition = FILE_OPEN_IF;
|
||||
|
||||
CreateOptions = 0;
|
||||
if (dwOpenMode & FILE_FLAG_WRITE_THROUGH)
|
||||
{
|
||||
CreateOptions = CreateOptions | FILE_FLAG_WRITE_THROUGH;
|
||||
}
|
||||
if (dwOpenMode & FILE_FLAG_OVERLAPPED)
|
||||
{
|
||||
CreateOptions = CreateOptions | FILE_SYNCHRONOUS_IO_ALERT;
|
||||
}
|
||||
|
||||
if (dwPipeMode & PIPE_TYPE_BYTE)
|
||||
{
|
||||
WriteModeMessage = FALSE;
|
||||
}
|
||||
else if (dwPipeMode & PIPE_TYPE_MESSAGE)
|
||||
{
|
||||
WriteModeMessage = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
WriteModeMessage = FALSE;
|
||||
}
|
||||
|
||||
if (dwPipeMode & PIPE_READMODE_BYTE)
|
||||
{
|
||||
ReadModeMessage = FALSE;
|
||||
}
|
||||
else if (dwPipeMode & PIPE_READMODE_MESSAGE)
|
||||
{
|
||||
ReadModeMessage = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadModeMessage = FALSE;
|
||||
}
|
||||
|
||||
if (dwPipeMode & PIPE_WAIT)
|
||||
{
|
||||
NonBlocking = FALSE;
|
||||
}
|
||||
else if (dwPipeMode & PIPE_NOWAIT)
|
||||
{
|
||||
NonBlocking = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
NonBlocking = FALSE;
|
||||
}
|
||||
|
||||
DefaultTimeOut.QuadPart = nDefaultTimeOut * 1000 * 1000;
|
||||
|
||||
Status = NtCreateNamedPipeFile(&PipeHandle,
|
||||
DesiredAccess,
|
||||
&ObjectAttributes,
|
||||
&Iosb,
|
||||
ShareAccess,
|
||||
CreateDisposition,
|
||||
CreateOptions,
|
||||
WriteModeMessage,
|
||||
ReadModeMessage,
|
||||
NonBlocking,
|
||||
nMaxInstances,
|
||||
nInBufferSize,
|
||||
nOutBufferSize,
|
||||
&DefaultTimeOut);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(INVALID_HANDLE_VALUE);
|
||||
}
|
||||
return(PipeHandle);
|
||||
}
|
||||
|
||||
BOOL WaitNamedPipeA(LPCSTR lpNamedPipeName,
|
||||
DWORD nTimeOut)
|
||||
{
|
||||
BOOL r;
|
||||
UNICODE_STRING NameU;
|
||||
ANSI_STRING NameA;
|
||||
|
||||
RtlInitAnsiString(&NameA, lpNamedPipeName);
|
||||
RtlAnsiStringToUnicodeString(&NameU, &NameA, TRUE);
|
||||
|
||||
r = WaitNamedPipeW(NameU.Buffer, nTimeOut);
|
||||
|
||||
RtlFreeUnicodeString(&NameU);
|
||||
|
||||
return(r);
|
||||
}
|
||||
|
||||
BOOL WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||
DWORD nTimeOut)
|
||||
{
|
||||
UNICODE_STRING NamedPipeName;
|
||||
BOOL r;
|
||||
NTSTATUS Status;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
NPFS_WAIT_PIPE WaitPipe;
|
||||
HANDLE FileHandle;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
|
||||
r = RtlDosPathNameToNtPathName_U(lpNamedPipeName,
|
||||
&NamedPipeName,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if (!r)
|
||||
{
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&NamedPipeName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = NtOpenFile(&FileHandle,
|
||||
FILE_GENERIC_READ,
|
||||
&ObjectAttributes,
|
||||
&Iosb,
|
||||
0,
|
||||
FILE_SYNCHRONOUS_IO_ALERT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
WaitPipe.Timeout.QuadPart = nTimeOut * 1000 * 1000;
|
||||
|
||||
Status = NtFsControlFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&Iosb,
|
||||
FSCTL_WAIT_PIPE,
|
||||
&WaitPipe,
|
||||
sizeof(WaitPipe),
|
||||
NULL,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
NtClose(FileHandle);
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
BOOL ConnectNamedPipe(HANDLE hNamedPipe,
|
||||
LPOVERLAPPED lpOverLapped)
|
||||
{
|
||||
NPFS_LISTEN ListenPipe;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
HANDLE hEvent;
|
||||
PIO_STATUS_BLOCK IoStatusBlock;
|
||||
NTSTATUS Status;
|
||||
|
||||
if (lpOverLapped != NULL)
|
||||
{
|
||||
lpOverLapped->Internal = STATUS_PENDING;
|
||||
hEvent = lpOverLapped->hEvent;
|
||||
IoStatusBlock = (PIO_STATUS_BLOCK)lpOverLapped;
|
||||
}
|
||||
else
|
||||
{
|
||||
IoStatusBlock = &Iosb;
|
||||
hEvent = NULL;
|
||||
}
|
||||
|
||||
Status = NtFsControlFile(hNamedPipe,
|
||||
hEvent,
|
||||
NULL,
|
||||
NULL,
|
||||
IoStatusBlock,
|
||||
FSCTL_LISTEN,
|
||||
&ListenPipe,
|
||||
sizeof(ListenPipe),
|
||||
NULL,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
BOOL SetNamedPipeHandleState(HANDLE hNamedPipe,
|
||||
LPDWORD lpMode,
|
||||
LPDWORD lpMaxCollectionCount,
|
||||
LPDWORD lpCollectDataTimeout)
|
||||
{
|
||||
NPFS_GET_STATE GetState;
|
||||
NPFS_SET_STATE SetState;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = NtFsControlFile(hNamedPipe,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&Iosb,
|
||||
FSCTL_GET_STATE,
|
||||
NULL,
|
||||
0,
|
||||
&GetState,
|
||||
sizeof(GetState));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
if (lpMode != NULL)
|
||||
{
|
||||
if ((*lpMode) & PIPE_READMODE_MESSAGE)
|
||||
{
|
||||
SetState.ReadModeMessage = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetState.ReadModeMessage = FALSE;
|
||||
}
|
||||
if ((*lpMode) & PIPE_NOWAIT)
|
||||
{
|
||||
SetState.NonBlocking = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetState.NonBlocking = FALSE;
|
||||
}
|
||||
SetState.WriteModeMessage = GetState.WriteModeMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetState.ReadModeMessage = GetState.ReadModeMessage;
|
||||
SetState.WriteModeMessage = GetState.WriteModeMessage;
|
||||
SetState.NonBlocking = SetState.NonBlocking;
|
||||
}
|
||||
|
||||
if (lpMaxCollectionCount != NULL)
|
||||
{
|
||||
SetState.InBufferSize = *lpMaxCollectionCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetState.InBufferSize = GetState.InBufferSize;
|
||||
}
|
||||
|
||||
SetState.OutBufferSize = GetState.OutBufferSize;
|
||||
|
||||
if (lpCollectDataTimeout != NULL)
|
||||
{
|
||||
SetState.Timeout.QuadPart = (*lpCollectDataTimeout) * 1000 * 1000;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetState.Timeout = GetState.Timeout;
|
||||
}
|
||||
|
||||
Status = NtFsControlFile(hNamedPipe,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&Iosb,
|
||||
FSCTL_SET_STATE,
|
||||
&SetState,
|
||||
sizeof(SetState),
|
||||
NULL,
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastError(RtlNtStatusToDosError(Status));
|
||||
return(FALSE);
|
||||
}
|
||||
return(TRUE);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rw.c,v 1.11 2000/04/03 21:54:35 dwelch Exp $
|
||||
/* $Id: rw.c,v 1.12 2000/05/13 13:50:56 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -157,22 +157,19 @@ VOID ApcRoutine(PVOID ApcContext,
|
|||
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine =
|
||||
(LPOVERLAPPED_COMPLETION_ROUTINE)ApcContext;
|
||||
|
||||
dwErrorCode = RtlNtStatusToDosError( IoStatusBlock->Status);
|
||||
dwErrorCode = RtlNtStatusToDosError(IoStatusBlock->Status);
|
||||
lpCompletionRoutine(dwErrorCode,
|
||||
NumberOfBytesTransfered,
|
||||
(LPOVERLAPPED)IoStatusBlock);
|
||||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
WriteFileEx (
|
||||
HANDLE hFile,
|
||||
LPCVOID lpBuffer,
|
||||
DWORD nNumberOfBytesToWrite,
|
||||
LPOVERLAPPED lpOverLapped,
|
||||
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
|
||||
)
|
||||
WINBOOL STDCALL WriteFileEx (HANDLE hFile,
|
||||
LPCVOID lpBuffer,
|
||||
DWORD nNumberOfBytesToWrite,
|
||||
LPOVERLAPPED lpOverLapped,
|
||||
LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine
|
||||
)
|
||||
{
|
||||
|
||||
LARGE_INTEGER Offset;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# $Id: makefile,v 1.33 2000/04/25 23:22:53 ea Exp $
|
||||
# $Id: makefile,v 1.34 2000/05/13 13:50:56 dwelch Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
|
@ -32,7 +32,8 @@ MISC_OBJECTS = misc/error.o misc/atom.o misc/handle.o misc/env.o misc/dllmain.o
|
|||
FILE_OBJECTS = file/file.o file/curdir.o file/lfile.o file/dir.o \
|
||||
file/iocompl.o file/volume.o file/deviceio.o file/dosdev.o \
|
||||
file/create.o file/find.o file/copy.o file/pipe.o \
|
||||
file/move.o file/lock.o file/rw.o file/delete.o
|
||||
file/move.o file/lock.o file/rw.o file/delete.o \
|
||||
file/npipe.o
|
||||
|
||||
MEM_OBJECTS = mem/virtual.o mem/heap.o mem/utils.o mem/section.o mem/isbad.o mem/procmem.o
|
||||
|
||||
|
@ -59,7 +60,8 @@ NLS_OBJECTS = nls/codepage.o nls/cpmisc.o nls/cptable.o\
|
|||
|
||||
THREAD_OBJECTS = thread/thread.o thread/tls.o
|
||||
|
||||
PROCESS_OBJECTS = process/proc.o process/cmdline.o process/create.o
|
||||
PROCESS_OBJECTS = process/proc.o process/cmdline.o process/create.o \
|
||||
process/lib.o
|
||||
|
||||
STRING_OBJECTS = string/lstring.o
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: stubs.c,v 1.15 2000/04/25 23:22:54 ea Exp $
|
||||
/* $Id: stubs.c,v 1.16 2000/05/13 13:50:57 dwelch Exp $
|
||||
*
|
||||
* KERNEL32.DLL stubs (unimplemented functions)
|
||||
* Remove from this file, if you implement them.
|
||||
|
@ -319,17 +319,6 @@ CompareStringW (
|
|||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
ConnectNamedPipe (
|
||||
HANDLE hNamedPipe,
|
||||
LPOVERLAPPED lpOverlapped
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL
|
||||
STDCALL
|
||||
|
@ -344,6 +333,19 @@ ConsoleMenuControl (
|
|||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
ContinueDebugEvent (
|
||||
DWORD dwProcessId,
|
||||
DWORD dwThreadId,
|
||||
DWORD dwContinueStatus
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
LCID
|
||||
STDCALL
|
||||
ConvertDefaultLocale (
|
||||
|
@ -383,40 +385,6 @@ CreateMailslotW (
|
|||
}
|
||||
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
CreateNamedPipeW (
|
||||
LPCWSTR lpName,
|
||||
DWORD dwOpenMode,
|
||||
DWORD dwPipeMode,
|
||||
DWORD nMaxInstances,
|
||||
DWORD nOutBufferSize,
|
||||
DWORD nInBufferSize,
|
||||
DWORD nDefaultTimeOut,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
|
||||
HANDLE
|
||||
STDCALL
|
||||
CreateNamedPipeA (
|
||||
LPCSTR lpName,
|
||||
DWORD dwOpenMode,
|
||||
DWORD dwPipeMode,
|
||||
DWORD nMaxInstances,
|
||||
DWORD nOutBufferSize,
|
||||
DWORD nInBufferSize,
|
||||
DWORD nDefaultTimeOut,
|
||||
LPSECURITY_ATTRIBUTES lpSecurityAttributes
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
|
||||
DWORD
|
||||
|
@ -3448,13 +3416,12 @@ SetMailslotInfo (
|
|||
}
|
||||
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
SetNamedPipeHandleState (
|
||||
HANDLE hNamedPipe,
|
||||
LPDWORD lpMode,
|
||||
LPDWORD lpMaxCollectionCount,
|
||||
LPDWORD lpCollectDataTimeout
|
||||
SetPriorityClass (
|
||||
HANDLE hProcess,
|
||||
DWORD dwPriorityClass
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
|
@ -3743,9 +3710,9 @@ WaitCommEvent (
|
|||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
WaitNamedPipeA (
|
||||
LPCSTR lpNamedPipeName,
|
||||
DWORD nTimeOut
|
||||
WaitForDebugEvent (
|
||||
LPDEBUG_EVENT lpDebugEvent,
|
||||
DWORD dwMilliseconds
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
|
@ -3753,17 +3720,6 @@ WaitNamedPipeA (
|
|||
}
|
||||
|
||||
|
||||
WINBOOL
|
||||
STDCALL
|
||||
WaitNamedPipeW (
|
||||
LPCWSTR lpNamedPipeName,
|
||||
DWORD nTimeOut
|
||||
)
|
||||
{
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
STDCALL
|
||||
|
|
|
@ -1,25 +1,15 @@
|
|||
# $Id: makefile,v 1.45 2000/04/15 23:09:39 ekohl Exp $
|
||||
# $Id: makefile,v 1.46 2000/05/13 13:50:57 dwelch Exp $
|
||||
#
|
||||
# ReactOS Operating System
|
||||
#
|
||||
TARGET=ntdll
|
||||
TARGET = ntdll
|
||||
|
||||
BASE_CFLAGS = -I../../include -D__NTDLL__
|
||||
|
||||
IMAGE_BASE = 0x77f60000
|
||||
|
||||
ifneq ($(HOST),mingw32-windows)
|
||||
ifneq ($(HOST),mingw32-linux)
|
||||
DLLTARGET=$(TARGET).a
|
||||
DLLMAIN=
|
||||
else
|
||||
DLLTARGET=$(TARGET).dll
|
||||
DLLMAIN=main/dllmain.o
|
||||
endif
|
||||
else
|
||||
DLLTARGET=$(TARGET).dll
|
||||
DLLMAIN=main/dllmain.o
|
||||
endif
|
||||
DLLTARGET=$(TARGET).dll
|
||||
DLLMAIN=main/dllmain.o
|
||||
|
||||
all: $(DLLTARGET)
|
||||
|
||||
|
@ -31,7 +21,7 @@ RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \
|
|||
rtl/math.o rtl/mem.o rtl/nls.o rtl/process.o rtl/sd.o \
|
||||
rtl/thread.o rtl/unicode.o rtl/env.o rtl/path.o rtl/ppb.o \
|
||||
rtl/bitmap.o rtl/time.o rtl/acl.o rtl/sid.o rtl/image.o \
|
||||
rtl/access.o rtl/luid.o
|
||||
rtl/access.o rtl/apc.o rtl/callback.o luid.o
|
||||
|
||||
STDIO_OBJECTS = stdio/sprintf.o stdio/swprintf.o
|
||||
|
||||
|
|
30
reactos/lib/ntdll/rtl/apc.c
Normal file
30
reactos/lib/ntdll/rtl/apc.c
Normal file
|
@ -0,0 +1,30 @@
|
|||
/* $Id: apc.c,v 1.1 2000/05/13 13:50:57 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: User-mode APC support
|
||||
* FILE: lib/ntdll/rtl/apc.c
|
||||
* PROGRAMER: David Welch <welch@cwcom.net>
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID KiUserApcDispatcher(PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK Iosb,
|
||||
ULONG Reserved,
|
||||
PCONTEXT Context)
|
||||
{
|
||||
ApcRoutine(ApcContext,
|
||||
Iosb,
|
||||
Reserved);;
|
||||
NtContinue(Context, 1);
|
||||
}
|
||||
|
36
reactos/lib/ntdll/rtl/callback.c
Normal file
36
reactos/lib/ntdll/rtl/callback.c
Normal file
|
@ -0,0 +1,36 @@
|
|||
/* $Id: callback.c,v 1.1 2000/05/13 13:50:57 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: User-mode callback support
|
||||
* FILE: lib/ntdll/rtl/callback.c
|
||||
* PROGRAMER: David Welch <welch@cwcom.net>
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <string.h>
|
||||
#include <internal/teb.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* TYPES *********************************************************************/
|
||||
|
||||
typedef NTSTATUS (*CALLBACK_FUNCTION)(PVOID Argument, ULONG ArgumentLength);
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID KiUserCallbackDispatcher(ULONG RoutineIndex,
|
||||
PVOID Argument,
|
||||
ULONG ArgumentLength)
|
||||
{
|
||||
PPEB Peb;
|
||||
NTSTATUS Status;
|
||||
CALLBACK_FUNCTION Callback;
|
||||
|
||||
Peb = NtCurrentPeb();
|
||||
Callback = (CALLBACK_FUNCTION)Peb->KernelCallbackTable[RoutineIndex];
|
||||
Status = Callback(Argument, ArgumentLength);
|
||||
ZwCallbackReturn(NULL, 0, Status);
|
||||
}
|
23
reactos/lib/ntdll/rtl/exception.c
Normal file
23
reactos/lib/ntdll/rtl/exception.c
Normal file
|
@ -0,0 +1,23 @@
|
|||
/* $Id: exception.c,v 1.1 2000/05/13 13:50:57 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* PURPOSE: User-mode exception support
|
||||
* FILE: lib/ntdll/rtl/exception.c
|
||||
* PROGRAMER: David Welch <welch@cwcom.net>
|
||||
*/
|
||||
|
||||
/* INCLUDES *****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
VOID KiUserExceptionDispatcher(PEXCEPTION_RECORD ExceptionRecord,
|
||||
PCONTEXT Context)
|
||||
{
|
||||
|
||||
}
|
|
@ -30,8 +30,6 @@ STUB(DbgSsInitialize)
|
|||
STUB(DbgUiConnectToDbg)
|
||||
STUB(DbgUiWaitStateChange)
|
||||
STUB(KiRaiseUserExceptionDispatcher)
|
||||
STUB(KiUserApcDispatcher)
|
||||
STUB(KiUserCallbackDispatcher)
|
||||
STUB(KiUserExceptionDispatcher)
|
||||
|
||||
STUB(LdrDisableThreadCalloutsForDll)
|
||||
|
|
|
@ -1,47 +1,6 @@
|
|||
RPC_STATUS RpcBindingFromStringBindingW(PWCHAR Binding,
|
||||
handle_t* BindingHandle)
|
||||
{
|
||||
RPC_STATUS Status;
|
||||
ULONG Length;
|
||||
PWCHAR TBinding;
|
||||
PVOID SomeStruct;
|
||||
ULONG a;
|
||||
|
||||
if (IsRpcInitialized)
|
||||
{
|
||||
Status = PerformRpcInitialization();
|
||||
if (Status != 0)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
|
||||
*BindingHandle = 0;
|
||||
Length = wcslen(Binding);
|
||||
Length = ((Length*2) + 5) & 0xfc;
|
||||
TBinding = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
Length);
|
||||
if (TBinding != NULL)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
wcscpy(TBinding, Binding);
|
||||
|
||||
SomeStruct = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
0x20);
|
||||
if (SomeStruct != NULL)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
Status = fn_77E16A0D(TBinding, &a);
|
||||
if (Status != 0)
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
43
reactos/lib/rpcrt4/include/rpcrt4/rpc.h
Normal file
43
reactos/lib/rpcrt4/include/rpcrt4/rpc.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
#ifndef __INCLUDE_RPCRT4_RPC_H
|
||||
#define __INCLUDE_RPCRT4_RPC_H
|
||||
|
||||
typedef void* RPC_BINDING_HANDLE;
|
||||
typedef long RPC_STATUS;
|
||||
|
||||
typedef ULONG RPC_PROTOCOL_ID;
|
||||
typedef ULONG RPC_PROTSEQ_ID;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
RPC_PROTSEQ_ID ProtseqId;
|
||||
ULONG Len;
|
||||
sockaddr_t sa;
|
||||
} *PRPC_ADDR;
|
||||
|
||||
typedef struct _RPC_PROTOCOL_VERSION
|
||||
{
|
||||
ULONG MajorVersion;
|
||||
ULONG MinorVersion;
|
||||
} RPC_PROTOCOL_VERSION, *PRPC_PROTOCOL_VERSION;
|
||||
|
||||
typedef struct _RPC_BINDING_REP
|
||||
{
|
||||
LIST_ENTRY ListEntry;
|
||||
RPC_PROTOCOL_ID ProtocolId;
|
||||
LONG ReferenceCount;
|
||||
UUID ObjectId;
|
||||
PRPC_ADDR RpcAddr;
|
||||
BOOLEAN IsServer;
|
||||
BOOLEAN AddrIsDynamic;
|
||||
PVOID AuthInfo;
|
||||
ULONG ExtendedBindFlag;
|
||||
ULONG BoundServerInstance;
|
||||
ULONG AddrHasEndpoint;
|
||||
LONG CallsInProgress;
|
||||
PVOID NsSpecific;
|
||||
PRPC_PROTOCOL_VERSION ProtocolVersion;
|
||||
} RPC_BINDING_REP, *PRPC_BINDING_REP;
|
||||
|
||||
|
||||
|
||||
#endif /* __INCLUDE_RPCRT4_RPC_H */
|
|
@ -9,6 +9,7 @@ char* id;
|
|||
int number;
|
||||
char* uuid;
|
||||
char operator;
|
||||
char* string;
|
||||
struct
|
||||
{
|
||||
int minor;
|
||||
|
@ -16,10 +17,16 @@ int major;
|
|||
} version;
|
||||
}
|
||||
|
||||
%token <id> ID_TOKEN
|
||||
%token <uuid> UUID_TOKEN
|
||||
%token NUMBER_TOKEN
|
||||
%token <version> VERSION_TOKEN
|
||||
%token <id> ID_LITERAL
|
||||
%token <uuid> UUID_LITERAL
|
||||
%token NUMBER_LITERAL
|
||||
%token <version> VERSION_LITERAL
|
||||
%token STRING_LITERAL
|
||||
|
||||
%token ENDPOINT_KEYWORD
|
||||
%token EXCEPTIONS_KEYWORD
|
||||
%token LOCAL_KEYWORD
|
||||
%token IMPORT_KEYWORD
|
||||
|
||||
%token UUID_KEYWORD
|
||||
%token VERSION_KEYWORD
|
||||
|
@ -78,24 +85,46 @@ option:
|
|||
{ set_uuid($3); }
|
||||
| VERSION_KEYWORD LEFT_BRACKET VERSION_TOKEN RIGHT_BRACKET
|
||||
{ set_version($3.major, $3.minor); }
|
||||
| ENDPOINT_KEYWORD LEFT_BRACKET port_specs RIGHT_BRACKET
|
||||
| EXCEPTIONS_KEYWORD LEFT_BRACKET excep_names RIGHT_BRACKET
|
||||
| LOCAL_KEYWORD
|
||||
| POINTER_DEFAULT_KEYWORD LEFT_BRACKET UNIQUE_KEYWORD RIGHT_BRACKET
|
||||
{ set_pointer_default($3); }
|
||||
{ set_pointer_default($3); }
|
||||
;
|
||||
|
||||
port_specs:
|
||||
| STRING_TOKEN COMMA port_specs
|
||||
;
|
||||
|
||||
excep_names: ID_TOKEN { }
|
||||
| ID_TOKEN COMMA excep_names { }
|
||||
;
|
||||
|
||||
interface: { start_interface(); }
|
||||
INTERFACE_KEYWORD ID_TOKEN LCURLY_BRACKET functions RCURLY_BRACKET
|
||||
INTERFACE_KEYWORD ID_TOKEN LCURLY_BRACKET interface_components
|
||||
RCURLY_BRACKET
|
||||
{ end_interface($3); }
|
||||
|
||||
functions:
|
||||
| function LINE_TERMINATOR functions
|
||||
| TYPEDEF_KEYWORD typedef LINE_TERMINATOR functions
|
||||
| const LINE_TERMINATOR functions
|
||||
| STRUCT_KEYWORD struct_def RCURLY_BRACKET LINE_TERMINATOR functions
|
||||
interface_components:
|
||||
| interface_component LINE_TERMINATOR interface_components
|
||||
|
||||
interface_component:
|
||||
| IMPORT_KEYWORD import_list
|
||||
| function
|
||||
| TYPEDEF_KEYWORD typedef
|
||||
| CONST_KEYWORD type ID_TOKEN ASSIGNMENT const_expr
|
||||
| STRUCT_KEYWORD struct_def RCURLY_BRACKET
|
||||
;
|
||||
|
||||
const: CONST_KEYWORD type ID_TOKEN ASSIGNMENT ID_TOKEN
|
||||
| CONST_KEYWORD type ID_TOKEN ASSIGNMENT NUMBER_TOKEN
|
||||
;
|
||||
import_list: STRING_TOKEN
|
||||
| STRING_TOKEN COMMA import_list
|
||||
;
|
||||
|
||||
const_expr: NUMBER_TOKEN
|
||||
| STRING_TOKEN
|
||||
;
|
||||
|
||||
|
||||
|
||||
typedef: type ID_TOKEN { add_typedef($2, $1); };
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ static type types[255] = {
|
|||
{"byte", BYTE_TYPE, 0},
|
||||
{"char", CHAR_TYPE, UNSIGNED_TYPE_OPTION},
|
||||
{"double", DOUBLE_TYPE, 0},
|
||||
{"enum", ENUM_TYPE, 0},
|
||||
{"error_status_t", ERROR_STATUS_TYPE, UNSIGNED_TYPE_OPTION},
|
||||
{"float", FLOAT_TYPE, 0},
|
||||
{"handle_t", HANDLE_TYPE, 0},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: buildirp.c,v 1.20 2000/03/26 19:38:21 ea Exp $
|
||||
/* $Id: buildirp.c,v 1.21 2000/05/13 13:50:59 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -144,7 +144,7 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
|||
* NULL on failure
|
||||
*/
|
||||
{
|
||||
PIRP Irp;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
|
||||
DPRINT("IoBuildAsynchronousFsdRequest(MajorFunction %x, DeviceObject %x, "
|
||||
|
@ -211,17 +211,15 @@ IoBuildAsynchronousFsdRequest(ULONG MajorFunction,
|
|||
return(Irp);
|
||||
}
|
||||
|
||||
PIRP
|
||||
STDCALL
|
||||
IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PVOID InputBuffer,
|
||||
ULONG InputBufferLength,
|
||||
PVOID OutputBuffer,
|
||||
ULONG OutputBufferLength,
|
||||
BOOLEAN InternalDeviceIoControl,
|
||||
PKEVENT Event,
|
||||
PIO_STATUS_BLOCK IoStatusBlock)
|
||||
PIRP STDCALL IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PVOID InputBuffer,
|
||||
ULONG InputBufferLength,
|
||||
PVOID OutputBuffer,
|
||||
ULONG OutputBufferLength,
|
||||
BOOLEAN InternalDeviceIoControl,
|
||||
PKEVENT Event,
|
||||
PIO_STATUS_BLOCK IoStatusBlock)
|
||||
/*
|
||||
* FUNCTION: Allocates and sets up an IRP to be sent to drivers
|
||||
* ARGUMENTS:
|
||||
|
@ -245,17 +243,17 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
|||
ULONG BufferLength;
|
||||
|
||||
DPRINT("IoBuildDeviceIoRequest(IoControlCode %x, DeviceObject %x, "
|
||||
"InputBuffer %x, InputBufferLength %x, OutputBuffer %x, "
|
||||
"OutputBufferLength %x, InternalDeviceIoControl %x "
|
||||
"Event %x, IoStatusBlock %x\n",IoControlCode,DeviceObject,
|
||||
InputBuffer,InputBufferLength,OutputBuffer,OutputBufferLength,
|
||||
InternalDeviceIoControl,Event,IoStatusBlock);
|
||||
"InputBuffer %x, InputBufferLength %x, OutputBuffer %x, "
|
||||
"OutputBufferLength %x, InternalDeviceIoControl %x "
|
||||
"Event %x, IoStatusBlock %x\n",IoControlCode,DeviceObject,
|
||||
InputBuffer,InputBufferLength,OutputBuffer,OutputBufferLength,
|
||||
InternalDeviceIoControl,Event,IoStatusBlock);
|
||||
|
||||
Irp = IoAllocateIrp(DeviceObject->StackSize,TRUE);
|
||||
if (Irp==NULL)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
Irp->UserEvent = Event;
|
||||
Irp->UserIosb = IoStatusBlock;
|
||||
|
@ -263,7 +261,8 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
|||
Irp->Tail.Overlay.Thread = PsGetCurrentThread();
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->MajorFunction = InternalDeviceIoControl ? IRP_MJ_INTERNAL_DEVICE_CONTROL : IRP_MJ_DEVICE_CONTROL;
|
||||
StackPtr->MajorFunction = InternalDeviceIoControl ?
|
||||
IRP_MJ_INTERNAL_DEVICE_CONTROL : IRP_MJ_DEVICE_CONTROL;
|
||||
StackPtr->MinorFunction = 0;
|
||||
StackPtr->Flags = 0;
|
||||
StackPtr->Control = 0;
|
||||
|
@ -272,102 +271,114 @@ IoBuildDeviceIoControlRequest(ULONG IoControlCode,
|
|||
StackPtr->CompletionRoutine = NULL;
|
||||
StackPtr->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
|
||||
StackPtr->Parameters.DeviceIoControl.InputBufferLength = InputBufferLength;
|
||||
StackPtr->Parameters.DeviceIoControl.OutputBufferLength = OutputBufferLength;
|
||||
StackPtr->Parameters.DeviceIoControl.OutputBufferLength =
|
||||
OutputBufferLength;
|
||||
|
||||
switch (IO_METHOD_FROM_CTL_CODE(IoControlCode))
|
||||
{
|
||||
case METHOD_BUFFERED:
|
||||
DPRINT("Using METHOD_BUFFERED!\n");
|
||||
{
|
||||
case METHOD_BUFFERED:
|
||||
DPRINT("Using METHOD_BUFFERED!\n");
|
||||
|
||||
BufferLength = (InputBufferLength>OutputBufferLength)?InputBufferLength:OutputBufferLength;
|
||||
if (BufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
ExAllocatePool(NonPagedPool,BufferLength);
|
||||
if (InputBufferLength > OutputBufferLength)
|
||||
{
|
||||
BufferLength = InputBufferLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
BufferLength = OutputBufferLength;
|
||||
}
|
||||
if (BufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
ExAllocatePool(NonPagedPool,BufferLength);
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
if (Irp->AssociatedIrp.SystemBuffer == NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
Irp->UserBuffer = OutputBuffer;
|
||||
break;
|
||||
|
||||
case METHOD_IN_DIRECT:
|
||||
DPRINT("Using METHOD_IN_DIRECT!\n");
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
Irp->UserBuffer = OutputBuffer;
|
||||
break;
|
||||
|
||||
case METHOD_IN_DIRECT:
|
||||
DPRINT("Using METHOD_IN_DIRECT!\n");
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
ExAllocatePool(NonPagedPool,InputBufferLength);
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer == NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
|
||||
/* build output buffer (data transfer buffer) */
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
{
|
||||
Irp->MdlAddress = IoAllocateMdl (OutputBuffer,OutputBufferLength,FALSE,FALSE,Irp);
|
||||
MmProbeAndLockPages (Irp->MdlAddress,UserMode,IoReadAccess);
|
||||
}
|
||||
break;
|
||||
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
{
|
||||
Irp->MdlAddress = IoAllocateMdl(OutputBuffer,
|
||||
OutputBufferLength,
|
||||
FALSE,
|
||||
FALSE,
|
||||
Irp);
|
||||
MmProbeAndLockPages (Irp->MdlAddress,UserMode,IoReadAccess);
|
||||
}
|
||||
break;
|
||||
|
||||
case METHOD_OUT_DIRECT:
|
||||
DPRINT("Using METHOD_OUT_DIRECT!\n");
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
DPRINT("Using METHOD_OUT_DIRECT!\n");
|
||||
|
||||
/* build input buffer (control buffer) */
|
||||
if (InputBuffer && InputBufferLength)
|
||||
{
|
||||
Irp->AssociatedIrp.SystemBuffer = (PVOID)
|
||||
ExAllocatePool(NonPagedPool,InputBufferLength);
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
if (Irp->AssociatedIrp.SystemBuffer==NULL)
|
||||
{
|
||||
IoFreeIrp(Irp);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer,
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
|
||||
/* build output buffer (data transfer buffer) */
|
||||
InputBuffer,
|
||||
InputBufferLength);
|
||||
}
|
||||
|
||||
/* build output buffer (data transfer buffer) */
|
||||
if (OutputBuffer && OutputBufferLength)
|
||||
{
|
||||
Irp->MdlAddress = IoAllocateMdl(OutputBuffer,
|
||||
OutputBufferLength,
|
||||
FALSE,
|
||||
FALSE,
|
||||
{
|
||||
Irp->MdlAddress = IoAllocateMdl(OutputBuffer,
|
||||
OutputBufferLength,
|
||||
FALSE,
|
||||
FALSE,
|
||||
Irp);
|
||||
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
||||
}
|
||||
break;
|
||||
|
||||
MmProbeAndLockPages(Irp->MdlAddress,UserMode,IoWriteAccess);
|
||||
}
|
||||
break;
|
||||
|
||||
case METHOD_NEITHER:
|
||||
DPRINT("Using METHOD_NEITHER!\n");
|
||||
|
||||
Irp->UserBuffer = OutputBuffer;
|
||||
StackPtr->Parameters.DeviceIoControl.Type3InputBuffer = InputBuffer;
|
||||
break;
|
||||
}
|
||||
DPRINT("Using METHOD_NEITHER!\n");
|
||||
|
||||
Irp->UserBuffer = OutputBuffer;
|
||||
StackPtr->Parameters.DeviceIoControl.Type3InputBuffer = InputBuffer;
|
||||
break;
|
||||
}
|
||||
|
||||
return(Irp);
|
||||
}
|
||||
|
|
|
@ -27,7 +27,13 @@ VOID IopCompleteRequest1(struct _KAPC* Apc,
|
|||
PVOID* SystemArgument1,
|
||||
PVOID* SystemArgument2)
|
||||
{
|
||||
PIRP Irp;
|
||||
|
||||
DPRINT("IopCompleteRequest1()\n");
|
||||
|
||||
Irp = (PIRP)(*SystemArgument1);
|
||||
(*SystemArgument1) = (PVOID)Irp->UserIosb;
|
||||
(*SystemArgument2) = (PVOID)Irp->IoStatus.Information;
|
||||
IoFreeIrp((PIRP)(*SystemArgument1));
|
||||
}
|
||||
|
||||
|
@ -179,19 +185,23 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost)
|
|||
if (Irp->Overlay.AsynchronousParameters.UserApcRoutine != NULL)
|
||||
{
|
||||
PKTHREAD Thread;
|
||||
PKNORMAL_ROUTINE UserApcRoutine;
|
||||
PVOID UserApcContext;
|
||||
|
||||
DPRINT("Dispatching APC\n");
|
||||
Thread = &Irp->Tail.Overlay.Thread->Tcb;
|
||||
UserApcRoutine = (PKNORMAL_ROUTINE)
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine;
|
||||
UserApcContext = (PVOID)
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine;
|
||||
KeInitializeApc(&Irp->Tail.Apc,
|
||||
Thread,
|
||||
0,
|
||||
IopCompleteRequest1,
|
||||
NULL,
|
||||
(PKNORMAL_ROUTINE)
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine,
|
||||
UserApcRoutine,
|
||||
UserMode,
|
||||
(PVOID)
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext);
|
||||
UserApcContext);
|
||||
KeInsertQueueApc(&Irp->Tail.Apc,
|
||||
Irp,
|
||||
NULL,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: fs.c,v 1.12 2000/03/26 19:38:24 ea Exp $
|
||||
/* $Id: fs.c,v 1.13 2000/05/13 13:51:00 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -47,101 +47,63 @@ NtFsControlFile (
|
|||
IN ULONG OutputBufferSize
|
||||
)
|
||||
{
|
||||
NTSTATUS Status = -1;
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
KEVENT Event;
|
||||
|
||||
if (InputBufferSize > 0)
|
||||
{
|
||||
Status = ObReferenceObjectByHandle(DeviceHandle,
|
||||
FILE_WRITE_DATA|FILE_READ_DATA,
|
||||
NULL,
|
||||
UserMode,
|
||||
(PVOID *) &FileObject,
|
||||
NULL);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_DEVICE_CONTROL,
|
||||
FileObject->DeviceObject,
|
||||
InputBuffer,
|
||||
InputBufferSize,
|
||||
0,
|
||||
&Event,
|
||||
IoStatusBlock);
|
||||
if (Irp == NULL)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
if (StackPtr == NULL)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
StackPtr->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
|
||||
StackPtr->FileObject = FileObject;
|
||||
StackPtr->Parameters.Write.Length = InputBufferSize;
|
||||
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||
Status = IoCallDriver(FileObject->DeviceObject,Irp);
|
||||
if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
{
|
||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||
}
|
||||
ObDereferenceObject(FileObject);
|
||||
return(Irp->IoStatus.Status);
|
||||
}
|
||||
KEVENT KEvent;
|
||||
|
||||
if (OutputBufferSize > 0)
|
||||
DPRINT("NtFsControlFile(DeviceHandle %x Event %x UserApcRoutine %x "
|
||||
"UserApcContext %x IoStatusBlock %x IoControlCode %x "
|
||||
"InputBuffer %x InputBufferSize %x OutputBuffer %x "
|
||||
"OutputBufferSize %x)\n",
|
||||
DeviceHandle,Event,UserApcRoutine,UserApcContext,IoStatusBlock,
|
||||
IoControlCode,InputBuffer,InputBufferSize,OutputBuffer,
|
||||
OutputBufferSize);
|
||||
|
||||
Status = ObReferenceObjectByHandle(DeviceHandle,
|
||||
FILE_READ_DATA | FILE_WRITE_DATA,
|
||||
NULL,
|
||||
KernelMode,
|
||||
(PVOID *) &FileObject,
|
||||
NULL);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
CHECKPOINT;
|
||||
Status = ObReferenceObjectByHandle(DeviceHandle,
|
||||
FILE_WRITE_DATA|FILE_READ_DATA,
|
||||
NULL,
|
||||
UserMode,
|
||||
(PVOID *) &FileObject,
|
||||
NULL);
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
CHECKPOINT;
|
||||
KeInitializeEvent(&Event,NotificationEvent,FALSE);
|
||||
CHECKPOINT;
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_DEVICE_CONTROL,
|
||||
FileObject->DeviceObject,
|
||||
OutputBuffer,
|
||||
OutputBufferSize,
|
||||
0,
|
||||
&Event,
|
||||
IoStatusBlock);
|
||||
if (Irp == NULL)
|
||||
{
|
||||
ObDereferenceObject(FileObject);
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
if (StackPtr == NULL)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
StackPtr->Parameters.DeviceIoControl.IoControlCode = IoControlCode;
|
||||
StackPtr->FileObject = FileObject;
|
||||
StackPtr->Parameters.Read.Length = OutputBufferSize;
|
||||
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||
Status = IoCallDriver(FileObject->DeviceObject,Irp);
|
||||
if (Status==STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
{
|
||||
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
|
||||
}
|
||||
return(Irp->IoStatus.Status);
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DeviceObject = FileObject->DeviceObject;
|
||||
|
||||
KeInitializeEvent(&KEvent,NotificationEvent,TRUE);
|
||||
|
||||
Irp = IoBuildDeviceIoControlRequest(IoControlCode,
|
||||
DeviceObject,
|
||||
InputBuffer,
|
||||
InputBufferSize,
|
||||
OutputBuffer,
|
||||
OutputBufferSize,
|
||||
FALSE,
|
||||
&KEvent,
|
||||
IoStatusBlock);
|
||||
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->DeviceObject = DeviceObject;
|
||||
StackPtr->Parameters.FileSystemControl.InputBufferLength = InputBufferSize;
|
||||
StackPtr->Parameters.FileSystemControl.OutputBufferLength =
|
||||
OutputBufferSize;
|
||||
StackPtr->MajorFunction = IRP_MJ_FILE_SYSTEM_CONTROL;
|
||||
|
||||
Status = IoCallDriver(DeviceObject,Irp);
|
||||
if (Status == STATUS_PENDING && (FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
{
|
||||
KeWaitForSingleObject(&KEvent,Executive,KernelMode,FALSE,NULL);
|
||||
return(IoStatusBlock->Status);
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
@ -234,9 +196,7 @@ NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject)
|
|||
return(STATUS_UNRECOGNIZED_VOLUME);
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||
VOID STDCALL IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
FILE_SYSTEM_OBJECT* fs;
|
||||
|
||||
|
@ -250,9 +210,7 @@ IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
|||
&FileSystemListLock);
|
||||
}
|
||||
|
||||
VOID
|
||||
STDCALL
|
||||
IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||
VOID STDCALL IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
PLIST_ENTRY current_entry;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: ioctrl.c,v 1.9 2000/04/24 04:17:55 phreak Exp $
|
||||
/* $Id: ioctrl.c,v 1.10 2000/05/13 13:51:02 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -28,20 +28,16 @@ ULONG IoGetFunctionCodeFromCtlCode(ULONG ControlCode)
|
|||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtDeviceIoControlFile (
|
||||
IN HANDLE DeviceHandle,
|
||||
IN HANDLE Event OPTIONAL,
|
||||
IN PIO_APC_ROUTINE UserApcRoutine,
|
||||
IN PVOID UserApcContext OPTIONAL,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG IoControlCode,
|
||||
IN PVOID InputBuffer,
|
||||
IN ULONG InputBufferSize,
|
||||
OUT PVOID OutputBuffer,
|
||||
IN ULONG OutputBufferSize
|
||||
)
|
||||
NTSTATUS STDCALL NtDeviceIoControlFile (IN HANDLE DeviceHandle,
|
||||
IN HANDLE Event,
|
||||
IN PIO_APC_ROUTINE UserApcRoutine,
|
||||
IN PVOID UserApcContext,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG IoControlCode,
|
||||
IN PVOID InputBuffer,
|
||||
IN ULONG InputBufferSize,
|
||||
OUT PVOID OutputBuffer,
|
||||
IN ULONG OutputBufferSize)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
|
@ -50,8 +46,6 @@ NtDeviceIoControlFile (
|
|||
PIO_STACK_LOCATION StackPtr;
|
||||
KEVENT KEvent;
|
||||
|
||||
assert_irql(PASSIVE_LEVEL);
|
||||
|
||||
DPRINT("NtDeviceIoControlFile(DeviceHandle %x Event %x UserApcRoutine %x "
|
||||
"UserApcContext %x IoStatusBlock %x IoControlCode %x "
|
||||
"InputBuffer %x InputBufferSize %x OutputBuffer %x "
|
||||
|
@ -66,14 +60,13 @@ NtDeviceIoControlFile (
|
|||
KernelMode,
|
||||
(PVOID *) &FileObject,
|
||||
NULL);
|
||||
|
||||
if (Status != STATUS_SUCCESS)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DeviceObject = FileObject->DeviceObject;
|
||||
assert(DeviceObject != NULL);
|
||||
|
||||
KeInitializeEvent(&KEvent,NotificationEvent,TRUE);
|
||||
|
||||
|
|
|
@ -23,13 +23,13 @@ NTSTATUS STDCALL NtCreateNamedPipeFile(
|
|||
IN ACCESS_MASK DesiredAccess,
|
||||
IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||
OUT PIO_STATUS_BLOCK IoStatusBlock,
|
||||
IN ULONG FileAttributes,
|
||||
IN ULONG ShareAccess,
|
||||
IN ULONG OpenMode,
|
||||
IN ULONG PipeType,
|
||||
IN ULONG PipeRead,
|
||||
IN ULONG PipeWait,
|
||||
IN ULONG MaxInstances,
|
||||
ULONG ShareAccess,
|
||||
ULONG CreateDisposition,
|
||||
ULONG CreateOptions,
|
||||
BOOLEAN WriteModeMessage,
|
||||
BOOLEAN ReadModeMessage,
|
||||
BOOLEAN NonBlocking,
|
||||
ULONG MaxInstances,
|
||||
IN ULONG InBufferSize,
|
||||
IN ULONG OutBufferSize,
|
||||
IN PLARGE_INTEGER TimeOut)
|
||||
|
@ -58,12 +58,12 @@ NTSTATUS STDCALL NtCreateNamedPipeFile(
|
|||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
if (OpenMode & FILE_SYNCHRONOUS_IO_ALERT)
|
||||
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
|
||||
{
|
||||
FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
|
||||
FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
|
||||
}
|
||||
if (OpenMode & FILE_SYNCHRONOUS_IO_NONALERT)
|
||||
if (CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT)
|
||||
{
|
||||
FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
|
||||
}
|
||||
|
@ -85,21 +85,23 @@ NTSTATUS STDCALL NtCreateNamedPipeFile(
|
|||
StackLoc->Control = 0;
|
||||
StackLoc->DeviceObject = FileObject->DeviceObject;
|
||||
StackLoc->FileObject = FileObject;
|
||||
StackLoc->Parameters.CreateNamedPipe.FileAttributes = FileAttributes;
|
||||
StackLoc->Parameters.CreateNamedPipe.OpenMode = OpenMode;
|
||||
StackLoc->Parameters.CreateNamedPipe.PipeType = PipeType;
|
||||
StackLoc->Parameters.CreateNamedPipe.PipeRead = PipeRead;
|
||||
StackLoc->Parameters.CreateNamedPipe.PipeWait = PipeWait;
|
||||
StackLoc->Parameters.CreateNamedPipe.CreateDisposition =
|
||||
CreateDisposition;
|
||||
StackLoc->Parameters.CreateNamedPipe.CreateOptions = CreateOptions;
|
||||
StackLoc->Parameters.CreateNamedPipe.ShareAccess = ShareAccess;
|
||||
StackLoc->Parameters.CreateNamedPipe.WriteModeMessage = WriteModeMessage;
|
||||
StackLoc->Parameters.CreateNamedPipe.ReadModeMessage = ReadModeMessage;
|
||||
StackLoc->Parameters.CreateNamedPipe.NonBlocking = NonBlocking;
|
||||
StackLoc->Parameters.CreateNamedPipe.MaxInstances = MaxInstances;
|
||||
StackLoc->Parameters.CreateNamedPipe.InBufferSize = InBufferSize;
|
||||
StackLoc->Parameters.CreateNamedPipe.OutBufferSize = OutBufferSize;
|
||||
if (TimeOut != NULL)
|
||||
{
|
||||
StackLoc->Parameters.CreateNamedPipe.Timeout = *TimeOut;
|
||||
StackLoc->Parameters.CreateNamedPipe.TimeOut = *TimeOut;
|
||||
}
|
||||
else
|
||||
{
|
||||
StackLoc->Parameters.CreateNamedPipe.Timeout.QuadPart = 0;
|
||||
StackLoc->Parameters.CreateNamedPipe.TimeOut.QuadPart = 0;
|
||||
}
|
||||
|
||||
Status = IoCallDriver(FileObject->DeviceObject,Irp);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rw.c,v 1.29 2000/05/09 16:13:49 ekohl Exp $
|
||||
/* $Id: rw.c,v 1.30 2000/05/13 13:51:02 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -50,24 +50,22 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
|
|||
PLARGE_INTEGER ByteOffset,
|
||||
PULONG Key)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
PKEVENT ptrEvent = NULL;
|
||||
KEVENT Event;
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
PKEVENT ptrEvent = NULL;
|
||||
KEVENT Event;
|
||||
|
||||
DPRINT("NtReadFile(FileHandle %x Buffer %x Length %x ByteOffset %x, "
|
||||
"IoStatusBlock %x)\n", FileHandle, Buffer, Length, ByteOffset,
|
||||
IoStatusBlock);
|
||||
|
||||
assert_irql(PASSIVE_LEVEL);
|
||||
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_READ_DATA,
|
||||
IoFileObjectType,
|
||||
UserMode,
|
||||
(PVOID *) & FileObject,
|
||||
(PVOID*)&FileObject,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -75,11 +73,9 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
|
|||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("ByteOffset %x FileObject->CurrentByteOffset %d\n",
|
||||
ByteOffset, FileObject->CurrentByteOffset.u.LowPart);
|
||||
if (ByteOffset == NULL)
|
||||
{
|
||||
ByteOffset = &(FileObject->CurrentByteOffset);
|
||||
ByteOffset = &FileObject->CurrentByteOffset;
|
||||
}
|
||||
|
||||
if (EventHandle != NULL)
|
||||
|
@ -88,7 +84,7 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
|
|||
SYNCHRONIZE,
|
||||
ExEventObjectType,
|
||||
UserMode,
|
||||
(PVOID *) ptrEvent,
|
||||
(PVOID*)ptrEvent,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
|
@ -103,8 +99,6 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
|
|||
ptrEvent = &Event;
|
||||
}
|
||||
|
||||
DPRINT("FileObject %x\n",FileObject);
|
||||
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_READ,
|
||||
FileObject->DeviceObject,
|
||||
Buffer,
|
||||
|
@ -129,8 +123,8 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
|
|||
|
||||
Status = IoCallDriver(FileObject->DeviceObject,
|
||||
Irp);
|
||||
if ((Status == STATUS_PENDING)
|
||||
&& (FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
if ((Status == STATUS_PENDING) &&
|
||||
(FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
{
|
||||
KeWaitForSingleObject(&Event,
|
||||
Executive,
|
||||
|
@ -140,11 +134,7 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
|
|||
Status = IoStatusBlock->Status;
|
||||
}
|
||||
|
||||
DPRINT("NtReadFile() = %x\n",Status);
|
||||
|
||||
assert_irql(PASSIVE_LEVEL);
|
||||
|
||||
return Status;
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
|
@ -161,99 +151,79 @@ NTSTATUS STDCALL NtReadFile(HANDLE FileHandle,
|
|||
* REVISIONS
|
||||
*
|
||||
*/
|
||||
NTSTATUS
|
||||
STDCALL
|
||||
NtWriteFile (
|
||||
HANDLE FileHandle,
|
||||
HANDLE EventHandle,
|
||||
PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PLARGE_INTEGER ByteOffset,
|
||||
PULONG Key
|
||||
)
|
||||
NTSTATUS STDCALL NtWriteFile(HANDLE FileHandle,
|
||||
HANDLE EventHandle,
|
||||
PIO_APC_ROUTINE ApcRoutine,
|
||||
PVOID ApcContext,
|
||||
PIO_STATUS_BLOCK IoStatusBlock,
|
||||
PVOID Buffer,
|
||||
ULONG Length,
|
||||
PLARGE_INTEGER ByteOffset,
|
||||
PULONG Key)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
KEVENT Event;
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIRP Irp;
|
||||
PIO_STACK_LOCATION StackPtr;
|
||||
KEVENT Event;
|
||||
|
||||
DPRINT(
|
||||
"NtWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
|
||||
FileHandle,
|
||||
Buffer,
|
||||
Length
|
||||
);
|
||||
DPRINT("NtWriteFile(FileHandle %x, Buffer %x, Length %d)\n",
|
||||
FileHandle, Buffer, Length);
|
||||
|
||||
Status = ObReferenceObjectByHandle(
|
||||
FileHandle,
|
||||
FILE_WRITE_DATA,
|
||||
IoFileObjectType,
|
||||
UserMode,
|
||||
(PVOID *) & FileObject,
|
||||
NULL
|
||||
);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
if (ByteOffset == NULL)
|
||||
{
|
||||
ByteOffset = & (FileObject->CurrentByteOffset);
|
||||
}
|
||||
Status = ObReferenceObjectByHandle(FileHandle,
|
||||
FILE_WRITE_DATA,
|
||||
IoFileObjectType,
|
||||
UserMode,
|
||||
(PVOID*)&FileObject,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
KeInitializeEvent(
|
||||
& Event,
|
||||
NotificationEvent,
|
||||
FALSE
|
||||
);
|
||||
Irp = IoBuildSynchronousFsdRequest(
|
||||
IRP_MJ_WRITE,
|
||||
FileObject->DeviceObject,
|
||||
Buffer,
|
||||
Length,
|
||||
ByteOffset,
|
||||
& Event,
|
||||
IoStatusBlock
|
||||
);
|
||||
if (ByteOffset == NULL)
|
||||
{
|
||||
ByteOffset = &FileObject->CurrentByteOffset;
|
||||
}
|
||||
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
|
||||
KeInitializeEvent(&Event,
|
||||
NotificationEvent,
|
||||
FALSE);
|
||||
Irp = IoBuildSynchronousFsdRequest(IRP_MJ_WRITE,
|
||||
FileObject->DeviceObject,
|
||||
Buffer,
|
||||
Length,
|
||||
ByteOffset,
|
||||
&Event,
|
||||
IoStatusBlock);
|
||||
|
||||
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->FileObject = FileObject;
|
||||
if (Key != NULL)
|
||||
{
|
||||
StackPtr->Parameters.Write.Key = *Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
StackPtr->Parameters.Write.Key = 0;
|
||||
}
|
||||
Status = IoCallDriver(
|
||||
FileObject->DeviceObject,
|
||||
Irp
|
||||
);
|
||||
if (
|
||||
(Status == STATUS_PENDING)
|
||||
&& (FileObject->Flags & FO_SYNCHRONOUS_IO)
|
||||
)
|
||||
{
|
||||
KeWaitForSingleObject(
|
||||
& Event,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL
|
||||
);
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
return Status;
|
||||
Irp->Overlay.AsynchronousParameters.UserApcRoutine = ApcRoutine;
|
||||
Irp->Overlay.AsynchronousParameters.UserApcContext = ApcContext;
|
||||
|
||||
DPRINT("FileObject->DeviceObject %x\n",FileObject->DeviceObject);
|
||||
|
||||
StackPtr = IoGetNextIrpStackLocation(Irp);
|
||||
StackPtr->FileObject = FileObject;
|
||||
if (Key != NULL)
|
||||
{
|
||||
StackPtr->Parameters.Write.Key = *Key;
|
||||
}
|
||||
else
|
||||
{
|
||||
StackPtr->Parameters.Write.Key = 0;
|
||||
}
|
||||
Status = IoCallDriver(FileObject->DeviceObject, Irp);
|
||||
if ((Status == STATUS_PENDING) &&
|
||||
(FileObject->Flags & FO_SYNCHRONOUS_IO))
|
||||
{
|
||||
KeWaitForSingleObject(&Event,
|
||||
Executive,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
Status = Irp->IoStatus.Status;
|
||||
}
|
||||
return(Status);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -54,46 +54,52 @@ BOOLEAN KiTestAlert(PKTHREAD Thread,
|
|||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
PKAPC Apc;
|
||||
PULONG Esp = (PULONG)UserContext->Esp;
|
||||
PULONG Esp;
|
||||
KIRQL oldlvl;
|
||||
CONTEXT SavedContext;
|
||||
ULONG Top;
|
||||
|
||||
DPRINT("KiTestAlert(Thread %x, UserContext %x)\n");
|
||||
KeAcquireSpinLock( &PiApcLock, &oldlvl );
|
||||
KeAcquireSpinLock(&PiApcLock, &oldlvl);
|
||||
current_entry = Thread->ApcState.ApcListHead[1].Flink;
|
||||
|
||||
if (current_entry == &Thread->ApcState.ApcListHead[1])
|
||||
{
|
||||
KeReleaseSpinLock( &PiApcLock, oldlvl );
|
||||
KeReleaseSpinLock(&PiApcLock, oldlvl);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
while (current_entry != &Thread->ApcState.ApcListHead[1])
|
||||
{
|
||||
Apc = CONTAINING_RECORD(current_entry, KAPC, ApcListEntry);
|
||||
current_entry = RemoveHeadList(&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);
|
||||
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 = (PULONG)UserContext->Esp;
|
||||
|
||||
memcpy(&SavedContext, UserContext, sizeof(CONTEXT));
|
||||
|
||||
/*
|
||||
* Now call for the kernel routine for the APC, which will free
|
||||
* the APC data structure
|
||||
*/
|
||||
KeCallKernelRoutineApc(Apc);
|
||||
|
||||
Esp = Esp - (sizeof(CONTEXT) + (4 * sizeof(ULONG)));
|
||||
memcpy(Esp, &SavedContext, sizeof(CONTEXT));
|
||||
Top = sizeof(CONTEXT) / 4;
|
||||
Esp[Top] = (ULONG)Apc->SystemArgument2;
|
||||
Esp[Top + 1] = (ULONG)Apc->SystemArgument1;
|
||||
Esp[Top + 2] = (ULONG)Apc->NormalContext;
|
||||
Esp[Top + 3] = (ULONG)Apc->NormalRoutine;
|
||||
UserContext->Eip = 0;
|
||||
|
||||
Esp = Esp - 16;
|
||||
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
|
||||
*/
|
||||
KeCallKernelRoutineApc(Apc);
|
||||
}
|
||||
UserContext->Esp = (ULONG)Esp;
|
||||
InitializeListHead(&Thread->ApcState.ApcListHead[1]);
|
||||
current_entry = current_entry->Flink;
|
||||
|
||||
|
||||
return(TRUE);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
#include <internal/ntoskrnl.h>
|
||||
|
||||
#define NR_TASKS 128
|
||||
|
||||
.globl _stext
|
||||
|
@ -36,14 +38,11 @@ _gdt_descr:
|
|||
.word ((8+NR_TASKS)*8)-1
|
||||
.long _KiGdt
|
||||
|
||||
/*_idt:
|
||||
.fill 256,8,0 */
|
||||
|
||||
.text
|
||||
|
||||
.align 8
|
||||
_init_stack:
|
||||
.fill 16384,1,0
|
||||
.fill MM_STACK_SIZE,1,0
|
||||
_init_stack_top:
|
||||
|
||||
_stext:
|
||||
|
|
|
@ -323,12 +323,12 @@ asmlinkage void exception_handler(unsigned int edi,
|
|||
}
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
#if 1
|
||||
DbgPrint("SS:ESP %x:%x\n",ss0,esp0);
|
||||
stack=(PULONG)(esp0);
|
||||
|
||||
DbgPrint("Stack:\n");
|
||||
for (i=0; i<16; i++)
|
||||
for (i=0; i<64; i++)
|
||||
{
|
||||
if (MmIsPagePresent(NULL,&stack[i]))
|
||||
{
|
||||
|
|
|
@ -151,7 +151,7 @@ NTSTATUS HalReleaseTask(PETHREAD Thread)
|
|||
* NOTE: The thread had better not be running when this is called
|
||||
*/
|
||||
{
|
||||
extern BYTE init_stack[16384];
|
||||
extern BYTE init_stack[MM_STACK_SIZE];
|
||||
|
||||
KeFreeGdtSelector(Thread->Tcb.Context.nr / 8);
|
||||
if (Thread->Tcb.Context.KernelStackBase != init_stack)
|
||||
|
@ -194,8 +194,7 @@ NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
|
|||
|
||||
length = sizeof(hal_thread_state) - 1;
|
||||
base = (unsigned int)(&(Thread->Tcb.Context));
|
||||
// kernel_stack = ExAllocatePool(NonPagedPool,PAGESIZE);
|
||||
kernel_stack = ExAllocatePool(NonPagedPool, 6*PAGESIZE);
|
||||
kernel_stack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
|
||||
|
||||
/*
|
||||
* Setup a TSS descriptor
|
||||
|
@ -209,7 +208,7 @@ NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
|
|||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
||||
stack_start = kernel_stack + 6*PAGESIZE - sizeof(CONTEXT);
|
||||
stack_start = kernel_stack + MM_STACK_SIZE - sizeof(CONTEXT);
|
||||
|
||||
DPRINT("stack_start %x kernel_stack %x\n",
|
||||
stack_start, kernel_stack);
|
||||
|
@ -246,6 +245,11 @@ NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
|
|||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
PULONG KeGetStackTopThread(PETHREAD Thread)
|
||||
{
|
||||
return((PULONG)(Thread->Tcb.Context.KernelStackBase + MM_STACK_SIZE));
|
||||
}
|
||||
|
||||
NTSTATUS HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext)
|
||||
/*
|
||||
* FUNCTION: Initializes the HAL portion of a thread object
|
||||
|
@ -259,7 +263,6 @@ NTSTATUS HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext)
|
|||
unsigned int desc;
|
||||
unsigned int length = sizeof(hal_thread_state) - 1;
|
||||
unsigned int base = (unsigned int)(&(thread->Tcb.Context));
|
||||
// PULONG KernelStack = ExAllocatePool(NonPagedPool,4096);
|
||||
PULONG KernelStack;
|
||||
ULONG GdtDesc[2];
|
||||
extern BYTE init_stack[16384];
|
||||
|
@ -270,7 +273,7 @@ NTSTATUS HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext)
|
|||
|
||||
if (fn != NULL)
|
||||
{
|
||||
KernelStack = ExAllocatePool(NonPagedPool, 3*PAGESIZE);
|
||||
KernelStack = ExAllocatePool(NonPagedPool, MM_STACK_SIZE);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: usercall.c,v 1.10 2000/03/08 01:53:59 ekohl Exp $
|
||||
/* $Id: usercall.c,v 1.11 2000/05/13 13:51:05 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -57,15 +57,15 @@ void PsBeginThreadWithContextInternal(void);
|
|||
|
||||
VOID KiSystemCallHook(ULONG Nr, ...)
|
||||
{
|
||||
#ifdef TRACE_SYSTEM_CALLS
|
||||
#if 1
|
||||
va_list ap;
|
||||
ULONG i;
|
||||
|
||||
va_start(ap, Nr);
|
||||
|
||||
DbgPrint("%x/%d ", _SystemServiceTable[Nr].Function,Nr);
|
||||
DbgPrint("%x (", _SystemServiceTable[Nr].ParametersSize);
|
||||
for (i = 0; i < _SystemServiceTable[Nr].ParametersSize / 4; i++)
|
||||
DbgPrint("%x/%d ", KeServiceDescriptorTable[0].SSDT[Nr].SysCallPtr, Nr);
|
||||
DbgPrint("%x (", KeServiceDescriptorTable[0].SSPT[Nr].ParamBytes);
|
||||
for (i = 0; i < KeServiceDescriptorTable[0].SSPT[Nr].ParamBytes / 4; i++)
|
||||
{
|
||||
DbgPrint("%x, ", va_arg(ap, ULONG));
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@
|
|||
/* GLOBALS *******************************************************************/
|
||||
|
||||
static PVOID SystemDllEntryPoint = NULL;
|
||||
//static PVOID SystemDllApcDispatcher = NULL;
|
||||
//static PVOID SystemDllCallbackDispatcher = NULL;
|
||||
//static PVOID SystemDllExceptionDispatcher = NULL;
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
|
108
reactos/ntoskrnl/mm/kmap.c
Normal file
108
reactos/ntoskrnl/mm/kmap.c
Normal file
|
@ -0,0 +1,108 @@
|
|||
/* $Id: kmap.c,v 1.1 2000/05/13 13:51:05 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
* FILE: ntoskrnl/mm/kmap.c
|
||||
* PURPOSE: Implements the kernel memory pool
|
||||
* PROGRAMMER: David Welch (welch@cwcom.net)
|
||||
*/
|
||||
|
||||
/* INCLUDES ****************************************************************/
|
||||
|
||||
#include <ddk/ntddk.h>
|
||||
#include <string.h>
|
||||
#include <internal/string.h>
|
||||
#include <internal/stddef.h>
|
||||
#include <internal/mm.h>
|
||||
#include <internal/mmhal.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/ntoskrnl.h>
|
||||
#include <internal/pool.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <internal/debug.h>
|
||||
|
||||
/* GLOBALS *****************************************************************/
|
||||
|
||||
/*
|
||||
* Memory managment initalized symbol for the base of the pool
|
||||
*/
|
||||
static ULONG MmKernelMapBase = 0;
|
||||
|
||||
#define ALLOC_MAP_SIZE (NONPAGED_POOL_SIZE / PAGESIZE)
|
||||
|
||||
/*
|
||||
* One bit for each page in the kmalloc region
|
||||
* If set then the page is used by a kmalloc block
|
||||
*/
|
||||
static ULONG alloc_map[ALLOC_MAP_SIZE/32]={0,};
|
||||
static KSPIN_LOCK AllocMapLock;
|
||||
|
||||
/* FUNCTIONS ***************************************************************/
|
||||
|
||||
PVOID MmAllocPageFrame(VOID)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
ULONG i = ((ULONG)Addr - kernel_pool_base) / PAGESIZE;
|
||||
|
||||
KeAcquireSpinLock(&AllocMapLock, &oldIrql);
|
||||
MmSetPage(NULL, (PVOID)Addr, 0, 0);
|
||||
clear_bit(i%32, &alloc_map[i/32]);
|
||||
KeReleaseSpinLock(&AllocMapLock, oldIrql);
|
||||
}
|
||||
|
||||
VOID MmFreePageFrame(PVOID Addr)
|
||||
{
|
||||
}
|
||||
|
||||
VOID ExUnmapPage(PVOID Addr)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
ULONG i = ((ULONG)Addr - kernel_pool_base) / PAGESIZE;
|
||||
|
||||
DPRINT("ExUnmapPage(Addr %x)\n",Addr);
|
||||
DPRINT("i %x\n",i);
|
||||
|
||||
KeAcquireSpinLock(&AllocMapLock, &oldIrql);
|
||||
MmSetPage(NULL, (PVOID)Addr, 0, 0);
|
||||
clear_bit(i%32, &alloc_map[i/32]);
|
||||
KeReleaseSpinLock(&AllocMapLock, oldIrql);
|
||||
}
|
||||
|
||||
PVOID ExAllocatePage(VOID)
|
||||
{
|
||||
KIRQL oldlvl;
|
||||
ULONG addr;
|
||||
ULONG i;
|
||||
ULONG PhysPage;
|
||||
|
||||
PhysPage = (ULONG)MmAllocPage();
|
||||
DPRINT("Allocated page %x\n",PhysPage);
|
||||
if (PhysPage == 0)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
KeAcquireSpinLock(&AllocMapLock, &oldlvl);
|
||||
for (i=1; i<ALLOC_MAP_SIZE;i++)
|
||||
{
|
||||
if (!test_bit(i%32,&alloc_map[i/32]))
|
||||
{
|
||||
DPRINT("i %x\n",i);
|
||||
set_bit(i%32,&alloc_map[i/32]);
|
||||
addr = kernel_pool_base + (i*PAGESIZE);
|
||||
MmSetPage(NULL, (PVOID)addr, PAGE_READWRITE, PhysPage);
|
||||
KeReleaseSpinLock(&AllocMapLock, oldlvl);
|
||||
return((PVOID)addr);
|
||||
}
|
||||
}
|
||||
KeReleaseSpinLock(&AllocMapLock, oldlvl);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
VOID MmKernelMapInit(ULONG BaseAddress)
|
||||
{
|
||||
MmKernelMapBase = BaseAddress;
|
||||
KeInitializeSpinLock(&AllocMapLock);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: mm.c,v 1.28 2000/04/07 02:24:00 dwelch Exp $
|
||||
/* $Id: mm.c,v 1.29 2000/05/13 13:51:05 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -133,115 +133,6 @@ VOID MmInitVirtualMemory(boot_param* bp)
|
|||
DPRINT("MmInitVirtualMemory() done\n");
|
||||
}
|
||||
|
||||
NTSTATUS MmCommitedSectionHandleFault(PMADDRESS_SPACE AddressSpace,
|
||||
MEMORY_AREA* MemoryArea,
|
||||
PVOID Address)
|
||||
{
|
||||
if (MmIsPagePresent(NULL, Address))
|
||||
{
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
MmSetPage(PsGetCurrentProcess(),
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
(ULONG)MmAllocPage());
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MmSectionHandleFault(PMADDRESS_SPACE AddressSpace,
|
||||
MEMORY_AREA* MemoryArea,
|
||||
PVOID Address)
|
||||
{
|
||||
LARGE_INTEGER Offset;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
PMDL Mdl;
|
||||
PVOID Page;
|
||||
NTSTATUS Status;
|
||||
ULONG PAddress;
|
||||
|
||||
DPRINT("MmSectionHandleFault(MemoryArea %x, Address %x)\n",
|
||||
MemoryArea,Address);
|
||||
|
||||
if (MmIsPagePresent(NULL, Address))
|
||||
{
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
DPRINT("Page isn't present\n");
|
||||
PAddress = (ULONG)PAGE_ROUND_DOWN(((ULONG)Address));
|
||||
DPRINT("PAddress %x\n", PAddress);
|
||||
Offset.QuadPart = (PAddress - (ULONG)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)
|
||||
{
|
||||
ULONG Page;
|
||||
|
||||
Page = (ULONG)MiTryToSharePageInSection(
|
||||
MemoryArea->Data.SectionData.Section,
|
||||
(ULONG)Offset.QuadPart);
|
||||
|
||||
if (Page == 0)
|
||||
{
|
||||
Page = (ULONG)MmAllocPage();
|
||||
}
|
||||
|
||||
MmSetPage(PsGetCurrentProcess(),
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
Page);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
DPRINT("Creating mdl\n");
|
||||
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
|
||||
DPRINT("Building mdl\n");
|
||||
MmBuildMdlFromPages(Mdl);
|
||||
DPRINT("Getting page address\n");
|
||||
Page = MmGetMdlPageAddress(Mdl, 0);
|
||||
DPRINT("Unlocking address space\n");
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
DPRINT("Reading page\n");
|
||||
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||
Mdl,
|
||||
&Offset,
|
||||
&IoStatus);
|
||||
DPRINT("Read page\n");
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Failed to read page\n");
|
||||
return(Status);
|
||||
}
|
||||
|
||||
DPRINT("Locking address space\n");
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
|
||||
DPRINT("Testing if page is present\n");
|
||||
if (MmIsPagePresent(NULL, Address))
|
||||
{
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
DPRINT("Setting page\n");
|
||||
MmSetPage(NULL,
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
(ULONG)Page);
|
||||
|
||||
DPRINT("Returning from MmSectionHandleFault()\n");
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
|
||||
ULONG Address)
|
||||
{
|
||||
|
@ -255,7 +146,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
|
|||
MEMORY_AREA* MemoryArea;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
|
||||
DPRINT1("MmNotPresentFault(Mode %d, Address %x)\n", Mode, Address);
|
||||
|
||||
if (KeGetCurrentIrql() >= DISPATCH_LEVEL)
|
||||
{
|
||||
|
@ -304,15 +195,15 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
|
|||
break;
|
||||
|
||||
case MEMORY_AREA_SECTION_VIEW_COMMIT:
|
||||
Status = MmSectionHandleFault(AddressSpace,
|
||||
MemoryArea,
|
||||
(PVOID)Address);
|
||||
Status = MmNotPresentFaultSectionView(AddressSpace,
|
||||
MemoryArea,
|
||||
(PVOID)Address);
|
||||
break;
|
||||
|
||||
case MEMORY_AREA_COMMIT:
|
||||
Status = MmCommitedSectionHandleFault(AddressSpace,
|
||||
MemoryArea,
|
||||
(PVOID)Address);
|
||||
Status = MmNotPresentFaultVirtualMemory(AddressSpace,
|
||||
MemoryArea,
|
||||
(PVOID)Address);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: pagefile.c,v 1.3 2000/03/26 19:38:32 ea Exp $
|
||||
/* $Id: pagefile.c,v 1.4 2000/05/13 13:51:05 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -14,6 +14,7 @@
|
|||
#include <ddk/ntddk.h>
|
||||
#include <internal/bitops.h>
|
||||
#include <internal/io.h>
|
||||
#include <napi/core.h>
|
||||
|
||||
#include <internal/debug.h>
|
||||
|
||||
|
@ -45,6 +46,11 @@ static ULONG MiFreeSwapPages;
|
|||
static ULONG MiUsedSwapPages;
|
||||
static ULONG MiReservedSwapPages;
|
||||
|
||||
#if 0
|
||||
static PVOID MmCoreDumpPageFrame;
|
||||
static BYTE MmCoreDumpHeader[PAGESIZE];
|
||||
#endif
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID MmInitPagingFile(VOID)
|
||||
|
@ -157,6 +163,28 @@ SWAPENTRY MmAllocSwapPage(VOID)
|
|||
return(0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
NTSTATUS STDCALL MmDumpToPagingFile(PCONTEXT Context,
|
||||
ULONG BugCode,
|
||||
ULONG ExceptionCode,
|
||||
ULONG Cr2)
|
||||
{
|
||||
((PMM_CORE_DUMP_HEADER)MmCoreDumpHeader)->Magic =
|
||||
MM_CORE_DUMP_HEADER_MAGIC;
|
||||
((PMM_CORE_DUMP_HEADER)MmCoreDumpHeader)->Version =
|
||||
MM_CORE_DUMP_HEADER_VERSION;
|
||||
memcpy(&((PMM_CORE_DUMP_HEADER)MmCoreDumpHeader)->Context,
|
||||
Context,
|
||||
sizeof(CONTEXT));
|
||||
((PMM_CORE_DUMP_HEADER)MmCoreDumpHeader)->DumpLength = 0;
|
||||
((PMM_CORE_DUMP_HEADER)MmCoreDumpHeader)->BugCode = BugCode;
|
||||
((PMM_CORE_DUMP_HEADER)MmCoreDumpHeader)->ExceptionCode =
|
||||
ExceptionCode;
|
||||
((PMM_CORE_DUMP_HEADER)MmCoreDumpHeader)->Cr2 = Cr2;
|
||||
((PMM_CORE_DUMP_HEADER)MmCoreDumpHeader)->Cr3 = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
NTSTATUS STDCALL NtCreatePagingFile(IN PUNICODE_STRING PageFileName,
|
||||
IN ULONG MinimumSize,
|
||||
IN ULONG MaximumSize,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: section.c,v 1.29 2000/04/07 02:24:01 dwelch Exp $
|
||||
/* $Id: section.c,v 1.30 2000/05/13 13:51:05 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -27,6 +27,20 @@ POBJECT_TYPE EXPORTED MmSectionObjectType = NULL;
|
|||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
VOID MmLockSection(PSECTION_OBJECT Section)
|
||||
{
|
||||
KeWaitForSingleObject(&Section->Lock,
|
||||
UserRequest,
|
||||
KernelMode,
|
||||
FALSE,
|
||||
NULL);
|
||||
}
|
||||
|
||||
VOID MmUnlockSection(PSECTION_OBJECT Section)
|
||||
{
|
||||
KeReleaseMutex(&Section->Lock, FALSE);
|
||||
}
|
||||
|
||||
VOID MmSetPageEntrySection(PSECTION_OBJECT Section,
|
||||
ULONG Offset,
|
||||
PVOID Entry)
|
||||
|
@ -66,47 +80,84 @@ PVOID MmGetPageEntrySection(PSECTION_OBJECT Section,
|
|||
return(Entry);
|
||||
}
|
||||
|
||||
PVOID MiTryToSharePageInSection(PSECTION_OBJECT Section,
|
||||
ULONG Offset)
|
||||
NTSTATUS MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||
MEMORY_AREA* MemoryArea,
|
||||
PVOID Address)
|
||||
{
|
||||
KIRQL oldIrql;
|
||||
PLIST_ENTRY current_entry;
|
||||
PMEMORY_AREA current;
|
||||
PVOID Address;
|
||||
ULONG PhysPage;
|
||||
LARGE_INTEGER Offset;
|
||||
IO_STATUS_BLOCK IoStatus;
|
||||
PMDL Mdl;
|
||||
PVOID Page;
|
||||
NTSTATUS Status;
|
||||
ULONG PAddress;
|
||||
PSECTION_OBJECT Section;
|
||||
PVOID Entry;
|
||||
|
||||
DPRINT("MiTryToSharePageInSection(Section %x, Offset %x)\n",
|
||||
Section, Offset);
|
||||
DPRINT("MmSectionHandleFault(MemoryArea %x, Address %x)\n",
|
||||
MemoryArea,Address);
|
||||
|
||||
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
||||
|
||||
current_entry = Section->ViewListHead.Flink;
|
||||
|
||||
while (current_entry != &Section->ViewListHead)
|
||||
if (MmIsPagePresent(NULL, Address))
|
||||
{
|
||||
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);
|
||||
MmReferencePage((PVOID)PhysPage);
|
||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||
DPRINT("MiTryToSharePageInSection() = %x\n", PhysPage);
|
||||
return((PVOID)PhysPage);
|
||||
}
|
||||
|
||||
current_entry = current_entry->Flink;
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||
DPRINT("MiTryToSharePageInSection() finished\n");
|
||||
return(NULL);
|
||||
PAddress = (ULONG)PAGE_ROUND_DOWN(((ULONG)Address));
|
||||
Offset.QuadPart = (PAddress - (ULONG)MemoryArea->BaseAddress) +
|
||||
MemoryArea->Data.SectionData.ViewOffset;
|
||||
|
||||
Section = MemoryArea->Data.SectionData.Section;
|
||||
|
||||
MmLockSection(Section);
|
||||
|
||||
Entry = MmGetPageEntrySection(Section, Offset.QuadPart);
|
||||
|
||||
if (Entry == NULL)
|
||||
{
|
||||
Mdl = MmCreateMdl(NULL, NULL, PAGESIZE);
|
||||
MmBuildMdlFromPages(Mdl);
|
||||
Page = MmGetMdlPageAddress(Mdl, 0);
|
||||
MmUnlockSection(Section);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
Status = IoPageRead(MemoryArea->Data.SectionData.Section->FileObject,
|
||||
Mdl,
|
||||
&Offset,
|
||||
&IoStatus);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
MmLockSection(Section);
|
||||
|
||||
Entry = MmGetPageEntrySection(Section, Offset.QuadPart);
|
||||
|
||||
if (Entry == NULL)
|
||||
{
|
||||
MmSetPageEntrySection(Section,
|
||||
Offset.QuadPart,
|
||||
Page);
|
||||
}
|
||||
else
|
||||
{
|
||||
MmDereferencePage(Page);
|
||||
Page = Entry;
|
||||
MmReferencePage(Page);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Page = Entry;
|
||||
MmReferencePage(Page);
|
||||
}
|
||||
|
||||
MmSetPage(NULL,
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
(ULONG)Page);
|
||||
MmUnlockSection(Section);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
VOID MmpDeleteSection(PVOID ObjectBody)
|
||||
|
@ -242,6 +293,7 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle,
|
|||
Section->AllocateAttributes = AllocationAttributes;
|
||||
InitializeListHead(&Section->ViewListHead);
|
||||
KeInitializeSpinLock(&Section->ViewListLock);
|
||||
KeInitializeMutex(&Section->Lock, 0);
|
||||
|
||||
if (FileHandle != (HANDLE)0xffffffff)
|
||||
{
|
||||
|
@ -253,9 +305,6 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle,
|
|||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/*
|
||||
* Delete section object
|
||||
*/
|
||||
DPRINT("NtCreateSection() = %x\n",Status);
|
||||
ZwClose(SectionHandle);
|
||||
ObDereferenceObject(Section);
|
||||
|
@ -295,8 +344,8 @@ NTSTATUS STDCALL NtOpenSection(PHANDLE SectionHandle,
|
|||
ACCESS_MASK DesiredAccess,
|
||||
POBJECT_ATTRIBUTES ObjectAttributes)
|
||||
{
|
||||
PVOID Object;
|
||||
NTSTATUS Status;
|
||||
PVOID Object;
|
||||
NTSTATUS Status;
|
||||
|
||||
*SectionHandle = 0;
|
||||
|
||||
|
@ -377,14 +426,14 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
ULONG CommitSize,
|
||||
PLARGE_INTEGER SectionOffset,
|
||||
PULONG ViewSize,
|
||||
SECTION_INHERIT InheritDisposition,
|
||||
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;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
@ -412,6 +461,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
}
|
||||
|
||||
DPRINT("Section %x\n",Section);
|
||||
MmLockSection(Section);
|
||||
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_VM_OPERATION,
|
||||
|
@ -423,6 +473,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
{
|
||||
DPRINT("ObReferenceObjectByHandle(ProcessHandle, ...) failed (%x)\n",
|
||||
Status);
|
||||
MmUnlockSection(Section);
|
||||
ObDereferenceObject(Section);
|
||||
return Status;
|
||||
}
|
||||
|
@ -461,6 +512,7 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
MmUnlockSection(Section);
|
||||
ObDereferenceObject(Section);
|
||||
|
||||
return Status;
|
||||
|
@ -480,13 +532,14 @@ NTSTATUS STDCALL NtMapViewOfSection(HANDLE SectionHandle,
|
|||
DPRINT("*BaseAddress %x\n",*BaseAddress);
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
ObDereferenceObject(Process);
|
||||
MmUnlockSection(Section);
|
||||
|
||||
DPRINT("NtMapViewOfSection() returning (Status %x)\n", STATUS_SUCCESS);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS STDCALL MmUnmapViewOfSection(PEPROCESS Process,
|
||||
PMEMORY_AREA MemoryArea)
|
||||
PMEMORY_AREA MemoryArea)
|
||||
{
|
||||
PSECTION_OBJECT Section;
|
||||
KIRQL oldIrql;
|
||||
|
@ -496,9 +549,11 @@ NTSTATUS STDCALL MmUnmapViewOfSection(PEPROCESS Process,
|
|||
DPRINT("MmUnmapViewOfSection(Section %x) SectionRC %d\n",
|
||||
Section, ObGetReferenceCount(Section));
|
||||
|
||||
MmLockSection(Section);
|
||||
KeAcquireSpinLock(&Section->ViewListLock, &oldIrql);
|
||||
RemoveEntryList(&MemoryArea->Data.SectionData.ViewListEntry);
|
||||
KeReleaseSpinLock(&Section->ViewListLock, oldIrql);
|
||||
MmUnlockSection(Section);
|
||||
ObDereferenceObject(Section);
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: virtual.c,v 1.27 2000/04/07 02:24:01 dwelch Exp $
|
||||
/* $Id: virtual.c,v 1.28 2000/05/13 13:51:06 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -27,6 +27,24 @@
|
|||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
NTSTATUS MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||
MEMORY_AREA* MemoryArea,
|
||||
PVOID Address)
|
||||
{
|
||||
if (MmIsPagePresent(NULL, Address))
|
||||
{
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
MmSetPage(PsGetCurrentProcess(),
|
||||
Address,
|
||||
MemoryArea->Attributes,
|
||||
(ULONG)MmAllocPage());
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
NTSTATUS MmReleaseMemoryArea(PEPROCESS Process, PMEMORY_AREA Marea)
|
||||
{
|
||||
PVOID i;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.14 2000/04/07 02:24:02 dwelch Exp $
|
||||
/* $Id: create.c,v 1.15 2000/05/13 13:51:07 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -264,9 +264,9 @@ static VOID PiTimeoutThread(struct _KDPC *dpc,
|
|||
KeRemoveAllWaitsThread((PETHREAD)Context, Status);
|
||||
}
|
||||
|
||||
VOID PiBeforeBeginThread(VOID)
|
||||
VOID PiBeforeBeginThread(CONTEXT c)
|
||||
{
|
||||
DPRINT("PiBeforeBeginThread()\n");
|
||||
DPRINT1("PiBeforeBeginThread(Eip %x)\n", c.Eip);
|
||||
//KeReleaseSpinLock(&PiThreadListLock, PASSIVE_LEVEL);
|
||||
KeLowerIrql(PASSIVE_LEVEL);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: thread.c,v 1.45 2000/04/07 02:24:02 dwelch Exp $
|
||||
/* $Id: thread.c,v 1.46 2000/05/13 13:51:08 dwelch Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS kernel
|
||||
|
@ -541,7 +541,13 @@ NTSTATUS STDCALL NtSuspendThread (IN HANDLE ThreadHandle,
|
|||
NTSTATUS STDCALL NtContinue(IN PCONTEXT Context,
|
||||
IN CINT IrqLevel)
|
||||
{
|
||||
UNIMPLEMENTED;
|
||||
PULONG StackTop;
|
||||
|
||||
StackTop = KeGetStackTopThread(PsGetCurrentThread());
|
||||
|
||||
memcpy(StackTop, Context, sizeof(CONTEXT));
|
||||
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ LD = $(PREFIX)ld
|
|||
NM = $(PREFIX)nm
|
||||
OBJCOPY = $(PREFIX)objcopy
|
||||
STRIP = $(PREFIX)strip
|
||||
AS = $(PREFIX)gcc -c -x assembler-with-cpp
|
||||
AS = $(PREFIX)gcc -c -x assembler-with-cpp -D__ASM__ -I../include
|
||||
CPP = $(PREFIX)cpp
|
||||
AR = $(PREFIX)ar
|
||||
RC = $(PREFIX)windres
|
||||
|
|
Loading…
Reference in a new issue