Adam Furmanek

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

Ever wanted to catch a StackOverflowException? Learn how to bypass C# safety features, execute raw machine code, and hijack methods at runtime.

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

Bypassing dynamic dispatch for static method invocation

Learn how to statically control which virtual method implementation to run by generating intermediate language (IL) with the `call` instruction instead of `callvirt`.

#2about 4 minutes

How to await async void methods in C#

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

#3about 14 minutes

Executing raw machine code from a byte array

Explore how to execute raw x86 machine code stored in a byte array by changing memory page protections and using `Marshall.GetDelegateForFunctionPointer`.

#4about 4 minutes

Hijacking .NET methods at runtime

Discover two techniques for method hijacking: modifying the method descriptor's function pointer or overwriting the method's machine code with a jump instruction.

#5about 6 minutes

A practical use case for method hijacking

Apply method hijacking to the `Process.Start` API by intercepting a constructor to run an application on a different virtual desktop, a feature not exposed by default.

#6about 2 minutes

Intercepting and handling unhandled thread exceptions

Prevent application crashes from unhandled exceptions on new threads by hijacking the `Thread` constructor to wrap the original delegate in a try-catch block.

#7about 4 minutes

How to safely handle a StackOverflowException

Use a vectored exception handler from the WinAPI combined with a setjmp/longjmp approach to catch a `StackOverflowException` and allow the application to continue safely.

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

test

Milly
Vienna, Austria

Intermediate

test

Milly
Vienna, Austria

Intermediate

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?
CH
Chris Heilmann
All the videos of Halfstack London 2024!
Last month was Halfstack London, a conference about the web, JavaScript and half a dozen other things. We were there to deliver a talk, but also to record all the sessions and we're happy to share them with you. It took a bit as we had to wait for th...
All the videos of Halfstack London 2024!
CH
Chris Heilmann
Dev Digest 121 - AI goes offline
Hello fellow developer, let's take a look at the cost of AI and its efficiency, catch up on security issues and sing the praise of new JavaScript and CSS features.News and ArticlesThe way we use AI these days seems powerful, but it isn't very efficie...
Dev Digest 121 - AI goes offline
CH
Chris Heilmann
WWC24 Talk - Scott Hanselman - AI: Superhero or Supervillain?
Join Scott Hanselman at WWC24 to explore AI's role as a superhero or supervillain. Scott shares his 32 years of experience in software engineering, discusses AI myths, ethical dilemmas, and tech advancements. Engage with his live demos and insights o...
WWC24 Talk - Scott Hanselman - AI: Superhero or Supervillain?

From learning to earning

Jobs that call for the skills explored in this talk.

C# Net Developer

C# Net Developer

Developerstrategicsiq Ltd

NoSQL
DevOps
Docker
.NET Core
Kubernetes
+1