Author: aandrejevic
Date: Thu Jun 4 22:56:02 2015
New Revision: 68017
URL:
http://svn.reactos.org/svn/reactos?rev=68017&view=rev
Log:
[NTVDM]
Store 8.3 file names in SFT entries. Some programs expect them there.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.h
trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/handle.c
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.c [iso-8859-1] Thu Jun 4
22:56:02 2015
@@ -22,6 +22,45 @@
#include "process.h"
#include "bios/bios.h"
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+static VOID StoreNameInSft(LPCSTR FilePath, PDOS_FILE_DESCRIPTOR Descriptor)
+{
+ CHAR ShortPath[MAX_PATH];
+ PCHAR Name;
+ PCHAR Extension;
+
+ /* Try to get the short path */
+ if (!GetShortPathNameA(FilePath, ShortPath, sizeof(ShortPath)))
+ {
+ /* If it failed, just use the uppercase long path */
+ strncpy(ShortPath, FilePath, sizeof(ShortPath) - 1);
+ _strupr(ShortPath);
+ }
+
+ /* Get the name part */
+ Name = strrchr(ShortPath, '\\');
+ if (Name == NULL) Name = ShortPath;
+
+ /* Find the extension */
+ Extension = strchr(Name, '.');
+
+ if (Extension)
+ {
+ /* Terminate the name string, and move the pointer to after the dot */
+ *Extension++ = 0;
+ }
+
+ /* Copy the name into the SFT descriptor */
+ RtlCopyMemory(Descriptor->FileName, Name, min(strlen(Name), 8));
+
+ if (Extension)
+ {
+ /* Copy the extension too */
+ RtlCopyMemory(&Descriptor->FileName[8], Extension, min(strlen(Extension),
3));
+ }
+}
/* PUBLIC FUNCTIONS ***********************************************************/
@@ -365,20 +404,24 @@
/* Set up the new descriptor */
Descriptor = DosGetFileDescriptor(DescriptorId);
RtlZeroMemory(Descriptor, sizeof(*Descriptor));
+ RtlFillMemory(Descriptor->FileName, sizeof(Descriptor->FileName), '
');
if (Node != NULL)
{
Descriptor->DevicePointer = Node->Driver;
Descriptor->DeviceInfo = Node->DeviceAttributes | FILE_INFO_DEVICE;
+ RtlCopyMemory(Descriptor->FileName, Node->Name.Buffer,
Node->Name.Length);
}
else
{
Descriptor->OpenMode = AccessShareModes;
Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
Descriptor->Size = GetFileSize(FileHandle, NULL);
- Descriptor->OwnerPsp = Sda->CurrentPsp;
Descriptor->Win32Handle = FileHandle;
- }
+ StoreNameInSft(FilePath, Descriptor);
+ }
+
+ Descriptor->OwnerPsp = Sda->CurrentPsp;
/* Open the DOS handle */
DosHandle = DosOpenHandle(DescriptorId);
@@ -441,19 +484,23 @@
/* Set up the new descriptor */
Descriptor = DosGetFileDescriptor(DescriptorId);
RtlZeroMemory(Descriptor, sizeof(*Descriptor));
+ RtlFillMemory(Descriptor->FileName, sizeof(Descriptor->FileName), '
');
if (Node != NULL)
{
Descriptor->DevicePointer = Node->Driver;
Descriptor->DeviceInfo = Node->DeviceAttributes | FILE_INFO_DEVICE;
+ RtlCopyMemory(Descriptor->FileName, Node->Name.Buffer,
Node->Name.Length);
}
else
{
Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
Descriptor->Size = GetFileSize(FileHandle, NULL);
- Descriptor->OwnerPsp = Sda->CurrentPsp;
Descriptor->Win32Handle = FileHandle;
- }
+ StoreNameInSft(FilePath, Descriptor);
+ }
+
+ Descriptor->OwnerPsp = Sda->CurrentPsp;
/* Open the DOS handle */
DosHandle = DosOpenHandle(DescriptorId);
@@ -589,20 +636,24 @@
/* Set up the new descriptor */
Descriptor = DosGetFileDescriptor(DescriptorId);
RtlZeroMemory(Descriptor, sizeof(*Descriptor));
+ RtlFillMemory(Descriptor->FileName, sizeof(Descriptor->FileName), '
');
if (Node != NULL)
{
Descriptor->DevicePointer = Node->Driver;
Descriptor->DeviceInfo = Node->DeviceAttributes | FILE_INFO_DEVICE;
+ RtlCopyMemory(Descriptor->FileName, Node->Name.Buffer,
Node->Name.Length);
}
else
{
Descriptor->OpenMode = AccessShareModes;
Descriptor->Attributes = LOBYTE(GetFileAttributesA(FilePath));
Descriptor->Size = GetFileSize(FileHandle, NULL);
- Descriptor->OwnerPsp = Sda->CurrentPsp;
Descriptor->Win32Handle = FileHandle;
- }
+ StoreNameInSft(FilePath, Descriptor);
+ }
+
+ Descriptor->OwnerPsp = Sda->CurrentPsp;
/* Open the DOS handle */
DosHandle = DosOpenHandle(DescriptorId);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dosfiles.h [iso-8859-1] Thu Jun 4
22:56:02 2015
@@ -26,7 +26,8 @@
DWORD Reserved;
WORD OwnerPsp;
HANDLE Win32Handle;
- BYTE Padding[0x1E - sizeof(HANDLE)];
+ CHAR FileName[11];
+ BYTE Padding[0x13 - sizeof(HANDLE)];
} DOS_FILE_DESCRIPTOR, *PDOS_FILE_DESCRIPTOR;
C_ASSERT(sizeof(DOS_FILE_DESCRIPTOR) == 0x3B);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/handle.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/handle.c [iso-8859-1] Thu Jun 4
22:56:02 2015
@@ -105,6 +105,8 @@
Descriptor->DeviceInfo = Node->DeviceAttributes |
FILE_INFO_DEVICE;
Descriptor->DevicePointer = SysVars->ActiveCon;
+ RtlFillMemory(Descriptor->FileName,
sizeof(Descriptor->FileName), ' ');
+ RtlCopyMemory(Descriptor->FileName, Node->Name.Buffer,
Node->Name.Length);
/* Call the open routine */
if (Node->OpenRoutine) Node->OpenRoutine(Node);