mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 17:44:45 +00:00
Use KeStackAttachProcess/KeUnstackDetachProcess instead of KeAttachProcess/KeDetachProcess.
svn path=/trunk/; revision=15915
This commit is contained in:
parent
56f5461bff
commit
a6b2363ea0
3 changed files with 32 additions and 44 deletions
|
@ -36,11 +36,11 @@ IntInt10AllocateBuffer(
|
||||||
PVOID MemoryAddress;
|
PVOID MemoryAddress;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKPROCESS CallingProcess;
|
PKPROCESS CallingProcess;
|
||||||
PKPROCESS PrevAttachedProcess;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
DPRINT("IntInt10AllocateBuffer\n");
|
DPRINT("IntInt10AllocateBuffer\n");
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
MemoryAddress = (PVOID)0x20000;
|
MemoryAddress = (PVOID)0x20000;
|
||||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
|
Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
|
||||||
|
@ -49,7 +49,7 @@ IntInt10AllocateBuffer(
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT("- ZwAllocateVirtualMemory failed\n");
|
DPRINT("- ZwAllocateVirtualMemory failed\n");
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ IntInt10AllocateBuffer(
|
||||||
ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, Length,
|
ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, Length,
|
||||||
MEM_RELEASE);
|
MEM_RELEASE);
|
||||||
DPRINT("- Unacceptable memory allocated\n");
|
DPRINT("- Unacceptable memory allocated\n");
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
return ERROR_NOT_ENOUGH_MEMORY;
|
return ERROR_NOT_ENOUGH_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ IntInt10AllocateBuffer(
|
||||||
DPRINT("- Offset: %x\n", (ULONG)MemoryAddress & 0xF);
|
DPRINT("- Offset: %x\n", (ULONG)MemoryAddress & 0xF);
|
||||||
DPRINT("- Length: %x\n", *Length);
|
DPRINT("- Length: %x\n", *Length);
|
||||||
|
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -83,16 +83,16 @@ IntInt10FreeBuffer(
|
||||||
PVOID MemoryAddress = (PVOID)((Seg << 4) | Off);
|
PVOID MemoryAddress = (PVOID)((Seg << 4) | Off);
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKPROCESS CallingProcess;
|
PKPROCESS CallingProcess;
|
||||||
PKPROCESS PrevAttachedProcess;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
DPRINT("IntInt10FreeBuffer\n");
|
DPRINT("IntInt10FreeBuffer\n");
|
||||||
DPRINT("- Segment: %x\n", Seg);
|
DPRINT("- Segment: %x\n", Seg);
|
||||||
DPRINT("- Offset: %x\n", Off);
|
DPRINT("- Offset: %x\n", Off);
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
Status = ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
|
Status = ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
|
||||||
MEM_RELEASE);
|
MEM_RELEASE);
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ IntInt10ReadMemory(
|
||||||
IN ULONG Length)
|
IN ULONG Length)
|
||||||
{
|
{
|
||||||
PKPROCESS CallingProcess;
|
PKPROCESS CallingProcess;
|
||||||
PKPROCESS PrevAttachedProcess;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
DPRINT("IntInt10ReadMemory\n");
|
DPRINT("IntInt10ReadMemory\n");
|
||||||
DPRINT("- Segment: %x\n", Seg);
|
DPRINT("- Segment: %x\n", Seg);
|
||||||
|
@ -114,9 +114,9 @@ IntInt10ReadMemory(
|
||||||
DPRINT("- Buffer: %x\n", Buffer);
|
DPRINT("- Buffer: %x\n", Buffer);
|
||||||
DPRINT("- Length: %x\n", Length);
|
DPRINT("- Length: %x\n", Length);
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
RtlCopyMemory(Buffer, (PVOID)((Seg << 4) | Off), Length);
|
RtlCopyMemory(Buffer, (PVOID)((Seg << 4) | Off), Length);
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ IntInt10WriteMemory(
|
||||||
IN ULONG Length)
|
IN ULONG Length)
|
||||||
{
|
{
|
||||||
PKPROCESS CallingProcess;
|
PKPROCESS CallingProcess;
|
||||||
PKPROCESS PrevAttachedProcess;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
DPRINT("IntInt10WriteMemory\n");
|
DPRINT("IntInt10WriteMemory\n");
|
||||||
DPRINT("- Segment: %x\n", Seg);
|
DPRINT("- Segment: %x\n", Seg);
|
||||||
|
@ -138,9 +138,9 @@ IntInt10WriteMemory(
|
||||||
DPRINT("- Buffer: %x\n", Buffer);
|
DPRINT("- Buffer: %x\n", Buffer);
|
||||||
DPRINT("- Length: %x\n", Length);
|
DPRINT("- Length: %x\n", Length);
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
RtlCopyMemory((PVOID)((Seg << 4) | Off), Buffer, Length);
|
RtlCopyMemory((PVOID)((Seg << 4) | Off), Buffer, Length);
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -153,11 +153,11 @@ IntInt10CallBios(
|
||||||
KV86M_REGISTERS Regs;
|
KV86M_REGISTERS Regs;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKPROCESS CallingProcess;
|
PKPROCESS CallingProcess;
|
||||||
PKPROCESS PrevAttachedProcess;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
DPRINT("IntInt10CallBios\n");
|
DPRINT("IntInt10CallBios\n");
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
memset(&Regs, 0, sizeof(Regs));
|
memset(&Regs, 0, sizeof(Regs));
|
||||||
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
|
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
|
||||||
|
@ -189,7 +189,7 @@ IntInt10CallBios(
|
||||||
BiosArguments->SegDs = Regs.Ds;
|
BiosArguments->SegDs = Regs.Ds;
|
||||||
BiosArguments->SegEs = Regs.Es;
|
BiosArguments->SegEs = Regs.Es;
|
||||||
|
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +208,7 @@ VideoPortInt10(
|
||||||
KV86M_REGISTERS Regs;
|
KV86M_REGISTERS Regs;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PKPROCESS CallingProcess;
|
PKPROCESS CallingProcess;
|
||||||
PKPROCESS PrevAttachedProcess;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
DPRINT("VideoPortInt10\n");
|
DPRINT("VideoPortInt10\n");
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ VideoPortInt10(
|
||||||
return ERROR_INVALID_PARAMETER;
|
return ERROR_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
memset(&Regs, 0, sizeof(Regs));
|
memset(&Regs, 0, sizeof(Regs));
|
||||||
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
|
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
|
||||||
|
@ -243,7 +243,7 @@ VideoPortInt10(
|
||||||
BiosArguments->Edi = Regs.Edi;
|
BiosArguments->Edi = Regs.Edi;
|
||||||
BiosArguments->Ebp = Regs.Ebp;
|
BiosArguments->Ebp = Regs.Ebp;
|
||||||
|
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "videoprt.h"
|
#include "videoprt.h"
|
||||||
#include "internal/ps.h"
|
|
||||||
|
|
||||||
/* GLOBAL VARIABLES ***********************************************************/
|
/* GLOBAL VARIABLES ***********************************************************/
|
||||||
|
|
||||||
|
@ -495,34 +494,21 @@ IntVideoPortFindAdapter(
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID FASTCALL
|
VOID FASTCALL
|
||||||
IntAttachToCSRSS(PKPROCESS *CallingProcess, PKPROCESS *PrevAttachedProcess)
|
IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
|
||||||
{
|
{
|
||||||
*CallingProcess = &PsGetCurrentProcess()->Pcb;
|
*CallingProcess = (PKPROCESS)PsGetCurrentProcess();
|
||||||
if (*CallingProcess != Csrss)
|
if (*CallingProcess != Csrss)
|
||||||
{
|
{
|
||||||
if (&PsGetCurrentThread()->ThreadsProcess->Pcb != *CallingProcess)
|
KeStackAttachProcess(Csrss, ApcState);
|
||||||
{
|
|
||||||
*PrevAttachedProcess = *CallingProcess;
|
|
||||||
KeDetachProcess();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
*PrevAttachedProcess = NULL;
|
|
||||||
}
|
|
||||||
KeAttachProcess(Csrss);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID FASTCALL
|
VOID FASTCALL
|
||||||
IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKPROCESS *PrevAttachedProcess)
|
IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
|
||||||
{
|
{
|
||||||
if (*CallingProcess != Csrss)
|
if (*CallingProcess != Csrss)
|
||||||
{
|
{
|
||||||
KeDetachProcess();
|
KeUnstackDetachProcess(ApcState);
|
||||||
if (NULL != *PrevAttachedProcess)
|
|
||||||
{
|
|
||||||
KeAttachProcess(*PrevAttachedProcess);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,7 +839,7 @@ VideoPortGetRomImage(
|
||||||
{
|
{
|
||||||
static PVOID RomImageBuffer = NULL;
|
static PVOID RomImageBuffer = NULL;
|
||||||
PKPROCESS CallingProcess;
|
PKPROCESS CallingProcess;
|
||||||
PKPROCESS PrevAttachedProcess;
|
KAPC_STATE ApcState;
|
||||||
|
|
||||||
DPRINT("VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
|
DPRINT("VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
|
||||||
HwDeviceExtension, Length);
|
HwDeviceExtension, Length);
|
||||||
|
@ -890,9 +876,9 @@ VideoPortGetRomImage(
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntAttachToCSRSS(&CallingProcess, &ApcState);
|
||||||
RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
|
RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
|
||||||
IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
|
IntDetachFromCSRSS(&CallingProcess, &ApcState);
|
||||||
|
|
||||||
return RomImageBuffer;
|
return RomImageBuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,8 @@
|
||||||
#include <ddk/ntddvdeo.h>
|
#include <ddk/ntddvdeo.h>
|
||||||
#include <ddk/ntapi.h>
|
#include <ddk/ntapi.h>
|
||||||
#include <ddk/ntagp.h>
|
#include <ddk/ntagp.h>
|
||||||
|
/* For process attaching functions */
|
||||||
|
#include <ddk/ntifs.h>
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
@ -201,10 +203,10 @@ VideoPortGetProcAddress(
|
||||||
IN PUCHAR FunctionName);
|
IN PUCHAR FunctionName);
|
||||||
|
|
||||||
VOID FASTCALL
|
VOID FASTCALL
|
||||||
IntAttachToCSRSS(PKPROCESS *CallingProcess, PKPROCESS *PrevAttachedProcess);
|
IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
|
||||||
|
|
||||||
VOID FASTCALL
|
VOID FASTCALL
|
||||||
IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKPROCESS *PrevAttachedProcess);
|
IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState);
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
IntVideoPortCreateAdapterDeviceObject(
|
IntVideoPortCreateAdapterDeviceObject(
|
||||||
|
|
Loading…
Reference in a new issue