using System; using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; class SessionStatePausa { [DllImport("kernel32.dll", SetLastError = true)] static extern IntPtr OpenProcess(int dwDesiredAccess, bool bInheritHandle, int dwProcessId); [DllImport("kernel32.dll")] static extern bool WriteProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out uint lpNumberOfBytesWritten); [DllImport("kernel32.dll")] static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, uint nSize, out uint lpNumberOfBytesRead); [DllImport("kernel32.dll")] static extern bool VirtualQueryEx(IntPtr hProcess, IntPtr lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, uint dwLength); struct MEMORY_BASIC_INFORMATION { public IntPtr BaseAddress; public IntPtr AllocationBase; public uint AllocationProtect; public uint RegionSize; public uint State; public uint Protect; public uint Type; } static void Main() { Console.WriteLine("=== SessionStatePausa v1.0 ==="); Console.WriteLine("Target: nvcontainer.exe (GeForce NOW)"); Console.WriteLine(); // Find the process dynamically instead of hardcoded PID Process[] processes = Process.GetProcessesByName("nvcontainer"); if (processes.Length == 0) { Console.WriteLine("[ERROR] nvcontainer.exe not found. Is GeForce NOW running?"); return; } int targetPid = processes[0].Id; Console.WriteLine($"[INFO] Found nvcontainer.exe with PID: {targetPid}"); IntPtr hProc = OpenProcess(0x1F0FFF, false, targetPid); // ALL_ACCESS if (hProc == IntPtr.Zero) { uint errorCode = Marshal.GetLastWin32Error(); Console.WriteLine($"[ERROR] Failed to open process. Error code: 0x{errorCode:X}"); return; } byte[] sessionStatePattern = Encoding.UTF8.GetBytes("sessionState"); IntPtr addr = FindPattern(hProc, sessionStatePattern); if (addr == IntPtr.Zero) { Console.WriteLine("[ERROR] Could not find 'sessionState' pattern in memory."); return; } Console.WriteLine($"[INFO] Found 'sessionState' at 0x{addr.ToInt64():X}"); // Write paused state (value 0 = idle/paused) every 5 seconds byte[] pausedState = new byte[8]; Array.Fill(pausedState, 0); int counter = 0; while (true) { if (!WriteProcessMemory(hProc, addr, pausedState, (uint)pausedState.Length, out uint bytesWritten)) { Console.WriteLine("[ERROR] Failed to write paused state."); break; } counter++; Console.WriteLine($"[OK] Wrote paused state ({counter} times). Timer should pause in ~5 seconds..."); System.Threading.Thread.Sleep(5000); // 5 second interval as per research document } } static IntPtr FindPattern(IntPtr hProc, byte[] pattern) { MEMORY_BASIC_INFORMATION mbi = new MEMORY_BASIC_INFORMATION(); IntPtr addr = new IntPtr(0x100000); while (addr.ToInt64() < 0x7FFFFFFF0000L) { if (!VirtualQueryEx(hProc, addr, ref mbi, (uint)sizeof(mbi))) break; if (mbi.State == 0x1000 && mbi.RegionSize >= pattern.Length) // MEM_COMMIT { IntPtr regionStart = mbi.BaseAddress; for (IntPtr p = regionStart; p.ToInt64() < regionStart.ToInt64() + mbi.RegionSize - pattern.Length; p += 32) { byte[] buffer = new byte[pattern.Length]; if (!ReadProcessMemory(hProc, p, buffer, (uint)buffer.Length, out uint bytesRead)) continue; for (int i = 0; i <= bytesRead - pattern.Length; i++) { bool match = true; for (int j = 0; j < pattern.Length; j++) { if (buffer[i + j] != pattern[j]) { match = false; break; } } if (match) { Console.WriteLine($"[INFO] Found pattern at 0x{p.ToInt64():X}"); return p; } } } } addr = new IntPtr(addr.ToInt64() + mbi.RegionSize); } return IntPtr.Zero; } }