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.

92 lines
1.6 KiB

  1. #include "ulib.hxx"
  2. #include "rootio.hxx"
  3. #include "diskedit.h"
  4. #include "rfatsa.hxx"
  5. extern "C" {
  6. #include <stdio.h>
  7. }
  8. BOOLEAN
  9. ROOT_IO::Setup(
  10. IN PMEM Mem,
  11. IN PLOG_IO_DP_DRIVE Drive,
  12. IN HANDLE Application,
  13. IN HWND WindowHandle,
  14. OUT PBOOLEAN Error
  15. )
  16. {
  17. REAL_FAT_SA fatsa;
  18. MESSAGE msg;
  19. _drive = Drive;
  20. *Error = TRUE;
  21. if (!_drive ||
  22. !fatsa.Initialize(_drive, &msg) ||
  23. !fatsa.FAT_SA::Read() ||
  24. !_rootdir.Initialize(Mem, _drive,
  25. fatsa.QueryReservedSectors() +
  26. fatsa.QueryFats() * fatsa.QuerySectorsPerFat(),
  27. fatsa.QueryRootEntries())) {
  28. return FALSE;
  29. }
  30. _buffer = _rootdir.GetDirEntry(0);
  31. _buffer_size = ((BytesPerDirent*fatsa.QueryRootEntries() - 1)/
  32. _drive->QuerySectorSize() + 1)*_drive->QuerySectorSize();
  33. wsprintf(_header_text, TEXT("DiskEdit - Root Directory"));
  34. return TRUE;
  35. }
  36. BOOLEAN
  37. ROOT_IO::Read(
  38. OUT PULONG pError
  39. )
  40. {
  41. *pError = 0;
  42. if (NULL == _drive) {
  43. return FALSE;
  44. }
  45. if (!_rootdir.Read()) {
  46. *pError = _drive->QueryLastNtStatus();
  47. return FALSE;
  48. }
  49. return TRUE;
  50. }
  51. BOOLEAN
  52. ROOT_IO::Write(
  53. )
  54. {
  55. return _drive ? _rootdir.Write() : FALSE;
  56. }
  57. PVOID
  58. ROOT_IO::GetBuf(
  59. OUT PULONG Size
  60. )
  61. {
  62. if (Size) {
  63. *Size = _buffer_size;
  64. }
  65. return _buffer;
  66. }
  67. PTCHAR
  68. ROOT_IO::GetHeaderText(
  69. )
  70. {
  71. return _header_text;
  72. }