vdmentry.c
Upload User: caisha3
Upload Date: 2013-09-21
Package Size: 208739k
Code Size: 4k
Category:

Windows Develop

Development Platform:

Visual C++

  1. /*++
  2. Copyright (c) 1991  Microsoft Corporation
  3. Module Name:
  4.     vdmentry.c
  5. Abstract:
  6.     This function dispatches to the vdm services
  7. Author:
  8.     Dave Hastings (daveh) 6-Apr-1992
  9. Notes:
  10.     This module will be fleshed out when the great vdm code consolidation
  11.     occurs, sometime soon after the functionality is done.
  12. Revision History:
  13.      24-Sep-1993 Jonle: reoptimize dispatcher to suit the number of services
  14.                         add QueueInterrupt service
  15. --*/
  16. #include "vdmp.h"
  17. #include <ntvdmp.h>
  18. #ifdef ALLOC_PRAGMA
  19. #pragma alloc_text(PAGE, NtVdmControl)
  20. #endif
  21. #if DBG
  22. void AssertIrqlPassive(void)
  23. {
  24. if (KeGetCurrentIrql() > PASSIVE_LEVEL) {
  25.     DbgPrint("NtVdmControl:returning at raised irql!n");
  26.     DbgBreakPoint();
  27.     }
  28. }
  29. #else
  30. #define AssertIrqlPassive()
  31. #endif
  32. NTSTATUS
  33. NtVdmControl(
  34.     IN VDMSERVICECLASS Service,
  35.     IN OUT PVOID ServiceData
  36.     )
  37. /*++
  38. Routine Description:
  39.     386 specific routine which dispatches to the appropriate function
  40.     based on service number.
  41. Arguments:
  42.     Service -- Specifies what service is to be performed
  43.     ServiceData -- Supplies a pointer to service specific data
  44. Return Value:
  45.     if invalid service number: STATUS_INVALID_PARAMETER_1
  46.     else see individual services.
  47. --*/
  48. {
  49.     NTSTATUS Status;
  50.     PAGED_CODE();
  51.     //
  52.     //  Dispatch in descending order of frequency
  53.     //
  54.     if (Service == VdmStartExecution) {
  55.         Status = VdmpStartExecution();
  56.     } else if (Service == VdmQueueInterrupt) {
  57.         Status = VdmpQueueInterrupt(ServiceData);
  58.     } else if (Service == VdmDelayInterrupt) {
  59.         Status = VdmpDelayInterrupt(ServiceData);
  60.     } else if (Service == VdmQueryDir) {
  61.         Status = VdmQueryDirectoryFile(ServiceData);
  62.     } else if (Service == VdmInitialize) {
  63.         Status = VdmpInitialize(ServiceData);
  64.     } else if (Service == VdmFeatures) {
  65.         try {
  66.             //
  67.             // Verify that we were passed a valid user address
  68.             //
  69.             ProbeForWriteBoolean((PBOOLEAN)ServiceData);
  70.             //
  71.             // Return the appropriate feature bits to notify
  72.             // ntvdm which modes (if any) fast IF emulation is
  73.             // available for
  74.             //
  75.             if (KeI386VdmIoplAllowed) {
  76.                 *((PULONG)ServiceData) = V86_VIRTUAL_INT_EXTENSIONS;
  77.             } else {
  78.                 // remove this if pm extensions to be used
  79.                 *((PULONG)ServiceData) = KeI386VirtualIntExtensions &
  80.                     ~PM_VIRTUAL_INT_EXTENSIONS;
  81.             }
  82.         } except(EXCEPTION_EXECUTE_HANDLER) {
  83.                 Status = GetExceptionCode();
  84.         }
  85.         Status = STATUS_SUCCESS;
  86.     } else if (Service == VdmSetInt21Handler) {
  87.         try {
  88.             ProbeForRead(ServiceData, sizeof(VDMSET_INT21_HANDLER_DATA), 1);
  89.             Status = Ke386SetVdmInterruptHandler(
  90.                 KeGetCurrentThread()->ApcState.Process,
  91.                 0x21L,
  92.                 (USHORT)(((PVDMSET_INT21_HANDLER_DATA)ServiceData)->Selector),
  93.                 ((PVDMSET_INT21_HANDLER_DATA)ServiceData)->Offset,
  94.                 ((PVDMSET_INT21_HANDLER_DATA)ServiceData)->Gate32
  95.                 );
  96.         } except(EXCEPTION_EXECUTE_HANDLER) {
  97.             Status = GetExceptionCode();
  98.         }
  99.     } else if (Service == VdmPrinterDirectIoOpen) {
  100.         Status = VdmpPrinterDirectIoOpen(ServiceData);
  101.     } else if (Service == VdmPrinterDirectIoClose) {
  102.         Status = VdmpPrinterDirectIoClose(ServiceData);
  103.     } else if (Service == VdmPrinterInitialize) {
  104.         Status = VdmpPrinterInitialize(ServiceData);
  105.     } else {
  106.         Status = STATUS_INVALID_PARAMETER_1;
  107.     }
  108.     AssertIrqlPassive();
  109.     return Status;
  110. }