Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Reflection;
- using System.Runtime.InteropServices;
- using System.IO;
- using ProcessDotNet;
- using ProcessDotNet.Applied.Detours;
- namespace Bootstrap
- {
- [UnmanagedFunctionPointer(CallingConvention.Winapi)]
- public delegate void GetSystemInfoDelegate(ref SYSTEM_INFO info);
- [StructLayout(LayoutKind.Sequential)]
- public struct SYSTEM_INFO
- {
- public ushort processorArchitecture;
- ushort reserved;
- public uint pageSize;
- public IntPtr minimumApplicationAddress;
- public IntPtr maximumApplicationAddress;
- public IntPtr activeProcessorMask;
- public uint numberOfProcessors;
- public uint processorType;
- public uint allocationGranularity;
- public ushort processorLevel;
- public ushort processorRevision;
- }
- class Loader
- {
- List<Proxy> _myProxys = new List<Proxy>();
- static void GetSystemInfoDetoured(ref SYSTEM_INFO info)
- {
- info = new SYSTEM_INFO();
- GetSystemInfoDetour.Disable();
- GetSystemInfo(ref info);
- info.allocationGranularity = 1000000;
- GetSystemInfoDetour.Enable();
- }
- static Detour GetSystemInfoDetour;
- static GetSystemInfoDelegate GetSystemInfo;
- static void Main(string[] args)
- {
- TestDomainCreation();
- }
- static void TestDomainCreation()
- {
- AppDomainSetup setup = new AppDomainSetup();
- ProcessSharp s = new ProcessSharp(Process.GetCurrentProcess(), ProcessDotNet.Memory.MemoryType.Local);
- GetSystemInfo = s["kernel32"]["GetSystemInfo"].GetDelegate<GetSystemInfoDelegate>();
- DetourManager dtm = new DetourManager(s.Memory);
- GetSystemInfoDetour = dtm.CreateAndApply(GetSystemInfo, new GetSystemInfoDelegate(GetSystemInfoDetoured), "GetSystemInfoDetour");
- var tempDomain = AppDomain.CreateDomain("HappyDomain", null, setup);
- GetSystemInfoDetour.Disable();
- GetSystemInfoDetour.Dispose();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement