mirror of
https://github.com/reactos/reactos.git
synced 2024-09-30 22:47:28 +00:00
[NTVDM]
- Fix some english. - Validity checks for DosGetSftEntry returned pointer added. - Use unsigned indices for for-loops indices that are always positive. svn path=/trunk/; revision=66903
This commit is contained in:
parent
4cc760792f
commit
05aaaf8a04
|
@ -57,6 +57,13 @@ BOOLEAN DosCheckInput(VOID)
|
|||
{
|
||||
PDOS_SFT_ENTRY SftEntry = DosGetSftEntry(DOS_INPUT_HANDLE);
|
||||
|
||||
if (SftEntry == NULL)
|
||||
{
|
||||
/* Invalid handle */
|
||||
DosLastError = ERROR_INVALID_HANDLE; // ERROR_FILE_NOT_FOUND
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (SftEntry->Type)
|
||||
{
|
||||
case DOS_SFT_ENTRY_WIN32:
|
||||
|
|
|
@ -380,4 +380,4 @@ Cleanup:
|
|||
return Result;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -139,7 +139,7 @@ static BOOL IsConsoleHandle(HANDLE hHandle)
|
|||
|
||||
static inline PDOS_SFT_ENTRY DosFindFreeSftEntry(VOID)
|
||||
{
|
||||
INT i;
|
||||
UINT i;
|
||||
|
||||
for (i = 0; i < DOS_SFT_SIZE; i++)
|
||||
{
|
||||
|
@ -154,7 +154,7 @@ static inline PDOS_SFT_ENTRY DosFindFreeSftEntry(VOID)
|
|||
|
||||
static inline PDOS_SFT_ENTRY DosFindWin32SftEntry(HANDLE Handle)
|
||||
{
|
||||
INT i;
|
||||
UINT i;
|
||||
|
||||
for (i = 0; i < DOS_SFT_SIZE; i++)
|
||||
{
|
||||
|
@ -170,7 +170,7 @@ static inline PDOS_SFT_ENTRY DosFindWin32SftEntry(HANDLE Handle)
|
|||
|
||||
static inline PDOS_SFT_ENTRY DosFindDeviceSftEntry(PDOS_DEVICE_NODE Device)
|
||||
{
|
||||
INT i;
|
||||
UINT i;
|
||||
|
||||
for (i = 0; i < DOS_SFT_SIZE; i++)
|
||||
{
|
||||
|
@ -209,7 +209,6 @@ WORD DosOpenHandle(HANDLE Handle)
|
|||
|
||||
/* Check if the handle is already in the SFT */
|
||||
SftEntry = DosFindWin32SftEntry(Handle);
|
||||
|
||||
if (SftEntry != NULL)
|
||||
{
|
||||
/* Already in the table, reference it */
|
||||
|
@ -266,7 +265,6 @@ WORD DosOpenDevice(PDOS_DEVICE_NODE Device)
|
|||
|
||||
/* Check if the device is already in the SFT */
|
||||
SftEntry = DosFindDeviceSftEntry(Device);
|
||||
|
||||
if (SftEntry != NULL)
|
||||
{
|
||||
/* Already in the table, reference it */
|
||||
|
@ -301,7 +299,7 @@ Finish:
|
|||
|
||||
static VOID DosCopyHandleTable(LPBYTE DestinationTable)
|
||||
{
|
||||
INT i;
|
||||
UINT i;
|
||||
PDOS_PSP PspBlock;
|
||||
LPBYTE SourceTable;
|
||||
|
||||
|
@ -340,7 +338,6 @@ static VOID DosCopyHandleTable(LPBYTE DestinationTable)
|
|||
{
|
||||
/* Create a new SFT entry for it */
|
||||
SftEntry = DosFindFreeSftEntry();
|
||||
|
||||
if (SftEntry == NULL)
|
||||
{
|
||||
DPRINT1("Cannot create standard handle %d, the SFT is full!\n", i);
|
||||
|
@ -1212,16 +1209,18 @@ Done:
|
|||
|
||||
BOOLEAN DosHandleIoctl(BYTE ControlCode, WORD FileHandle)
|
||||
{
|
||||
PDOS_SFT_ENTRY Entry = DosGetSftEntry(FileHandle);
|
||||
PDOS_DEVICE_NODE Node = Entry->DeviceNode;
|
||||
PDOS_SFT_ENTRY SftEntry = DosGetSftEntry(FileHandle);
|
||||
PDOS_DEVICE_NODE Node;
|
||||
|
||||
/* Make sure it exists and is a device */
|
||||
if (!Entry || Entry->Type != DOS_SFT_ENTRY_DEVICE)
|
||||
if (!SftEntry || SftEntry->Type != DOS_SFT_ENTRY_DEVICE)
|
||||
{
|
||||
DosLastError = ERROR_FILE_NOT_FOUND;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Node = SftEntry->DeviceNode;
|
||||
|
||||
switch (ControlCode)
|
||||
{
|
||||
/* Get Device Information */
|
||||
|
@ -2620,7 +2619,7 @@ VOID WINAPI DosInt21h(LPWORD Stack)
|
|||
{
|
||||
PDOS_SFT_ENTRY SftEntry = DosGetSftEntry(getBX());
|
||||
|
||||
if (SftEntry->Type != DOS_SFT_ENTRY_WIN32)
|
||||
if (SftEntry == NULL || SftEntry->Type != DOS_SFT_ENTRY_WIN32)
|
||||
{
|
||||
/* The handle is invalid */
|
||||
Stack[STACK_FLAGS] |= EMULATOR_FLAG_CF;
|
||||
|
|
|
@ -41,7 +41,7 @@ WORD DosCreateFileEx(LPWORD Handle,
|
|||
|
||||
//
|
||||
// The article about OpenFile API: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365430(v=vs.85).aspx
|
||||
// explains what are those AccessShareModes (see the uStyle flag).
|
||||
// explains what those AccessShareModes are (see the uStyle flag).
|
||||
//
|
||||
|
||||
/* Parse the access mode */
|
||||
|
@ -228,7 +228,6 @@ WORD DosCreateFileEx(LPWORD Handle,
|
|||
|
||||
/* Open the DOS handle */
|
||||
DosHandle = DosOpenHandle(FileHandle);
|
||||
|
||||
if (DosHandle == INVALID_DOS_HANDLE)
|
||||
{
|
||||
/* Close the file and return the error code */
|
||||
|
@ -268,7 +267,6 @@ WORD DosCreateFile(LPWORD Handle,
|
|||
|
||||
/* Open the DOS handle */
|
||||
DosHandle = DosOpenHandle(FileHandle);
|
||||
|
||||
if (DosHandle == INVALID_DOS_HANDLE)
|
||||
{
|
||||
/* Close the file and return the error code */
|
||||
|
@ -297,7 +295,7 @@ WORD DosOpenFile(LPWORD Handle,
|
|||
|
||||
//
|
||||
// The article about OpenFile API: http://msdn.microsoft.com/en-us/library/windows/desktop/aa365430(v=vs.85).aspx
|
||||
// explains what are those AccessShareModes (see the uStyle flag).
|
||||
// explains what those AccessShareModes are (see the uStyle flag).
|
||||
//
|
||||
|
||||
/* Parse the access mode */
|
||||
|
@ -380,7 +378,6 @@ WORD DosOpenFile(LPWORD Handle,
|
|||
|
||||
/* Open the DOS handle */
|
||||
DosHandle = DosOpenHandle(FileHandle);
|
||||
|
||||
if (DosHandle == INVALID_DOS_HANDLE)
|
||||
{
|
||||
/* Close the file and return the error code */
|
||||
|
@ -403,6 +400,12 @@ WORD DosReadFile(WORD FileHandle,
|
|||
|
||||
DPRINT("DosReadFile: FileHandle 0x%04X, Count 0x%04X\n", FileHandle, Count);
|
||||
|
||||
if (SftEntry == NULL)
|
||||
{
|
||||
/* Invalid handle */
|
||||
return ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (SftEntry->Type == DOS_SFT_ENTRY_WIN32)
|
||||
{
|
||||
DWORD BytesRead32 = 0;
|
||||
|
@ -445,6 +448,12 @@ WORD DosWriteFile(WORD FileHandle,
|
|||
|
||||
DPRINT("DosWriteFile: FileHandle 0x%04X, Count 0x%04X\n", FileHandle, Count);
|
||||
|
||||
if (SftEntry == NULL)
|
||||
{
|
||||
/* Invalid handle */
|
||||
return ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (SftEntry->Type == DOS_SFT_ENTRY_WIN32)
|
||||
{
|
||||
DWORD BytesWritten32 = 0;
|
||||
|
@ -491,6 +500,12 @@ WORD DosSeekFile(WORD FileHandle,
|
|||
Offset,
|
||||
Origin);
|
||||
|
||||
if (SftEntry == NULL)
|
||||
{
|
||||
/* Invalid handle */
|
||||
return ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
if (SftEntry->Type == DOS_SFT_ENTRY_NONE)
|
||||
{
|
||||
/* Invalid handle */
|
||||
|
@ -534,6 +549,12 @@ BOOL DosFlushFileBuffers(WORD FileHandle)
|
|||
{
|
||||
PDOS_SFT_ENTRY SftEntry = DosGetSftEntry(FileHandle);
|
||||
|
||||
if (SftEntry == NULL)
|
||||
{
|
||||
/* Invalid handle */
|
||||
return ERROR_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
switch (SftEntry->Type)
|
||||
{
|
||||
case DOS_SFT_ENTRY_WIN32:
|
||||
|
@ -544,14 +565,10 @@ BOOL DosFlushFileBuffers(WORD FileHandle)
|
|||
case DOS_SFT_ENTRY_DEVICE:
|
||||
{
|
||||
if (SftEntry->DeviceNode->FlushInputRoutine)
|
||||
{
|
||||
SftEntry->DeviceNode->FlushInputRoutine(SftEntry->DeviceNode);
|
||||
}
|
||||
|
||||
if (SftEntry->DeviceNode->FlushOutputRoutine)
|
||||
{
|
||||
SftEntry->DeviceNode->FlushOutputRoutine(SftEntry->DeviceNode);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -563,3 +580,5 @@ BOOL DosFlushFileBuffers(WORD FileHandle)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue