There seems to be a problem with long text. So I’ll divide my answer in 3 short sections and post separately.
Part 1:
Unfortunately there were indications that the BSD-signature on the disks to examine would not necessarily lead to a
BSD-type filesystem, like UFS, so the excellent suggestion by @Tim Jones to use a Big-Endian variant of BSD on a MIPS-emulator
might be less usable as hoped originally.
Also, after examining the disk with @Thomas Tempelmann 's IBored program, the newer version of the recorder didn’t expose
the filenames of the recorded programs (possibly encrypted now) unlike the earlier models. But some “magic numbers” pointing to VOB-files were visible.
However, even in Windows it appears not to be too difficult to access, especially read, a disk that is not yet "mounted",
in “Linux-speak”. I use a 3-step process as described late in this post.
Whether or not this will succeed depends also on the condition/health of the drive and it’s bootsector.
If the drive shows up in Windows’ DiskManagement tool, say as Disk1, one has good chance to be able to acquire a device handle
(even for an already visible, say Windows) drive. If the drive has some serious defects this may not be possible, however.
Reading in general is possible, even the “raw” info of a disk. But to do this, the program you create will in general have to run
with “administrator” permissions; this can be easily achieved by right-clicking your exe-file and choose “run ad administrator”. Of course, in the test-phase one can start Xojo itself with Administrator-priviliges.
NOTE: Reading from a severely damaged drive should be avoided at all cost, as it could deteriorate the drive beyond repair;
leave it to the professionals …
If you only have to look at a disk on a incidental basis, it would be easier to use a disk-viewing application,
Thomas Tempelmann’s IBored allowing you to view the blocks of the drive, copy blocks or sections to your own pc etc. and
search for specific patterns on the drive; in some situations editing is possible too. Also, IBored is scriptable.
However, sometimes it might be handier to access a non mounted drive directly from your program. I will give a small example
here for the necessary systemcalls; of course similar functions for Mac OS and Linux exist, but I have not investigated.
For Linux, it seemed more difficult to retrieve the drive handle for a disk.
First of all, for reading (and also: writing) disk on Windows, one has to know the sectorsize, in bytes.
In general this appears to be (an integer multiple of) 512, but one can inquire the drive by using one of the device
related DeviceIoControl functions, namely the one that takes the parameter IOCTL_DISK_GET_DRIVE_GEOMETRY.
All the control codes can be found at MSDN or, sometimes, in the file winnt.h (in many cases already on your hard disk).
Unlike reading from or writing to a (unmounted) disk, you do not need Administrator permission for this inquiry.
1. Getting a device-handle for the disk
First one has to acquire a so called device handle (integer value) for the drive to be used.
One uses the function CreateFileA, from kernel32.dll; when finished, later the device should be closed.
[code]Declare Function CreateFileA Lib “kernel32” (lpFileName AS CString, dwDesiredAccess AS INTEGER, dwShareMode AS INTEGER, lpSecurityAttributes AS PTR, dwCreateDisposition AS INTEGER, dwFlagsAndAttributes AS INTEGER, hTemplateFile AS INTEGER) AS INTEGER
Declare Function CloseHandle Lib “kernel32” (handle AS INTEGER) AS BOOLEAN
[/code]
Inquiring info from a drive only needs a minimal permission.
Define as follows: DIM Inq_Access AS INTEGER and give it the value 0.
But first look if Xojo can access/find the necessary dll:
IF System.IsFunctionAvailable( "DeviceIoControl", "kernel32.dll" ) THEN
MsgBox("Function DeviceIoControl is available")
ELSE
MsgBox("Function DeviceIoControl is NOT available")
END IF
If available, then get the handle for the device. In the case that the drive you are interested in showed up as “Disk1” in
DiskManagement, it will be known as PhysicalDrive1 to the system, to be encoded in a special format: “\\.\PhysicalDrive1”.
In a system with only one hd that built-in drive is known as PhysicalDrive0.
DIM hDisk AS INTEGER
CONST Inq_Access = 0
CONST INVALID_HANDLE = -1
CONST File_Share_Read = &h00000001
CONST File_Share_Write = &h00000002
CONST Open_Existing = &h00000003
CONST NullHandleTemplateFile = 0
hDisk = CreateFileA("\\\\.\\PhysicalDrive1", Inq_Access, File_Share_Read, NIL, Open_Existing, 0, NullHandleTemplateFile)
IF (hDisk = INVALID_HANDLE) THEN
MsgBox("Device could not be opened")
ELSE
MsgBox("Device succesfully opened; device-handle = " + STR(hDisk))
END IF
Note: CreateFileA can also be used to open “normal” files, with the first parameter then represented by the
full, classic, path (like “C:\users\ABCD\test.txt” e.g.).
If succesfull, the next step is to determine the number of bytes per sector of the device.