-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7678605
commit e4d3cae
Showing
2 changed files
with
94 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,74 @@ | ||
// See https://aka.ms/new-console-template for more information | ||
Console.WriteLine("Hello, World!"); | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
|
||
const uint PROCESS_VM_READ = 0x10; | ||
|
||
[DllImport("kernel32.dll")] | ||
static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId); | ||
|
||
[DllImport("kernel32.dll")] | ||
static extern bool ReadProcessMemory(IntPtr hProcess, IntPtr lpBaseAddress, byte[] lpBuffer, int dwSize, ref int lpNumberOfBytesRead); | ||
|
||
const int NOITA_SEED_VM_ADDRESS = 0xBEE850; | ||
//const int NOITA_PLAYTIME_VM_ADDRESS = 0x2670; | ||
//const int NOITA_INGAMETIME_VM_ADDRESS = 0xBF10C0; | ||
|
||
Process? noitaProcess = null; | ||
int seed = 0; | ||
|
||
ConsoleColor defaultColor = Console.ForegroundColor; | ||
|
||
while (true) | ||
{ | ||
#region WaitForNoitaProcess | ||
Console.Write($"Waiting for Noita process... "); | ||
|
||
do | ||
{ | ||
IEnumerable<Process> processes = Process.GetProcessesByName("noita") | ||
.Where(p => !p.HasExited); | ||
|
||
switch (processes.Count()) | ||
{ | ||
case 1: | ||
Console.WriteLine("Found!"); | ||
noitaProcess = processes.First(); | ||
break; | ||
case > 1: | ||
Console.ForegroundColor = ConsoleColor.Yellow; | ||
Console.WriteLine("Found!"); | ||
Console.Error.WriteLine($"Warning: Found ${processes.Count()} Noita processes. Selecting most recent."); | ||
Console.ForegroundColor = defaultColor; | ||
noitaProcess = processes.OrderByDescending(p => p.StartTime).First(); | ||
break; | ||
default: | ||
Thread.Sleep(500); | ||
break; | ||
} | ||
} while (noitaProcess == null); | ||
#endregion WaitForNoitaProcess | ||
|
||
#region ReadNoitaSeed | ||
IntPtr processHandle = OpenProcess(PROCESS_VM_READ, false, (uint)noitaProcess.Id); | ||
IntPtr noitaSeedOffset = IntPtr.Add(noitaProcess.MainModule.BaseAddress, NOITA_SEED_VM_ADDRESS); | ||
int bytesRead = 0; | ||
byte[] buffer = new byte[8]; | ||
|
||
do | ||
{ | ||
ReadProcessMemory(processHandle, noitaSeedOffset, buffer, buffer.Length, ref bytesRead); | ||
int currentSeed = BitConverter.ToInt32(buffer, 0); | ||
|
||
if (currentSeed != 0 && currentSeed != seed) | ||
{ | ||
seed = currentSeed; | ||
|
||
Console.ForegroundColor = ConsoleColor.Green; | ||
Console.WriteLine($"Seed: {seed} - https://cr4xy.dev/noita/?seed={seed}"); | ||
Console.ForegroundColor = defaultColor; | ||
} | ||
|
||
Thread.Sleep(500); | ||
} while (!noitaProcess.HasExited); | ||
#endregion ReadNoitaSeed | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,21 @@ | ||
# noisee | ||
Reads the seed of your current Noita run from memory. | ||
|
||
Reads the seed of your current Noita run from memory. | ||
|
||
# How to run | ||
|
||
Start noisee.exe before or after you start Noita. | ||
|
||
# Build from source | ||
|
||
To publish as a single-file binary (requires [.NET 6 Runtime](<https://dotnet.microsoft.com/en-us/download/dotnet/6.0/runtime>)), run | ||
|
||
``` | ||
dotnet publish --output "C:\temp\" --runtime win-x64 --configuration Release -p:PublishSingleFile=true --self-contained false | ||
``` | ||
|
||
To publish as a single-file and self-contained binary, run | ||
|
||
``` | ||
dotnet publish --output "C:\temp\" --runtime win-x64 --configuration Release -p:PublishSingleFile=true -p:PublishTrimmed=true --self-contained true | ||
``` |