From 746c7e4435d1e3131f185125b162afbcdc129462 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Mon, 28 Sep 2015 22:15:06 +0000 Subject: [PATCH] [NTVDM] - Add floppy image automount support from the registry, as it was done for HDDs in r69390 (it's really copy-paste & adaptation of the existing code). - Increase HDD number support from 1 to 4 (maximum) for INT 13h. svn path=/trunk/; revision=69411 --- .../mvdm/ntvdm/bios/bios32/dskbios32.c | 5 +- reactos/subsystems/mvdm/ntvdm/emulator.c | 11 ++++ reactos/subsystems/mvdm/ntvdm/ntvdm.c | 63 +++++++++++++++++++ reactos/subsystems/mvdm/ntvdm/ntvdm.h | 1 + 4 files changed, 79 insertions(+), 1 deletion(-) diff --git a/reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c b/reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c index 0ceada98675..f2a1533af0f 100644 --- a/reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c +++ b/reactos/subsystems/mvdm/ntvdm/bios/bios32/dskbios32.c @@ -32,7 +32,7 @@ // they will be arrays of objects containing disk information needed by // the BIOS only. static PDISK_IMAGE FloppyDrive[2] = {NULL}; -static PDISK_IMAGE HardDrive[1] = {NULL}; +static PDISK_IMAGE HardDrive[4] = {NULL}; #pragma pack(push, 1) @@ -689,6 +689,9 @@ BOOLEAN DiskBios32Initialize(VOID) FloppyDrive[0] = RetrieveDisk(FLOPPY_DISK, 0); FloppyDrive[1] = RetrieveDisk(FLOPPY_DISK, 1); HardDrive[0] = RetrieveDisk(HARD_DISK, 0); + HardDrive[1] = RetrieveDisk(HARD_DISK, 1); + HardDrive[2] = RetrieveDisk(HARD_DISK, 2); + HardDrive[3] = RetrieveDisk(HARD_DISK, 3); return TRUE; } diff --git a/reactos/subsystems/mvdm/ntvdm/emulator.c b/reactos/subsystems/mvdm/ntvdm/emulator.c index 5ff78d8a76b..344f64e5af0 100644 --- a/reactos/subsystems/mvdm/ntvdm/emulator.c +++ b/reactos/subsystems/mvdm/ntvdm/emulator.c @@ -553,6 +553,17 @@ BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput) return FALSE; } + /* Mount the available floppy disks */ + for (i = 0; i < ARRAYSIZE(GlobalSettings.FloppyDisks); ++i) + { + if (GlobalSettings.FloppyDisks[i].Length != 0 && + GlobalSettings.FloppyDisks[i].Buffer && + GlobalSettings.FloppyDisks[i].Buffer != '\0') + { + MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE); + } + } + /* Mount the available hard disks */ for (i = 0; i < ARRAYSIZE(GlobalSettings.HardDisks); ++i) { diff --git a/reactos/subsystems/mvdm/ntvdm/ntvdm.c b/reactos/subsystems/mvdm/ntvdm/ntvdm.c index 709c92aeebc..70948070dd5 100644 --- a/reactos/subsystems/mvdm/ntvdm/ntvdm.c +++ b/reactos/subsystems/mvdm/ntvdm/ntvdm.c @@ -333,6 +333,43 @@ NtVdmConfigureRom(IN PWSTR ValueName, return STATUS_SUCCESS; } +static NTSTATUS +NTAPI +NtVdmConfigureFloppy(IN PWSTR ValueName, + IN ULONG ValueType, + IN PVOID ValueData, + IN ULONG ValueLength, + IN PVOID Context, + IN PVOID EntryContext) +{ + PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context; + UNICODE_STRING ValueString; + ULONG DiskNumber = (ULONG)EntryContext; + + ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks)); + + /* Check whether the Hard Disk entry was not already configured */ + if (Settings->FloppyDisks[DiskNumber].Buffer != NULL) + { + DPRINT1("Floppy Disk %d -- '%Z' already configured\n", DiskNumber, &Settings->FloppyDisks[DiskNumber]); + return STATUS_SUCCESS; + } + + /* Check for the type of the value */ + if (ValueType != REG_SZ) + { + RtlInitEmptyAnsiString(&Settings->FloppyDisks[DiskNumber], NULL, 0); + return STATUS_SUCCESS; + } + + /* Convert the UNICODE string to ANSI and store it */ + RtlInitEmptyUnicodeString(&ValueString, (PWCHAR)ValueData, ValueLength); + ValueString.Length = ValueString.MaximumLength; + RtlUnicodeStringToAnsiString(&Settings->FloppyDisks[DiskNumber], &ValueString, TRUE); + + return STATUS_SUCCESS; +} + static NTSTATUS NTAPI NtVdmConfigureHDD(IN PWSTR ValueName, @@ -393,6 +430,26 @@ NtVdmConfigurationTable[] = 0 }, + { + NtVdmConfigureFloppy, + 0, + L"FloppyDisk0", + (PVOID)0, + REG_NONE, + NULL, + 0 + }, + + { + NtVdmConfigureFloppy, + 0, + L"FloppyDisk1", + (PVOID)1, + REG_NONE, + NULL, + 0 + }, + { NtVdmConfigureHDD, 0, @@ -480,6 +537,12 @@ FreeGlobalSettings(IN PNTVDM_SETTINGS Settings) if (Settings->RomFiles.Buffer) RtlFreeAnsiString(&Settings->RomFiles); + for (i = 0; i < ARRAYSIZE(Settings->FloppyDisks); ++i) + { + if (Settings->FloppyDisks[i].Buffer) + RtlFreeAnsiString(&Settings->FloppyDisks[i]); + } + for (i = 0; i < ARRAYSIZE(Settings->HardDisks); ++i) { if (Settings->HardDisks[i].Buffer) diff --git a/reactos/subsystems/mvdm/ntvdm/ntvdm.h b/reactos/subsystems/mvdm/ntvdm/ntvdm.h index d50c854fe37..d43a26e8914 100644 --- a/reactos/subsystems/mvdm/ntvdm/ntvdm.h +++ b/reactos/subsystems/mvdm/ntvdm/ntvdm.h @@ -76,6 +76,7 @@ typedef struct _NTVDM_SETTINGS { ANSI_STRING BiosFileName; ANSI_STRING RomFiles; + ANSI_STRING FloppyDisks[2]; ANSI_STRING HardDisks[4]; } NTVDM_SETTINGS, *PNTVDM_SETTINGS;