Skip to content

Instantly share code, notes, and snippets.

@ZloyChert ZloyChert/Example.cs Secret
Last active Sep 21, 2018

Embed
What would you like to do?
using System;
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Explicit)]
public class CustomStructWithLayout
{
[FieldOffset(0)]
public Test1 Test1;
[FieldOffset(0)]
public Test2 Test2;
}
public class Test1
{
public virtual int Useless(int param)
{
Console.WriteLine(param);
return param;
}
}
public class Test2
{
public virtual int Useless()
{
return 888;
}
}
public class Stub
{
public void Foo(int stub) { }
}
class Program
{
static void Main(string[] args)
{
Test2 fake = new CustomStructWithLayout
{
Test2 = new Test2(),
Test1 = new Test1()
}.Test2;
Stub bar = new Stub();
int param = 55555;
bar.Foo(param);
fake.Useless();
Console.Read();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.