2010-01-02 04:50:08 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS NMI Debug Driver
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: drivers/base/nmidebug/nmidebug.c
|
|
|
|
* PURPOSE: Driver Code
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
#include <ntifs.h>
|
2011-08-15 17:12:19 +00:00
|
|
|
#include <ndk/ketypes.h>
|
2010-01-02 04:50:08 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
2010-09-24 17:02:13 +00:00
|
|
|
PCHAR NmiBegin = "NMI4NMI@";
|
|
|
|
|
|
|
|
FORCEINLINE
|
2014-05-04 09:42:28 +00:00
|
|
|
VOID
|
2010-09-24 17:02:13 +00:00
|
|
|
NmiClearFlag(VOID)
|
|
|
|
{
|
|
|
|
((PCHAR)&KiBugCheckData[4])[0] -= (NmiBegin[3] | NmiBegin[7]);
|
|
|
|
((PCHAR)&KiBugCheckData[4])[3] |= 1;
|
2011-08-26 20:05:58 +00:00
|
|
|
#ifdef _M_IX86
|
2017-10-30 20:54:54 +00:00
|
|
|
#if defined(_MSC_VER) && !defined(__clang__)
|
2011-05-13 17:16:08 +00:00
|
|
|
__asm
|
|
|
|
{
|
|
|
|
rcr KiBugCheckData[4], 8
|
|
|
|
}
|
|
|
|
#else
|
2010-09-24 17:02:13 +00:00
|
|
|
__asm__("rcrl %b[shift], %k[retval]" : [retval] "=rm" (KiBugCheckData[4]) : "[retval]" (KiBugCheckData[4]), [shift] "Nc" (8));
|
2011-05-13 17:16:08 +00:00
|
|
|
#endif
|
2011-08-26 20:05:58 +00:00
|
|
|
#endif
|
2010-09-24 17:02:13 +00:00
|
|
|
}
|
2010-09-10 09:54:30 +00:00
|
|
|
|
2010-01-02 04:50:08 +00:00
|
|
|
BOOLEAN
|
|
|
|
NTAPI
|
|
|
|
NmiDbgCallback(IN PVOID Context,
|
|
|
|
IN BOOLEAN Handled)
|
|
|
|
{
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Clear the NMI flag */
|
2010-09-24 17:02:13 +00:00
|
|
|
NmiClearFlag();
|
2010-09-10 09:54:30 +00:00
|
|
|
|
|
|
|
/* Get NMI status signature */
|
|
|
|
__indwordstring(0x80, (PULONG)NmiBegin, 1);
|
|
|
|
((void(*)())&KiBugCheckData[4])();
|
|
|
|
|
|
|
|
/* Handle the NMI safely */
|
2011-08-26 20:05:58 +00:00
|
|
|
#ifdef _M_IX86
|
2010-09-24 17:02:13 +00:00
|
|
|
KiEnableTimerWatchdog = (RtlCompareMemory(NmiBegin, NmiBegin + 4, 4) != 4);
|
2011-08-26 20:05:58 +00:00
|
|
|
#endif
|
2010-09-10 09:54:30 +00:00
|
|
|
return TRUE;
|
2010-01-02 04:50:08 +00:00
|
|
|
}
|
2010-09-24 17:02:13 +00:00
|
|
|
|
2010-01-02 04:50:08 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
DriverEntry(IN PDRIVER_OBJECT DriverObject,
|
|
|
|
IN PUNICODE_STRING RegistryPath)
|
|
|
|
{
|
|
|
|
PAGED_CODE();
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Register NMI callback */
|
2010-01-02 04:50:08 +00:00
|
|
|
KeRegisterNmiCallback(&NmiDbgCallback, NULL);
|
|
|
|
|
2010-09-10 09:54:30 +00:00
|
|
|
/* Return success */
|
2010-01-02 04:50:08 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|