mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:52:57 +00:00
- Removed the member OldProcess from the ETHREAD structure.
svn path=/trunk/; revision=10759
This commit is contained in:
parent
2d0d1ee993
commit
a9bae8fa65
11 changed files with 139 additions and 87 deletions
|
@ -18,7 +18,7 @@
|
||||||
* If not, write to the Free Software Foundation,
|
* If not, write to the Free Software Foundation,
|
||||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
*
|
||||||
* $Id: videoprt.c,v 1.26 2004/07/03 17:40:21 navaraf Exp $
|
* $Id: videoprt.c,v 1.27 2004/08/31 20:17:17 hbirr Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "videoprt.h"
|
#include "videoprt.h"
|
||||||
|
@ -457,7 +457,7 @@ IntAttachToCSRSS(PEPROCESS *CallingProcess, PEPROCESS *PrevAttachedProcess)
|
||||||
*CallingProcess = PsGetCurrentProcess();
|
*CallingProcess = PsGetCurrentProcess();
|
||||||
if (*CallingProcess != Csrss)
|
if (*CallingProcess != Csrss)
|
||||||
{
|
{
|
||||||
if (PsGetCurrentThread()->OldProcess != NULL)
|
if (PsGetCurrentThread()->ThreadsProcess != *CallingProcess)
|
||||||
{
|
{
|
||||||
*PrevAttachedProcess = *CallingProcess;
|
*PrevAttachedProcess = *CallingProcess;
|
||||||
KeDetachProcess();
|
KeDetachProcess();
|
||||||
|
|
|
@ -26,12 +26,12 @@
|
||||||
#define KTHREAD_STACK_LIMIT 0x1C
|
#define KTHREAD_STACK_LIMIT 0x1C
|
||||||
#define KTHREAD_TEB 0x20
|
#define KTHREAD_TEB 0x20
|
||||||
#define KTHREAD_KERNEL_STACK 0x28
|
#define KTHREAD_KERNEL_STACK 0x28
|
||||||
|
#define KTHREAD_APCSTATE_PROCESS 0x44
|
||||||
#define KTHREAD_SERVICE_TABLE 0xDC
|
#define KTHREAD_SERVICE_TABLE 0xDC
|
||||||
#define KTHREAD_PREVIOUS_MODE 0x137
|
#define KTHREAD_PREVIOUS_MODE 0x137
|
||||||
#define KTHREAD_TRAP_FRAME 0x128
|
#define KTHREAD_TRAP_FRAME 0x128
|
||||||
#define KTHREAD_CALLBACK_STACK 0x120
|
#define KTHREAD_CALLBACK_STACK 0x120
|
||||||
|
|
||||||
#define ETHREAD_THREADS_PROCESS 0x234
|
|
||||||
|
|
||||||
#define KPROCESS_DIRECTORY_TABLE_BASE 0x18
|
#define KPROCESS_DIRECTORY_TABLE_BASE 0x18
|
||||||
#define KPROCESS_LDT_DESCRIPTOR0 0x20
|
#define KPROCESS_LDT_DESCRIPTOR0 0x20
|
||||||
|
|
|
@ -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: ps.h,v 1.65 2004/08/21 12:34:58 tamlin Exp $
|
/* $Id: ps.h,v 1.66 2004/08/31 20:17:17 hbirr Exp $
|
||||||
*
|
*
|
||||||
* FILE: ntoskrnl/ke/kthread.c
|
* FILE: ntoskrnl/ke/kthread.c
|
||||||
* PURPOSE: Process manager definitions
|
* PURPOSE: Process manager definitions
|
||||||
|
@ -62,7 +62,8 @@ typedef struct _KAPC_STATE
|
||||||
struct _KPROCESS* Process;
|
struct _KPROCESS* Process;
|
||||||
UCHAR KernelApcInProgress;
|
UCHAR KernelApcInProgress;
|
||||||
UCHAR KernelApcPending;
|
UCHAR KernelApcPending;
|
||||||
USHORT UserApcPending;
|
UCHAR UserApcPending;
|
||||||
|
UCHAR Reserved;
|
||||||
} KAPC_STATE, *PKAPC_STATE, *__restrict PRKAPC_STATE;
|
} KAPC_STATE, *PKAPC_STATE, *__restrict PRKAPC_STATE;
|
||||||
|
|
||||||
#include <poppack.h>
|
#include <poppack.h>
|
||||||
|
@ -223,10 +224,6 @@ typedef struct _ETHREAD
|
||||||
BOOLEAN ActiveImpersonationInfo; /* 23B/267 */
|
BOOLEAN ActiveImpersonationInfo; /* 23B/267 */
|
||||||
ULONG PerformanceCountHigh; /* 23C/268 */
|
ULONG PerformanceCountHigh; /* 23C/268 */
|
||||||
|
|
||||||
/*
|
|
||||||
* Added by David Welch (welch@cwcom.net)
|
|
||||||
*/
|
|
||||||
struct _EPROCESS* OldProcess; /* 240/26C */
|
|
||||||
|
|
||||||
struct _W32THREAD* Win32Thread;
|
struct _W32THREAD* Win32Thread;
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ _Ki386ContextSwitch:
|
||||||
* Set the current LDT
|
* Set the current LDT
|
||||||
*/
|
*/
|
||||||
xorl %eax, %eax
|
xorl %eax, %eax
|
||||||
movl ETHREAD_THREADS_PROCESS(%ebx), %edi
|
movl KTHREAD_APCSTATE_PROCESS(%ebx), %edi
|
||||||
testw $0xFFFF, KPROCESS_LDT_DESCRIPTOR0(%edi)
|
testw $0xFFFF, KPROCESS_LDT_DESCRIPTOR0(%edi)
|
||||||
jz .L4
|
jz .L4
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ _Ki386ContextSwitch:
|
||||||
/*
|
/*
|
||||||
* Change the address space
|
* Change the address space
|
||||||
*/
|
*/
|
||||||
movl ETHREAD_THREADS_PROCESS(%ebx), %ebx
|
movl KTHREAD_APCSTATE_PROCESS(%ebx), %ebx
|
||||||
movl KPROCESS_DIRECTORY_TABLE_BASE(%ebx), %eax
|
movl KPROCESS_DIRECTORY_TABLE_BASE(%ebx), %eax
|
||||||
movl %eax, %cr3
|
movl %eax, %cr3
|
||||||
|
|
||||||
|
|
|
@ -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: main.c,v 1.192 2004/08/15 16:39:05 chorns Exp $
|
/* $Id: main.c,v 1.193 2004/08/31 20:17:18 hbirr Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ke/main.c
|
* FILE: ntoskrnl/ke/main.c
|
||||||
|
@ -292,7 +292,7 @@ ExpInitializeExecutive(VOID)
|
||||||
assert(FIELD_OFFSET(KTHREAD, PreviousMode) == KTHREAD_PREVIOUS_MODE);
|
assert(FIELD_OFFSET(KTHREAD, PreviousMode) == KTHREAD_PREVIOUS_MODE);
|
||||||
assert(FIELD_OFFSET(KTHREAD, TrapFrame) == KTHREAD_TRAP_FRAME);
|
assert(FIELD_OFFSET(KTHREAD, TrapFrame) == KTHREAD_TRAP_FRAME);
|
||||||
assert(FIELD_OFFSET(KTHREAD, CallbackStack) == KTHREAD_CALLBACK_STACK);
|
assert(FIELD_OFFSET(KTHREAD, CallbackStack) == KTHREAD_CALLBACK_STACK);
|
||||||
assert(FIELD_OFFSET(ETHREAD, ThreadsProcess) == ETHREAD_THREADS_PROCESS);
|
assert(FIELD_OFFSET(KTHREAD, ApcState.Process) == KTHREAD_APCSTATE_PROCESS);
|
||||||
assert(FIELD_OFFSET(KPROCESS, DirectoryTableBase) ==
|
assert(FIELD_OFFSET(KPROCESS, DirectoryTableBase) ==
|
||||||
KPROCESS_DIRECTORY_TABLE_BASE);
|
KPROCESS_DIRECTORY_TABLE_BASE);
|
||||||
assert(FIELD_OFFSET(KPROCESS, IopmOffset) == KPROCESS_IOPM_OFFSET);
|
assert(FIELD_OFFSET(KPROCESS, IopmOffset) == KPROCESS_IOPM_OFFSET);
|
||||||
|
|
|
@ -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: process.c,v 1.26 2004/08/27 10:24:04 hbirr Exp $
|
/* $Id: process.c,v 1.27 2004/08/31 20:17:18 hbirr Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/ke/process.c
|
* FILE: ntoskrnl/ke/process.c
|
||||||
|
@ -49,11 +49,17 @@ KeAttachProcess (PEPROCESS Process)
|
||||||
|
|
||||||
CurrentThread = PsGetCurrentThread();
|
CurrentThread = PsGetCurrentThread();
|
||||||
|
|
||||||
if (CurrentThread->OldProcess != NULL)
|
if (&CurrentThread->ThreadsProcess->Pcb != CurrentThread->Tcb.ApcState.Process)
|
||||||
{
|
{
|
||||||
DbgPrint("Invalid attach (thread is already attached)\n");
|
DPRINT1("Invalid attach (thread is already attached)\n");
|
||||||
KEBUGCHECK(INVALID_PROCESS_ATTACH_ATTEMPT);
|
KEBUGCHECK(INVALID_PROCESS_ATTACH_ATTEMPT);
|
||||||
}
|
}
|
||||||
|
if (&Process->Pcb == CurrentThread->Tcb.ApcState.Process)
|
||||||
|
{
|
||||||
|
DPRINT1("Invalid attach (process is the same)\n");
|
||||||
|
KEBUGCHECK(INVALID_PROCESS_ATTACH_ATTEMPT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* The stack and the thread structure of the current process may be
|
/* The stack and the thread structure of the current process may be
|
||||||
located in a page which is not present in the page directory of
|
located in a page which is not present in the page directory of
|
||||||
|
@ -71,8 +77,7 @@ KeAttachProcess (PEPROCESS Process)
|
||||||
|
|
||||||
KiSwapApcEnvironment(&CurrentThread->Tcb, &Process->Pcb);
|
KiSwapApcEnvironment(&CurrentThread->Tcb, &Process->Pcb);
|
||||||
|
|
||||||
CurrentThread->OldProcess = PsGetCurrentProcess();
|
CurrentThread->Tcb.ApcState.Process = &Process->Pcb;
|
||||||
CurrentThread->ThreadsProcess = Process;
|
|
||||||
PageDir = Process->Pcb.DirectoryTableBase.u.LowPart;
|
PageDir = Process->Pcb.DirectoryTableBase.u.LowPart;
|
||||||
DPRINT("Switching process context to %x\n",PageDir);
|
DPRINT("Switching process context to %x\n",PageDir);
|
||||||
Ke386SetPageTableDirectory(PageDir);
|
Ke386SetPageTableDirectory(PageDir);
|
||||||
|
@ -93,19 +98,16 @@ KeDetachProcess (VOID)
|
||||||
|
|
||||||
CurrentThread = PsGetCurrentThread();
|
CurrentThread = PsGetCurrentThread();
|
||||||
|
|
||||||
if (CurrentThread->OldProcess == NULL)
|
if (&CurrentThread->ThreadsProcess->Pcb == CurrentThread->Tcb.ApcState.Process)
|
||||||
{
|
{
|
||||||
DbgPrint("Invalid detach (thread was not attached)\n");
|
DPRINT1("Invalid detach (thread was not attached)\n");
|
||||||
KEBUGCHECK(INVALID_PROCESS_DETACH_ATTEMPT);
|
KEBUGCHECK(INVALID_PROCESS_DETACH_ATTEMPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
|
KeRaiseIrql(DISPATCH_LEVEL, &oldlvl);
|
||||||
|
|
||||||
KiSwapApcEnvironment(&CurrentThread->Tcb, &CurrentThread->OldProcess->Pcb);
|
KiSwapApcEnvironment(&CurrentThread->Tcb, CurrentThread->Tcb.SavedApcState.Process);
|
||||||
|
PageDir = CurrentThread->Tcb.ApcState.Process->DirectoryTableBase.u.LowPart;
|
||||||
CurrentThread->ThreadsProcess = CurrentThread->OldProcess;
|
|
||||||
CurrentThread->OldProcess = NULL;
|
|
||||||
PageDir = CurrentThread->ThreadsProcess->Pcb.DirectoryTableBase.u.LowPart;
|
|
||||||
Ke386SetPageTableDirectory(PageDir);
|
Ke386SetPageTableDirectory(PageDir);
|
||||||
|
|
||||||
KeLowerIrql(oldlvl);
|
KeLowerIrql(oldlvl);
|
||||||
|
|
|
@ -77,7 +77,7 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
UNICODE_STRING DllPathname = ROS_STRING_INITIALIZER(L"\\SystemRoot\\system32\\ntdll.dll");
|
UNICODE_STRING DllPathname = ROS_STRING_INITIALIZER(L"\\SystemRoot\\system32\\ntdll.dll");
|
||||||
PIMAGE_DOS_HEADER DosHeader;
|
PIMAGE_DOS_HEADER DosHeader;
|
||||||
PIMAGE_NT_HEADERS NTHeaders;
|
PIMAGE_NT_HEADERS NTHeaders;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process, CurrentProcess;
|
||||||
ANSI_STRING ProcedureName;
|
ANSI_STRING ProcedureName;
|
||||||
ULONG ViewSize;
|
ULONG ViewSize;
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
|
@ -190,8 +190,12 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Attaching to Process\n");
|
CurrentProcess = PsGetCurrentProcess();
|
||||||
KeAttachProcess(Process);
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
DPRINT("Attaching to Process\n");
|
||||||
|
KeAttachProcess(Process);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* retrieve ntdll's startup address
|
* retrieve ntdll's startup address
|
||||||
|
@ -207,7 +211,10 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
KeDetachProcess();
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
KeDetachProcess();
|
||||||
|
}
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
ZwClose(NTDllSectionHandle);
|
ZwClose(NTDllSectionHandle);
|
||||||
return (Status);
|
return (Status);
|
||||||
|
@ -229,7 +236,10 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
KeDetachProcess();
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
KeDetachProcess();
|
||||||
|
}
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
ZwClose(NTDllSectionHandle);
|
ZwClose(NTDllSectionHandle);
|
||||||
return (Status);
|
return (Status);
|
||||||
|
@ -250,7 +260,10 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
KeDetachProcess();
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
KeDetachProcess();
|
||||||
|
}
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
ZwClose(NTDllSectionHandle);
|
ZwClose(NTDllSectionHandle);
|
||||||
return (Status);
|
return (Status);
|
||||||
|
@ -271,7 +284,10 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
KeDetachProcess();
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
KeDetachProcess();
|
||||||
|
}
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
ZwClose(NTDllSectionHandle);
|
ZwClose(NTDllSectionHandle);
|
||||||
return (Status);
|
return (Status);
|
||||||
|
@ -292,14 +308,20 @@ NTSTATUS LdrpMapSystemDll(HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
DbgPrint ("LdrGetProcedureAddress failed (Status %x)\n", Status);
|
||||||
KeDetachProcess();
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
KeDetachProcess();
|
||||||
|
}
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
ZwClose(NTDllSectionHandle);
|
ZwClose(NTDllSectionHandle);
|
||||||
return (Status);
|
return (Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KeDetachProcess();
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
KeDetachProcess();
|
||||||
|
}
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
ZwClose(NTDllSectionHandle);
|
ZwClose(NTDllSectionHandle);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: send.c,v 1.16 2004/08/15 16:39:06 chorns Exp $
|
/* $Id: send.c,v 1.17 2004/08/31 20:17:18 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -245,13 +245,13 @@ NtRequestWaitReplyPort (IN HANDLE PortHandle,
|
||||||
handle we can undo this, so everything is normal again. Need to
|
handle we can undo this, so everything is normal again. Need to
|
||||||
re-KeAttach() before returning though */
|
re-KeAttach() before returning though */
|
||||||
CurrentThread = PsGetCurrentThread();
|
CurrentThread = PsGetCurrentThread();
|
||||||
if (NULL == CurrentThread->OldProcess)
|
if (&CurrentThread->ThreadsProcess->Pcb == CurrentThread->Tcb.ApcState.Process)
|
||||||
{
|
{
|
||||||
AttachedProcess = NULL;
|
AttachedProcess = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AttachedProcess = CurrentThread->ThreadsProcess;
|
AttachedProcess = (PEPROCESS)CurrentThread->Tcb.ApcState.Process;
|
||||||
KeDetachProcess();
|
KeDetachProcess();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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: virtual.c,v 1.79 2004/07/17 03:03:52 ion Exp $
|
/* $Id: virtual.c,v 1.80 2004/08/31 20:17:18 hbirr Exp $
|
||||||
*
|
*
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
* FILE: ntoskrnl/mm/virtual.c
|
* FILE: ntoskrnl/mm/virtual.c
|
||||||
|
@ -376,7 +376,8 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PMDL Mdl;
|
PMDL Mdl;
|
||||||
PVOID SystemAddress;
|
PVOID SystemAddress;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process, CurrentProcess;
|
||||||
|
|
||||||
|
|
||||||
DPRINT("NtReadVirtualMemory(ProcessHandle %x, BaseAddress %x, "
|
DPRINT("NtReadVirtualMemory(ProcessHandle %x, BaseAddress %x, "
|
||||||
"Buffer %x, NumberOfBytesToRead %d)\n",ProcessHandle,BaseAddress,
|
"Buffer %x, NumberOfBytesToRead %d)\n",ProcessHandle,BaseAddress,
|
||||||
|
@ -393,31 +394,40 @@ NtReadVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mdl = MmCreateMdl(NULL,
|
CurrentProcess = PsGetCurrentProcess();
|
||||||
Buffer,
|
|
||||||
NumberOfBytesToRead);
|
if (Process == CurrentProcess)
|
||||||
if(Mdl == NULL)
|
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Process);
|
memcpy(Buffer, BaseAddress, NumberOfBytesToRead);
|
||||||
return(STATUS_NO_MEMORY);
|
|
||||||
}
|
}
|
||||||
MmProbeAndLockPages(Mdl,
|
else
|
||||||
UserMode,
|
|
||||||
IoWriteAccess);
|
|
||||||
|
|
||||||
KeAttachProcess(Process);
|
|
||||||
|
|
||||||
SystemAddress = MmGetSystemAddressForMdl(Mdl);
|
|
||||||
memcpy(SystemAddress, BaseAddress, NumberOfBytesToRead);
|
|
||||||
|
|
||||||
KeDetachProcess();
|
|
||||||
|
|
||||||
if (Mdl->MappedSystemVa != NULL)
|
|
||||||
{
|
{
|
||||||
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
|
Mdl = MmCreateMdl(NULL,
|
||||||
|
Buffer,
|
||||||
|
NumberOfBytesToRead);
|
||||||
|
if(Mdl == NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
MmProbeAndLockPages(Mdl,
|
||||||
|
UserMode,
|
||||||
|
IoWriteAccess);
|
||||||
|
|
||||||
|
KeAttachProcess(Process);
|
||||||
|
|
||||||
|
SystemAddress = MmGetSystemAddressForMdl(Mdl);
|
||||||
|
memcpy(SystemAddress, BaseAddress, NumberOfBytesToRead);
|
||||||
|
|
||||||
|
KeDetachProcess();
|
||||||
|
|
||||||
|
if (Mdl->MappedSystemVa != NULL)
|
||||||
|
{
|
||||||
|
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
|
||||||
|
}
|
||||||
|
MmUnlockPages(Mdl);
|
||||||
|
ExFreePool(Mdl);
|
||||||
}
|
}
|
||||||
MmUnlockPages(Mdl);
|
|
||||||
ExFreePool(Mdl);
|
|
||||||
|
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
|
@ -515,33 +525,40 @@ NtWriteVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mdl = MmCreateMdl(NULL,
|
if (Process == PsGetCurrentProcess())
|
||||||
Buffer,
|
|
||||||
NumberOfBytesToWrite);
|
|
||||||
MmProbeAndLockPages(Mdl,
|
|
||||||
UserMode,
|
|
||||||
IoReadAccess);
|
|
||||||
if(Mdl == NULL)
|
|
||||||
{
|
{
|
||||||
ObDereferenceObject(Process);
|
memcpy(BaseAddress, Buffer, NumberOfBytesToWrite);
|
||||||
return(STATUS_NO_MEMORY);
|
|
||||||
}
|
}
|
||||||
KeAttachProcess(Process);
|
else
|
||||||
|
{
|
||||||
|
Mdl = MmCreateMdl(NULL,
|
||||||
|
Buffer,
|
||||||
|
NumberOfBytesToWrite);
|
||||||
|
MmProbeAndLockPages(Mdl,
|
||||||
|
UserMode,
|
||||||
|
IoReadAccess);
|
||||||
|
if(Mdl == NULL)
|
||||||
|
{
|
||||||
|
ObDereferenceObject(Process);
|
||||||
|
return(STATUS_NO_MEMORY);
|
||||||
|
}
|
||||||
|
KeAttachProcess(Process);
|
||||||
|
|
||||||
SystemAddress = MmGetSystemAddressForMdl(Mdl);
|
SystemAddress = MmGetSystemAddressForMdl(Mdl);
|
||||||
memcpy(BaseAddress, SystemAddress, NumberOfBytesToWrite);
|
memcpy(BaseAddress, SystemAddress, NumberOfBytesToWrite);
|
||||||
|
|
||||||
KeDetachProcess();
|
KeDetachProcess();
|
||||||
|
|
||||||
|
if (Mdl->MappedSystemVa != NULL)
|
||||||
|
{
|
||||||
|
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
|
||||||
|
}
|
||||||
|
MmUnlockPages(Mdl);
|
||||||
|
ExFreePool(Mdl);
|
||||||
|
}
|
||||||
|
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
|
|
||||||
if (Mdl->MappedSystemVa != NULL)
|
|
||||||
{
|
|
||||||
MmUnmapLockedPages(Mdl->MappedSystemVa, Mdl);
|
|
||||||
}
|
|
||||||
MmUnlockPages(Mdl);
|
|
||||||
ExFreePool(Mdl);
|
|
||||||
|
|
||||||
*NumberOfBytesWritten = NumberOfBytesToWrite;
|
*NumberOfBytesWritten = NumberOfBytesToWrite;
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: kill.c,v 1.73 2004/08/15 16:39:10 chorns Exp $
|
/* $Id: kill.c,v 1.74 2004/08/31 20:17:18 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -254,6 +254,7 @@ PiTerminateProcess(PEPROCESS Process,
|
||||||
NTSTATUS ExitStatus)
|
NTSTATUS ExitStatus)
|
||||||
{
|
{
|
||||||
KIRQL OldIrql;
|
KIRQL OldIrql;
|
||||||
|
PEPROCESS CurrentProcess;
|
||||||
|
|
||||||
DPRINT("PiTerminateProcess(Process %x, ExitStatus %x) PC %d HC %d\n",
|
DPRINT("PiTerminateProcess(Process %x, ExitStatus %x) PC %d HC %d\n",
|
||||||
Process, ExitStatus, ObGetObjectPointerCount(Process),
|
Process, ExitStatus, ObGetObjectPointerCount(Process),
|
||||||
|
@ -267,9 +268,16 @@ PiTerminateProcess(PEPROCESS Process,
|
||||||
ObDereferenceObject(Process);
|
ObDereferenceObject(Process);
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
KeAttachProcess( Process );
|
CurrentProcess = PsGetCurrentProcess();
|
||||||
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
KeAttachProcess( Process );
|
||||||
|
}
|
||||||
ObCloseAllHandles(Process);
|
ObCloseAllHandles(Process);
|
||||||
KeDetachProcess();
|
if (Process != CurrentProcess)
|
||||||
|
{
|
||||||
|
KeDetachProcess();
|
||||||
|
}
|
||||||
OldIrql = KeAcquireDispatcherDatabaseLock ();
|
OldIrql = KeAcquireDispatcherDatabaseLock ();
|
||||||
Process->Pcb.DispatcherHeader.SignalState = TRUE;
|
Process->Pcb.DispatcherHeader.SignalState = TRUE;
|
||||||
KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
|
KeDispatcherObjectWake(&Process->Pcb.DispatcherHeader);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.139 2004/08/15 16:39:10 chorns Exp $
|
/* $Id: process.c,v 1.140 2004/08/31 20:17:18 hbirr Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -387,7 +387,13 @@ PiDeleteProcess(PVOID ObjectBody)
|
||||||
|
|
||||||
Context.Process = (PEPROCESS)ObjectBody;
|
Context.Process = (PEPROCESS)ObjectBody;
|
||||||
|
|
||||||
if (PsGetCurrentProcess() == Context.Process || PsGetCurrentThread()->OldProcess == NULL)
|
if (PsGetCurrentProcess() == Context.Process ||
|
||||||
|
PsGetCurrentThread()->ThreadsProcess == Context.Process)
|
||||||
|
{
|
||||||
|
KEBUGCHECK(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PsGetCurrentThread()->ThreadsProcess == PsGetCurrentProcess())
|
||||||
{
|
{
|
||||||
Context.IsWorkerQueue = FALSE;
|
Context.IsWorkerQueue = FALSE;
|
||||||
PiDeleteProcessWorker(&Context);
|
PiDeleteProcessWorker(&Context);
|
||||||
|
@ -525,13 +531,13 @@ PEPROCESS STDCALL
|
||||||
IoGetCurrentProcess(VOID)
|
IoGetCurrentProcess(VOID)
|
||||||
{
|
{
|
||||||
if (PsGetCurrentThread() == NULL ||
|
if (PsGetCurrentThread() == NULL ||
|
||||||
PsGetCurrentThread()->ThreadsProcess == NULL)
|
PsGetCurrentThread()->Tcb.ApcState.Process == NULL)
|
||||||
{
|
{
|
||||||
return(PsInitialSystemProcess);
|
return(PsInitialSystemProcess);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return(PsGetCurrentThread()->ThreadsProcess);
|
return(PEPROCESS)(PsGetCurrentThread()->Tcb.ApcState.Process);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue