Leaked source code of windows server 2003
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.

116 lines
2.4 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. w64misc.c
  5. Abstract:
  6. Miscallaneous Wow64 routines.
  7. Author:
  8. Samer Arafeh (samera) 12-Dec-2002
  9. Revision History:
  10. --*/
  11. #include "ldrp.h"
  12. #include <ntos.h>
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <wow64t.h>
  17. NTSTATUS
  18. RtlpWow64EnableFsRedirection (
  19. IN BOOLEAN Wow64FsEnableRedirection
  20. )
  21. /*++
  22. Routine Description:
  23. This function enables/disables Wow64 file system redirection.
  24. Wow64 redirects all accesses to %windir%\system32 to %windir%\syswow64.
  25. This API is useful for 32-bit applications which want to gain access to the
  26. native system32 directory. By default, Wow64 file system redirection is enabled.
  27. File redirection is only affected for the thread calling this API.
  28. Note : You must enable file system redirection after disabling it. Once you have
  29. a file handle, you must enable file system redirection back.
  30. Example:
  31. NTSTATUS Status = RtlpWow64EnableFsRedirection (FALSE);
  32. if (NT_SUCCESS (Status)) {
  33. //
  34. // Open the file handle
  35. //
  36. CreateFile (..."c:\\windows\\system32\\notepad.exe"...)
  37. //
  38. // Enable Wow64 file system redirection.
  39. //
  40. RtlpWow64EnableFsRedirection (TRUE);
  41. }
  42. //
  43. // Use the file handle
  44. //
  45. Arguments:
  46. Wow64FsEnableRedirection - Boolean to indicate whether to enable Wow64 file system
  47. redirection. Specify FALSE if you want to disable Wow64 file system redirection,
  48. otherwise TRUE to enable it.
  49. Return Value:
  50. NTSTATUS.
  51. --*/
  52. {
  53. #if !defined(BUILD_WOW6432)
  54. UNREFERENCED_PARAMETER (Wow64FsEnableRedirection);
  55. //
  56. // If this is not a wow64 process, then this is api is not supported.
  57. //
  58. return STATUS_NOT_IMPLEMENTED;
  59. #else
  60. NTSTATUS NtStatus;
  61. NtStatus = STATUS_SUCCESS;
  62. try {
  63. if (Wow64FsEnableRedirection == FALSE) {
  64. Wow64SetFilesystemRedirectorEx (WOW64_FILE_SYSTEM_DISABLE_REDIRECT);
  65. } else {
  66. Wow64SetFilesystemRedirectorEx (WOW64_FILE_SYSTEM_ENABLE_REDIRECT);
  67. }
  68. } except (EXCEPTION_EXECUTE_HANDLER) {
  69. NtStatus = GetExceptionCode ();
  70. }
  71. return NtStatus;
  72. #endif
  73. }