//public Text messageFromIOS; public void BackButton() { NativeAPI.showNativeApp(); }
/// <summary>Adds a line to the environment for the current frame. /// </summary> /// <param name="start">Starting point of the line.</param> /// <param name="end">End point of the line.</param> /// <param name="colorStart">Color for the start of the line, this is /// embedded in the vertex color of the line.</param> /// <param name="colorEnd">Color for the end of the line, this is /// embedded in the vertex color of the line.</param> /// <param name="thickness">Thickness of the line in meters.</param> public static void Add(Vec3 start, Vec3 end, Color32 colorStart, Color32 colorEnd, float thickness) => NativeAPI.line_add(start, end, colorStart, colorEnd, thickness);
static void StartGame(string path, string args = "", string workingDir = null) { System.IO.Stream str = new System.IO.MemoryStream(); GenericGameInfo gen = new GenericGameInfo(null, null, str); bool regMethod = false; if (!Path.IsPathRooted(path)) { string root = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); path = Path.Combine(root, path); } int tri = 0; ProcessStartInfo startInfo; startInfo = new ProcessStartInfo(); startInfo.FileName = path; startInfo.Arguments = args; if (!string.IsNullOrWhiteSpace(workingDir)) { startInfo.WorkingDirectory = workingDir; } try { //proc = Process.Start(startInfo); string currDir = Directory.GetCurrentDirectory(); //bool is64 = EasyHook.RemoteHooking.IsX64Process((int)pi.dwProcessId); if (isHook || renameMutex || setWindow || blockRaw) { var targetsBytes = Encoding.Unicode.GetBytes(mutexToRename); int targetsBytesLength = targetsBytes.Length; var logPath = Encoding.Unicode.GetBytes(nucleusFolderPath); int logPathLength = logPath.Length; //var hidBytes = Encoding.Unicode.GetBytes(rawHid); //int hidBytesLength = hidBytes.Length; int size = 27 + logPathLength + targetsBytesLength; var data = new byte[size]; data[0] = isHook == true ? (byte)1 : (byte)0; data[1] = renameMutex == true ? (byte)1 : (byte)0; data[2] = setWindow == true ? (byte)1 : (byte)0; data[3] = isDebug == true ? (byte)1 : (byte)0; data[4] = blockRaw == true ? (byte)1 : (byte)0; data[10] = (byte)(logPathLength >> 24); data[11] = (byte)(logPathLength >> 16); data[12] = (byte)(logPathLength >> 8); data[13] = (byte)logPathLength; data[14] = (byte)(targetsBytesLength >> 24); data[15] = (byte)(targetsBytesLength >> 16); data[16] = (byte)(targetsBytesLength >> 8); data[17] = (byte)targetsBytesLength; //data[18] = (byte)(hidBytesLength >> 24); //data[19] = (byte)(hidBytesLength >> 16); //data[20] = (byte)(hidBytesLength >> 8); //data[21] = (byte)hidBytesLength; Array.Copy(logPath, 0, data, 18, logPathLength); //Array.Copy(hidBytes, 0, data, 23 + logPathLength, hidBytesLength); Array.Copy(targetsBytes, 0, data, 19 + logPathLength, targetsBytesLength); IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(data, 0, ptr, size); if (!isDelay) // CreateandInject method { if (Is64Bit(path) == true) { try { IntPtr pid = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(uint))); RhCreateAndInject(path, args, 0, 0, Path.Combine(currDir, "Nucleus.SHook32.dll"), Path.Combine(currDir, "Nucleus.SHook64.dll"), ptr, (uint)size, pid); pOutPID = Marshal.ReadInt32(pid); Marshal.FreeHGlobal(pid); } catch (Exception ex) { Log(string.Format("ERROR - {0}", ex.Message)); //using (StreamWriter writer = new StreamWriter("error-log.txt", true)) //{ // writer.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]" + "ex msg: {0}, ex str: {1}", ex.Message, ex.ToString()); //} } } else if (Is64Bit(path) == false) { try { //pidTest = gen.Inject(path, args, 0, 0, Path.Combine(currDir, "Nucleus.Hook32.dll"), null, IntPtr.Zero, 0); string injectorPath = Path.Combine(currDir, "Nucleus.Inject32.exe"); ProcessStartInfo injstartInfo = new ProcessStartInfo(); injstartInfo.FileName = injectorPath; object[] injargs = new object[] { 0, path, args, 0, 0, Path.Combine(currDir, "Nucleus.SHook32.dll"), null, isHook, renameMutex, mutexToRename, setWindow, isDebug, nucleusFolderPath, blockRaw }; var sbArgs = new StringBuilder(); foreach (object arg in injargs) { sbArgs.Append(" \""); sbArgs.Append(arg); sbArgs.Append("\""); } string arguments = sbArgs.ToString(); injstartInfo.Arguments = arguments; //injstartInfo.WindowStyle = ProcessWindowStyle.Hidden; //injstartInfo.CreateNoWindow = true; injstartInfo.UseShellExecute = false; injstartInfo.RedirectStandardOutput = true; Process injectProc = Process.Start(injstartInfo); injectProc.OutputDataReceived += proc_OutputDataReceived; injectProc.BeginOutputReadLine(); //using (StreamWriter writer = new StreamWriter("important.txt", true)) //{ // writer.WriteLine("readtoend: {0}, readline: {1}", injectProc.StandardOutput.ReadToEnd(), injectProc.StandardOutput.ReadLine()); //} injectProc.WaitForExit(); //GenericGameHandler.RhCreateAndInject(path, args, 0, 0, Path.Combine(currDir, "Nucleus.Hook32.dll"), Path.Combine(currDir, "Nucleus.Hook64.dll"), IntPtr.Zero, 0, pid); //pidTest = Nucleus.Injector32.Injector32.RhCreateAndInject(path, args, 0, 0, Path.Combine(currDir, "Nucleus.Hook32.dll"), Path.Combine(currDir, "Nucleus.Hook64.dll"), IntPtr.Zero, 0, pid); } catch (Exception ex) { Log(string.Format("ERROR - {0}", ex.Message)); //using (StreamWriter writer = new StreamWriter("error-log.txt", true)) //{ // writer.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]" + "is64: false, ex msg: {0}, ex str: {1}", ex.Message, ex.ToString()); //} } } else { Log(string.Format("ERROR - Machine type {0} not implemented", GetDllMachineType(path))); //using (StreamWriter writer = new StreamWriter("error-log.txt", true)) //{ // writer.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]" + "Machine type: '{0}' not implemented.", GetDllMachineType(path)); //} } } else // delay method { Log("Starting game using delay method"); string directoryPath = Path.GetDirectoryName(path); STARTUPINFO si = new STARTUPINFO(); PROCESS_INFORMATION pi = new PROCESS_INFORMATION(); bool success = CreateProcess(path, args, IntPtr.Zero, IntPtr.Zero, false, ProcessCreationFlags.CREATE_SUSPENDED, IntPtr.Zero, directoryPath, ref si, out pi); if (!success) { Log(string.Format("ERROR - CreateProcess failed - startGamePath: {0}, startArgs: {1}, dirpath: {2}", path, args, directoryPath)); //using (StreamWriter writer = new StreamWriter("error-log.txt", true)) //{ // writer.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]" + "); //} return; } ResumeThread(pi.hThread); WaitForInputIdle(pi.hProcess, uint.MaxValue); SuspendThread(pi.hThread); if (Is64Bit(path) == true) { NativeAPI.RhInjectLibrary((int)pi.dwProcessId, 0, 0, null, Path.Combine(currDir, "Nucleus.Hook64.dll"), ptr, size); pOutPID = (int)pi.dwProcessId; } else if (Is64Bit(path) == false) { try { string injectorPath = Path.Combine(currDir, "Nucleus.Inject32.exe"); ProcessStartInfo injstartInfo = new ProcessStartInfo(); injstartInfo.FileName = injectorPath; object[] injargs = new object[] { 1, (int)pi.dwProcessId, 0, 0, Path.Combine(currDir, "Nucleus.SHook32.dll"), null, isHook, renameMutex, mutexToRename, setWindow, isDebug, nucleusFolderPath, blockRaw }; var sbArgs = new StringBuilder(); foreach (object arg in injargs) { sbArgs.Append(" \""); sbArgs.Append(arg); sbArgs.Append("\""); } string arguments = sbArgs.ToString(); injstartInfo.Arguments = arguments; //injstartInfo.WindowStyle = ProcessWindowStyle.Hidden; //injstartInfo.CreateNoWindow = true; injstartInfo.UseShellExecute = false; injstartInfo.RedirectStandardOutput = true; Process injectProc = Process.Start(injstartInfo); //injectProc.OutputDataReceived += proc_OutputDataReceived; //injectProc.BeginOutputReadLine(); //using (StreamWriter writer = new StreamWriter("important.txt", true)) //{ // writer.WriteLine("readtoend: {0}, readline: {1}", injectProc.StandardOutput.ReadToEnd(), injectProc.StandardOutput.ReadLine()); //} injectProc.WaitForExit(); } catch (Exception ex) { Log(string.Format("ERROR - {0}", ex.Message)); //using (StreamWriter writer = new StreamWriter("error-log.txt", true)) //{ // writer.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]" + "ex msg: {0}, ex str: {1}", ex.Message, ex.ToString()); //} } } ResumeThread(pi.hThread); pOutPID = (int)pi.dwProcessId; } } else // regular method (no hooks) { proc = Process.Start(startInfo); pOutPID = proc.Id; regMethod = true; } ConsoleU.WriteLine("Game started, process ID:" + pOutPID /*Marshal.ReadInt32(pid)*/ /*proc.Id*/ /*(int)pi.dwProcessId*/, Palette.Success); if (isDebug) { if (regMethod) { Thread.Sleep(100); Log(string.Format("Game started, process {0} (pid {1})", proc.ProcessName, pOutPID)); } else { Thread.Sleep(100); Log(string.Format("Game started, process ID: {0}", pOutPID)); } } } catch (Exception ex) { tri++; if (tri < tries) { if (!ex.Message.Contains("debug-log")) { Log(string.Format("ERROR - Failed to start process. EXCEPTION: {0} STACKTRACE: {1}", ex.Message, ex.StackTrace)); Console.WriteLine("Failed to start process. Retrying..."); } StartGame(path, args); } } }
public void Uninstall() { MessageBox.Show("f**k you"); NativeAPI.LhUninstallAllHooks(); }
private void Awake() { NativeAPI.UnityInitialize(); }
public static void Add(Model model, Matrix transform, Color color) { NativeAPI.render_add_model(model._modelInst, ref transform, color); }
public static void Add(Mesh mesh, Material material, Matrix transform, Color color) { NativeAPI.render_add_mesh(mesh._meshInst, material._materialInst, ref transform, color); }
public void Initialise() { NativeAPI.LhWaitForPendingRemovals(); }
public static void Blit(Tex2D toRendertarget, Material material) { NativeAPI.render_blit(toRendertarget._texInst, material._materialInst); }
public static void Add(Mesh mesh, Material material, Transform transform, Color color) { NativeAPI.render_add_mesh_tr(mesh._meshInst, material._materialInst, transform._transformInst, color); }
public static void SetSkytex(Tex2D skyTexture, bool showSky = true) { NativeAPI.render_set_skytex(skyTexture._texInst, showSky?1:0); }
public static void SetView(Transform cameraTransform) { NativeAPI.render_set_view(cameraTransform._transformInst); }
public static void SetCamera(Camera camera) { NativeAPI.render_set_camera(camera._cameraInst); }
/// <summary>Adds a line based on a ray to the environment for the /// current frame.</summary> /// <param name="ray">The ray we want to visualize!</param> /// <param name="length">How long should the ray be? Actual length /// will be ray.direction.Magnitude * length.</param> /// <param name="color">Color for the line, this is embedded in the /// vertex color of the line.</param> /// <param name="thickness">Thickness of the line in meters.</param> public static void Add(Ray ray, float length, Color32 color, float thickness) => NativeAPI.line_add(ray.position, ray.At(length), color, color, thickness);
Point CalcMousePosition(OverlayLayeredWindow window) { NativeMethods.POINT point = new NativeMethods.POINT(Control.MousePosition); NativeAPI.ScreenToClient(window.Handle, ref point); return(point.ToPoint()); }
public static unsafe long GetMemoryWorkingSet() { Trinity.Win32.NativeAPI.PROCESS_MEMORY_COUNTERS counter = new Trinity.Win32.NativeAPI.PROCESS_MEMORY_COUNTERS(); NativeAPI.GetProcessMemoryInfo(NativeAPI.GetCurrentProcess(), out counter, sizeof(Trinity.Win32.NativeAPI.PROCESS_MEMORY_COUNTERS)); return(counter.WorkingSetSize.ToInt64()); }
/// <summary>This allows you to override the application time! The application /// will progress from this time using the current timescale.</summary> /// <param name="totalSeconds">What time should it now be? The app will progress from this point in time.</param> /// <param name="frameElapsedSeconds">How long was the previous frame? This is a number often used /// in motion calculations. If left to zero, it'll use the previous frame's time, and if the previous /// frame's time was also zero, it'll use 1/90.</param> public static void SetTime(double totalSeconds, double frameElapsedSeconds = 0) => NativeAPI.time_set_time(totalSeconds, frameElapsedSeconds);
public void InstallTooManyHooks_ThrowException() { int maxHookCount = 128; List <LocalHook> hooks = new List <LocalHook>(); // Install MAX_HOOK_COUNT hooks (i.e. 128) for (var i = 0; i < maxHookCount; i++) { LocalHook lh = LocalHook.Create( LocalHook.GetProcAddress("kernel32.dll", "Beep"), new BeepDelegate(BeepHook), this); hooks.Add(lh); } // NOTE: Disposing hooks does not free the memory // need to also call NativeAPI.LhWaitForPendingRemovals() // or LocalHook.Release(); foreach (var h in hooks) { h.Dispose(); } hooks.Clear(); bool exceptionThrown = false; try { // Adding one more hook should result in System.InsufficientMemoryException hooks.Add(LocalHook.Create( LocalHook.GetProcAddress("kernel32.dll", "Beep"), new BeepDelegate(BeepHook), this)); foreach (var h in hooks) { h.Dispose(); } hooks.Clear(); } catch (System.InsufficientMemoryException) { // Correctly threw error because too many hooks exceptionThrown = true; } Assert.IsTrue(exceptionThrown, "System.InsufficientMemoryException was not thrown"); // Ensure the hooks are freed NativeAPI.LhWaitForPendingRemovals(); // Now try to install again after removals processed try { hooks.Add(LocalHook.Create( LocalHook.GetProcAddress("kernel32.dll", "Beep"), new BeepDelegate(BeepHook), this)); } catch (System.InsufficientMemoryException) { Assert.Fail("Disposing of hooks did not free room within GlobalSlotList"); } foreach (var h in hooks) { h.Dispose(); } hooks.Clear(); // Ensure the hooks are freed NativeAPI.LhWaitForPendingRemovals(); }
static void Main(string[] args) { int i = 0; int.TryParse(args[i++], out int Tier); if (Tier == 0) { string InEXEPath = args[i++]; string InCommandLine = args[i++]; uint.TryParse(args[i++], out uint InProcessCreationFlags); uint.TryParse(args[i++], out uint InInjectionOptions); string InLibraryPath_x86 = args[i++]; string InLibraryPath_x64 = args[i++]; bool.TryParse(args[i++], out bool isHook); bool.TryParse(args[i++], out bool renameMutex); string mutexToRename = args[i++]; bool.TryParse(args[i++], out bool setWindow); //IntPtr InPassThruBuffer = Marshal.StringToHGlobalUni(args[i++]); //uint.TryParse(args[i++], out uint InPassThruSize); var targetsBytes = Encoding.Unicode.GetBytes(mutexToRename); int targetsBytesLength = targetsBytes.Length; int size = 7 + targetsBytesLength; var data = new byte[size]; data[0] = isHook == true ? (byte)1 : (byte)0; data[1] = renameMutex == true ? (byte)1 : (byte)0; data[2] = setWindow == true ? (byte)1 : (byte)0; data[3] = (byte)(targetsBytesLength >> 24); data[4] = (byte)(targetsBytesLength >> 16); data[5] = (byte)(targetsBytesLength >> 8); data[6] = (byte)targetsBytesLength; Array.Copy(targetsBytes, 0, data, 7, targetsBytesLength); IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(data, 0, ptr, size); IntPtr pid = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(int))); try { int result = RhCreateAndInject(InEXEPath, InCommandLine, InProcessCreationFlags, InInjectionOptions, InLibraryPath_x86, InLibraryPath_x64, ptr, (uint)size, pid); int attmpts = 0; // 4 additional attempts to inject while (result != 0) { Thread.Sleep(1000); attmpts++; result = RhCreateAndInject(InEXEPath, InCommandLine, InProcessCreationFlags, InInjectionOptions, InLibraryPath_x86, InLibraryPath_x64, ptr, (uint)size, pid); if (attmpts == 4) { break; } } Marshal.FreeHGlobal(pid); Console.WriteLine(Marshal.ReadInt32(pid).ToString()); } catch (Exception ex) { using (StreamWriter writer = new StreamWriter("error-log.txt", true)) { writer.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]" + "ex msg: {0}, ex str: {1}", ex.Message, ex.ToString()); } } } else if (Tier == 1) { int.TryParse(args[i++], out int InTargetPID); int.TryParse(args[i++], out int InWakeUpTID); int.TryParse(args[i++], out int InInjectionOptions); string InLibraryPath_x86 = args[i++]; string InLibraryPath_x64 = args[i++]; //IntPtr InPassThruBuffer = Marshal.StringToHGlobalUni(args[i++]); //int.TryParse(args[i++], out int InPassThruSize); bool.TryParse(args[i++], out bool isHook); bool.TryParse(args[i++], out bool renameMutex); string mutexToRename = args[i++]; bool.TryParse(args[i++], out bool setWindow); var targetsBytes = Encoding.Unicode.GetBytes(mutexToRename); int targetsBytesLength = targetsBytes.Length; int size = 7 + targetsBytesLength; var data = new byte[size]; data[0] = isHook == true ? (byte)1 : (byte)0; data[1] = renameMutex == true ? (byte)1 : (byte)0; data[2] = setWindow == true ? (byte)1 : (byte)0; data[3] = (byte)(targetsBytesLength >> 24); data[4] = (byte)(targetsBytesLength >> 16); data[5] = (byte)(targetsBytesLength >> 8); data[6] = (byte)targetsBytesLength; Array.Copy(targetsBytes, 0, data, 7, targetsBytesLength); IntPtr ptr = Marshal.AllocHGlobal(size); Marshal.Copy(data, 0, ptr, size); try { NativeAPI.RhInjectLibrary(InTargetPID, InWakeUpTID, InInjectionOptions, InLibraryPath_x86, InLibraryPath_x64, ptr, size); } catch (Exception ex) { using (StreamWriter writer = new StreamWriter("error-log.txt", true)) { writer.WriteLine("[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "]" + "ex msg: {0}, ex str: {1}", ex.Message, ex.ToString()); } } } }
public MainView() { _weatherView = new WeatherControlView(); _badgesView = new BadgesControlView(); _dateTimeView = new DateTimeControlView(); _detailedTextView = new DetailedTextControlView(); _musicView = new MusicControlView(); _newsView = new NewsControlView(); _flashlight = new Flashlight(); /*_glance = new Glance(); _glance.GraceTime = TimeSpan.FromSeconds(1); _glance.GlanceEvent += Glance_GlanceEvent;*/ if (!DesignerProperties.IsInDesignTool) { NAPI = new NativeAPI(); var cont = Application.Current.Host.Content; NAPI.InitUIXMAResources((int)Math.Ceiling(cont.ActualWidth * cont.ScaleFactor * 0.01), (int)Math.Ceiling(cont.ActualHeight * cont.ScaleFactor * 0.01)); _secondsTimer = new DispatcherTimer(); _secondsTimer.Interval = new TimeSpan(0, 0, 1); _secondsTimer.Tick += secondsTimer_Tick; } else { PopulateDesignerData(); } MusicView.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { if (e.PropertyName == "HasMusic") { RaisePropertyChanged("LowerPanelVisibility"); RaisePropertyChanged("RightPanelRowSpan"); } }; Flashlight.PropertyChanged += (object sender, PropertyChangedEventArgs e) => { if (e.PropertyName == "IsTurnedOn") { RaisePropertyChanged("FlashlightImageUri"); } }; }
public static void Add(Model model, Transform transform, Color color) { NativeAPI.render_add_model_tr(model._modelInst, transform._transformInst, color); }