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.

137 lines
2.5 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. wow64apc.c
  5. Abstract:
  6. This module implements APC queuing to 32-bit target threads from
  7. native 64-bit threads.
  8. Author:
  9. Samer Arafeh (samera) 9-Oct-2000
  10. Revision History:
  11. --*/
  12. #include <ntos.h>
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <heap.h>
  17. #include <apcompat.h>
  18. #include "ldrp.h"
  19. #if defined(_WIN64)
  20. extern PVOID Wow64ApcRoutine;
  21. #endif
  22. #if defined(_WIN64)
  23. VOID
  24. RtlpWow64Apc(
  25. IN PVOID Argument1,
  26. IN PVOID Argument2,
  27. IN PVOID Argument3
  28. )
  29. /*++
  30. Routine Description:
  31. This function is called as a result of firing a usermode APC that's targeted to
  32. a thread running inside Wow64.
  33. Arguments:
  34. ApcArgument1 - The 1st argument of the APC. This includes both the 32-bit APC and
  35. the original 1st argument.
  36. ApcArgument2 - The second argument of the APC
  37. ApcArgument3 - The third argument of the APC
  38. Return Value:
  39. None
  40. --*/
  41. {
  42. if (Wow64ApcRoutine)
  43. {
  44. (*(PPS_APC_ROUTINE) Wow64ApcRoutine) (
  45. Argument1,
  46. Argument2,
  47. Argument3);
  48. }
  49. }
  50. #endif
  51. NTSTATUS
  52. RtlQueueApcWow64Thread(
  53. IN HANDLE ThreadHandle,
  54. IN PPS_APC_ROUTINE ApcRoutine,
  55. IN PVOID ApcArgument1,
  56. IN PVOID ApcArgument2,
  57. IN PVOID ApcArgument3
  58. )
  59. /*++
  60. Routine Description:
  61. This function is used to queue a 32-bit user-mode APC to the specified thread. The APC
  62. will fire when the specified thread does an alertable wait.
  63. Note: This function is only used by 64-bit components that want to queue an APC to
  64. a thread running inside Wow64.
  65. Arguments:
  66. ThreadHandle - Supplies a handle to a thread object. The caller
  67. must have THREAD_SET_CONTEXT access to the thread.
  68. ApcRoutine - Supplies the address of the APC routine to execute when the
  69. APC fires.
  70. ApcArgument1 - Supplies the first PVOID passed to the APC
  71. ApcArgument2 - Supplies the second PVOID passed to the APC
  72. ApcArgument3 - Supplies the third PVOID passed to the APC
  73. Return Value:
  74. Returns an NT Status code indicating success or failure of the API
  75. --*/
  76. {
  77. #if defined(_WIN64)
  78. //
  79. // Setup the jacket routine inside ntdll
  80. //
  81. ApcArgument1 = (PVOID)((ULONG_PTR) ApcArgument1 |
  82. ((ULONG_PTR) ApcRoutine << 32 ));
  83. ApcRoutine = RtlpWow64Apc;
  84. #endif
  85. return NtQueueApcThread (
  86. ThreadHandle,
  87. ApcRoutine,
  88. ApcArgument1,
  89. ApcArgument2,
  90. ApcArgument3);
  91. }