fixed implementation of SetErrorMode() which should rather store the mode in the EPROCESS structure

svn path=/trunk/; revision=13136
This commit is contained in:
Thomas Bluemel 2005-01-19 20:16:26 +00:00
parent c0ff13e571
commit 837f31e111
9 changed files with 80 additions and 15 deletions

View file

@ -15,9 +15,28 @@
#define NDEBUG #define NDEBUG
#include "../include/debug.h" #include "../include/debug.h"
UINT GlobalErrorMode = 0;
LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter = UnhandledExceptionFilter; LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter = UnhandledExceptionFilter;
UINT
STDCALL
GetErrorMode(VOID)
{
NTSTATUS Status;
UINT ErrMode;
Status = NtQueryInformationProcess(NtCurrentProcess(),
ProcessDefaultHardErrorMode,
(PVOID)&ErrMode,
sizeof(ErrMode),
NULL);
if(!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return 0;
}
return ErrMode;
}
/* /*
* @implemented * @implemented
@ -26,7 +45,22 @@ UINT
STDCALL STDCALL
SetErrorMode(UINT uMode) SetErrorMode(UINT uMode)
{ {
return (UINT)InterlockedExchange((LONG*)&GlobalErrorMode, (LONG)uMode); UINT PrevErrMode;
NTSTATUS Status;
PrevErrMode = GetErrorMode();
Status = NtSetInformationProcess(NtCurrentProcess(),
ProcessDefaultHardErrorMode,
(PVOID)&uMode,
sizeof(uMode));
if(!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
return 0;
}
return PrevErrMode;
} }
@ -114,7 +148,7 @@ UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
return EXCEPTION_CONTINUE_SEARCH; return EXCEPTION_CONTINUE_SEARCH;
} }
if ((GlobalErrorMode & SEM_NOGPFAULTERRORBOX) == 0) if ((GetErrorMode() & SEM_NOGPFAULTERRORBOX) == 0)
{ {
#ifdef _X86_ #ifdef _X86_
PULONG Frame; PULONG Frame;

View file

@ -25,7 +25,7 @@ static PFN_TYPE CcZeroPage = 0;
#define MAX_RW_LENGTH (256 * 1024) #define MAX_RW_LENGTH (256 * 1024)
#if defined(__GNUC__) #if defined(__GNUC__)
void * alloca(size_t size); /* void * alloca(size_t size); */
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
void* _alloca(size_t size); void* _alloca(size_t size);
#else #else

View file

@ -100,7 +100,7 @@ static CLIENT_ID LazyCloseThreadId;
static volatile BOOLEAN LazyCloseThreadShouldTerminate; static volatile BOOLEAN LazyCloseThreadShouldTerminate;
#if defined(__GNUC__) #if defined(__GNUC__)
void * alloca(size_t size); /* void * alloca(size_t size); */
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
void* _alloca(size_t size); void* _alloca(size_t size);
#else #else

View file

@ -62,4 +62,6 @@
#include <napi/teb.h> #include <napi/teb.h>
#include <napi/win32.h> #include <napi/win32.h>
#include <pseh.h>
#endif /* INCLUDE_NTOSKRNL_H */ #endif /* INCLUDE_NTOSKRNL_H */

View file

@ -30,7 +30,7 @@
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
#include <ntoskrnl.h> #include <ntoskrnl.h>
#include <pseh.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>

View file

@ -10,7 +10,6 @@
/* INCLUDES ****************************************************************/ /* INCLUDES ****************************************************************/
#include <ntoskrnl.h> #include <ntoskrnl.h>
#include <pseh.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>

View file

@ -27,7 +27,6 @@
/* INCLUDE *****************************************************************/ /* INCLUDE *****************************************************************/
#include <ntoskrnl.h> #include <ntoskrnl.h>
#include <pseh.h>
#define NDEBUG #define NDEBUG
#include <internal/debug.h> #include <internal/debug.h>

View file

@ -1139,7 +1139,7 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
*/ */
Status = ObReferenceObjectByHandle(ProcessHandle, Status = ObReferenceObjectByHandle(ProcessHandle,
PROCESS_SET_INFORMATION, PROCESS_QUERY_INFORMATION,
PsProcessType, PsProcessType,
UserMode, UserMode,
(PVOID*)&Process, (PVOID*)&Process,
@ -1272,12 +1272,21 @@ NtQueryInformationProcess(IN HANDLE ProcessHandle,
else else
{ {
PULONG HardErrMode = (PULONG)ProcessInformation; PULONG HardErrMode = (PULONG)ProcessInformation;
*HardErrMode = Process->DefaultHardErrorProcessing; _SEH_TRY
if (ReturnLength)
{ {
*ReturnLength = sizeof(ULONG); *HardErrMode = Process->DefaultHardErrorProcessing;
if (ReturnLength)
{
*ReturnLength = sizeof(ULONG);
}
Status = STATUS_SUCCESS;
} }
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
} }
break; break;
@ -1445,10 +1454,32 @@ NtSetInformationProcess(IN HANDLE ProcessHandle,
ProcessAccessTokenP = (PHANDLE)ProcessInformation; ProcessAccessTokenP = (PHANDLE)ProcessInformation;
Status = PspAssignPrimaryToken(Process, *ProcessAccessTokenP); Status = PspAssignPrimaryToken(Process, *ProcessAccessTokenP);
break; break;
case ProcessDefaultHardErrorMode:
{
if(ProcessInformationLength != sizeof(UINT))
{
Status = STATUS_INFO_LENGTH_MISMATCH;
}
else
{
_SEH_TRY
{
InterlockedExchange((LONG*)&Process->DefaultHardErrorProcessing,
*(PLONG)ProcessInformation);
Status = STATUS_SUCCESS;
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
break;
}
case ProcessLdtInformation: case ProcessLdtInformation:
case ProcessLdtSize: case ProcessLdtSize:
case ProcessDefaultHardErrorMode:
case ProcessIoPortHandlers: case ProcessIoPortHandlers:
case ProcessWorkingSetWatch: case ProcessWorkingSetWatch:
case ProcessUserModeIOPL: case ProcessUserModeIOPL:

View file

@ -25,7 +25,7 @@
#include <internal/debug.h> #include <internal/debug.h>
#if defined(__GNUC__) #if defined(__GNUC__)
void * alloca(size_t size); /* void * alloca(size_t size); */
#elif defined(_MSC_VER) #elif defined(_MSC_VER)
void* _alloca(size_t size); void* _alloca(size_t size);
#else #else