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.

212 lines
6.4 KiB

  1. #include "ulib.hxx"
  2. #include "drive.hxx"
  3. #include "untfs.hxx"
  4. #include "restarea.hxx"
  5. extern "C" {
  6. #include <stdio.h>
  7. }
  8. BOOLEAN
  9. RESTART_AREA_EDIT::Initialize(
  10. IN HWND WindowHandle,
  11. IN INT ClientHeight,
  12. IN INT ClientWidth,
  13. IN PLOG_IO_DP_DRIVE Drive
  14. )
  15. {
  16. TEXTMETRIC tm;
  17. HDC hdc;
  18. hdc = GetDC(WindowHandle);
  19. if (hdc == NULL)
  20. return FALSE;
  21. GetTextMetrics(hdc, &tm);
  22. ReleaseDC(WindowHandle, hdc);
  23. if (!VERTICAL_TEXT_SCROLL::Initialize(
  24. WindowHandle,
  25. 0,
  26. ClientHeight,
  27. ClientWidth,
  28. tm.tmExternalLeading + tm.tmHeight,
  29. tm.tmMaxCharWidth
  30. )) {
  31. return FALSE;
  32. }
  33. return TRUE;
  34. }
  35. VOID
  36. RESTART_AREA_EDIT::SetBuf(
  37. IN HWND WindowHandle,
  38. IN OUT PVOID Buffer,
  39. IN ULONG Size
  40. )
  41. {
  42. _buffer = Buffer;
  43. _size = Size;
  44. SetRange(WindowHandle, _size/2);
  45. InvalidateRect(WindowHandle, NULL, TRUE);
  46. }
  47. VOID
  48. RESTART_AREA_EDIT::Paint(
  49. IN HDC DeviceContext,
  50. IN RECT InvalidRect,
  51. IN HWND WindowHandle
  52. )
  53. {
  54. PLFS_RESTART_PAGE_HEADER pRestPageHeader;
  55. PLFS_RESTART_AREA pRestArea;
  56. PLFS_CLIENT_RECORD pClientRecord;
  57. TEXTMETRIC tm;
  58. INT ch, CurrentLine;
  59. TCHAR buf[1024];
  60. SetScrollRange(WindowHandle, SB_VERT, 0, _size/2, FALSE);
  61. SetScrollPos(WindowHandle, SB_VERT, QueryScrollPosition(), TRUE);
  62. SelectObject(DeviceContext, GetStockObject(ANSI_FIXED_FONT));
  63. if (!_buffer || _size < 512) {
  64. return;
  65. }
  66. GetTextMetrics(DeviceContext, &tm);
  67. ch = tm.tmExternalLeading + tm.tmHeight;
  68. CurrentLine = 0;
  69. pRestPageHeader = (PLFS_RESTART_PAGE_HEADER)_buffer;
  70. swprintf(buf, TEXT("MultiSectorHeader.Signature: \t\t\t%c%c%c%c"),
  71. pRestPageHeader->MultiSectorHeader.Signature[0],
  72. pRestPageHeader->MultiSectorHeader.Signature[1],
  73. pRestPageHeader->MultiSectorHeader.Signature[2],
  74. pRestPageHeader->MultiSectorHeader.Signature[3]);
  75. WriteLine(DeviceContext, CurrentLine++, buf);
  76. swprintf(buf, TEXT("MultiSectorHeader.UpdateSequenceArrayOffset: \t%u"),
  77. pRestPageHeader->MultiSectorHeader.UpdateSequenceArrayOffset);
  78. WriteLine(DeviceContext, CurrentLine++, buf);
  79. swprintf(buf, TEXT("MultiSectorHeader.UpdateSequenceArraySize: \t%x"),
  80. pRestPageHeader->MultiSectorHeader.UpdateSequenceArraySize);
  81. WriteLine(DeviceContext, CurrentLine++, buf);
  82. swprintf(buf, TEXT("ChkDskLsn: \t%x:%x"),
  83. pRestPageHeader->ChkDskLsn.HighPart,
  84. pRestPageHeader->ChkDskLsn.LowPart);
  85. WriteLine(DeviceContext, CurrentLine++, buf);
  86. swprintf(buf, TEXT("SystemPageSize: %x"), pRestPageHeader->SystemPageSize);
  87. WriteLine(DeviceContext, CurrentLine++, buf);
  88. swprintf(buf, TEXT("LogPageSize: \t%x"), pRestPageHeader->LogPageSize);
  89. WriteLine(DeviceContext, CurrentLine++, buf);
  90. swprintf(buf, TEXT("RestartOffset: \t%x"), pRestPageHeader->RestartOffset);
  91. WriteLine(DeviceContext, CurrentLine++, buf);
  92. swprintf(buf, TEXT("MinorVersion: \t%d"), pRestPageHeader->MinorVersion);
  93. WriteLine(DeviceContext, CurrentLine++, buf);
  94. swprintf(buf, TEXT("MajorVersion: \t%d"), pRestPageHeader->MajorVersion);
  95. WriteLine(DeviceContext, CurrentLine++, buf);
  96. CurrentLine++;
  97. pRestArea = PLFS_RESTART_AREA(PUCHAR(_buffer) + pRestPageHeader->RestartOffset);
  98. swprintf(buf, TEXT("CurrentLsn: \t\t%x:%x"), pRestArea->CurrentLsn.HighPart,
  99. pRestArea->CurrentLsn.LowPart);
  100. WriteLine(DeviceContext, CurrentLine++, buf);
  101. swprintf(buf, TEXT("LogClients: \t\t%x"), pRestArea->LogClients);
  102. WriteLine(DeviceContext, CurrentLine++, buf);
  103. swprintf(buf, TEXT("ClientFreeList: \t%x"), pRestArea->ClientFreeList);
  104. WriteLine(DeviceContext, CurrentLine++, buf);
  105. swprintf(buf, TEXT("ClientInUseList: \t%x"), pRestArea->ClientInUseList);
  106. WriteLine(DeviceContext, CurrentLine++, buf);
  107. swprintf(buf, TEXT("Flags: \t\t\t%x"), pRestArea->Flags);
  108. WriteLine(DeviceContext, CurrentLine++, buf);
  109. swprintf(buf, TEXT("SeqNumberBits: \t\t%x"), pRestArea->SeqNumberBits);
  110. WriteLine(DeviceContext, CurrentLine++, buf);
  111. swprintf(buf, TEXT("RestartAreaLength: \t%x"), pRestArea->RestartAreaLength);
  112. WriteLine(DeviceContext, CurrentLine++, buf);
  113. swprintf(buf, TEXT("ClientArrayOffset: \t%x"), pRestArea->ClientArrayOffset);
  114. WriteLine(DeviceContext, CurrentLine++, buf);
  115. swprintf(buf, TEXT("FileSize: \t\t%x"), pRestArea->FileSize);
  116. WriteLine(DeviceContext, CurrentLine++, buf);
  117. swprintf(buf, TEXT("LastLsnDataLength: \t%x"), pRestArea->LastLsnDataLength);
  118. WriteLine(DeviceContext, CurrentLine++, buf);
  119. swprintf(buf, TEXT("RecordHeaderLength: \t%x"), pRestArea->RecordHeaderLength);
  120. WriteLine(DeviceContext, CurrentLine++, buf);
  121. swprintf(buf, TEXT("LogPageDataOffset: \t%x"), pRestArea->LogPageDataOffset);
  122. WriteLine(DeviceContext, CurrentLine++, buf);
  123. for (INT i = 0; i < pRestArea->LogClients; ++i) {
  124. CurrentLine++;
  125. swprintf(buf, TEXT("CLIENT \t%d"), i);
  126. WriteLine(DeviceContext, CurrentLine++, buf);
  127. pClientRecord = &pRestArea->LogClientArray[i];
  128. swprintf(buf, TEXT(" OldestLsn: \t\t%x:%x"),
  129. pClientRecord->OldestLsn.HighPart,
  130. pClientRecord->OldestLsn.LowPart);
  131. WriteLine(DeviceContext, CurrentLine++, buf);
  132. swprintf(buf, TEXT(" ClientRestartLsn: \t%x:%x"),
  133. pClientRecord->ClientRestartLsn.HighPart,
  134. pClientRecord->ClientRestartLsn.LowPart);
  135. WriteLine(DeviceContext, CurrentLine++, buf);
  136. swprintf(buf, TEXT(" PrevClient: \t%x"), pClientRecord->PrevClient);
  137. WriteLine(DeviceContext, CurrentLine++, buf);
  138. swprintf(buf, TEXT(" NextClient: \t%x"), pClientRecord->NextClient);
  139. WriteLine(DeviceContext, CurrentLine++, buf);
  140. swprintf(buf, TEXT(" SeqNumber: \t\t%x"), pClientRecord->SeqNumber);
  141. WriteLine(DeviceContext, CurrentLine++, buf);
  142. swprintf(buf, TEXT(" ClientName: \t"));
  143. INT x = wcslen(buf);
  144. for (ULONG j = 0; j < pClientRecord->ClientNameLength; ++j) {
  145. buf[j + x] = (TCHAR)pClientRecord->ClientName[j];
  146. }
  147. WriteLine(DeviceContext, CurrentLine++, buf);
  148. }
  149. }
  150. VOID
  151. RESTART_AREA_EDIT::KeyUp(
  152. IN HWND WindowHandle
  153. )
  154. {
  155. ScrollUp(WindowHandle);
  156. }
  157. VOID
  158. RESTART_AREA_EDIT::KeyDown(
  159. IN HWND WindowHandle
  160. )
  161. {
  162. ScrollDown(WindowHandle);
  163. }