mirror of
https://github.com/reactos/reactos.git
synced 2025-07-04 10:01:23 +00:00
[NTVDM]: Fix current directory stuff.
svn path=/trunk/; revision=67620
This commit is contained in:
parent
86ba2faa4e
commit
020e3f1630
1 changed files with 41 additions and 16 deletions
|
@ -38,7 +38,7 @@
|
||||||
|
|
||||||
CALLBACK16 DosContext;
|
CALLBACK16 DosContext;
|
||||||
|
|
||||||
/*static*/ BYTE CurrentDrive;
|
/*static*/ BYTE CurrentDrive = 0x00;
|
||||||
static CHAR LastDrive = 'Z'; // The last drive can be redefined with the LASTDRIVE command. At the moment, set the real maximum possible, 'Z'.
|
static CHAR LastDrive = 'Z'; // The last drive can be redefined with the LASTDRIVE command. At the moment, set the real maximum possible, 'Z'.
|
||||||
static CHAR CurrentDirectories[NUM_DRIVES][DOS_DIR_LENGTH];
|
static CHAR CurrentDirectories[NUM_DRIVES][DOS_DIR_LENGTH];
|
||||||
static PBYTE InDos;
|
static PBYTE InDos;
|
||||||
|
@ -81,6 +81,8 @@ static BOOLEAN DosChangeDirectory(LPSTR Directory)
|
||||||
BYTE DriveNumber;
|
BYTE DriveNumber;
|
||||||
DWORD Attributes;
|
DWORD Attributes;
|
||||||
LPSTR Path;
|
LPSTR Path;
|
||||||
|
CHAR CurrentDirectory[MAX_PATH];
|
||||||
|
CHAR DosDirectory[DOS_DIR_LENGTH];
|
||||||
|
|
||||||
/* Make sure the directory path is not too long */
|
/* Make sure the directory path is not too long */
|
||||||
if (strlen(Directory) >= DOS_DIR_LENGTH)
|
if (strlen(Directory) >= DOS_DIR_LENGTH)
|
||||||
|
@ -89,14 +91,23 @@ static BOOLEAN DosChangeDirectory(LPSTR Directory)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the drive number */
|
/* Check whether the directory string is of format "?:..." */
|
||||||
DriveNumber = Directory[0] - 'A';
|
if (strlen(Directory) >= 2 && Directory[1] == ':')
|
||||||
|
|
||||||
/* Make sure the drive exists */
|
|
||||||
if (DriveNumber > (LastDrive - 'A'))
|
|
||||||
{
|
{
|
||||||
DosLastError = ERROR_PATH_NOT_FOUND;
|
/* Get the drive number */
|
||||||
return FALSE;
|
DriveNumber = RtlUpperChar(Directory[0]) - 'A';
|
||||||
|
|
||||||
|
/* Make sure the drive exists */
|
||||||
|
if (DriveNumber > (LastDrive - 'A'))
|
||||||
|
{
|
||||||
|
DosLastError = ERROR_PATH_NOT_FOUND;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Keep the current drive number */
|
||||||
|
DriveNumber = CurrentDrive;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the file attributes */
|
/* Get the file attributes */
|
||||||
|
@ -121,8 +132,22 @@ static BOOLEAN DosChangeDirectory(LPSTR Directory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get the (possibly new) current directory (needed if we specified a relative directory) */
|
||||||
|
if (!GetCurrentDirectoryA(sizeof(CurrentDirectory), CurrentDirectory))
|
||||||
|
{
|
||||||
|
// TODO: Use some kind of default path?
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert it to a DOS path */
|
||||||
|
if (!GetShortPathNameA(CurrentDirectory, DosDirectory, sizeof(DosDirectory)))
|
||||||
|
{
|
||||||
|
// TODO: Use some kind of default path?
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the directory part of the path */
|
/* Get the directory part of the path */
|
||||||
Path = strchr(Directory, '\\');
|
Path = strchr(DosDirectory, '\\');
|
||||||
if (Path != NULL)
|
if (Path != NULL)
|
||||||
{
|
{
|
||||||
/* Skip the backslash */
|
/* Skip the backslash */
|
||||||
|
@ -786,7 +811,7 @@ VOID WINAPI DosInt21h(LPWORD Stack)
|
||||||
/* Get Free Disk Space */
|
/* Get Free Disk Space */
|
||||||
case 0x36:
|
case 0x36:
|
||||||
{
|
{
|
||||||
CHAR RootPath[3] = "X:\\";
|
CHAR RootPath[3] = "?:\\";
|
||||||
DWORD SectorsPerCluster;
|
DWORD SectorsPerCluster;
|
||||||
DWORD BytesPerSector;
|
DWORD BytesPerSector;
|
||||||
DWORD NumberOfFreeClusters;
|
DWORD NumberOfFreeClusters;
|
||||||
|
@ -1896,10 +1921,10 @@ BOOLEAN DosKRNLInitialize(VOID)
|
||||||
#if 1
|
#if 1
|
||||||
|
|
||||||
UCHAR i;
|
UCHAR i;
|
||||||
|
PDOS_SFT Sft;
|
||||||
|
LPSTR Path;
|
||||||
CHAR CurrentDirectory[MAX_PATH];
|
CHAR CurrentDirectory[MAX_PATH];
|
||||||
CHAR DosDirectory[DOS_DIR_LENGTH];
|
CHAR DosDirectory[DOS_DIR_LENGTH];
|
||||||
LPSTR Path;
|
|
||||||
PDOS_SFT Sft;
|
|
||||||
|
|
||||||
const BYTE NullDriverRoutine[] = {
|
const BYTE NullDriverRoutine[] = {
|
||||||
/* Strategy routine entry */
|
/* Strategy routine entry */
|
||||||
|
@ -1925,21 +1950,21 @@ BOOLEAN DosKRNLInitialize(VOID)
|
||||||
RtlZeroMemory(CurrentDirectories, sizeof(CurrentDirectories));
|
RtlZeroMemory(CurrentDirectories, sizeof(CurrentDirectories));
|
||||||
|
|
||||||
/* Get the current directory */
|
/* Get the current directory */
|
||||||
if (!GetCurrentDirectoryA(MAX_PATH, CurrentDirectory))
|
if (!GetCurrentDirectoryA(sizeof(CurrentDirectory), CurrentDirectory))
|
||||||
{
|
{
|
||||||
// TODO: Use some kind of default path?
|
// TODO: Use some kind of default path?
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert that to a DOS path */
|
/* Convert it to a DOS path */
|
||||||
if (!GetShortPathNameA(CurrentDirectory, DosDirectory, DOS_DIR_LENGTH))
|
if (!GetShortPathNameA(CurrentDirectory, DosDirectory, sizeof(DosDirectory)))
|
||||||
{
|
{
|
||||||
// TODO: Use some kind of default path?
|
// TODO: Use some kind of default path?
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the drive */
|
/* Set the drive */
|
||||||
CurrentDrive = DosDirectory[0] - 'A';
|
CurrentDrive = RtlUpperChar(DosDirectory[0]) - 'A';
|
||||||
|
|
||||||
/* Get the directory part of the path */
|
/* Get the directory part of the path */
|
||||||
Path = strchr(DosDirectory, '\\');
|
Path = strchr(DosDirectory, '\\');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue