create a fake bsod in csharp

Here's a code snippet that can create a fake Blue Screen of Death (BSOD) in C#:

main.cs
using System;
using System.Runtime.InteropServices;

public class FakeBSOD
{
    [DllImport("kernel32.dll")]
    private static extern IntPtr GetConsoleWindow();

    [DllImport("user32.dll")]
    private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

    private const int SW_HIDE = 0;
    private const int SW_SHOW = 5;

    public static void Main(string[] args)
    {
        Console.Title = "Blue Screen of Death";

        IntPtr hConsole = GetConsoleWindow();
        ShowWindow(hConsole, SW_HIDE);

        Console.BackgroundColor = ConsoleColor.Blue;
        Console.Clear();
        Console.ForegroundColor = ConsoleColor.White;

        Console.WriteLine("A problem has been detected and Windows has been shut down to prevent damage to your computer.");
        Console.WriteLine();
        Console.WriteLine("UNMOUNTABLE_BOOT_VOLUME");
        Console.WriteLine();
        Console.WriteLine("If this is the first time you've seen this stop error screen, restart your computer. If this screen appears again, follow these steps:");
        Console.WriteLine();
        Console.WriteLine("Check to make sure any new hardware or software is properly installed.");
        Console.WriteLine("If this is a new installation, ask your hardware or software manufacturer for any Windows updates you might need.");
        Console.WriteLine("If problems continue, disable or remove any newly installed hardware or software. Disable BIOS memory options such as caching or shading.");
        
        while (true)
        {
            Console.ForegroundColor = (ConsoleColor)new Random().Next(1, 16);
            Console.Write("█");
        }
    }
}
1670 chars
43 lines

This code makes use of the kernel32.dll and user32.dll to hide the console window, change the console colors to blue and white, and display a fake error message. The last part of the code creates an infinite loop that displays random characters, causing the entire screen to appear to be frozen.

Please note that this code is meant to be used only for humor or prank purposes and should not be used to harm or deceive anyone.

gistlibby LogSnag