mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
[NTVDM]
Do not rely on the internal format for console handles. Instead, use a more reliable way, by checking for success when calling a simple console function acting on in/out console handles. svn path=/branches/ntvdm/; revision=59746
This commit is contained in:
parent
08dc1d3e16
commit
e3345a32fb
2 changed files with 24 additions and 1 deletions
|
@ -29,6 +29,30 @@ static BOOLEAN DosUmbLinked = FALSE;
|
||||||
|
|
||||||
/* PRIVATE FUNCTIONS **********************************************************/
|
/* PRIVATE FUNCTIONS **********************************************************/
|
||||||
|
|
||||||
|
/* Taken from base/shell/cmd/console.c */
|
||||||
|
static BOOL IsConsoleHandle(HANDLE hHandle)
|
||||||
|
{
|
||||||
|
DWORD dwMode;
|
||||||
|
|
||||||
|
/* Check whether the handle may be that of a console... */
|
||||||
|
if ((GetFileType(hHandle) & FILE_TYPE_CHAR) == 0) return FALSE;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* It may be. Perform another test... The idea comes from the
|
||||||
|
* MSDN description of the WriteConsole API:
|
||||||
|
*
|
||||||
|
* "WriteConsole fails if it is used with a standard handle
|
||||||
|
* that is redirected to a file. If an application processes
|
||||||
|
* multilingual output that can be redirected, determine whether
|
||||||
|
* the output handle is a console handle (one method is to call
|
||||||
|
* the GetConsoleMode function and check whether it succeeds).
|
||||||
|
* If the handle is a console handle, call WriteConsole. If the
|
||||||
|
* handle is not a console handle, the output is redirected and
|
||||||
|
* you should call WriteFile to perform the I/O."
|
||||||
|
*/
|
||||||
|
return GetConsoleMode(hHandle, &dwMode);
|
||||||
|
}
|
||||||
|
|
||||||
static VOID DosCombineFreeBlocks(WORD StartBlock)
|
static VOID DosCombineFreeBlocks(WORD StartBlock)
|
||||||
{
|
{
|
||||||
PDOS_MCB CurrentMcb = SEGMENT_TO_MCB(StartBlock), NextMcb;
|
PDOS_MCB CurrentMcb = SEGMENT_TO_MCB(StartBlock), NextMcb;
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#define MAX_ADDRESS TO_LINEAR(MAX_SEGMENT, MAX_OFFSET)
|
#define MAX_ADDRESS TO_LINEAR(MAX_SEGMENT, MAX_OFFSET)
|
||||||
#define FAR_POINTER(x) ((ULONG_PTR)BaseAddress + TO_LINEAR(HIWORD(x), LOWORD(x)))
|
#define FAR_POINTER(x) ((ULONG_PTR)BaseAddress + TO_LINEAR(HIWORD(x), LOWORD(x)))
|
||||||
#define STEPS_PER_CYCLE 256
|
#define STEPS_PER_CYCLE 256
|
||||||
#define IsConsoleHandle(h) (((((ULONG_PTR)h) & 0x10000003) == 3) ? TRUE : FALSE)
|
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue