Skip to content

Commit 034e66e

Browse files
committed
Probe: drop a stale check, and print what the launcher's own file looks like if it has no import to patch
1 parent d8af524 commit 034e66e

2 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎.github/workflows/launcher-probe.yml‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ jobs:
8585
if (-not $r.Report) { $failures += "a fault exit code was not reported" }
8686
else {
8787
Write-Host $r.Report
88-
if ($r.Report -notmatch "launcher: the program ended with exit code 0xC0000135 after") { $failures += "the report does not say what happened to the program" }
89-
if ($r.Report -notmatch "Crash Lc0000135") { $failures += "the report has no signature in its title" }
88+
if ($r.Report -notmatch "Crash Lc0000135") { $failures += "the report has no signature in its title" }
9089
foreach ($secret in $env:USERNAME, $env:USERPROFILE, "bid.catch", "203.0.113.7", "hunter2", "2026-10-21") {
9190
if ($r.Report -match [regex]::Escape($secret)) { $failures += "the report still holds '$secret'" }
9291
}
@@ -119,7 +118,14 @@ jobs:
119118
for ($i = $text.IndexOf("mscoree.dll", $ordinal); $i -ge 0; $i = $text.IndexOf("mscoree.dll", $i + 1, $ordinal)) {
120119
[Array]::Copy($replacement, 0, $bytes, $i, $replacement.Length); $found++
121120
}
122-
if (-not $found) { $failures += "the launcher does not import mscoree.dll, so the missing-library check has nothing to patch" }
121+
if (-not $found) {
122+
$failures += "the launcher does not import mscoree.dll, so the missing-library check has nothing to patch"
123+
$at = $text.IndexOf("mscoree", [StringComparison]::OrdinalIgnoreCase)
124+
Write-Host "mscoree (any case) at $at"
125+
if ($at -ge 0) { Write-Host ("around it: " + ($text.Substring([Math]::Max(0, $at - 8), 32) -replace '[^\x20-\x7e]', '.')) }
126+
$pe = [BitConverter]::ToInt32($bytes, 0x3C)
127+
Write-Host ("e_lfanew=$pe machine=0x{0:X} optional magic=0x{1:X}" -f [BitConverter]::ToUInt16($bytes, $pe + 4), [BitConverter]::ToUInt16($bytes, $pe + 24))
128+
}
123129
[System.IO.File]::WriteAllBytes("$PWD\child\patched.exe", $bytes)
124130
foreach ($case in @(@{ file = "child\patched.exe"; want = $true }, @{ file = "launcher-out\lapsecoin-launch.exe"; want = $false })) {
125131
$env:LAPSECOIN_IMPORTS_TEST = "$PWD\$($case.file)"

‎launcher/Launch.cs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static int Main(string[] args)
6161
{
6262
// what was read from the file, then what is missing (the first line is what a test looks at)
6363
File.WriteAllText(Environment.GetEnvironmentVariable("LAPSECOIN_IMPORTS_OUT"),
64-
"imports: " + string.Join(" ", Imports(importsTest).ToArray()) + "\n" +
64+
"imports: " + string.Join(" ", Imports(importsTest).ToArray()) + "\nparse: " + LastParse + "\n" +
6565
LoadProblems(importsTest, Path.GetDirectoryName(importsTest)));
6666
return 0;
6767
}
@@ -409,19 +409,22 @@ static bool LoadsFromWindows(string name)
409409
}
410410

411411
// The names in a program's import table (the libraries it needs before it runs).
412+
static string LastParse = "";
413+
412414
static List<string> Imports(string path)
413415
{
414416
List<string> names = new List<string>();
415417
try
416418
{
417419
byte[] b = File.ReadAllBytes(path);
418420
int pe = BitConverter.ToInt32(b, 0x3C);
419-
if (BitConverter.ToUInt32(b, pe) != 0x00004550u) return names;
421+
if (BitConverter.ToUInt32(b, pe) != 0x00004550u) { LastParse = "no PE signature at " + pe; return names; }
420422
int sections = BitConverter.ToUInt16(b, pe + 6);
421423
int optSize = BitConverter.ToUInt16(b, pe + 20);
422424
int opt = pe + 24;
423425
bool pe64 = BitConverter.ToUInt16(b, opt) == 0x20B;
424426
uint importRva = BitConverter.ToUInt32(b, opt + (pe64 ? 112 : 96) + 8);
427+
LastParse = "pe64=" + pe64 + " sections=" + sections + " optSize=" + optSize + " importRva=0x" + importRva.ToString("X");
425428
if (importRva == 0) return names;
426429
int table = opt + optSize;
427430
Func<uint, int> offset = delegate(uint rva)

0 commit comments

Comments
 (0)