HyperDbg/hyperdbg/include/platform/kernel/code/PlatformIrql.c
Max Raulea b0de162deb Added linux part of PlatformIrql
Added the linux part of PlatformIrql by adding preempt_enable() and preempt_disable.
2026-08-11 12:20:50 +02:00

67 lines
1.1 KiB
C

/**
* @file PlatformIrql.c
* @author Sina Karvandi (sina@hyperdbg.org)
* @brief Implementation of cross platform APIs for IRQL management
* @details
* @version 0.19
* @date 2026-05-09
*
* @copyright This project is released under the GNU Public License v3.
*
*/
#include "pch.h"
#if defined(__linux__)
# include "../header/PlatformIrql.h"
#endif // defined(__linux__)
/**
* @brief Raise the current IRQL to DISPATCH_LEVEL
*
* @return KIRQL The previous IRQL before the raise
*/
KIRQL
PlatformIrqlRaiseToDpcLevel(VOID)
{
#if defined(_WIN32) || defined(_WIN64)
return KeRaiseIrqlToDpcLevel();
#elif defined(__linux__)
preempt_disable();
return 0;
#else
# error "Unsupported platform"
#endif
}
/**
* @brief Lower the current IRQL to the previously saved value
*
* @param OldIrql The previous IRQL to restore
* @return VOID
*/
VOID
PlatformIrqlLower(KIRQL OldIrql)
{
#if defined(_WIN32) || defined(_WIN64)
KeLowerIrql(OldIrql);
#elif defined(__linux__)
UNREFERENCED_PARAMETER(OldIrql);
preempt_enable();
#else
# error "Unsupported platform"
#endif
}