WebPanel fix round 1: close reply by code, loader PE check, no-open scan, drop Core.xml
- RynthCoreChatCommands: each method keeps its own summary; /rc webpanel close answers by the Close code (closing / already closed / could not close); verb added to the class header list. - Build-Installer.ps1: Assert-PeMachine throws unless Runtime\WebView2Loader.dll is x86 (0x14C). - ChatCommandReplyTests: HandleWebPanelCommand has no Open(, Navigate( or ShellExecute. - Engine csproj: Microsoft.Web.WebView2.Core.xml is not copied (with the other dropped WebView2 copies). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
9797db14a3
commit
4e30b16bf5
4 changed files with 42 additions and 9 deletions
|
|
@ -339,6 +339,17 @@ if ($SkipDecalBridge) {
|
|||
# release.txt — which core release this install is ($release, from -Version at the top).
|
||||
Set-Content -Path "$StagingDir\release.txt" -Value @($release, $Version) -Encoding ASCII
|
||||
|
||||
# The PE machine field of a DLL (e_lfanew at 0x3C, then the COFF Machine at PE offset + 4). The game is
|
||||
# 32-bit, so the web panel's native loader must be the x86 one (0x14C): the NuGet package also carries
|
||||
# win-x64 and win-arm64 copies that would load nowhere.
|
||||
function Assert-PeMachine([string]$Path, [int]$Expected) {
|
||||
$bytes = [System.IO.File]::ReadAllBytes($Path)
|
||||
if ($bytes.Length -lt 0x40) { throw "$Path is not a PE file (too short)" }
|
||||
$pe = [System.BitConverter]::ToInt32($bytes, 0x3C)
|
||||
if ($pe -lt 0 -or $pe + 6 -gt $bytes.Length) { throw "$Path is not a PE file (bad e_lfanew)" }
|
||||
$machine = [System.BitConverter]::ToUInt16($bytes, $pe + 4)
|
||||
if ($machine -ne $Expected) { throw ("{0}: PE machine 0x{1:X}, expected 0x{2:X}" -f $Path, $machine, $Expected) }
|
||||
}
|
||||
# Everything a working install needs. The 2026-09-25 public installer went out
|
||||
# without the Loader and the SEH trampoline because nothing checked.
|
||||
$required = @(
|
||||
|
|
@ -369,7 +380,9 @@ if (-not $SkipDecalBridge) {
|
|||
}
|
||||
$missing = @($required | Where-Object { -not (Test-Path $_) })
|
||||
if ($missing.Count -gt 0) { throw "Staging is missing required files:`n $($missing -join "`n ")" }
|
||||
|
||||
if (-not $NativeAot) {
|
||||
Assert-PeMachine "$StagingDir\Runtime\WebView2Loader.dll" 0x14C
|
||||
}
|
||||
# Report staged sizes
|
||||
$engineDll = "$StagingDir\Runtime\RynthCore.Engine.dll"
|
||||
if (Test-Path $engineDll) {
|
||||
|
|
|
|||
|
|
@ -108,6 +108,9 @@ namespace RynthCore.Engine.Compatibility;
|
|||
/// <item><c>/rc uicost [on|off|<ms>|now|status]</c> - the UI frame cost breakdown
|
||||
/// (<see cref="ImGuiBackend.UiCost"/>): timing on or off, the slow-frame threshold, and (now, or
|
||||
/// alone) which parts of the UI frame took the time over the last seconds. Also Settings > Diagnostics.</item>
|
||||
/// <item><c>/rc webpanel [status|close]</c> - the in-game web panel (<see cref="WebPanel.WebPanelApi"/>):
|
||||
/// status is one redacted line (state, handle, visible/focused, browser pid, free address space);
|
||||
/// close closes the panel. It never opens a URL.</item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
internal static class RynthCoreChatCommands
|
||||
|
|
@ -1723,12 +1726,6 @@ internal static class RynthCoreChatCommands
|
|||
ReplyLines(UI.Data.Discord.ChatDiscord.HandleCommand(verb));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// /rc layout: which panel layout this client uses and its files (UI/PanelLayout: the character's own,
|
||||
/// or the PC-wide default and why); default makes this character's the default for new characters;
|
||||
/// reset asks, reset confirm copies the default over this character's. Those two answer when their
|
||||
/// files are written (from the UI writer), or at once with why they can't run.
|
||||
/// </summary>
|
||||
/// <summary>
|
||||
/// /rc webpanel [status|close]. Status: one redacted line (WebPanelApi.Describe plus the address
|
||||
/// space). Close: closes the live panel (WebPanelApi.Close does not block). Nothing here opens a URL.
|
||||
|
|
@ -1741,12 +1738,21 @@ internal static class RynthCoreChatCommands
|
|||
int handle = WebPanel.WebPanelApi.LiveHandle;
|
||||
if (handle <= 0) { Reply("web panel: nothing to close."); return; }
|
||||
int rc = WebPanel.WebPanelApi.Close(handle);
|
||||
Reply($"web panel: close requested (handle {handle}, code {rc}).");
|
||||
// 1 = closing, 0 = already closed (the WebPanelCode values); anything else is a refusal or error.
|
||||
if (rc == 1) Reply("web panel: closing.");
|
||||
else if (rc == 0) Reply("web panel: already closed.");
|
||||
else Fail($"web panel: could not close (code {rc}).");
|
||||
return;
|
||||
}
|
||||
Reply(WebPanel.WebPanelApi.Describe() + "; address space " + AddressSpace.Describe());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// /rc layout: which panel layout this client uses and its files (UI/PanelLayout: the character's own,
|
||||
/// or the PC-wide default and why); default makes this character's the default for new characters;
|
||||
/// reset asks, reset confirm copies the default over this character's. Those two answer when their
|
||||
/// files are written (from the UI writer), or at once with why they can't run.
|
||||
/// </summary>
|
||||
private static void HandleLayoutCommand(string args)
|
||||
{
|
||||
UI.LayoutCommand cmd = UI.PanelLayoutPolicy.ParseCommand(args);
|
||||
|
|
|
|||
|
|
@ -69,6 +69,8 @@
|
|||
<Target Name="DropWebView2UiCopies" AfterTargets="ResolveAssemblyReferences" Condition="'$(EngineHost)' == 'coreclr'">
|
||||
<ItemGroup>
|
||||
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(Filename)' == 'Microsoft.Web.WebView2.WinForms' Or '%(Filename)' == 'Microsoft.Web.WebView2.Wpf'" />
|
||||
<!-- The Core wrapper's XML doc file is not needed at run time. -->
|
||||
<ReferenceCopyLocalPaths Remove="@(ReferenceCopyLocalPaths)" Condition="'%(Filename)%(Extension)' == 'Microsoft.Web.WebView2.Core.xml'" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
|
||||
|
|
|
|||
|
|
@ -344,7 +344,19 @@ internal static class Program
|
|||
Check(!Regex.IsMatch(src, @"\bReply\(\$?""[Uu]sage"), "no usage line is written as a success (they go through Fail)");
|
||||
Check(!Regex.IsMatch(src, @"\bReply\((usage|ServerUsage)\)"), "nor the usage constants");
|
||||
Check(!Regex.IsMatch(src, @"catch \(Exception ex\) \{ RynthLog\.Compat"), "no command's exception is only logged");
|
||||
}
|
||||
|
||||
Case("RynthCoreChatCommands.cs: /rc webpanel never opens or navigates (an arbitrary-URL command would be a phishing vector)");
|
||||
int wpStart = src.IndexOf("private static void HandleWebPanelCommand", StringComparison.Ordinal);
|
||||
int wpEnd = src.IndexOf("private static void HandleLayoutCommand", StringComparison.Ordinal);
|
||||
Check(wpStart > 0 && wpEnd > wpStart, "found HandleWebPanelCommand");
|
||||
if (wpStart > 0 && wpEnd > wpStart)
|
||||
{
|
||||
string wp = src.Substring(wpStart, wpEnd - wpStart);
|
||||
Check(!Regex.IsMatch(wp, @"\bOpen\("), "HandleWebPanelCommand has no Open(");
|
||||
Check(!Regex.IsMatch(wp, @"\bNavigate\("), "HandleWebPanelCommand has no Navigate(");
|
||||
Check(!wp.Contains("ShellExecute", StringComparison.Ordinal), "HandleWebPanelCommand has no ShellExecute");
|
||||
Check(wp.Contains("WebPanelApi.Close(", StringComparison.Ordinal), "the scan reads the real body (it calls WebPanelApi.Close)");
|
||||
} }
|
||||
|
||||
private static string? FindRepoFile(string relative)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue