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.

88 lines
3.0 KiB

  1. /*
  2. This file is meant only to assist in ensuring offsets in peb and teb
  3. are maintained while editing base\published\pebteb.w.
  4. */
  5. #define _WIN32_WINNT 0x0501
  6. #include <stdio.h>
  7. #include <assert.h>
  8. #include <limits.h>
  9. #include <stddef.h>
  10. #include "nt.h"
  11. #include "ntrtl.h"
  12. #include "wow64t.h"
  13. void Test1()
  14. {
  15. #undef TEB_MEMBER
  16. #define TEB_MEMBER(name) printf("%s %ld %ld\n", #name, (long)FIELD_OFFSET(TEB, name), (long)RTL_FIELD_SIZE(TEB, name));
  17. #ifdef _IA64_
  18. #define TEB_MEMBER_IA64(name) TEB_MEMBER(name)
  19. #else
  20. #define TEB_MEMBER_IA64(name) /* nothing */
  21. #endif
  22. #define TEB TEB
  23. printf("\n\nnative TEB %ld\n\n", (long)sizeof(TEB));
  24. #include "teb.h"
  25. #undef TEB
  26. #undef TEB_MEMBER
  27. #define TEB_MEMBER(name) printf("%s %ld %ld\n", #name, (long)FIELD_OFFSET(TEB32, name), (long)RTL_FIELD_SIZE(TEB32, name));
  28. #undef TEB_MEMBER_IA64
  29. #define TEB_MEMBER_IA64(name) /* nothing */
  30. printf("\n\nTEB32 %ld\n\n", (long)sizeof(TEB32));
  31. #include "teb.h"
  32. #undef TEB_MEMBER
  33. #define TEB_MEMBER(name) printf("%s %ld %ld\n", #name, (long)FIELD_OFFSET(TEB64, name), (long)RTL_FIELD_SIZE(TEB64, name));
  34. #if defined(_X86_)
  35. #undef TEB_MEMBER_IA64
  36. #define TEB_MEMBER_IA64(name) TEB_MEMBER(name)
  37. #endif
  38. #define TEB64 TEB64
  39. printf("\n\nTEB64 %ld\n\n", (long)sizeof(TEB64));
  40. #include "teb.h"
  41. #undef TEB64
  42. #define PEB_MEMBER(name) printf("%s %ld %ld\n", #name, (long)FIELD_OFFSET(PEB, name), (long)RTL_FIELD_SIZE(PEB, name));
  43. #define PEB PEB
  44. printf("\n\nnative PEB %ld\n\n", (long)sizeof(PEB));
  45. #include "peb.h"
  46. #undef PEB
  47. #undef PEB_MEMBER
  48. #define PEB_MEMBER(name) printf("%s %ld %ld\n", #name, (long)FIELD_OFFSET(PEB32, name), (long)RTL_FIELD_SIZE(PEB32, name));
  49. printf("\n\nPEB32 %ld\n\n", (long)sizeof(PEB32));
  50. #include "peb.h"
  51. #undef PEB_MEMBER
  52. #define PEB_MEMBER(name) printf("%s %ld %ld\n", #name, (long)FIELD_OFFSET(PEB64, name), (long)RTL_FIELD_SIZE(PEB64, name));
  53. printf("\n\nPEB64 %ld\n\n", (long)sizeof(PEB64));
  54. #include "peb.h"
  55. printf("\n\npadding\n\n");
  56. printf("TEB %ld\n", (long)RTL_PADDING_BETWEEN_FIELDS(TEB, ActivationContextStack, ExceptionCode));
  57. printf("TEB %ld\n", (long)RTL_PADDING_BETWEEN_FIELDS(TEB, ExceptionCode, ActivationContextStack));
  58. printf("TEB32 %ld\n", (long)RTL_PADDING_BETWEEN_FIELDS(TEB32, ActivationContextStack, ExceptionCode));
  59. printf("TEB32 %ld\n", (long)RTL_PADDING_BETWEEN_FIELDS(TEB32, ExceptionCode, ActivationContextStack));
  60. printf("TEB64 %ld\n", (long)RTL_PADDING_BETWEEN_FIELDS(TEB64, ActivationContextStack, ExceptionCode));
  61. printf("TEB64 %ld\n", (long)RTL_PADDING_BETWEEN_FIELDS(TEB64, ExceptionCode, ActivationContextStack));
  62. if ((sizeof(PVOID)*CHAR_BIT) == 32)
  63. {
  64. assert(sizeof(PEB) == sizeof(PEB32));
  65. assert(sizeof(TEB) == sizeof(TEB32));
  66. }
  67. if ((sizeof(PVOID)*CHAR_BIT) == 64)
  68. {
  69. assert(sizeof(PEB) == sizeof(PEB64));
  70. assert(sizeof(TEB) == sizeof(TEB64));
  71. }
  72. }
  73. int main()
  74. {
  75. Test1();
  76. return 0;
  77. }