https://git.reactos.org/?p=reactos.git;a=commitdiff;h=44898a4ea4b445d57063f…
commit 44898a4ea4b445d57063fe281b1785164887b754
Author: Mark Jansen <mark.jansen(a)reactos.org>
AuthorDate: Mon Oct 8 23:12:19 2018 +0200
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sat Oct 20 00:14:44 2018 +0200
[NTVDM] Implement INT21, AX=4408, Determine if a block device is removable.
---
subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c | 70 +++++++++++++++++++++++++-
1 file changed, 69 insertions(+), 1 deletion(-)
diff --git a/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
b/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
index fea885a71b..b636e225db 100644
--- a/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
+++ b/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
@@ -1125,11 +1125,79 @@ BOOLEAN DosUnlockFile(WORD DosHandle, DWORD Offset, DWORD Size)
return TRUE;
}
+BOOLEAN DosDeviceIoControlDrive(WORD DriveNumber, BYTE ControlCode, DWORD Buffer, PWORD
Result)
+{
+ CHAR RootPath[] = "?:\\";
+
+ if (DriveNumber == 0x00)
+ RootPath[0] = 'A' + Sda->CurrentDrive;
+ else
+ RootPath[0] = 'A' + DriveNumber - 1;
+
+ switch (ControlCode)
+ {
+ case 0x04:
+ DPRINT1("UNIMPLEMENTED INT 21h, 4404h, Read from block device
%s\n", RootPath);
+ Sda->LastErrorCode = ERROR_INVALID_FUNCTION;
+ break;
+ case 0x05:
+ DPRINT1("UNIMPLEMENTED INT 21h, 4405h, Write block device control string
%s\n", RootPath);
+ Sda->LastErrorCode = ERROR_INVALID_FUNCTION;
+ break;
+ case 0x08:
+ {
+ DWORD DriveType = GetDriveTypeA(RootPath);
+
+ switch (DriveType)
+ {
+ case DRIVE_UNKNOWN:
+ case DRIVE_NO_ROOT_DIR:
+ default:
+ DPRINT1("INT 21h, 4408h, %s -> DriveType = 0x%x\n",
RootPath, DriveType);
+ *Result = 0x000f;
+ return TRUE;
+ case DRIVE_REMOVABLE:
+ case DRIVE_CDROM:
+ *Result = 0x0000;
+ return TRUE;
+ case DRIVE_FIXED:
+ *Result = 0x0001;
+ return TRUE;
+ case DRIVE_REMOTE:
+ case DRIVE_RAMDISK: // ??
+ break;
+ }
+ Sda->LastErrorCode = ERROR_INVALID_FUNCTION;
+ return FALSE;
+ }
+ case 0x09:
+ DPRINT1("UNIMPLEMENTED INT 21h, 4409h, Determine if a logical device is
local or remote %s\n", RootPath);
+ Sda->LastErrorCode = ERROR_INVALID_FUNCTION;
+ return FALSE;
+ default:
+ assert(0);
+ break;
+ }
+
+ return FALSE;
+}
+
BOOLEAN DosDeviceIoControl(WORD FileHandle, BYTE ControlCode, DWORD Buffer, PWORD
Length)
{
- PDOS_FILE_DESCRIPTOR Descriptor = DosGetHandleFileDescriptor(FileHandle);
+ PDOS_FILE_DESCRIPTOR Descriptor;
PDOS_DEVICE_NODE Node = NULL;
+ switch (ControlCode)
+ {
+ case 0x04:
+ case 0x05:
+ case 0x08:
+ case 0x09:
+ return DosDeviceIoControlDrive(FileHandle, ControlCode, Buffer, Length);
+ }
+
+ Descriptor = DosGetHandleFileDescriptor(FileHandle);
+
if (!Descriptor)
{
Sda->LastErrorCode = ERROR_INVALID_HANDLE;