mirror of
https://github.com/reactos/reactos.git
synced 2025-04-30 02:58:48 +00:00

* lib/kernel32/debug/break.c: Add @implemented and @unimplemented to APIs. * lib/kernel32/debug/debugger.c: Ditto. * lib/kernel32/debug/output.c: Ditto. * lib/kernel32/except/except.c: Ditto. * lib/kernel32/file/backup.c: Ditto. * lib/kernel32/file/cnotify.c: Ditto. * lib/kernel32/file/copy.c: Ditto. * lib/kernel32/file/create.c: Ditto. * lib/kernel32/file/curdir.c: Ditto. * lib/kernel32/file/delete.c: Ditto. * lib/kernel32/file/deviceio.c: Ditto. * lib/kernel32/file/dir.c: Ditto. * lib/kernel32/file/dosdev.c: Ditto. * lib/kernel32/file/file.c: Ditto. * lib/kernel32/file/find.c: Ditto. * lib/kernel32/file/iocompl.c: Ditto. * lib/kernel32/file/lfile.c: Ditto. * lib/kernel32/file/lock.c: Ditto. * lib/kernel32/file/mailslot.c: Ditto. * lib/kernel32/file/move.c: Ditto. * lib/kernel32/file/npipe.c: Ditto. * lib/kernel32/file/pipe.c: Ditto. * lib/kernel32/file/rw.c: Ditto. * lib/kernel32/file/tape.c: Ditto. * lib/kernel32/file/volume.c: Ditto. * lib/kernel32/mem/global.c: Ditto. * lib/kernel32/mem/heap.c: Ditto. * lib/kernel32/mem/isbad.c: Ditto. * lib/kernel32/mem/local.c: Ditto. * lib/kernel32/mem/procmem.c: Ditto. * lib/kernel32/mem/section.c: Ditto. * lib/kernel32/mem/virtual.c: Ditto. * lib/kernel32/misc/atom.c: Ditto. * lib/kernel32/misc/comm.c: Ditto. * lib/kernel32/misc/computername.c: Ditto. * lib/kernel32/misc/console.c: Ditto. * lib/kernel32/misc/env.c: Ditto. * lib/kernel32/misc/error.c: Ditto. * lib/kernel32/misc/errormsg.c: Ditto. * lib/kernel32/misc/handle.c: Ditto. * lib/kernel32/misc/ldr.c: Ditto. * lib/kernel32/misc/mbchars.c: Ditto. * lib/kernel32/misc/muldiv.c: Ditto. * lib/kernel32/misc/perfcnt.c: Ditto. * lib/kernel32/misc/profile.c: Ditto. * lib/kernel32/misc/res.c: Ditto. * lib/kernel32/misc/stubs.c: Ditto. * lib/kernel32/misc/sysinfo.c: Ditto. * lib/kernel32/misc/time.c: Ditto. * lib/kernel32/misc/toolhelp.c: Ditto. * lib/kernel32/process/cmdline.c: Ditto. * lib/kernel32/process/create.c: Ditto. * lib/kernel32/process/proc.c: Ditto. * lib/kernel32/process/session.c: Ditto. * lib/kernel32/string/lstring.c: Ditto. * lib/kernel32/synch/critical.c: Ditto. * lib/kernel32/synch/event.c: Ditto. * lib/kernel32/synch/intrlck.c: Ditto. * lib/kernel32/synch/mutex.c: Ditto. * lib/kernel32/synch/sem.c: Ditto. * lib/kernel32/synch/timer.c: Ditto. * lib/kernel32/synch/wait.c: Ditto. * lib/kernel32/thread/fiber.c: Ditto. * lib/kernel32/thread/fls.c: Ditto. * lib/kernel32/thread/thread.c: Ditto. * lib/kernel32/thread/tls.c: Ditto. svn path=/trunk/; revision=5045
166 lines
4 KiB
C
166 lines
4 KiB
C
/* $Id: except.c,v 1.11 2003/07/10 18:50:51 chorns Exp $
|
|
*
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
* PROJECT: ReactOS system libraries
|
|
* FILE: lib/kernel32/misc/except.c
|
|
* PURPOSE: Exception functions
|
|
* PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
|
|
* modified from WINE [ Onno Hovers, (onno@stack.urc.tue.nl) ]
|
|
* UPDATE HISTORY:
|
|
* Created 01/11/98
|
|
*/
|
|
|
|
#include <k32.h>
|
|
|
|
|
|
typedef LONG (STDCALL *LPTOP_LEVEL_EXCEPTION_FILTER)(
|
|
struct _EXCEPTION_POINTERS *ExceptionInfo
|
|
);
|
|
|
|
UINT GlobalErrMode;
|
|
LPTOP_LEVEL_EXCEPTION_FILTER GlobalTopLevelExceptionFilter;
|
|
|
|
UINT GetErrorMode(void);
|
|
|
|
|
|
|
|
UINT GetErrorMode(void)
|
|
{
|
|
return GlobalErrMode;
|
|
}
|
|
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
UINT
|
|
STDCALL
|
|
SetErrorMode( UINT uMode )
|
|
{
|
|
UINT OldErrMode = GetErrorMode();
|
|
GlobalErrMode = uMode;
|
|
return OldErrMode;
|
|
}
|
|
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
LPTOP_LEVEL_EXCEPTION_FILTER
|
|
STDCALL
|
|
SetUnhandledExceptionFilter(
|
|
LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter
|
|
)
|
|
{
|
|
LPTOP_LEVEL_EXCEPTION_FILTER OldTopLevelExceptionFilter =
|
|
GlobalTopLevelExceptionFilter;
|
|
lpTopLevelExceptionFilter = GlobalTopLevelExceptionFilter;
|
|
return OldTopLevelExceptionFilter;
|
|
}
|
|
|
|
|
|
/*
|
|
* @unimplemented
|
|
*/
|
|
LONG
|
|
STDCALL
|
|
UnhandledExceptionFilter(struct _EXCEPTION_POINTERS *ExceptionInfo)
|
|
{
|
|
DWORD dbgRet;
|
|
HANDLE DebugPort;
|
|
NTSTATUS errCode;
|
|
|
|
if(ExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION) {
|
|
// might check read only resource
|
|
// Is there a debugger running ?
|
|
errCode = NtQueryInformationProcess(NtCurrentProcess(),ProcessDebugPort,&DebugPort,sizeof(HANDLE),NULL);
|
|
if ( !NT_SUCCESS(errCode) ) {
|
|
SetLastErrorByStatus(errCode);
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
}
|
|
if ( DebugPort ) {
|
|
//return EXCEPTION_CONTINUE_SEARCH;
|
|
}
|
|
if(GlobalTopLevelExceptionFilter != NULL) {
|
|
dbgRet = GlobalTopLevelExceptionFilter(ExceptionInfo);
|
|
if(dbgRet == EXCEPTION_EXECUTE_HANDLER)
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
else if(dbgRet == EXCEPTION_CONTINUE_EXECUTION)
|
|
return EXCEPTION_CONTINUE_EXECUTION;
|
|
}
|
|
|
|
}
|
|
|
|
//if ( GetErrorMode() & SEM_NOGPFAULTERRORBOX == SEM_NOGPFAULTERRORBOX ) {
|
|
// produce a stack trace or pop a message
|
|
//sprintf( message, "Unhandled exception 0x%08lx at address 0x%08lx.",
|
|
// ExceptionInfo->ExceptionRecord->ExceptionCode,
|
|
// (DWORD)ExceptionInfo->ExceptionRecord->ExceptionAddress );
|
|
//MessageBoxA( 0, message, "Error", MB_OK | MB_ICONHAND );
|
|
|
|
//}
|
|
// Returning EXCEPTION_EXECUTE_HANDLER means that the code in
|
|
// the __execept block will be executed. Normally this will end up in a
|
|
// Terminate process.
|
|
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
* @implemented
|
|
*/
|
|
VOID
|
|
STDCALL
|
|
RaiseException (
|
|
DWORD dwExceptionCode,
|
|
DWORD dwExceptionFlags,
|
|
DWORD nNumberOfArguments,
|
|
CONST DWORD * lpArguments OPTIONAL
|
|
)
|
|
{
|
|
EXCEPTION_RECORD ExceptionRecord;
|
|
|
|
/* Do NOT normalize dwExceptionCode: it will be done in
|
|
* NTDLL.RtlRaiseException().
|
|
*/
|
|
ExceptionRecord.ExceptionCode = dwExceptionCode;
|
|
ExceptionRecord.ExceptionRecord = NULL;
|
|
ExceptionRecord.ExceptionAddress = (PVOID) RaiseException;
|
|
/*
|
|
* Normalize dwExceptionFlags.
|
|
*/
|
|
ExceptionRecord.ExceptionFlags = (dwExceptionFlags & EXCEPTION_NONCONTINUABLE);
|
|
/*
|
|
* Normalize nNumberOfArguments.
|
|
*/
|
|
if (EXCEPTION_MAXIMUM_PARAMETERS < nNumberOfArguments)
|
|
{
|
|
nNumberOfArguments = EXCEPTION_MAXIMUM_PARAMETERS;
|
|
}
|
|
/*
|
|
* If the exception has no argument,
|
|
* or it is a non-continuable exception,
|
|
* ignore nNumberOfArguments and lpArguments.
|
|
*/
|
|
if ((NULL == lpArguments) || ExceptionRecord.ExceptionFlags)
|
|
{
|
|
ExceptionRecord.NumberParameters = 0;
|
|
}
|
|
else
|
|
{
|
|
ExceptionRecord.NumberParameters = nNumberOfArguments;
|
|
for ( nNumberOfArguments = 0;
|
|
(nNumberOfArguments < ExceptionRecord.NumberParameters);
|
|
nNumberOfArguments ++
|
|
)
|
|
{
|
|
ExceptionRecord.ExceptionInformation [nNumberOfArguments]
|
|
= *lpArguments ++;
|
|
}
|
|
}
|
|
RtlRaiseException (& ExceptionRecord);
|
|
}
|
|
|
|
/* EOF */
|