Created
February 17, 2022 06:42
-
-
Save fifty-six/f0ec6780eb4646c089feab5bd7c02d98 to your computer and use it in GitHub Desktop.
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
using System.Runtime.CompilerServices; | |
#pragma warning disable CS8604 | |
#pragma warning disable CS8600 | |
C local = null; | |
if (local != null && local.Prop) | |
{ | |
Console.WriteLine(local.ToString()); | |
} | |
class C | |
{ | |
private int _h; | |
public bool Prop | |
{ | |
get | |
{ | |
unsafe | |
{ | |
fixed (int* iptr = &_h) | |
{ | |
var i = (nuint*) iptr; | |
// Kill the vtable | |
*(i - 1) = 0; | |
// Kill the object header too | |
*(i - 2) = 0; | |
} | |
} | |
return true; | |
} | |
} | |
public static bool operator !=(in C a, in C _) | |
{ | |
Unsafe.AsRef(a) = new C(); | |
return true; | |
} | |
public static bool operator ==(C a, C b) => throw new NotImplementedException(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment