fix(engine): make GetMergeStackResult thunk cdecl to stop plugin stack corruption (API v69)
The delegate lacked [UnmanagedFunctionPointer(Cdecl)], so x86 marshalled a stdcall thunk; cdecl callers popped args twice and AutoStack corrupted RynthAi's stack until the client died. SDK now requires v69 before calling it; release build rejects any non-cdecl API delegate. Adds one-time RenderOverlay diagnostics. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
1772e658da
commit
19095e17c0
6 changed files with 71 additions and 3 deletions
|
|
@ -57,6 +57,9 @@ internal sealed class LoadedPlugin
|
|||
/// <summary>Optional RynthPluginRenderOverlay: ImGui windows drawn while the ImGui shell is off.</summary>
|
||||
public PluginRenderDelegate? RenderOverlay { get; set; }
|
||||
|
||||
/// <summary>Set after the first RenderOverlay call has been logged (render thread only).</summary>
|
||||
public bool RenderOverlayLogged { get; set; }
|
||||
|
||||
// ─── Runtime state ───────────────────────────────────────────────
|
||||
public bool Initialized { get; set; }
|
||||
public bool LoginCompleteDispatched { get; set; }
|
||||
|
|
|
|||
|
|
@ -747,7 +747,7 @@ internal unsafe struct VendorTradeStatusNative
|
|||
/// <summary>Current API version. Bump when adding fields to RynthCoreAPI.</summary>
|
||||
internal static class PluginContractVersion
|
||||
{
|
||||
public const uint Current = 68; // v68: GetMergeStackResult
|
||||
public const uint Current = 69; // v69: GetMergeStackResult thunk is cdecl (v68 engines pass a stdcall thunk - unusable)
|
||||
}
|
||||
|
||||
internal static class ClientActionHookFlags
|
||||
|
|
@ -1214,4 +1214,7 @@ internal unsafe delegate uint VendorSellCallbackDelegate(uint vendorId, uint* it
|
|||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int GetVendorTradeStatusCallbackDelegate(VendorTradeStatusNative* status);
|
||||
// Cdecl is mandatory on every API delegate: without it x86 marshals a stdcall thunk, the callee and
|
||||
// the cdecl caller both pop the args, and the plugin's stack drifts on every call.
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
internal unsafe delegate int GetMergeStackResultCallbackDelegate(uint sourceObjectId, uint targetObjectId, int* amount, int* ageMs);
|
||||
|
|
|
|||
|
|
@ -1064,6 +1064,13 @@ internal static class PluginManager
|
|||
if (!plugin.Initialized || plugin.Failed || overlay == null)
|
||||
continue;
|
||||
|
||||
if (!plugin.RenderOverlayLogged)
|
||||
{
|
||||
// One line per plugin per session: proves the engine is actually driving the overlay export.
|
||||
plugin.RenderOverlayLogged = true;
|
||||
RynthLog.Plugin($"PluginManager: first RenderOverlay call for {plugin.DisplayName}.");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
overlay();
|
||||
|
|
|
|||
Loading…
Reference in a new issue