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.

189 lines
3.3 KiB

  1. /*++
  2. Copyright (c) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. wowprxy.c
  5. Abstract:
  6. This module implements pxoxy interfaces not inplemented yet.
  7. Author:
  8. 24-Aug-1999 askhalid
  9. Revision History:
  10. 29-Jan-2000 SamerA Added CpupDoInterrupt and CpupRaiseException
  11. --*/
  12. #include <nt.h>
  13. #include <ntrtl.h>
  14. #include <nturtl.h>
  15. #include <windows.h>
  16. #include <stdio.h>
  17. #include <errno.h>
  18. #define _WOW64CPUAPI_
  19. #define _WX86CPUAPI_
  20. #include "wx86.h"
  21. #include "wx86nt.h"
  22. #include "wx86cpu.h"
  23. #include "cpuassrt.h"
  24. #include "config.h"
  25. #include "entrypt.h"
  26. #include "instr.h"
  27. #include "compiler.h"
  28. ASSERTNAME;
  29. PVOID _HUGE;
  30. CONFIGVAR CpuConfigData;
  31. NTSTATUS
  32. CpupDoInterrupt(
  33. IN DWORD InterruptNumber)
  34. /*++
  35. Routine Description:
  36. This routine simulates an x86 software interrupt.
  37. Arguments:
  38. InterruptNumber - Interrupt number to simulate
  39. Return Value:
  40. NTSTATUS
  41. --*/
  42. {
  43. return Wow64RaiseException(InterruptNumber, NULL);
  44. }
  45. NTSTATUS
  46. CpupRaiseException(
  47. IN PEXCEPTION_RECORD ExceptionRecord)
  48. {
  49. return Wow64RaiseException(-1L, ExceptionRecord);
  50. }
  51. PCONFIGVAR
  52. Wx86FetchConfigVar(
  53. PWSTR VariableName
  54. )
  55. {
  56. return NULL;
  57. }
  58. VOID
  59. Wx86FreeConfigVar(
  60. PCONFIGVAR ConfigVar
  61. )
  62. {
  63. }
  64. VOID
  65. Wx86RaiseStatus(
  66. NTSTATUS Status
  67. )
  68. {
  69. EXCEPTION_RECORD ExRec;
  70. DECLARE_CPU;
  71. ExRec.ExceptionCode = Status;
  72. ExRec.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
  73. ExRec.ExceptionRecord = NULL;
  74. ExRec.ExceptionAddress = (PVOID)cpu->eipReg.i4;
  75. ExRec.NumberParameters = 0;
  76. CpupRaiseException(&ExRec);
  77. }
  78. void
  79. Wx86DispatchBop(
  80. PBOPINSTR Bop
  81. )
  82. {
  83. CONTEXT32 Context;
  84. DECLARE_CPU;
  85. Context.ContextFlags = CONTEXT_CONTROL_WX86|CONTEXT_INTEGER_WX86;
  86. MsCpuGetContext(&Context);
  87. cpu->Eax.i4=Wow64SystemService(cpu->Eax.i4,
  88. &Context);
  89. }
  90. BOOL
  91. ProxyIsProcessorFeaturePresent (
  92. DWORD ProcessorFeature
  93. )
  94. {
  95. BOOL rv;
  96. if ( ProcessorFeature < PROCESSOR_FEATURE_MAX ) {
  97. rv = (BOOL)(USER_SHARED_DATA->ProcessorFeatures[ProcessorFeature]);
  98. }
  99. else {
  100. rv = FALSE;
  101. }
  102. return rv;
  103. }
  104. VOID ProxyRaiseException(
  105. IN DWORD dwExceptionCode,
  106. IN DWORD dwExceptionFlags,
  107. IN DWORD nNumberOfArguments,
  108. IN CONST ULONG_PTR *lpArguments
  109. )
  110. {
  111. EXCEPTION_RECORD ExceptionRecord;
  112. ULONG n;
  113. PULONG s,d;
  114. ExceptionRecord.ExceptionCode = (DWORD)dwExceptionCode;
  115. ExceptionRecord.ExceptionFlags = dwExceptionFlags & EXCEPTION_NONCONTINUABLE;
  116. ExceptionRecord.ExceptionRecord = NULL;
  117. ExceptionRecord.ExceptionAddress = NULL;
  118. if ( ARGUMENT_PRESENT(lpArguments) ) {
  119. n = nNumberOfArguments;
  120. if ( n > EXCEPTION_MAXIMUM_PARAMETERS ) {
  121. n = EXCEPTION_MAXIMUM_PARAMETERS;
  122. }
  123. ExceptionRecord.NumberParameters = n;
  124. s = (PULONG)lpArguments;
  125. d = (PULONG)ExceptionRecord.ExceptionInformation;
  126. while(n--){
  127. *d++ = *s++;
  128. }
  129. }
  130. else {
  131. ExceptionRecord.NumberParameters = 0;
  132. }
  133. CpupRaiseException(&ExceptionRecord);
  134. }
  135. VOID
  136. SetMathError (
  137. int Code
  138. )
  139. {
  140. int *_errno();
  141. *_errno() = Code;
  142. }