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.2 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1995 - 1999
  3. All rights reserved.
  4. Module Name:
  5. wow64.h
  6. Abstract:
  7. printui wow64 related functions.
  8. Author:
  9. Lazar Ivanov (LazarI) 10-Mar-2000
  10. Revision History:
  11. --*/
  12. #include <nt.h>
  13. #include <ntrtl.h>
  14. #include <nturtl.h>
  15. #include <windows.h>
  16. #include <tchar.h>
  17. #include "wow64.h"
  18. #define ARRAYSIZE(x) (sizeof(x)/sizeof(x[0]))
  19. //
  20. // Win64 APIs, types and data structures.
  21. //
  22. ClientVersion
  23. OSEnv_GetClientVer(
  24. VOID
  25. )
  26. {
  27. return(sizeof(ULONG_PTR));
  28. }
  29. ServerVersion
  30. OSEnv_GetServerVer(
  31. VOID
  32. )
  33. {
  34. ULONG_PTR ul;
  35. NTSTATUS st;
  36. ServerVersion serverVersion;
  37. st = NtQueryInformationProcess(NtCurrentProcess(),
  38. ProcessWow64Information, &ul, sizeof(ul), NULL);
  39. if( NT_SUCCESS(st) )
  40. {
  41. // If this call succeeds, we're on Win2000 or newer machines.
  42. if( 0 != ul )
  43. {
  44. // 32-bit code running on Win64
  45. serverVersion = THUNKVERSION;
  46. }
  47. else
  48. {
  49. // 32-bit code running on Win2000 or later 32-bit OS
  50. serverVersion = NATIVEVERSION;
  51. }
  52. }
  53. else
  54. {
  55. serverVersion = NATIVEVERSION;
  56. }
  57. return serverVersion;
  58. }
  59. BOOL
  60. IsRunningWOW64(
  61. VOID
  62. )
  63. {
  64. // return !IsRunningInSPLWOW();
  65. return (RUN32BINVER == OSEnv_GetClientVer() &&
  66. THUNKVERSION == OSEnv_GetServerVer());
  67. }
  68. PlatformType
  69. GetCurrentPlatform(
  70. VOID
  71. )
  72. {
  73. if (RUN64BINVER == OSEnv_GetClientVer())
  74. {
  75. // this is a native 64bit process - i.e. the platform is IA64
  76. return kPlatform_IA64;
  77. }
  78. else
  79. {
  80. // this is 32 bit process. it can be either native - i.e. the platform is i386 -
  81. // or wow64 - i.e. the platform is again IA64.
  82. if (THUNKVERSION == OSEnv_GetServerVer())
  83. {
  84. // the process is wow64 - the platform is IA64
  85. return kPlatform_IA64;
  86. }
  87. else
  88. {
  89. // the process is native - i.e. the platform is x86
  90. return kPlatform_x86;
  91. }
  92. }
  93. }