Author: hbelusca
Date: Sat Nov 7 20:19:32 2015
New Revision: 69840
URL:
http://svn.reactos.org/svn/reactos?rev=69840&view=rev
Log:
[NTVDM]: Natively use UNICODE strings for the disk mounting system.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/console/console.c
trunk/reactos/subsystems/mvdm/ntvdm/emulator.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.c
trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.h
trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c
trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h
Modified: trunk/reactos/subsystems/mvdm/ntvdm/console/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cons…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/console/console.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/console/console.c [iso-8859-1] Sat Nov 7 20:19:32
2015
@@ -146,7 +146,6 @@
UpdateVdmMenuDisks(VOID)
{
UINT_PTR ItemID;
- UNICODE_STRING ValueString;
USHORT i;
WCHAR szNoMedia[100];
@@ -170,17 +169,12 @@
if (GlobalSettings.FloppyDisks[i].Length != 0 &&
GlobalSettings.FloppyDisks[i].Buffer &&
- GlobalSettings.FloppyDisks[i].Buffer != '\0')
- {
- /* Convert the ANSI string to UNICODE */
- RtlAnsiStringToUnicodeString(&ValueString,
&GlobalSettings.FloppyDisks[i], TRUE);
-
+ GlobalSettings.FloppyDisks[i].Buffer != L'\0')
+ {
/* 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);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/emulator.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/emul…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/emulator.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/emulator.c [iso-8859-1] Sat Nov 7 20:19:32 2015
@@ -419,9 +419,9 @@
#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 @@
/* Free the old string */
if (GlobalSettings.FloppyDisks[DiskNumber].Buffer)
- RtlFreeAnsiString(&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);
+ RtlFreeUnicodeString(&GlobalSettings.FloppyDisks[DiskNumber]);
+
+ /* 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 @@
/* 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 @@
{
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 @@
{
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;
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.c [iso-8859-1] Sat Nov 7 20:19:32
2015
@@ -499,7 +499,7 @@
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 @@
SetLastError(0); // For debugging purposes
if (ReadOnly)
{
- hFile = CreateFileA(FileName,
+ hFile = CreateFileW(FileName,
GENERIC_READ,
FILE_SHARE_READ,
NULL,
@@ -537,7 +537,7 @@
}
else
{
- hFile = CreateFileA(FileName,
+ hFile = CreateFileW(FileName,
GENERIC_READ | GENERIC_WRITE,
0, // No sharing access
NULL,
@@ -545,13 +545,13 @@
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 @@
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 @@
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;
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/hard…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/hardware/disk.h [iso-8859-1] Sat Nov 7 20:19:32
2015
@@ -78,7 +78,7 @@
BOOLEAN
MountDisk(IN DISK_TYPE DiskType,
IN ULONG DiskNumber,
- IN PCSTR FileName,
+ IN PCWSTR FileName,
IN BOOLEAN ReadOnly);
BOOLEAN
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ntvd…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.c [iso-8859-1] Sat Nov 7 20:19:32 2015
@@ -93,8 +93,8 @@
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 @@
/* 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 @@
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 @@
/* 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 @@
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]);
}
}
Modified: trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/ntvd…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/ntvdm.h [iso-8859-1] Sat Nov 7 20:19:32 2015
@@ -74,8 +74,8 @@
{
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;