Skip to content

Fixes to improve the security and stability of native plugins#108

Open
kirurobo wants to merge 15 commits intomainfrom
dev_win
Open

Fixes to improve the security and stability of native plugins#108
kirurobo wants to merge 15 commits intomainfrom
dev_win

Conversation

@kirurobo
Copy link
Copy Markdown
Owner

Fixes to improve the security and stability of native plugins for v0.9.9

Copilot AI review requested due to automatic review settings March 24, 2026 23:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates LibUniWinC/UniWindowController to v0.9.9 with a focus on native-plugin stability/security improvements (e.g., safer buffer handling, window-proc teardown hardening) and adds new window z-order controls plus Windows ARM64 build support. It also includes a Unity project upgrade and related settings/package churn.

Changes:

  • Add z-order “topmost type” APIs (C++/C#) and expose them in sample UIs; add focus-handling hook intended to re-apply z-order.
  • Harden native code paths (custom window procedure teardown; cap drop-file buffer sizes; validate panel path buffers).
  • Bump versions to 0.9.9 and add Windows ARM64 project/platform configurations (VS projects + Unity plugin metas).

Reviewed changes

Copilot reviewed 31 out of 38 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Xcode/LibUniWinC.xcodeproj/project.pbxproj Bumps macOS bundle marketing version to 0.9.9.
VisualStudio/TestLibUniWinC/TestLibUniWinC.csproj Adds ARM64 build configs for test app.
VisualStudio/TestLibUniWinC/LowLevel/UniWinCore.cs Updates P/Invoke calling convention; adds new native bindings and z-order types; callback registration refactor.
VisualStudio/TestLibUniWinC/FormMain.cs Adds UI control to select z-order type; minor monitor-combobox tweak.
VisualStudio/TestLibUniWinC/FormMain.Designer.cs Adds comboBoxOrderType and reorders generated UI code.
VisualStudio/LibUniWinC/libuniwinc.h Adds TopMostType enum + new exported APIs (focus hook, topmost type setter).
VisualStudio/LibUniWinC/libuniwinc.cpp Large formatting normalization plus stability/security hardening and new mouse/modifier APIs.
VisualStudio/LibUniWinC/Resource.rc Bumps Windows DLL file/product versions to 0.9.9.0.
VisualStudio/LibUniWinC/LibUniWinC.vcxproj Adds ARM64 configurations and updates toolset/settings.
VisualStudio/LibUniWinC.sln Adds ARM64 solution configurations; updates VS version metadata.
UniWinC/ProjectSettings/SceneTemplateSettings.json Adds UnityEngine.PhysicsMaterial scene template entry (Unity upgrade fallout).
UniWinC/ProjectSettings/ProjectVersion.txt Upgrades Unity editor version to 6000.0.x (Unity 6).
UniWinC/ProjectSettings/ProjectSettings.asset Unity 6 settings serialization changes; bundleVersion -> 0.9.9 and many platform defaults updated.
UniWinC/ProjectSettings/MultiplayerManager.asset Adds new Unity MultiplayerManager settings asset (Unity upgrade fallout).
UniWinC/Packages/packages-lock.json Updates/changes package versions and sources (builtin vs registry), adds new built-in modules.
UniWinC/Packages/manifest.json Updates package dependencies and adds new built-in modules.
UniWinC/Assets/Kirurobo/UniWindowController/package.json Bumps UniWindowController package version to 0.9.9.
UniWinC/Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSampleController.cs Adds dropdown wiring to set window order level and reflect current value in UI.
UniWinC/Assets/Kirurobo/UniWindowController/Samples/02_UiSample/UiSample.unity Unity scene serialization changes due to editor upgrade; minor layout tweaks.
UniWinC/Assets/Kirurobo/UniWindowController/Samples/00_Menu/SampleMenu/ReflectionProbe-0.exr.meta Adds meta for sample asset (Unity upgrade/sample changes).
UniWinC/Assets/Kirurobo/UniWindowController/Samples/00_Menu/SampleMenu/LightingData.asset.meta Adds meta for lighting data asset.
UniWinC/Assets/Kirurobo/UniWindowController/Samples/00_Menu/SampleMenu/LightingData.asset Adds lighting data binary asset.
UniWinC/Assets/Kirurobo/UniWindowController/Samples/00_Menu/SampleMenu.meta Adds folder meta for new sample menu assets.
UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/UniWindowController.cs Adds public OrderLevel and SetOrder API; adds focus-loss logic to reapply topmost ordering.
UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Scripts/LowLevel/UniWinCore.cs Adds TopmostType and native bindings + callback registration refactor (Unity runtime copy).
UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Plugins/Windows/x64/LibUniWinC.dll.meta Updates PluginImporter format/settings for Unity 6.
UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Plugins/Windows/ARM64/LibUniWinC.dll.meta Adds PluginImporter settings for Windows ARM64 plugin.
UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Plugins/Windows/ARM64.meta Updates ARM64 plugin folder meta (GUID changed).
UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Plugins/MacOS/LibUniWinC.bundle/Contents/Info.plist Bumps bundle version to 0.9.9 and updates Xcode build metadata.
UniWinC/Assets/Kirurobo/UniWindowController/Runtime/Plugins/MacOS/LibUniWinC.bundle.meta Updates PluginImporter format/settings for Unity 6.
UniWinC/Assets/Kirurobo/UniWindowController/CHANGELOG.md Adds v0.9.9 entry (macOS Unity 6 crash fix reference).
Files not reviewed (1)
  • VisualStudio/TestLibUniWinC/FormMain.Designer.cs: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +13 to +35
platformData:
Any:
enabled: 1
settings:
Exclude Editor: 0
Exclude Linux64: 0
Exclude OSXUniversal: 0
Exclude Win: 1
Exclude Win64: 0
Editor:
enabled: 1
settings:
CPU: ARM64
DefaultValueInitialized: true
OS: Windows
Linux64:
enabled: 1
settings:
CPU: x86_64
OSXUniversal:
enabled: 1
settings:
CPU: None
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Windows ARM64 DLL plugin is marked as enabled for Linux64 and OSXUniversal, and Any does not exclude non-Windows platforms. Since a Windows .dll cannot be loaded on Linux/macOS, this risks breaking non-Windows imports/builds. Restrict PluginImporter platformData so the plugin is only enabled for Windows Editor/Standalone (Win64) targets, and disable/exclude other platforms.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +2
m_EditorVersion: 6000.0.69f1
m_EditorVersionWithRevision: 6000.0.69f1 (5f8607f5118b)
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change bumps the Unity editor version from 2022.3.x to 6000.0.x (Unity 6), which is a major tooling/runtime upgrade. That’s a much larger scope than “security and stability fixes” and can introduce unrelated setting/package churn and compatibility constraints; if the upgrade is intentional for v0.9.9, it should be called out explicitly in the PR description/release notes and validated across supported Unity versions.

Copilot uses AI. Check for mistakes.
Comment on lines +315 to 320
this.comboBoxOrderType.Location = new System.Drawing.Point(144, 68);
this.comboBoxOrderType.Name = "comboBoxOrderType";
this.comboBoxOrderType.Size = new System.Drawing.Size(121, 23);
this.comboBoxOrderType.TabIndex = 3;
this.comboBoxOrderType.SelectedIndexChanged += new System.EventHandler(this.comboBoxTransparentType_SelectedIndexChanged);
//
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comboBoxOrderType is wired to comboBoxTransparentType_SelectedIndexChanged, but FormMain.InitializeControls() already registers a dedicated SelectedIndexChanged lambda for comboBoxOrderType. This will cause the transparent-type handler to fire when the order type changes (and may double-handle the event). Remove this designer-generated handler or wire it to the correct order-type handler only.

Copilot uses AI. Check for mistakes.
Comment on lines 118 to 121
{
int monitor = uniwinc.GetCurrentMonitor();
int count = UniWinCore.GetMonitorCount();
int index = comboBoxFitMonitor.SelectedIndex;
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable 'monitor' is assigned but never used. This adds noise and can trigger warnings depending on build settings; remove it or use it to initialize the combobox selection (e.g., select the current monitor).

Copilot uses AI. Check for mistakes.
Comment on lines +83 to +93
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\ARM64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>ARM64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer32Bit is set to true for the ARM64 configurations. Prefer32Bit is only meaningful for AnyCPU and should be false/omitted for ARM64 builds; leaving it true is misleading and may cause tooling/build issues.

Copilot uses AI. Check for mistakes.
Comment on lines +930 to +934
if (_isTopmost)
{
// フォーカスが外れたのちには最前面状態を再設定
_uniWinCore.OnApplicationFocus(focus);
Debug.Log("Reapply topmost on focus lost.");
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On focus loss, _uniWinCore is used without a null-check. If _isTopmost is true before _uniWinCore is initialized (e.g., via serialized defaults), this can throw a NullReferenceException. Also, the Debug.Log here will spam user logs in production; consider guarding it behind a debug flag or removing it.

Suggested change
if (_isTopmost)
{
// フォーカスが外れたのちには最前面状態を再設定
_uniWinCore.OnApplicationFocus(focus);
Debug.Log("Reapply topmost on focus lost.");
if (_isTopmost && _uniWinCore != null)
{
// フォーカスが外れたのちには最前面状態を再設定
_uniWinCore.OnApplicationFocus(focus);
if (Debug.isDebugBuild)
{
Debug.Log("Reapply topmost on focus lost.");
}

Copilot uses AI. Check for mistakes.
Comment on lines 13 to 37
@@ -23,67 +21,28 @@ PluginImporter:
Exclude OSXUniversal: 0
Exclude Win: 1
Exclude Win64: 0
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
Editor:
enabled: 1
settings:
CPU: AnyCPU
CPU: x86_64
DefaultValueInitialized: true
OS: AnyOS
- first:
Facebook: Win
second:
enabled: 0
settings:
CPU: None
- first:
Facebook: Win64
second:
enabled: 0
settings:
CPU: AnyCPU
- first:
Standalone: Linux
second:
enabled: 1
settings:
CPU: x86
- first:
Standalone: Linux64
second:
OS: Windows
Linux64:
enabled: 1
settings:
CPU: x86_64
- first:
Standalone: LinuxUniversal
second:
OSXUniversal:
enabled: 1
settings:
CPU: AnyCPU
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This Windows DLL plugin is marked as enabled for Linux64 and OSXUniversal (and Any has Exclude Linux/OSX set to 0). A Windows .dll cannot be loaded on Linux/macOS, so this configuration can cause the plugin to be included in non-Windows builds and fail at runtime/import time. Update PluginImporter platformData to disable non-Windows platforms (and/or set the appropriate Exclude * flags) so it is only enabled for Windows Editor/Standalone targets.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants