Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
1.9 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. vdmfault.c
  5. Abstract:
  6. This module contains the support for dispatching VDM page faults.
  7. Author:
  8. Sudeep Bharati (sudeepb) 30-Aug-1992
  9. Revision History:
  10. --*/
  11. #include "vdmp.h"
  12. BOOLEAN
  13. VdmDispatchPageFault(
  14. PKTRAP_FRAME TrapFrame,
  15. ULONG Mode,
  16. ULONG FaultAddr
  17. );
  18. #ifdef ALLOC_PRAGMA
  19. #pragma alloc_text(PAGE, VdmDispatchPageFault)
  20. #endif
  21. BOOLEAN
  22. VdmDispatchPageFault(
  23. PKTRAP_FRAME TrapFrame,
  24. ULONG Mode,
  25. ULONG FaultAddr
  26. )
  27. /*++
  28. Routine Description:
  29. This routine dispatches a v86 mode page fault to the VDM monitor.
  30. It verifies that the fault occurred below 1MB.
  31. Arguments:
  32. TrapFrame
  33. Mode - 0 - if read
  34. 1 - if write
  35. FaultAddr - faulting address
  36. Return Value:
  37. True if successful, False otherwise
  38. --*/
  39. {
  40. PVDM_TIB VdmTib;
  41. NTSTATUS Status;
  42. KIRQL OldIrql;
  43. PAGED_CODE();
  44. Status = VdmpGetVdmTib (&VdmTib);
  45. if (!NT_SUCCESS(Status)) {
  46. return FALSE;
  47. }
  48. KeRaiseIrql(APC_LEVEL, &OldIrql);
  49. //
  50. // VdmTib is in user mode memory
  51. //
  52. if ((TrapFrame->EFlags & EFLAGS_V86_MASK) ||
  53. (TrapFrame->SegCs != (KGDT_R3_CODE | RPL_MASK))) {
  54. //
  55. // If the faulting address is above 1MB return failure.
  56. //
  57. if (FaultAddr < 0x100000) {
  58. try {
  59. VdmTib->EventInfo.Event = VdmMemAccess;
  60. VdmTib->EventInfo.InstructionSize = 0;
  61. VdmTib->EventInfo.FaultInfo.FaultAddr = FaultAddr;
  62. VdmTib->EventInfo.FaultInfo.RWMode = Mode;
  63. VdmEndExecution(TrapFrame, VdmTib);
  64. } except(EXCEPTION_EXECUTE_HANDLER) {
  65. Status = GetExceptionCode();
  66. }
  67. }
  68. else {
  69. Status = STATUS_ILLEGAL_INSTRUCTION;
  70. }
  71. }
  72. KeLowerIrql (OldIrql);
  73. if (!NT_SUCCESS(Status)) {
  74. return FALSE;
  75. }
  76. return TRUE;
  77. }