示例#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);
            }
        }
示例#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);
            }
        }
示例#3
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);
			}
		}