mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +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)
|
||||
{
|
||||
UINT_PTR ItemID;
|
||||
UNICODE_STRING ValueString;
|
||||
USHORT i;
|
||||
|
||||
WCHAR szNoMedia[100];
|
||||
|
@ -170,18 +169,13 @@ UpdateVdmMenuDisks(VOID)
|
|||
|
||||
if (GlobalSettings.FloppyDisks[i].Length != 0 &&
|
||||
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 */
|
||||
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, ValueString.Buffer);
|
||||
_snwprintf(szMenuString2, ARRAYSIZE(szMenuString2), szMenuString1, i, GlobalSettings.FloppyDisks[i].Buffer);
|
||||
szMenuString2[ARRAYSIZE(szMenuString2) - 1] = UNICODE_NULL;
|
||||
ModifyMenuW(hConsoleMenu, ItemID, MF_BYCOMMAND | MF_STRING, ItemID, szMenuString2);
|
||||
|
||||
RtlFreeUnicodeString(&ValueString);
|
||||
|
||||
/* Enable the eject item */
|
||||
EnableMenuItem(hConsoleMenu, ItemID + 1, MF_BYCOMMAND | MF_ENABLED);
|
||||
}
|
||||
|
|
|
@ -419,9 +419,9 @@ VOID MountFloppy(IN ULONG DiskNumber)
|
|||
#define OFN_EX_NOPLACESBAR 0x00000001
|
||||
#endif // (_WIN32_WINNT >= 0x0500)
|
||||
|
||||
BOOLEAN Success;
|
||||
OPENFILENAMEW ofn;
|
||||
WCHAR szFile[MAX_PATH] = L"";
|
||||
UNICODE_STRING ValueString;
|
||||
|
||||
ASSERT(DiskNumber < ARRAYSIZE(GlobalSettings.FloppyDisks));
|
||||
|
||||
|
@ -445,19 +445,18 @@ VOID MountFloppy(IN ULONG DiskNumber)
|
|||
|
||||
/* Free the old string */
|
||||
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
|
||||
RtlFreeAnsiString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||
|
||||
/* Convert the UNICODE string to ANSI and store it */
|
||||
RtlInitEmptyUnicodeString(&ValueString, szFile, wcslen(szFile) * sizeof(WCHAR));
|
||||
ValueString.Length = ValueString.MaximumLength;
|
||||
RtlUnicodeStringToAnsiString(&GlobalSettings.FloppyDisks[DiskNumber], &ValueString, TRUE);
|
||||
/* Reinitialize the string */
|
||||
Success = RtlCreateUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], szFile);
|
||||
ASSERT(Success);
|
||||
|
||||
/* Mount the disk */
|
||||
if (!MountDisk(FLOPPY_DISK, DiskNumber, GlobalSettings.FloppyDisks[DiskNumber].Buffer, !!(ofn.Flags & OFN_READONLY)))
|
||||
{
|
||||
DisplayMessage(L"An error happened when mounting disk %d", DiskNumber);
|
||||
RtlFreeAnsiString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||
RtlInitEmptyAnsiString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
||||
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -476,8 +475,8 @@ VOID EjectFloppy(IN ULONG DiskNumber)
|
|||
/* Free the old string */
|
||||
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
|
||||
{
|
||||
RtlFreeAnsiString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||
RtlInitEmptyAnsiString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
||||
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
|
||||
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber], NULL, 0);
|
||||
}
|
||||
|
||||
/* Refresh the menu state */
|
||||
|
@ -597,9 +596,9 @@ BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
|
|||
{
|
||||
if (!MountDisk(FLOPPY_DISK, i, GlobalSettings.FloppyDisks[i].Buffer, FALSE))
|
||||
{
|
||||
DPRINT1("Failed to mount floppy disk file '%Z'.\n", &GlobalSettings.FloppyDisks[i]);
|
||||
RtlFreeAnsiString(&GlobalSettings.FloppyDisks[i]);
|
||||
RtlInitEmptyAnsiString(&GlobalSettings.FloppyDisks[i], NULL, 0);
|
||||
DPRINT1("Failed to mount floppy disk file '%wZ'.\n", &GlobalSettings.FloppyDisks[i]);
|
||||
RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[i]);
|
||||
RtlInitEmptyUnicodeString(&GlobalSettings.FloppyDisks[i], NULL, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -612,11 +611,11 @@ BOOLEAN EmulatorInitialize(HANDLE ConsoleInput, HANDLE ConsoleOutput)
|
|||
{
|
||||
if (GlobalSettings.HardDisks[i].Length != 0 &&
|
||||
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))
|
||||
{
|
||||
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();
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -499,7 +499,7 @@ RetrieveDisk(IN DISK_TYPE DiskType,
|
|||
BOOLEAN
|
||||
MountDisk(IN DISK_TYPE DiskType,
|
||||
IN ULONG DiskNumber,
|
||||
IN PCSTR FileName,
|
||||
IN PCWSTR FileName,
|
||||
IN BOOLEAN ReadOnly)
|
||||
{
|
||||
BOOLEAN Success = FALSE;
|
||||
|
@ -527,7 +527,7 @@ MountDisk(IN DISK_TYPE DiskType,
|
|||
SetLastError(0); // For debugging purposes
|
||||
if (ReadOnly)
|
||||
{
|
||||
hFile = CreateFileA(FileName,
|
||||
hFile = CreateFileW(FileName,
|
||||
GENERIC_READ,
|
||||
FILE_SHARE_READ,
|
||||
NULL,
|
||||
|
@ -537,7 +537,7 @@ MountDisk(IN DISK_TYPE DiskType,
|
|||
}
|
||||
else
|
||||
{
|
||||
hFile = CreateFileA(FileName,
|
||||
hFile = CreateFileW(FileName,
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0, // No sharing access
|
||||
NULL,
|
||||
|
@ -545,13 +545,13 @@ MountDisk(IN DISK_TYPE DiskType,
|
|||
FILE_ATTRIBUTE_NORMAL,
|
||||
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());
|
||||
|
||||
/* If we failed, bail out */
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -569,7 +569,7 @@ MountDisk(IN DISK_TYPE DiskType,
|
|||
GetLastError() == ERROR_INVALID_FUNCTION)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
SetLastError(0);
|
||||
|
@ -577,14 +577,14 @@ MountDisk(IN DISK_TYPE DiskType,
|
|||
GetLastError() == ERROR_INVALID_FUNCTION)
|
||||
{
|
||||
/* 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;
|
||||
}
|
||||
|
||||
/* Success, mount the image */
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ RetrieveDisk(IN DISK_TYPE DiskType,
|
|||
BOOLEAN
|
||||
MountDisk(IN DISK_TYPE DiskType,
|
||||
IN ULONG DiskNumber,
|
||||
IN PCSTR FileName,
|
||||
IN PCWSTR FileName,
|
||||
IN BOOLEAN ReadOnly);
|
||||
|
||||
BOOLEAN
|
||||
|
|
|
@ -93,8 +93,8 @@ NtVdmConfigureFloppy(IN PWSTR ValueName,
|
|||
IN PVOID Context,
|
||||
IN PVOID EntryContext)
|
||||
{
|
||||
BOOLEAN Success;
|
||||
PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
|
||||
UNICODE_STRING ValueString;
|
||||
ULONG DiskNumber = (ULONG)EntryContext;
|
||||
|
||||
ASSERT(DiskNumber < ARRAYSIZE(Settings->FloppyDisks));
|
||||
|
@ -102,21 +102,20 @@ NtVdmConfigureFloppy(IN PWSTR ValueName,
|
|||
/* 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]);
|
||||
DPRINT1("Floppy Disk %d -- '%wZ' 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);
|
||||
RtlInitEmptyUnicodeString(&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);
|
||||
/* Initialize the string */
|
||||
Success = RtlCreateUnicodeString(&Settings->FloppyDisks[DiskNumber], (PCWSTR)ValueData);
|
||||
ASSERT(Success);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -130,8 +129,8 @@ NtVdmConfigureHDD(IN PWSTR ValueName,
|
|||
IN PVOID Context,
|
||||
IN PVOID EntryContext)
|
||||
{
|
||||
BOOLEAN Success;
|
||||
PNTVDM_SETTINGS Settings = (PNTVDM_SETTINGS)Context;
|
||||
UNICODE_STRING ValueString;
|
||||
ULONG DiskNumber = (ULONG)EntryContext;
|
||||
|
||||
ASSERT(DiskNumber < ARRAYSIZE(Settings->HardDisks));
|
||||
|
@ -139,21 +138,20 @@ NtVdmConfigureHDD(IN PWSTR ValueName,
|
|||
/* Check whether the Hard Disk entry was not already configured */
|
||||
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;
|
||||
}
|
||||
|
||||
/* Check for the type of the value */
|
||||
if (ValueType != REG_SZ)
|
||||
{
|
||||
RtlInitEmptyAnsiString(&Settings->HardDisks[DiskNumber], NULL, 0);
|
||||
RtlInitEmptyUnicodeString(&Settings->HardDisks[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->HardDisks[DiskNumber], &ValueString, TRUE);
|
||||
/* Initialize the string */
|
||||
Success = RtlCreateUnicodeString(&Settings->HardDisks[DiskNumber], (PCWSTR)ValueData);
|
||||
ASSERT(Success);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -291,13 +289,13 @@ FreeGlobalSettings(IN PNTVDM_SETTINGS Settings)
|
|||
for (i = 0; i < ARRAYSIZE(Settings->FloppyDisks); ++i)
|
||||
{
|
||||
if (Settings->FloppyDisks[i].Buffer)
|
||||
RtlFreeAnsiString(&Settings->FloppyDisks[i]);
|
||||
RtlFreeUnicodeString(&Settings->FloppyDisks[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(Settings->HardDisks); ++i)
|
||||
{
|
||||
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 RomFiles;
|
||||
ANSI_STRING FloppyDisks[2];
|
||||
ANSI_STRING HardDisks[4];
|
||||
UNICODE_STRING FloppyDisks[2];
|
||||
UNICODE_STRING HardDisks[4];
|
||||
} NTVDM_SETTINGS, *PNTVDM_SETTINGS;
|
||||
|
||||
extern NTVDM_SETTINGS GlobalSettings;
|
||||
|
|
Loading…
Reference in a new issue