Adam Furmanek

Hacking C# from the inside - how to do anything in NET

There's no such thing as 'impossible' in .NET. Learn to hijack methods, execute raw machine code, and even catch a StackOverflowException.

Hacking C# from the inside - how to do anything in NET
#1about 6 minutes

Avoiding dynamic dispatch with static method invocation

Bypass polymorphism by generating intermediate language (IL) with the `call` instruction instead of `callvirt` to invoke a specific base class method.

#2about 4 minutes

How to await async void methods in C#

Implement a custom `TaskScheduler` and `SynchronizationContext` to enable awaiting `async void` methods and properly handle their exceptions.

#3about 14 minutes

Running raw machine code from a C# byte array

Explore two methods for executing machine code: using the `Marshall` API for managed delegates or by manually overwriting a method's body with a CPU jump instruction.

#4about 4 minutes

Hijacking methods by modifying metadata or machine code

Explore two techniques for method hijacking: either by overwriting the function pointer in the method descriptor or by injecting a jump instruction into the method's machine code.

#5about 6 minutes

Use case: Running an application on a different desktop

Apply method hijacking to the `CreateProcess` API by intercepting a constructor to specify a target desktop, a feature not exposed by the standard .NET API.

#6about 2 minutes

Use case: Handling unhandled exceptions on a thread

Prevent application crashes by hijacking the `Thread` constructor to automatically wrap the thread's starting logic in a try-catch block.

#7about 4 minutes

Handling the uncatchable StackOverflowException

Catch a `StackOverflowException` by using a WinAPI vectored exception handler to save and restore CPU registers, allowing the application to continue safely.

Related jobs
Jobs that call for the skills explored in this talk.

Featured Partners

Related Articles

View all articles
CH
Chris Heilmann
Dev Digest 138 - Are you secure about this?
Hello there! This is the 2nd "out of the can" edition of 3 as I am on vacation in Greece eating lovely things on the beach. So, fewer news, but lots of great resources. Many around the topic of security. Enjoy! News and ArticlesGoogle Pixel phones t...
Dev Digest 138 - Are you secure about this?
BR
Benjamin Ruschin
What Developers Really Need to Create Great Code Demos
Every developer on earth has, at some point, had another developer to thank for a breakthrough, a success, an aha moment they wouldn’t have had without coming across that blog post, that open-source contribution, that reply on socials or that humble ...
What Developers Really Need to Create Great Code Demos
DC
Daniel Cranney
Dev Digest 181: America Offline! Pay to code? And bad AI hackers…
Inside last week’s Dev Digest 181 . ☎️ AOL shuts down dial-up internet 🔥 Bot-only social media platform immediately goes to war 🤑 Is the future pay to code? ⚠️ Path traversal vulnerability in Microsoft’s agentic web 🤷 Why is XSS still a thing? 🟪 The...
Dev Digest 181: America Offline! Pay to code? And bad AI hackers…

From learning to earning

Jobs that call for the skills explored in this talk.

C# Net Developer

C# Net Developer

Developerstrategicsiq Ltd
Bramley, United Kingdom

.NET
REST
Azure
NoSQL
DevOps
+4
Software Engineer C#

Software Engineer C#

SAFELOG GmbH
Markt Schwaben, Germany

Remote
Intermediate
GIT
Microsoft SQL Server
C# .Net Developer

C# .Net Developer

Dynamtiv People
Glenrothes, United Kingdom

37-44K
MVC
GIT
Azure
DevOps
+1