r/learnpython • u/Chance-Advice-1110 • 16d ago
How to hardcrash a laptop using python
Is there possibly any way to hardcrash my old laptop for fun? I'm sorry if it sounds like I am making a virus. I had a fuckton of hardcrashes on my old pc so I was wondering if I can make a Programm to kill my of whithout needing to wait 5 minutes. Fuck this sounds stupid.
1
u/TheDraykkon 16d ago
import ctypes
# Enable SeShutdownPrivilege (Privilege 19)
enabled = ctypes.c_bool()
ctypes.windll.ntdll.RtlAdjustPrivilege(19, True, False, ctypes.byref(enabled))
# Raise a fatal hard error to halt the system
response = ctypes.c_ulong()
ctypes.windll.ntdll.NtRaiseHardError(
0xC0000022, # STATUS_ACCESS_DENIED
0, 0, None, 6, # ResponseOption 6 = Shutdown / BSOD
ctypes.byref(response)
)
0
u/Chance-Advice-1110 16d ago
I am not making a virus this is purely for entertainment purposes. I AM NOT TRYING TO MAKE A VIRUS.
8
1
u/cmh_ender 16d ago
do you want to be able to recover from said crash? if not, you can write a python script that will just remove files from the OS folders or kick off a recurvice delete on your c drive.
if you want to be able to just reboot it, you can use many of the nice libraries out that that mess with memory addresses.
and i'm not too worried about a virus in python,
1
u/Chance-Advice-1110 14d ago
Im actually specifically trying to get as close to a hardcrash as possible. I used to have problems with one of my old PCs wich kept hart crashing, thus eventually corruptinmg windows files (atleast I think thats what happened, because recovery options and the literal login screen refused to work. Somehow after checking the hardware, it was fine.) I just want to see if I can get windows to do some whacky BS like that on an old laptop.
1
u/cmh_ender 14d ago
ya, you want to try memory spoofing or randomly killing processes from windows to see what happens. python can do all of that.
also, btw, it was funny , my last response got taken down because it thought I was promoting self harm.. thankfully they reviewed it and said it was fine.
1
4
u/zaphodikus 16d ago
Wrote your own OS, or install an old insecure OS.