Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class TestClass
- {
- public int Value { get; set; }
- }
- public class InjectorClass
- {
- public int Value { get; set; }
- public void SetterInjecter(int Data)
- {
- Value = ~Data;
- Console.WriteLine("Hello from injected setter!");
- }
- }
- Type testType = typeof(TestClass);
- Type injectType = typeof(InjectorClass);
- Injector.Inject(testType.GetMethod("set_Value"), injectType.GetMethod("SetterInjecter"));
- TestClass test = new TestClass();
- test.Value = int.MinValue;
- Console.WriteLine("test.Value == {0}", test.Value);
- [StructLayout(LayoutKind.Explicit, Size = 4)]
- public struct IntByte
- {
- [FieldOffset(0), MarshalAs(UnmanagedType.I1)]
- public byte _0;
- [FieldOffset(1), MarshalAs(UnmanagedType.I1)]
- public byte _1;
- [FieldOffset(2), MarshalAs(UnmanagedType.I1)]
- public byte _2;
- [FieldOffset(3), MarshalAs(UnmanagedType.I1)]
- public byte _3;
- public IntByte(int From)
- {
- string bits = Convert.ToString(From, 2).PadLeft(32, '0');
- _3 = Convert.ToByte(bits.Substring(0, 8), 2);
- _2 = Convert.ToByte(bits.Substring(8, 8), 2);
- _1 = Convert.ToByte(bits.Substring(16, 8), 2);
- _0 = Convert.ToByte(bits.Substring(24, 8), 2);
- }
- }
- public class InjectorClass
- {
- public IntByte Value { get; set; }
- public void SetterInjecter(int Data)
- {
- Value = new IntByte(~Data);
- Console.WriteLine("Hello from injected setter!nnbyte 0: {0};nbyte 1: {1};nbyte 2: {2};nbyte 3: {3};nn", Value._0, Value._1, Value._2, Value._3);
- }
- }
- dynamic a = new IntByte(1);
- int b = a;
- public class InjectorClass
- {
- public IntByte X { get; set; }
- public void SetterInjecter(int Data)
- {
- X = new IntByte(~Data);
- Console.WriteLine("Hello from injected setter!nnbyte 0: {0};nbyte 1: {1};nbyte 2: {2};nbyte 3: {3};nn", X._0, X._1, X._2, X._3);
- }
- }
Add Comment
Please, Sign In to add comment