Advertisement
Guest User

Untitled

a guest
Jul 11th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Include "windows.bi"
  2. #Include "win/winioctl.bi"
  3.  
  4. Type FAT_Header
  5.     BS_jmpBoot(2) As UByte
  6.     BS_OEMName(7) As UByte
  7.     BPB_BytesPerSec As UShort
  8.     BPB_SecPerClus As UByte
  9.     BPB_RsvdSecCnt As UShort
  10.     BPB_NumFATs As UByte
  11.     BPB_RootEntCnt As UShort
  12.     BPB_TotSec16 As UShort
  13.     BPB_Media As UByte
  14.     BPB_FATSz16 As UShort
  15.     BPB_SecPerTrk As UShort
  16.     BPB_NumHeads As UShort
  17.     BPB_HiddSec As ULong
  18.     BPB_TotSec32 As ULong
  19.     BPB_FATSz32 As ULong
  20.     BPB_ExtFlags As UShort
  21.     BPB_FSVer As UShort
  22.     BPB_RootClus As ULong
  23.     BPB_FSInfo As UShort
  24.     BPB_BkBootSec As UShort
  25.     BPB_Reserved(11) As UByte
  26.     BS_DrvNum As UByte
  27.     BS_Reserved1 As UByte
  28.     BS_BootSig As UByte
  29.     BS_VolID As ULong
  30.     BS_VolLab(10) As UByte
  31.     BS_FilSysType(7) As UByte
  32. End Type
  33.  
  34. type STORAGE_DEVICE_NUMBER
  35.   DeviceType       as DEVICE_TYPE
  36.   DeviceNumber     as ULONG
  37.   PartitionNumber  as ULONG
  38. end Type
  39.  
  40. Dim hDevice As HANDLE
  41. Dim sds As STORAGE_DEVICE_NUMBER
  42. Dim bResult As Integer
  43. 'Dim fh As FAT_Header
  44. Dim As String TempString = Space(1024)
  45. Dim bytes_ret As DWORD
  46. Dim szReturn As Integer
  47. Dim ov As OVERLAPPED
  48.  
  49. hDevice = CreateFile("\\.\G:", GENERIC_READ, FILE_SHARE_READ Or FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL)
  50.  
  51. If hDevice = INVALID_HANDLE_VALUE Then
  52.     Print "Error, unable to open device!"
  53.     GoTo Ending
  54. EndIf
  55.  
  56. bResult = DeviceIoControl(hDevice, IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, Cast(Any Ptr, @sds), SizeOf(sds), @bytes_ret, @ov)
  57.  
  58. bResult = ReadFile(hDevice, StrPtr(TempString), 1204, @szReturn, NULL)
  59. If bResult = 0 Then
  60.     Print "Error, unable to read file!"
  61.     Print "Last error was "; GetLastError(); "."
  62.     GoTo Ending
  63. EndIf
  64.  
  65. 'Print "BS_OEMName contains "; fh.BS_OEMName(0);fh.BS_OEMName(1);fh.BS_OEMName(2);fh.BS_OEMName(3);fh.BS_OEMName(4);fh.BS_OEMName(5);fh.BS_OEMName(6); fh.BS_OEMName(7); "."
  66.  
  67. Ending:
  68. Sleep
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement