2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>

* subsys/system/winlogon/winlogon.c (WinMain): Check for
	failure when creating a window system.

2002-06-11  David Welch  <welch@whitehall1-5.seh.ox.ac.uk>

	* ntoskrnl/ob/handle.c (ObDuplicateObject): Added this internal
	function for duplicating objects.
	* ntoskrnl/ps/process.c (NtCreateProcess): Duplicate the parent
	process's window station to the child process.
	* ntoskrnl/ps/process.c (PsInitProcessManagement): Initialize the
	first process's window station.

2002-06-11  David Welch  <welch@whitehall1-5.seh.ox.ac.uk>

	* ntoskrnl/mm/marea.c (MmCreateMemoryArea): Initialise
	page operation structure members.
	* ntoskrnl/mm/pageop.c (MmReleasePageOp, MmGetPageOp): Increment
	or decrement the page operation count in the memory area.
	* ntoskrnl/mm/virtual.c (MmNotPresentFaultVirtualMemory,
	MmPageOutVirtualMemory): Check for a deleted memory area before
	handling the fault.
	* ntoskrnl/mm/virtual.c (MmFreeVirtualMemory): Wait for all
	page operations to finish before freeing the memory area.

2002-06-11  David Welch  <welch@whitehall1-5.seh.ox.ac.uk>

	* ntoskrnl/ke/i386/syscall.S (interrupt_handler2e): Corrected
	test for previous mode, upper 16-bit of CS on the stack after an
	interrupt are arbitary.

2002-06-11  David Welch  <welch@whitehall1-5.seh.ox.ac.uk>

	* lib/user32/misc/winsta.c: Cleaned up indentation.

2002-06-11  David Welch  <welch@whitehall1-5.seh.ox.ac.uk>

	* apps/tests/winhello/winhello.c (WinMain, MainWndProc):
	Cleaned up formatting, some more error checks.

2002-06-04  David Welch  <welch@whitehall1-5.seh.ox.ac.uk>

	* ntoskrnl/mm/virtual.c (MmSecureVirtualMemory,
	MmUnsecureVirtualMemory, NtQueryVirtualMemory): Corrected indentation.

svn path=/trunk/; revision=3050
This commit is contained in:
David Welch 2002-06-11 22:09:03 +00:00
parent 669a991546
commit 05ad1d3198
17 changed files with 577 additions and 321 deletions

View file

@ -1,3 +1,49 @@
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* subsys/system/winlogon/winlogon.c (WinMain): Check for
failure when creating a window system.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ob/handle.c (ObDuplicateObject): Added this internal
function for duplicating objects.
* ntoskrnl/ps/process.c (NtCreateProcess): Duplicate the parent
process's window station to the child process.
* ntoskrnl/ps/process.c (PsInitProcessManagement): Initialize the
first process's window station.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/mm/marea.c (MmCreateMemoryArea): Initialise
page operation structure members.
* ntoskrnl/mm/pageop.c (MmReleasePageOp, MmGetPageOp): Increment
or decrement the page operation count in the memory area.
* ntoskrnl/mm/virtual.c (MmNotPresentFaultVirtualMemory,
MmPageOutVirtualMemory): Check for a deleted memory area before
handling the fault.
* ntoskrnl/mm/virtual.c (MmFreeVirtualMemory): Wait for all
page operations to finish before freeing the memory area.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/syscall.S (interrupt_handler2e): Corrected
test for previous mode, upper 16-bit of CS on the stack after an
interrupt are arbitary.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* lib/user32/misc/winsta.c: Cleaned up indentation.
2002-06-11 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* apps/tests/winhello/winhello.c (WinMain, MainWndProc):
Cleaned up formatting, some more error checks.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/mm/virtual.c (MmSecureVirtualMemory,
MmUnsecureVirtualMemory, NtQueryVirtualMemory): Corrected indentation.
2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk> 2002-06-04 David Welch <welch@whitehall1-5.seh.ox.ac.uk>
* ntoskrnl/ke/i386/exp.c (KiDoubleFaultHandler): Print CR3 * ntoskrnl/ke/i386/exp.c (KiDoubleFaultHandler): Print CR3

View file

@ -1,8 +1,10 @@
#include <windows.h> #include <windows.h>
#include <stdio.h>
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM); LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain(HINSTANCE hInstance, int WINAPI
WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance, HINSTANCE hPrevInstance,
LPSTR lpszCmdLine, LPSTR lpszCmdLine,
int nCmdShow) int nCmdShow)
@ -21,10 +23,14 @@ int WINAPI WinMain(HINSTANCE hInstance,
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
wc.cbWndExtra = 0; wc.cbWndExtra = 0;
RegisterClass(&wc); if (RegisterClass(&wc) == 0)
{
fprintf(stderr, "RegisterClass failed (last error 0x%X)\n",
GetLastError());
return(1);
}
hWnd = CreateWindow hWnd = CreateWindow("HelloClass",
( "HelloClass",
"Hello World", "Hello World",
WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL, WS_OVERLAPPEDWINDOW|WS_HSCROLL|WS_VSCROLL,
0, 0,
@ -34,8 +40,13 @@ int WINAPI WinMain(HINSTANCE hInstance,
NULL, NULL,
NULL, NULL,
hInstance, hInstance,
NULL NULL);
); if (hWnd == NULL)
{
fprintf(stderr, "CreateWindow failed (last error 0x%X)\n",
GetLastError());
return(1);
}
ShowWindow(hWnd, nCmdShow); ShowWindow(hWnd, nCmdShow);
@ -57,7 +68,8 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{ {
case WM_PAINT: case WM_PAINT:
hDC = BeginPaint(hWnd, &ps); hDC = BeginPaint(hWnd, &ps);
TextOut(hDC, 10, 10, "Hello World from ReactOS!", strlen("Hello World from ReactOS!")); TextOut(hDC, 10, 10, "Hello World from ReactOS!",
strlen("Hello World from ReactOS!"));
EndPaint(hWnd, &ps); EndPaint(hWnd, &ps);
break; break;

View file

@ -2,5 +2,16 @@
/sbin/modprobe loop /sbin/modprobe loop
echo "Installing to disk." echo "Installing to disk."
mount -t vfat /mnt/hda3/bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw mount -t vfat /mnt/hda3/bochs/10M.vga.dos /mnt/floppy -o loop,offset=8704,rw
cp -rv reactos/system32 /mnt/floppy/reactos cp -rv reactos /mnt/floppy
umount /mnt/floppy umount /mnt/floppy

View file

@ -1,4 +1,4 @@
/* $Id: winsta.c,v 1.2 2001/06/29 19:31:59 ekohl Exp $ /* $Id: winsta.c,v 1.3 2002/06/11 22:09:01 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
@ -13,18 +13,14 @@
#include <debug.h> #include <debug.h>
WINBOOL WINBOOL STDCALL
STDCALL CloseWindowStation(HWINSTA hWinSta)
CloseWindowStation(
HWINSTA hWinSta)
{ {
return NtUserCloseWindowStation(hWinSta); return(NtUserCloseWindowStation(hWinSta));
} }
HWINSTA HWINSTA STDCALL
STDCALL CreateWindowStationA(LPSTR lpwinsta,
CreateWindowStationA(
LPSTR lpwinsta,
DWORD dwReserved, DWORD dwReserved,
ACCESS_MASK dwDesiredAccess, ACCESS_MASK dwDesiredAccess,
LPSECURITY_ATTRIBUTES lpsa) LPSECURITY_ATTRIBUTES lpsa)
@ -33,15 +29,18 @@ CreateWindowStationA(
UNICODE_STRING WindowStationNameU; UNICODE_STRING WindowStationNameU;
HWINSTA hWinSta; HWINSTA hWinSta;
if (lpwinsta != NULL) { if (lpwinsta != NULL)
{
RtlInitAnsiString(&WindowStationNameA, lpwinsta); RtlInitAnsiString(&WindowStationNameA, lpwinsta);
RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA, TRUE); RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA,
} else { TRUE);
}
else
{
RtlInitUnicodeString(&WindowStationNameU, NULL); RtlInitUnicodeString(&WindowStationNameU, NULL);
} }
hWinSta = CreateWindowStationW( hWinSta = CreateWindowStationW(WindowStationNameU.Buffer,
WindowStationNameU.Buffer,
dwReserved, dwReserved,
dwDesiredAccess, dwDesiredAccess,
lpsa); lpsa);
@ -51,10 +50,8 @@ CreateWindowStationA(
return hWinSta; return hWinSta;
} }
HWINSTA HWINSTA STDCALL
STDCALL CreateWindowStationW(LPWSTR lpwinsta,
CreateWindowStationW(
LPWSTR lpwinsta,
DWORD dwReserved, DWORD dwReserved,
ACCESS_MASK dwDesiredAccess, ACCESS_MASK dwDesiredAccess,
LPSECURITY_ATTRIBUTES lpsa) LPSECURITY_ATTRIBUTES lpsa)
@ -63,41 +60,33 @@ CreateWindowStationW(
RtlInitUnicodeString(&WindowStationName, lpwinsta); RtlInitUnicodeString(&WindowStationName, lpwinsta);
return NtUserCreateWindowStation( return NtUserCreateWindowStation(&WindowStationName,
&WindowStationName,
dwDesiredAccess, dwDesiredAccess,
lpsa, 0, 0, 0); lpsa, 0, 0, 0);
} }
WINBOOL WINBOOL STDCALL
STDCALL EnumWindowStationsA(ENUMWINDOWSTATIONPROC lpEnumFunc,
EnumWindowStationsA(
ENUMWINDOWSTATIONPROC lpEnumFunc,
LPARAM lParam) LPARAM lParam)
{ {
return FALSE; return FALSE;
} }
WINBOOL WINBOOL STDCALL
STDCALL EnumWindowStationsW(ENUMWINDOWSTATIONPROC lpEnumFunc,
EnumWindowStationsW(
ENUMWINDOWSTATIONPROC lpEnumFunc,
LPARAM lParam) LPARAM lParam)
{ {
return FALSE; return FALSE;
} }
HWINSTA HWINSTA STDCALL
STDCALL
GetProcessWindowStation(VOID) GetProcessWindowStation(VOID)
{ {
return NtUserGetProcessWindowStation(); return NtUserGetProcessWindowStation();
} }
HWINSTA HWINSTA STDCALL
STDCALL OpenWindowStationA(LPSTR lpszWinSta,
OpenWindowStationA(
LPSTR lpszWinSta,
WINBOOL fInherit, WINBOOL fInherit,
ACCESS_MASK dwDesiredAccess) ACCESS_MASK dwDesiredAccess)
{ {
@ -105,15 +94,18 @@ OpenWindowStationA(
UNICODE_STRING WindowStationNameU; UNICODE_STRING WindowStationNameU;
HWINSTA hWinSta; HWINSTA hWinSta;
if (lpszWinSta != NULL) { if (lpszWinSta != NULL)
{
RtlInitAnsiString(&WindowStationNameA, lpszWinSta); RtlInitAnsiString(&WindowStationNameA, lpszWinSta);
RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA, TRUE); RtlAnsiStringToUnicodeString(&WindowStationNameU, &WindowStationNameA,
} else { TRUE);
}
else
{
RtlInitUnicodeString(&WindowStationNameU, NULL); RtlInitUnicodeString(&WindowStationNameU, NULL);
} }
hWinSta = OpenWindowStationW( hWinSta = OpenWindowStationW(WindowStationNameU.Buffer,
WindowStationNameU.Buffer,
fInherit, fInherit,
dwDesiredAccess); dwDesiredAccess);
@ -122,10 +114,8 @@ OpenWindowStationA(
return hWinSta; return hWinSta;
} }
HWINSTA HWINSTA STDCALL
STDCALL OpenWindowStationW(LPWSTR lpszWinSta,
OpenWindowStationW(
LPWSTR lpszWinSta,
WINBOOL fInherit, WINBOOL fInherit,
ACCESS_MASK dwDesiredAccess) ACCESS_MASK dwDesiredAccess)
{ {
@ -136,10 +126,8 @@ OpenWindowStationW(
return NtUserOpenWindowStation(&WindowStationName, dwDesiredAccess); return NtUserOpenWindowStation(&WindowStationName, dwDesiredAccess);
} }
WINBOOL WINBOOL STDCALL
STDCALL SetProcessWindowStation(HWINSTA hWinSta)
SetProcessWindowStation(
HWINSTA hWinSta)
{ {
return NtUserSetProcessWindowStation(hWinSta); return NtUserSetProcessWindowStation(hWinSta);
} }

View file

@ -1,4 +1,4 @@
/* $Id: class.c,v 1.9 2001/06/12 17:50:27 chorns Exp $ /* $Id: class.c,v 1.10 2002/06/11 22:09:01 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS user32.dll * PROJECT: ReactOS user32.dll
@ -151,10 +151,8 @@ RealGetWindowClassW(
return 0; return 0;
} }
ATOM ATOM STDCALL
STDCALL RegisterClassA(CONST WNDCLASS *lpWndClass)
RegisterClassA(
CONST WNDCLASS *lpWndClass)
{ {
WNDCLASSEX Class; WNDCLASSEX Class;
@ -164,10 +162,8 @@ RegisterClassA(
return RegisterClassExA(&Class); return RegisterClassExA(&Class);
} }
ATOM ATOM STDCALL
STDCALL RegisterClassExA(CONST WNDCLASSEX *lpwcx)
RegisterClassExA(
CONST WNDCLASSEX *lpwcx)
{ {
UNICODE_STRING MenuName; UNICODE_STRING MenuName;
UNICODE_STRING ClassName; UNICODE_STRING ClassName;
@ -191,8 +187,7 @@ RegisterClassExA(
Class.lpszMenuName = (LPCTSTR)MenuName.Buffer; Class.lpszMenuName = (LPCTSTR)MenuName.Buffer;
Class.lpszClassName = (LPCTSTR)ClassName.Buffer; Class.lpszClassName = (LPCTSTR)ClassName.Buffer;
Atom = NtUserRegisterClassExWOW( Atom = NtUserRegisterClassExWOW((WNDCLASSEX*)lpwcx,
(WNDCLASSEX*)lpwcx,
FALSE, FALSE,
0, 0,
0, 0,
@ -206,15 +201,12 @@ RegisterClassExA(
return (ATOM)Atom; return (ATOM)Atom;
} }
ATOM ATOM STDCALL
STDCALL RegisterClassExW(CONST WNDCLASSEX *lpwcx)
RegisterClassExW(
CONST WNDCLASSEX *lpwcx)
{ {
RTL_ATOM Atom; RTL_ATOM Atom;
Atom = NtUserRegisterClassExWOW( Atom = NtUserRegisterClassExWOW((WNDCLASSEX*)lpwcx,
(WNDCLASSEX*)lpwcx,
TRUE, TRUE,
0, 0,
0, 0,
@ -224,10 +216,8 @@ RegisterClassExW(
return (ATOM)Atom; return (ATOM)Atom;
} }
ATOM ATOM STDCALL
STDCALL RegisterClassW(CONST WNDCLASS *lpWndClass)
RegisterClassW(
CONST WNDCLASS *lpWndClass)
{ {
WNDCLASSEX Class; WNDCLASSEX Class;

View file

@ -126,6 +126,8 @@ typedef struct
LIST_ENTRY Entry; LIST_ENTRY Entry;
ULONG LockCount; ULONG LockCount;
struct _EPROCESS* Process; struct _EPROCESS* Process;
BOOLEAN DeleteInProgress;
ULONG PageOpCount;
union union
{ {
struct struct
@ -520,7 +522,8 @@ VOID
MmDisableVirtualMapping(PEPROCESS Process, PVOID Address, BOOL* WasDirty, ULONG* PhysicalAddr); MmDisableVirtualMapping(PEPROCESS Process, PVOID Address, BOOL* WasDirty, ULONG* PhysicalAddr);
VOID MmEnableVirtualMapping(PEPROCESS Process, PVOID Address); VOID MmEnableVirtualMapping(PEPROCESS Process, PVOID Address);
VOID VOID
MmDeletePageFileMapping(PEPROCESS Process, PVOID Address, SWAPENTRY* SwapEntry); MmDeletePageFileMapping(PEPROCESS Process, PVOID Address,
SWAPENTRY* SwapEntry);
NTSTATUS NTSTATUS
MmCreatePageFileMapping(PEPROCESS Process, MmCreatePageFileMapping(PEPROCESS Process,
PVOID Address, PVOID Address,
@ -532,5 +535,8 @@ VOID MmSetDirtyPage(PEPROCESS Process, PVOID Address);
VOID VOID
MmInitializeMdlImplementation(VOID); MmInitializeMdlImplementation(VOID);
extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress; extern PHYSICAL_ADDRESS MmSharedDataPagePhysicalAddress;
PMM_PAGEOP
MmCheckForPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
PMM_SECTION_SEGMENT Segment, ULONG Offset);
#endif #endif

View file

@ -100,5 +100,13 @@ ObpCreateTypeObject(POBJECT_TYPE ObjectType);
ULONG ULONG
ObGetObjectHandleCount(PVOID Object); ObGetObjectHandleCount(PVOID Object);
NTSTATUS
ObDuplicateObject(PEPROCESS SourceProcess,
PEPROCESS TargetProcess,
HANDLE SourceHandle,
PHANDLE TargetHandle,
ACCESS_MASK DesiredAccess,
BOOLEAN InheritHandle,
ULONG Options);
#endif /* __INCLUDE_INTERNAL_OBJMGR_H */ #endif /* __INCLUDE_INTERNAL_OBJMGR_H */

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: syscall.S,v 1.4 2002/01/15 02:51:32 dwelch Exp $ /* $Id: syscall.S,v 1.5 2002/06/11 22:09:02 dwelch Exp $
* *
* FILE: ntoskrnl/hal/x86/syscall.s * FILE: ntoskrnl/hal/x86/syscall.s
* PURPOSE: 2E trap handler * PURPOSE: 2E trap handler
@ -63,6 +63,7 @@ _interrupt_handler2e:
pushl %ebx pushl %ebx
/* Set the new previous mode based on the saved CS selector */ /* Set the new previous mode based on the saved CS selector */
movl 0x24(%esp), %ebx movl 0x24(%esp), %ebx
andl $0x0000FFFF, %ebx
cmpl $KERNEL_CS, %ebx cmpl $KERNEL_CS, %ebx
jne L1 jne L1
movb $KernelMode, %ss:KTHREAD_PREVIOUS_MODE(%esi) movb $KernelMode, %ss:KTHREAD_PREVIOUS_MODE(%esi)

View file

@ -452,6 +452,8 @@ NTSTATUS MmCreateMemoryArea(PEPROCESS Process,
(*Result)->Attributes = Attributes; (*Result)->Attributes = Attributes;
(*Result)->LockCount = 0; (*Result)->LockCount = 0;
(*Result)->Process = Process; (*Result)->Process = Process;
(*Result)->PageOpCount = 0;
(*Result)->DeleteInProgress = FALSE;
MmInsertMemoryArea(AddressSpace, *Result); MmInsertMemoryArea(AddressSpace, *Result);

View file

@ -1,4 +1,4 @@
/* $Id: pageop.c,v 1.9 2002/05/14 21:19:19 dwelch Exp $ /* $Id: pageop.c,v 1.10 2002/06/11 22:09:02 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -45,6 +45,7 @@ MmReleasePageOp(PMM_PAGEOP PageOp)
KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql); KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
return; return;
} }
InterlockedDecrement(&PageOp->MArea->PageOpCount);
PrevPageOp = MmPageOpHashTable[PageOp->Hash]; PrevPageOp = MmPageOpHashTable[PageOp->Hash];
if (PrevPageOp == PageOp) if (PrevPageOp == PageOp)
{ {
@ -68,6 +69,68 @@ MmReleasePageOp(PMM_PAGEOP PageOp)
KeBugCheck(0); KeBugCheck(0);
} }
PMM_PAGEOP
MmCheckForPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
PMM_SECTION_SEGMENT Segment, ULONG Offset)
{
ULONG Hash;
KIRQL oldIrql;
PMM_PAGEOP PageOp;
/*
* Calcuate the hash value for pageop structure
*/
if (MArea->Type == MEMORY_AREA_SECTION_VIEW_COMMIT)
{
Hash = (((ULONG)Segment) | (((ULONG)Offset) / PAGESIZE));
}
else
{
Hash = (((ULONG)Pid) | (((ULONG)Address) / PAGESIZE));
}
Hash = Hash % PAGEOP_HASH_TABLE_SIZE;
KeAcquireSpinLock(&MmPageOpHashTableLock, &oldIrql);
/*
* Check for an existing pageop structure
*/
PageOp = MmPageOpHashTable[Hash];
while (PageOp != NULL)
{
if (MArea->Type == MEMORY_AREA_SECTION_VIEW_COMMIT)
{
if (PageOp->Segment == Segment &&
PageOp->Offset == Offset)
{
break;
}
}
else
{
if (PageOp->Pid == Pid &&
PageOp->Address == Address)
{
break;
}
}
PageOp = PageOp->Next;
}
/*
* If we found an existing pageop then increment the reference count
* and return it.
*/
if (PageOp != NULL)
{
PageOp->ReferenceCount++;
KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
return(PageOp);
}
KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
return(NULL);
}
PMM_PAGEOP PMM_PAGEOP
MmGetPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address, MmGetPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
PMM_SECTION_SEGMENT Segment, ULONG Offset, ULONG OpType) PMM_SECTION_SEGMENT Segment, ULONG Offset, ULONG OpType)
@ -160,8 +223,10 @@ MmGetPageOp(PMEMORY_AREA MArea, ULONG Pid, PVOID Address,
PageOp->Abandoned = FALSE; PageOp->Abandoned = FALSE;
PageOp->Status = STATUS_PENDING; PageOp->Status = STATUS_PENDING;
PageOp->OpType = OpType; PageOp->OpType = OpType;
PageOp->MArea = MArea;
KeInitializeEvent(&PageOp->CompletionEvent, NotificationEvent, FALSE); KeInitializeEvent(&PageOp->CompletionEvent, NotificationEvent, FALSE);
MmPageOpHashTable[Hash] = PageOp; MmPageOpHashTable[Hash] = PageOp;
InterlockedIncrement(&MArea->PageOpCount);
KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql); KeReleaseSpinLock(&MmPageOpHashTableLock, oldIrql);
return(PageOp); return(PageOp);

View file

@ -1,4 +1,4 @@
/* $Id: virtual.c,v 1.60 2002/06/10 21:34:37 hbirr Exp $ /* $Id: virtual.c,v 1.61 2002/06/11 22:09:02 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top directory * COPYRIGHT: See COPYING in the top directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -110,6 +110,14 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
DPRINT("MmPageOutVirtualMemory(Address 0x%.8X) PID %d\n", DPRINT("MmPageOutVirtualMemory(Address 0x%.8X) PID %d\n",
Address, MemoryArea->Process->UniqueProcessId); Address, MemoryArea->Process->UniqueProcessId);
/*
* Check for paging out from a deleted virtual memory area.
*/
if (MemoryArea->DeleteInProgress)
{
return(STATUS_UNSUCCESSFUL);
}
/* /*
* Paging out code or readonly data is easy. * Paging out code or readonly data is easy.
*/ */
@ -241,6 +249,14 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
/*
* Check for the virtual memory area being deleted.
*/
if (MemoryArea->DeleteInProgress)
{
return(STATUS_UNSUCCESSFUL);
}
/* /*
* Get the segment corresponding to the virtual address * Get the segment corresponding to the virtual address
*/ */
@ -1076,9 +1092,53 @@ MmFreeVirtualMemory(PEPROCESS Process,
{ {
PLIST_ENTRY current_entry; PLIST_ENTRY current_entry;
PMM_SEGMENT current; PMM_SEGMENT current;
ULONG i;
DPRINT("MmFreeVirtualMemory(Process %p MemoryArea %p)\n", Process, MemoryArea); DPRINT("MmFreeVirtualMemory(Process %p MemoryArea %p)\n", Process,
MemoryArea);
/* Mark this memory area as about to be deleted. */
MemoryArea->DeleteInProgress = TRUE;
/*
* Wait for any ongoing paging operations. Notice that since we have
* flagged this memory area as deleted no more page ops will be added.
*/
if (MemoryArea->PageOpCount > 0)
{
for (i = 0; i < (PAGE_ROUND_UP(MemoryArea->Length) / PAGESIZE); i++)
{
PMM_PAGEOP PageOp;
if (MemoryArea->PageOpCount == 0)
{
break;
}
PageOp = MmCheckForPageOp(MemoryArea, Process->UniqueProcessId,
MemoryArea->BaseAddress + (i * PAGESIZE),
NULL, 0);
if (PageOp != NULL)
{
NTSTATUS Status;
MmUnlockAddressSpace(&Process->AddressSpace);
Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
0,
KernelMode,
FALSE,
NULL);
if (Status != STATUS_SUCCESS)
{
DPRINT1("Failed to wait for page op\n");
KeBugCheck(0);
}
MmLockAddressSpace(&Process->AddressSpace);
MmReleasePageOp(PageOp);
}
}
}
/* Free all the individual segments. */
current_entry = MemoryArea->Data.VirtualMemoryData.SegmentListHead.Flink; current_entry = MemoryArea->Data.VirtualMemoryData.SegmentListHead.Flink;
while (current_entry != &MemoryArea->Data.VirtualMemoryData.SegmentListHead) while (current_entry != &MemoryArea->Data.VirtualMemoryData.SegmentListHead)
{ {
@ -1088,6 +1148,7 @@ MmFreeVirtualMemory(PEPROCESS Process,
ExFreePool(current); ExFreePool(current);
} }
/* Actually free the memory area. */
MmFreeMemoryArea(&Process->AddressSpace, MmFreeMemoryArea(&Process->AddressSpace,
MemoryArea->BaseAddress, MemoryArea->BaseAddress,
0, 0,
@ -1154,21 +1215,13 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
switch (FreeType) switch (FreeType)
{ {
case MEM_RELEASE: case MEM_RELEASE:
/* We can only free a memory area in one step. */
if (MemoryArea->BaseAddress != BaseAddress) if (MemoryArea->BaseAddress != BaseAddress)
{ {
MmUnlockAddressSpace(AddressSpace); MmUnlockAddressSpace(AddressSpace);
ObDereferenceObject(Process); ObDereferenceObject(Process);
return(STATUS_UNSUCCESSFUL); return(STATUS_UNSUCCESSFUL);
} }
#if 0
if ((MemoryArea->Type == MEMORY_AREA_COMMIT) &&
((MemoryArea->Attributes & PAGE_READWRITE) ||
(MemoryArea->Attributes & PAGE_EXECUTE_READWRITE)))
{
MmDereserveSwapPages(PAGE_ROUND_UP(MemoryArea->Length));
}
#endif
MmFreeVirtualMemory(Process, MemoryArea); MmFreeVirtualMemory(Process, MemoryArea);
MmUnlockAddressSpace(AddressSpace); MmUnlockAddressSpace(AddressSpace);
ObDereferenceObject(Process); ObDereferenceObject(Process);
@ -1286,7 +1339,8 @@ NtProtectVirtualMemory(IN HANDLE ProcessHandle,
} }
NTSTATUS STDCALL NtQueryVirtualMemory (IN HANDLE ProcessHandle, NTSTATUS STDCALL
NtQueryVirtualMemory (IN HANDLE ProcessHandle,
IN PVOID Address, IN PVOID Address,
IN CINT VirtualMemoryInformationClass, IN CINT VirtualMemoryInformationClass,
OUT PVOID VirtualMemoryInformation, OUT PVOID VirtualMemoryInformation,
@ -1504,24 +1558,18 @@ NtWriteVirtualMemory(IN HANDLE ProcessHandle,
} }
DWORD DWORD STDCALL
STDCALL MmSecureVirtualMemory (DWORD Unknown0,
MmSecureVirtualMemory (
DWORD Unknown0,
DWORD Unknown1, DWORD Unknown1,
DWORD Unknown2 DWORD Unknown2)
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
return 0; return 0;
} }
VOID VOID STDCALL
STDCALL MmUnsecureVirtualMemory (DWORD Unknown0)
MmUnsecureVirtualMemory (
DWORD Unknown0
)
{ {
UNIMPLEMENTED; UNIMPLEMENTED;
} }

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: handle.c,v 1.37 2002/05/07 22:38:29 hbirr Exp $ /* $Id: handle.c,v 1.38 2002/06/11 22:09:02 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -105,8 +105,56 @@ static PHANDLE_REP ObpGetObjectByHandle(PHANDLE_TABLE HandleTable, HANDLE h)
return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES])); return(&(blk->handles[handle%HANDLE_BLOCK_ENTRIES]));
} }
NTSTATUS
ObDuplicateObject(PEPROCESS SourceProcess,
PEPROCESS TargetProcess,
HANDLE SourceHandle,
PHANDLE TargetHandle,
ACCESS_MASK DesiredAccess,
BOOLEAN InheritHandle,
ULONG Options)
{
KIRQL oldIrql;
PHANDLE_REP SourceHandleRep;
PVOID ObjectBody;
NTSTATUS STDCALL NtDuplicateObject (IN HANDLE SourceProcessHandle, KeAcquireSpinLock(&SourceProcess->HandleTable.ListLock, &oldIrql);
SourceHandleRep = ObpGetObjectByHandle(&SourceProcess->HandleTable,
SourceHandle);
if (SourceHandleRep == NULL)
{
KeReleaseSpinLock(&SourceProcess->HandleTable.ListLock, oldIrql);
return(STATUS_INVALID_HANDLE);
}
ObjectBody = SourceHandleRep->ObjectBody;
ObReferenceObjectByPointer(ObjectBody,
0,
NULL,
UserMode);
if (Options & DUPLICATE_SAME_ACCESS)
{
DesiredAccess = SourceHandleRep->GrantedAccess;
}
KeReleaseSpinLock(&SourceProcess->HandleTable.ListLock, oldIrql);
ObCreateHandle(TargetProcess,
ObjectBody,
DesiredAccess,
InheritHandle,
TargetHandle);
if (Options & DUPLICATE_CLOSE_SOURCE)
{
ZwClose(SourceHandle);
}
ObDereferenceObject(ObjectBody);
return(STATUS_SUCCESS);
}
NTSTATUS STDCALL
NtDuplicateObject (IN HANDLE SourceProcessHandle,
IN HANDLE SourceHandle, IN HANDLE SourceHandle,
IN HANDLE TargetProcessHandle, IN HANDLE TargetProcessHandle,
OUT PHANDLE UnsafeTargetHandle, OUT PHANDLE UnsafeTargetHandle,
@ -191,7 +239,6 @@ NTSTATUS STDCALL NtDuplicateObject (IN HANDLE SourceProcessHandle,
} }
KeReleaseSpinLock(&SourceProcess->HandleTable.ListLock, oldIrql); KeReleaseSpinLock(&SourceProcess->HandleTable.ListLock, oldIrql);
if (!SourceHandleRep->Inherit) if (!SourceHandleRep->Inherit)
{ {
ObDereferenceObject(TargetProcess); ObDereferenceObject(TargetProcess);
@ -199,7 +246,6 @@ NTSTATUS STDCALL NtDuplicateObject (IN HANDLE SourceProcessHandle,
ObDereferenceObject(ObjectBody); ObDereferenceObject(ObjectBody);
return STATUS_INVALID_HANDLE; return STATUS_INVALID_HANDLE;
} }
ObCreateHandle(TargetProcess, ObCreateHandle(TargetProcess,
ObjectBody, ObjectBody,
DesiredAccess, DesiredAccess,
@ -370,14 +416,16 @@ VOID ObCreateHandleTable(PEPROCESS Parent,
{ {
if (current_block->handles[i].Inherit && Inherit) if (current_block->handles[i].Inherit && Inherit)
{ {
new_block->handles[i].ObjectBody = current_block->handles[i].ObjectBody; new_block->handles[i].ObjectBody =
new_block->handles[i].GrantedAccess = current_block->handles[i].GrantedAccess; current_block->handles[i].ObjectBody;
new_block->handles[i].GrantedAccess =
current_block->handles[i].GrantedAccess;
new_block->handles[i].Inherit = TRUE; new_block->handles[i].Inherit = TRUE;
InterlockedIncrement(&(BODY_TO_HEADER(current_block->handles[i].ObjectBody)->HandleCount)); InterlockedIncrement(&(BODY_TO_HEADER(current_block->handles[i].ObjectBody)->HandleCount));
} }
} }
} }
InsertTailList(&(Process->HandleTable.ListHead), &new_block->entry); InsertTailList(&Process->HandleTable.ListHead, &new_block->entry);
parent_current = parent_current->Flink; parent_current = parent_current->Flink;
} }
KeReleaseSpinLockFromDpcLevel(&Process->HandleTable.ListLock); KeReleaseSpinLockFromDpcLevel(&Process->HandleTable.ListLock);

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.80 2002/06/04 15:26:57 dwelch Exp $ /* $Id: process.c,v 1.81 2002/06/11 22:09:03 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -255,6 +255,7 @@ PsInitProcessManagment(VOID)
(LARGE_INTEGER)(LONGLONG)(ULONG)MmGetPageDirectory(); (LARGE_INTEGER)(LONGLONG)(ULONG)MmGetPageDirectory();
PsInitialSystemProcess->UniqueProcessId = PsInitialSystemProcess->UniqueProcessId =
InterlockedIncrement(&PiNextProcessUniqueId); InterlockedIncrement(&PiNextProcessUniqueId);
PsInitialSystemProcess->Win32WindowStation = (HANDLE)0;
KeAcquireSpinLock(&PsProcessListLock, &oldIrql); KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
InsertHeadList(&PsProcessListHead, InsertHeadList(&PsProcessListHead,
@ -285,9 +286,11 @@ PiFreeSymbols(PPEB Peb)
assert (Peb->Ldr); assert (Peb->Ldr);
CurrentEntry = Peb->Ldr->InLoadOrderModuleList.Flink; CurrentEntry = Peb->Ldr->InLoadOrderModuleList.Flink;
while ((CurrentEntry != &Peb->Ldr->InLoadOrderModuleList) && (CurrentEntry != NULL)) while (CurrentEntry != &Peb->Ldr->InLoadOrderModuleList &&
CurrentEntry != NULL)
{ {
Current = CONTAINING_RECORD (CurrentEntry, LDR_MODULE, InLoadOrderModuleList); Current = CONTAINING_RECORD(CurrentEntry, LDR_MODULE,
InLoadOrderModuleList);
Symbol = Current->Symbols.Symbols; Symbol = Current->Symbols.Symbols;
while (Symbol != NULL) while (Symbol != NULL)
{ {
@ -515,6 +518,26 @@ NtCreateProcess(OUT PHANDLE ProcessHandle,
InheritObjectTable, InheritObjectTable,
Process); Process);
MmCopyMmInfo(ParentProcess, Process); MmCopyMmInfo(ParentProcess, Process);
if (ParentProcess->Win32WindowStation != (HANDLE)0)
{
/* Always duplicate the process window station. */
Process->Win32WindowStation = 0;
Status = ObDuplicateObject(ParentProcess,
Process,
ParentProcess->Win32WindowStation,
&Process->Win32WindowStation,
0,
FALSE,
DUPLICATE_SAME_ACCESS);
if (!NT_SUCCESS(Status))
{
KeBugCheck(0);
}
}
else
{
Process->Win32WindowStation = (HANDLE)0;
}
KeAcquireSpinLock(&PsProcessListLock, &oldIrql); KeAcquireSpinLock(&PsProcessListLock, &oldIrql);
for (i = 0; i < PiProcessNotifyRoutineCount; i++) for (i = 0; i < PiProcessNotifyRoutineCount; i++)

View file

@ -1,4 +1,4 @@
/* $Id: winlogon.c,v 1.8 2002/02/08 02:57:06 chorns Exp $ /* $Id: winlogon.c,v 1.9 2002/06/11 22:09:03 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -227,6 +227,12 @@ WinMain(HINSTANCE hInstance,
*/ */
InteractiveWindowStation = CreateWindowStationW( InteractiveWindowStation = CreateWindowStationW(
L"WinSta0", 0, GENERIC_ALL, NULL); L"WinSta0", 0, GENERIC_ALL, NULL);
if (InteractiveWindowStation == NULL)
{
DbgPrint("Failed to create window station (0x%X)\n", GetLastError());
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED, 0, 0, 0, 0, 0);
ExitProcess(1);
}
/* /*
* Set the process window station * Set the process window station

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.43 2002/05/06 22:20:32 dwelch Exp $ # $Id: makefile,v 1.44 2002/06/11 22:09:03 dwelch Exp $
PATH_TO_TOP = ../.. PATH_TO_TOP = ../..
@ -10,10 +10,15 @@ TARGET_BASE = 0x0
TARGET_ENTRY = _DllMain@8 TARGET_ENTRY = _DllMain@8
# from atheos appserver makefile include $(PATH_TO_TOP)/config
COPTS = -pipe -O3 -I./freetype/include -c -Wall
TARGET_CFLAGS = -I$(PATH_TO_TOP)/ntoskrnl/include -DUNICODE -Wall ifeq ($(DBG), 1)
CFLAGS_DBG := -g
else
CFLAGS_DBG :=
endif
TARGET_CFLAGS = $(CFLAGS_DBG) -I$(PATH_TO_TOP)/ntoskrnl/include -DUNICODE -Wall
ENG_OBJECTS= eng/debug.o eng/mem.o eng/brush.o eng/bitblt.o eng/clip.o \ ENG_OBJECTS= eng/debug.o eng/mem.o eng/brush.o eng/bitblt.o eng/clip.o \
eng/copybits.o eng/device.o eng/handle.o eng/lineto.o eng/paint.o \ eng/copybits.o eng/device.o eng/handle.o eng/lineto.o eng/paint.o \

View file

@ -1,4 +1,4 @@
/* $Id: class.c,v 1.4 2002/01/27 01:11:24 dwelch Exp $ /* $Id: class.c,v 1.5 2002/06/11 22:09:03 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -18,7 +18,7 @@
#include <include/winsta.h> #include <include/winsta.h>
#include <include/object.h> #include <include/object.h>
#define NDEBUG //#define NDEBUG
#include <debug.h> #include <debug.h>
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/

View file

@ -1,4 +1,4 @@
/* $Id: winsta.c,v 1.2 2001/06/16 14:11:31 ekohl Exp $ /* $Id: winsta.c,v 1.3 2002/06/11 22:09:03 dwelch Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -19,7 +19,7 @@
#include <include/winsta.h> #include <include/winsta.h>
#include <include/object.h> #include <include/object.h>
#define NDEBUG //#define NDEBUG
#include <debug.h> #include <debug.h>
#define WINSTA_ROOT_NAME L"\\Windows\\WindowStations" #define WINSTA_ROOT_NAME L"\\Windows\\WindowStations"
@ -27,7 +27,6 @@
HDESK InputDesktop; /* Currently active desktop */ HDESK InputDesktop; /* Currently active desktop */
NTSTATUS NTSTATUS
InitWindowStationImpl(VOID) InitWindowStationImpl(VOID)
{ {
@ -39,24 +38,22 @@ InitWindowStationImpl(VOID)
/* /*
* Create the '\Windows\WindowStations' directory * Create the '\Windows\WindowStations' directory
*/ */
RtlInitUnicodeString( RtlInitUnicodeString(&UnicodeString,
&UnicodeString,
WINSTA_ROOT_NAME); WINSTA_ROOT_NAME);
InitializeObjectAttributes( InitializeObjectAttributes(&ObjectAttributes,
&ObjectAttributes,
&UnicodeString, &UnicodeString,
0, 0,
NULL, NULL,
NULL); NULL);
Status = ZwCreateDirectoryObject( Status = ZwCreateDirectoryObject(&WindowStationsDirectory,
&WindowStationsDirectory,
0, 0,
&ObjectAttributes); &ObjectAttributes);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("Could not create \\Windows\\WindowStations directory (Status 0x%X)\n", Status); DPRINT("Could not create \\Windows\\WindowStations directory "
"(Status 0x%X)\n", Status);
return Status; return Status;
} }
@ -71,22 +68,21 @@ CleanupWindowStationImpl(VOID)
NTSTATUS NTSTATUS
ValidateWindowStationHandle( ValidateWindowStationHandle(HWINSTA WindowStation,
HWINSTA WindowStation,
KPROCESSOR_MODE AccessMode, KPROCESSOR_MODE AccessMode,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
PWINSTATION_OBJECT *Object) PWINSTATION_OBJECT *Object)
{ {
NTSTATUS Status; NTSTATUS Status;
Status = ObReferenceObjectByHandle( Status = ObReferenceObjectByHandle(WindowStation,
WindowStation,
DesiredAccess, DesiredAccess,
ExWindowStationObjectType, ExWindowStationObjectType,
AccessMode, AccessMode,
(PVOID*)Object, (PVOID*)Object,
NULL); NULL);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status))
{
SetLastNtError(Status); SetLastNtError(Status);
} }
@ -94,22 +90,21 @@ ValidateWindowStationHandle(
} }
NTSTATUS NTSTATUS
ValidateDesktopHandle( ValidateDesktopHandle(HDESK Desktop,
HDESK Desktop,
KPROCESSOR_MODE AccessMode, KPROCESSOR_MODE AccessMode,
ACCESS_MASK DesiredAccess, ACCESS_MASK DesiredAccess,
PDESKTOP_OBJECT *Object) PDESKTOP_OBJECT *Object)
{ {
NTSTATUS Status; NTSTATUS Status;
Status = ObReferenceObjectByHandle( Status = ObReferenceObjectByHandle(Desktop,
Desktop,
DesiredAccess, DesiredAccess,
ExDesktopObjectType, ExDesktopObjectType,
AccessMode, AccessMode,
(PVOID*)Object, (PVOID*)Object,
NULL); NULL);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status))
{
SetLastNtError(Status); SetLastNtError(Status);
} }
@ -372,29 +367,31 @@ NtUserSetObjectInformation(
* RETURNS: * RETURNS:
* Status * Status
*/ */
BOOL BOOL STDCALL
STDCALL NtUserSetProcessWindowStation(HWINSTA hWindowStation)
NtUserSetProcessWindowStation(
HWINSTA hWindowStation)
{ {
PWINSTATION_OBJECT Object; PWINSTATION_OBJECT Object;
NTSTATUS Status; NTSTATUS Status;
DPRINT("About to set process window station with handle (0x%X)\n", hWindowStation); DPRINT("About to set process window station with handle (0x%X)\n",
hWindowStation);
Status = ValidateWindowStationHandle( Status = ValidateWindowStationHandle(hWindowStation,
hWindowStation,
KernelMode, KernelMode,
0, 0,
&Object); &Object);
if (!NT_SUCCESS(Status)) { if (!NT_SUCCESS(Status))
DPRINT("Validation of window station handle (0x%X) failed\n", hWindowStation); {
DPRINT("Validation of window station handle (0x%X) failed\n",
hWindowStation);
return FALSE; return FALSE;
} }
ObDereferenceObject(Object); ObDereferenceObject(Object);
SET_PROCESS_WINDOW_STATION(hWindowStation); SET_PROCESS_WINDOW_STATION(hWindowStation);
DPRINT("IoGetCurrentProcess()->Win32WindowStation 0x%X\n",
IoGetCurrentProcess()->Win32WindowStation);
return TRUE; return TRUE;
} }