We help IT Professionals succeed at work.

Causing a BSOD in C/C++?

brandonhsiao90
on
1,722 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)
Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2009

Commented:
You could write a driver, and then do something in it that causes a crash (like dereferencing an invalid pointer, NULL eg.).
CERTIFIED EXPERT
Top Expert 2009
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> It is used for testing purposes.

Yes, to test a very important feature ! lol ... god forbid the BSOD wouldn't work ;)
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
>> 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.
CERTIFIED EXPERT
Top Expert 2009

Commented:
There's no recovering from a BSOD, is there ? It's basically the OS saying : "I give up - this is too much for me".
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
>> 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.
CERTIFIED EXPERT
Top Expert 2009

Commented:
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 ?
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
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.
masheikSoftware Engineer
CERTIFIED EXPERT

Commented:
--what causes a BSOD?
i found the wikipedia link helpful,
http://en.wikipedia.org/wiki/Blue_Screen_of_Death

Author

Commented:
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?
CERTIFIED EXPERT
Top Expert 2009

Commented:
>> 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

Author

Commented:
>> 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.
CERTIFIED EXPERT
Top Expert 2009

Commented:
Ok ... Well, let us know if there's anything else you need.
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
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}
CERTIFIED EXPERT
Top Expert 2009

Commented:
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.
evilrixSenior Software Engineer (Avast)
CERTIFIED EXPERT

Commented:
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.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.