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.

152 lines
3.8 KiB

  1. #include "ulib.hxx"
  2. #include "untfs.hxx"
  3. #include "secstr.hxx"
  4. #include "frsstruc.hxx"
  5. #include "ntfssa.hxx"
  6. #include "attrrec.hxx"
  7. #include "cmem.hxx"
  8. #include "ntfssa.hxx"
  9. extern "C" {
  10. #include <stdio.h>
  11. }
  12. ///////////////////////////////////////////////////////////////////////////////
  13. // Security stream support //
  14. ///////////////////////////////////////////////////////////////////////////////
  15. BOOLEAN
  16. SECURITY_STREAM_EDIT::Initialize(
  17. IN HWND WindowHandle,
  18. IN INT ClientHeight,
  19. IN INT ClientWidth,
  20. IN PLOG_IO_DP_DRIVE Drive
  21. )
  22. {
  23. TEXTMETRIC textmetric;
  24. HDC hdc;
  25. NTFS_SA ntfssa;
  26. MESSAGE msg;
  27. hdc = GetDC(WindowHandle);
  28. if (hdc == NULL)
  29. return FALSE;
  30. GetTextMetrics(hdc, &textmetric);
  31. ReleaseDC(WindowHandle, hdc);
  32. _buffer = NULL;
  33. _size = 0;
  34. return VERTICAL_TEXT_SCROLL::Initialize(
  35. WindowHandle,
  36. 0,
  37. ClientHeight,
  38. ClientWidth,
  39. textmetric.tmExternalLeading + textmetric.tmHeight,
  40. textmetric.tmMaxCharWidth);
  41. }
  42. VOID
  43. SECURITY_STREAM_EDIT::SetBuf(
  44. IN HWND WindowHandle,
  45. IN OUT PVOID Buffer,
  46. IN ULONG Size
  47. )
  48. {
  49. _buffer = Buffer;
  50. _size = Size;
  51. SetScrollPos(WindowHandle, SB_VERT, 0, FALSE);
  52. }
  53. VOID
  54. SECURITY_STREAM_EDIT::KeyUp(
  55. IN HWND WindowHandle
  56. )
  57. {
  58. ScrollUp(WindowHandle);
  59. }
  60. VOID
  61. SECURITY_STREAM_EDIT::KeyDown(
  62. IN HWND WindowHandle
  63. )
  64. {
  65. ScrollDown(WindowHandle);
  66. }
  67. VOID
  68. SECURITY_STREAM_EDIT::Paint(
  69. IN HDC DeviceContext,
  70. IN RECT InvalidRect,
  71. IN HWND WindowHandle
  72. )
  73. {
  74. TCHAR buf[1024];
  75. if (!_buffer || !_size) {
  76. return;
  77. }
  78. SelectObject(DeviceContext, GetStockObject(ANSI_FIXED_FONT));
  79. //
  80. // While there are more windows to dump
  81. //
  82. PVOID CurrentWindow = _buffer;
  83. INT CurrentLine = 0;
  84. while ((PCHAR)CurrentWindow < (PCHAR)_buffer + _size) {
  85. //
  86. // Dump window
  87. //
  88. PSECURITY_DESCRIPTOR_HEADER Header = (PSECURITY_DESCRIPTOR_HEADER) CurrentWindow;
  89. while ((PBYTE)Header < (PBYTE)CurrentWindow + 256 * 1024 &&
  90. Header->HashKey.SecurityId != SECURITY_ID_INVALID) {
  91. swprintf( buf, TEXT( "%08x: Hash %08x SecurityId %08x Offset %016I64x Length %08x" ),
  92. (PCHAR)Header - (PCHAR)_buffer,
  93. Header->HashKey.Hash, Header->HashKey.SecurityId,
  94. Header->Offset, Header->Length );
  95. WriteLine( DeviceContext, CurrentLine++, buf );
  96. Header = (PSECURITY_DESCRIPTOR_HEADER) ((PBYTE)Header + ((Header->Length + 15) & ~15));
  97. }
  98. //
  99. // Dump mirror
  100. //
  101. Header = (PSECURITY_DESCRIPTOR_HEADER) ((PBYTE) CurrentWindow + 256 * 1024);
  102. while ((PBYTE)Header < (PBYTE)_buffer + _size &&
  103. (PBYTE)Header < (PBYTE)CurrentWindow + 512 * 1024 &&
  104. Header->HashKey.SecurityId != SECURITY_ID_INVALID) {
  105. swprintf( buf, TEXT( "%08x: Hash %08x SecurityId %08x Offset %016I64x Length %08x" ),
  106. (PCHAR)Header - (PCHAR)_buffer,
  107. Header->HashKey.Hash, Header->HashKey.SecurityId,
  108. Header->Offset, Header->Length );
  109. WriteLine( DeviceContext, CurrentLine++, buf );
  110. Header = (PSECURITY_DESCRIPTOR_HEADER) ((PBYTE)Header + ((Header->Length + 15) & ~15));
  111. }
  112. //
  113. // Advance to next block
  114. //
  115. CurrentWindow = (PVOID) ((PBYTE)CurrentWindow + 512 * 1024);
  116. }
  117. SetRange(WindowHandle, CurrentLine + 50);
  118. }