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.

156 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1998-2000 Microsoft Corporation
  3. Module Name:
  4. bintrans.h
  5. Abstract:
  6. Header for calling bintrans.dll if it exists
  7. Author:
  8. 22-Aug-2000 v-cspira (charles spirakis)
  9. --*/
  10. #ifndef _BINTRANS_INCLUDE
  11. #define _BINTRANS_INCLUDE
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. //
  16. // Create the typedefs for the functions we can import from the bintrans
  17. // dll. These functions are duplicates of the wow64cpu export list for both
  18. // what they do and te parameters they take. Any changes to the wow64cpu
  19. // list should also update these typedefs
  20. //
  21. //
  22. // Cache manipulation functions and Dll notification
  23. //
  24. typedef VOID (*PFNCPUFLUSHINSTRUCTIONCACHE)( PVOID BaseAddress, ULONG Length );
  25. typedef VOID (*PFNCPUNOTIFYDLLLOAD)( LPWSTR DllName, PVOID DllBase, ULONG DllSize );
  26. typedef VOID (*PFNCPUNOTIFYDLLUNLOAD)( PVOID DllBase );
  27. //
  28. // Init and term APIs
  29. //
  30. typedef NTSTATUS (*PFNCPUPROCESSINIT)(PWSTR pImageName, PSIZE_T pCpuThreadDataSize);
  31. typedef NTSTATUS (*PFNCPUPROCESSTERM)(HANDLE ProcessHandle);
  32. typedef NTSTATUS (*PFNCPUTHREADINIT)(PVOID pPerThreadData);
  33. typedef NTSTATUS (*PFNCPUTHREADTERM)(VOID);
  34. //
  35. // Execution
  36. //
  37. typedef VOID (*PFNCPUSIMULATE)(VOID);
  38. //
  39. // Exception handling, context manipulation
  40. //
  41. typedef VOID (*PFNCPURESETTOCONSISTENTSTATE)(PEXCEPTION_POINTERS pExecptionPointers);
  42. typedef ULONG (*PFNCPUGETSTACKPOINTER)(VOID);
  43. typedef VOID (*PFNCPUSETSTACKPOINTER)(ULONG Value);
  44. typedef VOID (*PFNCPUSETINSTRUCTIONPOINTER)(ULONG Value);
  45. typedef VOID (*PFNCPUSETFLOATINGPOINT)(VOID);
  46. typedef NTSTATUS (*PFNCPUSUSPENDTHREAD)( IN HANDLE ThreadHandle, IN HANDLE ProcessHandle, IN PTEB Teb, OUT PULONG PreviousSuspendCount OPTIONAL);
  47. typedef NTSTATUS (*PFNCPUGETCONTEXT)( IN HANDLE ThreadHandle, IN HANDLE ProcessHandle, IN PTEB Teb, OUT PCONTEXT32 Context);
  48. typedef NTSTATUS (*PFNCPUSETCONTEXT)( IN HANDLE ThreadHandle, IN HANDLE ProcessHandle, IN PTEB Teb, PCONTEXT32 Context);
  49. //
  50. // Need the entry point names as well
  51. // This is what needs to be exported from the binary translation dll
  52. // The LdrGetProcedureAddress() uses Ansi, so these are ansi too
  53. //
  54. // NOTE: the order of these strings must match the order
  55. // of the corresponding functions in the _bintrans structure below
  56. //
  57. PUCHAR BtImportList[] = {
  58. "BTCpuProcessInit",
  59. "BTCpuProcessTerm",
  60. "BTCpuThreadInit",
  61. "BTCpuThreadTerm",
  62. "BTCpuSimulate",
  63. "BTCpuGetStackPointer",
  64. "BTCpuSetStackPointer",
  65. "BTCpuSetInstructionPointer",
  66. "BTCpuResetFloatingPoint",
  67. "BTCpuSuspendThread",
  68. "BTCpuGetContext",
  69. "BTCpuSetContext",
  70. "BTCpuResetToConsistentState",
  71. "BTCpuFlushInstructionCache",
  72. "BTCpuNotifyDllLoad",
  73. "BTCpuNotifyDllUnload"
  74. };
  75. //
  76. // NOTE: The order of entries in this structure MUST match the
  77. // order of entries listed above. This structure gets cast
  78. // into a PVOID struction to be filled in and we iterate though the
  79. // names above to do it...
  80. //
  81. typedef struct _bintrans {
  82. PFNCPUPROCESSINIT BtProcessInit;
  83. PFNCPUPROCESSTERM BtProcessTerm;
  84. PFNCPUTHREADINIT BtThreadInit;
  85. PFNCPUTHREADTERM BtThreadTerm;
  86. PFNCPUSIMULATE BtSimulate;
  87. PFNCPUGETSTACKPOINTER BtGetStack;
  88. PFNCPUSETSTACKPOINTER BtSetStack;
  89. PFNCPUSETINSTRUCTIONPOINTER BtSetEip;
  90. PFNCPUSETFLOATINGPOINT BtResetFP;
  91. PFNCPUSUSPENDTHREAD BtSuspend;
  92. PFNCPUGETCONTEXT BtGetContext;
  93. PFNCPUSETCONTEXT BtSetContext;
  94. PFNCPURESETTOCONSISTENTSTATE BtReset;
  95. PFNCPUFLUSHINSTRUCTIONCACHE BtFlush;
  96. PFNCPUNOTIFYDLLLOAD BtDllLoad;
  97. PFNCPUNOTIFYDLLUNLOAD BtDllUnload;
  98. } BINTRANS;
  99. //
  100. // The binary translator is enabled by a key in the registry
  101. // The key is in HKLM, and there are subkeys for enabling (1)
  102. //
  103. // No subkey area and/or no enable key means don't use the binary translator.
  104. //
  105. // The path must be specified and is used to load the dll. Thus, the dll can
  106. // actually have any name as long as the path is right and the export list
  107. // is correct.
  108. //
  109. // Individual apps can be listed here with a DWORD subkey. A
  110. // value of 1 says use btrans, and a value of 0 says don't. No value says
  111. // use the global enable/disable to decide
  112. //
  113. //
  114. //
  115. #define BTKEY_SUBKEY L"Software\\Microsoft\\Wow64\\Bintrans"
  116. #define BTKEY_MACHINE_SUBKEY L"\\Registry\\Machine\\Software\\Microsoft\\Wow64\\Bintrans"
  117. #define BTKEY_ENABLE L"Enable"
  118. #define BTKEY_PATH L"Path"
  119. #ifdef __cplusplus
  120. }
  121. #endif
  122. #endif //_BINTRANS_INCLUDE