Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ Compatibility can vary with Azimuth and FH2ML versions or other mods. If somethi

Both the standalone EXE and the FH2ML DLL write `%LOCALAPPDATA%\\AzimuthRPC\\logs\\AzimuthRPC.log` (paste that path into Windows Explorer). The native DLL now logs as soon as `FH2ML_Initialize` is called, including rejected host API versions or unsupported game-image checks. If no log is created, first verify the executable actually started or the loader called the DLL initializer; an absent log alone does **not** prove that car offsets changed. Logs can contain runtime telemetry, memory probe values, loaded module names and Discord IPC status, so **review the log before uploading it publicly**.

The **standalone EXE automatically removes `AzimuthRPC.log` and its rotated `.1` log after a normal exit** (tray `Exit`). If it crashes or is force-terminated, logs are kept for troubleshooting. To preserve logs while testing, launch the standalone with `--keep-logs`; copy the log before exiting if you need to share it. Cleanup is best-effort if another process keeps the file open.

The FH2ML native DLL still retains logs: it has no safe, guaranteed shutdown callback, and attempting deletion inside `DllMain` during process teardown could cause instability. Don't run the standalone and native DLL at the same time.

AzimuthRPC does not ask for your Discord password or token. No game files, saves or raw memory captures are included in this repository.

## Build from source
Expand Down
14 changes: 13 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ try {

if ($SmokeTest) {
$exe = Join-Path $PSScriptRoot 'src/AzimuthRPC.App/bin/Release/net8.0-windows/AzimuthRPC.exe'
$process = Start-Process -FilePath $exe -ArgumentList '--smoke-test' -WindowStyle Hidden -PassThru
$process = Start-Process -FilePath $exe -ArgumentList '--smoke-test', '--keep-logs' -WindowStyle Hidden -PassThru
if (-not $process.WaitForExit(15000)) { throw 'Public tray smoke test timed out' }
if ($process.ExitCode -ne 0) { throw "Public tray smoke test failed: $($process.ExitCode)" }
# A zero exit code is not enough: confirm the EXE actually wrote its
Expand All @@ -25,10 +25,12 @@ try {
(Join-Path ([IO.Path]::GetTempPath()) 'AzimuthRPC\AzimuthRPC.log')
)
$startupLogged = $false
$verifiedLog = $null
foreach ($candidate in $candidates) {
if ((Test-Path -LiteralPath $candidate) -and
((Get-Content -LiteralPath $candidate -Raw) -match 'standalone started \(smoke test\)')) {
$startupLogged = $true
$verifiedLog = $candidate
Write-Host "Verified standalone startup log at: $candidate"
break
}
Expand All @@ -37,5 +39,15 @@ try {
throw "Public tray smoke test did not create a startup log in either AppData or TEMP"
}

# Run a normal clean exit and verify the active/rotated files vanish.
$cleanupProcess = Start-Process -FilePath $exe -ArgumentList '--smoke-test' -WindowStyle Hidden -PassThru
if (-not $cleanupProcess.WaitForExit(15000)) { throw 'Public tray cleanup smoke test timed out' }
if ($cleanupProcess.ExitCode -ne 0) { throw "Public tray cleanup smoke test failed: $($cleanupProcess.ExitCode)" }
foreach ($candidate in $candidates) {
if ($candidate -eq $verifiedLog -and ((Test-Path -LiteralPath $candidate) -or (Test-Path -LiteralPath "$candidate.1"))) {
throw "Public tray clean exit left log files behind: $candidate"
}
}
Write-Host "Verified clean shutdown removed standalone active/rotated logs."
}
} finally { Pop-Location }
19 changes: 19 additions & 0 deletions src/AzimuthRPC.App/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ private static void Main(string[] args)
ApplicationConfiguration.Initialize();

bool smokeTest = args.Contains("--smoke-test", StringComparer.OrdinalIgnoreCase);
bool keepLogs = args.Contains("--keep-logs", StringComparer.OrdinalIgnoreCase);
using var mutex = new Mutex(true, @"Local\AzimuthRPC", out bool firstInstance);
if (!firstInstance)
{
Expand Down Expand Up @@ -48,11 +49,13 @@ private static void Main(string[] args)
"AzimuthRPC log fallback", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}

bool exitedNormally = false;
try
{
var config = new AppConfig { Offline = smokeTest };
using var context = new TrayApplicationContext(config, smokeTest, log);
Application.Run(context);
exitedNormally = true;
}
catch (Exception e)
{
Expand All @@ -65,6 +68,9 @@ private static void Main(string[] args)
finally
{
log.Write("AzimuthRPC standalone stopped");
// Leave diagnostics behind if startup fails or the process crashes.
// Only clean files after the normal tray/smoke-test shutdown.
log.DeleteOnDispose = exitedNormally && !keepLogs;
}
}
}
Expand Down Expand Up @@ -232,6 +238,7 @@ private FileLog(string path, StreamWriter writer)

internal string FilePath { get; }
internal string? FallbackReason { get; private set; }
internal bool DeleteOnDispose { get; set; }

internal static FileLog Open()
{
Expand Down Expand Up @@ -281,7 +288,19 @@ public void Dispose()
{
lock (_gate)
{
// Close the writer first; Windows otherwise retains the file handle.
_writer.Dispose();
if (!DeleteOnDispose)
return;

// Delete only our known log files, never user files or the folder.
// Cleanup is best-effort if antivirus/another process has a file open.
foreach (string path in new[] { FilePath, FilePath + ".1" })
{
try { File.Delete(path); }
catch (IOException) { }
catch (UnauthorizedAccessException) { }
}
}
}
}
Loading