Windows中有没有办法根据Python的需要抛出BSOD?

Rus*_*ber 6 windows bsod automated-tests

我正在制作一个脚本来测试一些始终运行的软件,并且我想测试它从 BSOD 的恢复情况。有没有一种方法可以从 python 抛出蓝屏而不调用外部脚本或可执行文件,如 OSR 的 BANG!

McS*_*ebi 3

有趣的事情。有一个 Windows 内核函数可以做到这一点。

我假设这是预期的行为,因为该函数已经存在

以下 Python 代码将使任何 Windows 计算机在用户模式下崩溃,无需任何额外设置。

from ctypes import windll
from ctypes import c_int
from ctypes import c_uint
from ctypes import c_ulong
from ctypes import POINTER
from ctypes import byref

nullptr = POINTER(c_int)()

windll.ntdll.RtlAdjustPrivilege(
    c_uint(19), 
    c_uint(1), 
    c_uint(0), 
    byref(c_int())
)

windll.ntdll.NtRaiseHardError(
    c_ulong(0xC000007B), 
    c_ulong(0), 
    nullptr, 
    nullptr, 
    c_uint(6), 
    byref(c_uint())
)
Run Code Online (Sandbox Code Playgroud)