Click here to Skip to main content
15,887,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to make a C# program that can intentionally CRASH, not close, an exe. I had the idea to divide something by 0 in the code but I have no idea of how I would do this? Any help would be greatly appreciated, thank you! (I don't really mind how it's done just a way to crash an EXE) TY!

What I have tried:

I've tried googling answers but I can only find help for languages like Python
Posted
Updated 3-Nov-20 11:35am
Comments
Dave Kreskowiak 3-Nov-20 10:41am    
Are you asking how to force another app you didn't write to crash? Like you trying to crash Notepad or something?
Minecraft Graphix 3-Nov-20 10:43am    
i'm not sure what you mean? but yeah for example crash notepad or chrome
Dave Kreskowiak 3-Nov-20 10:52am    
First, why would you want to?

Next, that's a LOT harder to do than just simply injecting a divide by zero somewhere. .NET doesn't support the exports to inject managed code into another process.

You'd have to write something along the lines of a debugger to do what you want, and it would take admin permissions to be able to do it.

Think about it. If it was that easy, you'd have far more malware doing it all the time, crashing stuff constantly.
PIEBALDconsult 3-Nov-20 12:00pm    
You can kill another process, but not cause it to crash.

Quote:
I want to make a C# program that can intentionally CRASH, not close, an exe.

Making a program that can remotely and silently crash another program is a dream feature for any malware program. This alone is a very good reason for the OS to actively prevent it to happen from an ordinary program.
Such programs are seriously screened by OS and AV and you must give guaranties that the action is legitimate.
Just a guess, not only the program must be executed as admin and it must be signed/approved by trusted authority. Not easy to do.
 
Share this answer
 
C#
int x = 1;
int y = 0;
int z = x / y;
 
Share this answer
 
Comments
Minecraft Graphix 3-Nov-20 10:43am    
But how do i attach that to a process i want to CRASH?
F-ES Sitecore 3-Nov-20 11:01am    
You can't. Apps are protected from each other so one app can't modify another.
You need to understand what the app works with and it's error recovery capabilities. All it may take is to lock a file. Then there are the "destructive" techniques.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900