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.

205 lines
5.5 KiB

  1. #include "ulib.hxx"
  2. #include "logreced.hxx"
  3. #include "untfs.hxx"
  4. #include "frsstruc.hxx"
  5. #include "attrrec.hxx"
  6. #include "cmem.hxx"
  7. #include "ntfssa.hxx"
  8. #include "lfs.h"
  9. #include "lfsdisk.h"
  10. //#include "ntfsstru.h"
  11. #include "ntfslog.h"
  12. extern "C" {
  13. #include <stdio.h>
  14. }
  15. BOOLEAN
  16. LOG_RECORD_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. _drive = Drive;
  35. if (!_drive) {
  36. return FALSE;
  37. }
  38. if (!ntfssa.Initialize(Drive, &msg) ||
  39. !ntfssa.Read()) {
  40. return FALSE;
  41. }
  42. _cluster_factor = ntfssa.QueryClusterFactor();
  43. _frs_size = ntfssa.QueryFrsSize();
  44. return VERTICAL_TEXT_SCROLL::Initialize(
  45. WindowHandle,
  46. 0,
  47. ClientHeight,
  48. ClientWidth,
  49. textmetric.tmExternalLeading + textmetric.tmHeight,
  50. textmetric.tmMaxCharWidth);
  51. }
  52. VOID
  53. LOG_RECORD_EDIT::SetBuf(
  54. IN HWND WindowHandle,
  55. IN OUT PVOID Buffer,
  56. IN ULONG Size
  57. )
  58. {
  59. _buffer = Buffer;
  60. _size = Size;
  61. SetRange(WindowHandle, _size/4);
  62. }
  63. VOID
  64. LOG_RECORD_EDIT::Paint(
  65. IN HDC DeviceContext,
  66. IN RECT InvalidRect,
  67. IN HWND WindowHandle
  68. )
  69. {
  70. TCHAR buf[1024];
  71. INT nDrawX, nDrawY;
  72. PLFS_RECORD_HEADER plog;
  73. PNTFS_LOG_RECORD_HEADER pntfs_record;
  74. TEXTMETRIC tm;
  75. INT ch, CurrentLine;
  76. SetScrollRange(WindowHandle, SB_VERT, 0, _size/4, FALSE);
  77. SetScrollPos(WindowHandle, SB_VERT, QueryScrollPosition(), TRUE);
  78. if (!_buffer || !_size) {
  79. return;
  80. }
  81. GetTextMetrics(DeviceContext, &tm);
  82. ch = tm.tmExternalLeading + tm.tmHeight;
  83. CurrentLine = 0;
  84. plog = (PLFS_RECORD_HEADER)_buffer;
  85. pntfs_record = PNTFS_LOG_RECORD_HEADER(PUCHAR(_buffer) +
  86. LFS_RECORD_HEADER_SIZE);
  87. swprintf(buf, TEXT("ThisLsn: %x:%x"),
  88. plog->ThisLsn.HighPart,
  89. plog->ThisLsn.LowPart);
  90. WriteLine(DeviceContext, CurrentLine++, buf);
  91. swprintf(buf, TEXT("ClientPreviousLsn: %x:%x"),
  92. plog->ClientPreviousLsn.HighPart,
  93. plog->ClientPreviousLsn.LowPart);
  94. WriteLine(DeviceContext, CurrentLine++, buf);
  95. swprintf(buf, TEXT("ClientUndoNextLsn: %x:%x"),
  96. plog->ClientUndoNextLsn.HighPart,
  97. plog->ClientUndoNextLsn.LowPart);
  98. WriteLine(DeviceContext, CurrentLine++, buf);
  99. swprintf(buf, TEXT("ClientDataLength: %x"), plog->ClientDataLength);
  100. WriteLine(DeviceContext, CurrentLine++, buf);
  101. swprintf(buf, TEXT("ClientId.SeqNumber: %x"), plog->ClientId.SeqNumber);
  102. WriteLine(DeviceContext, CurrentLine++, buf);
  103. swprintf(buf, TEXT("ClientId.ClientIndex: %x"), plog->ClientId.ClientIndex);
  104. WriteLine(DeviceContext, CurrentLine++, buf);
  105. swprintf(buf, TEXT("RecordType: %x"), plog->RecordType);
  106. WriteLine(DeviceContext, CurrentLine++, buf);
  107. swprintf(buf, TEXT("TransactionId: %x"), plog->TransactionId);
  108. WriteLine(DeviceContext, CurrentLine++, buf);
  109. if (LOG_RECORD_MULTI_PAGE == plog->Flags) {
  110. swprintf(buf, TEXT("Flags: LOG_RECORD_MULTI_PAGE"));
  111. } else {
  112. swprintf(buf, TEXT("Flags: %x"), plog->Flags);
  113. }
  114. WriteLine(DeviceContext, CurrentLine++, buf);
  115. CurrentLine++;
  116. swprintf(buf, TEXT("RedoOperation: %x"), pntfs_record->RedoOperation);
  117. WriteLine(DeviceContext, CurrentLine++, buf);
  118. swprintf(buf, TEXT("UndoOperation: %x"), pntfs_record->UndoOperation);
  119. WriteLine(DeviceContext, CurrentLine++, buf);
  120. swprintf(buf, TEXT("RedoOffset: %x"), pntfs_record->RedoOffset);
  121. WriteLine(DeviceContext, CurrentLine++, buf);
  122. swprintf(buf, TEXT("RedoLength: %x"), pntfs_record->RedoLength);
  123. WriteLine(DeviceContext, CurrentLine++, buf);
  124. swprintf(buf, TEXT("UndoOffset: %x"), pntfs_record->UndoOffset);
  125. WriteLine(DeviceContext, CurrentLine++, buf);
  126. swprintf(buf, TEXT("UndoLength: %x"), pntfs_record->UndoLength);
  127. WriteLine(DeviceContext, CurrentLine++, buf);
  128. swprintf(buf, TEXT("TargetAttribute: %x"), pntfs_record->TargetAttribute);
  129. WriteLine(DeviceContext, CurrentLine++, buf);
  130. swprintf(buf, TEXT("LcnsToFollow: %x"), pntfs_record->LcnsToFollow);
  131. WriteLine(DeviceContext, CurrentLine++, buf);
  132. swprintf(buf, TEXT("RecordOffset: %x"), pntfs_record->RecordOffset);
  133. WriteLine(DeviceContext, CurrentLine++, buf);
  134. swprintf(buf, TEXT("AttributeOffset: %x"), pntfs_record->AttributeOffset);
  135. WriteLine(DeviceContext, CurrentLine++, buf);
  136. swprintf(buf, TEXT("TargetVcn: %x"), (ULONG)pntfs_record->TargetVcn);
  137. WriteLine(DeviceContext, CurrentLine++, buf);
  138. if (0 != pntfs_record->LcnsToFollow) {
  139. WriteLine(DeviceContext, CurrentLine++, TEXT("Lcns:"));
  140. for (USHORT i = 0; i < pntfs_record->LcnsToFollow; ++i) {
  141. swprintf(buf, TEXT(" %x"), (ULONG)pntfs_record->LcnsForPage[i]);
  142. WriteLine(DeviceContext, CurrentLine++, buf);
  143. }
  144. }
  145. }
  146. VOID
  147. LOG_RECORD_EDIT::KeyUp(
  148. IN HWND WindowHandle
  149. )
  150. {
  151. ScrollUp(WindowHandle);
  152. }
  153. VOID
  154. LOG_RECORD_EDIT::KeyDown(
  155. IN HWND WindowHandle
  156. )
  157. {
  158. ScrollDown(WindowHandle);
  159. }