mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
[NTVDM]: Natively use UNICODE strings for the disk mounting system.
svn path=/trunk/; revision=69840
This commit is contained in:
parent
c5bfef5f06
commit
1eff622a45
6 changed files with 41 additions and 50 deletions
|
@ -146,7 +146,6 @@ UpdateVdmMenuMouse(VOID)
|
||||||
UpdateVdmMenuDisks(VOID)
|
UpdateVdmMenuDisks(VOID)
|
||||||
{
|
{
|
||||||
UINT_PTR ItemID;
|
UINT_PTR ItemID;
|
||||||
UNICODE_STRING ValueString;
|
|
||||||
USHORT i;
|
USHORT i;
|
||||||
|
|
||||||
WCHAR szNoMedia[100];
|
WCHAR szNoMedia[100];
|
||||||
|
@ -170,18 +169,13 @@ UpdateVdmMenuDisks(VOID)
|
||||||
|
|
||||||
if (GlobalSettings.FloppyDisks[i].Length != 0 &&
|
if (GlobalSettings.FloppyDisks[i].Length != 0 &&
|
||||||
GlobalSettings.FloppyDisks[i].Buffer &&
|
GlobalSettings.FloppyDisks[i].Buffer &&
|
||||||
GlobalSettings.FloppyDisks[i].Buffer != '\0')
|
GlobalSettings.FloppyDisks[i].Buffer != L'\0')
|
||||||
{
|
{
|
||||||
/* Convert the ANSI string to UNICODE */
|
|
||||||
RtlAnsiStringToUnicodeString(&ValueString, &GlobalSettings.FloppyDisks[i], TRUE);
|
|
||||||
|
|
||||||
/* Update item text */
|
/* Update item text */
|
||||||
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, ValueString.Buffer);
|
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, GlobalSettings.FloppyDisks[i].Buffer);
|
||||||
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
||||||
ModifyMenuW(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
|
ModifyMenuW(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
|
||||||
|
|
||||||
RtlFreeUnicodeString(&ValueString);
|
|
||||||
|
|
||||||
/* Enable the eject item */
|
/* Enable the eject item */
|
||||||
EnableMenuItem(hConsoleMenu, ItemID + 1, MF_BYCOMMAND | MF_ENABLED);
|
EnableMenuItem(hConsoleMenu, ItemID + 1, MF_BYCOMMAND | MF_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
|
@ -419,9 +419,9 @@ VOID MountFloppy(IN ULONG DiskNumber)
|
||||||
#define OFN_EX_NOPLACESBAR 0x00000001
|
#define OFN_EX_NOPLACESBAR 0x00000001
|
||||||
#endif // (_WIN32_WINNT >= 0x0500)
|
#endif // (_WIN32_WINNT >= 0x0500)
|
||||||
|
|
||||||
|
BOOLEAN Success;
|
||||||
OPENFILENAMEW ofn;
|
OPENFILENAMEW ofn;
|
||||||
WCHAR szFile[MAX_PATH] = L"";
|
WCHAR szFile[MAX_PATH] = L"";
|
||||||
UNICODE_STRING ValueString;
|
|
||||||
|
|
||||||
ASSERT(DiskNumber < ARRAYSIZE(GlobalSettings.FloppyDisks));
|
ASSERT(DiskNumber < ARRAYSIZE(GlobalSettings.FloppyDisks));
|
||||||
|
|
||||||
|
@ -445,19 +445,18 @@ VOID MountFloppy(IN ULONG DiskNumber)
|
||||||
|
|
||||||
/* Free the old string */
|
/* Free the old string */
|
||||||
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
|
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
|
||||||
RtlFreeAnsiString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||||
|
|
||||||
/* Convert the UNICODE string to ANSI and store it */
|
/* Reinitialize the string */
|
||||||
RtlInitEmptyUnicodeString(&ValueString, szFile, wcslen(szFile) * sizeof(WCHAR));
|
Success = RtlCreateUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], szFile);
|
||||||
ValueString.Length = ValueString.MaximumLength;
|
ASSERT(Success);
|
||||||
RtlUnicodeStringToAnsiString(&GlobalSettings.FloppyDisks[DiskNumber], &ValueString, TRUE);
|
|
||||||
|
|
||||||
/* Mount the disk */
|
/* Mount the disk */
|
||||||
if (!MountDisk(FLOPPY_DISK, DiskNumber, GlobalSettings.FloppyDisks[DiskNumber].Buffer, !!(ofn.Flags & OFN_READONLY)))
|
if (!MountDisk(FLOPPY_DISK, DiskNumber, GlobalSettings.FloppyDisks[DiskNumber].Buffer, !!(ofn.Flags & OFN_READONLY)))
|
||||||
{
|
{
|
||||||
DisplayMessage(L"An error happened when mounting disk %d", DiskNumber);
|
DisplayMessage(L"An error happened when mounting disk %d", DiskNumber);
|
||||||
RtlFreeAnsiString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||||
RtlInitEmptyAnsiString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,8 +475,8 @@ VOID EjectFloppy(IN ULONG DiskNumber)
|
||||||
/* Free the old string */
|
/* Free the old string */
|
||||||
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
|
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
|
||||||
{
|
{
|
||||||
RtlFreeAnsiString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||||
RtlInitEmptyAnsiString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Refresh the menu state */
|
/* Refresh the menu state */
|
||||||
|
@ -597,9 +596,9 @@ BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
|
||||||
{
|
{
|
||||||
if (!MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE))
|
if (!MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE))
|
||||||
{
|
{
|
||||||
DPRINT1("Failed to mount floppy disk file '%Z'.\n", &GlobalSettings.FloppyDisks[i]);
|
DPRINT1("Failed to mount floppy disk file '%wZ'.\n", &GlobalSettings.FloppyDisks[i]);
|
||||||
RtlFreeAnsiString(&GlobalSettings.FloppyDisks[i]);
|
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[i]);
|
||||||
RtlInitEmptyAnsiString(&GlobalSettings.FloppyDisks[i], NULL, 0);
|
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[i], NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -612,11 +611,11 @@ BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
|
||||||
{
|
{
|
||||||
if (GlobalSettings.HardDisks[i].Length != 0 &&
|
if (GlobalSettings.HardDisks[i].Length != 0 &&
|
||||||
GlobalSettings.HardDisks[i].Buffer &&
|
GlobalSettings.HardDisks[i].Buffer &&
|
||||||
GlobalSettings.HardDisks[i].Buffer != '\0')
|
GlobalSettings.HardDisks[i].Buffer != L'\0')
|
||||||
{
|
{
|
||||||
if (!MountDisk(HARD_DISK, i, GlobalSettings.HardDisks[i].Buffer, FALSE))
|
if (!MountDisk(HARD_DISK, i, GlobalSettings.HardDisks[i].Buffer, FALSE))
|
||||||
{
|
{
|
||||||
wprintf(L"FATAL: Failed to mount hard disk file '%Z'.\n", &GlobalSettings.HardDisks[i]);
|
wprintf(L"FATAL: Failed to mount hard disk file '%wZ'.\n", &GlobalSettings.HardDisks[i]);
|
||||||
EmulatorCleanup();
|
EmulatorCleanup();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,7 +499,7 @@ RetrieveDisk(IN DISK_TYPE DiskType,
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
MountDisk(IN DISK_TYPE DiskType,
|
MountDisk(IN DISK_TYPE DiskType,
|
||||||
IN ULONG DiskNumber,
|
IN ULONG DiskNumber,
|
||||||
IN PCSTR FileName,
|
IN PCWSTR FileName,
|
||||||
IN BOOLEAN ReadOnly)
|
IN BOOLEAN ReadOnly)
|
||||||
{
|
{
|
||||||
BOOLEAN Success = FALSE;
|
BOOLEAN Success = FALSE;
|
||||||
|
@ -527,7 +527,7 @@ MountDisk(IN DISK_TYPE DiskType,
|
||||||
SetLastError(0); // For debugging purposes
|
SetLastError(0); // For debugging purposes
|
||||||
if (ReadOnly)
|
if (ReadOnly)
|
||||||
{
|
{
|
||||||
hFile = CreateFileA(FileName,
|
hFile = CreateFileW(FileName,
|
||||||
GENERIC_READ,
|
GENERIC_READ,
|
||||||
FILE_SHARE_READ,
|
FILE_SHARE_READ,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -537,7 +537,7 @@ MountDisk(IN DISK_TYPE DiskType,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hFile = CreateFileA(FileName,
|
hFile = CreateFileW(FileName,
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
0, // No sharing access
|
0, // No sharing access
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -545,13 +545,13 @@ MountDisk(IN DISK_TYPE DiskType,
|
||||||
FILE_ATTRIBUTE_NORMAL,
|
FILE_ATTRIBUTE_NORMAL,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
DPRINT1("File '%s' opening %s ; GetLastError() = %u\n",
|
DPRINT1("File '%S' opening %s ; GetLastError() = %u\n",
|
||||||
FileName, hFile != INVALID_HANDLE_VALUE ? "succeeded" : "failed", GetLastError());
|
FileName, hFile != INVALID_HANDLE_VALUE ? "succeeded" : "failed", GetLastError());
|
||||||
|
|
||||||
/* If we failed, bail out */
|
/* If we failed, bail out */
|
||||||
if (hFile == INVALID_HANDLE_VALUE)
|
if (hFile == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
DisplayMessage(L"MountDisk: Error when opening disk file '%S' (Error: %u).", FileName, GetLastError());
|
DisplayMessage(L"MountDisk: Error when opening disk file '%s' (Error: %u).", FileName, GetLastError());
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -569,7 +569,7 @@ MountDisk(IN DISK_TYPE DiskType,
|
||||||
GetLastError() == ERROR_INVALID_FUNCTION)
|
GetLastError() == ERROR_INVALID_FUNCTION)
|
||||||
{
|
{
|
||||||
/* Objects other than real files are not supported */
|
/* Objects other than real files are not supported */
|
||||||
DisplayMessage(L"MountDisk: '%S' is not a valid disk file.", FileName);
|
DisplayMessage(L"MountDisk: '%s' is not a valid disk file.", FileName);
|
||||||
goto Quit;
|
goto Quit;
|
||||||
}
|
}
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
|
@ -577,14 +577,14 @@ MountDisk(IN DISK_TYPE DiskType,
|
||||||
GetLastError() == ERROR_INVALID_FUNCTION)
|
GetLastError() == ERROR_INVALID_FUNCTION)
|
||||||
{
|
{
|
||||||
/* Objects other than real files are not supported */
|
/* Objects other than real files are not supported */
|
||||||
DisplayMessage(L"MountDisk: '%S' is not a valid disk file.", FileName);
|
DisplayMessage(L"MountDisk: '%s' is not a valid disk file.", FileName);
|
||||||
goto Quit;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Success, mount the image */
|
/* Success, mount the image */
|
||||||
if (!DiskMountInfo[DiskType].MountDiskHelper(DiskImage, hFile))
|
if (!DiskMountInfo[DiskType].MountDiskHelper(DiskImage, hFile))
|
||||||
{
|
{
|
||||||
DisplayMessage(L"MountDisk: Failed to mount disk file '%S' in 0x%p.", FileName, DiskImage);
|
DisplayMessage(L"MountDisk: Failed to mount disk file '%s' in 0x%p.", FileName, DiskImage);
|
||||||
goto Quit;
|
goto Quit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ RetrieveDisk(IN DISK_TYPE DiskType,
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
MountDisk(IN DISK_TYPE DiskType,
|
MountDisk(IN DISK_TYPE DiskType,
|
||||||
IN ULONG DiskNumber,
|
IN ULONG DiskNumber,
|
||||||
IN PCSTR FileName,
|
IN PCWSTR FileName,
|
||||||
IN BOOLEAN ReadOnly);
|
IN BOOLEAN ReadOnly);
|
||||||
|
|
||||||
BOOLEAN
|
BOOLEAN
|
||||||
|
|
|
@ -93,8 +93,8 @@ NtVdmConfigureFloppy(IN PWSTR ValueName,
|
||||||
IN PVOID Context,
|
IN PVOID Context,
|
||||||
IN PVOID EntryContext)
|
IN PVOID EntryContext)
|
||||||
{
|
{
|
||||||
|
BOOLEAN Success;
|
||||||
PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
|
PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
|
||||||
UNICODE_STRING ValueString;
|
|
||||||
ULONG DiskNumber = (ULONG)EntryContext;
|
ULONG DiskNumber = (ULONG)EntryContext;
|
||||||
|
|
||||||
ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks));
|
ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks));
|
||||||
|
@ -102,21 +102,20 @@ NtVdmConfigureFloppy(IN PWSTR ValueName,
|
||||||
/* Check whether the Hard Disk entry was not already configured */
|
/* Check whether the Hard Disk entry was not already configured */
|
||||||
if (Settings->FloppyDisks[DiskNumber].Buffer != NULL)
|
if (Settings->FloppyDisks[DiskNumber].Buffer != NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("Floppy Disk %d -- '%Z' already configured\n", DiskNumber, &Settings->FloppyDisks[DiskNumber]);
|
DPRINT1("Floppy Disk %d -- '%wZ' already configured\n", DiskNumber, &Settings->FloppyDisks[DiskNumber]);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for the type of the value */
|
/* Check for the type of the value */
|
||||||
if (ValueType != REG_SZ)
|
if (ValueType != REG_SZ)
|
||||||
{
|
{
|
||||||
RtlInitEmptyAnsiString(&Settings->FloppyDisks[DiskNumber], NULL, 0);
|
RtlInitEmptyUnicodeString(&Settings->FloppyDisks[DiskNumber], NULL, 0);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the UNICODE string to ANSI and store it */
|
/* Initialize the string */
|
||||||
RtlInitEmptyUnicodeString(&ValueString, (PWCHAR)ValueData, ValueLength);
|
Success = RtlCreateUnicodeString(&Settings->FloppyDisks[DiskNumber], (PCWSTR)ValueData);
|
||||||
ValueString.Length = ValueString.MaximumLength;
|
ASSERT(Success);
|
||||||
RtlUnicodeStringToAnsiString(&Settings->FloppyDisks[DiskNumber], &ValueString, TRUE);
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -130,8 +129,8 @@ NtVdmConfigureHDD(IN PWSTR ValueName,
|
||||||
IN PVOID Context,
|
IN PVOID Context,
|
||||||
IN PVOID EntryContext)
|
IN PVOID EntryContext)
|
||||||
{
|
{
|
||||||
|
BOOLEAN Success;
|
||||||
PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
|
PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
|
||||||
UNICODE_STRING ValueString;
|
|
||||||
ULONG DiskNumber = (ULONG)EntryContext;
|
ULONG DiskNumber = (ULONG)EntryContext;
|
||||||
|
|
||||||
ASSERT(DiskNumber < ARRAYSIZE(Settings->HardDisks));
|
ASSERT(DiskNumber < ARRAYSIZE(Settings->HardDisks));
|
||||||
|
@ -139,21 +138,20 @@ NtVdmConfigureHDD(IN PWSTR ValueName,
|
||||||
/* Check whether the Hard Disk entry was not already configured */
|
/* Check whether the Hard Disk entry was not already configured */
|
||||||
if (Settings->HardDisks[DiskNumber].Buffer != NULL)
|
if (Settings->HardDisks[DiskNumber].Buffer != NULL)
|
||||||
{
|
{
|
||||||
DPRINT1("Hard Disk %d -- '%Z' already configured\n", DiskNumber, &Settings->HardDisks[DiskNumber]);
|
DPRINT1("Hard Disk %d -- '%wZ' already configured\n", DiskNumber, &Settings->HardDisks[DiskNumber]);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for the type of the value */
|
/* Check for the type of the value */
|
||||||
if (ValueType != REG_SZ)
|
if (ValueType != REG_SZ)
|
||||||
{
|
{
|
||||||
RtlInitEmptyAnsiString(&Settings->HardDisks[DiskNumber], NULL, 0);
|
RtlInitEmptyUnicodeString(&Settings->HardDisks[DiskNumber], NULL, 0);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert the UNICODE string to ANSI and store it */
|
/* Initialize the string */
|
||||||
RtlInitEmptyUnicodeString(&ValueString, (PWCHAR)ValueData, ValueLength);
|
Success = RtlCreateUnicodeString(&Settings->HardDisks[DiskNumber], (PCWSTR)ValueData);
|
||||||
ValueString.Length = ValueString.MaximumLength;
|
ASSERT(Success);
|
||||||
RtlUnicodeStringToAnsiString(&Settings->HardDisks[DiskNumber], &ValueString, TRUE);
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -291,13 +289,13 @@ FreeGlobalSettings(IN PNTVDM_SETTINGS Settings)
|
||||||
for (i = 0; i < ARRAYSIZE(Settings->FloppyDisks); ++i)
|
for (i = 0; i < ARRAYSIZE(Settings->FloppyDisks); ++i)
|
||||||
{
|
{
|
||||||
if (Settings->FloppyDisks[i].Buffer)
|
if (Settings->FloppyDisks[i].Buffer)
|
||||||
RtlFreeAnsiString(&Settings->FloppyDisks[i]);
|
RtlFreeUnicodeString(&Settings->FloppyDisks[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(Settings->HardDisks); ++i)
|
for (i = 0; i < ARRAYSIZE(Settings->HardDisks); ++i)
|
||||||
{
|
{
|
||||||
if (Settings->HardDisks[i].Buffer)
|
if (Settings->HardDisks[i].Buffer)
|
||||||
RtlFreeAnsiString(&Settings->HardDisks[i]);
|
RtlFreeUnicodeString(&Settings->HardDisks[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,8 @@ typedef struct _NTVDM_SETTINGS
|
||||||
{
|
{
|
||||||
ANSI_STRING BiosFileName;
|
ANSI_STRING BiosFileName;
|
||||||
ANSI_STRING RomFiles;
|
ANSI_STRING RomFiles;
|
||||||
ANSI_STRING FloppyDisks[2];
|
UNICODE_STRING FloppyDisks[2];
|
||||||
ANSI_STRING HardDisks[4];
|
UNICODE_STRING HardDisks[4];
|
||||||
} NTVDM_SETTINGS, *PNTVDM_SETTINGS;
|
} NTVDM_SETTINGS, *PNTVDM_SETTINGS;
|
||||||
|
|
||||||
extern NTVDM_SETTINGS GlobalSettings;
|
extern NTVDM_SETTINGS GlobalSettings;
|
||||||
|
|
Loading…
Reference in a new issue