PVOID MemoryAddress;
NTSTATUS Status;
PKPROCESS CallingProcess;
- PKPROCESS PrevAttachedProcess;
+ KAPC_STATE ApcState;
DPRINT("IntInt10AllocateBuffer\n");
- IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntAttachToCSRSS(&CallingProcess, &ApcState);
MemoryAddress = (PVOID)0x20000;
Status = ZwAllocateVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
if (!NT_SUCCESS(Status))
{
DPRINT("- ZwAllocateVirtualMemory failed\n");
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return ERROR_NOT_ENOUGH_MEMORY;
}
ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, Length,
MEM_RELEASE);
DPRINT("- Unacceptable memory allocated\n");
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return ERROR_NOT_ENOUGH_MEMORY;
}
DPRINT("- Offset: %x\n", (ULONG)MemoryAddress & 0xF);
DPRINT("- Length: %x\n", *Length);
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return NO_ERROR;
}
PVOID MemoryAddress = (PVOID)((Seg << 4) | Off);
NTSTATUS Status;
PKPROCESS CallingProcess;
- PKPROCESS PrevAttachedProcess;
+ KAPC_STATE ApcState;
DPRINT("IntInt10FreeBuffer\n");
DPRINT("- Segment: %x\n", Seg);
DPRINT("- Offset: %x\n", Off);
- IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntAttachToCSRSS(&CallingProcess, &ApcState);
Status = ZwFreeVirtualMemory(NtCurrentProcess(), &MemoryAddress, 0,
MEM_RELEASE);
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return Status;
}
IN ULONG Length)
{
PKPROCESS CallingProcess;
- PKPROCESS PrevAttachedProcess;
+ KAPC_STATE ApcState;
DPRINT("IntInt10ReadMemory\n");
DPRINT("- Segment: %x\n", Seg);
DPRINT("- Buffer: %x\n", Buffer);
DPRINT("- Length: %x\n", Length);
- IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntAttachToCSRSS(&CallingProcess, &ApcState);
RtlCopyMemory(Buffer, (PVOID)((Seg << 4) | Off), Length);
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return NO_ERROR;
}
IN ULONG Length)
{
PKPROCESS CallingProcess;
- PKPROCESS PrevAttachedProcess;
+ KAPC_STATE ApcState;
DPRINT("IntInt10WriteMemory\n");
DPRINT("- Segment: %x\n", Seg);
DPRINT("- Buffer: %x\n", Buffer);
DPRINT("- Length: %x\n", Length);
- IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntAttachToCSRSS(&CallingProcess, &ApcState);
RtlCopyMemory((PVOID)((Seg << 4) | Off), Buffer, Length);
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return NO_ERROR;
}
KV86M_REGISTERS Regs;
NTSTATUS Status;
PKPROCESS CallingProcess;
- PKPROCESS PrevAttachedProcess;
+ KAPC_STATE ApcState;
DPRINT("IntInt10CallBios\n");
- IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntAttachToCSRSS(&CallingProcess, &ApcState);
memset(&Regs, 0, sizeof(Regs));
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
BiosArguments->SegDs = Regs.Ds;
BiosArguments->SegEs = Regs.Es;
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return Status;
}
KV86M_REGISTERS Regs;
NTSTATUS Status;
PKPROCESS CallingProcess;
- PKPROCESS PrevAttachedProcess;
+ KAPC_STATE ApcState;
DPRINT("VideoPortInt10\n");
return ERROR_INVALID_PARAMETER;
}
- IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntAttachToCSRSS(&CallingProcess, &ApcState);
memset(&Regs, 0, sizeof(Regs));
DPRINT("- Input register Eax: %x\n", BiosArguments->Eax);
BiosArguments->Edi = Regs.Edi;
BiosArguments->Ebp = Regs.Ebp;
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return Status;
}
*/
#include "videoprt.h"
-#include "internal/ps.h"
/* GLOBAL VARIABLES ***********************************************************/
}
VOID FASTCALL
-IntAttachToCSRSS(PKPROCESS *CallingProcess, PKPROCESS *PrevAttachedProcess)
+IntAttachToCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
{
- *CallingProcess = &PsGetCurrentProcess()->Pcb;
+ *CallingProcess = (PKPROCESS)PsGetCurrentProcess();
if (*CallingProcess != Csrss)
{
- if (&PsGetCurrentThread()->ThreadsProcess->Pcb != *CallingProcess)
- {
- *PrevAttachedProcess = *CallingProcess;
- KeDetachProcess();
- }
- else
- {
- *PrevAttachedProcess = NULL;
- }
- KeAttachProcess(Csrss);
+ KeStackAttachProcess(Csrss, ApcState);
}
}
VOID FASTCALL
-IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKPROCESS *PrevAttachedProcess)
+IntDetachFromCSRSS(PKPROCESS *CallingProcess, PKAPC_STATE ApcState)
{
if (*CallingProcess != Csrss)
{
- KeDetachProcess();
- if (NULL != *PrevAttachedProcess)
- {
- KeAttachProcess(*PrevAttachedProcess);
- }
+ KeUnstackDetachProcess(ApcState);
}
}
{
static PVOID RomImageBuffer = NULL;
PKPROCESS CallingProcess;
- PKPROCESS PrevAttachedProcess;
+ KAPC_STATE ApcState;
DPRINT("VideoPortGetRomImage(HwDeviceExtension 0x%X Length 0x%X)\n",
HwDeviceExtension, Length);
return NULL;
}
- IntAttachToCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntAttachToCSRSS(&CallingProcess, &ApcState);
RtlCopyMemory(RomImageBuffer, (PUCHAR)0xC0000, Length);
- IntDetachFromCSRSS(&CallingProcess, &PrevAttachedProcess);
+ IntDetachFromCSRSS(&CallingProcess, &ApcState);
return RomImageBuffer;
}