Exemplo n.º 1
0
        private static void ResolveInjectDLL()
        {
            try
            {
                mmf = MemoryMappedFile.CreateOrOpen("Local\\LeagueSharpBootstrap", 260 * 2,
                                                    MemoryMappedFileAccess.ReadWrite);

                var sharedMem = new SharedMemoryLayout(PathRandomizer.LeagueSharpSandBoxDllPath, PathRandomizer.LeagueSharpBootstrapDllPath,
                                                       Config.Instance.Username, Config.Instance.Password);

                using (var writer = mmf.CreateViewAccessor())
                {
                    var len = Marshal.SizeOf(typeof(SharedMemoryLayout));
                    var arr = new byte[len];
                    var ptr = Marshal.AllocHGlobal(len);
                    Marshal.StructureToPtr(sharedMem, ptr, true);
                    Marshal.Copy(ptr, arr, 0, len);
                    Marshal.FreeHGlobal(ptr);
                    writer.WriteArray(0, arr, 0, arr.Length);
                }

                var hModule = Win32Imports.LoadLibrary(PathRandomizer.LeagueSharpBootstrapDllPath);
                if (!(hModule != IntPtr.Zero))
                {
                    return;
                }

                var procAddress = Win32Imports.GetProcAddress(hModule, "InjectModule");
                if (!(procAddress != IntPtr.Zero))
                {
                    return;
                }

                injectDLL = Marshal.GetDelegateForFunctionPointer(procAddress, typeof(InjectDLLDelegate)) as InjectDLLDelegate;

                procAddress = Win32Imports.GetProcAddress(hModule, "HasModule");
                if (!(procAddress != IntPtr.Zero))
                {
                    return;
                }

                hasModule = Marshal.GetDelegateForFunctionPointer(procAddress, typeof(HasModuleDelegate)) as HasModuleDelegate;

                procAddress = Win32Imports.GetProcAddress(hModule, "GetFilePath");
                if (!(procAddress != IntPtr.Zero))
                {
                    return;
                }

                getFilePath = Marshal.GetDelegateForFunctionPointer(procAddress, typeof(GetFilePathDelegate)) as GetFilePathDelegate;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 2
0
        private static void ResolveInjectDLL()
        {
            try
            {
                SharedMemory      = new SharedMemory <SharedMemoryLayout>("LeagueSharpBootstrap");
                SharedMemory.Data = new SharedMemoryLayout(
                    Directories.AppDomainRandomFilePath,
                    Directories.BootstrapRandomFilePath,
                    Config.Instance.Username,
                    Config.Instance.Password);

                bootstrapper = Win32Imports.LoadLibrary(Directories.BootstrapFilePath);
                if (!(bootstrapper != IntPtr.Zero))
                {
                    return;
                }

                var procAddress = Win32Imports.GetProcAddress(bootstrapper, "InjectModule");
                if (!(procAddress != IntPtr.Zero))
                {
                    return;
                }

                injectDLL =
                    Marshal.GetDelegateForFunctionPointer(procAddress, typeof(InjectDLLDelegate)) as InjectDLLDelegate;

                procAddress = Win32Imports.GetProcAddress(bootstrapper, "HasModule");
                if (!(procAddress != IntPtr.Zero))
                {
                    return;
                }

                hasModule =
                    Marshal.GetDelegateForFunctionPointer(procAddress, typeof(HasModuleDelegate)) as HasModuleDelegate;

                procAddress = Win32Imports.GetProcAddress(bootstrapper, "GetFilePath");
                if (!(procAddress != IntPtr.Zero))
                {
                    return;
                }

                getFilePath =
                    Marshal.GetDelegateForFunctionPointer(procAddress, typeof(GetFilePathDelegate)) as
                    GetFilePathDelegate;
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 3
0
        private static void ResolveInjectDLL()
        {
            var hModule = LoadLibrary(Directories.BootstrapFilePath);

            if (!(hModule != IntPtr.Zero))
            {
                return;
            }
            var procAddress = GetProcAddress(hModule, "_InjectDLL@8");

            if (!(procAddress != IntPtr.Zero))
            {
                return;
            }
            injectDLL =
                Marshal.GetDelegateForFunctionPointer(procAddress, typeof(InjectDLLDelegate)) as InjectDLLDelegate;
        }
Exemplo n.º 4
0
        public static void Bootstrap()
        {
            try
            {
                CreateServiceHost();

                var mmf = MemoryMappedFile.CreateNew("Local\\LeagueSharpBootstrap", 260 * 2,
                                                     MemoryMappedFileAccess.Write);

                using (var writer = mmf.CreateViewAccessor())
                {
                    var path = Directories.SandboxFilePath.ToCharArray();
                    writer.WriteArray(0, path, 0, path.Length);
                }

                const string procedureName = "_InjectDLL@8";
                var          hModule       = Interop.Interop.LoadLibrary(Directories.SandboxFilePath);

                if (hModule.IsZero())
                {
                    Log.WarnFormat("LoadLibrary failed {0}", Directories.SandboxFilePath);
                    return;
                }

                var proc = Interop.Interop.GetProcAddress(hModule, procedureName);

                if (proc.IsZero())
                {
                    Log.WarnFormat("Procedure [{0}] not found at 0x{1}", procedureName, hModule.ToString("X"));
                    return;
                }

                InjectDll = Marshal.GetDelegateForFunctionPointer(proc, typeof(InjectDLLDelegate)) as InjectDLLDelegate;
                Log.InfoFormat("{0} injected at 0x{1}", Path.GetFileName(Directories.SandboxFilePath),
                               hModule.ToString("X"));
            }
            catch (Exception e)
            {
                Log.Warn(e);
            }
        }
Exemplo n.º 5
0
		private static void ResolveInjectDLL()
		{
			try
			{
				mmf = MemoryMappedFile.CreateOrOpen("Local\\LeagueSharpBootstrap", 260 * 2,
					MemoryMappedFileAccess.ReadWrite);

				var sharedMem = new SharedMemoryLayout(PathRandomizer.LeagueSharpSandBoxDllPath, PathRandomizer.LeagueSharpBootstrapDllPath,
					Config.Instance.Username, Config.Instance.Password);

				using (var writer = mmf.CreateViewAccessor())
				{
					var len = Marshal.SizeOf(typeof(SharedMemoryLayout));
					var arr = new byte[len];
					var ptr = Marshal.AllocHGlobal(len);
					Marshal.StructureToPtr(sharedMem, ptr, true);
					Marshal.Copy(ptr, arr, 0, len);
					Marshal.FreeHGlobal(ptr);
					writer.WriteArray(0, arr, 0, arr.Length);
				}

				var hModule = Win32Imports.LoadLibrary(PathRandomizer.LeagueSharpBootstrapDllPath);
				if (!(hModule != IntPtr.Zero))
				{
					return;
				}

				var procAddress = Win32Imports.GetProcAddress(hModule, "InjectModule");
				if (!(procAddress != IntPtr.Zero))
				{
					return;
				}

				injectDLL = Marshal.GetDelegateForFunctionPointer(procAddress, typeof(InjectDLLDelegate)) as InjectDLLDelegate;

				procAddress = Win32Imports.GetProcAddress(hModule, "HasModule");
				if (!(procAddress != IntPtr.Zero))
				{
					return;
				}

				hasModule = Marshal.GetDelegateForFunctionPointer(procAddress, typeof(HasModuleDelegate)) as HasModuleDelegate;

				procAddress = Win32Imports.GetProcAddress(hModule, "GetFilePath");
				if (!(procAddress != IntPtr.Zero))
				{
					return;
				}

				getFilePath = Marshal.GetDelegateForFunctionPointer(procAddress, typeof(GetFilePathDelegate)) as GetFilePathDelegate;
			}
			catch (Exception e)
			{
				Console.WriteLine(e);
			}
		}
Exemplo n.º 6
0
 private static void ResolveInjectDLL()
 {
     var hModule = LoadLibrary(Path.Combine(Directories.CoreDirectory, "LeagueSharp.Bootstrap.dll"));
     if (!(hModule != IntPtr.Zero))
     {
         return;
     }
     var procAddress = GetProcAddress(hModule, "_InjectDLL@8");
     if (!(procAddress != IntPtr.Zero))
     {
         return;
     }
     injectDLL =
         Marshal.GetDelegateForFunctionPointer(procAddress, typeof(InjectDLLDelegate)) as InjectDLLDelegate;
 }