test: vdmfault.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# vdmfault.c File Reference

`#include "vdmp.h"`

Go to the source code of this file.

## Functions

BOOLEAN | VdmDispatchPageFault (PKTRAP_FRAME TrapFrame, ULONG Mode, ULONG FaultAddr)

## Function Documentation

BOOLEAN VdmDispatchPageFault | ( | PKTRAP_FRAME | TrapFrame,
|  | ULONG | Mode,
|  | ULONG | FaultAddr
| ) |

Definition at line 36 of file vdmfault.c.

References APC_LEVEL, _VdmEventInfo::Event, _Vdm_Tib::EventInfo, EXCEPTION_EXECUTE_HANDLER, FALSE, _VdmEventInfo::InstructionSize, KeLowerIrql(), KeRaiseIrql(), NT_SUCCESS, NTSTATUS(), PAGED_CODE, Status, TRUE, VdmEndExecution(), VdmMemAccess, VdmpGetVdmTib(), and VDMTIB_KPROBE.

    00044                    :
    00045
    00046     This routine dispatches a v86 mode page fault to the VDM monitor.
    00047     It verifies that the fault occurred below 1MB.
    00048
    00049
    00050 Arguments:
    00051     TrapFrame
    00052     Mode - 0 - if read
    00053            1 - if write
    00054     FaultAddr - faulting address
    00055
    00056 Return Value:
    00057
    00058     True if successfull, False otherwise
    00059
    00060 --*/
    00061 {
    00062     PVDM_TIB VdmTib;
    00063     NTSTATUS Status = STATUS_SUCCESS;
    00064     KIRQL   OldIrql;
    00065
    00066
    00067     PAGED_CODE();
    00068
    00069     //
    00070     // Raise Irql to APC level...
    00071     //
    00072     KeRaiseIrql(APC_LEVEL, &OldIrql);
    00073
    00074     Status = VdmpGetVdmTib(&VdmTib, VDMTIB_KPROBE);
    00075     if (!NT_SUCCESS(Status)) {
    00076        KeLowerIrql(OldIrql);
    00077        return(FALSE);
    00078     }
    00079
    00080     //
    00081     // VdmTib is in user mode memory
    00082     //
    00083     try {
    00084         //
    00085         // Get a pointer to the VdmTib
    00086         //
    00087  //       VdmTib =
    00088  //        ((PVDM_PROCESS_OBJECTS)(PsGetCurrentProcess()->VdmObjects))->VdmTib;
    00089
    00090         if ((TrapFrame->EFlags & EFLAGS_V86_MASK) ||
    00091             (TrapFrame->SegCs != (KGDT_R3_CODE | RPL_MASK))) {
    00092
    00093             //
    00094             // If the faulting address is above 1MB return failure
    00095             //
    00096             if (FaultAddr < 0x100000) {
    00097                 VdmTib->EventInfo.Event = VdmMemAccess;
    00098                 VdmTib->EventInfo.InstructionSize = 0;
    00099                 VdmTib->EventInfo.FaultInfo.FaultAddr = FaultAddr;
    00100                 VdmTib->EventInfo.FaultInfo.RWMode = Mode;
    00101                 VdmEndExecution(TrapFrame, VdmTib);
    00102             }
    00103             else {
    00104                 Status = STATUS_ILLEGAL_INSTRUCTION;
    00105             }
    00106         }
    00107
    00108     } except(EXCEPTION_EXECUTE_HANDLER) {
    00109         Status = GetExceptionCode();
    00110     }
    00111
    00112     KeLowerIrql(OldIrql);
    00113
    00114     if (!NT_SUCCESS(Status)) {
    00115         return FALSE;
    00116     } else {
    00117         return TRUE;
    00118     }
    00119
    00120 }
    }