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.

192 lines
6.2 KiB

  1. #include "ulib.hxx"
  2. #include "bootedit.hxx"
  3. #include "bpb.hxx"
  4. extern "C" {
  5. #include <stdio.h>
  6. }
  7. VOID
  8. DOS_BOOT_EDIT::SetBuf(
  9. IN HWND WindowHandle,
  10. IN OUT PVOID Buffer,
  11. IN ULONG Size
  12. )
  13. {
  14. _buffer = Buffer;
  15. _size = Size;
  16. SetScrollRange(WindowHandle, SB_VERT, 0, 0, FALSE);
  17. InvalidateRect(WindowHandle, NULL, TRUE);
  18. }
  19. VOID
  20. DOS_BOOT_EDIT::Paint(
  21. IN HDC DeviceContext,
  22. IN RECT InvalidRect,
  23. IN HWND WindowHandle
  24. )
  25. {
  26. EXTENDED_BIOS_PARAMETER_BLOCK bios;
  27. TEXTMETRIC textmetric;
  28. INT ch, current;
  29. TCHAR buf[1024];
  30. SetScrollRange(WindowHandle, SB_VERT, 0, 0, FALSE);
  31. if (!_buffer || _size < 128) {
  32. return;
  33. }
  34. memset(&bios, 0, sizeof(EXTENDED_BIOS_PARAMETER_BLOCK));
  35. // Unpack the bios
  36. UnpackExtendedBios(&bios, (PPACKED_EXTENDED_BIOS_PARAMETER_BLOCK)_buffer);
  37. SelectObject(DeviceContext, GetStockObject(ANSI_FIXED_FONT));
  38. GetTextMetrics(DeviceContext, &textmetric);
  39. ch = textmetric.tmExternalLeading + textmetric.tmHeight;
  40. current = 0;
  41. swprintf(buf, TEXT("OEM String: %c%c%c%c%c%c%c%c"),
  42. bios.OemData[0],
  43. bios.OemData[1],
  44. bios.OemData[2],
  45. bios.OemData[3],
  46. bios.OemData[4],
  47. bios.OemData[5],
  48. bios.OemData[6],
  49. bios.OemData[7]);
  50. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  51. current += ch;
  52. swprintf(buf, TEXT("Bytes per sector: %x"), bios.Bpb.BytesPerSector);
  53. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  54. current += ch;
  55. swprintf(buf, TEXT("Sectors per cluster: %x"), bios.Bpb.SectorsPerCluster);
  56. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  57. current += ch;
  58. swprintf(buf, TEXT("Reserved Sectors: %x"), bios.Bpb.ReservedSectors);
  59. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  60. current += ch;
  61. swprintf(buf, TEXT("Number of fats: %x"), bios.Bpb.Fats);
  62. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  63. current += ch;
  64. swprintf(buf, TEXT("Root entries: %x"), bios.Bpb.RootEntries);
  65. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  66. current += ch;
  67. swprintf(buf, TEXT("Small sector count: %x"), bios.Bpb.Sectors);
  68. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  69. current += ch;
  70. swprintf(buf, TEXT("Media byte: %x"), bios.Bpb.Media);
  71. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  72. current += ch;
  73. swprintf(buf, TEXT("Sectors per fat: %x"), bios.Bpb.SectorsPerFat);
  74. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  75. current += ch;
  76. if(!bios.Bpb.SectorsPerFat){
  77. swprintf(buf, TEXT("Large sectors per fat: %x"), bios.Bpb.BigSectorsPerFat);
  78. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  79. current += ch;
  80. }
  81. swprintf(buf, TEXT("Sectors per track: %x"),
  82. bios.Bpb.SectorsPerTrack);
  83. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  84. current += ch;
  85. swprintf(buf, TEXT("Number of heads: %x"),
  86. bios.Bpb.Heads);
  87. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  88. current += ch;
  89. swprintf(buf, TEXT("Number of hidden sectors: %x"),
  90. bios.Bpb.HiddenSectors);
  91. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  92. current += ch;
  93. swprintf(buf, TEXT("Large number of sectors: %x"),
  94. bios.Bpb.LargeSectors);
  95. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  96. current += ch;
  97. if(!bios.Bpb.SectorsPerFat){
  98. swprintf(buf, TEXT("Extended flags: %x"),
  99. bios.Bpb.ExtFlags);
  100. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  101. current += ch;
  102. swprintf(buf, TEXT("File system version: %x"),
  103. bios.Bpb.FS_Version);
  104. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  105. current += ch;
  106. swprintf(buf, TEXT("Root directory start cluster: %x"), bios.Bpb.RootDirStrtClus);
  107. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  108. current += ch;
  109. swprintf(buf, TEXT("File system info sector number: %x"), bios.Bpb.FSInfoSec);
  110. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  111. current += ch;
  112. swprintf(buf, TEXT("Backup boot sector: %x"), bios.Bpb.BkUpBootSec);
  113. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  114. current += ch;
  115. }
  116. swprintf(buf, TEXT("Physical drive: %x"), bios.PhysicalDrive);
  117. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  118. current += ch;
  119. swprintf(buf, TEXT("Current head: %x"), bios.CurrentHead);
  120. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  121. current += ch;
  122. swprintf(buf, TEXT("Extended boot signature: %x"), bios.Signature);
  123. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  124. current += ch;
  125. swprintf(buf, TEXT("Serial number: %x"), bios.SerialNumber);
  126. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  127. current += ch;
  128. swprintf(buf, TEXT("Label: %c%c%c%c%c%c%c%c%c%c%c"),
  129. bios.Label[0],
  130. bios.Label[1],
  131. bios.Label[2],
  132. bios.Label[3],
  133. bios.Label[4],
  134. bios.Label[5],
  135. bios.Label[6],
  136. bios.Label[7],
  137. bios.Label[8],
  138. bios.Label[9],
  139. bios.Label[10]);
  140. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  141. current += ch;
  142. swprintf(buf, TEXT("System id: %c%c%c%c%c%c%c%c"),
  143. bios.SystemIdText[0],
  144. bios.SystemIdText[1],
  145. bios.SystemIdText[2],
  146. bios.SystemIdText[3],
  147. bios.SystemIdText[4],
  148. bios.SystemIdText[5],
  149. bios.SystemIdText[6],
  150. bios.SystemIdText[7]);
  151. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  152. current += ch;
  153. }