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.

146 lines
4.7 KiB

  1. #include "ulib.hxx"
  2. #include "nbedit.hxx"
  3. #include "untfs.hxx"
  4. extern "C" {
  5. #include <stdio.h>
  6. }
  7. VOID
  8. NTFS_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. NTFS_BOOT_EDIT::Paint(
  21. IN HDC DeviceContext,
  22. IN RECT InvalidRect,
  23. IN HWND WindowHandle
  24. )
  25. {
  26. PPACKED_BOOT_SECTOR p;
  27. BIOS_PARAMETER_BLOCK bpb;
  28. TEXTMETRIC textmetric;
  29. INT ch, current;
  30. TCHAR buf[1024];
  31. SetScrollRange(WindowHandle, SB_VERT, 0, 0, FALSE);
  32. if (!_buffer || _size < 128) {
  33. return;
  34. }
  35. p = (PPACKED_BOOT_SECTOR) _buffer;
  36. UnpackBios(&bpb, &(p->PackedBpb));
  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. p->Oem[0],
  43. p->Oem[1],
  44. p->Oem[2],
  45. p->Oem[3],
  46. p->Oem[4],
  47. p->Oem[5],
  48. p->Oem[6],
  49. p->Oem[7]);
  50. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  51. current += ch;
  52. swprintf(buf, TEXT("Bytes per sector: %x"), bpb.BytesPerSector);
  53. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  54. current += ch;
  55. swprintf(buf, TEXT("Sectors per cluster: %x"), bpb.SectorsPerCluster);
  56. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  57. current += ch;
  58. swprintf(buf, TEXT("Reserved Sectors: %x"), bpb.ReservedSectors);
  59. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  60. current += ch;
  61. swprintf(buf, TEXT("Number of fats: %x"), bpb.Fats);
  62. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  63. current += ch;
  64. swprintf(buf, TEXT("Root entries: %x"), bpb.RootEntries);
  65. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  66. current += ch;
  67. swprintf(buf, TEXT("Small sector count: %x"), bpb.Sectors);
  68. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  69. current += ch;
  70. swprintf(buf, TEXT("Media byte: %x"), bpb.Media);
  71. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  72. current += ch;
  73. swprintf(buf, TEXT("Sectors per fat: %x"), bpb.SectorsPerFat);
  74. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  75. current += ch;
  76. swprintf(buf, TEXT("Sectors per track: %x"), bpb.SectorsPerTrack);
  77. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  78. current += ch;
  79. swprintf(buf, TEXT("Number of heads: %x"), bpb.Heads);
  80. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  81. current += ch;
  82. swprintf(buf, TEXT("Number of hidden sectors: %x"), bpb.HiddenSectors);
  83. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  84. current += ch;
  85. swprintf(buf, TEXT("Large number of sectors: %x"), bpb.LargeSectors);
  86. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  87. current += ch;
  88. swprintf(buf, TEXT("Physical drive: %x"), p->PhysicalDrive);
  89. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  90. current += ch;
  91. swprintf(buf, TEXT("NTFS number of sectors: %x"), p->NumberSectors.LowPart);
  92. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  93. current += ch;
  94. swprintf(buf, TEXT("MFT starting cluster: %x"), p->MftStartLcn.GetLowPart());
  95. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  96. current += ch;
  97. swprintf(buf, TEXT("MFT mirror starting cluster: %x"),
  98. p->Mft2StartLcn.GetLowPart());
  99. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  100. current += ch;
  101. swprintf(buf, TEXT("Clusters per file record: %x"),
  102. p->ClustersPerFileRecordSegment);
  103. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  104. current += ch;
  105. swprintf(buf, TEXT("Clusters per index block: %x"),
  106. p->DefaultClustersPerIndexAllocationBuffer);
  107. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  108. current += ch;
  109. swprintf(buf, TEXT("SerialNumber: %08x%08x"), p->SerialNumber.HighPart,
  110. p->SerialNumber.LowPart);
  111. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  112. current += ch;
  113. swprintf(buf, TEXT("Checksum: %x"), p->Checksum);
  114. TextOut(DeviceContext, 0, current, buf, wcslen(buf));
  115. current += ch;
  116. }