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.

173 lines
4.3 KiB

  1. #include "ulib.hxx"
  2. #include "untfs.hxx"
  3. #include "frsstruc.hxx"
  4. #include "ntfssa.hxx"
  5. #include "attrrec.hxx"
  6. #include "cmem.hxx"
  7. #include "ntfssa.hxx"
  8. #include "atrlsted.hxx"
  9. #include "crack.hxx"
  10. #include "attrlist.hxx"
  11. extern "C" {
  12. #include <stdio.h>
  13. }
  14. BOOLEAN
  15. ATTR_LIST_EDIT::Initialize(
  16. IN HWND WindowHandle,
  17. IN INT ClientHeight,
  18. IN INT ClientWidth,
  19. IN PLOG_IO_DP_DRIVE Drive
  20. )
  21. {
  22. TEXTMETRIC textmetric;
  23. HDC hdc;
  24. NTFS_SA ntfssa;
  25. MESSAGE msg;
  26. hdc = GetDC(WindowHandle);
  27. if (hdc == NULL)
  28. return FALSE;
  29. GetTextMetrics(hdc, &textmetric);
  30. ReleaseDC(WindowHandle, hdc);
  31. _buffer = NULL;
  32. _size = 0;
  33. _drive = Drive;
  34. if (!_drive) {
  35. return FALSE;
  36. }
  37. return VERTICAL_TEXT_SCROLL::Initialize(
  38. WindowHandle,
  39. 0,
  40. ClientHeight,
  41. ClientWidth,
  42. textmetric.tmExternalLeading + textmetric.tmHeight,
  43. textmetric.tmMaxCharWidth);
  44. }
  45. VOID
  46. ATTR_LIST_EDIT::SetBuf(
  47. IN HWND WindowHandle,
  48. IN OUT PVOID Buffer,
  49. IN ULONG Size
  50. )
  51. {
  52. _buffer = Buffer;
  53. _size = Size;
  54. SetRange(WindowHandle, _size/3);
  55. }
  56. STATIC TCHAR buf[1024];
  57. VOID
  58. ATTR_LIST_EDIT::Paint(
  59. IN HDC DeviceContext,
  60. IN RECT InvalidRect,
  61. IN HWND WindowHandle
  62. )
  63. {
  64. PATTRIBUTE_LIST_ENTRY CurrentEntry;
  65. PTCHAR pc;
  66. TCHAR sbFlags[32];
  67. ULONG LengthOfList = _size;
  68. ULONG CurrentOffset;
  69. ULONG CurrentLine = 0;
  70. SetScrollRange(WindowHandle, SB_VERT, 0, _size/3, FALSE);
  71. SetScrollPos(WindowHandle, SB_VERT, QueryScrollPosition(), TRUE);
  72. SelectObject(DeviceContext, GetStockObject(ANSI_FIXED_FONT));
  73. if (!_buffer || !_size) {
  74. return;
  75. }
  76. WriteLine(DeviceContext, CurrentLine++, buf);
  77. CurrentEntry = (PATTRIBUTE_LIST_ENTRY)((PCHAR)_buffer);
  78. CurrentOffset = 0;
  79. while (CurrentOffset < LengthOfList) {
  80. if (0 != CurrentOffset) {
  81. CurrentLine++;
  82. }
  83. PTCHAR SymbolicTypeCode = GetNtfsAttributeTypeCodeName(
  84. CurrentEntry->AttributeTypeCode);
  85. swprintf(buf, TEXT("Attribute type code: \t%x (%s)"),
  86. CurrentEntry->AttributeTypeCode, SymbolicTypeCode);
  87. WriteLine(DeviceContext, CurrentLine++, buf);
  88. swprintf(buf, TEXT("Record length \t\t%x"), CurrentEntry->RecordLength);
  89. WriteLine(DeviceContext, CurrentLine++, buf);
  90. swprintf(buf, TEXT("Attribute name length \t%x"),
  91. CurrentEntry->AttributeNameLength);
  92. WriteLine(DeviceContext, CurrentLine++, buf);
  93. swprintf(buf, TEXT("Attribute name offset \t%x"),
  94. CurrentEntry->AttributeNameOffset);
  95. WriteLine(DeviceContext, CurrentLine++, buf);
  96. swprintf(buf, TEXT("Lowest vcn \t\t<%x,%x>"),
  97. CurrentEntry->LowestVcn.GetHighPart(),
  98. CurrentEntry->LowestVcn.GetLowPart());
  99. WriteLine(DeviceContext, CurrentLine++, buf);
  100. swprintf(buf, TEXT("Segment reference: \t<%x,%x>"),
  101. CurrentEntry->SegmentReference.HighPart,
  102. CurrentEntry->SegmentReference.LowPart,
  103. CurrentEntry->SegmentReference.SequenceNumber);
  104. WriteLine(DeviceContext, CurrentLine++, buf);
  105. swprintf(buf, TEXT("Sequence number: \t%x"),
  106. CurrentEntry->SegmentReference.SequenceNumber);
  107. WriteLine(DeviceContext, CurrentLine++, buf);
  108. swprintf(buf, TEXT("Instance: \t\t%x"), CurrentEntry->Instance);
  109. WriteLine(DeviceContext, CurrentLine++, buf);
  110. swprintf(buf, TEXT("Attribute name:\t\t"));
  111. pc = buf + wcslen(buf);
  112. for (int i = 0; i < min(64, CurrentEntry->AttributeNameLength); ++i) {
  113. *pc++ = (CHAR)CurrentEntry->AttributeName[i];
  114. }
  115. *pc++ = '\0';
  116. if (CurrentEntry->AttributeNameLength > 64) {
  117. wcscat(buf, TEXT("..."));
  118. }
  119. WriteLine(DeviceContext, CurrentLine++, buf);
  120. if (CurrentEntry->RecordLength == 0) {
  121. break;
  122. }
  123. CurrentOffset += CurrentEntry->RecordLength;
  124. CurrentEntry = NextEntry(CurrentEntry);
  125. }
  126. }
  127. VOID
  128. ATTR_LIST_EDIT::KeyUp(
  129. IN HWND WindowHandle
  130. )
  131. {
  132. ScrollUp(WindowHandle);
  133. }
  134. VOID
  135. ATTR_LIST_EDIT::KeyDown(
  136. IN HWND WindowHandle
  137. )
  138. {
  139. ScrollDown(WindowHandle);
  140. }