Solved

Causing a BSOD in C/C++?

Posted on 2009-06-28
19
1,239 Views
Last Modified: 2013-12-14
I'd like to know, what causes a BSOD? What is the easiet way I can cause a BSOD in C++?

(it's not for anything malicious, don't worry)
0
Comment
Question by:brandonhsiao90
  • 8
  • 6
  • 2
  • +1
19 Comments
 
LVL 53

Expert Comment

by:Infinity08
ID: 24731544
You could write a driver, and then do something in it that causes a crash (like dereferencing an invalid pointer, NULL eg.).
0
 
LVL 53

Accepted Solution

by:
Infinity08 earned 63 total points
ID: 24731548
lol, looking around, I found this weird "trick" to cause a BSOD :

in the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\i8042prt\Parameters, create a DWORD value called CrashOnCtrlScroll, and set it to 1. Then reboot, and after that, you can cause a crash by holding the right Ctrl key, and pressing the Scroll Lock key twice.
I'm not sure what the use of that is, but it might be what you need :)
0
 
LVL 40

Assisted Solution

by:evilrix
evilrix earned 62 total points
ID: 24731561
A BSOD is caused by code running in the kernel (as I8 said, it's normally a driver) that causes an exception that is unhandled. Since the OS has no way to do anything with this unhandled exception the only safe thing it can do is terminate the kernel and display a BSOD.

The following link explains about stop errors includes a detailed explanation of the stop error trick I8 refers to. It is used for testing purposes.
http://www.tomstricks.com/how-to-manually-force-windows-xp-to-generate-a-stop-error/
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 53

Expert Comment

by:Infinity08
ID: 24731572
>> It is used for testing purposes.

Yes, to test a very important feature ! lol ... god forbid the BSOD wouldn't work ;)
0
 
LVL 40

Expert Comment

by:evilrix
ID: 24731637
>> Yes, to test a very important feature
Ok, for example... you want to test that your uber-important and critical program can survive a BSOD (or a Stop Error to give it the correct name) and recover properly, but how? Answer, generate a BSOD in a controlled way. I suppose you could just pull the plug but I'm not sure that would be the same test, since a stop error has other side effects that just pulling the plug doesn't and vice versa.

Full documentation on the feature can be found here: http://support.microsoft.com/kb/244139

>> god forbid the BSOD wouldn't work ;)
I wonder, is there an equivalent way to make a Linux kernel panic (other than should 'boo' really loudly at it)? I can't say I've ever come across one, I'm sure there must be thought.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24731762
There's no recovering from a BSOD, is there ? It's basically the OS saying : "I give up - this is too much for me".
0
 
LVL 40

Expert Comment

by:evilrix
ID: 24731812
>> There's no recovering from a BSOD, is there ? It's basically the OS saying : "I give up - this is too much for me".
The OS is stopped, but as part of that it performs certain things such as perform a memory dump.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 24731840
Right, but what I was getting at is : why would you want to leave it in the finished product ... Why would you give your users the option to trigger a BSOD with a few key presses ?

Which actually makes me curious ... because apparently brandonhsiao90 does want to do it ... Could you satisfy my curiosity, brandonhsiao90 ?
0
 
LVL 40

Expert Comment

by:evilrix
ID: 24732143
that's not what I meant. I meant you generate the stop error from a different program written are part of your test suite. The ability to generate a stop error is just to facilitate testing. I'm not suggesting this should in into production code. I'm sorry if I gave that impression.
0
 
LVL 9

Expert Comment

by:masheik
ID: 24734868
--what causes a BSOD?
i found the wikipedia link helpful,
http://en.wikipedia.org/wiki/Blue_Screen_of_Death
0
 

Author Comment

by:brandonhsiao90
ID: 25000647
I wanted to create a BSOD-generator, I thought that some people might actually think it interesting that there's a program whose purpose is to BSOD you.

Problem with the CrashOnCtrlScroll method is that once you do that, obviously your computer shuts down, and you have no way of restoring the old settings. Thanks for all your help!

How can I code a driver?
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 25000669
>> Problem with the CrashOnCtrlScroll method is that once you do that, obviously your computer shuts down, and you have no way of restoring the old settings.

Of course you do. Just reboot the PC, and then restore the old settings.


>> How can I code a driver?

"How to write a Windows driver" : http://msdn.microsoft.com/en-us/library/ms809956.aspx
0
 

Author Comment

by:brandonhsiao90
ID: 25001032
>> Of course you do. Just reboot the PC, and then restore the old settings.

But I'm distributing my program.

Thanks for the link, helped me lots.
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 25002081
Ok ... Well, let us know if there's anything else you need.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 25332372
The suggested answer doesn't actually answer the original question. The asker wasn't to generate a BSOD and Windows provides a built in diagnostic tool for doing this. This was documented by the following two answers.

{http:#24731548} {http:#24731561}
0
 
LVL 53

Expert Comment

by:Infinity08
ID: 25332820
As it turned out in http:#25001032, that approach wouldn't work for the author, since he's looking for a tool to distribute, rather than a set of instructions. I assume that's why TheLearnedOne picked that answer.
0
 
LVL 40

Expert Comment

by:evilrix
ID: 25332858
Well, he stated "I wanted to create a BSOD-generator" the fact he that says after about distributing it make little sense. Also, if he's looking to create a tool to generate BSOD to test the program he plans to distribute then the answers I suggest will also do that.

Either way those answers provide solutions to the original question asked (which is probably why we both suggested them in the first place). The requirements (if we can call them that) were changed later in the question.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Passing command line arguments in C 10 95
sameEnds challenge 3 179
debug as  junit test 4 83
How and where to get Business Intelligence Development Studio? 2 91
Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question