Skip to content

Replace native drivelist addon with enumeration via winapis + koffi#22909

Open
halgari wants to merge 6 commits intomasterfrom
halgari/APP-403
Open

Replace native drivelist addon with enumeration via winapis + koffi#22909
halgari wants to merge 6 commits intomasterfrom
halgari/APP-403

Conversation

@halgari
Copy link
Copy Markdown
Contributor

@halgari halgari commented Apr 29, 2026

Summary

  • Replaces the native C++ drivelist addon with pure TS implementations
  • Windows: Uses koffi FFI to call GetLogicalDriveStringsW + GetDriveTypeW from kernel32.dll — the standard Win32 APIs for drive enumeration. Instant (no process spawn), filters to DRIVE_FIXED (type 3).
  • Linux: Parses /proc/mounts filtering for real block devices on common filesystems (ext4, btrfs, xfs, etc.)
  • Removes drivelist from both package.json files, pnpm-workspace.yaml (catalog + allowBuilds), flatpak/generated-sources.json, and the dependency report
  • The getDriveList() API and error handling behavior are preserved — callers are unchanged

Resolves APP-403

Test plan

  • All 1188 tests pass
  • pnpm install succeeds without drivelist
  • Verified koffi drive enumeration returns correct drive letters on Windows 11

@halgari halgari self-assigned this Apr 29, 2026
@halgari halgari marked this pull request as ready for review April 30, 2026 00:01
@halgari halgari requested a review from a team as a code owner April 30, 2026 00:01
@Aragas
Copy link
Copy Markdown
Member

Aragas commented Apr 30, 2026

It's usually not a good idea to spawn a new process that does some action, are we sure it's an acceptable solution?

@github-actions
Copy link
Copy Markdown

This PR has conflicts. You need to rebase the PR before it can be merged.

@halgari
Copy link
Copy Markdown
Contributor Author

halgari commented Apr 30, 2026

The code this replaces calls out to wmi, but now that we already have koffi in place we may be able to replace it with calls into the Nt API, I'll look down that path

@halgari halgari marked this pull request as draft April 30, 2026 16:37
@halgari halgari marked this pull request as ready for review April 30, 2026 17:14
@halgari
Copy link
Copy Markdown
Contributor Author

halgari commented Apr 30, 2026

Done, swapped to koffi, and the implementation remains rather clean.

@github-actions
Copy link
Copy Markdown

This PR doesn't have conflicts anymore. It can be merged after all status checks have passed and it has been reviewed.

halgari added 2 commits April 30, 2026 11:15
drivelist is a native C++ addon that shells out to platform-specific
tools to list drives. Replace it with direct PowerShell
(Get-CimInstance Win32_LogicalDisk) on Windows and /proc/mounts
parsing on Linux. The function is called infrequently (game discovery,
staging folder selection) so the PowerShell startup cost is negligible.

Resolves APP-403
Use GetLogicalDriveStringsW + GetDriveTypeW from kernel32.dll via koffi
instead of spawning powershell.exe. This is instant (no process spawn
overhead), consistent with the koffi approach used elsewhere, and calls
the same Win32 APIs that the old native drivelist module wrapped.
Comment thread src/renderer/src/extensions/gamemode_management/util/getDriveList.ts Outdated
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 5, 2026

This PR has conflicts. You need to rebase the PR before it can be merged.

@halgari halgari changed the title Replace native drivelist addon with PowerShell/proc enumeration Replace native drivelist addon with enumeration via winapis + koffi May 6, 2026
…ist.ts

Co-authored-by: erri120 <erri120@erri120.dev>
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This PR doesn't have conflicts anymore. It can be merged after all status checks have passed and it has been reviewed.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This PR has conflicts. You need to rebase the PR before it can be merged.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This PR doesn't have conflicts anymore. It can be merged after all status checks have passed and it has been reviewed.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

❌ Code is not formatted

To fix this:

  1. Set up the pre-commit hook (prevents future issues):

    pnpm run prepare

    This auto-formats staged files on every commit. (You will never see this error again)

  2. Format all files manually:

    pnpm run format

Then commit the formatting changes. View logs

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 6, 2026

This PR has conflicts. You need to rebase the PR before it can be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants