Store 8.3 file names in SFT entries. Some programs expect them there.


svn path=/trunk/; revision=68017
This commit is contained in:
Aleksandar Andrejevic 2015-06-04 22:56:02 +00:00
parent e97fb8ee65
commit 8d62f932c5
3 changed files with 58 additions and 4 deletions

View file

@ -23,6 +23,45 @@
#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 ***********************************************************/
BYTE DosFindFreeDescriptor(VOID)
@ -365,21 +404,25 @@ WORD DosCreateFileEx(LPWORD Handle,
/* 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);
if (DosHandle == INVALID_DOS_HANDLE)
@ -441,20 +484,24 @@ WORD DosCreateFile(LPWORD Handle,
/* 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);
if (DosHandle == INVALID_DOS_HANDLE)
@ -589,21 +636,25 @@ WORD DosOpenFile(LPWORD Handle,
/* 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);
if (DosHandle == INVALID_DOS_HANDLE)

View file

@ -26,7 +26,8 @@ typedef struct _DOS_FILE_DESCRIPTOR
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);

View file

@ -105,6 +105,8 @@ VOID DosCopyHandleTable(LPBYTE DestinationTable)
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);