diff --git a/.github/agents/e2e-test.md b/.github/agents/e2e-test.md index cc61b294..f7a9ce61 100644 --- a/.github/agents/e2e-test.md +++ b/.github/agents/e2e-test.md @@ -1,6 +1,6 @@ --- name: e2e-test -description: Run end-to-end tests for dynwinrt code generation and WinRT/Classic COM API invocation +description: Run end-to-end tests for dynwinrt code generation and WinRT, Classic COM, and flat Win32 API invocation tools: - powershell - view @@ -24,13 +24,18 @@ You run and manage the dynwinrt end-to-end test suite. # Classic COM only (requires Windows.Win32.winmd) .\tests\e2e\e2e_test.ps1 -SkipBuild -Lang com +# Flat Win32 only (requires Windows.Win32.winmd) +.\tests\e2e\e2e_test.ps1 -SkipBuild -Lang win32 + # Full build + test .\tests\e2e\e2e_test.ps1 ``` ## Adding test cases -Add entries to `tests/e2e/e2e_specs.json`. See `tests/e2e/e2e_specs.schema.json` for the field definitions. +Add WinRT entries to `tests/e2e/e2e_specs.json`. See `tests/e2e/e2e_specs.schema.json` for the field definitions. +Classic COM and flat Win32 scenarios use the runners under `tests/e2e/runners/com/` +and `tests/e2e/runners/win32/`, wired through `tests/e2e/e2e_test.ps1`. Safe WinRT APIs to test (no extra dependencies): - `Windows.Foundation`: Uri, PropertyValue, WwwFormUrlDecoder, MemoryBuffer @@ -43,5 +48,5 @@ Avoid APIs that need WinAppSDK, network, or user interaction. ## Diagnosing failures 1. Check `tests/e2e/e2e_generated/results_py.json` or `results_ts.json` for structured failure details -2. Inspect generated code in `tests/e2e/e2e_generated/python_bindings/`, `ts/`, or `com/` +2. Inspect generated code in `tests/e2e/e2e_generated/python_bindings/`, `ts/`, `com/`, or `win32/` 3. Common issues: circular imports in codegen, naming mismatch (Python snake_case vs TS camelCase) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index d7c19a32..7ad51e44 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -10,6 +10,10 @@ This file provides instructions for the GitHub Copilot coding agent when working - **Python binding** (`bindings/py/`) — PyO3 binding for Python - **Code generator** (`tools/dynwinrt-codegen/`) — Source for dynwinrt-codegen, which generates typed JavaScript (`.js`) + TypeScript declarations (`.d.ts`), or Python (`.py` + optional `.pyi`) wrappers from .winmd metadata +Classic COM and flat Win32 have separate JavaScript/TypeScript projections and +runtime subpaths. Flat Win32 uses its own native ABI, resource, and contract +model; see [the Win32 architecture](../docs/architecture/flat-win32-contracts.md). + ## Build & Test Commands ```bash @@ -53,9 +57,9 @@ The E2E test framework validates the full pipeline: reading .winmd metadata → - `instantiate`: how to create an instance (`activate`, `static_factory`, or `none`) - `checks`: array of assertions (`property_equals`, `property_exists`, `method_equals`, `method_result_contains`, `static_equals`, `static_not_null`) -2. **Runners** (`tests/e2e/runners/py_runner.py`, `tests/e2e/runners/ts_runner.ts`, and `tests/e2e/runners/com/*.mjs`) execute generated WinRT and Classic COM bindings. +2. **Runners** (`tests/e2e/runners/py_runner.py`, `tests/e2e/runners/ts_runner.ts`, `tests/e2e/runners/com/*.mjs`, and `tests/e2e/runners/win32/*.mjs`) execute generated WinRT, Classic COM, and flat Win32 bindings. -3. **Orchestrator** (`tests/e2e/e2e_test.ps1`) handles build, temporary code generation, and runner invocation. Use `-Lang com` for the Classic COM suite; it requires `DYNWINRT_WIN32_WINMD` or an installed `Microsoft.Windows.SDK.Win32Metadata` package. +3. **Orchestrator** (`tests/e2e/e2e_test.ps1`) handles build, temporary code generation, and runner invocation. Use `-Lang com` for Classic COM or `-Lang win32` for flat Win32; both require `DYNWINRT_WIN32_WINMD` or an installed `Microsoft.Windows.SDK.Win32Metadata` package. 4. **Adding new test cases**: Add entries to `tests/e2e/e2e_specs.json`: ```json diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1eaca3c4..8149093c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -72,13 +72,26 @@ jobs: "DYNWINRT_WIN32_WINMD=$($winmd.FullName)" >> $env:GITHUB_ENV "DYNWINRT_REQUIRE_WIN32_METADATA=1" >> $env:GITHUB_ENV - name: Test core library - run: cargo test -p dynwinrt-com-contracts -p dynwinrt - - name: Test borrowed-copy contracts on i686 - run: cargo test -p dynwinrt-com-contracts --target i686-pc-windows-msvc + run: cargo test -p dynwinrt-com-contracts -p dynwinrt-win32-contracts -p dynwinrt + - name: Test native-independent contracts on i686 + run: cargo test -p dynwinrt-com-contracts -p dynwinrt-win32-contracts --target i686-pc-windows-msvc - name: Test borrowed-copy ABI on live i686 run: cargo test -p dynwinrt --target i686-pc-windows-msvc --lib borrowed_copy - name: Test dynwinrt-codegen run: cargo test -p dynwinrt-codegen + - name: Test Win32 binding boundaries and lifetimes + run: cargo test -p jswinrt_rs --lib win32 + - name: Enforce flat Win32 coverage baseline + shell: pwsh + run: | + $json = cargo run -p dynwinrt-codegen --quiet -- win32-census ` + --winmd $env:DYNWINRT_WIN32_WINMD --json + if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } + $result = $json | ConvertFrom-Json + if ($result.eligible_functions -ne 18321 -or $result.complete_functions -lt 8936) { + throw "Flat Win32 coverage regressed: $($result.complete_functions)/$($result.eligible_functions)" + } + Write-Host "Flat Win32 coverage: $($result.complete_functions)/$($result.eligible_functions)" - name: Test raw union MSVC C oracle (x64) run: cargo test -p jswinrt_rs --features test-hooks com_raw::tests::msvc_c_union_oracle_executes_through_libffi -- --exact - name: Test raw union MSVC C oracle (live i686) @@ -274,6 +287,9 @@ jobs: if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE } npm run build:entrypoints --silent npm install --no-save tsx + - name: Test JS binding + working-directory: bindings/js + run: npm test - name: Build Python binding run: | cd bindings/py @@ -402,15 +418,12 @@ jobs: - uses: actions/upload-artifact@v4 with: name: dynwinrt - path: | - bindings/js/dist/dynwinrt.win32-x64-msvc.node - bindings/js/dist/dynwinrt.win32-arm64-msvc.node - bindings/js/dist/index.js - bindings/js/dist/index.d.ts - bindings/js/dist/winrt.js - bindings/js/dist/winrt.d.ts - bindings/js/dist/com.js - bindings/js/dist/com.d.ts - bindings/js/dist/com-projection.js - bindings/js/dist/com-unsafe.js - bindings/js/dist/com-unsafe.d.ts + path: bindings/js/dist/ + if-no-files-found: error + - uses: actions/download-artifact@v4 + with: + name: dynwinrt + path: ${{ runner.temp }}\dynwinrt-artifact + - name: Verify downloaded JS runtime artifact + shell: pwsh + run: node .\bindings\js\scripts\verify-runtime-artifact.mjs "$env:RUNNER_TEMP\dynwinrt-artifact" diff --git a/.gitignore b/.gitignore index 90772da2..fdef3b49 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,10 @@ mono_crash.* x64/ x86/ [Ww][Ii][Nn]32/ +!tools/dynwinrt-codegen/contracts/win32/ +!tools/dynwinrt-codegen/src/codegen/win32/ +!tests/e2e/runners/win32/ +!samples/js/win32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ [Aa][Rr][Mm]64[Ee][Cc]/ diff --git a/CLAUDE.md b/CLAUDE.md index f9e5b429..285c6738 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,6 +6,12 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co `dynwinrt` is a Rust-based runtime library that enables dynamic invocation of Windows Runtime (WinRT) APIs. Unlike static projections (PyWinRT, C++/WinRT), this library uses runtime metadata (.winmd files) and FFI (libffi) to call arbitrary WinRT methods without native code generation. It provides JavaScript (napi-rs) and Python (PyO3) bindings, plus a code generation tool (`dynwinrt-codegen`) that produces typed wrappers from .winmd files. +Classic COM and flat Win32 have separate JavaScript/TypeScript projections and +runtime subpaths. Flat Win32 DLL exports use an independent native ABI and +contract model; see [the Win32 architecture](docs/architecture/flat-win32-contracts.md). +Run `.\tests\e2e\e2e_test.ps1 -SkipBuild -Lang win32` for its E2E suite with +`DYNWINRT_WIN32_WINMD` pointing to the pinned Win32 metadata. + ## Repository Structure ``` diff --git a/Cargo.lock b/Cargo.lock index a1039732..f31e8e22 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -174,7 +174,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.114", ] [[package]] @@ -346,16 +346,24 @@ version = "0.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5" +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + [[package]] name = "dynwinrt" version = "0.1.0" dependencies = [ "criterion", "dynwinrt-com-contracts", + "dynwinrt-win32-contracts", "futures", "libffi", "libffi-sys", "paste", + "serde", "tokio", "windows", "windows-collections", @@ -372,6 +380,7 @@ dependencies = [ "clap", "csv", "dynwinrt-com-contracts", + "dynwinrt-win32-contracts", "fs2", "regex", "roxmltree", @@ -402,6 +411,15 @@ dependencies = [ "windows", ] +[[package]] +name = "dynwinrt-win32-contracts" +version = "0.1.0" +dependencies = [ + "schemars", + "serde", + "serde_json", +] + [[package]] name = "either" version = "1.15.0" @@ -480,7 +498,7 @@ checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.114", ] [[package]] @@ -594,6 +612,7 @@ version = "0.1.0" dependencies = [ "cc", "dynwinrt", + "libffi", "napi", "napi-build", "napi-derive", @@ -688,7 +707,7 @@ dependencies = [ "napi-derive-backend", "proc-macro2", "quote", - "syn", + "syn 2.0.114", ] [[package]] @@ -701,7 +720,7 @@ dependencies = [ "proc-macro2", "quote", "semver", - "syn", + "syn 2.0.114", ] [[package]] @@ -878,7 +897,7 @@ dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn", + "syn 2.0.114", ] [[package]] @@ -890,7 +909,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.114", ] [[package]] @@ -922,6 +941,26 @@ dependencies = [ "crossbeam-utils", ] +[[package]] +name = "ref-cast" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e440fb4e4b4147295338efb76001ab9e4efc0e5839df2c47fc5ac2381d365c3" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92ecd8964f8453721699a1ed72037b0db49ce2f5a5138486ee89bed6f67cdf3a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", +] + [[package]] name = "regex" version = "1.12.3" @@ -984,6 +1023,31 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schemars" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "687274d293b6cdc6e73e0fee520bf2049650090d7164f87672d212a3c530cf4a" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d98c67716b46af2f0b8cf752abc930f6f9aecfbf671ecfb531db8a31dbe4e2ba" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn 3.0.5", +] + [[package]] name = "semver" version = "1.0.27" @@ -1017,7 +1081,18 @@ checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.114", +] + +[[package]] +name = "serde_derive_internals" +version = "0.30.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f852137cce035d6a4df67ccce505ff6b3e9fd3a10e3e52b24dc71e650bb1a9bd" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.5", ] [[package]] @@ -1084,6 +1159,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12df2e0110f65b775f769bb17ef989067a1d931b2eb822bd4346631eeada89f9" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "target-lexicon" version = "0.13.5" @@ -1118,7 +1204,7 @@ checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.114", ] [[package]] @@ -1193,7 +1279,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 2.0.114", "wasm-bindgen-shared", ] @@ -1300,7 +1386,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.114", ] [[package]] @@ -1311,7 +1397,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.114", ] [[package]] @@ -1395,7 +1481,7 @@ checksum = "7e6cc098ea4d3bd6246687de65af3f920c430e236bee1e3bf2e441463f08a02f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.114", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index fd122a89..e6d721f1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = [ "crates/dynwinrt-com-contracts", + "crates/dynwinrt-win32-contracts", "crates/dynwinrt", "bindings/js", "benchmarks/js/static-rust", diff --git a/README.md b/README.md index e6b90a40..d4f196be 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # dynwinrt -**Call Windows Runtime (WinRT) APIs from JavaScript, TypeScript, or Python — without writing a native extension.** +**An experimental runtime for calling Windows APIs from JavaScript, TypeScript, or Python — without writing a native extension.** [![@microsoft/dynwinrt](https://img.shields.io/npm/v/@microsoft/dynwinrt.svg?label=%40microsoft%2Fdynwinrt)](https://www.npmjs.com/package/@microsoft/dynwinrt) [![@microsoft/dynwinrt-codegen](https://img.shields.io/npm/v/@microsoft/dynwinrt-codegen.svg?label=%40microsoft%2Fdynwinrt-codegen)](https://www.npmjs.com/package/@microsoft/dynwinrt-codegen) @@ -8,6 +8,17 @@ [![dynwinrt-codegen on PyPI](https://img.shields.io/pypi/v/dynwinrt-codegen.svg?label=PyPI%20dynwinrt-codegen)](https://pypi.org/project/dynwinrt-codegen/) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) +> **Status: experimental.** `dynwinrt` is under active development and intended +> for evaluation and prototyping. Public APIs, generated bindings, and +> runtime/codegen contracts may change between releases; backward compatibility +> is not yet guaranteed. Do not treat it as a stable production dependency. +> Use matching runtime and codegen versions, regenerate bindings when upgrading, +> and validate the APIs you rely on in your target environment. +> +> WinRT projections are available for JavaScript/TypeScript and Python. +> Classic COM and flat Win32 projections currently support JavaScript/TypeScript +> only, with the capability boundaries described below. + ## Why dynwinrt? If you've ever tried to call a modern Windows API (WinAppSDK, Windows AI, notifications, file pickers, sensors, …) from an Electron, Node, or Python app, you've probably hit one of these walls: @@ -20,7 +31,8 @@ If you've ever tried to call a modern Windows API (WinAppSDK, Windows AI, notifi > **Scope** — `dynwinrt` primarily targets **data-style WinRT APIs**. WinUI > `Application + Window` hosting is also supported on a caller-managed STA UI -> thread. Classic COM has a separate preview surface described below. +> thread. Classic COM and contract-driven flat Win32 have separate +> JavaScript/TypeScript surfaces described below. ## Quick start @@ -207,6 +219,21 @@ contracts or provide a universal overload parser. See the - [Classic COM JavaScript usage guide](docs/guides/windows/classic-com-usage.md) - [Supported ABI, coverage, limitations, and ownership model](docs/architecture/classic-com-support.md) +## Contract-driven flat Win32 + +Generate JavaScript bindings with TypeScript declarations for Win32 DLL exports +from `Windows.Win32.winmd`. Supported features include native structures, +counted buffers, managed resource cleanup, and IOCP-backed asynchronous file I/O. +Explicit subsystem contexts load their lifecycle DLLs on demand. + +An independent `contracts/win32` registry describes ownership, buffer +relationships, and lifecycle rules. Generated bindings use the separate +`@microsoft/dynwinrt/win32` entrypoint, preserving the existing COM and WinRT +semantic models. +See the [supported capabilities and contract boundary](docs/architecture/flat-win32-contracts.md), +[generation command](tools/dynwinrt-codegen/README.md#contract-driven-flat-win32), +and [JavaScript examples](samples/js/win32/README.md). + ## Repository layout ``` diff --git a/bindings/js/Cargo.toml b/bindings/js/Cargo.toml index f99c66b2..2c15768d 100644 --- a/bindings/js/Cargo.toml +++ b/bindings/js/Cargo.toml @@ -23,6 +23,7 @@ windows-string = "0.0.0" pollster = "0.4.0" serde_json = "1" serde = { version = "1", features = ["derive"] } +libffi = "5.1.0" [dependencies.windows] version = ">=0.59, <=0.62" @@ -30,6 +31,11 @@ features = [ "Data_Xml_Dom", "Win32_Security", "Win32_System_Threading", + "Win32_System_IO", + "Win32_Storage_FileSystem", + "Win32_Networking_WinSock", + "Win32_Graphics_GdiPlus", + "Win32_Media_MediaFoundation", "Win32_Storage_Packaging_Appx", "Web_Http", "Win32_System_SystemInformation", diff --git a/bindings/js/README.md b/bindings/js/README.md index 884ed899..5d25143f 100644 --- a/bindings/js/README.md +++ b/bindings/js/README.md @@ -210,6 +210,26 @@ See the repository's codegen, current coverage and limitations, GUID/IID/CLSID, lifetime, Automation, and `/com/unsafe` examples. +### Flat Win32 DLL exports + +Generated Win32 wrappers use `@microsoft/dynwinrt/win32` to invoke DLL exports +described by `Windows.Win32.winmd`. They support validated native structures, +counted buffers, managed handle cleanup, and IOCP-backed asynchronous file I/O. +Manual raw ABI operations remain isolated under +`@microsoft/dynwinrt/win32/unsafe`; the package root stays WinRT-only. + +Winsock, GDI+, and Media Foundation functions that require initialization take +an explicit subsystem context. Keep that context for the required native +lifetime and call `close()` when finished. Lifecycle DLLs load on initialization, +not package import; missing components fail the requested initialization without +adding an eager dependency to ordinary WinRT/COM imports. MAPI utility +initialization is available only on the unsafe subpath and requires a configured +provider. + +See the [Win32 generation guide](../../tools/dynwinrt-codegen/README.md#contract-driven-flat-win32), +[JavaScript samples](../../samples/js/win32/README.md), and +[supported capabilities and ownership rules](../../docs/architecture/flat-win32-contracts.md). + ### Generated WinRT values Unambiguous public WinRT activation metadata is projected as JavaScript constructors. diff --git a/bindings/js/__test__/fixtures/win32-aliases.cjs b/bindings/js/__test__/fixtures/win32-aliases.cjs new file mode 100644 index 00000000..b788b87e --- /dev/null +++ b/bindings/js/__test__/fixtures/win32-aliases.cjs @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +'use strict' + +const assert = require('node:assert/strict') +const { DynWin32: W, DynWin32Function: F } = require('..\\..\\dist\\win32-unsafe.js') +const layout = { + size: 16, + alignment: 4, + fields: ['left', 'top', 'right', 'bottom'].map((name, index) => ({ + name, + offset: index * 4, + count: 1, + type: { kind: 'i32' }, + })), +} +const descriptor = JSON.stringify({ name: 'Tests.RECT', kind: 'struct', x86: layout, x64: layout, arm64: layout }) +const rectangle = W.createNativeStruct(descriptor, Buffer.alloc(16)) +const equal = F.bind({ + dll: 'user32.dll', + entryPoint: 'EqualRect', + parameters: [ + { type: 'pointer', direction: 'in' }, + { type: 'pointer', direction: 'in' }, + ], + returnType: 'bool32', +}) +const pointer = W.nativeStruct(rectangle, descriptor) +assert.throws(() => equal.invoke([pointer, pointer]), /same native aggregate/) +const second = W.createNativeStruct(descriptor, Buffer.alloc(16)) +assert.equal(W.toBoolean(equal.invoke([pointer, W.nativeStruct(second, descriptor)]).returnValue), true) + +const event = F.bind({ + dll: 'kernel32.dll', + entryPoint: 'CreateEventW', + parameters: [ + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'bool32', direction: 'in' }, + { type: 'bool32', direction: 'in' }, + { type: 'pointer', direction: 'in', nullable: true }, + ], + returnType: 'handle', + returnCleanup: 'closeHandle', + successRule: 'nonnull', +}).invoke([W.nullPointer(), W.bool32(true), W.bool32(false), W.nullPointer()]) +assert.equal(event.succeeded, true) +const resource = W.toResource(event.returnValue) +try { + const compare = F.bind({ + dll: 'kernelbase.dll', + entryPoint: 'CompareObjectHandles', + parameters: [ + { type: 'handle', direction: 'in', resourceCleanup: 'closeHandle' }, + { type: 'handle', direction: 'in', resourceCleanup: 'closeHandle' }, + ], + returnType: 'bool32', + }) + const alias = W.toResource(W.handle(resource)) + assert.throws(() => compare.invoke([W.handle(resource), W.handle(alias)]), /same managed Win32 resource/) + resource.close() + assert.equal(alias.closed, true) +} finally { + resource.close() +} +console.log('native-alias-guards-ok') diff --git a/bindings/js/__test__/fixtures/win32-completion-modes.cjs b/bindings/js/__test__/fixtures/win32-completion-modes.cjs new file mode 100644 index 00000000..b20fc6d7 --- /dev/null +++ b/bindings/js/__test__/fixtures/win32-completion-modes.cjs @@ -0,0 +1,191 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const assert = require('node:assert/strict') +const { randomUUID } = require('node:crypto') +const { once } = require('node:events') +const { createServer } = require('node:net') +const { setTimeout: delay } = require('node:timers/promises') +const { DynWin32, DynWin32Function } = require('../../dist/win32-unsafe.js') + +const createFile = DynWin32Function.bind(JSON.parse(process.argv[2])) +const modeSpec = { + dll: 'kernel32.dll', + entryPoint: 'SetFileCompletionNotificationModes', + parameters: [ + { type: 'handle', direction: 'in', resourceCleanup: 'closeHandle' }, + { type: 'u8', direction: 'in' }, + ], + returnType: 'bool32', + successRule: 'nonzero', + captureLastError: true, +} +const trackedModes = DynWin32Function.bind({ + ...modeSpec, + callContractDescriptor: JSON.stringify({ + resourceEffects: [{ kind: 'add-file-completion-modes', handleParameter: 0, flagsParameter: 1 }], + }), +}) +const externalModes = DynWin32Function.bind(modeSpec) +const peek = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'PeekNamedPipe', + parameters: [ + { type: 'handle', direction: 'in', resourceCleanup: 'closeHandle' }, + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'u32', direction: 'in' }, + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'u32', direction: 'out' }, + { type: 'pointer', direction: 'in', nullable: true }, + ], + returnType: 'bool32', + successRule: 'nonzero', +}) +const start = (operation) => + new Promise((resolve, reject) => + operation.start((error, transferred) => (error ? reject(error) : resolve(transferred))), + ) +const resource = (file) => DynWin32.resource(file, 'closeHandle') +const setModes = (file, flags, external = false) => { + const result = (external ? externalModes : trackedModes).invoke([resource(file), DynWin32.u8(flags)]) + assert.equal(result.succeeded, true, `SetFileCompletionNotificationModes: ${result.lastError}`) +} +const waitForNativeCompletion = (file) => { + const wait = new Int32Array(new SharedArrayBuffer(4)) + const deadline = Date.now() + 5000 + while (file.active) { + assert.ok(Date.now() < deadline, 'native completion timed out while JS delivery was blocked') + Atomics.wait(wait, 0, 0, 1) + } +} + +async function scenario(flags, external) { + console.log(`completion modes ${flags}, external=${external}`) + const pipe = `\\\\.\\pipe\\dynwinrt-completion-modes-${randomUUID()}` + let peer + const server = createServer((socket) => { + peer = socket + }) + server.listen(pipe) + await once(server, 'listening') + let file + try { + const connected = once(server, 'connection') + const opened = createFile.invoke([ + DynWin32.wideString(pipe), + DynWin32.u32(0xc0000000), + DynWin32.u32(7), + DynWin32.nullPointer(), + DynWin32.u32(3), + DynWin32.u32(0x40000000), + DynWin32.handle(0n, true), + ]) + assert.equal(opened.succeeded, true) + file = DynWin32.toResource(opened.returnValue) + await connected + setModes(file, flags, external) + setModes(file, 0, external) + + await new Promise((resolve, reject) => peer.write('ready', (error) => (error ? reject(error) : resolve()))) + const available = peek.invoke([ + resource(file), + DynWin32.nullPointer(), + DynWin32.u32(0), + DynWin32.nullPointer(), + DynWin32.nullPointer(), + ]) + assert.equal(available.succeeded, true) + assert.ok(DynWin32.toNumber(available.outputs[0]) >= 5) + const bytes = Buffer.alloc(5) + const immediate = DynWin32.beginReadFile(file, bytes) + assert.throws(() => setModes(file, 1), /completion modes.*asynchronous I\/O/) + let deliveries = 0 + const immediateResult = new Promise((resolve, reject) => + immediate.start((error, transferred) => { + deliveries++ + if (error) reject(error) + else resolve(transferred) + }), + ) + waitForNativeCompletion(file) + assert.equal(deliveries, 0) + assert.equal(file.busy, true) + assert.deepEqual(bytes, Buffer.alloc(5)) + assert.throws(() => file.close(), /asynchronous I\/O/) + assert.throws(() => setModes(file, 1), /completion modes.*asynchronous I\/O/) + immediate.cancel() + assert.equal(await immediateResult, 5) + assert.equal(deliveries, 1) + assert.equal(bytes.toString(), 'ready') + assert.equal(file.busy, false) + assert.equal(file.active, false) + immediate.cancel() + + const cancelled = DynWin32.beginReadFile(file, Buffer.alloc(4)) + const pending = start(cancelled) + assert.equal(file.active, true) + assert.throws(() => setModes(file, 2), /completion modes.*asynchronous I\/O/) + cancelled.cancel() + await assert.rejects(pending, /995/) + assert.equal(file.busy, false) + assert.equal(file.active, false) + + setModes(file, flags | 1, external) + const recovered = Buffer.alloc(4) + const read = start(DynWin32.beginReadFile(file, recovered)) + peer.write('next') + assert.equal(await read, 4) + assert.equal(recovered.toString(), 'next') + assert.equal(file.busy, false) + + await new Promise((resolve, reject) => peer.write('late', (error) => (error ? reject(error) : resolve()))) + const backing = new ArrayBuffer(4) + const detachedResult = start(DynWin32.beginReadFile(file, Buffer.from(backing))) + waitForNativeCompletion(file) + structuredClone(backing, { transfer: [backing] }) + assert.equal(file.busy, true) + await assert.rejects(detachedResult, /detached|changed/) + assert.equal(file.busy, false) + + if (!external && (flags === 0 || flags === 3)) { + await new Promise((resolve, reject) => + peer.write(Buffer.alloc(1024, 0x51), (error) => (error ? reject(error) : resolve())), + ) + const buffers = Array.from({ length: 1024 }, () => Buffer.alloc(1)) + const results = buffers.map((buffer) => start(DynWin32.beginReadFile(file, buffer))) + waitForNativeCompletion(file) + assert.equal(file.busy, true) + assert.ok(buffers.every((buffer) => buffer[0] === 0)) + assert.throws(() => DynWin32.beginReadFile(file, Buffer.alloc(0)), /operation limit/) + assert.deepEqual(await Promise.all(results), Array(1024).fill(1)) + assert.ok(buffers.every((buffer) => buffer[0] === 0x51)) + assert.equal(file.busy, false) + } + + const received = once(peer, 'data') + const original = Buffer.from('back') + const write = DynWin32.beginWriteFile(file, original) + original.fill(0) + assert.equal(await start(write), 4) + assert.equal((await received)[0].toString(), 'back') + assert.equal(file.busy, false) + file.close() + assert.equal(file.closed, true) + await delay(25) + } finally { + if (file && !file.busy) file.close() + peer?.destroy() + await new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve()))) + } +} + +async function main() { + for (const flags of [0, 1, 2, 3]) await scenario(flags, false) + await scenario(3, true) + console.log('PASS completion modes') +} + +main().catch((error) => { + console.error(error) + process.exitCode = 1 +}) diff --git a/bindings/js/__test__/fixtures/win32-io-lifecycle.cjs b/bindings/js/__test__/fixtures/win32-io-lifecycle.cjs new file mode 100644 index 00000000..4dba4201 --- /dev/null +++ b/bindings/js/__test__/fixtures/win32-io-lifecycle.cjs @@ -0,0 +1,217 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +const assert = require('node:assert/strict') +const { randomUUID } = require('node:crypto') +const { once } = require('node:events') +const { createServer } = require('node:net') +const { isMainThread, parentPort, threadId, Worker, workerData } = require('node:worker_threads') + +const DELIVERY_COUNT = 32 +const SENTINEL = 0x5a + +async function bounded(promise, description) { + let timeout + try { + return await Promise.race([ + promise, + new Promise((_, reject) => { + timeout = setTimeout(() => reject(new Error(`${description} timed out`)), 10000) + }), + ]) + } finally { + clearTimeout(timeout) + } +} + +function waitForNativeCompletion(file) { + const wait = new Int32Array(new SharedArrayBuffer(4)) + const deadline = Date.now() + 5000 + while (file.active) { + assert.ok(Date.now() < deadline, 'native I/O did not become terminal while the owner was blocked') + Atomics.wait(wait, 0, 0, 1) + } +} + +async function runWorker() { + const { DynWin32, DynWin32Function } = require('../../dist/win32-unsafe.js') + const opened = DynWin32Function.bind(workerData.spec).invoke([ + DynWin32.wideString(workerData.pipe), + DynWin32.u32(0xc0000000), + DynWin32.u32(7), + DynWin32.nullPointer(), + DynWin32.u32(3), + DynWin32.u32(0x40000000), + DynWin32.handle(0n, true), + ]) + assert.equal(opened.succeeded, true, `CreateFileW: ${opened.lastError}`) + const file = DynWin32.toResource(opened.returnValue) + parentPort.postMessage('opened') + const [command] = await once(parentPort, 'message') + assert.equal(command.ownerThread, threadId) + const { phase, byte } = workerData + let deliveries = 0 + + if (phase === 'prepared-gc') { + assert.equal(typeof global.gc, 'function') + ;(() => { + const operation = DynWin32.beginReadFile(file, Buffer.alloc(4, SENTINEL)) + assert.ok(operation) + assert.equal(file.busy, true) + assert.equal(file.active, false) + })() + const deadline = Date.now() + 5000 + while (file.busy) { + assert.ok(Date.now() < deadline, 'prepared operation GC retained its native lease') + global.gc() + await new Promise((resolve) => setImmediate(resolve)) + } + } else if (phase === 'throwing') { + const buffer = Buffer.alloc(1, SENTINEL) + const expected = new Error('IOCP owner-thread callback exception') + const uncaught = once(process, 'uncaughtException') + DynWin32.beginReadFile(file, buffer).start((error, transferred) => { + deliveries++ + assert.equal(threadId, command.ownerThread) + assert.equal(error, null) + assert.equal(transferred, 1) + assert.equal(buffer[0], byte) + throw expected + }) + waitForNativeCompletion(file) + assert.equal(buffer[0], SENTINEL) + assert.equal(file.busy, true) + const [actual] = await uncaught + assert.equal(actual, expected) + assert.equal(deliveries, 1) + assert.equal(file.busy, false) + + const recovered = Buffer.alloc(1, SENTINEL) + const transferred = await new Promise((resolve, reject) => { + DynWin32.beginReadFile(file, recovered).start((error, output) => { + deliveries++ + assert.equal(threadId, command.ownerThread) + if (error) reject(error) + else resolve(output) + }) + }) + assert.equal(transferred, 1) + assert.equal(recovered[0], byte) + } else { + const count = phase === 'queued' || phase === 'delivered' ? DELIVERY_COUNT : 1 + const buffers = Array.from({ length: count }, () => Buffer.alloc(1, SENTINEL)) + const calls = Array(count).fill(0) + const operations = buffers.map((buffer) => DynWin32.beginReadFile(file, buffer)) + // Prepared work has no TSFN. Keep it reachable until environment teardown. + if (phase === 'prepared') global.preparedOperations = operations + const results = + phase === 'prepared' + ? [] + : operations.map( + (operation, index) => + new Promise((resolve, reject) => { + operation.start((error, output) => { + deliveries++ + assert.equal(threadId, command.ownerThread) + assert.equal(++calls[index], 1) + if (error) reject(error) + else { + assert.equal(buffers[index][0], byte) + resolve(output) + } + }) + }), + ) + if (phase !== 'pending') waitForNativeCompletion(file) + assert.equal(deliveries, 0) + assert.equal(file.busy, true) + assert.ok(buffers.every((buffer) => buffer[0] === SENTINEL)) + if (phase !== 'delivered') { + parentPort.postMessage({ + busy: file.busy, + active: file.active, + deliveries, + unchanged: buffers.every((buffer) => buffer[0] === SENTINEL), + }) + Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0) + throw new Error('blocked owner unexpectedly resumed before teardown') + } + assert.deepEqual(await Promise.all(results), Array(count).fill(1)) + assert.deepEqual(calls, Array(count).fill(1)) + assert.ok(buffers.every((buffer) => buffer[0] === byte)) + } + assert.equal(file.busy, false) + assert.equal(file.active, false) + file.close() + parentPort.postMessage({ busy: false, active: false, deliveries, ownerThread: threadId }) + parentPort.close() +} + +async function scenario(phase, byte = 0x71) { + const pipe = `\\\\.\\pipe\\dynwinrt-io-lifecycle-${randomUUID()}` + let peer + const server = createServer((socket) => { + peer = socket + }) + server.listen(pipe) + await once(server, 'listening') + const connected = once(server, 'connection') + const worker = new Worker(__filename, { + workerData: { phase, byte, pipe, spec: JSON.parse(process.argv[2]) }, + }) + const ownerThread = worker.threadId + const exited = once(worker, 'exit') + try { + assert.deepEqual(await bounded(once(worker, 'message'), `${phase} open`), ['opened']) + await bounded(connected, `${phase} connection`) + const closed = once(peer, 'close') + if (phase === 'queued' || phase === 'delivered' || phase === 'throwing') { + const count = phase === 'throwing' ? 2 : DELIVERY_COUNT + await new Promise((resolve, reject) => + peer.write(Buffer.alloc(count, byte), (error) => (error ? reject(error) : resolve())), + ) + } + const settled = once(worker, 'message') + worker.postMessage({ ownerThread }) + const [state] = await bounded(settled, `${phase} state`) + if (phase === 'prepared' || phase === 'pending' || phase === 'queued') { + assert.deepEqual(state, { busy: true, active: phase === 'pending', deliveries: 0, unchanged: true }) + await bounded(worker.terminate(), `${phase} terminate`) + } else { + assert.deepEqual(state, { + busy: false, + active: false, + deliveries: phase === 'prepared-gc' ? 0 : phase === 'throwing' ? 2 : DELIVERY_COUNT, + ownerThread, + }) + assert.deepEqual(await bounded(exited, `${phase} exit`), [0]) + } + await bounded(closed, `${phase} native pipe retirement`) + console.log(`IOCP lifecycle ${phase}: ok`) + } finally { + await worker.terminate() + peer?.destroy() + await new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve()))) + } +} + +async function main() { + // Only workers load the addon. The pinned IOCP workers and shared relay must + // survive each environment unload, including pending and queued teardown. + for (const phase of ['prepared-gc', 'prepared', 'pending', 'queued', 'throwing']) await scenario(phase) + await Promise.all([scenario('delivered', 0x31), scenario('delivered', 0x72)]) + console.log('PASS IOCP owner-thread lifecycle') +} + +if (isMainThread) { + main().catch((error) => { + console.error(error) + process.exitCode = 1 + }) +} else { + runWorker().catch((error) => { + console.error(error) + process.exitCode = 1 + parentPort.close() + }) +} diff --git a/bindings/js/__test__/helpers/optional-media-foundation.d.mts b/bindings/js/__test__/helpers/optional-media-foundation.d.mts new file mode 100644 index 00000000..c896256b --- /dev/null +++ b/bindings/js/__test__/helpers/optional-media-foundation.d.mts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export function isMissingMediaFoundation(error: unknown): error is Error diff --git a/bindings/js/__test__/helpers/optional-media-foundation.mjs b/bindings/js/__test__/helpers/optional-media-foundation.mjs new file mode 100644 index 00000000..9fba3a34 --- /dev/null +++ b/bindings/js/__test__/helpers/optional-media-foundation.mjs @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** Only the explicit System32 loader's missing-component errors permit a skip. */ +export function isMissingMediaFoundation(/** @type {unknown} */ error) { + if (!(error instanceof Error)) return false + return ( + /^0x8007007E: System DLL `mfplat\.dll` could not be loaded from System32: .+/.test(error.message) || + /^0x8007007F: Export `(?:MFStartup|MFShutdown)` was not found in `mfplat\.dll`(?: |$)/.test(error.message) + ) +} diff --git a/bindings/js/__test__/index.spec.ts b/bindings/js/__test__/index.spec.ts index bbb13a10..8037fd1d 100644 --- a/bindings/js/__test__/index.spec.ts +++ b/bindings/js/__test__/index.spec.ts @@ -43,6 +43,8 @@ import { DynComRawStructLayout, DynComRawUnionLayout, } from '../dist/com-unsafe-raw.js' +import { DynWin32, DynWin32Function, DynWin32Unsafe } from '../dist/win32-unsafe.js' +import * as win32Runtime from '../dist/win32.js' const requireFromTest = createRequire(import.meta.url) const nativeRuntime = requireFromTest('../dist/index.js') as Record @@ -50,6 +52,8 @@ const winrtCjsRuntime = requireFromTest('../dist/winrt.js') as Record const unsafeComRuntime = requireFromTest('../dist/com-unsafe.js') as Record const rawComRuntime = requireFromTest('../dist/com-unsafe-raw.js') as Record +const win32CjsRuntime = requireFromTest('../dist/win32.js') as Record +const unsafeWin32Runtime = requireFromTest('../dist/win32-unsafe.js') as Record const moduleKeys = (value: object) => Object.keys(value) @@ -148,8 +152,40 @@ test('Classic COM is isolated from the WinRT root entrypoint', (t) => { test('package facades exactly partition native exports', (t) => { const nativeKeys = moduleKeys(nativeRuntime) + const win32NativeNames = new Set([ + 'DynWin32', + 'DynWin32Unsafe', + 'win32Bind', + 'win32CarrierKind', + 'win32NativeStructBytes', + 'win32NativeStructLength', + 'win32ResourceValue', + 'win32ResourceClosed', + 'win32ResourceBusy', + 'win32ResourceActive', + 'win32ResourceClose', + 'win32FunctionDll', + 'win32FunctionEntryPoint', + 'win32Invoke', + 'win32InvokeWithSubsystem', + 'win32ResultReturnValue', + 'win32ResultOutputs', + 'win32ResultLastError', + 'win32ResultSucceeded', + 'win32SubsystemName', + 'win32SubsystemClosed', + 'win32SubsystemClose', + 'win32OverlappedCancel', + 'win32OverlappedStart', + ]) + t.deepEqual( + nativeKeys.filter((name) => name.startsWith('win32') || name.startsWith('DynWin32')), + [...win32NativeNames].sort(), + ) const expectedWinrt = [ - ...nativeKeys.filter((name) => !name.startsWith('DynCom') && name !== 'initializeCom'), + ...nativeKeys.filter( + (name) => !name.startsWith('DynCom') && name !== 'initializeCom' && !win32NativeNames.has(name), + ), 'DynWinRtImplementationHandle', ].sort() const safeComNames = new Set([ @@ -207,6 +243,19 @@ test('package facades exactly partition native exports', (t) => { moduleKeys(rawComRuntime), [...nativeKeys.filter((name) => rawComNames.has(name)), 'projectAs', '__registerComProjection', '__comProjectionIid', '__activateAudioInterfaceAsync'].sort(), ) + for (const facade of [winrtCjsRuntime, comCjsRuntime, unsafeComRuntime, rawComRuntime]) { + for (const name of win32NativeNames) { + t.false(Object.prototype.hasOwnProperty.call(facade, name)) + } + const safeWin32Names = [ + 'DynWin32', 'DynWin32NativeStruct', 'DynWin32OverlappedOperation', 'DynWin32Resource', + 'DynWin32SubsystemContext', 'DynWin32Value', 'DynWinRtValue', + ] + t.deepEqual(moduleKeys(win32CjsRuntime), safeWin32Names.sort()) + t.deepEqual(moduleKeys(unsafeWin32Runtime), [ + ...safeWin32Names, 'DynWin32CallResult', 'DynWin32Function', 'DynWin32Unsafe', + ].sort()) + } t.is(winrtCjsRuntime.WinGuid, comCjsRuntime.WinGuid) t.is(comCjsRuntime.initializeCom, unsafeComRuntime.initializeCom) @@ -225,6 +274,120 @@ test('package facades exactly partition native exports', (t) => { } }) +test('flat Win32 is isolated and raw addresses require the unsafe entrypoint', (t) => { + for (const facade of [winrtRuntime, comRuntime]) { + t.false(Object.prototype.hasOwnProperty.call(facade, 'DynWin32')) + } + t.false(Object.prototype.hasOwnProperty.call(win32Runtime, 'DynWin32Unsafe')) + t.false(Object.prototype.hasOwnProperty.call(win32Runtime, 'DynWin32Function')) + t.false(Object.prototype.hasOwnProperty.call(win32Runtime.DynWin32, 'createNativeStruct')) + t.false(Object.prototype.hasOwnProperty.call(win32Runtime.DynWin32, 'initializeMapiUtilities')) + t.is(typeof DynWin32.dataPointer, 'function') + t.is(typeof win32Runtime.DynWin32Value, 'function') + t.throws(() => DynWin32.dataPointer(0x1234n as never), { message: /arbitrary numeric addresses/ }) + const pointer = DynWin32.dataPointer(Buffer.alloc(4)) + t.throws(() => DynWin32.toBigint(pointer), { message: /not a 64-bit integer/ }) + t.truthy(DynWin32Unsafe.pointerAddress(pointer)) + t.truthy(DynWin32Unsafe.pointer(0x1234n)) + t.truthy(DynWin32.handle(null, true)) + t.throws(() => DynWin32.handle(null), { message: /explicitly nullable/ }) + t.throws(() => DynWin32.dataPointer(Buffer.alloc(0)), { message: /non-empty backing storage/ }) + t.truthy(DynWin32.dataPointer(Buffer.alloc(0), true)) +}) + +test('flat Win32 immutable plans validate ABI before native dispatch', (t) => { + const mulDiv = DynWin32Function.bind({ + dll: 'kernel32.dll', entryPoint: 'MulDiv', + parameters: Array.from({ length: 3 }, () => ({ type: 'i32', direction: 'in' })), + returnType: 'i32', successRule: 'always', captureLastError: false, + }) + const call = mulDiv.invoke([DynWin32.i32(100), DynWin32.i32(3), DynWin32.i32(2)]) + t.is(DynWin32.toNumber(call.returnValue!), 150) + t.deepEqual(call.outputs, []) + t.throws(() => call.outputs, { message: /already consumed/ }) + t.throws(() => mulDiv.invoke([DynWin32.u32(100), DynWin32.i32(3), DynWin32.i32(2)]), { + message: /does not match I32/, + }) + const consuming = DynWin32Function.bind({ + dll: 'advapi32.dll', entryPoint: 'RegCloseKey', + parameters: [{ type: 'handle', direction: 'in', consumesResource: true, resourceCleanup: 'regCloseKey' }], + returnType: 'i32', successRule: 'zero', + }) + t.throws(() => consuming.invoke([DynWin32.handle(0x80000002n)]), { message: /managed resource object/ }) +}) + +test('flat Win32 native aggregate storage is aligned and exactly identified', (t) => { + const layout = { size: 8, alignment: 4, fields: [] } + const descriptor = JSON.stringify({ name: 'Tests.POINT', kind: 'struct', x86: layout, x64: layout, arm64: layout }) + const bytes = Buffer.from([1, 0, 0, 0, 2, 0, 0, 0]) + const point = DynWin32.createNativeStruct(descriptor, bytes) + t.is(point.length, 8) + t.deepEqual(point.bytes, bytes) + t.truthy(DynWin32.nativeStruct(point, descriptor)) + t.throws(() => DynWin32.nativeStruct(point, descriptor.replace('POINT', 'SIZE')), { message: /type mismatch/ }) + const huge = { size: 16 * 1024 * 1024 + 8, alignment: 8, fields: [] } + t.throws(() => DynWin32.createNativeStruct(JSON.stringify({ + name: 'Tests.HUGE', kind: 'struct', x86: huge, x64: huge, arm64: huge, + })), { message: /safety limit/ }) + t.throws(() => DynWin32.createNativeStruct(`${descriptor}${' '.repeat(1024 * 1024)}`), { message: /descriptor exceeds/ }) +}) + +test('flat Win32 multi-strings retain double-NUL ownership', (t) => { + t.truthy(DynWin32.wideMultiString(['en-US', 'fr-FR'])) + t.truthy(DynWin32.ansiMultiString(['alpha', 'beta'])) + t.throws(() => DynWin32.wideMultiString(Buffer.from([65, 0, 0, 0])), { message: /two NUL code units/ }) + t.throws(() => DynWin32.ansiMultiString(Buffer.from([65, 0])), { message: /two NUL bytes/ }) + t.truthy(DynWin32.wideMultiString(Buffer.from([65, 0, 0, 0, 0, 0]))) + t.truthy(DynWin32.ansiMultiString(Buffer.from([65, 0, 0]))) +}) + +test('flat Win32 subsystem contexts enforce kind and close state', (t) => { + const winsock = DynWin32.initializeWinsock() + t.is(winsock.subsystem, 'winsock') + t.false(winsock.closed) + t.notThrows(() => DynWin32.requireSubsystem(winsock, 'winsock')) + t.throws(() => DynWin32.requireSubsystem(winsock, 'gdiplus'), { message: /received winsock/ }) + winsock.close() + t.true(winsock.closed) + t.throws(() => DynWin32.requireSubsystem(winsock, 'winsock'), { message: /context is closed/ }) + t.notThrows(() => winsock.close()) + const gdiplus = DynWin32.initializeGdiPlus() + t.notThrows(() => DynWin32.requireSubsystem(gdiplus, 'gdiplus')) + gdiplus.close() + t.is(typeof DynWin32.initializeMapiUtilities, 'function') +}) + +test('flat Win32 pointer-bearing aggregates retain safe field owners', (t) => { + const layout = (wide: boolean) => ({ + size: wide ? 24 : 12, alignment: wide ? 8 : 4, + fields: [ + { name: 'nLength', offset: 0, count: 1, type: { kind: 'u32' } }, + { name: 'lpSecurityDescriptor', offset: wide ? 8 : 4, count: 1, type: { kind: 'pointer' } }, + { name: 'bInheritHandle', offset: wide ? 16 : 8, count: 1, type: { kind: 'i32' } }, + ], + }) + const descriptor = JSON.stringify({ + name: 'Windows.Win32.Security.SECURITY_ATTRIBUTES', kind: 'struct', + x86: layout(false), x64: layout(true), arm64: layout(true), + }) + t.throws(() => DynWin32.createNativeStruct(descriptor, Buffer.alloc(24)), { message: /raw bytes/ }) + const attributes = DynWin32.createNativeStruct(descriptor) + DynWin32.setNativeStructU32(attributes, descriptor, 'nLength', attributes.length) + DynWin32.setNativeStructBool32(attributes, descriptor, 'bInheritHandle', true) + const storage = new Uint8Array(20) + DynWin32.setNativeStructPointer(attributes, descriptor, 'lpSecurityDescriptor', DynWin32.dataPointer(storage)) + t.throws(() => attributes.bytes, { message: /unavailable/ }) + t.throws(() => DynWin32.setNativeStructPointer( + attributes, descriptor, 'lpSecurityDescriptor', DynWin32Unsafe.pointer(0x1234n), + ), { message: /retained Buffer or string storage/ }) + const aggregate = DynWin32.nativeStruct(attributes, descriptor) + structuredClone(storage.buffer, { transfer: [storage.buffer] }) + const noArgs = DynWin32Function.bind({ + dll: 'kernel32.dll', entryPoint: 'GetLastError', parameters: [], returnType: 'u32', + }) + t.throws(() => noArgs.invoke([aggregate]), { message: /detached/ }) +}) + test('FORMATETC and STGMEDIUM expose a closed HGLOBAL semantic subset', (t) => { const format = DynComFormatEtc.hglobal(13) t.is(format.clipboardFormat, 13) diff --git a/bindings/js/__test__/pe-imports.spec.ts b/bindings/js/__test__/pe-imports.spec.ts new file mode 100644 index 00000000..f9f4b912 --- /dev/null +++ b/bindings/js/__test__/pe-imports.spec.ts @@ -0,0 +1,264 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import test from 'ava' +import { mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' +import { assertNoEagerWin32Imports, readPeImports, verifyAddonImports } from '../scripts/pe-imports.mjs' + +function fixture(wide: boolean) { + const bytes = Buffer.alloc(0x800) + const optional = 0x98 + const optionalSize = wide ? 240 : 224 + const directory = optional + (wide ? 112 : 96) + const sections = optional + optionalSize + bytes.write('MZ') + bytes.writeUInt32LE(0x80, 0x3c) + bytes.writeUInt32LE(0x4550, 0x80) + bytes.writeUInt16LE(wide ? 0x8664 : 0x14c, 0x84) + bytes.writeUInt16LE(2, 0x86) + bytes.writeUInt16LE(optionalSize, 0x94) + bytes.writeUInt16LE(wide ? 0x20b : 0x10b, optional) + bytes.writeUInt32LE(0x200, optional + 60) + bytes.writeUInt32LE(16, directory - 4) + bytes.writeUInt32LE(0x2020, directory + 8) + bytes.writeUInt32LE(60, directory + 12) + for (const [index, rva, size, offset] of [ + [0, 0x2000, 0x500, 0x200], + [1, 0x4000, 0x100, 0x700], + ]) { + const section = sections + index * 40 + bytes.write(index ? '.names' : '.idata', section) + bytes.writeUInt32LE(size, section + 8) + bytes.writeUInt32LE(rva, section + 12) + bytes.writeUInt32LE(size, section + 16) + bytes.writeUInt32LE(offset, section + 20) + } + for (const [descriptor, lookup, name, address] of [ + [0x220, 0x2080, 0x4020, 0x20c0], + [0x234, 0x20a0, 0x4060, 0x20e0], + ]) { + bytes.writeUInt32LE(lookup, descriptor) + bytes.writeUInt32LE(name, descriptor + 12) + bytes.writeUInt32LE(address, descriptor + 16) + } + const writeThunk = (offset: number, value: bigint) => { + if (wide) bytes.writeBigUInt64LE(value, offset) + else bytes.writeUInt32LE(Number(value), offset) + } + const width = wide ? 8 : 4 + for (const offset of [0x280, 0x2c0]) { + writeThunk(offset, 0x4040n) + writeThunk(offset + width, (1n << BigInt(width * 8 - 1)) | 17n) + } + for (const offset of [0x2a0, 0x2e0]) writeThunk(offset, 0x4080n) + bytes.write('KERNEL32.dll\0', 0x720) + bytes.writeUInt16LE(7, 0x740) + bytes.write('GetTickCount\0', 0x742) + bytes.write('MFPLAT.DLL\0', 0x760) + bytes.write('MFStartup\0', 0x782) + bytes.write('mapi32.dll\0GdiplusStartup\0', 0x600) + return { bytes, optional, directory, sections, width, writeThunk } +} + +const expected = [ + { dll: 'KERNEL32.dll', symbols: ['GetTickCount', 17] }, + { dll: 'MFPLAT.DLL', symbols: ['MFStartup'] }, +] + +for (const wide of [false, true]) { + const format = wide ? 'PE32+' : 'PE32' + + test(`Win32 ${format} parser follows DLL and named/ordinal thunk RVAs across sections`, (t) => { + t.deepEqual(readPeImports(fixture(wide).bytes), expected) + }) + + test(`Win32 ${format} parser falls back to FirstThunk when OriginalFirstThunk is absent`, (t) => { + const { bytes } = fixture(wide) + bytes.writeUInt32LE(0, 0x220) + bytes.writeUInt32LE(0, 0x234) + t.deepEqual(readPeImports(bytes), expected) + }) + + test(`Win32 ${format} parser supports header RVAs and an absent import directory`, (t) => { + const { bytes, directory } = fixture(wide) + bytes.writeUInt32LE(0x1e0, 0x22c) + bytes.write('ole32.dll\0', 0x1e0) + t.deepEqual(readPeImports(bytes), [{ ...expected[0], dll: 'ole32.dll' }, expected[1]]) + bytes.writeUInt32LE(1, directory - 4) + t.deepEqual(readPeImports(bytes), []) + bytes.writeUInt32LE(16, directory - 4) + bytes.writeUInt32LE(0, directory + 8) + bytes.writeUInt32LE(0, directory + 12) + t.deepEqual(readPeImports(bytes), []) + }) + + test(`Win32 ${format} parser ignores delay imports and incidental DLL/symbol strings`, (t) => { + const { bytes, directory } = fixture(wide) + bytes.writeUInt32LE(0, directory + 8) + bytes.writeUInt32LE(0, directory + 12) + bytes.writeUInt32LE(0x2020, directory + 13 * 8) + bytes.writeUInt32LE(60, directory + 13 * 8 + 4) + t.deepEqual(readPeImports(bytes), []) + }) + + const malformed: [string, (image: ReturnType) => void, RegExp][] = [ + ['MZ signature', ({ bytes }) => bytes.writeUInt16LE(0, 0), /missing MZ/], + ['PE header offset', ({ bytes }) => bytes.writeUInt32LE(0xfffffff0, 0x3c), /truncated PE header/], + ['overlapping PE header', ({ bytes }) => bytes.writeUInt32LE(2, 0x3c), /invalid PE header offset/], + ['PE signature', ({ bytes }) => bytes.writeUInt32LE(0, 0x80), /missing PE signature/], + ['optional header size', ({ bytes }) => bytes.writeUInt16LE(2, 0x94), /truncated optional header/], + ['optional header magic', ({ bytes, optional }) => bytes.writeUInt16LE(0x107, optional), /unsupported.*magic/], + ['directory count', ({ bytes, directory }) => bytes.writeUInt32LE(17, directory - 4), /directories exceed/], + ['section table', ({ bytes }) => bytes.writeUInt16LE(0xffff, 0x86), /truncated section table/], + ['header size', ({ bytes, optional }) => bytes.writeUInt32LE(0x100, optional + 60), /SizeOfHeaders/], + ['section data', ({ bytes, sections }) => bytes.writeUInt32LE(0x800, sections + 16), /truncated section data/], + ['section in headers', ({ bytes, sections }) => bytes.writeUInt32LE(0x100, sections + 20), /overlaps headers/], + ['section RVA overflow', ({ bytes, sections }) => bytes.writeUInt32LE(0xffffff00, sections + 12), /RVA overflow/], + ['zero directory RVA', ({ bytes, directory }) => bytes.writeUInt32LE(0, directory + 8), /invalid import directory/], + [ + 'zero directory size', + ({ bytes, directory }) => bytes.writeUInt32LE(0, directory + 12), + /invalid import directory/, + ], + ['short directory', ({ bytes, directory }) => bytes.writeUInt32LE(19, directory + 12), /invalid import directory/], + [ + 'directory terminator', + ({ bytes, directory }) => bytes.writeUInt32LE(40, directory + 12), + /unterminated import directory/, + ], + ['unmapped directory', ({ bytes, directory }) => bytes.writeUInt32LE(0x3000, directory + 8), /unmapped.*directory/], + ['unmapped name', ({ bytes }) => bytes.writeUInt32LE(0x3000, 0x22c), /unmapped.*DLL name/], + ['missing address table', ({ bytes }) => bytes.writeUInt32LE(0, 0x230), /missing import address table/], + ['unmapped thunk', ({ bytes }) => bytes.writeUInt32LE(0x3000, 0x220), /unmapped.*thunk/], + ['empty DLL name', ({ bytes }) => bytes.writeUInt8(0, 0x720), /empty DLL name/], + ['non-ASCII DLL name', ({ bytes }) => bytes.writeUInt8(0xff, 0x720), /non-ASCII DLL name/], + ['empty symbol', ({ bytes }) => bytes.writeUInt8(0, 0x742), /empty import symbol/], + ['ambiguous RVA', ({ bytes, sections }) => bytes.writeUInt32LE(0x2000, sections + 40 + 12), /ambiguous.*directory/], + [ + 'virtual-only directory', + ({ bytes, sections, directory }) => { + bytes.writeUInt32LE(0x1000, sections + 8) + bytes.writeUInt32LE(0x2600, directory + 8) + }, + /directory is not file-backed/, + ], + [ + 'thunk terminator', + ({ bytes, width, writeThunk }) => { + bytes.writeUInt32LE(0x2500 - width, 0x220) + writeThunk(0x700 - width, 0x4040n) + }, + /unterminated import thunk/, + ], + [ + 'DLL terminator', + ({ bytes }) => { + bytes.writeUInt32LE(0x40fc, 0x22c) + bytes.fill(65, 0x7fc) + }, + /unterminated DLL name/, + ], + [ + 'symbol terminator', + ({ bytes, writeThunk }) => { + writeThunk(0x280, 0x40fan) + bytes.fill(65, 0x7fc) + }, + /unterminated import symbol/, + ], + ['hint/name bounds', ({ writeThunk }) => writeThunk(0x280, 0x40fen), /hint\/name is not file-backed/], + [ + 'ordinal reserved bits', + ({ width, writeThunk }) => writeThunk(0x280, (1n << BigInt(width * 8 - 1)) | 0x10011n), + /reserved ordinal thunk bits/, + ], + ] + for (const [name, corrupt, message] of malformed) { + test(`Win32 ${format} parser rejects malformed ${name}`, (t) => { + const image = fixture(wide) + corrupt(image) + t.throws(() => readPeImports(image.bytes), { message }) + }) + } +} + +test('Win32 PE parser rejects truncated buffers and oversized PE32+ name RVAs', (t) => { + const { bytes, writeThunk } = fixture(true) + for (const length of [0, 2, 63, 0x90, 0x100, 0x7ff]) { + t.throws(() => readPeImports(bytes.subarray(0, length)), { message: /^Invalid PE import table:/ }) + } + writeThunk(0x280, 0x100004040n) + t.throws(() => readPeImports(bytes), { message: /import name RVA overflow/ }) + t.throws(() => readPeImports('not a Buffer' as unknown as Buffer), { instanceOf: TypeError }) +}) + +test('Win32 production import policy bans optional DLLs, including ordinals, regardless of case or path', (t) => { + for (const dll of ['mfplat.dll', 'GDIPLUS.DLL', 'ws2_32.dll', 'C:\\Windows\\System32\\MAPI32.dll']) { + for (const symbols of [['MFCreateSample'], [17], []]) { + t.throws(() => assertNoEagerWin32Imports([{ dll, symbols }]), { message: /must load lazily/ }) + } + } + t.notThrows(() => + assertNoEagerWin32Imports([ + { dll: 'KERNEL32.dll', symbols: ['LoadLibraryExW', 'GetProcAddress'] }, + { dll: 'ole32.dll', symbols: ['CoInitializeEx'] }, + ]), + ) + t.throws(() => assertNoEagerWin32Imports(readPeImports(fixture(true).bytes)), { message: /MFPLAT\.DLL: MFStartup/ }) +}) + +test('Win32 test-hooks import policy permits only the exact existing COM media fixture symbol', (t) => { + t.notThrows(() => + assertNoEagerWin32Imports([{ dll: 'mfplat.dll', symbols: ['MFCreateSample'] }], { testHooks: true }), + ) + for (const symbol of ['MFStartup', 'MFShutdown', 'MFCreateMemoryBuffer', 'MFCreateSomethingNew', 17]) { + t.throws( + () => + assertNoEagerWin32Imports([{ dll: 'mfplat.dll', symbols: ['MFCreateSample', symbol] }], { testHooks: true }), + { message: /must load lazily/ }, + ) + } + for (const dll of ['ws2_32.dll', 'gdiplus.dll', 'mapi32.dll']) { + t.throws(() => assertNoEagerWin32Imports([{ dll, symbols: ['MFCreateSample'] }], { testHooks: true })) + } + t.throws(() => assertNoEagerWin32Imports([{ dll: 'mfplat.dll', symbols: [] }], { testHooks: true })) +}) + +test('Win32 artifact import verification checks every shipped architecture without loading binaries', (t) => { + const directory = mkdtempSync(fileURLToPath(new URL('../target-pe-imports-', import.meta.url))) + const x64 = 'dynwinrt.win32-x64-msvc.node' + const arm64 = 'dynwinrt.win32-arm64-msvc.node' + const safe = fixture(true) + safe.bytes.write('ole32.dll\0', 0x760) + const hooks = fixture(true) + hooks.bytes.fill(0, 0x782) + hooks.bytes.write('MFCreateSample\0', 0x782) + try { + t.throws(() => verifyAddonImports(directory), { message: /No native addons/ }) + writeFileSync(join(directory, x64), safe.bytes) + writeFileSync(join(directory, 'not-an-addon.txt'), fixture(true).bytes) + t.deepEqual(verifyAddonImports(directory), [x64]) + writeFileSync(join(directory, arm64), fixture(true).bytes) + t.throws(() => verifyAddonImports(directory), { message: /arm64-msvc\.node:.*eager PE imports/ }) + writeFileSync(join(directory, arm64), safe.bytes) + t.deepEqual(verifyAddonImports(directory), [arm64, x64]) + writeFileSync(join(directory, x64), hooks.bytes) + t.throws(() => verifyAddonImports(directory), { message: /x64-msvc\.node:.*eager PE imports/ }) + t.deepEqual(verifyAddonImports(directory, { testHooksAddon: x64 }), [arm64, x64]) + writeFileSync(join(directory, arm64), hooks.bytes) + t.throws(() => verifyAddonImports(directory, { testHooksAddon: x64 }), { + message: /arm64-msvc\.node:.*eager PE imports/, + }) + t.throws(() => verifyAddonImports(directory, { testHooksAddon: 'absent.node' }), { + message: /Missing test-hooks addon/, + }) + writeFileSync(join(directory, x64), Buffer.from('MZ')) + t.throws(() => verifyAddonImports(directory), { message: /arm64-msvc\.node:.*eager PE imports/ }) + writeFileSync(join(directory, arm64), safe.bytes) + t.throws(() => verifyAddonImports(directory), { message: /x64-msvc\.node: Invalid PE import table/ }) + } finally { + rmSync(directory, { recursive: true, force: true }) + } +}) diff --git a/bindings/js/__test__/win32-contracts.spec.ts b/bindings/js/__test__/win32-contracts.spec.ts new file mode 100644 index 00000000..7f56f11b --- /dev/null +++ b/bindings/js/__test__/win32-contracts.spec.ts @@ -0,0 +1,1265 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import test from 'ava' +import { spawnSync } from 'node:child_process' +import { randomUUID } from 'node:crypto' +import { once } from 'node:events' +import { cpSync, mkdtempSync, rmSync, writeFileSync, unlinkSync } from 'node:fs' +import { createRequire } from 'node:module' +import { createServer, type Socket } from 'node:net' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { Worker } from 'node:worker_threads' +import { fileURLToPath } from 'node:url' +import { DynCom, DynWinRtValue, initializeCom } from '../dist/com-unsafe.js' +import { DynWinRtType, WinGuid } from '../dist/winrt.js' +import { + DynWin32, + DynWin32Function, + DynWin32NativeStruct, + DynWin32Resource, + DynWin32Unsafe, + type DynWin32OverlappedOperation, +} from '../dist/win32-unsafe.js' +import * as safe from '../dist/win32.js' + +const require = createRequire(import.meta.url) +const machine = () => DynWin32.handle(0x80000002n) +const openKey = () => { + const open = DynWin32Function.bind({ + dll: 'advapi32.dll', + entryPoint: 'RegOpenKeyExW', + parameters: [ + { type: 'handle', direction: 'in' }, + { type: 'pointer', direction: 'in' }, + { type: 'u32', direction: 'in' }, + { type: 'u32', direction: 'in' }, + { type: 'handle', direction: 'out', cleanup: 'regCloseKey' }, + ], + returnType: 'i32', + successRule: 'zero', + }) + const result = open.invoke([ + machine(), + DynWin32.wideString('SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion'), + DynWin32.u32(0), + DynWin32.u32(1), + ]) + if (!result.succeeded) throw new Error(`RegOpenKeyExW: ${DynWin32.toNumber(result.returnValue!)}`) + return DynWin32.toResource(result.outputs[0])! +} +const consumeKey = () => + DynWin32Function.bind({ + dll: 'advapi32.dll', + entryPoint: 'RegCloseKey', + parameters: [ + { + type: 'handle', + direction: 'in', + consumesResource: true, + resourceCleanup: 'regCloseKey', + }, + ], + returnType: 'i32', + successRule: 'zero', + }) +const pointDescriptor = () => { + const layout = { + size: 8, + alignment: 4, + fields: [ + { name: 'x', offset: 0, count: 1, type: { kind: 'i32' } }, + { name: 'y', offset: 4, count: 1, type: { kind: 'i32' } }, + ], + } + return JSON.stringify({ name: 'Tests.POINT', kind: 'struct', x86: layout, x64: layout, arm64: layout }) +} + +test('Win32 facades retain the full isolated runtime without manual safe descriptors', (t) => { + t.deepEqual( + Object.keys(safe) + .filter((key) => !['default', 'module.exports'].includes(key)) + .sort(), + [ + 'DynWin32', + 'DynWin32NativeStruct', + 'DynWin32OverlappedOperation', + 'DynWin32Resource', + 'DynWin32SubsystemContext', + 'DynWin32Value', + 'DynWinRtValue', + ].sort(), + ) + for (const facade of ['winrt', 'com', 'com-unsafe', 'com-unsafe-raw']) { + t.false(Object.keys(require(`../dist/${facade}.js`)).some((name) => /win32/i.test(name))) + } + t.false('createNativeStruct' in safe.DynWin32) + t.false('initializeMapiUtilities' in safe.DynWin32) + t.is(typeof DynWin32.initializeMapiUtilities, 'function') + for (const [entryPoint, returnType, expected] of [ + ['GetTickCount', 'u32', 'number'], + ['GetTickCount64', 'u64', 'bigint'], + ] as const) { + const result = DynWin32Function.bind({ dll: 'kernel32.dll', entryPoint, parameters: [], returnType }).invoke([]) + t.is( + typeof (returnType === 'u64' ? DynWin32.toBigint(result.returnValue!) : DynWin32.toNumber(result.returnValue!)), + expected, + ) + t.deepEqual(result.outputs, []) + } +}) + +test('Win32 artifact consumers require the complete runtime dependency tree', (t) => { + const artifact = mkdtempSync(fileURLToPath(new URL('../target-artifact-', import.meta.url))) + const consumer = fileURLToPath(new URL('../scripts/verify-runtime-artifact.mjs', import.meta.url)) + const hostAddon = fileURLToPath(new URL(`../dist/dynwinrt.win32-${process.arch}-msvc.node`, import.meta.url)) + const testHooks = typeof require(hostAddon).DynComBorrowedCopyTestFixture === 'function' + const consumerArgs = [consumer, artifact, ...(testHooks ? ['--test-hooks'] : [])] + try { + cpSync(fileURLToPath(new URL('../dist/', import.meta.url)), artifact, { recursive: true }) + const complete = spawnSync(process.execPath, consumerArgs, { encoding: 'utf8', timeout: 15000 }) + t.is(complete.status, 0, `${complete.error}\n${complete.stdout}\n${complete.stderr}`) + unlinkSync(join(artifact, 'win32-internal.js')) + const incomplete = spawnSync(process.execPath, consumerArgs, { encoding: 'utf8', timeout: 15000 }) + t.is(incomplete.status, 1, `${incomplete.error}\n${incomplete.stdout}\n${incomplete.stderr}`) + t.regex(incomplete.stderr, /Cannot find module '\.\/win32-internal\.js'/) + } finally { + rmSync(artifact, { recursive: true, force: true }) + } +}) + +test('Win32 native tags reject forged handles, structs, values and receivers', (t) => { + const resource = openKey() + const descriptor = pointDescriptor() + const point = DynWin32.createNativeStruct(descriptor) + try { + t.true(resource instanceof DynWin32Resource) + for (const forged of [ + 0x80000002n, + { value: resource.value }, + Object.create(DynWin32Resource.prototype), + Object.setPrototypeOf(DynWin32.i32(1), DynWin32Resource.prototype), + Object.setPrototypeOf(Buffer.alloc(8), DynWin32Resource.prototype), + Object.setPrototypeOf(DynWin32.createNativeStruct(descriptor), DynWin32Resource.prototype), + ]) { + t.throws(() => DynWin32.resource(forged as never, 'regCloseKey')) + t.throws(() => DynWin32Resource.prototype.close.call(forged)) + } + for (const forged of [ + {}, + Object.create(DynWin32NativeStruct.prototype), + Object.setPrototypeOf(DynWin32.i32(1), DynWin32NativeStruct.prototype), + ]) { + t.throws(() => DynWin32.nativeStruct(forged as never, descriptor), { message: /native DynWin32NativeStruct/ }) + const getter = Object.getOwnPropertyDescriptor(DynWin32NativeStruct.prototype, 'bytes')!.get! + t.throws(() => getter.call(forged)) + } + t.throws(() => DynWin32.toNumber(point as never), { message: /native DynWin32Value/ }) + t.throws(() => DynWin32Function.prototype.invoke.call(point, []), { message: /native DynWin32Function/ }) + const alias = DynWin32.toResource(DynWin32.handle(resource))! + t.true(consumeKey().invoke([DynWin32.resource(resource, 'regCloseKey')]).succeeded) + t.true(resource.closed) + t.true(alias.closed) + t.notThrows(() => alias.close()) + t.throws(() => DynWin32.resource(resource, 'regCloseKey'), { message: /closed/ }) + } finally { + resource.close() + } +}) + +test('Win32 native alias contracts share HKEY ownership and preserve borrowed inputs', (t) => { + for (const suffix of ['A', 'W']) { + const open = DynWin32Function.bind({ + dll: 'advapi32.dll', + entryPoint: `RegOpenKey${suffix}`, + parameters: [ + { type: 'handle', direction: 'in', resourceCleanup: 'regCloseKey' }, + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'handle', direction: 'out', cleanup: 'regCloseKey' }, + ], + returnType: 'i32', + successRule: 'zero', + callContractDescriptor: JSON.stringify({ + outputs: [ + { + parameter: 2, + when: { inputs: [{ kind: 'null-or-empty', parameter: 1, elementWidth: suffix === 'W' ? 2 : 1 }] }, + action: { kind: 'alias-input', parameter: 0 }, + }, + ], + }), + }) + for (const empty of [null, '']) { + const text = + empty === null + ? DynWin32.nullPointer() + : suffix === 'W' + ? DynWin32.wideString(empty) + : DynWin32.ansiString(empty) + const owner = openKey() + try { + const result = open.invoke([DynWin32.resource(owner, 'regCloseKey'), text]) + t.true(result.succeeded) + const alias = DynWin32.toResourceOrHandle(result.outputs[0]) + if (!(alias instanceof DynWin32Resource)) throw new Error('Expected a shared managed HKEY') + t.is(alias.value, owner.value) + alias.close() + t.true(owner.closed) + t.true(alias.closed) + t.throws(() => DynWin32.resource(owner, 'regCloseKey'), { message: /closed/ }) + t.notThrows(() => alias.close()) + } finally { + owner.close() + } + const borrowed = open.invoke([machine(), text]) + t.true(borrowed.succeeded) + t.is(DynWin32.toResourceOrHandle(borrowed.outputs[0]), 0x80000002n) + } + } +}) + +test('Win32 predefined HKEY aliases use native pointer-width values, not truncated bits', (t) => { + for (const suffix of ['A', 'W']) { + const open = DynWin32Function.bind({ + dll: 'advapi32.dll', + entryPoint: `RegOpenKeyEx${suffix}`, + parameters: [ + { type: 'handle', direction: 'in', resourceCleanup: 'regCloseKey' }, + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'u32', direction: 'in' }, + { type: 'u32', direction: 'in' }, + { type: 'handle', direction: 'out', cleanup: 'regCloseKey' }, + ], + returnType: 'i32', + successRule: 'zero', + callContractDescriptor: JSON.stringify({ + outputs: [ + { + parameter: 4, + when: { + inputs: [ + { kind: 'handle-in', parameter: 0, values: [-2147483646] }, + { kind: 'null-or-empty', parameter: 1, elementWidth: suffix === 'W' ? 2 : 1 }, + ], + }, + action: { kind: 'alias-input', parameter: 0 }, + }, + ], + }), + }) + for (const key of [-2147483646n, 0x80000002n]) { + for (const empty of [null, '']) { + const text = + empty === null + ? DynWin32.nullPointer() + : suffix === 'W' + ? DynWin32.wideString(empty) + : DynWin32.ansiString(empty) + const result = open.invoke([DynWin32.handle(key), text, DynWin32.u32(0), DynWin32.u32(0x20019)]) + t.true(result.succeeded) + const output = DynWin32.toResourceOrHandle(result.outputs[0]) + if (key < 0n) { + t.is(output, DynWin32.toBigint(DynWin32.handle(key))) + } else { + if (!(output instanceof DynWin32Resource)) throw new Error('Expected a new owned HKEY') + t.not(output.value, key) + output.close() + t.true(output.closed) + } + } + } + } +}) + +test('Win32 buffer lengths come from native backing storage and never truncate success', (t) => { + let getterCalls = 0 + const backing = Buffer.from([1, 2, 3, 4, 5, 6]) + const value = backing.subarray(1, 5) + for (const property of ['length', 'byteLength']) { + Object.defineProperty(value, property, { + get() { + getterCalls++ + return 0xffffffff + }, + }) + } + t.is(DynWin32.bufferLength(value), 4) + t.is(DynWin32.byteLength(value), 4) + t.is(DynWin32.bufferByteLength(value), 4) + t.is(safe.DynWin32.byteLength(value), 4) + t.is(safe.DynWin32.bufferByteLength(value), 4) + t.deepEqual(DynWin32.copyBuffer(value), Buffer.from([2, 3, 4, 5])) + t.deepEqual(DynWin32.copyBuffer(value, 2), Buffer.from([2, 3])) + t.throws(() => DynWin32.copyBuffer(value, 5), { message: /exceeds native buffer capacity/ }) + t.truthy(DynWin32.dataPointer(value)) + t.is(getterCalls, 0) + for (const length of [-1, 0.5, NaN, Infinity, 64 * 1024 * 1024 + 1]) { + t.throws(() => DynWin32.allocateBuffer(length), { message: /64 MiB/ }) + } + t.deepEqual(DynWin32.allocateBuffer(4), Buffer.alloc(4)) + for (const alignment of [0, 3, 0.5, 2 ** 32 + 1]) { + t.throws(() => DynWin32.alignedDataPointer(Buffer.alloc(8), alignment)) + } + const detached = new Uint8Array(8) + structuredClone(detached.buffer, { transfer: [detached.buffer] }) + for (const invalid of [detached, new Uint8Array(new SharedArrayBuffer(8)), new Uint16Array(8), { length: 8 }]) { + t.throws(() => DynWin32.bufferLength(invalid as never)) + t.throws(() => DynWin32.byteLength(invalid as never)) + t.throws(() => DynWin32.bufferByteLength(invalid as never)) + t.throws(() => DynWin32.dataPointer(invalid as never)) + t.throws(() => DynWin32.createNativeStruct(pointDescriptor(), invalid as never)) + } +}) + +test('Win32 counted registry buffers preserve status, exact sizes and immediate LastError', (t) => { + const key = openKey() + const query = DynWin32Function.bind({ + dll: 'advapi32.dll', + entryPoint: 'RegQueryValueExW', + parameters: [ + { type: 'handle', direction: 'in', resourceCleanup: 'regCloseKey' }, + { type: 'pointer', direction: 'in' }, + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'u32', direction: 'out' }, + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'u32', direction: 'inout' }, + ], + returnType: 'i32', + successRule: 'zero', + }) + const read = (buffer: Buffer | null) => + query.invoke([ + DynWin32.handle(key), + DynWin32.wideString('ProductName'), + DynWin32.nullPointer(), + buffer === null ? DynWin32.nullPointer() : DynWin32.dataPointer(buffer), + DynWin32.u32(buffer === null ? 0 : DynWin32.bufferLength(buffer)), + ]) + try { + const probe = read(null) + t.true(probe.succeeded) + const size = DynWin32.toNumber(probe.outputs[1]) + t.true(size > 2) + const small = read(Buffer.alloc(1)) + t.false(small.succeeded) + t.is(DynWin32.toNumber(small.returnValue!), 234) + t.is(DynWin32.toNumber(small.outputs[1]), size) + const buffer = DynWin32.allocateBuffer(size) + Object.defineProperty(buffer, 'byteLength', { value: 0xffffffff }) + const result = read(buffer) + t.true(result.succeeded) + const actual = DynWin32.toNumber(result.outputs[1]) + t.is(actual, size) + t.true(DynWin32.copyBuffer(buffer, actual).toString('utf16le').includes('Windows')) + t.throws(() => DynWin32.copyBuffer(buffer, actual + 1), { message: /exceeds native buffer capacity/ }) + } finally { + key.close() + } + const missingModule = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'GetModuleHandleW', + parameters: [{ type: 'pointer', direction: 'in' }], + returnType: 'handle', + successRule: 'nonnull', + captureLastError: true, + }).invoke([DynWin32.wideString(`dynwinrt-missing-${randomUUID()}.dll`)]) + t.false(missingModule.succeeded) + t.is(missingModule.lastError, 126) + t.is(DynWin32.toBigint(missingModule.returnValue!), 0n) +}) + +test.serial('Win32 performance-data queries preserve success without failure-size inference', (t) => { + const performanceKey = DynWin32.handle(-2147483644n) + const normalKey = openKey() + const closePerformance = DynWin32Function.bind({ + dll: 'advapi32.dll', + entryPoint: 'RegCloseKey', + parameters: [{ type: 'handle', direction: 'in' }], + returnType: 'i32', + successRule: 'zero', + }) + try { + for (const name of ['RegQueryValueExA', 'RegQueryValueExW', 'RegGetValueA', 'RegGetValueW']) { + const get = name.startsWith('RegGetValue') + const wide = name.endsWith('W') + const query = DynWin32Function.bind({ + dll: 'advapi32.dll', + entryPoint: name, + parameters: [ + { type: 'handle', direction: 'in', resourceCleanup: 'regCloseKey' }, + { type: 'pointer', direction: 'in', nullable: get }, + { type: 'pointer', direction: 'in', nullable: true }, + ...(get ? [{ type: 'u32', direction: 'in' }] : []), + { type: 'u32', direction: 'out' }, + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'u32', direction: 'inout' }, + ], + returnType: 'i32', + successRule: 'zero', + callContractDescriptor: JSON.stringify({ + outputs: [ + { + parameter: get ? 6 : 5, + when: { + inputs: [{ kind: 'bits-in', parameter: 0, mask: 0xffffffff, values: [0x80000004] }], + returnValue: 234, + }, + action: { kind: 'unavailable' }, + }, + ], + }), + }) + const read = (performance: boolean, buffer: Buffer | null) => { + const name = wide + ? DynWin32.wideString(performance ? '2' : 'ProductName') + : DynWin32.ansiString(performance ? '2' : 'ProductName') + return query.invoke([ + performance ? performanceKey : DynWin32.handle(normalKey), + ...(get ? [DynWin32.nullPointer(), name, DynWin32.u32(0xffff)] : [name, DynWin32.nullPointer()]), + buffer === null ? DynWin32.nullPointer() : DynWin32.dataPointer(buffer), + DynWin32.u32(buffer === null ? 0 : DynWin32.byteLength(buffer)), + ]) + } + + // ERROR_MORE_DATA does not authorize reading the performance-data size. + for (const buffer of [DynWin32.allocateBuffer(1), DynWin32.allocateBuffer(64)]) { + const result = read(true, buffer) + t.is(DynWin32.toNumber(result.returnValue!), 234) + t.false(result.succeeded) + const count = result.outputs[1] + t.true(DynWin32.isUnavailable(count)) + t.throws(() => DynWin32.toNumber(count), { message: /not a JavaScript number/ }) + } + + let succeeded = false + for (let capacity = 64 * 1024; capacity <= 64 * 1024 * 1024; capacity *= 2) { + const buffer = DynWin32.allocateBuffer(capacity) + const result = read(true, buffer) + const status = DynWin32.toNumber(result.returnValue!) + if (status === 234) continue + t.is(status, 0) + t.true(result.succeeded) + const size = DynWin32.toNumber(result.outputs[1]) + t.true(size >= 8 && size <= DynWin32.byteLength(buffer)) + t.deepEqual(DynWin32.copyBuffer(buffer, 8), Buffer.from('PERF', 'utf16le')) + succeeded = true + break + } + t.true(succeeded, `${name}: performance data must remain queryable by growing capacity`) + + const normalProbe = read(false, null) + t.true(normalProbe.succeeded) + const required = DynWin32.toNumber(normalProbe.outputs[1]) + t.true(required > 1) + const normalSmall = read(false, DynWin32.allocateBuffer(1)) + t.is(DynWin32.toNumber(normalSmall.returnValue!), 234) + t.is(DynWin32.toNumber(normalSmall.outputs[1]), required) + const normalData = DynWin32.allocateBuffer(required) + const normalSuccess = read(false, normalData) + t.true(normalSuccess.succeeded) + const actual = DynWin32.toNumber(normalSuccess.outputs[1]) + t.true(actual > 0 && actual <= required) + t.regex(normalData.toString(wide ? 'utf16le' : 'latin1', 0, actual), /Windows/i) + if (!get) t.is(actual, required) + } + } finally { + normalKey.close() + t.is(DynWin32.toNumber(closePerformance.invoke([performanceKey]).returnValue!), 0) + } +}) + +test('Win32 semantic descriptors reject unknown fields and invalid native relationships', (t) => { + const spec = { + dll: 'absent-dynwinrt-test.dll', + entryPoint: 'Missing', + parameters: [{ type: 'u32', direction: 'inout' }], + returnType: 'u32', + } + for (const descriptor of [ + '{', + '{"outputs":[],"unknown":true}', + '{"outputs":[{"parameter":0,"when":{},"action":{"kind":"invented"}}]}', + '{"outputs":[{"parameter":0,"when":{"inputs":[{"kind":"null-or-empty","parameter":0,"elementWidth":2}]},"action":{"kind":"unavailable"}}]}', + '{"outputs":[{"parameter":0,"when":{"inputs":[{"kind":"handle-in","parameter":0,"values":[-1]}]},"action":{"kind":"unavailable"}}]}', + '{"outputs":[{"parameter":0,"when":{},"action":{"kind":"alias-input","parameter":0}}]}', + '{"resourceEffects":[{"kind":"add-file-completion-modes","handleParameter":0,"flagsParameter":0}]}', + ]) { + const error = t.throws(() => DynWin32Function.bind({ ...spec, callContractDescriptor: descriptor }))! + t.notRegex(error.message, /Failed to load|cannot find the file/i) + } +}) + +test('Win32 integer, string and aggregate guards fail before native invocation', (t) => { + const scalarSpec = { dll: 'kernel32.dll', entryPoint: 'GetTickCount', parameters: [], returnType: 'u32' } + const oversized: never[] = [] + oversized.length = 0xffffffff + t.throws(() => DynWin32Function.bind(scalarSpec).invoke(oversized), { message: /1024/ }) + t.throws(() => DynWin32Function.bind({ ...scalarSpec, unknown: true } as never), { message: /[Uu]nknown/ }) + t.throws(() => DynWin32Unsafe.bind({ ...scalarSpec, parameters: oversized }), { message: /1024/ }) + t.throws( + () => + DynWin32Function.bind({ + ...scalarSpec, + parameters: [{ type: 'u32', direction: 'in', countParamIndex: 9 }], + } as never), + { message: /[Uu]nknown/ }, + ) + t.throws( + () => + DynWin32Function.bind({ + ...scalarSpec, + returnType: 'handle', + returnCleanup: 'notCloseHandle', + }), + { message: /Unsupported flat Win32 cleanup/ }, + ) + for (const [convert, low, high] of [ + [DynWin32.i8, -128, 127], + [DynWin32.u8, 0, 255], + [DynWin32.i16, -32768, 32767], + [DynWin32.u16, 0, 65535], + [DynWin32.i32, -2147483648, 2147483647], + [DynWin32.u32, 0, 4294967295], + ] as const) { + t.is(DynWin32.toNumber(convert(low)), low) + t.is(DynWin32.toNumber(convert(high)), high) + for (const invalid of [low - 1, high + 1, 0.5, NaN, Infinity]) t.throws(() => convert(invalid)) + } + t.is(DynWin32.toBigint(DynWin32.i64(-(1n << 63n))), -(1n << 63n)) + t.is(DynWin32.toBigint(DynWin32.u64((1n << 64n) - 1n)), (1n << 64n) - 1n) + t.throws(() => DynWin32.i64(1n << 63n)) + t.throws(() => DynWin32.u64(-1n)) + t.throws(() => DynWin32.u64(1n << 64n)) + t.is(DynWin32.toNumber(DynWin32.f32(Math.PI)), Math.fround(Math.PI)) + t.is(DynWin32.toNumber(DynWin32.f64(Math.PI)), Math.PI) + t.throws(() => DynWin32.wideString('nul\0suffix'), { message: /NUL/ }) + t.throws(() => DynWin32.wideString('\ud800'), { message: /UTF-16/ }) + t.throws(() => DynWin32.ansiString('é'), { message: /ASCII/ }) + t.throws(() => DynWin32.wideMultiString(['first', '', 'hidden']), { message: /truncate/ }) + const mutableString = Buffer.from('ok\0') + const retainedString = DynWin32.ansiString(mutableString) + mutableString[2] = 1 + t.throws(() => DynWin32Unsafe.pointerAddress(retainedString), { message: /NUL-terminated/ }) + const original = JSON.parse(pointDescriptor()) + for (const mutate of [ + (layout: any) => { + layout.fields[0].offset = 2 ** 40 + }, + (layout: any) => { + layout.fields[0].count = 2 ** 40 + }, + (layout: any) => { + layout.fields[0].type.kind = 'unknown' + }, + (layout: any) => { + layout.fields[1].offset = 0 + }, + ]) { + const invalid = structuredClone(original) + for (const architecture of ['x86', 'x64', 'arm64']) mutate(invalid[architecture]) + t.throws(() => DynWin32.createNativeStruct(JSON.stringify(invalid))) + t.throws(() => + DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'GetTickCount', + parameters: [ + { + type: 'pointer', + direction: 'in', + aggregateDescriptor: JSON.stringify(invalid), + }, + ], + returnType: 'u32', + }), + ) + } + t.throws( + () => + DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'GetTickCount', + parameters: [], + returnType: 'f64', + successRule: 'nonzero', + }), + { message: /floating-point/ }, + ) +}) + +test('Win32 by-value aggregate and explicit subsystem plans call real exports', (t) => { + const descriptor = pointDescriptor() + const pointBytes = Buffer.alloc(8) + pointBytes.writeInt32LE(5, 0) + pointBytes.writeInt32LE(7, 4) + const point = DynWin32.createNativeStruct(descriptor, pointBytes) + const rect = Buffer.alloc(16) + rect.writeInt32LE(10, 8) + rect.writeInt32LE(10, 12) + const contains = DynWin32Function.bind({ + dll: 'user32.dll', + entryPoint: 'PtInRect', + parameters: [ + { type: 'pointer', direction: 'in' }, + { type: 'pointer', direction: 'in', aggregateDescriptor: descriptor }, + ], + returnType: 'bool32', + }) + t.true( + DynWin32.toBoolean( + contains.invoke([DynWin32.dataPointer(rect), DynWin32.nativeStructValue(point, descriptor)]).returnValue!, + ), + ) + const context = DynWin32.initializeWinsock() + const getError = DynWin32Function.bind({ + dll: 'ws2_32.dll', + entryPoint: 'WSAGetLastError', + parameters: [], + returnType: 'i32', + }) + t.is(typeof DynWin32.toNumber(getError.invokeWithSubsystem(context, 'winsock', []).returnValue!), 'number') + context.close() + t.throws(() => getError.invokeWithSubsystem(context, 'winsock', []), { message: /closed/ }) +}) + +test('Win32 COM inputs borrow an exact IID and retain the independent reference', (t) => { + initializeCom(0) + const object = DynCom.createErrorInfo() + try { + t.throws(() => DynWin32.comObject(object, '00000000-0000-0000-0000-000000000000'), { + message: /required Win32 interface/, + }) + const borrowed = DynWin32.comObject(object, '22f03340-547d-101b-8e65-08002b2bd119') + const spoofed = Object.setPrototypeOf(DynWin32.createNativeStruct(pointDescriptor()), DynWinRtValue.prototype) + t.throws(() => DynWin32.comObject(spoofed, '00000000-0000-0000-c000-000000000046'), { + message: /not managed COM references/, + }) + const original = Object.getOwnPropertyDescriptor(DynWinRtValue.prototype, 'isNull')! + try { + Object.defineProperty(DynWinRtValue.prototype, 'isNull', { ...original, value: () => false }) + for (const foreign of [DynWinRtType.i32(), WinGuid.parse('00000000-0000-0000-0000-000000000000')]) { + Object.setPrototypeOf(foreign, DynWinRtValue.prototype) + t.throws(() => DynWin32.comObject(foreign as never, '00000000-0000-0000-c000-000000000046'), { + message: /native managed COM carrier/, + }) + } + } finally { + Object.defineProperty(DynWinRtValue.prototype, 'isNull', original) + } + object.release() + t.true(DynWin32Unsafe.pointerAddress(borrowed) > 0n) + } finally { + object.release() + } +}) + +test('Win32 descriptors reject hidden contract fields and propagate getter failures', (t) => { + const base = { dll: 'kernel32.dll', entryPoint: 'GetLastError', parameters: [], returnType: 'u32' } + const hidden = { ...base } + Object.defineProperty(hidden, 'callingConventon', { value: 'cdecl', enumerable: false }) + t.throws(() => DynWin32Function.bind(hidden), { message: /[Uu]nknown/ }) + const symbol = { ...base, [Symbol('unmodeled contract')]: true } + t.throws(() => DynWin32Function.bind(symbol), { message: /[Uu]nknown|specification/ }) + for (const change of [ + { parameters: {} }, + { parameters: [null] }, + { returnType: true }, + { callingConvention: 'fastcall' }, + { captureLastError: 'true' }, + { dll: 'x'.repeat(1025) }, + { dll: 'kernel32.dll\0' }, + { parameters: [{ type: 'u32', direction: 'sideways' }] }, + { parameters: [{ type: 'u32', direction: 'out', cleanup: 'closeHandle' }] }, + ]) { + t.throws(() => DynWin32Function.bind({ ...base, ...change } as never)) + } + for (const property of ['dll', 'parameters', 'captureLastError']) { + const failure = new Error(`native descriptor getter: ${property}`) + const descriptor = { ...base } + Object.defineProperty(descriptor, property, { + get() { + throw failure + }, + enumerable: true, + }) + t.throws(() => DynWin32Function.bind(descriptor), { is: failure }) + } + const parameterFailure = new Error('native parameter getter') + t.throws( + () => + DynWin32Function.bind({ + ...base, + parameters: [ + { + get type(): string { + throw parameterFailure + }, + direction: 'in', + }, + ], + }), + { is: parameterFailure }, + ) + const argumentFailure = new Error('native argument getter') + const args = [DynWin32.u32(0)] + Object.defineProperty(args, 0, { + get() { + throw argumentFailure + }, + }) + t.throws(() => DynWin32Function.bind(base).invoke(args), { is: argumentFailure }) + const nonEnumerable = Object.create(null) + for (const [name, value] of Object.entries(base)) Object.defineProperty(nonEnumerable, name, { value }) + t.is(typeof DynWin32.toNumber(DynWin32Function.bind(nonEnumerable).invoke([]).returnValue!), 'number') +}) + +test('Win32 prepared plans do not follow later descriptor mutations', (t) => { + const spec = { + dll: 'kernel32.dll', + entryPoint: 'MulDiv', + parameters: Array.from({ length: 3 }, () => ({ type: 'i32', direction: 'in' })), + returnType: 'i32', + successRule: 'always', + } + const plan = DynWin32Function.bind(spec) + spec.entryPoint = 'GetLastError' + spec.parameters[0].type = 'pointer' + spec.parameters.length = 0 + spec.returnType = 'pointer' + const result = plan.invoke([DynWin32.i32(8), DynWin32.i32(9), DynWin32.i32(2)]) + t.is(plan.entryPoint, 'MulDiv') + t.is(DynWin32.toNumber(result.returnValue!), 36) + t.is(result.returnValue, null) + t.deepEqual(result.outputs, []) + t.throws(() => result.outputs, { message: /already consumed/ }) +}) + +test('Win32 string encodings and pointer slots retain validated native storage', (t) => { + for (const wide of [false, true]) { + const length = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: wide ? 'lstrlenW' : 'lstrlenA', + parameters: [{ type: 'pointer', direction: 'in' }], + returnType: 'i32', + }) + const construct = wide ? DynWin32.wideString : DynWin32.ansiString + t.is(DynWin32.toNumber(length.invoke([construct('')]).returnValue!), 0) + t.is(DynWin32.toNumber(length.invoke([construct('hello')]).returnValue!), 5) + const bytes = Buffer.from('abc\0', wide ? 'utf16le' : 'ascii') + const pointer = construct(bytes) + bytes[0] = 90 + t.is(DynWin32.toNumber(length.invoke([pointer]).returnValue!), 3) + bytes.fill(1, bytes.length - (wide ? 2 : 1)) + t.throws(() => DynWin32Unsafe.pointerAddress(pointer), { message: /NUL-terminated/ }) + const detached = new Uint8Array(wide ? [65, 0, 0, 0] : [65, 0]) + const held = construct(detached) + structuredClone(detached.buffer, { transfer: [detached.buffer] }) + t.throws(() => DynWin32Unsafe.pointerAddress(held), { message: /detached/ }) + const multi = wide ? DynWin32.wideMultiString : DynWin32.ansiMultiString + t.truthy(multi([])) + t.truthy(multi(['one', 'two'])) + t.throws(() => multi(['one\0two']), { message: /NUL/ }) + t.throws(() => multi(['one', 2] as never)) + t.truthy(multi(null, true)) + t.throws(() => multi(null), { message: /nullable/ }) + const encoded = Buffer.from(wide ? [65, 0, 0, 0, 0, 0] : [65, 0, 0]) + const list = multi(encoded) + encoded[encoded.length - 1] = 1 + t.throws(() => DynWin32Unsafe.pointerAddress(list), { message: /two NUL/ }) + } + t.truthy(DynWin32.ansiString(Buffer.from([0xe9, 0]))) + const wideLength = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'lstrlenW', + parameters: [{ type: 'pointer', direction: 'in' }], + returnType: 'i32', + }) + t.is(DynWin32.toNumber(wideLength.invoke([DynWin32.wideString('😀A')]).returnValue!), 3) + const width = process.arch === 'ia32' ? 4 : 8 + const copy = DynWin32Function.bind({ + dll: 'msvcrt.dll', + entryPoint: 'memcpy', + callingConvention: 'cdecl', + parameters: [ + { type: 'pointer', direction: 'in' }, + { type: 'pointer', direction: 'in' }, + { type: width === 8 ? 'u64' : 'u32', direction: 'in' }, + ], + returnType: 'pointer', + }) + const slot = DynWin32.wideStringPointerPointer('owned slot') + const pointerBytes = DynWin32.allocateBuffer(width) + copy.invoke([ + DynWin32.dataPointer(pointerBytes), + slot, + width === 8 ? DynWin32.u64(BigInt(width)) : DynWin32.u32(width), + ]) + const pointer = width === 8 ? pointerBytes.readBigUInt64LE() : BigInt(pointerBytes.readUInt32LE()) + t.not(pointer, DynWin32Unsafe.pointerAddress(slot)) + t.is(DynWin32.toNumber(wideLength.invoke([DynWin32Unsafe.pointer(pointer)]).returnValue!), 10) + t.throws(() => DynWin32.wideStringPointerPointer(null), { message: /nullable/ }) + t.is(DynWin32Unsafe.pointerAddress(DynWin32.wideStringPointerPointer(null, true)), 0n) +}) + +test('Win32 buffers keep byte-view offsets, alignment and exact native argument counts', (t) => { + const backing = Buffer.alloc(32) + const base = DynWin32Unsafe.pointerAddress(DynWin32.dataPointer(backing)) + const offset = Number(-base & 7n) + const aligned = backing.subarray(offset, offset + 16) + t.is(DynWin32Unsafe.pointerAddress(DynWin32.alignedDataPointer(aligned, 8)), base + BigInt(offset)) + t.throws(() => DynWin32.alignedDataPointer(backing.subarray(offset + 1, offset + 9), 4), { + message: /not aligned/, + }) + t.deepEqual(DynWin32.copyBuffer(aligned, 0), Buffer.alloc(0)) + for (const length of [-1, 0.5, Infinity, NaN, 17]) { + t.throws(() => DynWin32.copyBuffer(aligned, length)) + } + const scalar = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'GetTickCount', + parameters: [], + returnType: 'u32', + }) + t.throws(() => scalar.invoke([DynWin32.u32(0)]), { message: /expects 0/ }) + t.throws(() => scalar.invoke({ length: 0 } as never), { message: /array/ }) +}) + +test('Win32 aliased resources and aggregates cannot deadlock dispatch', (t) => { + const child = spawnSync(process.execPath, [fileURLToPath(new URL('./fixtures/win32-aliases.cjs', import.meta.url))], { + timeout: 15000, + encoding: 'utf8', + windowsHide: true, + }) + t.is(child.error, undefined) + t.is(child.status, 0, child.stderr) + t.regex(child.stdout, /native-alias-guards-ok/) +}) + +test('Win32 aggregate field access checks state, identity and copy isolation', (t) => { + const layout = { + size: 8, + alignment: 4, + fields: [ + { name: 'value', offset: 0, count: 1, type: { kind: 'u32' } }, + { name: 'flag', offset: 4, count: 1, type: { kind: 'i32' } }, + ], + } + const descriptor = JSON.stringify({ name: 'Tests.Mutable', kind: 'struct', x86: layout, x64: layout, arm64: layout }) + const value = DynWin32.createNativeStruct(descriptor) + DynWin32.setNativeStructU32(value, descriptor, 'value', 42) + DynWin32.setNativeStructBool32(value, descriptor, 'flag', true) + const copy = value.bytes + copy.fill(0xff) + t.is(value.bytes.readUInt32LE(0), 42) + t.is(value.bytes.readInt32LE(4), 1) + t.throws(() => DynWin32.getNativeStructU32(value, descriptor, 'value'), { message: /before a successful/ }) + DynWin32.markNativeStructCallResult(value, descriptor, false) + t.throws(() => DynWin32.getNativeStructU32(value, descriptor, 'value'), { message: /call failed/ }) + DynWin32.markNativeStructCallResult(value, descriptor, true) + t.is(DynWin32.getNativeStructU32(value, descriptor, 'value'), 42) + t.throws(() => DynWin32.setNativeStructU32(value, descriptor, 'flag', 1), { message: /not u32/ }) + t.throws(() => DynWin32.setNativeStructU32(value, descriptor, 'missing', 1), { message: /unknown native field/ }) + t.throws(() => DynWin32.getNativeStructU32(value, descriptor.replace('Mutable', 'Other'), 'value'), { + message: /type mismatch/, + }) + DynWin32.prepareNativeStructCall(value, descriptor) + t.throws(() => DynWin32.getNativeStructU32(value, descriptor, 'value'), { message: /call failed/ }) + t.throws(() => DynWin32.toResource(DynWin32.handle(1n)), { message: /not an owned resource/ }) + t.is(DynWin32.toResource(DynWin32.handle(0n)), null) +}) + +const createEvent = () => { + const result = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'CreateEventW', + parameters: [ + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'bool32', direction: 'in' }, + { type: 'bool32', direction: 'in' }, + { type: 'pointer', direction: 'in', nullable: true }, + ], + returnType: 'handle', + returnCleanup: 'closeHandle', + successRule: 'nonnull', + captureLastError: true, + }).invoke([DynWin32.nullPointer(), DynWin32.bool32(true), DynWin32.bool32(false), DynWin32.nullPointer()]) + if (!result.succeeded) throw new Error(`CreateEventW: ${result.lastError}`) + return DynWin32.toResource(result.returnValue!)! +} + +test('Win32 argument getters cannot close a captured resource and still dispatch', (t) => { + const event = createEvent() + const wait = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'WaitForSingleObject', + parameters: [ + { type: 'handle', direction: 'in', resourceCleanup: 'closeHandle' }, + { type: 'u32', direction: 'in' }, + ], + returnType: 'u32', + }) + try { + const args = [DynWin32.handle(event), DynWin32.u32(0)] + Object.defineProperty(args, 1, { + get() { + event.close() + return DynWin32.u32(0) + }, + }) + t.throws(() => wait.invoke(args), { message: /closed/ }) + t.true(event.closed) + } finally { + event.close() + } +}) + +const start = (operation: DynWin32OverlappedOperation) => + new Promise((resolve, reject) => { + operation.start((error, transferred) => (error ? reject(error) : resolve(transferred!))) + }) +const fileSpec = { + dll: 'kernel32.dll', + entryPoint: 'CreateFileW', + parameters: [ + { type: 'pointer', direction: 'in' }, + { type: 'u32', direction: 'in' }, + { type: 'u32', direction: 'in' }, + { type: 'pointer', direction: 'in', nullable: true }, + { type: 'u32', direction: 'in' }, + { type: 'u32', direction: 'in' }, + { type: 'handle', direction: 'in', nullable: true }, + ], + returnType: 'handle', + returnCleanup: 'closeHandle', + successRule: 'validHandle', + captureLastError: true, +} +const openFile = (path: string, access = 0xc0000000) => { + const result = DynWin32Function.bind(fileSpec).invoke([ + DynWin32.wideString(path), + DynWin32.u32(access), + DynWin32.u32(7), + DynWin32.nullPointer(), + DynWin32.u32(3), + DynWin32.u32(0x40000000), + DynWin32.handle(0n, true), + ]) + if (!result.succeeded) throw new Error(`CreateFileW: ${result.lastError}`) + return DynWin32.toResource(result.returnValue!)! +} + +test.serial('Win32 IOCP completion modes preserve immediate, pending and cancelled operations', (t) => { + t.timeout(40000) + const result = spawnSync( + process.execPath, + [fileURLToPath(new URL('./fixtures/win32-completion-modes.cjs', import.meta.url)), JSON.stringify(fileSpec)], + { encoding: 'utf8', timeout: 30000 }, + ) + t.is(result.error, undefined, `${result.error}\n${result.stdout}\n${result.stderr}`) + t.is(result.status, 0, `${result.stdout}\n${result.stderr}`) + t.is(result.stderr, '') + t.regex(result.stdout, /PASS completion modes/) +}) + +test.serial('Win32 IOCP relay survives owner-thread GC, exceptions and environment teardown', (t) => { + t.timeout(50000) + const result = spawnSync( + process.execPath, + [ + '--expose-gc', + fileURLToPath(new URL('./fixtures/win32-io-lifecycle.cjs', import.meta.url)), + JSON.stringify(fileSpec), + ], + { encoding: 'utf8', timeout: 45000 }, + ) + t.is(result.error, undefined, `${result.error}\n${result.stdout}\n${result.stderr}`) + t.is(result.status, 0, `${result.stdout}\n${result.stderr}`) + t.is(result.stderr, '') + t.regex(result.stdout, /PASS IOCP owner-thread lifecycle/) +}) + +test.serial('Win32 IOCP AbortSignal cancels active native pipe I/O through CancelIoEx', async (t) => { + t.timeout(20000) + const pipe = `\\\\.\\pipe\\dynwinrt-iocp-${randomUUID()}` + let peer: Socket | undefined + const server = createServer((socket) => { + peer = socket + }) + server.listen(pipe) + await once(server, 'listening') + let file: DynWin32Resource | undefined + let operation: DynWin32OverlappedOperation | undefined + let completion: Promise | undefined + try { + const connected = once(server, 'connection') + file = openFile(pipe) + await connected + const cancelledOutput = Buffer.alloc(16, 0x5a) + operation = DynWin32.beginReadFile(file, cancelledOutput) + const abort = new AbortController() + abort.signal.addEventListener('abort', () => operation!.cancel(), { once: true }) + completion = start(operation) + await new Promise((resolve) => setImmediate(resolve)) + t.true(file.active) + t.true(file.busy) + abort.abort() + await t.throwsAsync(completion, { message: /Win32 error 995/ }) + t.false(file.active) + t.false(file.busy) + t.deepEqual(cancelledOutput, Buffer.alloc(16, 0x5a)) + operation.cancel() + const recovered = Buffer.alloc(4) + operation = DynWin32.beginReadFile(file, recovered) + completion = start(operation) + peer!.write(Buffer.from('next')) + t.is(await completion, 4) + t.is(recovered.toString(), 'next') + operation.cancel() + t.false(file.busy) + } finally { + operation?.cancel() + await completion?.catch(() => {}) + file?.close() + peer?.destroy() + await new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve()))) + } +}) + +test.serial('Win32 IOCP retires pending native work when its Node environment closes', async (t) => { + t.timeout(20000) + const pipe = `\\\\.\\pipe\\dynwinrt-iocp-teardown-${randomUUID()}` + let peer: Socket | undefined + const server = createServer((socket) => { + peer = socket + }) + server.listen(pipe) + await once(server, 'listening') + const connected = once(server, 'connection') + const worker = new Worker( + ` + const { parentPort, workerData } = require('node:worker_threads'); + const { DynWin32, DynWin32Function } = require(workerData.runtime); + const result = DynWin32Function.bind(workerData.spec).invoke([ + DynWin32.wideString(workerData.pipe), DynWin32.u32(0xc0000000), DynWin32.u32(7), + DynWin32.nullPointer(), DynWin32.u32(3), DynWin32.u32(0x40000000), DynWin32.handle(0n, true) + ]); + if (!result.succeeded) throw new Error('CreateFileW failed: ' + result.lastError); + const file = DynWin32.toResource(result.returnValue); + const operation = DynWin32.beginReadFile(file, Buffer.alloc(16)); + operation.start(() => {}); + parentPort.postMessage({ active: file.active }); + `, + { eval: true, workerData: { runtime: join(process.cwd(), 'dist', 'win32-unsafe.js'), spec: fileSpec, pipe } }, + ) + let timeout: ReturnType | undefined + try { + const [message] = await once(worker, 'message') + await connected + t.true(message.active) + const closed = once(peer!, 'close') + await worker.terminate() + await Promise.race([ + closed, + new Promise((_, reject) => { + timeout = setTimeout(() => reject(new Error('IOCP teardown did not release the native pipe')), 10000) + }), + ]) + t.pass() + } finally { + clearTimeout(timeout) + await worker.terminate() + peer?.destroy() + await new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve()))) + } +}) + +test.serial('Win32 IOCP retires prepared and queued deliveries on the Node owner thread', async (t) => { + t.timeout(30000) + for (const phase of ['prepared', 'queued']) { + const pipe = `\\\\.\\pipe\\dynwinrt-iocp-${phase}-${randomUUID()}` + let peer: Socket | undefined + const server = createServer((socket) => { + peer = socket + }) + server.listen(pipe) + await once(server, 'listening') + const connected = once(server, 'connection') + const worker = new Worker( + ` + const { parentPort, workerData } = require('node:worker_threads'); + const { DynWin32, DynWin32Function } = require(workerData.runtime); + const result = DynWin32Function.bind(workerData.spec).invoke([ + DynWin32.wideString(workerData.pipe), DynWin32.u32(0xc0000000), DynWin32.u32(7), + DynWin32.nullPointer(), DynWin32.u32(3), DynWin32.u32(0x40000000), DynWin32.handle(0n, true) + ]); + if (!result.succeeded) throw new Error('CreateFileW failed: ' + result.lastError); + const file = DynWin32.toResource(result.returnValue); + parentPort.postMessage('opened'); + parentPort.once('message', () => { + const buffer = Buffer.alloc(4); + const operation = DynWin32.beginReadFile(file, buffer); + let delivered = false; + if (workerData.phase === 'queued') operation.start(() => { delivered = true; }); + const wait = new Int32Array(new SharedArrayBuffer(4)); + const deadline = Date.now() + 5000; + while (file.active) { + if (Date.now() > deadline) throw new Error('native completion did not become terminal'); + Atomics.wait(wait, 0, 0, 1); + } + parentPort.postMessage({ + busy: file.busy, active: file.active, delivered, unchanged: buffer.every(byte => byte === 0) + }); + Atomics.wait(wait, 0, 0); + }); + `, + { + eval: true, + workerData: { runtime: join(process.cwd(), 'dist', 'win32-unsafe.js'), spec: fileSpec, pipe, phase }, + }, + ) + let timeout: ReturnType | undefined + try { + t.deepEqual(await once(worker, 'message'), ['opened']) + await connected + if (phase === 'queued') { + await new Promise((resolve, reject) => + peer!.write('hold', (error) => (error ? reject(error) : resolve())), + ) + } + const settled = once(worker, 'message') + worker.postMessage('start') + const [state] = await settled + t.deepEqual(state, { busy: true, active: false, delivered: false, unchanged: true }) + const closed = once(peer!, 'close') + await worker.terminate() + await Promise.race([ + closed, + new Promise((_, reject) => { + timeout = setTimeout(() => reject(new Error(`${phase} IOCP teardown retained the native pipe`)), 10000) + }), + ]) + t.pass() + } finally { + clearTimeout(timeout) + await worker.terminate() + peer?.destroy() + await new Promise((resolve, reject) => server.close((error) => (error ? reject(error) : resolve()))) + } + } +}) + +test.serial('Win32 IOCP owns buffers through completion, cancellation, EOF and capacity checks', async (t) => { + t.timeout(20000) + const path = join(process.cwd(), '__test__', `win32-iocp-${randomUUID()}.bin`) + writeFileSync(path, Buffer.from('native-iocp')) + t.teardown(() => unlinkSync(path)) + const file = openFile(path) + try { + const output = Buffer.alloc(11) + const read = DynWin32.beginReadFile(file, output, 0n) + t.true(file.busy) + t.throws(() => file.close(), { message: /asynchronous I\/O/ }) + const close = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'CloseHandle', + parameters: [{ type: 'handle', direction: 'in', consumesResource: true, resourceCleanup: 'closeHandle' }], + returnType: 'bool32', + successRule: 'nonzero', + }) + + t.throws(() => close.invoke([DynWin32.resource(file, 'closeHandle')]), { message: /asynchronous I\/O/ }) + t.is(await start(read), 11) + t.is(output.toString(), 'native-iocp') + t.false(file.busy) + read.cancel() + t.throws(() => read.start(() => {}), { message: /already started/ }) + const short = Buffer.alloc(20, 0xa5) + t.is(await start(DynWin32.beginReadFile(file, short, 7n)), 4) + t.is(short.subarray(0, 4).toString(), 'iocp') + t.true(short.subarray(4).every((byte) => byte === 0xa5)) + for (const offset of [-1n, 1n << 64n]) { + t.throws(() => DynWin32.beginReadFile(file, Buffer.alloc(1), offset), { message: /unsigned 64-bit/ }) + t.throws(() => DynWin32.beginWriteFile(file, Buffer.alloc(1), offset), { message: /unsigned 64-bit/ }) + t.false(file.busy) + } + t.is(await start(DynWin32.beginReadFile(file, Buffer.alloc(4), 100n)), 0) + t.is(await start(DynWin32.beginWriteFile(file, Buffer.from('IOCP'), 0n)), 4) + const written = Buffer.alloc(4) + t.is(await start(DynWin32.beginReadFile(file, written, 0n)), 4) + t.is(written.toString(), 'IOCP') + const cancelled = DynWin32.beginReadFile(file, Buffer.alloc(1)) + cancelled.cancel() + await t.throwsAsync(start(cancelled), { message: /aborted/ }) + t.false(file.busy) + const detachedBacking = new ArrayBuffer(4) + const detachedBefore = Buffer.from(detachedBacking) + structuredClone(detachedBacking, { transfer: [detachedBacking] }) + t.throws(() => DynWin32.beginReadFile(file, detachedBefore), { message: /detached/ }) + t.false(file.busy) + const backing = new ArrayBuffer(16) + const detached = DynWin32.beginReadFile(file, Buffer.from(backing), 0n) + structuredClone(backing, { transfer: [backing] }) + await t.throwsAsync(start(detached), { message: /detached|changed/ }) + t.false(file.busy) + t.throws(() => DynWin32.beginReadFile(file, Buffer.from(new SharedArrayBuffer(4))), { + message: /SharedArrayBuffer/, + }) + const pending = Array.from({ length: 1024 }, () => DynWin32.beginReadFile(file, Buffer.alloc(0))) + try { + t.throws(() => DynWin32.beginReadFile(file, Buffer.alloc(0)), { message: /operation limit/ }) + } finally { + for (const operation of pending) { + operation.cancel() + t.throws(() => operation.start(() => {}), { message: /aborted/ }) + } + } + t.false(file.busy) + const resumed = Buffer.alloc(1) + t.is(await start(DynWin32.beginReadFile(file, resumed, 0n)), 1) + t.is(resumed[0], 'I'.charCodeAt(0)) + file.close() + t.true(file.closed) + } finally { + file.close() + } +}) + +test.serial('Win32 IOCP submission errors release reservations and leave resources usable', async (t) => { + t.timeout(20000) + const event = createEvent() + try { + const invalidFile = DynWin32.beginReadFile(event, Buffer.alloc(1)) + t.true(event.busy) + await t.throwsAsync(start(invalidFile), { message: /associate.*IOCP/ }) + t.false(event.busy) + t.false(event.active) + t.false(event.closed) + t.throws(() => invalidFile.start(() => {}), { message: /already started/ }) + } finally { + event.close() + } + const path = join(process.cwd(), '__test__', `win32-readonly-${randomUUID()}.bin`) + writeFileSync(path, Buffer.from('read-only')) + let file: DynWin32Resource | undefined + try { + file = openFile(path, 0x80000000) + await t.throwsAsync(start(DynWin32.beginWriteFile(file, Buffer.from('bad'))), { + message: /WriteFile failed|Win32 error/, + }) + t.false(file.busy) + t.false(file.active) + t.false(file.closed) + const output = Buffer.alloc(9) + const operation = DynWin32.beginReadFile(file, output) + t.throws(() => operation.start(null as never)) + t.false(file.busy) + t.false(file.active) + t.throws(() => operation.start(() => {}), { message: /already started/ }) + t.is(await start(DynWin32.beginReadFile(file, output)), 9) + t.is(output.toString(), 'read-only') + t.false(file.busy) + } finally { + file?.close() + unlinkSync(path) + } +}) diff --git a/bindings/js/__test__/win32-imports.spec.ts b/bindings/js/__test__/win32-imports.spec.ts new file mode 100644 index 00000000..767aa976 --- /dev/null +++ b/bindings/js/__test__/win32-imports.spec.ts @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import test from 'ava' +import { readFileSync } from 'node:fs' +import { createRequire } from 'node:module' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' +import { readPeImports, verifyAddonImports } from '../scripts/pe-imports.mjs' +import { isMissingMediaFoundation } from './helpers/optional-media-foundation.mjs' + +const require = createRequire(import.meta.url) +const dist = fileURLToPath(new URL('../dist/', import.meta.url)) + +test('Win32 addon PE ordinary imports exclude optional subsystem DLLs', (t) => { + const hostAddon = `dynwinrt.win32-${process.arch}-msvc.node` + const imports = readPeImports(readFileSync(join(dist, hostAddon))) + const hasMediaFixture = imports.some( + ({ dll, symbols }) => dll.toLowerCase() === 'mfplat.dll' && symbols.includes('MFCreateSample'), + ) + const testHooksAddon = + hasMediaFixture && typeof require(join(dist, hostAddon)).DynComBorrowedCopyTestFixture === 'function' + ? hostAddon + : undefined + const checked = verifyAddonImports(dist, { testHooksAddon }) + t.true(checked.includes(hostAddon)) + t.true(imports.length > 0, 'The actual addon has ordinary imports; this is not a source or loaded-module scan') + if (testHooksAddon) t.log('test-hooks: only mfplat.dll!MFCreateSample is permitted for the COM media fixture') +}) + +test('Win32 Media Foundation skips require actionable missing system DLL or lifecycle export errors', (t) => { + const missingDll = + '0x8007007E: System DLL `mfplat.dll` could not be loaded from System32: The specified module could not be found.' + t.true(isMissingMediaFoundation(new Error(missingDll))) + for (const symbol of ['MFStartup', 'MFShutdown']) { + t.true(isMissingMediaFoundation(new Error(`0x8007007F: Export \`${symbol}\` was not found in \`mfplat.dll\``))) + } + for (const error of [ + missingDll, + { message: missingDll }, + new Error('The specified module could not be found.'), + new Error('MFStartup failed: 0x8007007E'), + new Error('MFStartup failed: 0x80004005'), + new Error(missingDll.replace('0x8007007E', '0x80070005')), + new Error(missingDll.replace('0x8007007E', '0x800700C1')), + new Error(missingDll.replace('mfplat.dll', 'other.dll')), + new Error(missingDll.replace('System32', 'the current directory')), + new Error('0x8007007F: Export `MFGetTimerPeriodicity` was not found in `mfplat.dll`'), + new Error('0x8007007F: Export `mfstartup` was not found in `mfplat.dll`'), + new Error('0x8007007F: Export `MFStartup` was not found in `other.dll`'), + new Error('0x80070005: Export `MFStartup` was not found in `mfplat.dll`'), + ]) { + t.false(isMissingMediaFoundation(error)) + } +}) + +test('Win32 Media Foundation initialization is explicit and isolated from WinRT and COM imports', async (t) => { + const winrt = await import('../dist/winrt.js') + const com = await import('../dist/com.js') + const { DynWin32 } = await import('../dist/win32.js') + t.is(typeof winrt.WinGuid.parse, 'function') + t.is(typeof com.initializeCom, 'function') + let context + try { + context = DynWin32.initializeMediaFoundation() + } catch (error) { + if (!isMissingMediaFoundation(error)) throw error + t.log(`SKIP optional Media Foundation context checks; initialization reported: ${error.message}`) + t.pass('Initialization rejected the positively identified missing system component') + return + } + try { + t.is(context.subsystem, 'mediaFoundation') + t.false(context.closed) + t.notThrows(() => DynWin32.requireSubsystem(context, 'mediaFoundation')) + } finally { + context.close() + } + t.true(context.closed) + t.throws(() => DynWin32.requireSubsystem(context, 'mediaFoundation'), { message: /context is closed/ }) + t.notThrows(() => context.close()) +}) diff --git a/bindings/js/package.json b/bindings/js/package.json index daa7f034..f38953fc 100644 --- a/bindings/js/package.json +++ b/bindings/js/package.json @@ -29,6 +29,18 @@ "require": "./dist/com-unsafe-raw.js", "default": "./dist/com-unsafe-raw.js" }, + "./win32": { + "types": "./dist/win32.d.ts", + "import": "./dist/win32.js", + "require": "./dist/win32.js", + "default": "./dist/win32.js" + }, + "./win32/unsafe": { + "types": "./dist/win32-unsafe.d.ts", + "import": "./dist/win32-unsafe.js", + "require": "./dist/win32-unsafe.js", + "default": "./dist/win32-unsafe.js" + }, "./package.json": "./package.json" }, "typesVersions": { @@ -41,6 +53,12 @@ ], "com/unsafe/raw": [ "dist/com-unsafe-raw.d.ts" + ], + "win32": [ + "dist/win32.d.ts" + ], + "win32/unsafe": [ + "dist/win32-unsafe.d.ts" ] } }, @@ -96,9 +114,11 @@ "test:winrt-implementation": "npm run build:test-hooks && npm run build:entrypoints && ava __test__/winrt-implementation.spec.ts", "test:native-completion": "npm run build:test-hooks && npm run build:entrypoints && ava __test__/native-completion.e2e.ts", "test:borrowed-copy": "npm run build:test-hooks && npm run build:entrypoints && ava __test__/borrowed-copy.e2e.ts", - "test:types": "npm run test:types:index && npm run test:types:raw", + "test:win32-runtime": "npm run test:types:win32 && ava __test__/win32-contracts.spec.ts __test__/index.spec.ts __test__/pe-imports.spec.ts __test__/win32-imports.spec.ts --match \"*Win32*\" --match \"package facades exactly partition native exports\"", + "test:types": "npm run test:types:index && npm run test:types:raw && npm run test:types:win32", "test:types:index": "tsc --noEmit --strict --target ESNext --module NodeNext --moduleResolution NodeNext __test__/index.spec.ts __test__/winrt-marshalling.spec.ts __test__/winrt-implementation.spec.ts __test__/native-imports.spec.ts", "test:types:raw": "tsc --noEmit --project __test__/types/tsconfig.json", + "test:types:win32": "tsc --noEmit --strict --target ESNext --module NodeNext --moduleResolution NodeNext __test__/win32-contracts.spec.ts __test__/pe-imports.spec.ts __test__/win32-imports.spec.ts", "test:tsfn": "npm run build:test-hooks && ava __test__/tsfn.spec.ts", "version": "napi version" }, diff --git a/bindings/js/scripts/generate-entrypoints.mjs b/bindings/js/scripts/generate-entrypoints.mjs index d243df4f..f1aad9ce 100644 --- a/bindings/js/scripts/generate-entrypoints.mjs +++ b/bindings/js/scripts/generate-entrypoints.mjs @@ -209,7 +209,8 @@ const rawComDeclarations = [ ] const winrtExports = nativeExports.filter( - (name) => !name.startsWith('DynCom') && name !== 'initializeCom', + (name) => !name.startsWith('DynCom') && !name.startsWith('DynWin32') && + !name.startsWith('win32') && name !== 'initializeCom', ) writeFacade('winrt', winrtExports, [...winrtExports, 'DynWinRtImplementationMethod'], [], [ '/** A generated interface plan and its synchronous, metadata-ordered dispatcher. */', @@ -258,6 +259,157 @@ writeFacade( true, ) +const win32NativeExports = [ + 'DynWin32', 'DynWin32Unsafe', 'win32CarrierKind', + 'win32NativeStructBytes', 'win32NativeStructLength', + 'win32ResourceValue', 'win32ResourceClosed', 'win32ResourceBusy', + 'win32ResourceActive', 'win32ResourceClose', 'win32Bind', + 'win32FunctionDll', 'win32FunctionEntryPoint', 'win32Invoke', 'win32InvokeWithSubsystem', + 'win32ResultReturnValue', 'win32ResultOutputs', 'win32ResultLastError', 'win32ResultSucceeded', + 'win32SubsystemName', 'win32SubsystemClosed', 'win32SubsystemClose', + 'win32OverlappedCancel', 'win32OverlappedStart', +] +const missingWin32 = win32NativeExports.filter((name) => !nativeExports.includes(name)) +if (missingWin32.length) throw new Error(`Missing required Win32 exports: ${missingWin32.join(', ')}`) +const unsafeWin32Methods = [ + 'initializeMapiUtilities', 'createNativeStruct', 'setNativeStructU32', 'setNativeStructBool32', + 'setNativeStructPointer', 'getNativeStructU32', 'takeNativeStructResource', + 'markNativeStructCallResult', 'prepareNativeStructCall', 'nativeStruct', 'nativeStructValue', + 'toNativeStruct', +] +const win32CarrierNames = [ + 'DynWin32Value', 'DynWin32NativeStruct', 'DynWin32Resource', 'DynWin32Function', + 'DynWin32CallResult', 'DynWin32SubsystemContext', 'DynWin32OverlappedOperation', +] +const safeWin32Names = [ + 'DynWin32', 'DynWin32NativeStruct', 'DynWin32OverlappedOperation', + 'DynWin32Resource', 'DynWin32SubsystemContext', 'DynWin32Value', 'DynWinRtValue', +] +const unsafeWin32Names = [ + ...safeWin32Names, 'DynWin32CallResult', 'DynWin32Function', 'DynWin32Unsafe', +] +writeFileSync(join(distDir, 'win32-internal.js'), [ + '// Generated by scripts/generate-entrypoints.mjs - do not edit', + "'use strict'", + "const native = require('./index.js')", + 'class DynWin32Value {', + " constructor() { throw new TypeError('Win32 values originate from native runtime helpers') }", + '}', + 'class DynWin32NativeStruct {', + " constructor() { throw new TypeError('Use a generated native struct builder') }", + ' get bytes() { return native.win32NativeStructBytes(this) }', + ' get length() { return native.win32NativeStructLength(this) }', + '}', + 'class DynWin32Resource {', + " constructor() { throw new TypeError('Resources originate only from native owned outputs') }", + ' get value() { return native.win32ResourceValue(this) }', + ' get closed() { return native.win32ResourceClosed(this) }', + ' get busy() { return native.win32ResourceBusy(this) }', + ' get active() { return native.win32ResourceActive(this) }', + ' close() { return native.win32ResourceClose(this) }', + '}', + 'class DynWin32Function {', + " constructor() { throw new TypeError('Use DynWin32Function.bind with an exact unsafe native descriptor') }", + ' static bind(spec) { return project(native.win32Bind(spec)) }', + ' get dll() { return native.win32FunctionDll(this) }', + ' get entryPoint() { return native.win32FunctionEntryPoint(this) }', + ' invoke(args) { return project(native.win32Invoke(this, args)) }', + ' invokeWithSubsystem(context, subsystem, args) { return project(native.win32InvokeWithSubsystem(this, context, subsystem, args)) }', + '}', + 'class DynWin32CallResult {', + " constructor() { throw new TypeError('Win32 call results originate only from native dispatch') }", + ' get returnValue() { return project(native.win32ResultReturnValue(this)) }', + ' get outputs() { return project(native.win32ResultOutputs(this)) }', + ' get lastError() { return native.win32ResultLastError(this) }', + ' get succeeded() { return native.win32ResultSucceeded(this) }', + '}', + 'class DynWin32SubsystemContext {', + " constructor() { throw new TypeError('Use an explicit Win32 subsystem initializer') }", + ' get subsystem() { return native.win32SubsystemName(this) }', + ' get closed() { return native.win32SubsystemClosed(this) }', + ' close() { return native.win32SubsystemClose(this) }', + '}', + 'class DynWin32OverlappedOperation {', + " constructor() { throw new TypeError('Use a generated ReadFile/WriteFile wrapper') }", + ' cancel() { return native.win32OverlappedCancel(this) }', + ' start(callback) { return native.win32OverlappedStart(this, callback) }', + '}', + `const classes = [null, ${win32CarrierNames.join(', ')}]`, + 'function project(value) {', + ' if (value === null || typeof value !== "object") return value', + ' if (Array.isArray(value)) return value.map(project)', + ' const kind = native.win32CarrierKind(value)', + ' if (kind) Object.setPrototypeOf(value, classes[kind].prototype)', + ' return value', + '}', + 'function statics(source, omitted = []) {', + ' class Runtime { constructor() { throw new TypeError("Win32 runtime helpers are static") } }', + ' for (const name of Object.getOwnPropertyNames(source)) {', + ' if (["name", "length", "prototype"].includes(name) || omitted.includes(name)) continue', + ' const method = Object.getOwnPropertyDescriptor(source, name).value', + ' if (typeof method === "function") Object.defineProperty(Runtime, name, {', + ' value: (...args) => project(Reflect.apply(method, source, args)),', + ' })', + ' }', + ' return Runtime', + '}', + `module.exports.safeDynWin32 = statics(native.DynWin32, ${JSON.stringify(unsafeWin32Methods)})`, + 'module.exports.DynWin32 = statics(native.DynWin32)', + 'module.exports.DynWin32Unsafe = statics(native.DynWin32Unsafe)', + 'module.exports.DynWinRtValue = native.DynWinRtValue', + ...win32CarrierNames.map((name) => `module.exports.${name} = ${name}`), + '', +].join('\n')) +const carrierMembers = [ + [], + ['readonly bytes: Buffer', 'readonly length: number'], + ['readonly value: bigint', 'readonly closed: boolean', 'readonly busy: boolean', 'readonly active: boolean', 'close(): void'], + [ + 'static bind(spec: DynWin32FunctionSpec): DynWin32Function', + 'readonly dll: string', 'readonly entryPoint: string', + 'invoke(args: DynWin32Value[]): DynWin32CallResult', + 'invokeWithSubsystem(context: DynWin32SubsystemContext, subsystem: string, args: DynWin32Value[]): DynWin32CallResult', + ], + ['readonly returnValue: DynWin32Value | null', 'readonly outputs: DynWin32Value[]', 'readonly lastError: number | null', 'readonly succeeded: boolean'], + ['readonly subsystem: string', 'readonly closed: boolean', 'close(): void'], + ['cancel(): void', 'start(callback: (error: Error | null, bytesTransferred?: number) => void): void'], +] +const carrierMarker = '// Win32 native carrier declarations (generated)' +const nativeDeclaration = readFileSync(join(distDir, 'index.d.ts'), 'utf8').split(carrierMarker)[0] +writeFileSync(join(distDir, 'index.d.ts'), [ + nativeDeclaration.trimEnd(), '', carrierMarker, + ...win32CarrierNames.flatMap((name, index) => [ + `export declare class ${name} {`, + ' private constructor()', + ` private readonly __${name}Brand: never`, + ...carrierMembers[index].map((member) => ` ${member}`), + '}', + ]), + '', +].join('\n')) +for (const [file, names, safe] of [ + ['win32', safeWin32Names, true], + ['win32-unsafe', unsafeWin32Names, false], +]) { + writeFileSync(join(distDir, `${file}.js`), [ + '// Generated by scripts/generate-entrypoints.mjs - do not edit', + "'use strict'", + "const runtime = require('./win32-internal.js')", + ...names.map((name) => `module.exports.${name} = runtime.${safe && name === 'DynWin32' ? 'safeDynWin32' : name}`), + '', + ].join('\n')) + writeFileSync(join(distDir, `${file}.d.ts`), [ + '// Generated by scripts/generate-entrypoints.mjs - do not edit', + `export { ${names.filter((name) => !safe || name !== 'DynWin32').join(', ')} } from './index.js'`, + ...(safe ? [ + `export declare const DynWin32: Omit JSON.stringify(name)).join(' | ')}>`, + ] : [ + "export type { DynWin32FunctionSpec, DynWin32ParameterSpec } from './index.js'", + ]), + '', + ].join('\n')) +} + writeFileSync( join(distDir, 'winrt-implementation.cjs'), readFileSync(join(packageDir, 'runtime', 'winrt-implementation.cjs'), 'utf8'), diff --git a/bindings/js/scripts/pe-imports.d.mts b/bindings/js/scripts/pe-imports.d.mts new file mode 100644 index 00000000..f052451f --- /dev/null +++ b/bindings/js/scripts/pe-imports.d.mts @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +export interface PeImport { + dll: string + symbols: (string | number)[] +} + +export function readPeImports(bytes: Buffer): PeImport[] +export function assertNoEagerWin32Imports(imports: PeImport[], options?: { testHooks?: boolean }): void +export function verifyAddonImports(directory: string, options?: { testHooksAddon?: string }): string[] diff --git a/bindings/js/scripts/pe-imports.mjs b/bindings/js/scripts/pe-imports.mjs new file mode 100644 index 00000000..bfa49c42 --- /dev/null +++ b/bindings/js/scripts/pe-imports.mjs @@ -0,0 +1,181 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { readFileSync, readdirSync } from 'node:fs' +import { join, win32 } from 'node:path' + +/** @typedef {{ dll: string, symbols: (string | number)[] }} PeImport */ + +/** Read ordinary PE imports from the file, not the process-wide loaded-module list. */ +export function readPeImports(/** @type {Buffer} */ bytes) { + if (!Buffer.isBuffer(bytes)) throw new TypeError('PE input must be a Buffer') + const invalid = (/** @type {string} */ reason) => new Error(`Invalid PE import table: ${reason}`) + const range = (/** @type {number} */ offset, /** @type {number} */ size, /** @type {string} */ label) => { + if (!Number.isSafeInteger(offset) || offset < 0 || size < 0 || offset + size > bytes.length) { + throw invalid(`truncated ${label}`) + } + } + range(0, 64, 'DOS header') + if (bytes.readUInt16LE(0) !== 0x5a4d) throw invalid('missing MZ signature') + const pe = bytes.readUInt32LE(0x3c) + if (pe < 64) throw invalid('invalid PE header offset') + range(pe, 24, 'PE header') + if (bytes.readUInt32LE(pe) !== 0x4550) throw invalid('missing PE signature') + + const optional = pe + 24 + const optionalSize = bytes.readUInt16LE(pe + 20) + range(optional, optionalSize, 'optional header') + if (optionalSize < 2) throw invalid('truncated optional header magic') + const magic = bytes.readUInt16LE(optional) + if (magic !== 0x10b && magic !== 0x20b) throw invalid('unsupported optional header magic') + const width = magic === 0x20b ? 8 : 4 + const directories = magic === 0x20b ? 112 : 96 + if (optionalSize < directories) throw invalid('truncated optional header') + const directoryCount = bytes.readUInt32LE(optional + directories - 4) + if (directoryCount > Math.floor((optionalSize - directories) / 8)) { + throw invalid('data directories exceed optional header') + } + + const sectionTable = optional + optionalSize + const sectionCount = bytes.readUInt16LE(pe + 6) + range(sectionTable, sectionCount * 40, 'section table') + const headerSize = bytes.readUInt32LE(optional + 60) + if (headerSize < sectionTable + sectionCount * 40 || headerSize > bytes.length) { + throw invalid('invalid SizeOfHeaders') + } + /** @type {{ rva: number, span: number, size: number, offset: number }[]} */ + const sections = [] + for (let index = 0; index < sectionCount; index++) { + const section = sectionTable + index * 40 + const virtualSize = bytes.readUInt32LE(section + 8) + const rva = bytes.readUInt32LE(section + 12) + const size = bytes.readUInt32LE(section + 16) + const offset = bytes.readUInt32LE(section + 20) + if (size && offset < headerSize) throw invalid('section overlaps headers') + range(offset, size, 'section data') + const span = Math.max(virtualSize, size) + if (rva + span > 0x100000000) throw invalid('section RVA overflow') + sections.push({ rva, span, size, offset }) + } + + const map = (/** @type {number} */ rva, /** @type {number} */ size, /** @type {string} */ label) => { + if (!Number.isSafeInteger(rva) || rva <= 0 || rva + size > 0x100000000) { + throw invalid(`invalid ${label} RVA`) + } + if (rva < headerSize) { + if (rva + size > headerSize) throw invalid(`${label} exceeds headers`) + return { offset: rva, end: headerSize } + } + const matches = sections.filter((section) => rva >= section.rva && rva - section.rva < section.span) + if (matches.length !== 1) throw invalid(`unmapped or ambiguous ${label} RVA`) + const section = matches[0] + const delta = rva - section.rva + if (delta + size > section.size) throw invalid(`${label} is not file-backed`) + return { offset: section.offset + delta, end: section.offset + section.size } + } + const string = (/** @type {number} */ rva, /** @type {string} */ label) => { + const { offset, end } = map(rva, 1, label) + const region = bytes.subarray(offset, end) + const nul = region.indexOf(0) + if (nul < 0) throw invalid(`unterminated ${label}`) + if (nul === 0) throw invalid(`empty ${label}`) + const value = region.subarray(0, nul) + if (value.some((byte) => byte < 0x20 || byte > 0x7e)) throw invalid(`non-ASCII ${label}`) + return value.toString('ascii') + } + const symbols = (/** @type {number} */ rva) => { + const { offset, end } = map(rva, width, 'import thunk') + const ordinalFlag = 1n << BigInt(width * 8 - 1) + /** @type {(string | number)[]} */ + const result = [] + for (let thunk = offset; thunk + width <= end; thunk += width) { + const value = width === 8 ? bytes.readBigUInt64LE(thunk) : BigInt(bytes.readUInt32LE(thunk)) + if (value === 0n) return result + if (value & ordinalFlag) { + if (value & ~(ordinalFlag | 0xffffn)) throw invalid('reserved ordinal thunk bits') + result.push(Number(value & 0xffffn)) + } else { + if (value > 0xffffffffn) throw invalid('import name RVA overflow') + const name = Number(value) + map(name, 3, 'import hint/name') + result.push(string(name + 2, 'import symbol')) + } + } + throw invalid('unterminated import thunk table') + } + + /** @type {PeImport[]} */ + const imports = [] + if (directoryCount < 2) return imports + const importRva = bytes.readUInt32LE(optional + directories + 8) + const importSize = bytes.readUInt32LE(optional + directories + 12) + if (importRva === 0 && importSize === 0) return imports + if (!importRva || importSize < 20) throw invalid('invalid import directory') + const { offset } = map(importRva, importSize, 'import directory') + for (let descriptor = offset; descriptor + 20 <= offset + importSize; descriptor += 20) { + const fields = Array.from({ length: 5 }, (_, index) => bytes.readUInt32LE(descriptor + index * 4)) + if (fields.every((field) => field === 0)) return imports + const [lookup, , , name, addressTable] = fields + if (!addressTable) throw invalid('missing import address table') + imports.push({ dll: string(name, 'DLL name'), symbols: symbols(lookup || addressTable) }) + } + throw invalid('unterminated import directory') +} + +const optionalSubsystemDlls = new Set(['mapi32.dll', 'gdiplus.dll', 'ws2_32.dll', 'mfplat.dll']) + +/** + * Production forbids these DLL descriptors entirely. The test-hooks-only + * DynComBorrowedCopyTestFixture uses MFCreateSample in com_borrowed_test_support.rs; + * no lifecycle import, ordinal, or other MFCreate* gets that exception. + * @param {PeImport[]} imports + * @param {{ testHooks?: boolean }} options + */ +export function assertNoEagerWin32Imports(imports, { testHooks = false } = {}) { + const violations = [] + for (const { dll, symbols } of imports) { + const name = win32.basename(dll).toLowerCase() + if (!optionalSubsystemDlls.has(name)) continue + if ( + testHooks && + name === 'mfplat.dll' && + symbols.length && + symbols.every((symbol) => symbol === 'MFCreateSample') + ) { + continue + } + violations.push( + `${dll}: ${symbols.map((symbol) => (typeof symbol === 'number' ? `#${symbol}` : symbol)).join(', ')}`, + ) + } + if (violations.length) { + throw new Error(`Optional Win32 subsystem DLLs must load lazily; eager PE imports:\n${violations.join('\n')}`) + } +} + +/** + * Inspect every shipped architecture without loading the addon. A caller allowing + * a local test-hooks addon must positively identify its native fixture export. + * @param {string} directory + * @param {{ testHooksAddon?: string }} options + */ +export function verifyAddonImports(directory, { testHooksAddon } = {}) { + const addons = readdirSync(directory, { withFileTypes: true }) + .filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith('.node')) + .map((entry) => entry.name) + .sort() + if (!addons.length) throw new Error(`No native addons found in ${directory}`) + if (testHooksAddon !== undefined && !addons.includes(testHooksAddon)) { + throw new Error(`Missing test-hooks addon: ${testHooksAddon}`) + } + for (const addon of addons) { + try { + assertNoEagerWin32Imports(readPeImports(readFileSync(join(directory, addon))), { + testHooks: addon === testHooksAddon, + }) + } catch (error) { + throw new Error(`${addon}: ${error instanceof Error ? error.message : error}`, { cause: error }) + } + } + return addons +} diff --git a/bindings/js/scripts/verify-runtime-artifact.mjs b/bindings/js/scripts/verify-runtime-artifact.mjs new file mode 100644 index 00000000..96e4191e --- /dev/null +++ b/bindings/js/scripts/verify-runtime-artifact.mjs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import assert from 'node:assert/strict' +import { readFileSync, realpathSync, statSync } from 'node:fs' +import { createRequire } from 'node:module' +import { dirname, join } from 'node:path' +import { fileURLToPath, pathToFileURL } from 'node:url' +import { verifyAddonImports } from './pe-imports.mjs' + +const args = process.argv.slice(2) +if (args.length !== 1 && !(args.length === 2 && args[1] === '--test-hooks')) { + throw new Error('Usage: node verify-runtime-artifact.mjs [--test-hooks]') +} + +const artifact = realpathSync(args[0]) +const source = dirname(fileURLToPath(import.meta.url)) +const manifest = JSON.parse(readFileSync(join(source, '..', 'package.json'), 'utf8')) +const require = createRequire(join(artifact, 'artifact-consumer.cjs')) +const modules = new Map() +const testHooksAddon = args[1] === '--test-hooks' ? `dynwinrt.win32-${process.arch}-msvc.node` : undefined +const addons = verifyAddonImports(artifact, { testHooksAddon }) +if (testHooksAddon) { + assert.equal( + typeof require(join(artifact, testHooksAddon)).DynComBorrowedCopyTestFixture, + 'function', + '--test-hooks requires the actual native COM borrowed-copy fixture export', + ) +} +console.log( + `Verified ordinary PE imports for ${addons.join(', ')}${testHooksAddon ? ' (explicit test-hooks mode)' : ''}`, +) + +function artifactFile(target) { + assert.ok(target.startsWith('./dist/'), `Unexpected runtime export target: ${target}`) + const path = join(artifact, target.slice('./dist/'.length)) + assert.ok(statSync(path).isFile(), `Missing artifact file: ${target}`) + return path +} + +for (const [name, target] of Object.entries(manifest.exports)) { + if (name === './package.json') continue + artifactFile(target.types) + const commonjs = require(artifactFile(target.require)) + const esm = await import(pathToFileURL(artifactFile(target.import)).href) + for (const key of Object.keys(commonjs)) { + assert.equal(esm[key], commonjs[key], `${name}: inconsistent ESM export ${key}`) + } + modules.set(name, commonjs) +} + +assert.equal(typeof modules.get('.').WinGuid.parse, 'function') +assert.equal(typeof modules.get('./com').initializeCom, 'function') +const { DynWin32, DynWin32Function } = modules.get('./win32/unsafe') +const tickCount = DynWin32Function.bind({ + dll: 'kernel32.dll', + entryPoint: 'GetTickCount', + parameters: [], + returnType: 'u32', +}).invoke([]) +assert.ok(Number.isInteger(DynWin32.toNumber(tickCount.returnValue))) +assert.equal(modules.get('./win32').DynWin32.initializeMapiUtilities, undefined) +console.log(`Verified ${modules.size} downloaded runtime entrypoints through CommonJS, ESM and native dispatch`) diff --git a/bindings/js/src/com.rs b/bindings/js/src/com.rs index 1371ee33..847aac66 100644 --- a/bindings/js/src/com.rs +++ b/bindings/js/src/com.rs @@ -625,7 +625,10 @@ fn get_error_info() -> napi::Result> { .transpose() } -fn try_cast(value: &DynWinRTValue, iid: &WinGUID) -> napi::Result> { +pub(super) fn try_cast( + value: &DynWinRTValue, + iid: &WinGUID, +) -> napi::Result> { const E_NOINTERFACE: windows::core::HRESULT = windows::core::HRESULT(0x80004002u32 as i32); value.ensure_existing_com_apartment()?; @@ -961,7 +964,7 @@ fn uint8_array_info( })) } -fn pointer(value: Unknown) -> napi::Result { +pub(super) fn pointer(value: Unknown) -> napi::Result { use napi::sys; let env = value.value().env; @@ -1058,7 +1061,7 @@ fn exact_null_pointer(value: Unknown) -> napi::Result { )) } -fn safe_data_pointer(value: Unknown, nullable: bool) -> napi::Result { +pub(super) fn safe_data_pointer(value: Unknown, nullable: bool) -> napi::Result { use napi::sys; let env = value.value().env; @@ -1442,7 +1445,7 @@ fn copy_callback_bstr(value: &DynWinRTValue) -> napi::Result> { Ok(value.as_deref().map(str::to_owned)) } -fn validate_pointer_owner(value: &DynWinRTValue) -> napi::Result<()> { +pub(super) fn validate_pointer_owner(value: &DynWinRTValue) -> napi::Result<()> { if let Some(owner) = &value.1 { owner.validate()?; } @@ -1536,6 +1539,16 @@ fn admit_com_inputs(args: &[&DynWinRTValue]) -> napi::Result { Ok(guard) } +pub(super) fn with_win32_input_leases( + args: &[&DynWinRTValue], + invoke: impl FnOnce(&dyn Fn() -> napi::Result<()>) -> napi::Result, +) -> napi::Result { + let guard = admit_com_inputs(args)?; + let _leases = collect_native_invocation_leases(args)?; + guard.check()?; + invoke(&|| guard.check()) +} + fn with_com_invocation_args_guarded( args: &[&DynWinRTValue], invoke: impl FnOnce( diff --git a/bindings/js/src/lib.rs b/bindings/js/src/lib.rs index 205daab5..66cb66a4 100644 --- a/bindings/js/src/lib.rs +++ b/bindings/js/src/lib.rs @@ -38,6 +38,13 @@ mod com_input; mod generated_unsafe_test_hooks; mod managed_tsfn; mod scheduled_start; +mod win32; +mod win32_subsystem; +pub use win32::{ + DynWin32, DynWin32CallResult, DynWin32Function, DynWin32FunctionSpec, DynWin32NativeStruct, + DynWin32ParameterSpec, DynWin32Resource, DynWin32Unsafe, DynWin32Value, +}; +pub use win32_subsystem::DynWin32SubsystemContext; mod winrt_delegate_method; pub use winrt_delegate_method::DynWinRtDelegateMethod; mod winrt_implementation; diff --git a/bindings/js/src/win32.rs b/bindings/js/src/win32.rs new file mode 100644 index 00000000..c10a0f58 --- /dev/null +++ b/bindings/js/src/win32.rs @@ -0,0 +1,2137 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::collections::BTreeMap; +#[cfg(test)] +use std::sync::atomic::Ordering; +use std::sync::Arc; + +use napi::bindgen_prelude::{BigInt, Buffer, Either, FromNapiValue, Unknown}; +use napi::JsValue; +use napi_derive::napi; +#[cfg(test)] +use windows::Win32::Foundation::HANDLE; + +use super::{com, win32_subsystem, DynWin32SubsystemContext, DynWinRTValue, WinGUID}; + +#[path = "win32_boundary.rs"] +pub(super) mod boundary; +#[path = "win32_io.rs"] +mod io; +pub use io::DynWin32OverlappedOperation; +#[path = "win32_spec.rs"] +mod specification; +#[path = "win32_storage.rs"] +mod storage; + +const MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH: usize = 1024 * 1024; + +#[napi(object)] +pub struct DynWin32ParameterSpec { + #[napi(js_name = "type")] + pub typ: String, + pub direction: String, + pub nullable: Option, + pub cleanup: Option, + pub consumes_resource: Option, + pub resource_cleanup: Option, + pub aggregate_descriptor: Option, + pub pointee_descriptor: Option, +} + +#[napi(object)] +pub struct DynWin32FunctionSpec { + pub dll: String, + pub entry_point: String, + pub parameters: Vec, + pub return_type: Option, + pub return_cleanup: Option, + pub success_rule: Option, + pub capture_last_error: Option, + pub calling_convention: Option, + pub return_aggregate_descriptor: Option, + pub call_contract_descriptor: Option, +} + +pub struct DynWin32Value { + value: dynwinrt::win32::Value, + pointer_owner: Option, +} +boundary::carrier!(DynWin32Value, 1, "DynWin32Value"); + +enum Win32PointerOwner { + Native(Arc), + Aggregate(Arc), + PointerSlot { + inner: Arc, + slot: Box, + }, +} + +struct RetainedNativePointer { + value: DynWinRTValue, + string: Option<(bool, bool)>, +} + +impl RetainedNativePointer { + fn validate(&self) -> napi::Result<()> { + self.value.ensure_existing_com_apartment()?; + self.value.check_com_input_state()?; + com::validate_pointer_owner(&self.value)?; + if let Some((wide, multi)) = self.string { + storage::validate_string_owner(&self.value, wide, multi)?; + } + Ok(()) + } +} + +impl DynWin32Value { + fn new(value: dynwinrt::win32::Value) -> Self { + Self { + value, + pointer_owner: None, + } + } + + fn with_pointer_owner(value: dynwinrt::win32::Value, pointer_owner: DynWinRTValue) -> Self { + Self { + value, + pointer_owner: Some(Win32PointerOwner::Native(Arc::new(RetainedNativePointer { + value: pointer_owner, + string: None, + }))), + } + } + + fn validate(&self) -> napi::Result<()> { + if let Some(Win32PointerOwner::Native(owner)) = &self.pointer_owner { + owner.validate()?; + } + if let Some(Win32PointerOwner::Aggregate(owner)) = &self.pointer_owner { + let _ = owner.byte_length; + } + if let Some(Win32PointerOwner::PointerSlot { inner, slot }) = &self.pointer_owner { + inner.validate()?; + let _ = **slot; + } + Ok(()) + } +} + +struct NativeAggregateStorage { + state: std::sync::Mutex, + backing: Arc, + byte_length: usize, + contains_pointers: bool, +} + +struct NativeAggregateState { + owners: BTreeMap>, +} + +impl NativeAggregateStorage { + fn new( + identity: String, + byte_length: usize, + alignment: usize, + bytes: Option<&[u8]>, + contains_pointers: bool, + fields: Vec, + ) -> napi::Result { + if contains_pointers && bytes.is_some() { + return Err(napi::Error::from_reason( + "pointer-bearing native aggregates cannot be initialized from raw bytes", + )); + } + if byte_length > dynwinrt::win32::MAX_NATIVE_AGGREGATE_SIZE { + return Err(napi::Error::from_reason(format!( + "native aggregate exceeds the {} byte safety limit", + dynwinrt::win32::MAX_NATIVE_AGGREGATE_SIZE + ))); + } + let layout = + dynwinrt::win32::NativeAggregatePointerLayout::new(identity, byte_length, alignment, fields) + .map_err(|error| napi::Error::from_reason(error.message()))?; + let backing = dynwinrt::win32::NativeAggregateBuffer::new(layout, bytes) + .map_err(|error| napi::Error::from_reason(error.message()))?; + Ok(Self { + state: std::sync::Mutex::new(NativeAggregateState { + owners: BTreeMap::new(), + }), + backing, + byte_length, + contains_pointers, + }) + } + + fn pointer(&self) -> *mut std::ffi::c_void { + self.backing.pointer() + } + + fn bytes(&self) -> napi::Result> { + if self.contains_pointers { + return Err(napi::Error::from_reason( + "raw bytes are unavailable for pointer-bearing native aggregates", + )); + } + self + .backing + .bytes() + .map_err(|error| napi::Error::from_reason(error.message())) + } + + fn write_field( + &self, + offset: usize, + bytes: &[u8], + owner: Option>, + ) -> napi::Result<()> { + let mut state = self.state.lock().unwrap_or_else(|error| error.into_inner()); + self + .backing + .write(offset, bytes) + .map_err(|error| napi::Error::from_reason(error.message()))?; + state.owners.remove(&offset); + if let Some(owner) = owner { + state.owners.insert(offset, owner); + } + Ok(()) + } + + fn read_field(&self, offset: usize) -> napi::Result<[u8; N]> { + self + .backing + .read(offset) + .map_err(|error| napi::Error::from_reason(error.message())) + } + + unsafe fn mark_call_result(&self, succeeded: bool) -> napi::Result<()> { + unsafe { self.backing.mark_legacy(succeeded) } + .map_err(|error| napi::Error::from_reason(error.message())) + } + + fn prepare_call(&self) -> napi::Result<()> { + self + .backing + .prepare() + .map_err(|error| napi::Error::from_reason(error.message())) + } + + fn require_success(&self) -> napi::Result<()> { + self + .backing + .require_success() + .map_err(|error| napi::Error::from_reason(error.message())) + } +} + +pub struct DynWin32NativeStruct { + descriptor: String, + storage: Arc, +} +boundary::carrier!(DynWin32NativeStruct, 2, "DynWin32NativeStruct"); + +impl DynWin32NativeStruct { + pub fn bytes(&self) -> napi::Result { + Ok(Buffer::from(self.storage.bytes()?)) + } + + pub fn length(&self) -> u32 { + self.storage.byte_length as u32 + } +} + +pub struct DynWin32Resource(Arc); +boundary::carrier!(DynWin32Resource, 3, "DynWin32Resource"); + +impl DynWin32Resource { + pub fn value(&self) -> BigInt { + BigInt::from(self.0.raw() as u64) + } + + pub fn closed(&self) -> bool { + self.0.is_closed() + } + + pub fn busy(&self) -> bool { + self.0.has_async_leases() + } + + pub fn active(&self) -> bool { + self.0.has_active_async_io() + } + + pub fn close(&self) -> napi::Result<()> { + self + .0 + .close() + .map_err(|error| napi::Error::from_reason(error.to_string())) + } +} + +pub struct DynWin32Function(Arc); +boundary::carrier!(DynWin32Function, 4, "DynWin32Function"); + +impl DynWin32Function { + pub fn bind(spec: DynWin32FunctionSpec) -> napi::Result { + bind_function(spec) + } + + pub fn dll(&self) -> String { + self.0.dll().to_string() + } + + pub fn entry_point(&self) -> String { + self.0.entry_point().to_string() + } + + pub fn invoke(&self, args: Vec<&DynWin32Value>) -> napi::Result { + self.invoke_impl(args) + } + + pub fn invoke_with_subsystem( + &self, + context: &DynWin32SubsystemContext, + subsystem: String, + args: Vec<&DynWin32Value>, + ) -> napi::Result { + let _subsystem_guard = win32_subsystem::call_guard(context, &subsystem)?; + self.invoke_impl(args) + } +} + +impl DynWin32Function { + fn invoke_impl(&self, args: Vec<&DynWin32Value>) -> napi::Result { + let owners = args + .iter() + .filter_map(|value| match &value.pointer_owner { + Some(Win32PointerOwner::Native(owner)) => Some(&owner.value), + Some(Win32PointerOwner::PointerSlot { inner, .. }) => Some(&inner.value), + _ => None, + }) + .collect::>(); + com::with_win32_input_leases(&owners, |validate_inputs| { + self.invoke_validated(&args, validate_inputs) + }) + } + + fn invoke_validated( + &self, + args: &[&DynWin32Value], + validate_inputs: &dyn Fn() -> napi::Result<()>, + ) -> napi::Result { + for value in args { + value.validate()?; + } + let mut aggregates = args + .iter() + .filter_map(|value| match &value.pointer_owner { + Some(Win32PointerOwner::Aggregate(owner)) => Some(owner), + _ => None, + }) + .collect::>(); + aggregates.sort_by_key(|owner| Arc::as_ptr(owner) as usize); + if aggregates + .windows(2) + .any(|pair| Arc::ptr_eq(pair[0], pair[1])) + { + return Err(napi::Error::from_reason( + "the same native aggregate cannot occupy multiple parameters in one call", + )); + } + let _aggregate_guards = aggregates + .into_iter() + .map(|owner| { + owner + .state + .lock() + .unwrap_or_else(|error| error.into_inner()) + }) + .collect::>(); + for state in &_aggregate_guards { + for owner in state.owners.values() { + owner.validate()?; + } + } + let _by_value_guards = args + .iter() + .filter_map(|value| { + if matches!(value.value, dynwinrt::win32::Value::Aggregate { .. }) { + if let Some(Win32PointerOwner::Aggregate(owner)) = &value.pointer_owner { + return Some(owner.backing.lease()); + } + } + None + }) + .collect::>(); + let values = args + .iter() + .map(|value| value.value.clone()) + .collect::>(); + validate_inputs()?; + let result = unsafe { self.0.invoke(&values) }.map_err(|error| { + napi::Error::from_reason(format!( + "DynWin32Function {}!{}: {}", + self.0.dll(), + self.0.entry_point(), + error.message() + )) + })?; + Ok(DynWin32CallResult { + return_value: result.return_value.map(DynWin32Value::new), + outputs: Some(result.outputs.into_iter().map(DynWin32Value::new).collect()), + last_error: result.last_error, + succeeded: result.succeeded, + }) + } +} + +pub struct DynWin32CallResult { + return_value: Option, + outputs: Option>, + last_error: Option, + succeeded: bool, +} +boundary::carrier!(DynWin32CallResult, 5, "DynWin32CallResult"); + +impl DynWin32CallResult { + pub fn return_value(&mut self) -> napi::Result> { + Ok(self.return_value.take()) + } + + pub fn outputs(&mut self) -> napi::Result> { + self + .outputs + .take() + .ok_or_else(|| napi::Error::from_reason("Win32 outputs were already consumed")) + } + + pub fn last_error(&self) -> Option { + self.last_error + } + + pub fn succeeded(&self) -> bool { + self.succeeded + } +} + +#[napi] +pub struct DynWin32; + +#[napi] +impl DynWin32 { + #[napi] + pub fn initialize_winsock() -> napi::Result { + win32_subsystem::initialize("winsock") + } + + #[napi] + pub fn initialize_gdi_plus() -> napi::Result { + win32_subsystem::initialize("gdiplus") + } + + #[napi] + pub fn initialize_media_foundation() -> napi::Result { + win32_subsystem::initialize("mediaFoundation") + } + + /// Requires an installed, configured MAPI provider of the process architecture. + /// The Windows system stub alone is insufficient and may display native UI. + #[napi] + pub fn initialize_mapi_utilities() -> napi::Result { + win32_subsystem::initialize("mapiUtilities") + } + + #[napi] + pub fn require_subsystem( + context: &DynWin32SubsystemContext, + #[napi(ts_arg_type = "string")] subsystem: specification::Name, + ) -> napi::Result<()> { + win32_subsystem::require(context, &subsystem) + } + + #[napi] + pub fn bool8(value: bool) -> DynWin32Value { + DynWin32Value::new(dynwinrt::win32::Value::U8(u8::from(value))) + } + + #[napi] + pub fn bool32(value: bool) -> DynWin32Value { + DynWin32Value::new(dynwinrt::win32::Value::Bool(value)) + } + + #[napi] + pub fn i8(value: f64) -> napi::Result { + check_integer(value, i8::MIN as f64, i8::MAX as f64, "i8")?; + Ok(DynWin32Value::new(dynwinrt::win32::Value::I8(value as i8))) + } + + #[napi] + pub fn u8(value: f64) -> napi::Result { + check_integer(value, 0.0, u8::MAX as f64, "u8")?; + Ok(DynWin32Value::new(dynwinrt::win32::Value::U8(value as u8))) + } + + #[napi] + pub fn i16(value: f64) -> napi::Result { + check_integer(value, i16::MIN as f64, i16::MAX as f64, "i16")?; + Ok(DynWin32Value::new(dynwinrt::win32::Value::I16( + value as i16, + ))) + } + + #[napi] + pub fn u16(value: f64) -> napi::Result { + check_integer(value, 0.0, u16::MAX as f64, "u16")?; + Ok(DynWin32Value::new(dynwinrt::win32::Value::U16( + value as u16, + ))) + } + + #[napi] + pub fn i32(value: f64) -> napi::Result { + check_integer(value, i32::MIN as f64, i32::MAX as f64, "i32")?; + Ok(DynWin32Value::new(dynwinrt::win32::Value::I32( + value as i32, + ))) + } + + #[napi] + pub fn u32(value: f64) -> napi::Result { + check_integer(value, 0.0, u32::MAX as f64, "u32")?; + Ok(DynWin32Value::new(dynwinrt::win32::Value::U32( + value as u32, + ))) + } + + #[napi] + pub fn i64(#[napi(ts_arg_type = "bigint")] value: Unknown) -> napi::Result { + Ok(DynWin32Value::new(dynwinrt::win32::Value::I64( + storage::signed64(&value)?, + ))) + } + + #[napi] + pub fn u64(#[napi(ts_arg_type = "bigint")] value: Unknown) -> napi::Result { + Ok(DynWin32Value::new(dynwinrt::win32::Value::U64( + storage::unsigned64(&value)?, + ))) + } + + #[napi] + pub fn f32(value: f64) -> DynWin32Value { + DynWin32Value::new(dynwinrt::win32::Value::F32(value as f32)) + } + + #[napi] + pub fn f64(value: f64) -> DynWin32Value { + DynWin32Value::new(dynwinrt::win32::Value::F64(value)) + } + + #[napi] + pub fn handle( + #[napi(ts_arg_type = "bigint | number | DynWin32Resource | null | undefined")] value: Unknown, + nullable: Option, + ) -> napi::Result { + handle_value(value, nullable.unwrap_or(false)) + } + + #[napi] + pub fn resource( + value: &DynWin32Resource, + #[napi(ts_arg_type = "string")] cleanup: specification::Name, + ) -> napi::Result { + let cleanup = parse_cleanup(&cleanup)?; + if cleanup == dynwinrt::win32::Cleanup::None || value.0.cleanup() != cleanup { + return Err(napi::Error::from_reason( + "Managed Win32 resource cleanup does not match the consuming API", + )); + } + if value.0.is_closed() { + return Err(napi::Error::from_reason( + "Cannot consume a closed flat Win32 resource", + )); + } + Ok(DynWin32Value::new(dynwinrt::win32::Value::Resource( + Arc::clone(&value.0), + ))) + } + + #[napi] + pub fn com_object( + #[napi(ts_arg_type = "DynWinRtValue | null | undefined")] value: Unknown, + #[napi(ts_arg_type = "string")] iid: specification::Name, + nullable: Option, + ) -> napi::Result { + use windows::core::Interface; + + let env = value.value().env; + let raw = value.value().value; + let mut value_type = napi::sys::ValueType::napi_undefined; + unsafe { napi::sys::napi_typeof(env, raw, &mut value_type) }; + if matches!( + value_type, + napi::sys::ValueType::napi_null | napi::sys::ValueType::napi_undefined + ) { + return if nullable.unwrap_or(false) { + Ok(DynWin32Value::new(dynwinrt::win32::Value::Null)) + } else { + Err(napi::Error::from_reason( + "DynWin32.comObject(): null requires an explicitly nullable interface", + )) + }; + } + if boundary::has_carrier(env, raw)? { + return Err(napi::Error::from_reason( + "Win32 handles and structs are not managed COM references", + )); + } + let value = boundary::managed_com_value(&value)?; + let iid = WinGUID( + windows::core::GUID::try_from(iid.as_str()) + .map_err(|_| napi::Error::from_reason("Invalid COM interface IID"))?, + ); + let owner = com::with_win32_input_leases(&[value], |validate_inputs| { + let owner = com::try_cast(value, &iid)?.ok_or_else(|| { + napi::Error::from_reason("Managed object does not implement the required Win32 interface") + })?; + validate_inputs()?; + Ok(owner) + })?; + let pointer = owner + .0 + .as_object() + .ok_or_else(|| napi::Error::from_reason("Managed value is not a COM object"))? + .as_raw(); + Ok(DynWin32Value { + value: dynwinrt::win32::Value::Pointer(pointer), + pointer_owner: Some(Win32PointerOwner::Native(Arc::new(RetainedNativePointer { + value: owner, + string: None, + }))), + }) + } + + #[napi] + pub fn data_pointer( + #[napi(ts_arg_type = "Buffer | Uint8Array | null | undefined")] value: Unknown, + nullable: Option, + ) -> napi::Result { + let nullable = nullable.unwrap_or(false); + let value = pointer_value(storage::data_pointer(value, nullable)?)?; + reject_required_null_pointer(&value, nullable)?; + Ok(value) + } + + #[napi] + pub fn buffer_length( + #[napi(ts_arg_type = "Buffer | Uint8Array")] value: Unknown, + ) -> napi::Result { + Ok(storage::length(&value)? as u32) + } + + #[napi] + pub fn byte_length( + #[napi(ts_arg_type = "Buffer | Uint8Array")] value: Unknown, + ) -> napi::Result { + Self::buffer_length(value) + } + + #[napi] + pub fn buffer_byte_length( + #[napi(ts_arg_type = "Buffer | Uint8Array")] value: Unknown, + ) -> napi::Result { + Self::buffer_length(value) + } + + #[napi] + pub fn allocate_buffer(length: f64) -> napi::Result { + Ok(Buffer::from(storage::zeroed(storage::checked_length( + length, + )?)?)) + } + + #[napi] + pub fn copy_buffer( + #[napi(ts_arg_type = "Buffer | Uint8Array")] value: Unknown, + actual_length: Option, + ) -> napi::Result { + storage::copy(&value, actual_length) + } + + #[napi] + pub fn aligned_data_pointer( + #[napi(ts_arg_type = "Buffer | Uint8Array | null | undefined")] value: Unknown, + alignment: f64, + nullable: Option, + ) -> napi::Result { + check_integer(alignment, 1.0, 8.0, "alignedDataPointer alignment")?; + let alignment = alignment as u32; + if !alignment.is_power_of_two() { + return Err(napi::Error::from_reason( + "DynWin32.alignedDataPointer(): alignment must be 1, 2, 4, or 8", + )); + } + let nullable = nullable.unwrap_or(false); + let value = pointer_value(storage::data_pointer(value, nullable)?)?; + reject_required_null_pointer(&value, nullable)?; + if let dynwinrt::win32::Value::Pointer(pointer) = &value.value { + if !pointer.is_null() && (*pointer as usize) % alignment as usize != 0 { + return Err(napi::Error::from_reason(format!( + "native buffer address is not aligned to {alignment} bytes" + ))); + } + } + Ok(value) + } + + #[napi] + pub fn wide_string( + #[napi(ts_arg_type = "string | Buffer | Uint8Array | null | undefined")] value: Unknown, + nullable: Option, + ) -> napi::Result { + string_value( + storage::string_pointer(value, nullable.unwrap_or(false), true, false)?, + true, + false, + ) + } + + #[napi] + pub fn ansi_string( + #[napi(ts_arg_type = "string | Buffer | Uint8Array | null | undefined")] value: Unknown, + nullable: Option, + ) -> napi::Result { + string_value( + storage::string_pointer(value, nullable.unwrap_or(false), false, false)?, + false, + false, + ) + } + + #[napi] + pub fn wide_multi_string( + #[napi(ts_arg_type = "string | readonly string[] | Buffer | Uint8Array | null | undefined")] + value: Unknown, + nullable: Option, + ) -> napi::Result { + string_value( + storage::string_pointer(value, nullable.unwrap_or(false), true, true)?, + true, + true, + ) + } + + #[napi] + pub fn ansi_multi_string( + #[napi(ts_arg_type = "string | readonly string[] | Buffer | Uint8Array | null | undefined")] + value: Unknown, + nullable: Option, + ) -> napi::Result { + string_value( + storage::string_pointer(value, nullable.unwrap_or(false), false, true)?, + false, + true, + ) + } + + #[napi] + pub fn wide_string_pointer_pointer( + #[napi(ts_arg_type = "string | Buffer | Uint8Array | null | undefined")] value: Unknown, + nullable: Option, + ) -> napi::Result { + string_pointer_pointer(value, nullable.unwrap_or(false), true) + } + + #[napi] + pub fn ansi_string_pointer_pointer( + #[napi(ts_arg_type = "string | Buffer | Uint8Array | null | undefined")] value: Unknown, + nullable: Option, + ) -> napi::Result { + string_pointer_pointer(value, nullable.unwrap_or(false), false) + } + + #[napi] + pub fn null_pointer() -> DynWin32Value { + DynWin32Value::new(dynwinrt::win32::Value::Null) + } + + #[napi] + pub fn begin_read_file( + file: &DynWin32Resource, + #[napi(ts_arg_type = "Buffer")] buffer: Unknown, + #[napi(ts_arg_type = "bigint | null")] offset: Option, + ) -> napi::Result { + io::prepare(dynwinrt::win32::io::IoKind::Read, file, buffer, offset) + } + + #[napi] + pub fn begin_write_file( + file: &DynWin32Resource, + #[napi(ts_arg_type = "Buffer")] buffer: Unknown, + #[napi(ts_arg_type = "bigint | null")] offset: Option, + ) -> napi::Result { + io::prepare(dynwinrt::win32::io::IoKind::Write, file, buffer, offset) + } + + #[napi] + pub fn create_native_struct( + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + #[napi(ts_arg_type = "Buffer | Uint8Array | null")] bytes: Option, + ) -> napi::Result { + let (_, size, alignment, contains_pointers, fields) = native_aggregate_layout(&descriptor)?; + if alignment > 8 { + return Err(napi::Error::from_reason( + "flat Win32 native aggregate alignment above 8 is unsupported", + )); + } + Ok(DynWin32NativeStruct { + storage: Arc::new(NativeAggregateStorage::new( + descriptor.as_str().to_string(), + size, + alignment, + bytes + .as_ref() + .map(|bytes| storage::buffer_info(bytes.value().env, bytes.raw())) + .transpose()? + .as_ref() + .map(|info| unsafe { info.bytes() }), + contains_pointers, + fields, + )?), + descriptor: descriptor.into_string(), + }) + } + + #[napi] + pub fn set_native_struct_u32( + value: &DynWin32NativeStruct, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + #[napi(ts_arg_type = "string")] field: specification::Name, + input: f64, + ) -> napi::Result<()> { + check_integer(input, 0.0, u32::MAX as f64, "native u32 field")?; + validate_native_struct(value, &descriptor)?; + let (offset, kind, _) = native_aggregate_field(&descriptor, &field)?; + if kind != "u32" { + return Err(napi::Error::from_reason(format!( + "native field `{field}` is not u32" + ))); + } + value + .storage + .write_field(offset, &(input as u32).to_le_bytes(), None) + } + + #[napi] + pub fn set_native_struct_bool32( + value: &DynWin32NativeStruct, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + #[napi(ts_arg_type = "string")] field: specification::Name, + input: bool, + ) -> napi::Result<()> { + validate_native_struct(value, &descriptor)?; + let (offset, kind, _) = native_aggregate_field(&descriptor, &field)?; + if kind != "i32" { + return Err(napi::Error::from_reason(format!( + "native field `{field}` is not BOOL" + ))); + } + value + .storage + .write_field(offset, &i32::from(input).to_le_bytes(), None) + } + + #[napi] + pub fn set_native_struct_pointer( + value: &DynWin32NativeStruct, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + #[napi(ts_arg_type = "string")] field: specification::Name, + pointer: &DynWin32Value, + ) -> napi::Result<()> { + validate_native_struct(value, &descriptor)?; + pointer.validate()?; + let (offset, kind, _) = native_aggregate_field(&descriptor, &field)?; + if kind != "pointer" { + return Err(napi::Error::from_reason(format!( + "native field `{field}` is not a data pointer" + ))); + } + let (bits, owner) = match (&pointer.value, &pointer.pointer_owner) { + (dynwinrt::win32::Value::Null, _) => (0usize, None), + (dynwinrt::win32::Value::Pointer(pointer), _) if pointer.is_null() => (0usize, None), + (dynwinrt::win32::Value::Pointer(pointer), Some(Win32PointerOwner::Native(owner))) + if owner.value.1.is_some() => + { + (*pointer as usize, Some(Arc::clone(owner))) + } + (dynwinrt::win32::Value::Pointer(_), _) => { + return Err(napi::Error::from_reason( + "native struct pointer fields require retained Buffer or string storage", + )); + } + _ => { + return Err(napi::Error::from_reason( + "native struct pointer field value is not a data pointer", + )); + } + }; + value + .storage + .write_field(offset, &bits.to_le_bytes(), owner) + } + + #[napi] + pub fn get_native_struct_u32( + value: &DynWin32NativeStruct, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + #[napi(ts_arg_type = "string")] field: specification::Name, + ) -> napi::Result { + validate_native_struct(value, &descriptor)?; + let (offset, kind, _) = native_aggregate_field(&descriptor, &field)?; + if kind != "u32" { + return Err(napi::Error::from_reason(format!( + "native field `{field}` is not u32" + ))); + } + if let Some(index) = value.storage.backing.field_index(&field) { + match value + .storage + .backing + .field_value(index) + .map_err(|error| napi::Error::from_reason(error.message()))? + { + dynwinrt::win32::Value::U32(_) => Ok(u32::from_le_bytes(value.storage.read_field(offset)?)), + _ => Err(napi::Error::from_reason( + "Native aggregate result field is not u32", + )), + } + } else { + value.storage.require_success()?; + Ok(u32::from_le_bytes(value.storage.read_field(offset)?)) + } + } + + #[napi] + pub fn take_native_struct_resource( + value: &DynWin32NativeStruct, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + #[napi(ts_arg_type = "string")] field: specification::Name, + #[napi(ts_arg_type = "string")] cleanup: specification::Name, + ) -> napi::Result> { + validate_native_struct(value, &descriptor)?; + let (_, kind, field_cleanup) = native_aggregate_field(&descriptor, &field)?; + if kind != "handle" || field_cleanup.as_deref() != Some(cleanup.as_str()) { + return Err(napi::Error::from_reason(format!( + "native field `{field}` does not have cleanup `{cleanup}`" + ))); + } + let cleanup = parse_cleanup(&cleanup)?; + if cleanup == dynwinrt::win32::Cleanup::None { + return Err(napi::Error::from_reason( + "Native resource fields require exact ownership cleanup", + )); + } + let index = value.storage.backing.field_index(&field).ok_or_else(|| { + napi::Error::from_reason("Native handle field has no result ownership contract") + })?; + match value + .storage + .backing + .take_field(index) + .map_err(|error| napi::Error::from_reason(error.message()))? + { + dynwinrt::win32::Value::Resource(resource) if resource.cleanup() == cleanup => { + Ok(Some(DynWin32Resource(resource))) + } + dynwinrt::win32::Value::Handle(0) => Ok(None), + _ => Err(napi::Error::from_reason( + "Native aggregate result is not an owned handle", + )), + } + } + + /// # Safety + /// + /// Successful legacy fields must be defined native results transferring + /// exclusive ownership with their declared cleanup; borrowed handles or + /// caller-written pointer bytes alone do not satisfy this contract. The caller + /// must uphold `dynwinrt::win32::NativeAggregateBuffer::mark_legacy`'s safety + /// requirements, including completed native writes and no other owners. + #[napi] + pub unsafe fn mark_native_struct_call_result( + value: &DynWin32NativeStruct, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + succeeded: bool, + ) -> napi::Result<()> { + validate_native_struct(value, &descriptor)?; + unsafe { value.storage.mark_call_result(succeeded) } + } + + #[napi] + pub fn prepare_native_struct_call( + value: &DynWin32NativeStruct, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + ) -> napi::Result<()> { + validate_native_struct(value, &descriptor)?; + value.storage.prepare_call() + } + + #[napi] + pub fn native_struct( + #[napi(ts_arg_type = "DynWin32NativeStruct | null | undefined")] value: Unknown, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + nullable: Option, + ) -> napi::Result { + let env = value.value().env; + let raw = value.value().value; + let mut value_type = napi::sys::ValueType::napi_undefined; + unsafe { napi::sys::napi_typeof(env, raw, &mut value_type) }; + if matches!( + value_type, + napi::sys::ValueType::napi_null | napi::sys::ValueType::napi_undefined + ) { + return if nullable.unwrap_or(false) { + Ok(DynWin32Value::new(dynwinrt::win32::Value::Null)) + } else { + Err(napi::Error::from_reason( + "DynWin32.nativeStruct(): null requires an explicitly nullable aggregate pointer", + )) + }; + } + let value = unsafe { <&DynWin32NativeStruct>::from_napi_value(env, raw) }?; + if value.descriptor != descriptor.as_str() { + return Err(napi::Error::from_reason( + "DynWin32.nativeStruct(): native aggregate type mismatch", + )); + } + Ok(DynWin32Value { + value: dynwinrt::win32::Value::AggregatePointer(Arc::clone(&value.storage.backing)), + pointer_owner: Some(Win32PointerOwner::Aggregate(Arc::clone(&value.storage))), + }) + } + + #[napi] + pub fn native_struct_value( + value: &DynWin32NativeStruct, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + ) -> napi::Result { + if value.descriptor != descriptor.as_str() { + return Err(napi::Error::from_reason( + "DynWin32.nativeStructValue(): native aggregate type mismatch", + )); + } + let layout = native_aggregate_call_layout(&descriptor)?; + Ok(DynWin32Value { + value: dynwinrt::win32::Value::Aggregate { + layout, + pointer: value.storage.pointer(), + }, + pointer_owner: Some(Win32PointerOwner::Aggregate(Arc::clone(&value.storage))), + }) + } + + #[napi] + pub fn to_native_struct( + value: &DynWin32Value, + #[napi(ts_arg_type = "string")] descriptor: specification::Descriptor, + ) -> napi::Result { + let dynwinrt::win32::Value::OwnedAggregate { layout, bytes } = &value.value else { + return Err(napi::Error::from_reason( + "Win32 value is not an owned native aggregate", + )); + }; + if layout.identity() != descriptor.as_str() { + return Err(napi::Error::from_reason( + "native aggregate return identity mismatch", + )); + } + let (_, _, alignment, _, fields) = native_aggregate_layout(&descriptor)?; + Ok(DynWin32NativeStruct { + storage: Arc::new(NativeAggregateStorage::new( + descriptor.as_str().to_string(), + bytes.len(), + alignment, + Some(bytes), + false, + fields, + )?), + descriptor: descriptor.into_string(), + }) + } + + #[napi] + pub fn to_number(value: &DynWin32Value) -> napi::Result { + Ok(match &value.value { + dynwinrt::win32::Value::Bool(value) => u8::from(*value) as f64, + dynwinrt::win32::Value::I8(value) => *value as f64, + dynwinrt::win32::Value::U8(value) => *value as f64, + dynwinrt::win32::Value::I16(value) => *value as f64, + dynwinrt::win32::Value::U16(value) => *value as f64, + dynwinrt::win32::Value::I32(value) => *value as f64, + dynwinrt::win32::Value::U32(value) => *value as f64, + dynwinrt::win32::Value::F32(value) => *value as f64, + dynwinrt::win32::Value::F64(value) => *value, + _ => { + return Err(napi::Error::from_reason( + "Win32 value is not a JavaScript number", + )); + } + }) + } + + #[napi] + pub fn to_bigint(value: &DynWin32Value) -> napi::Result { + match &value.value { + dynwinrt::win32::Value::I64(value) => Ok(BigInt::from(*value)), + dynwinrt::win32::Value::U64(value) => Ok(BigInt::from(*value)), + dynwinrt::win32::Value::FunctionPointer(value) => Ok(BigInt::from(*value as u64)), + dynwinrt::win32::Value::Handle(value) => Ok(BigInt::from(*value as u64)), + dynwinrt::win32::Value::Resource(value) => Ok(BigInt::from(value.raw() as u64)), + dynwinrt::win32::Value::Null => Ok(BigInt::from(0u64)), + _ => Err(napi::Error::from_reason( + "Win32 value is not a 64-bit integer, pointer, or handle", + )), + } + } + + #[napi] + pub fn to_boolean(value: &DynWin32Value) -> napi::Result { + match value.value { + dynwinrt::win32::Value::Bool(value) => Ok(value), + dynwinrt::win32::Value::U8(value) => Ok(value != 0), + _ => Err(napi::Error::from_reason("Win32 value is not BOOL")), + } + } + + #[napi] + pub fn to_resource(value: &DynWin32Value) -> napi::Result> { + if matches!( + &value.value, + dynwinrt::win32::Value::Handle(0) + | dynwinrt::win32::Value::Null + | dynwinrt::win32::Value::Discarded + ) { + return Ok(None); + } + value + .value + .resource() + .cloned() + .map(DynWin32Resource) + .map(Some) + .ok_or_else(|| napi::Error::from_reason("Win32 value is not an owned resource")) + } + + #[napi] + pub fn is_unavailable(value: &DynWin32Value) -> bool { + matches!( + value.value, + dynwinrt::win32::Value::Unavailable | dynwinrt::win32::Value::Discarded + ) + } + + #[napi] + pub fn to_resource_or_handle( + value: &DynWin32Value, + ) -> napi::Result>> { + match &value.value { + dynwinrt::win32::Value::Resource(resource) => { + Ok(Some(Either::A(DynWin32Resource(Arc::clone(resource))))) + } + dynwinrt::win32::Value::Handle(0) + | dynwinrt::win32::Value::Null + | dynwinrt::win32::Value::Discarded => Ok(None), + dynwinrt::win32::Value::Handle(bits) => Ok(Some(Either::B(BigInt::from(*bits as u64)))), + _ => Err(napi::Error::from_reason( + "Win32 value is not a resource or borrowed handle", + )), + } + } +} + +fn reject_required_null_pointer(value: &DynWin32Value, nullable: bool) -> napi::Result<()> { + if !nullable + && matches!( + &value.value, + dynwinrt::win32::Value::Pointer(pointer) if pointer.is_null() + ) + { + return Err(napi::Error::from_reason( + "non-nullable native pointer requires non-empty backing storage", + )); + } + Ok(()) +} + +fn validate_native_struct(value: &DynWin32NativeStruct, descriptor: &str) -> napi::Result<()> { + if value.descriptor != descriptor { + return Err(napi::Error::from_reason("native aggregate type mismatch")); + } + Ok(()) +} + +fn native_aggregate_field( + descriptor: &str, + field: &str, +) -> napi::Result<(usize, String, Option)> { + let root = parse_native_aggregate_descriptor(descriptor)?; + #[cfg(target_arch = "x86")] + let architecture = "x86"; + #[cfg(target_arch = "x86_64")] + let architecture = "x64"; + #[cfg(target_arch = "aarch64")] + let architecture = "arm64"; + #[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))] + return Err(napi::Error::from_reason( + "flat Win32 native aggregates support only x86, x64, and ARM64", + )); + let fields = root + .get(architecture) + .and_then(|layout| layout.get("fields")) + .and_then(serde_json::Value::as_array) + .ok_or_else(|| napi::Error::from_reason("native aggregate descriptor has no fields"))?; + let field = fields + .iter() + .find(|candidate| candidate.get("name").and_then(serde_json::Value::as_str) == Some(field)) + .ok_or_else(|| napi::Error::from_reason(format!("unknown native field `{field}`")))?; + let offset = field + .get("offset") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .ok_or_else(|| napi::Error::from_reason("native field has invalid offset"))?; + let kind = field + .get("type") + .and_then(|typ| typ.get("kind")) + .and_then(serde_json::Value::as_str) + .ok_or_else(|| napi::Error::from_reason("native field has invalid type"))?; + let cleanup = field + .get("type") + .and_then(|typ| typ.get("cleanup")) + .and_then(serde_json::Value::as_str) + .map(str::to_string); + Ok((offset, kind.to_string(), cleanup)) +} + +fn native_layout_extent(layout: &serde_json::Value) -> napi::Result<(usize, usize)> { + let size = layout + .get("size") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .filter(|value| *value > 0 && *value <= dynwinrt::win32::MAX_NATIVE_AGGREGATE_SIZE) + .ok_or_else(|| napi::Error::from_reason("Native aggregate size exceeds its safety limit"))?; + let alignment = layout + .get("alignment") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .filter(|value| value.is_power_of_two() && *value <= 8 && size % *value == 0) + .ok_or_else(|| napi::Error::from_reason("Native aggregate alignment is invalid"))?; + Ok((size, alignment)) +} + +fn validate_native_layout(layout: &serde_json::Value, union: bool) -> napi::Result<()> { + let (size, _) = native_layout_extent(layout)?; + let fields = layout + .get("fields") + .and_then(serde_json::Value::as_array) + .ok_or_else(|| napi::Error::from_reason("Native aggregate is missing fields"))?; + let mut ranges = Vec::new(); + ranges + .try_reserve_exact(fields.len()) + .map_err(|_| napi::Error::from_reason("Unable to allocate native layout validation"))?; + let mut names = std::collections::HashSet::new(); + names + .try_reserve(fields.len()) + .map_err(|_| napi::Error::from_reason("Unable to allocate native field identities"))?; + for field in fields { + let name = field + .get("name") + .and_then(serde_json::Value::as_str) + .filter(|name| !name.is_empty()) + .ok_or_else(|| napi::Error::from_reason("Native field requires an exact name"))?; + if !names.insert(name) { + return Err(napi::Error::from_reason("Duplicate native field name")); + } + let offset = field + .get("offset") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .ok_or_else(|| napi::Error::from_reason("Native field offset is invalid"))?; + let count = field + .get("count") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .filter(|value| *value > 0) + .ok_or_else(|| napi::Error::from_reason("Native field count is invalid"))?; + let typ = field + .get("type") + .ok_or_else(|| napi::Error::from_reason("Native field type is missing"))?; + let kind = typ + .get("kind") + .and_then(serde_json::Value::as_str) + .ok_or_else(|| napi::Error::from_reason("Native field kind is missing"))?; + let field_size = match kind { + "i8" | "u8" => 1, + "i16" | "u16" => 2, + "i32" | "u32" | "f32" => 4, + "i64" | "u64" | "f64" => 8, + "isize" | "usize" => std::mem::size_of::(), + "guid" => 16, + "pointer" | "handle" => { + if count != 1 || union { + return Err(napi::Error::from_reason( + "Native pointer/resource arrays and unions require ownership contracts", + )); + } + if kind == "handle" { + parse_cleanup( + typ + .get("cleanup") + .and_then(serde_json::Value::as_str) + .ok_or_else(|| { + napi::Error::from_reason("Native handle field has no cleanup contract") + })?, + )?; + } + std::mem::size_of::() + } + "struct" | "union" => { + let nested = typ + .get("layout") + .ok_or_else(|| napi::Error::from_reason("Nested native field layout is missing"))?; + validate_native_layout(nested, kind == "union")?; + if native_layout_contains_pointers(nested)? { + return Err(napi::Error::from_reason( + "Nested pointer ownership is not modeled", + )); + } + native_layout_extent(nested)?.0 + } + _ => { + return Err(napi::Error::from_reason(format!( + "Unsupported native field kind `{kind}`" + ))) + } + }; + let end = field_size + .checked_mul(count) + .and_then(|length| offset.checked_add(length)) + .filter(|end| *end <= size) + .ok_or_else(|| napi::Error::from_reason("Native field exceeds aggregate size"))?; + if union && offset != 0 { + return Err(napi::Error::from_reason( + "Native union fields must overlap at offset zero", + )); + } + ranges.push((offset, end)); + } + if !union { + ranges.sort_unstable(); + if ranges.windows(2).any(|fields| fields[0].1 > fields[1].0) { + return Err(napi::Error::from_reason("Native struct fields overlap")); + } + } + Ok(()) +} + +fn reserve_ffi_elements( + elements: &mut Vec, + count: usize, +) -> napi::Result<()> { + const MAX_ELEMENTS: usize = + dynwinrt::win32::MAX_NATIVE_AGGREGATE_SIZE / std::mem::size_of::(); + if elements + .len() + .checked_add(count) + .is_none_or(|length| length > MAX_ELEMENTS) + { + return Err(napi::Error::from_reason( + "Native aggregate libffi type graph exceeds its safety limit", + )); + } + elements + .try_reserve_exact(count) + .map_err(|_| napi::Error::from_reason("Unable to allocate native aggregate libffi fields")) +} + +fn native_aggregate_layout( + descriptor: &str, +) -> napi::Result<( + String, + usize, + usize, + bool, + Vec, +)> { + let root = parse_native_aggregate_descriptor(descriptor)?; + let name = root + .get("name") + .and_then(serde_json::Value::as_str) + .ok_or_else(|| napi::Error::from_reason("native aggregate descriptor is missing `name`"))?; + #[cfg(target_arch = "x86")] + let architecture = "x86"; + #[cfg(target_arch = "x86_64")] + let architecture = "x64"; + #[cfg(target_arch = "aarch64")] + let architecture = "arm64"; + #[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))] + return Err(napi::Error::from_reason( + "flat Win32 native aggregates support only x86, x64, and ARM64", + )); + let layout = root.get(architecture).ok_or_else(|| { + napi::Error::from_reason(format!( + "native aggregate descriptor is missing `{architecture}`" + )) + })?; + let union = match root.get("kind").and_then(serde_json::Value::as_str) { + Some("struct") => false, + Some("union") => true, + _ => { + return Err(napi::Error::from_reason( + "Native aggregate requires struct or union kind", + )) + } + }; + validate_native_layout(layout, union)?; + let size = layout + .get("size") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .filter(|value| *value > 0) + .ok_or_else(|| napi::Error::from_reason("native aggregate has invalid `size`"))?; + if size > dynwinrt::win32::MAX_NATIVE_AGGREGATE_SIZE { + return Err(napi::Error::from_reason(format!( + "native aggregate exceeds the {} byte safety limit", + dynwinrt::win32::MAX_NATIVE_AGGREGATE_SIZE + ))); + } + let alignment = layout + .get("alignment") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .filter(|value| value.is_power_of_two() && size % *value == 0) + .ok_or_else(|| napi::Error::from_reason("native aggregate has invalid `alignment`"))?; + Ok(( + name.to_string(), + size, + alignment, + native_layout_contains_pointers(layout)?, + native_layout_result_fields(&root, layout)?, + )) +} + +fn native_aggregate_pointer_layout( + descriptor: &str, +) -> napi::Result> { + let (_, size, alignment, _, fields) = native_aggregate_layout(descriptor)?; + dynwinrt::win32::NativeAggregatePointerLayout::new( + descriptor.to_string(), + size, + alignment, + fields, + ) + .map_err(|error| napi::Error::from_reason(error.message())) +} + +fn native_layout_result_fields( + root: &serde_json::Value, + layout: &serde_json::Value, +) -> napi::Result> { + let fields = layout + .get("fields") + .and_then(serde_json::Value::as_array) + .ok_or_else(|| napi::Error::from_reason("Native aggregate fields are missing"))?; + let owned = fields + .iter() + .filter_map(|field| { + let typ = field.get("type")?; + (typ.get("kind").and_then(serde_json::Value::as_str) == Some("handle") + && typ + .get("cleanup") + .and_then(serde_json::Value::as_str) + .is_some_and(|cleanup| cleanup != "none")) + .then(|| field.get("name").and_then(serde_json::Value::as_str)) + .flatten() + }) + .collect::>(); + let names = match root.get("outputFields") { + None => owned.clone(), + Some(value) => value + .as_array() + .ok_or_else(|| napi::Error::from_reason("outputFields must be an array"))? + .iter() + .map(|value| { + value + .as_str() + .ok_or_else(|| napi::Error::from_reason("outputFields must contain field names")) + }) + .collect::>>()?, + }; + if names.len() > 1024 || owned.iter().any(|name| !names.contains(name)) { + return Err(napi::Error::from_reason( + "Native result fields omit owned handles or exceed the field limit", + )); + } + if !names.is_empty() && root.get("kind").and_then(serde_json::Value::as_str) != Some("struct") { + return Err(napi::Error::from_reason( + "Union result ownership requires an explicit active-arm contract", + )); + } + let mut seen = std::collections::BTreeSet::new(); + names + .into_iter() + .map(|name| { + if !seen.insert(name) { + return Err(napi::Error::from_reason( + "Duplicate native aggregate output field", + )); + } + let field = fields + .iter() + .find(|field| field.get("name").and_then(serde_json::Value::as_str) == Some(name)) + .ok_or_else(|| napi::Error::from_reason("Unknown native aggregate output field"))?; + if field.get("count").and_then(serde_json::Value::as_u64) != Some(1) { + return Err(napi::Error::from_reason( + "Aggregate result arrays require an element ownership contract", + )); + } + let typ = field + .get("type") + .ok_or_else(|| napi::Error::from_reason("Native output field type is missing"))?; + let kind = typ + .get("kind") + .and_then(serde_json::Value::as_str) + .ok_or_else(|| napi::Error::from_reason("Native output field kind is missing"))?; + let abi = match kind { + "isize" => { + if cfg!(target_pointer_width = "64") { + dynwinrt::win32::Type::I64 + } else { + dynwinrt::win32::Type::I32 + } + } + "usize" => { + if cfg!(target_pointer_width = "64") { + dynwinrt::win32::Type::U64 + } else { + dynwinrt::win32::Type::U32 + } + } + _ => parse_type(kind)?, + }; + let cleanup = typ + .get("cleanup") + .and_then(serde_json::Value::as_str) + .map(parse_cleanup) + .transpose()? + .unwrap_or(dynwinrt::win32::Cleanup::None); + let offset = field + .get("offset") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .ok_or_else(|| napi::Error::from_reason("Native output field offset is invalid"))?; + Ok(dynwinrt::win32::AggregateResultField { + name: name.to_owned(), + offset, + typ: abi, + cleanup, + }) + }) + .collect() +} + +fn native_layout_contains_pointers(layout: &serde_json::Value) -> napi::Result { + let mut contains = false; + for field in layout + .get("fields") + .and_then(serde_json::Value::as_array) + .ok_or_else(|| napi::Error::from_reason("Native aggregate is missing fields"))? + { + let typ = field + .get("type") + .ok_or_else(|| napi::Error::from_reason("Native field is missing type"))?; + let kind = typ + .get("kind") + .and_then(serde_json::Value::as_str) + .ok_or_else(|| napi::Error::from_reason("Native field is missing kind"))?; + contains |= match kind { + "pointer" | "handle" => true, + "struct" | "union" => native_layout_contains_pointers( + typ + .get("layout") + .ok_or_else(|| napi::Error::from_reason("Nested native layout is missing"))?, + )?, + "i8" | "u8" | "i16" | "u16" | "i32" | "u32" | "i64" | "u64" | "isize" | "usize" | "f32" + | "f64" | "guid" => false, + _ => { + return Err(napi::Error::from_reason(format!( + "Unsupported native field kind `{kind}`" + ))) + } + }; + } + Ok(contains) +} + +fn native_aggregate_call_layout( + descriptor: &str, +) -> napi::Result> { + let root = parse_native_aggregate_descriptor(descriptor)?; + if root.get("kind").and_then(serde_json::Value::as_str) != Some("struct") { + return Err(napi::Error::from_reason( + "Only plain native structs can be passed by value", + )); + } + #[cfg(target_arch = "x86")] + let architecture = "x86"; + #[cfg(target_arch = "x86_64")] + let architecture = "x64"; + #[cfg(target_arch = "aarch64")] + let architecture = "arm64"; + #[cfg(not(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64")))] + return Err(napi::Error::from_reason( + "flat Win32 native aggregates support only x86, x64, and ARM64", + )); + let layout = root.get(architecture).ok_or_else(|| { + napi::Error::from_reason(format!( + "native aggregate descriptor is missing `{architecture}`" + )) + })?; + validate_native_layout(layout, false)?; + if native_layout_contains_pointers(layout)? { + return Err(napi::Error::from_reason( + "Pointer-bearing native aggregates cannot be passed by value", + )); + } + let size = layout + .get("size") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .ok_or_else(|| napi::Error::from_reason("native aggregate has invalid `size`"))?; + let alignment = layout + .get("alignment") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .ok_or_else(|| napi::Error::from_reason("native aggregate has invalid `alignment`"))?; + let ffi_type = native_aggregate_ffi_type(layout)?; + dynwinrt::win32::NativeAggregateLayout::new(descriptor, size, alignment, ffi_type) + .map_err(|error| napi::Error::from_reason(error.message())) +} + +fn parse_native_aggregate_descriptor(descriptor: &str) -> napi::Result { + if descriptor.len() > MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH { + return Err(napi::Error::from_reason(format!( + "flat Win32 native aggregate descriptor exceeds the {MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH} byte safety limit" + ))); + } + serde_json::from_str(descriptor).map_err(|error| { + napi::Error::from_reason(format!( + "Invalid flat Win32 native aggregate descriptor: {error}" + )) + }) +} + +fn native_aggregate_ffi_type(layout: &serde_json::Value) -> napi::Result { + validate_native_layout(layout, false)?; + let size = layout + .get("size") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .ok_or_else(|| napi::Error::from_reason("native aggregate has invalid `size`"))?; + let mut fields = layout + .get("fields") + .and_then(serde_json::Value::as_array) + .ok_or_else(|| napi::Error::from_reason("native aggregate is missing `fields`"))? + .iter() + .collect::>(); + fields.sort_by_key(|field| { + field + .get("offset") + .and_then(serde_json::Value::as_u64) + .unwrap_or(u64::MAX) + }); + let mut elements = Vec::new(); + let mut cursor = 0usize; + for field in fields { + let offset = field + .get("offset") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .ok_or_else(|| napi::Error::from_reason("native field has invalid `offset`"))?; + if offset < cursor { + return Err(napi::Error::from_reason( + "overlapping native fields cannot be passed by value", + )); + } + if offset > size { + return Err(napi::Error::from_reason( + "Native field offset exceeds aggregate size", + )); + } + reserve_ffi_elements(&mut elements, offset - cursor)?; + elements.extend(std::iter::repeat_with(libffi::middle::Type::u8).take(offset - cursor)); + let count = field + .get("count") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .filter(|value| *value > 0) + .ok_or_else(|| napi::Error::from_reason("native field has invalid `count`"))?; + let typ = field + .get("type") + .ok_or_else(|| napi::Error::from_reason("native field is missing `type`"))?; + let (field_type, field_size) = native_ffi_field_type(typ)?; + let end = offset + .checked_add( + field_size + .checked_mul(count) + .ok_or_else(|| napi::Error::from_reason("native aggregate field size overflow"))?, + ) + .ok_or_else(|| napi::Error::from_reason("native aggregate field end overflow"))?; + if end > size { + return Err(napi::Error::from_reason( + "Native field exceeds aggregate size", + )); + } + reserve_ffi_elements(&mut elements, count)?; + for _ in 0..count { + elements.push(field_type.clone()); + } + cursor = end; + } + if cursor > size { + return Err(napi::Error::from_reason( + "native aggregate fields exceed declared size", + )); + } + if elements.is_empty() { + return Err(napi::Error::from_reason( + "By-value native aggregates require exact field ABI types", + )); + } + reserve_ffi_elements(&mut elements, size - cursor)?; + elements.extend(std::iter::repeat_with(libffi::middle::Type::u8).take(size - cursor)); + Ok(libffi::middle::Type::structure(elements)) +} + +fn native_ffi_field_type(typ: &serde_json::Value) -> napi::Result<(libffi::middle::Type, usize)> { + let kind = typ + .get("kind") + .and_then(serde_json::Value::as_str) + .ok_or_else(|| napi::Error::from_reason("native field type is missing `kind`"))?; + Ok(match kind { + "i8" => (libffi::middle::Type::i8(), 1), + "u8" => (libffi::middle::Type::u8(), 1), + "i16" => (libffi::middle::Type::i16(), 2), + "u16" => (libffi::middle::Type::u16(), 2), + "i32" => (libffi::middle::Type::i32(), 4), + "u32" => (libffi::middle::Type::u32(), 4), + "i64" => (libffi::middle::Type::i64(), 8), + "u64" => (libffi::middle::Type::u64(), 8), + "isize" if std::mem::size_of::() == 4 => (libffi::middle::Type::i32(), 4), + "usize" if std::mem::size_of::() == 4 => (libffi::middle::Type::u32(), 4), + "isize" => (libffi::middle::Type::i64(), 8), + "usize" => (libffi::middle::Type::u64(), 8), + "f32" => (libffi::middle::Type::f32(), 4), + "f64" => (libffi::middle::Type::f64(), 8), + "pointer" => ( + libffi::middle::Type::pointer(), + std::mem::size_of::(), + ), + "guid" => { + let mut fields = vec![ + libffi::middle::Type::u32(), + libffi::middle::Type::u16(), + libffi::middle::Type::u16(), + ]; + fields.extend(std::iter::repeat_with(libffi::middle::Type::u8).take(8)); + (libffi::middle::Type::structure(fields), 16) + } + "struct" => { + let layout = typ + .get("layout") + .ok_or_else(|| napi::Error::from_reason("nested struct is missing `layout`"))?; + let size = layout + .get("size") + .and_then(serde_json::Value::as_u64) + .and_then(|value| usize::try_from(value).ok()) + .ok_or_else(|| napi::Error::from_reason("nested struct has invalid `size`"))?; + (native_aggregate_ffi_type(layout)?, size) + } + "union" => { + return Err(napi::Error::from_reason( + "nested unions cannot be passed by value safely", + )); + } + _ => { + return Err(napi::Error::from_reason(format!( + "unsupported native aggregate field kind `{kind}`" + ))); + } + }) +} + +#[napi] +pub struct DynWin32Unsafe; + +#[napi] +impl DynWin32Unsafe { + #[napi] + pub fn bind( + #[napi(ts_arg_type = "DynWin32FunctionSpec")] spec: Unknown, + ) -> napi::Result { + bind_function(specification::function_spec(spec)?) + } + + #[napi] + pub fn pointer( + #[napi(ts_arg_type = "bigint | number | Buffer | Uint8Array | null | undefined")] + value: Unknown, + ) -> napi::Result { + pointer_value(storage::unsafe_pointer(value)?) + } + + #[napi] + pub fn pointer_address(value: &DynWin32Value) -> napi::Result { + value.validate()?; + match &value.value { + dynwinrt::win32::Value::Pointer(pointer) => Ok(BigInt::from(*pointer as usize as u64)), + dynwinrt::win32::Value::AggregatePointer(buffer) => { + Ok(BigInt::from(buffer.pointer() as usize as u64)) + } + dynwinrt::win32::Value::Null => Ok(BigInt::from(0u64)), + _ => Err(napi::Error::from_reason( + "DynWin32Unsafe.pointerAddress(): value is not a data pointer", + )), + } + } +} + +fn bind_function(spec: DynWin32FunctionSpec) -> napi::Result { + let mut parameter_aggregates = Vec::with_capacity(spec.parameters.len()); + let mut parameter_pointees = Vec::with_capacity(spec.parameters.len()); + let parameters = spec + .parameters + .into_iter() + .map(|parameter| { + let aggregate = parameter + .aggregate_descriptor + .as_deref() + .map(native_aggregate_call_layout) + .transpose()?; + let pointee = parameter + .pointee_descriptor + .as_deref() + .map(native_aggregate_pointer_layout) + .transpose()?; + let typ = if aggregate.is_some() { + dynwinrt::win32::Type::Pointer + } else { + parse_type(¶meter.typ)? + }; + parameter_aggregates.push(aggregate); + parameter_pointees.push(pointee); + Ok(dynwinrt::win32::Parameter { + typ, + direction: parse_direction(¶meter.direction)?, + nullable: parameter.nullable.unwrap_or(false), + cleanup: parse_cleanup(parameter.cleanup.as_deref().unwrap_or("none"))?, + consumes_resource: parameter.consumes_resource.unwrap_or(false), + resource_cleanup: parse_cleanup(parameter.resource_cleanup.as_deref().unwrap_or("none"))?, + }) + }) + .collect::>>()?; + let return_aggregate = spec + .return_aggregate_descriptor + .as_deref() + .map(native_aggregate_call_layout) + .transpose()?; + let return_type = spec + .return_type + .as_deref() + .filter(|value| !value.eq_ignore_ascii_case("void")) + .map(parse_type) + .transpose()? + .filter(|_| return_aggregate.is_none()); + let plan = unsafe { + dynwinrt::win32::CallPlan::new_with_described_pointees( + dynwinrt::win32::CallPlanSpec { + dll: spec.dll, + entry_point: spec.entry_point, + parameters, + return_type, + return_cleanup: parse_cleanup(spec.return_cleanup.as_deref().unwrap_or("none"))?, + success_rule: parse_success_rule(spec.success_rule.as_deref().unwrap_or("always"))?, + capture_last_error: spec.capture_last_error.unwrap_or(false), + calling_convention: parse_calling_convention( + spec.calling_convention.as_deref().unwrap_or("system"), + )?, + parameter_aggregates, + return_aggregate, + }, + spec.call_contract_descriptor.as_deref(), + parameter_pointees, + ) + } + .map_err(|error| napi::Error::from_reason(error.message()))?; + Ok(DynWin32Function(plan)) +} + +fn parse_type(value: &str) -> napi::Result { + use dynwinrt::win32::Type; + match value.to_ascii_lowercase().as_str() { + "bool32" | "bool" => Ok(Type::Bool32), + "i8" => Ok(Type::I8), + "u8" => Ok(Type::U8), + "i16" => Ok(Type::I16), + "u16" | "char16" => Ok(Type::U16), + "i32" => Ok(Type::I32), + "u32" => Ok(Type::U32), + "i64" => Ok(Type::I64), + "u64" => Ok(Type::U64), + "f32" => Ok(Type::F32), + "f64" => Ok(Type::F64), + "pointer" | "ptr" => Ok(Type::Pointer), + "functionpointer" | "function_pointer" => Ok(Type::FunctionPointer), + "handle" => Ok(Type::Handle), + _ => Err(napi::Error::from_reason(format!( + "Unsupported flat Win32 ABI type `{value}`" + ))), + } +} + +fn parse_direction(value: &str) -> napi::Result { + use dynwinrt::win32::Direction; + match value.to_ascii_lowercase().as_str() { + "in" => Ok(Direction::In), + "out" => Ok(Direction::Out), + "inout" | "in_out" | "in,out" => Ok(Direction::InOut), + _ => Err(napi::Error::from_reason(format!( + "Unsupported flat Win32 parameter direction `{value}`" + ))), + } +} + +fn parse_cleanup(value: &str) -> napi::Result { + use dynwinrt::win32::Cleanup; + match value.to_ascii_lowercase().as_str() { + "none" => Ok(Cleanup::None), + "closehandle" => Ok(Cleanup::CloseHandle), + "regclosekey" => Ok(Cleanup::RegCloseKey), + "localfree" => Ok(Cleanup::LocalFree), + "globalfree" => Ok(Cleanup::GlobalFree), + "freelibrary" => Ok(Cleanup::FreeLibrary), + "closeservicehandle" => Ok(Cleanup::CloseServiceHandle), + "cotaskmemfree" => Ok(Cleanup::CoTaskMemFree), + "credfree" => Ok(Cleanup::CredFree), + _ => Err(napi::Error::from_reason(format!( + "Unsupported flat Win32 cleanup `{value}`" + ))), + } +} + +fn parse_success_rule(value: &str) -> napi::Result { + use dynwinrt::win32::SuccessRule; + match value.to_ascii_lowercase().as_str() { + "always" => Ok(SuccessRule::Always), + "zero" | "returnzero" => Ok(SuccessRule::ReturnZero), + "nonzero" | "returnnonzero" => Ok(SuccessRule::ReturnNonZero), + "nonnull" | "returnnonnull" => Ok(SuccessRule::ReturnNonNull), + "hresult" | "hresultsucceeded" => Ok(SuccessRule::HResultSucceeded), + "signednonnegative" | "nonnegative" => Ok(SuccessRule::SignedNonNegative), + "validhandle" | "returnvalidhandle" => Ok(SuccessRule::ReturnValidHandle), + _ => Err(napi::Error::from_reason(format!( + "Unsupported flat Win32 success rule `{value}`" + ))), + } +} + +fn parse_calling_convention(value: &str) -> napi::Result { + use dynwinrt::win32::CallingConvention; + match value.to_ascii_lowercase().as_str() { + "system" | "winapi" => Ok(CallingConvention::System), + "cdecl" | "c" => Ok(CallingConvention::Cdecl), + _ => Err(napi::Error::from_reason(format!( + "Unsupported flat Win32 calling convention `{value}`" + ))), + } +} + +fn pointer_value(owner: DynWinRTValue) -> napi::Result { + let value = match owner.0 { + dynwinrt::WinRTValue::RawPtr(value) => dynwinrt::win32::Value::Pointer(value), + dynwinrt::WinRTValue::Null => dynwinrt::win32::Value::Null, + _ => { + return Err(napi::Error::from_reason( + "native pointer helper did not produce a pointer value", + )); + } + }; + Ok(DynWin32Value::with_pointer_owner(value, owner)) +} + +fn string_value(owner: DynWinRTValue, wide: bool, multi: bool) -> napi::Result { + let mut value = pointer_value(owner)?; + if let Some(Win32PointerOwner::Native(owner)) = &mut value.pointer_owner { + Arc::get_mut(owner) + .expect("new string owner is unique") + .string = Some((wide, multi)); + } + Ok(value) +} + +fn string_pointer_pointer( + value: Unknown, + nullable: bool, + wide: bool, +) -> napi::Result { + let env = value.value().env; + let raw = value.value().value; + let mut value_type = napi::sys::ValueType::napi_undefined; + unsafe { napi::sys::napi_typeof(env, raw, &mut value_type) }; + if matches!( + value_type, + napi::sys::ValueType::napi_null | napi::sys::ValueType::napi_undefined + ) { + return if nullable { + Ok(DynWin32Value::new(dynwinrt::win32::Value::Null)) + } else { + Err(napi::Error::from_reason( + "string pointer slot null requires an explicitly nullable parameter", + )) + }; + } + let inner = storage::string_pointer(value, false, wide, false)?; + let pointer = match &inner.0 { + dynwinrt::WinRTValue::RawPtr(pointer) => *pointer as usize, + _ => { + return Err(napi::Error::from_reason( + "string pointer helper did not produce native storage", + )); + } + }; + let mut slot = Box::new(pointer); + let slot_pointer = (&mut *slot as *mut usize).cast(); + Ok(DynWin32Value { + value: dynwinrt::win32::Value::Pointer(slot_pointer), + pointer_owner: Some(Win32PointerOwner::PointerSlot { + inner: Arc::new(RetainedNativePointer { + value: inner, + string: Some((wide, false)), + }), + slot, + }), + }) +} + +fn check_integer(value: f64, minimum: f64, maximum: f64, name: &str) -> napi::Result<()> { + if !value.is_finite() || value.fract() != 0.0 || !(minimum..=maximum).contains(&value) { + return Err(napi::Error::from_reason(format!( + "DynWin32.{name}(): value is outside the exact integer range" + ))); + } + Ok(()) +} + +fn handle_value(value: Unknown, nullable: bool) -> napi::Result { + use napi::sys; + + let env = value.value().env; + let raw = value.value().value; + if let Ok(resource) = unsafe { <&DynWin32Resource>::from_napi_value(env, raw) } { + if resource.0.is_closed() { + return Err(napi::Error::from_reason( + "Cannot use a closed flat Win32 resource", + )); + } + + return Ok(DynWin32Value::new(dynwinrt::win32::Value::Resource( + Arc::clone(&resource.0), + ))); + } + + let mut value_type = sys::ValueType::napi_undefined; + unsafe { sys::napi_typeof(env, raw, &mut value_type) }; + if matches!( + value_type, + sys::ValueType::napi_null | sys::ValueType::napi_undefined + ) { + return if nullable { + Ok(DynWin32Value::new(dynwinrt::win32::Value::Null)) + } else { + Err(napi::Error::from_reason( + "DynWin32.handle(): null requires an explicitly nullable handle parameter", + )) + }; + } + let bits = if value_type == sys::ValueType::napi_bigint { + if let Ok(signed) = storage::signed64(&value) { + if signed as isize as i64 != signed { + return Err(napi::Error::from_reason( + "DynWin32.handle(): value does not fit this process pointer width", + )); + } + signed as isize as usize as u64 + } else { + storage::unsigned64(&value)? + } + } else if value_type == sys::ValueType::napi_number { + let mut number = 0.0; + unsafe { sys::napi_get_value_double(env, raw, &mut number) }; + if !number.is_finite() || number.fract() != 0.0 || number.abs() > 9_007_199_254_740_991.0 { + return Err(napi::Error::from_reason( + "DynWin32.handle(): number must be a safe integer", + )); + } + if number < 0.0 { + let signed = number as i64; + if signed as isize as i64 != signed { + return Err(napi::Error::from_reason( + "DynWin32.handle(): value does not fit this process pointer width", + )); + } + signed as isize as usize as u64 + } else { + number as u64 + } + } else { + return Err(napi::Error::from_reason( + "DynWin32.handle(): expected bigint, number, or DynWin32Resource", + )); + }; + if bits as usize as u64 != bits { + return Err(napi::Error::from_reason( + "DynWin32.handle(): value does not fit this process pointer width", + )); + } + Ok(DynWin32Value::new(dynwinrt::win32::Value::Handle( + bits as usize, + ))) +} + +#[cfg(test)] +#[path = "win32_outcome_tests.rs"] +mod outcome_tests; + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn discarded_results_have_no_delivered_resource_without_relaxing_invalid_types() { + let discarded = DynWin32Value::new(dynwinrt::win32::Value::Discarded); + assert!(DynWin32::is_unavailable(&discarded)); + assert!(DynWin32::to_resource(&discarded).unwrap().is_none()); + assert!(DynWin32::to_resource_or_handle(&discarded) + .unwrap() + .is_none()); + + let unavailable = DynWin32Value::new(dynwinrt::win32::Value::Unavailable); + assert!(DynWin32::is_unavailable(&unavailable)); + assert!(DynWin32::to_resource(&unavailable).is_err()); + assert!(DynWin32::to_resource_or_handle(&unavailable).is_err()); + let invalid = DynWin32Value::new(dynwinrt::win32::Value::I32(0)); + assert!(!DynWin32::is_unavailable(&invalid)); + assert!(DynWin32::to_resource(&invalid).is_err()); + assert!(DynWin32::to_resource_or_handle(&invalid).is_err()); + } +} diff --git a/bindings/js/src/win32_boundary.rs b/bindings/js/src/win32_boundary.rs new file mode 100644 index 00000000..f1e32ef1 --- /dev/null +++ b/bindings/js/src/win32_boundary.rs @@ -0,0 +1,435 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Every opaque Win32 carrier checks a native type tag before typed unwrapping. +//! napi-rs class casts only test JavaScript prototypes, which are mutable. + +use std::{cell::RefCell, collections::HashMap, ffi::c_void, ptr, sync::OnceLock}; + +use napi::{ + bindgen_prelude::{BigInt, Buffer, FromNapiValue, Function, Unknown}, + sys, Env, JsValue, +}; +use napi_derive::napi; + +use super::{ + DynWin32CallResult, DynWin32Function, DynWin32NativeStruct, DynWin32OverlappedOperation, + DynWin32Resource, DynWin32SubsystemContext, DynWin32Value, DynWinRTValue, +}; + +thread_local! { + static COM_RECEIVER_GUARDS: RefCell>> = RefCell::new(HashMap::new()); +} + +#[napi(module_exports, skip_typescript)] +fn capture_com_receiver_guard(env: Env) -> napi::Result<()> { + let constructor = napi::bindgen_prelude::get_class_constructor("DynWinRtValue\0") + .ok_or_else(|| napi::Error::from_reason("Managed COM carrier constructor is unavailable"))?; + let mut class = ptr::null_mut(); + napi::check_status!(unsafe { + sys::napi_get_reference_value(env.raw(), constructor, &mut class) + })?; + let mut prototype = ptr::null_mut(); + let mut method = ptr::null_mut(); + napi::check_status!(unsafe { + sys::napi_get_named_property(env.raw(), class, c"prototype".as_ptr(), &mut prototype) + })?; + napi::check_status!(unsafe { + sys::napi_get_named_property(env.raw(), prototype, c"isNull".as_ptr(), &mut method) + })?; + let mut reference = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_create_reference(env.raw(), method, 1, &mut reference) })?; + let key = env.raw() as usize; + let result = (|| { + if COM_RECEIVER_GUARDS.with(|guards| !guards.borrow().contains_key(&key)) { + let _hook = env.add_env_cleanup_hook(key, |key| { + if let Some(references) = + COM_RECEIVER_GUARDS.with(|guards| guards.borrow_mut().remove(&key)) + { + for reference in references { + let _ = unsafe { sys::napi_delete_reference(key as sys::napi_env, reference) }; + } + } + })?; + } + COM_RECEIVER_GUARDS.with(|guards| { + let mut guards = guards.borrow_mut(); + let references = guards.entry(key).or_default(); + references + .try_reserve_exact(1) + .map_err(|_| napi::Error::from_reason("Unable to retain native COM carrier validation"))?; + references.push(reference); + Ok(()) + }) + })(); + if result.is_err() { + let _ = unsafe { sys::napi_delete_reference(env.raw(), reference) }; + } + result +} + +pub(super) fn managed_com_value<'a>(value: &'a Unknown) -> napi::Result<&'a DynWinRTValue> { + let env = value.value().env; + let raw = value.raw(); + // Node's original napi_define_class method enforces its native receiver + // signature. Unlike instanceof, this rejects another wrapped Rust type even + // after prototype spoofing. Retain the method before exports are published so + // replacing the public prototype cannot replace this validation. + let references = COM_RECEIVER_GUARDS + .with(|guards| guards.borrow().get(&(env as usize)).cloned()) + .ok_or_else(|| napi::Error::from_reason("Native COM carrier validation is unavailable"))?; + for reference in references { + let mut method = ptr::null_mut(); + let mut result = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_get_reference_value(env, reference, &mut method) })?; + let status = unsafe { sys::napi_call_function(env, raw, method, 0, ptr::null(), &mut result) }; + if status == sys::Status::napi_pending_exception { + let mut exception = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_get_and_clear_last_exception(env, &mut exception) })?; + continue; + } + napi::check_status!(status)?; + let mut is_null = false; + napi::check_status!(unsafe { sys::napi_get_value_bool(env, result, &mut is_null) })?; + return unsafe { <&DynWinRTValue>::from_napi_value(env, raw) }; + } + Err(napi::Error::from_reason( + "DynWin32.comObject(): expected a native managed COM carrier", + )) +} + +#[repr(C)] +struct TypeTag { + lower: u64, + upper: u64, +} + +type TagObject = + unsafe extern "C" fn(sys::napi_env, sys::napi_value, *const TypeTag) -> sys::napi_status; +type CheckTag = unsafe extern "C" fn( + sys::napi_env, + sys::napi_value, + *const TypeTag, + *mut bool, +) -> sys::napi_status; + +struct TagApi { + tag: TagObject, + check: CheckTag, +} + +fn tags() -> napi::Result<&'static TagApi> { + static API: OnceLock> = OnceLock::new(); + API + .get_or_init(|| { + use windows::core::PCSTR; + use windows::Win32::System::LibraryLoader::{GetModuleHandleW, GetProcAddress}; + let host = unsafe { GetModuleHandleW(None) }.map_err(|error| error.to_string())?; + let tag = unsafe { GetProcAddress(host, PCSTR(c"napi_type_tag_object".as_ptr().cast())) } + .ok_or("Win32 carriers require N-API 8 type tags")?; + let check = + unsafe { GetProcAddress(host, PCSTR(c"napi_check_object_type_tag".as_ptr().cast())) } + .ok_or("Win32 carriers require N-API 8 type tags")?; + Ok(TagApi { + tag: unsafe { std::mem::transmute:: isize, TagObject>(tag) }, + check: unsafe { + std::mem::transmute:: isize, CheckTag>(check) + }, + }) + }) + .as_ref() + .map_err(|reason| napi::Error::from_reason(reason.clone())) +} + +fn tag(kind: u32) -> TypeTag { + static MODULE_BRAND: u8 = 0; + TypeTag { + lower: 0x8485_314d_f6a9_0e67 ^ u64::from(kind), + // Separate addon copies must not unwrap one another's Rust layouts/state. + upper: 0x397a_626b_dd58_45cb ^ std::ptr::addr_of!(MODULE_BRAND) as usize as u64, + } +} + +pub(crate) trait Carrier: Sized + 'static { + const KIND: u32; + const NAME: &'static str; +} + +unsafe extern "C" fn finalize(_: sys::napi_env, data: *mut c_void, _: *mut c_void) { + drop(unsafe { Box::from_raw(data.cast::()) }); +} + +pub(crate) unsafe fn wrap( + env: sys::napi_env, + value: T, +) -> napi::Result { + let api = tags()?; + let mut object = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_create_object(env, &mut object) })?; + let mut value = Box::new(value); + napi::check_status!(unsafe { + sys::napi_wrap( + env, + object, + (&mut *value as *mut T).cast(), + Some(finalize::), + ptr::null_mut(), + ptr::null_mut(), + ) + })?; + // The registered finalizer owns the value even if tagging or JS projection fails. + let _ = Box::into_raw(value); + napi::check_status!(unsafe { (api.tag)(env, object, &tag(T::KIND)) })?; + Ok(object) +} + +unsafe fn has_tag(env: sys::napi_env, raw: sys::napi_value, kind: u32) -> napi::Result { + let mut typ = sys::ValueType::napi_undefined; + napi::check_status!(unsafe { sys::napi_typeof(env, raw, &mut typ) })?; + if typ != sys::ValueType::napi_object { + return Ok(false); + } + let mut matches = false; + napi::check_status!(unsafe { (tags()?.check)(env, raw, &tag(kind), &mut matches) })?; + Ok(matches) +} + +pub(crate) unsafe fn unwrap( + env: sys::napi_env, + raw: sys::napi_value, +) -> napi::Result<*mut T> { + if !unsafe { has_tag(env, raw, T::KIND) }? { + return Err(napi::Error::from_reason(format!( + "Expected a native {} carrier", + T::NAME + ))); + } + let mut pointer = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_unwrap(env, raw, &mut pointer) })?; + if pointer.is_null() { + return Err(napi::Error::from_reason( + "Missing native Win32 carrier state", + )); + } + Ok(pointer.cast()) +} + +macro_rules! carrier { + ($typ:ty, $kind:expr, $name:literal) => { + impl $crate::win32::boundary::Carrier for $typ { + const KIND: u32 = $kind; + const NAME: &'static str = $name; + } + impl napi::bindgen_prelude::TypeName for $typ { + fn type_name() -> &'static str { + $name + } + fn value_type() -> napi::ValueType { + napi::ValueType::Object + } + } + impl napi::bindgen_prelude::TypeName for &$typ { + fn type_name() -> &'static str { + $name + } + fn value_type() -> napi::ValueType { + napi::ValueType::Object + } + } + impl napi::bindgen_prelude::TypeName for &mut $typ { + fn type_name() -> &'static str { + $name + } + fn value_type() -> napi::ValueType { + napi::ValueType::Object + } + } + impl napi::bindgen_prelude::ToNapiValue for $typ { + unsafe fn to_napi_value( + env: napi::sys::napi_env, + value: Self, + ) -> napi::Result { + unsafe { $crate::win32::boundary::wrap(env, value) } + } + } + impl napi::bindgen_prelude::FromNapiRef for $typ { + unsafe fn from_napi_ref( + env: napi::sys::napi_env, + value: napi::sys::napi_value, + ) -> napi::Result<&'static Self> { + Ok(unsafe { &*$crate::win32::boundary::unwrap::(env, value)? }) + } + } + impl napi::bindgen_prelude::FromNapiMutRef for $typ { + unsafe fn from_napi_mut_ref( + env: napi::sys::napi_env, + value: napi::sys::napi_value, + ) -> napi::Result<&'static mut Self> { + Ok(unsafe { &mut *$crate::win32::boundary::unwrap::(env, value)? }) + } + } + impl napi::bindgen_prelude::ValidateNapiValue for &$typ { + unsafe fn validate( + env: napi::sys::napi_env, + value: napi::sys::napi_value, + ) -> napi::Result { + unsafe { $crate::win32::boundary::unwrap::<$typ>(env, value)? }; + Ok(std::ptr::null_mut()) + } + } + impl napi::bindgen_prelude::ValidateNapiValue for &mut $typ { + unsafe fn validate( + env: napi::sys::napi_env, + value: napi::sys::napi_value, + ) -> napi::Result { + unsafe { $crate::win32::boundary::unwrap::<$typ>(env, value)? }; + Ok(std::ptr::null_mut()) + } + } + }; +} +pub(crate) use carrier; + +#[napi] +pub fn win32_carrier_kind(value: Unknown) -> napi::Result { + for kind in 1..=7 { + if unsafe { has_tag(value.value().env, value.raw(), kind) }? { + return Ok(kind); + } + } + Ok(0) +} + +pub(super) fn has_carrier(env: sys::napi_env, raw: sys::napi_value) -> napi::Result { + for kind in 1..=7 { + if unsafe { has_tag(env, raw, kind) }? { + return Ok(true); + } + } + Ok(false) +} + +#[napi] +pub fn win32_native_struct_bytes(value: &DynWin32NativeStruct) -> napi::Result { + value.bytes() +} + +#[napi] +pub fn win32_native_struct_length(value: &DynWin32NativeStruct) -> u32 { + value.length() +} + +#[napi] +pub fn win32_resource_value(value: &DynWin32Resource) -> BigInt { + value.value() +} + +#[napi] +pub fn win32_resource_closed(value: &DynWin32Resource) -> bool { + value.closed() +} + +#[napi] +pub fn win32_resource_busy(value: &DynWin32Resource) -> bool { + value.busy() +} + +#[napi] +pub fn win32_resource_active(value: &DynWin32Resource) -> bool { + value.active() +} + +#[napi] +pub fn win32_resource_close(value: &DynWin32Resource) -> napi::Result<()> { + value.close() +} + +#[napi] +pub fn win32_bind( + #[napi(ts_arg_type = "DynWin32FunctionSpec")] spec: Unknown, +) -> napi::Result { + DynWin32Function::bind(super::specification::function_spec(spec)?) +} + +#[napi] +pub fn win32_function_dll(value: &DynWin32Function) -> String { + value.dll() +} + +#[napi] +pub fn win32_function_entry_point(value: &DynWin32Function) -> String { + value.entry_point() +} + +#[napi] +pub fn win32_invoke( + value: &DynWin32Function, + #[napi(ts_arg_type = "DynWin32Value[]")] args: Unknown, +) -> napi::Result { + value.invoke(super::specification::arguments(&args)?) +} + +#[napi] +pub fn win32_invoke_with_subsystem( + value: &DynWin32Function, + context: &DynWin32SubsystemContext, + #[napi(ts_arg_type = "string")] subsystem: super::specification::Name, + #[napi(ts_arg_type = "DynWin32Value[]")] args: Unknown, +) -> napi::Result { + value.invoke_with_subsystem( + context, + subsystem.into_string(), + super::specification::arguments(&args)?, + ) +} + +#[napi] +pub fn win32_result_return_value( + value: &mut DynWin32CallResult, +) -> napi::Result> { + value.return_value() +} + +#[napi] +pub fn win32_result_outputs(value: &mut DynWin32CallResult) -> napi::Result> { + value.outputs() +} + +#[napi] +pub fn win32_result_last_error(value: &DynWin32CallResult) -> Option { + value.last_error() +} + +#[napi] +pub fn win32_result_succeeded(value: &DynWin32CallResult) -> bool { + value.succeeded() +} + +#[napi] +pub fn win32_subsystem_name(value: &DynWin32SubsystemContext) -> &'static str { + value.subsystem() +} + +#[napi] +pub fn win32_subsystem_closed(value: &DynWin32SubsystemContext) -> bool { + value.closed() +} + +#[napi] +pub fn win32_subsystem_close(value: &DynWin32SubsystemContext) -> napi::Result<()> { + value.close() +} + +#[napi] +pub fn win32_overlapped_cancel(value: &DynWin32OverlappedOperation) { + value.cancel() +} + +#[napi] +pub fn win32_overlapped_start( + value: &mut DynWin32OverlappedOperation, + #[napi(ts_arg_type = "(error: Error | null, bytesTransferred?: number) => void")] + callback: Function<'static, (), ()>, +) -> napi::Result<()> { + value.start(callback) +} diff --git a/bindings/js/src/win32_io.rs b/bindings/js/src/win32_io.rs new file mode 100644 index 00000000..dc815e43 --- /dev/null +++ b/bindings/js/src/win32_io.rs @@ -0,0 +1,395 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Node-thread delivery for the native Win32 I/O engine. One adapter-owned +//! relay consumes native records; its TSFN registrations never enter the core +//! channel or operations. Only the owner thread retains and touches JS Buffers. + +use std::{ + cell::RefCell, + collections::HashMap, + marker::PhantomData, + rc::Rc, + sync::{ + atomic::{AtomicU64, Ordering}, + mpsc::{channel, Sender}, + Arc, LazyLock, Mutex, + }, +}; + +use dynwinrt::win32::io::{IoCancellation, IoCompletion, IoKind, IocpRuntime, PreparedIo}; +use napi::{ + bindgen_prelude::{Buffer, Function, ToNapiValue, Unknown}, + sys, JsValue, +}; + +use super::{boundary, storage, DynWin32Resource}; +use crate::managed_tsfn::ManagedTsfn; + +static NEXT_PENDING_ID: AtomicU64 = AtomicU64::new(1); +static COMPLETIONS: LazyLock> = LazyLock::new(CompletionRelay::new); + +struct CompletionRelay { + sender: Sender, + notifications: Arc>>>, +} + +impl CompletionRelay { + fn shared() -> napi::Result<&'static Self> { + COMPLETIONS + .as_ref() + .map_err(|error| napi::Error::from_reason(error.clone())) + } + + fn new() -> Result { + use windows::Win32::Foundation::HMODULE; + use windows::Win32::System::LibraryLoader::{ + GetModuleHandleExW, GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, GET_MODULE_HANDLE_EX_FLAG_PIN, + }; + + // The shared relay, like the core IOCP workers, can outlive a Node env. + let mut module = HMODULE::default(); + unsafe { + GetModuleHandleExW( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, + windows::core::PCWSTR(Self::new as *const () as *const u16), + &mut module, + ) + } + .map_err(|error| format!("Cannot pin the OVERLAPPED completion relay module: {error}"))?; + + let (sender, receiver) = channel::(); + let notifications = Arc::new(Mutex::new(HashMap::>::new())); + let registrations = Arc::clone(¬ifications); + std::thread::Builder::new() + .name("dynwinrt-win32-io-relay".into()) + .spawn(move || { + while let Ok(native) = receiver.recv() { + let token = native.token(); + let notification = registrations + .lock() + .unwrap_or_else(|error| error.into_inner()) + .remove(&token); + let Some(notification) = notification else { + // Environment teardown removed the adapter registration. This + // record is terminal and dropping it cannot touch a JS Buffer. + drop(native); + continue; + }; + let status = notification.call(native); + if !matches!(status, napi::Status::Ok | napi::Status::Closing) { + eprintln!("[dynwinrt] OVERLAPPED completion {token} notification failed: {status}"); + } + // Failed notifications retire native storage in ManagedTsfn::call; + // releasing the handle schedules owner-thread pending-state cleanup. + } + }) + .map_err(|error| format!("Failed to create OVERLAPPED completion relay: {error}"))?; + Ok(Self { + sender, + notifications, + }) + } + + fn register(&self, token: u64, notification: ManagedTsfn) -> napi::Result<()> { + let mut registrations = self + .notifications + .lock() + .unwrap_or_else(|error| error.into_inner()); + if registrations.contains_key(&token) { + return Err(napi::Error::from_reason( + "Duplicate OVERLAPPED completion registration", + )); + } + registrations + .try_reserve(1) + .map_err(|_| napi::Error::from_reason("Unable to retain OVERLAPPED notification state"))?; + registrations.insert(token, notification); + Ok(()) + } + + fn unregister(&self, token: u64) -> Option> { + self + .notifications + .lock() + .unwrap_or_else(|error| error.into_inner()) + .remove(&token) + } +} + +thread_local! { + static PENDING: RefCell> = RefCell::new(HashMap::new()); +} + +struct JsPendingIo { + buffer: Buffer, + buffer_len: usize, + buffer_pointer: usize, + env: usize, + _owner_thread: PhantomData>, +} + +struct JsPreparedIo { + native: PreparedIo, + pending: JsPendingIo, +} + +pub struct DynWin32OverlappedOperation { + task: Option, + cancellation: IoCancellation, +} + +boundary::carrier!( + DynWin32OverlappedOperation, + 7, + "DynWin32OverlappedOperation" +); + +impl DynWin32OverlappedOperation { + pub fn cancel(&self) { + self.cancellation.cancel(); + } + + pub fn start(&mut self, callback: Function<'static, (), ()>) -> napi::Result<()> { + let task = self + .task + .take() + .ok_or_else(|| napi::Error::from_reason("OVERLAPPED operation was already started"))?; + let env = callback.value().env; + if task.pending.env != env as usize { + return Err(napi::Error::from_reason( + "OVERLAPPED operation belongs to a different Node environment", + )); + } + let id = NEXT_PENDING_ID + .fetch_update(Ordering::Relaxed, Ordering::Relaxed, |next| { + next.checked_add(1) + }) + .map_err(|_| napi::Error::from_reason("OVERLAPPED delivery identifiers were exhausted"))?; + let relay = CompletionRelay::shared()?; + let closing = self.cancellation.clone(); + let completion = ManagedTsfn::create( + env, + callback.raw(), + 1, + false, + completion_arguments, + Some(Box::new(move |_| { + // ManagedTsfn aborts on environment teardown even while the relay map + // holds a registration. Unregister before cancelling OS-owned work. + drop(relay.unregister(id)); + closing.cancel(); + // This finalizer runs on the owning environment thread. In particular, + // an IOCP worker never drops a Buffer or touches its backing store. + drop(take_pending(id)); + })), + )?; + PENDING.with(|pending| { + let mut pending = pending.borrow_mut(); + pending + .try_reserve(1) + .map_err(|_| napi::Error::from_reason("Unable to retain OVERLAPPED delivery state"))?; + pending.insert(id, task.pending); + Ok::<_, napi::Error>(()) + })?; + if let Err(error) = relay.register(id, completion) { + drop(take_pending(id)); + return Err(error); + } + let result = task.native.submit(id, relay.sender.clone()); + if let Err(error) = result { + drop(relay.unregister(id)); + drop(take_pending(id)); + return Err(napi::Error::from_reason(error.to_string())); + } + Ok(()) + } +} + +pub(super) fn prepare( + kind: IoKind, + file: &DynWin32Resource, + buffer: Unknown, + offset: Option, +) -> napi::Result { + let env = buffer.value().env as usize; + let buffer = storage::native_buffer(buffer)?; + let offset = offset + .as_ref() + .map(storage::unsigned64) + .transpose()? + .unwrap_or(0); + let runtime = + IocpRuntime::shared().map_err(|error| napi::Error::from_reason(error.to_string()))?; + let native = match kind { + IoKind::Read => runtime.prepare_read(&file.0, buffer.len(), offset), + IoKind::Write => runtime.prepare_write(&file.0, &buffer, offset), + } + .map_err(|error| napi::Error::from_reason(error.to_string()))?; + let cancellation = native.cancellation(); + Ok(DynWin32OverlappedOperation { + task: Some(JsPreparedIo { + native, + pending: JsPendingIo { + buffer_len: buffer.len(), + buffer_pointer: buffer.as_ptr() as usize, + buffer, + env, + _owner_thread: PhantomData, + }, + }), + cancellation, + }) +} + +fn take_pending(id: u64) -> Option { + PENDING.with(|pending| pending.borrow_mut().remove(&id)) +} + +impl JsPendingIo { + fn resolve( + self, + kind: IoKind, + native: &[u8], + env: sys::napi_env, + output: u32, + ) -> napi::Result { + if self.env != env as usize { + return Err(napi::Error::from_reason( + "OVERLAPPED result belongs to a different Node environment", + )); + } + let transferred = usize::try_from(output) + .map_err(|_| napi::Error::from_reason("OVERLAPPED result exceeds usize"))?; + if transferred > self.buffer_len || transferred > native.len() { + return Err(napi::Error::from_reason( + "OVERLAPPED result exceeds the original Buffer length", + )); + } + if kind == IoKind::Read { + let raw = unsafe { Buffer::to_napi_value(env, self.buffer) }?; + let mut is_buffer = false; + napi::check_status!( + unsafe { sys::napi_is_buffer(env, raw, &mut is_buffer) }, + "Failed to revalidate OVERLAPPED read Buffer" + )?; + if !is_buffer { + return Err(napi::Error::from_reason( + "OVERLAPPED read Buffer is no longer a Node Buffer", + )); + } + let info = storage::buffer_info(env, raw).map_err(|error| { + napi::Error::new( + error.status, + format!( + "OVERLAPPED read Buffer backing ArrayBuffer was detached or changed: {}", + error.reason + ), + ) + })?; + if info.length != self.buffer_len + || (info.length != 0 && info.pointer as usize != self.buffer_pointer) + { + return Err(napi::Error::from_reason( + "OVERLAPPED read Buffer backing ArrayBuffer was detached or changed", + )); + } + if transferred != 0 { + unsafe { + std::ptr::copy_nonoverlapping(native.as_ptr(), info.pointer, transferred); + } + } + } + Ok(output) + } +} + +fn completion_arguments( + native: IoCompletion, + env: sys::napi_env, +) -> napi::Result> { + let result = (|| { + let pending = take_pending(native.token()) + .ok_or_else(|| napi::Error::from_reason("OVERLAPPED delivery state is unavailable"))?; + let output = native + .result() + .map_err(|error| napi::Error::from_reason(error.to_string()))?; + pending.resolve(native.kind(), native.buffer(), env, output) + })(); + match result { + Ok(output) => { + let mut null = std::ptr::null_mut(); + napi::check_status!( + unsafe { sys::napi_get_null(env, &mut null) }, + "Failed to create OVERLAPPED completion null" + )?; + let output = unsafe { u32::to_napi_value(env, output) }?; + Ok(vec![null, output]) + } + + Err(error) => { + let mut message = std::ptr::null_mut(); + napi::check_status!( + unsafe { + sys::napi_create_string_utf8( + env, + error.reason.as_ptr().cast(), + error.reason.len() as isize, + &mut message, + ) + }, + "Failed to create OVERLAPPED completion error message" + )?; + let mut error = std::ptr::null_mut(); + napi::check_status!( + unsafe { sys::napi_create_error(env, std::ptr::null_mut(), message, &mut error) }, + "Failed to create OVERLAPPED completion error" + )?; + Ok(vec![error]) + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn pending() -> JsPendingIo { + let buffer = Buffer::from(vec![1, 2, 3]); + JsPendingIo { + buffer_len: buffer.len(), + buffer_pointer: buffer.as_ptr() as usize, + buffer, + env: 0, + _owner_thread: PhantomData, + } + } + + #[test] + fn completed_write_and_invalid_lengths_retire_without_native_buffer_access() { + assert_eq!( + pending() + .resolve(IoKind::Write, &[1, 2, 3], std::ptr::null_mut(), 2) + .unwrap(), + 2 + ); + for kind in [IoKind::Read, IoKind::Write] { + assert!(pending() + .resolve(kind, &[1, 2, 3], std::ptr::null_mut(), 4) + .unwrap_err() + .reason + .contains("original Buffer")); + assert!(pending() + .resolve(kind, &[1], std::ptr::null_mut(), 2) + .is_err()); + } + } + + #[test] + fn owner_thread_pending_state_can_only_be_taken_once() { + let id = NEXT_PENDING_ID.fetch_add(1, Ordering::Relaxed); + PENDING.with(|entries| entries.borrow_mut().insert(id, pending())); + assert!(take_pending(id).is_some()); + assert!(take_pending(id).is_none()); + } +} diff --git a/bindings/js/src/win32_outcome_tests.rs b/bindings/js/src/win32_outcome_tests.rs new file mode 100644 index 00000000..ce1c4c0e --- /dev/null +++ b/bindings/js/src/win32_outcome_tests.rs @@ -0,0 +1,334 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use std::{ffi::c_void, sync::atomic::AtomicU64}; +use windows::core::HSTRING; +use windows::Win32::Foundation::{ + CloseHandle, SetHandleInformation, HANDLE_FLAGS, HANDLE_FLAG_PROTECT_FROM_CLOSE, +}; +use windows::Win32::System::Threading::{CreateEventW, OpenEventW, SYNCHRONIZATION_SYNCHRONIZE}; + +struct Event { + handle: HANDLE, + name: HSTRING, +} + +impl Event { + fn new() -> Self { + static NEXT: AtomicU64 = AtomicU64::new(1); + let name = HSTRING::from(format!( + "Local\\dynwinrt-outcome-{}-{}", + std::process::id(), + NEXT.fetch_add(1, Ordering::Relaxed), + )); + let handle = unsafe { CreateEventW(None, true, false, &name) }.unwrap(); + Self { handle, name } + } + + fn take(&mut self) -> usize { + std::mem::replace(&mut self.handle, HANDLE::default()).0 as usize + } + + fn exists(&self) -> bool { + match unsafe { OpenEventW(SYNCHRONIZATION_SYNCHRONIZE, false, &self.name) } { + Ok(handle) => { + unsafe { CloseHandle(handle) }.unwrap(); + true + } + Err(error) => { + assert_eq!(error.code().0 as u32, 0x80070002); + false + } + } + } +} + +impl Drop for Event { + fn drop(&mut self) { + if !self.handle.is_invalid() { + let _ = unsafe { CloseHandle(self.handle) }; + } + } +} + +fn handle_storage() -> Arc { + let width = std::mem::size_of::(); + Arc::new( + NativeAggregateStorage::new( + "Tests.HandlePair".into(), + width * 2, + width, + None, + true, + vec![ + dynwinrt::win32::AggregateResultField { + name: "first".into(), + offset: 0, + typ: dynwinrt::win32::Type::Handle, + cleanup: dynwinrt::win32::Cleanup::CloseHandle, + }, + dynwinrt::win32::AggregateResultField { + name: "second".into(), + offset: width, + typ: dynwinrt::win32::Type::Handle, + cleanup: dynwinrt::win32::Cleanup::CloseHandle, + }, + ], + ) + .unwrap(), + ) +} + +fn write_handles(storage: &NativeAggregateStorage, first: usize, second: usize) { + #[repr(C)] + struct Pair { + first: HANDLE, + second: HANDLE, + } + unsafe extern "system" fn fill(output: *mut Pair, first: HANDLE, second: HANDLE) { + unsafe { output.write(Pair { first, second }) }; + } + unsafe { + fill( + storage.pointer().cast(), + HANDLE(first as *mut c_void), + HANDLE(second as *mut c_void), + ); + } +} + +#[test] +fn aggregate_success_gates_adoption_reuse_and_unclaimed_cleanup() { + let mut first = Event::new(); + let mut second = Event::new(); + let storage = handle_storage(); + assert!(storage.require_success().is_err()); + storage.prepare_call().unwrap(); + let (first_raw, second_raw) = (first.take(), second.take()); + write_handles(&storage, first_raw, second_raw); + // Event::take transferred both live handles into the aggregate fields. + unsafe { storage.mark_call_result(true) }.unwrap(); + storage.require_success().unwrap(); + assert!(storage.bytes().is_err()); + let taken = storage.backing.take_field(0).unwrap(); + let adopted = Arc::clone(taken.resource().unwrap()); + assert_eq!(adopted.raw(), first_raw); + assert!(matches!( + storage.backing.take_field(0).unwrap(), + dynwinrt::win32::Value::Handle(0) + )); + storage.prepare_call().unwrap(); + assert!(first.exists()); + assert!(!second.exists()); + assert!(storage.require_success().is_err()); + assert_eq!( + usize::from_ne_bytes(storage.read_field(std::mem::size_of::()).unwrap()), + 0 + ); + drop(storage); + assert!(first.exists()); + adopted.close().unwrap(); + adopted.close().unwrap(); + assert!(!first.exists()); + + let mut unclaimed = Event::new(); + let raw = unclaimed.take(); + let storage = handle_storage(); + write_handles(&storage, raw, 0); + // The event handle is exclusively owned by the aggregate; the other field is null. + unsafe { storage.mark_call_result(true) }.unwrap(); + drop(storage); + assert!(!unclaimed.exists()); +} + +#[test] +fn aggregate_failed_outputs_are_not_adopted_or_guessed_as_owned() { + let event = Event::new(); + let storage = handle_storage(); + write_handles(&storage, event.handle.0 as usize, 0); + unsafe { storage.mark_call_result(false) }.unwrap(); + assert!(storage.require_success().is_err()); + storage.prepare_call().unwrap(); + drop(storage); + assert!(event.exists()); +} + +struct UnprotectField(Arc); + +impl Drop for UnprotectField { + fn drop(&mut self) { + let raw = usize::from_ne_bytes(self.0.read_field(0).unwrap()); + if raw != 0 { + let _ = unsafe { + SetHandleInformation( + HANDLE(raw as *mut c_void), + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + HANDLE_FLAGS(0), + ) + }; + } + } +} + +#[test] +fn aggregate_cleanup_failure_retains_failed_field_but_cleans_other_fields() { + let mut protected = Event::new(); + let mut other = Event::new(); + let storage = handle_storage(); + let protection = UnprotectField(Arc::clone(&storage)); + unsafe { + SetHandleInformation( + protected.handle, + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + HANDLE_FLAG_PROTECT_FROM_CLOSE, + ) + } + .unwrap(); + let (raw, other_raw) = (protected.take(), other.take()); + write_handles(&storage, raw, other_raw); + // Event::take transferred the handles; protection affects cleanup, not ownership. + unsafe { storage.mark_call_result(true) }.unwrap(); + assert!(storage.prepare_call().is_err()); + assert!(protected.exists()); + assert!(!other.exists()); + assert_eq!(usize::from_ne_bytes(storage.read_field(0).unwrap()), raw); + assert_eq!( + usize::from_ne_bytes(storage.read_field(std::mem::size_of::()).unwrap()), + 0 + ); + unsafe { + SetHandleInformation( + HANDLE(raw as *mut c_void), + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + HANDLE_FLAGS(0), + ) + } + .unwrap(); + storage.prepare_call().unwrap(); + assert!(!protected.exists()); + drop(protection); +} + +fn owned_text(value: &[u16]) -> Arc { + let mut value = value.to_vec().into_boxed_slice(); + let pointer = value.as_mut_ptr().cast(); + Arc::new(RetainedNativePointer { + value: DynWinRTValue::with_pointer_owner( + dynwinrt::WinRTValue::RawPtr(pointer), + com::NativePointerOwner::WideString(value), + ), + string: Some((true, false)), + }) +} + +#[test] +fn aggregate_owner_replacement_and_failed_field_writes_are_atomic() { + let storage = + NativeAggregateStorage::new("Tests.Pointers".into(), 16, 8, None, true, Vec::new()).unwrap(); + let first = owned_text(&[65, 0]); + let first_weak = Arc::downgrade(&first); + let dynwinrt::WinRTValue::RawPtr(first_pointer) = first.value.0 else { + unreachable!() + }; + storage + .write_field(0, &(first_pointer as usize).to_le_bytes(), Some(first)) + .unwrap(); + assert!(first_weak.upgrade().is_some()); + let second = owned_text(&[66, 0]); + let second_weak = Arc::downgrade(&second); + let dynwinrt::WinRTValue::RawPtr(second_pointer) = second.value.0 else { + unreachable!() + }; + storage + .write_field(0, &(second_pointer as usize).to_le_bytes(), Some(second)) + .unwrap(); + assert!(first_weak.upgrade().is_none()); + assert!(second_weak.upgrade().is_some()); + assert!(storage.write_field(usize::MAX, &[1], None).is_err()); + assert!(storage.write_field(15, &[1, 2], None).is_err()); + assert!(second_weak.upgrade().is_some()); + assert_eq!( + usize::from_le_bytes(storage.read_field(0).unwrap()), + second_pointer as usize + ); + storage.write_field(0, &0usize.to_le_bytes(), None).unwrap(); + assert!(second_weak.upgrade().is_none()); +} + +#[test] +fn aggregate_storage_alignment_copy_isolation_and_field_bounds_are_exact() { + let storage = NativeAggregateStorage::new( + "Tests.Bytes".into(), + 24, + 8, + Some(&[7; 24]), + false, + Vec::new(), + ) + .unwrap(); + assert_eq!(storage.pointer() as usize % 8, 0); + let mut bytes = storage.bytes().unwrap(); + bytes[0] = 99; + assert_eq!(storage.bytes().unwrap()[0], 7); + storage + .write_field(20, &123u32.to_le_bytes(), None) + .unwrap(); + assert_eq!(u32::from_le_bytes(storage.read_field(20).unwrap()), 123); + assert!(storage.read_field::<8>(20).is_err()); + assert!(storage.backing.take_field(usize::MAX).is_err()); + assert!(NativeAggregateStorage::new( + "Tests.Bytes".into(), + 24, + 8, + Some(&[0; 23]), + false, + Vec::new() + ) + .is_err()); +} + +#[test] +fn string_encodings_alignment_and_double_terminators_are_validated_without_native_reads() { + use super::storage::{validate_string_bytes, BufferInfo}; + let mut bytes = [65u8, 0, 0, 1]; + let ansi = BufferInfo { + pointer: bytes.as_mut_ptr(), + length: 2, + }; + assert!(validate_string_bytes(&ansi, false, false).is_ok()); + assert!(validate_string_bytes(&ansi, false, true).is_err()); + let list = BufferInfo { + pointer: bytes.as_mut_ptr(), + length: 3, + }; + assert!(validate_string_bytes(&list, false, true).is_ok()); + let mut units = [65u16, 0, 0, 0]; + let wide = BufferInfo { + pointer: units.as_mut_ptr().cast(), + length: 4, + }; + assert!(validate_string_bytes(&wide, true, false).is_ok()); + assert!(validate_string_bytes(&wide, true, true).is_err()); + let list = BufferInfo { + pointer: units.as_mut_ptr().cast(), + length: 6, + }; + assert!(validate_string_bytes(&list, true, true).is_ok()); + let misaligned = BufferInfo { + pointer: unsafe { units.as_mut_ptr().cast::().add(1) }, + length: 4, + }; + assert!(validate_string_bytes(&misaligned, true, false).is_err()); + let odd = BufferInfo { + pointer: units.as_mut_ptr().cast(), + length: 5, + }; + assert!(validate_string_bytes(&odd, true, false).is_err()); + let empty = BufferInfo { + pointer: std::ptr::null_mut(), + length: 0, + }; + assert!(validate_string_bytes(&empty, true, false).is_err()); + assert!(validate_string_bytes(&empty, false, true).is_err()); +} diff --git a/bindings/js/src/win32_spec.rs b/bindings/js/src/win32_spec.rs new file mode 100644 index 00000000..0c23779d --- /dev/null +++ b/bindings/js/src/win32_spec.rs @@ -0,0 +1,380 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::{ffi::CStr, ops::Deref, ptr}; + +use napi::{ + bindgen_prelude::{FromNapiValue, TypeName, Unknown, ValidateNapiValue}, + sys, JsValue, +}; + +use super::{ + DynWin32FunctionSpec, DynWin32ParameterSpec, DynWin32Value, + MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH, +}; + +pub struct Descriptor(String); + +pub struct Name(String); + +impl Name { + pub fn into_string(self) -> String { + self.0 + } +} + +impl Deref for Name { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl std::fmt::Display for Name { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + std::fmt::Display::fmt(&self.0, formatter) + } +} + +impl TypeName for Name { + fn type_name() -> &'static str { + "string" + } + fn value_type() -> napi::ValueType { + napi::ValueType::String + } +} + +impl ValidateNapiValue for Name {} + +impl FromNapiValue for Name { + unsafe fn from_napi_value(env: sys::napi_env, raw: sys::napi_value) -> napi::Result { + Ok(Self(string(env, raw, 1024, "Win32 contract name")?)) + } +} + +impl Descriptor { + pub fn into_string(self) -> String { + self.0 + } +} + +impl Deref for Descriptor { + type Target = String; + fn deref(&self) -> &Self::Target { + &self.0 + } +} + +impl TypeName for Descriptor { + fn type_name() -> &'static str { + "string" + } + fn value_type() -> napi::ValueType { + napi::ValueType::String + } +} + +impl ValidateNapiValue for Descriptor {} + +impl FromNapiValue for Descriptor { + unsafe fn from_napi_value(env: sys::napi_env, raw: sys::napi_value) -> napi::Result { + Ok(Self(string( + env, + raw, + MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH, + "native aggregate descriptor", + )?)) + } +} + +fn string( + env: sys::napi_env, + raw: sys::napi_value, + limit: usize, + description: &str, +) -> napi::Result { + let mut length = 0; + napi::check_status!(unsafe { + sys::napi_get_value_string_utf8(env, raw, ptr::null_mut(), 0, &mut length) + })?; + if length > limit { + return Err(napi::Error::from_reason(format!( + "{description} exceeds the {limit} byte safety limit" + ))); + } + let mut bytes = Vec::new(); + bytes + .try_reserve_exact(length + 1) + .map_err(|_| napi::Error::from_reason(format!("Unable to allocate {description}")))?; + bytes.resize(length + 1, 0); + let mut written = 0; + napi::check_status!(unsafe { + sys::napi_get_value_string_utf8( + env, + raw, + bytes.as_mut_ptr().cast(), + bytes.len(), + &mut written, + ) + })?; + if written != length { + return Err(napi::Error::from_reason(format!( + "{description} length changed" + ))); + } + bytes.truncate(length); + String::from_utf8(bytes) + .map_err(|_| napi::Error::from_reason(format!("{description} is not valid UTF-8"))) +} + +fn property( + env: sys::napi_env, + object: sys::napi_value, + name: &CStr, +) -> napi::Result { + let mut value = ptr::null_mut(); + napi::check_status!(unsafe { + sys::napi_get_named_property(env, object, name.as_ptr(), &mut value) + })?; + Ok(value) +} + +fn optional(env: sys::napi_env, raw: sys::napi_value) -> napi::Result { + let mut kind = sys::ValueType::napi_undefined; + napi::check_status!(unsafe { sys::napi_typeof(env, raw, &mut kind) })?; + Ok(matches!( + kind, + sys::ValueType::napi_null | sys::ValueType::napi_undefined + )) +} + +fn optional_string( + env: sys::napi_env, + object: sys::napi_value, + name: &CStr, + limit: usize, +) -> napi::Result> { + let value = property(env, object, name)?; + if optional(env, value)? { + Ok(None) + } else { + Ok(Some(string(env, value, limit, &name.to_string_lossy())?)) + } +} + +fn optional_bool( + env: sys::napi_env, + object: sys::napi_value, + name: &CStr, +) -> napi::Result> { + let value = property(env, object, name)?; + if optional(env, value)? { + return Ok(None); + } + let mut boolean = false; + napi::check_status!(unsafe { sys::napi_get_value_bool(env, value, &mut boolean) })?; + Ok(Some(boolean)) +} + +fn closed_object(env: sys::napi_env, object: sys::napi_value, keys: &[&str]) -> napi::Result<()> { + let mut kind = sys::ValueType::napi_undefined; + napi::check_status!(unsafe { sys::napi_typeof(env, object, &mut kind) })?; + if kind != sys::ValueType::napi_object { + return Err(napi::Error::from_reason( + "Win32 native specification must be an object", + )); + } + let mut properties = ptr::null_mut(); + napi::check_status!(unsafe { + sys::napi_get_all_property_names( + env, + object, + sys::KeyCollectionMode::own_only, + sys::KeyFilter::all_properties, + sys::KeyConversion::numbers_to_strings, + &mut properties, + ) + })?; + validate_property_names(env, properties, keys)?; + napi::check_status!(unsafe { sys::napi_get_property_names(env, object, &mut properties) })?; + validate_property_names(env, properties, keys) +} + +fn validate_property_names( + env: sys::napi_env, + properties: sys::napi_value, + keys: &[&str], +) -> napi::Result<()> { + let mut count = 0; + napi::check_status!(unsafe { sys::napi_get_array_length(env, properties, &mut count) })?; + if count as usize > keys.len() { + return Err(napi::Error::from_reason( + "Win32 native specification has unknown fields", + )); + } + for index in 0..count { + let mut key = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_get_element(env, properties, index, &mut key) })?; + let mut kind = sys::ValueType::napi_undefined; + napi::check_status!(unsafe { sys::napi_typeof(env, key, &mut kind) })?; + if kind != sys::ValueType::napi_string { + return Err(napi::Error::from_reason( + "Unknown Win32 native specification symbol field", + )); + } + let key = string(env, key, 128, "Win32 specification field")?; + if !keys.contains(&key.as_str()) { + return Err(napi::Error::from_reason(format!( + "Unknown Win32 native specification field `{key}`" + ))); + } + } + Ok(()) +} + +pub(super) fn function_spec(value: Unknown) -> napi::Result { + let env = value.value().env; + let raw = value.raw(); + closed_object( + env, + raw, + &[ + "dll", + "entryPoint", + "parameters", + "returnType", + "returnCleanup", + "successRule", + "captureLastError", + "callingConvention", + "returnAggregateDescriptor", + "callContractDescriptor", + ], + )?; + let dll = string(env, property(env, raw, c"dll")?, 1024, "Win32 DLL name")?; + let entry_point = string( + env, + property(env, raw, c"entryPoint")?, + 1024, + "Win32 export name", + )?; + let array = property(env, raw, c"parameters")?; + let mut is_array = false; + napi::check_status!(unsafe { sys::napi_is_array(env, array, &mut is_array) })?; + if !is_array { + return Err(napi::Error::from_reason( + "Win32 parameters must be an array", + )); + } + let mut count = 0; + napi::check_status!(unsafe { sys::napi_get_array_length(env, array, &mut count) })?; + if count > 1024 { + return Err(napi::Error::from_reason( + "Win32 parameter count exceeds the 1024 limit", + )); + } + let mut parameters = Vec::new(); + parameters + .try_reserve_exact(count as usize) + .map_err(|_| napi::Error::from_reason("Unable to allocate Win32 parameters"))?; + for index in 0..count { + let mut parameter = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_get_element(env, array, index, &mut parameter) })?; + closed_object( + env, + parameter, + &[ + "type", + "direction", + "nullable", + "cleanup", + "consumesResource", + "resourceCleanup", + "aggregateDescriptor", + "pointeeDescriptor", + ], + )?; + parameters.push(DynWin32ParameterSpec { + typ: string( + env, + property(env, parameter, c"type")?, + 1024, + "Win32 parameter type", + )?, + direction: string( + env, + property(env, parameter, c"direction")?, + 1024, + "Win32 parameter direction", + )?, + nullable: optional_bool(env, parameter, c"nullable")?, + cleanup: optional_string(env, parameter, c"cleanup", 1024)?, + consumes_resource: optional_bool(env, parameter, c"consumesResource")?, + resource_cleanup: optional_string(env, parameter, c"resourceCleanup", 1024)?, + aggregate_descriptor: optional_string( + env, + parameter, + c"aggregateDescriptor", + MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH, + )?, + pointee_descriptor: optional_string( + env, + parameter, + c"pointeeDescriptor", + MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH, + )?, + }); + } + Ok(DynWin32FunctionSpec { + dll, + entry_point, + parameters, + return_type: optional_string(env, raw, c"returnType", 1024)?, + return_cleanup: optional_string(env, raw, c"returnCleanup", 1024)?, + success_rule: optional_string(env, raw, c"successRule", 1024)?, + capture_last_error: optional_bool(env, raw, c"captureLastError")?, + calling_convention: optional_string(env, raw, c"callingConvention", 1024)?, + return_aggregate_descriptor: optional_string( + env, + raw, + c"returnAggregateDescriptor", + MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH, + )?, + call_contract_descriptor: optional_string( + env, + raw, + c"callContractDescriptor", + MAX_NATIVE_AGGREGATE_DESCRIPTOR_LENGTH, + )?, + }) +} + +pub(super) fn arguments<'a>(value: &'a Unknown) -> napi::Result> { + let env = value.value().env; + let raw = value.raw(); + let mut is_array = false; + napi::check_status!(unsafe { sys::napi_is_array(env, raw, &mut is_array) })?; + if !is_array { + return Err(napi::Error::from_reason( + "Win32 invocation arguments must be an array", + )); + } + let mut count = 0; + napi::check_status!(unsafe { sys::napi_get_array_length(env, raw, &mut count) })?; + if count > 1024 { + return Err(napi::Error::from_reason( + "Win32 argument count exceeds the 1024 limit", + )); + } + let mut arguments = Vec::new(); + arguments + .try_reserve_exact(count as usize) + .map_err(|_| napi::Error::from_reason("Unable to allocate Win32 invocation arguments"))?; + for index in 0..count { + let mut element = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_get_element(env, raw, index, &mut element) })?; + arguments.push(unsafe { <&DynWin32Value>::from_napi_value(env, element) }?); + } + Ok(arguments) +} diff --git a/bindings/js/src/win32_storage.rs b/bindings/js/src/win32_storage.rs new file mode 100644 index 00000000..2742031e --- /dev/null +++ b/bindings/js/src/win32_storage.rs @@ -0,0 +1,412 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::{ffi::c_void, ptr}; + +use napi::{ + bindgen_prelude::{Buffer, FromNapiValue, ToNapiValue, Unknown}, + sys, JsValue, +}; + +use super::{com, DynWinRTValue}; + +pub(super) const MAX_BUFFER_BYTES: usize = 64 * 1024 * 1024; + +pub(super) fn signed64(value: &Unknown) -> napi::Result { + let mut integer = 0; + let mut lossless = false; + napi::check_status!(unsafe { + sys::napi_get_value_bigint_int64(value.value().env, value.raw(), &mut integer, &mut lossless) + })?; + if !lossless { + return Err(napi::Error::from_reason( + "Win32 bigint must fit a signed 64-bit integer", + )); + } + Ok(integer) +} + +pub(super) fn unsigned64(value: &Unknown) -> napi::Result { + let mut integer = 0; + let mut lossless = false; + napi::check_status!(unsafe { + sys::napi_get_value_bigint_uint64(value.value().env, value.raw(), &mut integer, &mut lossless) + })?; + if !lossless { + return Err(napi::Error::from_reason( + "Win32 bigint must fit an unsigned 64-bit integer", + )); + } + Ok(integer) +} + +pub(super) struct BufferInfo { + pub pointer: *mut u8, + pub length: usize, +} + +impl BufferInfo { + pub unsafe fn bytes(&self) -> &[u8] { + if self.length == 0 { + &[] + } else { + unsafe { std::slice::from_raw_parts(self.pointer, self.length) } + } + } +} + +pub(super) fn buffer_info(env: sys::napi_env, raw: sys::napi_value) -> napi::Result { + let mut is_typed_array = false; + napi::check_status!(unsafe { sys::napi_is_typedarray(env, raw, &mut is_typed_array) })?; + if !is_typed_array { + return Err(napi::Error::from_reason( + "Expected Buffer or Uint8Array native storage", + )); + } + let mut kind = 0; + let mut length = 0; + let mut data = ptr::null_mut(); + let mut backing = ptr::null_mut(); + let mut offset = 0; + napi::check_status!(unsafe { + sys::napi_get_typedarray_info( + env, + raw, + &mut kind, + &mut length, + &mut data, + &mut backing, + &mut offset, + ) + })?; + if kind != sys::TypedarrayType::uint8_array as i32 { + return Err(napi::Error::from_reason( + "Expected unsigned byte Buffer or Uint8Array storage", + )); + } + let mut is_array_buffer = false; + napi::check_status!(unsafe { sys::napi_is_arraybuffer(env, backing, &mut is_array_buffer) })?; + if !is_array_buffer { + return Err(napi::Error::from_reason( + "SharedArrayBuffer storage is unsupported for Win32", + )); + } + let mut detached = false; + napi::check_status!(unsafe { sys::napi_is_detached_arraybuffer(env, backing, &mut detached) })?; + if detached { + return Err(napi::Error::from_reason( + "Cannot use a detached Win32 Buffer/Uint8Array", + )); + } + let mut backing_data: *mut c_void = ptr::null_mut(); + let mut backing_length = 0; + napi::check_status!(unsafe { + sys::napi_get_arraybuffer_info(env, backing, &mut backing_data, &mut backing_length) + })?; + if length > MAX_BUFFER_BYTES + || offset + .checked_add(length) + .is_none_or(|end| end > backing_length) + || (length != 0 + && (data.is_null() + || backing_data.is_null() + || (backing_data as usize).checked_add(offset) != Some(data as usize))) + { + return Err(napi::Error::from_reason( + "Invalid or excessive Win32 native buffer extent (64 MiB maximum)", + )); + } + Ok(BufferInfo { + pointer: data.cast(), + length, + }) +} + +pub(super) fn length(value: &Unknown) -> napi::Result { + Ok(buffer_info(value.value().env, value.raw())?.length) +} + +pub(super) fn checked_length(value: f64) -> napi::Result { + if !value.is_finite() || value.fract() != 0.0 || !(0.0..=MAX_BUFFER_BYTES as f64).contains(&value) + { + return Err(napi::Error::from_reason( + "Win32 byte length must be a non-negative integer no larger than 64 MiB", + )); + } + Ok(value as usize) +} + +pub(super) fn zeroed(length: usize) -> napi::Result> { + if length > MAX_BUFFER_BYTES { + return Err(napi::Error::from_reason( + "Win32 buffer exceeds the 64 MiB limit", + )); + } + let mut bytes = Vec::new(); + bytes + .try_reserve_exact(length) + .map_err(|_| napi::Error::from_reason("Unable to allocate Win32 native buffer"))?; + bytes.resize(length, 0); + Ok(bytes) +} + +pub(super) fn copy(value: &Unknown, actual: Option) -> napi::Result { + let info = buffer_info(value.value().env, value.raw())?; + let length = actual + .map(checked_length) + .transpose()? + .unwrap_or(info.length); + if length > info.length { + return Err(napi::Error::from_reason( + "Successful Win32 output length exceeds native buffer capacity", + )); + } + let mut bytes = zeroed(length)?; + if length != 0 { + unsafe { ptr::copy_nonoverlapping(info.pointer, bytes.as_mut_ptr(), length) }; + } + Ok(Buffer::from(bytes)) +} + +fn is_null(value: &Unknown) -> napi::Result { + Ok(matches!( + value.get_type()?, + napi::ValueType::Null | napi::ValueType::Undefined + )) +} + +pub(super) fn data_pointer(value: Unknown, nullable: bool) -> napi::Result { + if matches!( + value.get_type()?, + napi::ValueType::Number | napi::ValueType::BigInt + ) { + return Err(napi::Error::from_reason( + "arbitrary numeric addresses require @microsoft/dynwinrt/win32/unsafe", + )); + } + if !is_null(&value)? { + buffer_info(value.value().env, value.raw())?; + } + com::safe_data_pointer(value, nullable) +} + +pub(super) fn unsafe_pointer(value: Unknown) -> napi::Result { + if value.get_type()? == napi::ValueType::BigInt { + let bits = usize::try_from(unsigned64(&value)?) + .map_err(|_| napi::Error::from_reason("Win32 address exceeds the process pointer width"))?; + return Ok(DynWinRTValue::with_borrowed_pointer( + dynwinrt::WinRTValue::RawPtr(bits as *mut c_void), + )); + } + if value.get_type()? == napi::ValueType::Object { + buffer_info(value.value().env, value.raw())?; + } + com::pointer(value) +} + +fn utf16(env: sys::napi_env, raw: sys::napi_value) -> napi::Result> { + let mut length = 0; + napi::check_status!(unsafe { + sys::napi_get_value_string_utf16(env, raw, ptr::null_mut(), 0, &mut length) + })?; + if length >= MAX_BUFFER_BYTES / 2 { + return Err(napi::Error::from_reason( + "Win32 UTF-16 string exceeds the 64 MiB limit", + )); + } + let mut units = Vec::new(); + units + .try_reserve_exact(length + 1) + .map_err(|_| napi::Error::from_reason("Unable to allocate Win32 UTF-16 storage"))?; + units.resize(length + 1, 0); + let mut written = 0; + napi::check_status!(unsafe { + sys::napi_get_value_string_utf16(env, raw, units.as_mut_ptr(), units.len(), &mut written) + })?; + if written != length { + return Err(napi::Error::from_reason( + "Win32 UTF-16 input length changed", + )); + } + units.truncate(length); + if units.contains(&0) || char::decode_utf16(units.iter().copied()).any(|unit| unit.is_err()) { + return Err(napi::Error::from_reason( + "Win32 UTF-16 input contains NUL or ill-formed UTF-16", + )); + } + Ok(units) +} + +fn push_units(storage: &mut Vec, units: &[u16]) -> napi::Result<()> { + let additional = units + .len() + .checked_add(1) + .ok_or_else(|| napi::Error::from_reason("Win32 string length overflow"))?; + let length = storage + .len() + .checked_add(additional) + .filter(|length| *length < MAX_BUFFER_BYTES / 2) + .ok_or_else(|| napi::Error::from_reason("Win32 string exceeds the 64 MiB limit"))?; + storage + .try_reserve_exact(additional) + .map_err(|_| napi::Error::from_reason("Unable to allocate Win32 string storage"))?; + storage.extend_from_slice(units); + storage.resize(length, 0); + Ok(()) +} + +pub(super) fn string_pointer( + value: Unknown, + nullable: bool, + wide: bool, + multi: bool, +) -> napi::Result { + if is_null(&value)? { + return if nullable { + com::pointer(value) + } else { + Err(napi::Error::from_reason( + "Win32 string null requires an explicitly nullable parameter", + )) + }; + } + let env = value.value().env; + let raw = value.raw(); + let mut is_array = false; + if multi { + napi::check_status!(unsafe { sys::napi_is_array(env, raw, &mut is_array) })?; + } + if value.get_type()? == napi::ValueType::String || is_array { + let mut units = Vec::new(); + if is_array { + let mut length = 0u32; + napi::check_status!(unsafe { sys::napi_get_array_length(env, raw, &mut length) })?; + if length as usize > MAX_BUFFER_BYTES / 2 - 2 { + return Err(napi::Error::from_reason( + "Win32 multi-string array exceeds the storage bound", + )); + } + for index in 0..length { + let mut element = ptr::null_mut(); + napi::check_status!(unsafe { sys::napi_get_element(env, raw, index, &mut element) })?; + let text = utf16(env, element)?; + if text.is_empty() && length > 1 { + return Err(napi::Error::from_reason( + "Empty multi-string entries would truncate the list", + )); + } + push_units(&mut units, &text)?; + } + if length == 0 { + push_units(&mut units, &[])?; + } + } else { + push_units(&mut units, &utf16(env, raw)?)?; + } + if multi { + push_units(&mut units, &[])?; + } + return if wide { + let mut units = units.into_boxed_slice(); + let pointer = units.as_mut_ptr().cast(); + Ok(DynWinRTValue::with_pointer_owner( + dynwinrt::WinRTValue::RawPtr(pointer), + com::NativePointerOwner::WideString(units), + )) + } else { + if units.iter().any(|unit| *unit > 0x7f) { + return Err(napi::Error::from_reason( + "ANSI strings must be ASCII; use explicitly encoded terminated Buffer storage", + )); + } + let mut bytes = zeroed(units.len())?.into_boxed_slice(); + for (target, unit) in bytes.iter_mut().zip(units) { + *target = unit as u8; + } + let pointer = bytes.as_mut_ptr().cast(); + Ok(DynWinRTValue::with_pointer_owner( + dynwinrt::WinRTValue::RawPtr(pointer), + com::NativePointerOwner::AnsiString(bytes), + )) + }; + } + let info = buffer_info(env, raw)?; + validate_string_bytes(&info, wide, multi)?; + com::safe_data_pointer(value, false) +} + +pub(super) fn validate_string_bytes( + info: &BufferInfo, + wide: bool, + multi: bool, +) -> napi::Result<()> { + let terminator = if wide { 2 } else { 1 } * if multi { 2 } else { 1 }; + if info.length < terminator + || (wide && (info.length % 2 != 0 || info.pointer as usize % 2 != 0)) + || unsafe { info.bytes() }[info.length - terminator..] + .iter() + .any(|byte| *byte != 0) + { + return Err(napi::Error::from_reason(if multi && wide { + "Win32 multi-string storage must end in two NUL code units with UTF-16 alignment" + } else if multi { + "Win32 multi-string storage must end in two NUL bytes" + } else { + "Win32 string storage must be aligned and NUL-terminated" + })); + } + Ok(()) +} + +pub(super) fn validate_string_owner( + owner: &DynWinRTValue, + wide: bool, + multi: bool, +) -> napi::Result<()> { + match &owner.1 { + Some(com::NativePointerOwner::Uint8Array { value, env, .. }) => { + let mut value = value + .lock() + .map_err(|_| napi::Error::from_reason("Win32 string owner lock is poisoned"))?; + let raw = unsafe { + <&mut napi::bindgen_prelude::Uint8Array as ToNapiValue>::to_napi_value(*env, &mut *value) + }?; + validate_string_bytes(&buffer_info(*env, raw)?, wide, multi) + } + Some(com::NativePointerOwner::WideString(units)) if wide => validate_string_bytes( + &BufferInfo { + pointer: units.as_ptr().cast::().cast_mut(), + length: units.len() * 2, + }, + wide, + multi, + ), + Some(com::NativePointerOwner::AnsiString(bytes)) if !wide => validate_string_bytes( + &BufferInfo { + pointer: bytes.as_ptr().cast_mut(), + length: bytes.len(), + }, + wide, + multi, + ), + None if matches!(owner.0, dynwinrt::WinRTValue::Null) => Ok(()), + None if matches!(owner.0, dynwinrt::WinRTValue::RawPtr(pointer) if pointer.is_null()) => Ok(()), + _ => Err(napi::Error::from_reason( + "Win32 string is missing its exact retained storage", + )), + } +} + +pub(super) fn native_buffer(value: Unknown) -> napi::Result { + buffer_info(value.value().env, value.raw())?; + let mut is_buffer = false; + napi::check_status!(unsafe { + sys::napi_is_buffer(value.value().env, value.raw(), &mut is_buffer) + })?; + if !is_buffer { + return Err(napi::Error::from_reason( + "OVERLAPPED I/O requires a Node Buffer", + )); + } + unsafe { Buffer::from_napi_value(value.value().env, value.raw()) } +} diff --git a/bindings/js/src/win32_subsystem.rs b/bindings/js/src/win32_subsystem.rs new file mode 100644 index 00000000..c320bfca --- /dev/null +++ b/bindings/js/src/win32_subsystem.rs @@ -0,0 +1,956 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::mem::MaybeUninit; +use std::sync::{LazyLock, Mutex, MutexGuard}; + +use windows::Win32::Graphics::GdiPlus::{GdiplusStartupInput, Ok as GDIPLUS_OK}; +use windows::Win32::Media::MediaFoundation::{MFSTARTUP_FULL, MF_VERSION}; +use windows::Win32::Networking::WinSock::WSADATA; + +#[path = "win32_subsystem_api.rs"] +mod api; +use api::{GdiPlusFunctions, MapiUtilityFunctions, MediaFoundationFunctions, WinsockFunctions}; + +#[cfg(test)] +#[path = "win32_subsystem_lifecycle_tests.rs"] +mod lifecycle_tests; + +const WINSOCK_VERSION_2_2: u16 = 0x0202; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum SubsystemKind { + Winsock, + GdiPlus, + MediaFoundation, + MapiUtilities, +} + +impl SubsystemKind { + fn parse(value: &str) -> napi::Result { + match value.to_ascii_lowercase().as_str() { + "winsock" => Ok(Self::Winsock), + "gdiplus" | "gdi+" => Ok(Self::GdiPlus), + "mediafoundation" | "media_foundation" => Ok(Self::MediaFoundation), + "mapiutilities" | "mapi_utilities" => Ok(Self::MapiUtilities), + _ => Err(napi::Error::from_reason(format!( + "Unknown flat Win32 subsystem `{value}`" + ))), + } + } + + const fn name(self) -> &'static str { + match self { + Self::Winsock => "winsock", + Self::GdiPlus => "gdiplus", + Self::MediaFoundation => "mediaFoundation", + Self::MapiUtilities => "mapiUtilities", + } + } +} + +#[derive(Default)] +struct CountedState { + leases: usize, +} + +#[derive(Default)] +struct WinsockState { + leases: usize, + rollback_pending: bool, +} + +#[derive(Default)] +struct GdiPlusState { + leases: usize, + token: usize, +} + +static WINSOCK_STATE: LazyLock> = + LazyLock::new(|| Mutex::new(WinsockState::default())); +static GDIPLUS_STATE: LazyLock> = + LazyLock::new(|| Mutex::new(GdiPlusState::default())); +static MEDIA_FOUNDATION_STATE: LazyLock> = + LazyLock::new(|| Mutex::new(CountedState::default())); +static MAPI_UTILITIES_STATE: LazyLock> = + LazyLock::new(|| Mutex::new(CountedState::default())); + +#[cfg(target_arch = "x86")] +const MAPI_INIT_EXPORT: &std::ffi::CStr = c"ScInitMapiUtil@4"; +#[cfg(target_arch = "x86")] +const MAPI_DEINIT_EXPORT: &std::ffi::CStr = c"DeinitMapiUtil@0"; +#[cfg(not(target_arch = "x86"))] +const MAPI_INIT_EXPORT: &std::ffi::CStr = c"ScInitMapiUtil"; +#[cfg(not(target_arch = "x86"))] +const MAPI_DEINIT_EXPORT: &std::ffi::CStr = c"DeinitMapiUtil"; + +fn system_mapi_utilities() -> napi::Result>> { + api::mapi() +} + +fn winsock_functions() -> napi::Result { + #[cfg(test)] + if let Some(functions) = lifecycle_tests::winsock_functions() { + return functions; + } + Ok(api::winsock()?.functions) +} + +fn gdiplus_functions() -> napi::Result { + #[cfg(test)] + if let Some(functions) = lifecycle_tests::gdiplus_functions() { + return functions; + } + Ok(api::gdiplus()?.functions) +} + +fn media_foundation_functions() -> napi::Result { + #[cfg(test)] + if let Some(functions) = lifecycle_tests::media_foundation_functions() { + return functions; + } + Ok(api::media_foundation()?.functions) +} + +fn mapi_utilities() -> napi::Result { + #[cfg(test)] + if let Some(functions) = tests::mapi_utility_fixture() { + return functions; + } + Ok(system_mapi_utilities()?.functions) +} + +pub struct DynWin32SubsystemContext { + kind: SubsystemKind, + closed: Mutex, +} +super::win32::boundary::carrier!(DynWin32SubsystemContext, 6, "DynWin32SubsystemContext"); + +pub(super) struct SubsystemCallGuard<'a> { + _closed: MutexGuard<'a, bool>, +} + +impl DynWin32SubsystemContext { + pub fn subsystem(&self) -> &'static str { + self.kind.name() + } + + pub fn closed(&self) -> bool { + *self + .closed + .lock() + .unwrap_or_else(|error| error.into_inner()) + } + + pub fn close(&self) -> napi::Result<()> { + let mut closed = self + .closed + .lock() + .unwrap_or_else(|error| error.into_inner()); + if *closed { + return Ok(()); + } + release(self.kind)?; + *closed = true; + Ok(()) + } +} + +impl Drop for DynWin32SubsystemContext { + fn drop(&mut self) { + let closed = self + .closed + .get_mut() + .unwrap_or_else(|error| error.into_inner()); + if !*closed { + if let Err(error) = release(self.kind) { + eprintln!( + "[dynwinrt] {} subsystem cleanup failed: {}", + self.kind.name(), + error.reason + ); + } + *closed = true; + } + } +} + +pub(super) fn initialize(subsystem: &str) -> napi::Result { + let kind = SubsystemKind::parse(subsystem)?; + acquire(kind)?; + Ok(DynWin32SubsystemContext { + kind, + closed: Mutex::new(false), + }) +} + +pub(super) fn require(context: &DynWin32SubsystemContext, subsystem: &str) -> napi::Result<()> { + drop(call_guard(context, subsystem)?); + Ok(()) +} + +pub(super) fn call_guard<'a>( + context: &'a DynWin32SubsystemContext, + subsystem: &str, +) -> napi::Result> { + let expected = SubsystemKind::parse(subsystem)?; + if context.kind != expected { + return Err(napi::Error::from_reason(format!( + "{} APIs require a {} context, received {}", + expected.name(), + expected.name(), + context.kind.name() + ))); + } + let closed = context + .closed + .lock() + .unwrap_or_else(|error| error.into_inner()); + if *closed { + return Err(napi::Error::from_reason(format!( + "{} subsystem context is closed", + expected.name() + ))); + } + if !is_active(expected) { + return Err(napi::Error::from_reason(format!( + "{} subsystem is not initialized", + expected.name() + ))); + } + Ok(SubsystemCallGuard { _closed: closed }) +} + +fn acquire(kind: SubsystemKind) -> napi::Result<()> { + match kind { + SubsystemKind::Winsock => acquire_winsock(), + SubsystemKind::GdiPlus => acquire_gdiplus(), + SubsystemKind::MediaFoundation => acquire_media_foundation(), + SubsystemKind::MapiUtilities => acquire_mapi_utilities(), + } +} + +fn release(kind: SubsystemKind) -> napi::Result<()> { + match kind { + SubsystemKind::Winsock => release_winsock(), + SubsystemKind::GdiPlus => release_gdiplus(), + SubsystemKind::MediaFoundation => release_media_foundation(), + SubsystemKind::MapiUtilities => release_mapi_utilities(), + } +} + +fn is_active(kind: SubsystemKind) -> bool { + match kind { + SubsystemKind::Winsock => { + WINSOCK_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()) + .leases + != 0 + } + SubsystemKind::GdiPlus => { + GDIPLUS_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()) + .leases + != 0 + } + SubsystemKind::MediaFoundation => { + MEDIA_FOUNDATION_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()) + .leases + != 0 + } + SubsystemKind::MapiUtilities => { + MAPI_UTILITIES_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()) + .leases + != 0 + } + } +} + +fn acquire_winsock() -> napi::Result<()> { + let mut state = WINSOCK_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()); + if state.leases == 0 { + let functions = winsock_functions()?; + if state.rollback_pending { + let status = unsafe { (functions.cleanup)() }; + if status != 0 { + return Err(napi::Error::from_reason(format!( + "Winsock initialization rollback is still pending; WSACleanup failed with Winsock error {}", + unsafe { (functions.last_error)() } + ))); + } + state.rollback_pending = false; + } + let mut data = MaybeUninit::::uninit(); + let status = unsafe { (functions.startup)(WINSOCK_VERSION_2_2, data.as_mut_ptr()) }; + if status != 0 { + return Err(napi::Error::from_reason(format!( + "WSAStartup(2.2) failed with Winsock error {status}" + ))); + } + let data = unsafe { data.assume_init() }; + if data.wVersion != WINSOCK_VERSION_2_2 { + if unsafe { (functions.cleanup)() } != 0 { + state.rollback_pending = true; + return Err(napi::Error::from_reason(format!( + "Winsock 2.2 is unavailable; negotiated version 0x{:04x}; WSACleanup rollback failed with Winsock error {}", + data.wVersion, + unsafe { (functions.last_error)() } + ))); + } + return Err(napi::Error::from_reason(format!( + "Winsock 2.2 is unavailable; negotiated version 0x{:04x}", + data.wVersion + ))); + } + } + state.leases = state + .leases + .checked_add(1) + .ok_or_else(|| napi::Error::from_reason("Winsock context count overflow"))?; + Ok(()) +} + +fn release_winsock() -> napi::Result<()> { + let mut state = WINSOCK_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()); + if state.leases == 0 { + return Err(napi::Error::from_reason( + "Winsock subsystem context is not active", + )); + } + if state.leases == 1 { + let functions = winsock_functions()?; + let status = unsafe { (functions.cleanup)() }; + if status != 0 { + return Err(napi::Error::from_reason(format!( + "WSACleanup failed with Winsock error {}", + unsafe { (functions.last_error)() } + ))); + } + } + state.leases -= 1; + Ok(()) +} + +fn acquire_gdiplus() -> napi::Result<()> { + let mut state = GDIPLUS_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()); + if state.leases == 0 { + let functions = gdiplus_functions()?; + let input = GdiplusStartupInput { + GdiplusVersion: 1, + DebugEventCallback: 0, + SuppressBackgroundThread: false.into(), + SuppressExternalCodecs: false.into(), + }; + let mut token = 0usize; + let status = unsafe { (functions.startup)(&mut token, &input, std::ptr::null_mut()) }; + if status != GDIPLUS_OK { + return Err(napi::Error::from_reason(format!( + "GdiplusStartup failed with status {}", + status.0 + ))); + } + if token == 0 { + return Err(napi::Error::from_reason( + "GdiplusStartup returned an invalid token", + )); + } + state.token = token; + } + state.leases = state + .leases + .checked_add(1) + .ok_or_else(|| napi::Error::from_reason("GDI+ context count overflow"))?; + Ok(()) +} + +fn release_gdiplus() -> napi::Result<()> { + let mut state = GDIPLUS_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()); + if state.leases == 0 { + return Err(napi::Error::from_reason( + "GDI+ subsystem context is not active", + )); + } + if state.leases == 1 { + let functions = gdiplus_functions()?; + unsafe { (functions.shutdown)(state.token) }; + state.token = 0; + } + state.leases -= 1; + Ok(()) +} + +fn acquire_media_foundation() -> napi::Result<()> { + let mut state = MEDIA_FOUNDATION_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()); + if state.leases == 0 { + let functions = media_foundation_functions()?; + unsafe { (functions.startup)(MF_VERSION, MFSTARTUP_FULL) } + .ok() + .map_err(|error| napi::Error::from_reason(format!("MFStartup failed: {error}")))?; + } + state.leases = state + .leases + .checked_add(1) + .ok_or_else(|| napi::Error::from_reason("Media Foundation context count overflow"))?; + Ok(()) +} + +fn release_media_foundation() -> napi::Result<()> { + let mut state = MEDIA_FOUNDATION_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()); + if state.leases == 0 { + return Err(napi::Error::from_reason( + "Media Foundation subsystem context is not active", + )); + } + if state.leases == 1 { + let functions = media_foundation_functions()?; + unsafe { (functions.shutdown)() } + .ok() + .map_err(|error| napi::Error::from_reason(format!("MFShutdown failed: {error}")))?; + } + state.leases -= 1; + Ok(()) +} + +fn acquire_mapi_utilities() -> napi::Result<()> { + let mut state = MAPI_UTILITIES_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()); + if state.leases == 0 { + let status = unsafe { (mapi_utilities()?.initialize)(0) }; + if status != 0 { + return Err(napi::Error::from_reason(format!( + "ScInitMapiUtil(0) failed with SCODE 0x{:08x}", + status as u32 + ))); + } + } + state.leases = state + .leases + .checked_add(1) + .ok_or_else(|| napi::Error::from_reason("MAPI utility context count overflow"))?; + Ok(()) +} + +fn release_mapi_utilities() -> napi::Result<()> { + let mut state = MAPI_UTILITIES_STATE + .lock() + .unwrap_or_else(|error| error.into_inner()); + if state.leases == 0 { + return Err(napi::Error::from_reason( + "MAPI utility subsystem context is not active", + )); + } + if state.leases == 1 { + let functions = mapi_utilities()?; + unsafe { (functions.deinitialize)() }; + } + state.leases -= 1; + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::lifecycle_tests::Fixture as NativeFixture; + use super::*; + use std::{ + process::{Command, Stdio}, + sync::atomic::{AtomicBool, AtomicI32, Ordering}, + time::{Duration, Instant}, + }; + + pub(super) static TEST_SERIAL: Mutex<()> = Mutex::new(()); + static MAPI_FIXTURE_ENABLED: AtomicBool = AtomicBool::new(false); + static MAPI_FIXTURE_LOAD_FAILURE: AtomicBool = AtomicBool::new(false); + static MAPI_FIXTURE_STATUS: AtomicI32 = AtomicI32::new(0); + static MAPI_FIXTURE_EVENTS: Mutex> = Mutex::new(Vec::new()); + + #[derive(Clone, Copy, Debug, PartialEq, Eq)] + enum MapiEvent { + Initialize(u32), + Deinitialize, + } + + struct MapiFixture; + + impl MapiFixture { + fn new(status: i32) -> Self { + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 0); + assert!(!MAPI_FIXTURE_ENABLED.swap(true, Ordering::SeqCst)); + MAPI_FIXTURE_LOAD_FAILURE.store(false, Ordering::SeqCst); + MAPI_FIXTURE_STATUS.store(status, Ordering::SeqCst); + MAPI_FIXTURE_EVENTS + .lock() + .unwrap_or_else(|error| error.into_inner()) + .clear(); + Self + } + + fn events(&self) -> Vec { + MAPI_FIXTURE_EVENTS + .lock() + .unwrap_or_else(|error| error.into_inner()) + .clone() + } + } + + impl Drop for MapiFixture { + fn drop(&mut self) { + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 0); + MAPI_FIXTURE_ENABLED.store(false, Ordering::SeqCst); + } + } + + unsafe extern "system" fn fixture_mapi_initialize(flags: u32) -> i32 { + MAPI_FIXTURE_EVENTS + .lock() + .unwrap_or_else(|error| error.into_inner()) + .push(MapiEvent::Initialize(flags)); + MAPI_FIXTURE_STATUS.load(Ordering::SeqCst) + } + + unsafe extern "system" fn fixture_mapi_deinitialize() { + MAPI_FIXTURE_EVENTS + .lock() + .unwrap_or_else(|error| error.into_inner()) + .push(MapiEvent::Deinitialize); + } + + pub(super) fn mapi_utility_fixture() -> Option> { + if !MAPI_FIXTURE_ENABLED.load(Ordering::SeqCst) { + return None; + } + if MAPI_FIXTURE_LOAD_FAILURE.load(Ordering::SeqCst) { + return Some(Err(napi::Error::from_reason( + "MAPI utility fixture exports are unavailable", + ))); + } + Some(Ok(MapiUtilityFunctions { + initialize: fixture_mapi_initialize, + deinitialize: fixture_mapi_deinitialize, + })) + } + + fn isolated_native_test(test: F) -> bool { + const CHILD: &str = "DYNWINRT_SUBSYSTEM_TEST_CHILD"; + let qualified = std::any::type_name_of_val(&test); + let (_, name) = qualified + .split_once("::") + .expect("native subsystem test has a qualified Rust name"); + if std::env::var(CHILD).as_deref() == Ok(name) { + return false; + } + let mut child = Command::new(std::env::current_exe().unwrap()) + .arg(name) + .args([ + "--exact", + "--nocapture", + "--test-threads=1", + "--include-ignored", + ]) + .env(CHILD, name) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) + .spawn() + .expect("start isolated native subsystem test"); + let deadline = Instant::now() + Duration::from_secs(60); + loop { + if let Some(status) = child.try_wait().expect("check subsystem test process") { + assert!(status.success(), "{name}: child failed with {status}"); + return true; + } + if Instant::now() >= deadline { + child.kill().expect("terminate this subsystem test process"); + child.wait().expect("reap subsystem test process"); + panic!("{name}: native subsystem lifecycle exceeded 60 seconds; see the last stage above"); + } + std::thread::sleep(Duration::from_millis(20)); + } + } + + fn live_context(name: &str) -> DynWin32SubsystemContext { + eprintln!("[subsystem-test] initialize {name}"); + let context = initialize(name).unwrap(); + eprintln!("[subsystem-test] initialized {name}"); + context + } + + fn close_context(context: &DynWin32SubsystemContext) { + eprintln!("[subsystem-test] close {}", context.subsystem()); + context.close().unwrap(); + eprintln!("[subsystem-test] closed {}", context.subsystem()); + } + + fn drop_context(context: DynWin32SubsystemContext) { + let name = context.subsystem(); + eprintln!("[subsystem-test] drop {name}"); + drop(context); + eprintln!("[subsystem-test] dropped {name}"); + } + + pub(super) fn lease_count(kind: SubsystemKind) -> usize { + match kind { + SubsystemKind::Winsock => WINSOCK_STATE.lock().unwrap().leases, + SubsystemKind::GdiPlus => GDIPLUS_STATE.lock().unwrap().leases, + SubsystemKind::MediaFoundation => MEDIA_FOUNDATION_STATE.lock().unwrap().leases, + SubsystemKind::MapiUtilities => MAPI_UTILITIES_STATE.lock().unwrap().leases, + } + } + + #[test] + fn winsock_context_is_counted_and_rejects_use_after_close() { + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let first = initialize("winsock").unwrap(); + let second = initialize("winsock").unwrap(); + require(&first, "winsock").unwrap(); + first.close().unwrap(); + assert!(require(&first, "winsock").is_err()); + require(&second, "winsock").unwrap(); + second.close().unwrap(); + } + + #[test] + fn context_kind_mismatch_is_rejected() { + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let winsock = initialize("winsock").unwrap(); + let error = require(&winsock, "gdiplus").unwrap_err(); + assert!(error.reason.contains("received winsock")); + winsock.close().unwrap(); + } + + pub(super) fn assert_call_guard_blocks_close(subsystem: &str) { + let context = std::sync::Arc::new(initialize(subsystem).unwrap()); + let guard = call_guard(&context, subsystem).unwrap(); + let closing = std::sync::Arc::clone(&context); + let (started_sender, started_receiver) = std::sync::mpsc::channel(); + let (finished_sender, finished_receiver) = std::sync::mpsc::channel(); + let thread = std::thread::spawn(move || { + started_sender.send(()).unwrap(); + let result = closing.close(); + finished_sender.send(result).unwrap(); + }); + + started_receiver + .recv_timeout(std::time::Duration::from_secs(5)) + .unwrap(); + assert!(matches!( + context.closed.try_lock(), + Err(std::sync::TryLockError::WouldBlock) + )); + assert!(matches!( + finished_receiver.try_recv(), + Err(std::sync::mpsc::TryRecvError::Empty) + )); + drop(guard); + finished_receiver + .recv_timeout(std::time::Duration::from_secs(5)) + .unwrap() + .unwrap(); + thread.join().unwrap(); + } + + #[test] + fn call_guard_blocks_concurrent_close() { + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + assert_call_guard_blocks_close("winsock"); + } + + #[test] + fn gdiplus_media_foundation_and_mapi_utility_contexts_are_counted() { + if isolated_native_test(gdiplus_media_foundation_and_mapi_utility_contexts_are_counted) { + return; + } + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let _gdi = NativeFixture::new(SubsystemKind::GdiPlus); + let _media = NativeFixture::new(SubsystemKind::MediaFoundation); + let mapi = MapiFixture::new(0); + for subsystem in ["gdiplus", "mediaFoundation", "mapiUtilities"] { + let first = live_context(subsystem); + let second = live_context(subsystem); + close_context(&first); + require(&second, subsystem).unwrap(); + close_context(&second); + } + assert_eq!( + mapi.events(), + [MapiEvent::Initialize(0), MapiEvent::Deinitialize] + ); + } + + #[test] + fn subsystem_counts_remain_independent_across_kind_and_alias_closure() { + if isolated_native_test(subsystem_counts_remain_independent_across_kind_and_alias_closure) { + return; + } + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let _gdi = NativeFixture::new(SubsystemKind::GdiPlus); + let _media = NativeFixture::new(SubsystemKind::MediaFoundation); + let mapi_fixture = MapiFixture::new(0); + let winsock = live_context("winsock"); + let winsock_alias = live_context("winsock"); + let gdi = live_context("gdi+"); + let media = live_context("media_foundation"); + let mapi = live_context("mapi_utilities"); + close_context(&winsock); + require(&winsock_alias, "winsock").unwrap(); + require(&gdi, "gdiplus").unwrap(); + require(&media, "mediaFoundation").unwrap(); + require(&mapi, "mapiUtilities").unwrap(); + close_context(&gdi); + require(&winsock_alias, "winsock").unwrap(); + require(&media, "mediaFoundation").unwrap(); + close_context(&winsock_alias); + require(&media, "mediaFoundation").unwrap(); + close_context(&media); + require(&mapi, "mapiUtilities").unwrap(); + close_context(&mapi); + for context in [&winsock, &winsock_alias, &gdi, &media, &mapi] { + assert!(context.closed()); + context.close().unwrap(); + } + assert_eq!( + mapi_fixture.events(), + [MapiEvent::Initialize(0), MapiEvent::Deinitialize] + ); + } + + #[test] + fn every_closed_context_rejects_dispatch_and_unknown_kinds_fail_closed() { + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + for kind in [ + SubsystemKind::Winsock, + SubsystemKind::GdiPlus, + SubsystemKind::MediaFoundation, + SubsystemKind::MapiUtilities, + ] { + let context = DynWin32SubsystemContext { + kind, + closed: Mutex::new(true), + }; + assert!(call_guard(&context, kind.name()) + .err() + .unwrap() + .reason + .contains("closed")); + context.close().unwrap(); + assert!(context.closed()); + } + for name in ["", "winsock2", "mapi", "gdiplusSuffix"] { + assert!(SubsystemKind::parse(name).is_err()); + } + } + + #[test] + fn dropping_live_contexts_returns_each_subsystems_exact_lease_count() { + if isolated_native_test(dropping_live_contexts_returns_each_subsystems_exact_lease_count) { + return; + } + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let _gdi = NativeFixture::new(SubsystemKind::GdiPlus); + let _media = NativeFixture::new(SubsystemKind::MediaFoundation); + let mapi = MapiFixture::new(0); + for kind in [ + SubsystemKind::Winsock, + SubsystemKind::GdiPlus, + SubsystemKind::MediaFoundation, + SubsystemKind::MapiUtilities, + ] { + let before = lease_count(kind); + let first = live_context(kind.name()); + let last = live_context(kind.name()); + assert_eq!(lease_count(kind), before + 2); + drop_context(first); + assert_eq!(lease_count(kind), before + 1); + require(&last, kind.name()).unwrap(); + drop_context(last); + assert_eq!(lease_count(kind), before); + } + assert_eq!( + mapi.events(), + [MapiEvent::Initialize(0), MapiEvent::Deinitialize] + ); + } + + #[test] + fn mapi_initialization_failure_does_not_publish_a_lease_and_can_be_retried() { + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let mapi = MapiFixture::new(0x8000_4005_u32 as i32); + let error = initialize("mapiUtilities").err().unwrap(); + assert!(error.reason.contains("SCODE 0x80004005")); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 0); + assert_eq!(mapi.events(), [MapiEvent::Initialize(0)]); + + MAPI_FIXTURE_STATUS.store(0, Ordering::SeqCst); + let context = initialize("mapi_utilities").unwrap(); + require(&context, "mapiUtilities").unwrap(); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 1); + drop(context); + assert_eq!( + mapi.events(), + [ + MapiEvent::Initialize(0), + MapiEvent::Initialize(0), + MapiEvent::Deinitialize + ] + ); + } + + #[test] + fn missing_mapi_exports_do_not_publish_or_cleanup_a_lease() { + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let mapi = MapiFixture::new(0); + MAPI_FIXTURE_LOAD_FAILURE.store(true, Ordering::SeqCst); + let error = initialize("mapiUtilities").err().unwrap(); + assert!(error.reason.contains("exports are unavailable")); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 0); + assert!(mapi.events().is_empty()); + } + + #[test] + fn mapi_final_close_is_idempotent_and_allows_reinitialization() { + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let mapi = MapiFixture::new(0); + let first = initialize("mapiUtilities").unwrap(); + let second = initialize("mapi_utilities").unwrap(); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 2); + first.close().unwrap(); + first.close().unwrap(); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 1); + assert_eq!(mapi.events(), [MapiEvent::Initialize(0)]); + require(&second, "mapiUtilities").unwrap(); + drop(second); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 0); + assert!(release_mapi_utilities().is_err()); + let reopened = initialize("mapiUtilities").unwrap(); + reopened.close().unwrap(); + drop(reopened); + assert_eq!( + mapi.events(), + [ + MapiEvent::Initialize(0), + MapiEvent::Deinitialize, + MapiEvent::Initialize(0), + MapiEvent::Deinitialize + ] + ); + } + + #[test] + fn mapi_call_guard_blocks_final_cleanup_on_another_thread() { + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let mapi = MapiFixture::new(0); + assert_call_guard_blocks_close("mapiUtilities"); + assert_eq!( + mapi.events(), + [MapiEvent::Initialize(0), MapiEvent::Deinitialize] + ); + } + + #[test] + #[ignore = "requires a configured Extended MAPI provider of the process architecture"] + fn mapi_utility_contexts_use_installed_provider() { + if isolated_native_test(mapi_utility_contexts_use_installed_provider) { + return; + } + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + let first = live_context("mapiUtilities"); + let last = live_context("mapi_utilities"); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 2); + close_context(&first); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 1); + require(&last, "mapiUtilities").unwrap(); + drop_context(last); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 0); + let reopened = live_context("mapiUtilities"); + close_context(&reopened); + close_context(&reopened); + assert_eq!(lease_count(SubsystemKind::MapiUtilities), 0); + } + + #[test] + fn mapi_utility_exports_resolve_for_the_process_architecture() { + assert!(!MAPI_INIT_EXPORT.to_bytes().is_empty()); + assert!(!MAPI_DEINIT_EXPORT.to_bytes().is_empty()); + system_mapi_utilities().expect("resolve the exact system utility exports"); + } + + #[test] + fn installed_native_lifecycle_tables_initialize_and_reinitialize() { + if isolated_native_test(installed_native_lifecycle_tables_initialize_and_reinitialize) { + return; + } + let _serial = TEST_SERIAL + .lock() + .unwrap_or_else(|error| error.into_inner()); + for kind in [ + SubsystemKind::Winsock, + SubsystemKind::GdiPlus, + SubsystemKind::MediaFoundation, + ] { + let first = match initialize(kind.name()) { + Ok(context) => context, + Err(error) + if kind != SubsystemKind::Winsock + && (error.reason.starts_with("0x8007007E:") + || error.reason.starts_with("0x8007007F:")) => + { + assert_eq!(lease_count(kind), 0); + eprintln!( + "[subsystem-test] SKIP unavailable {}: {}", + kind.name(), + error.reason + ); + continue; + } + Err(error) => panic!("{} initialization failed: {error}", kind.name()), + }; + let second = initialize(kind.name()).unwrap(); + first.close().unwrap(); + require(&second, kind.name()).unwrap(); + second.close().unwrap(); + assert_eq!(lease_count(kind), 0); + initialize(kind.name()).unwrap().close().unwrap(); + } + } +} diff --git a/bindings/js/src/win32_subsystem_api.rs b/bindings/js/src/win32_subsystem_api.rs new file mode 100644 index 00000000..38e9194f --- /dev/null +++ b/bindings/js/src/win32_subsystem_api.rs @@ -0,0 +1,297 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::{ + ffi::{c_void, CStr}, + sync::{Arc, Mutex}, +}; + +use dynwinrt::win32::module::SystemModule; +use windows::core::HRESULT; +use windows::Win32::{ + Graphics::GdiPlus::{GdiplusStartupInput, GdiplusStartupOutput, Status}, + Networking::WinSock::WSADATA, +}; + +use super::{MAPI_DEINIT_EXPORT, MAPI_INIT_EXPORT}; + +struct SuccessCache { + value: Mutex>>, +} + +impl SuccessCache { + const fn new() -> Self { + Self { + value: Mutex::new(None), + } + } + + fn get_or_try_init(&self, initialize: impl FnOnce() -> napi::Result) -> napi::Result> { + if let Some(value) = self + .value + .lock() + .unwrap_or_else(|error| error.into_inner()) + .as_ref() + .cloned() + { + return Ok(value); + } + let complete = Arc::new(initialize()?); + let published = { + let mut value = self.value.lock().unwrap_or_else(|error| error.into_inner()); + Arc::clone(value.get_or_insert_with(|| Arc::clone(&complete))) + }; + Ok(published) + } +} + +pub(super) struct LoadedApi { + pub(super) functions: F, + _module: Arc, +} + +fn load_api( + dll: &str, + resolve: impl FnOnce(&mut dyn FnMut(&CStr) -> napi::Result<*mut c_void>) -> napi::Result, +) -> napi::Result> { + // These adapters select fixed system DLLs and validate all lifecycle exports before startup. + let module = unsafe { SystemModule::cached(dll) } + .map_err(|error| napi::Error::from_reason(error.message()))?; + let functions = resolve(&mut |name| { + module + .export(name) + .map_err(|error| napi::Error::from_reason(error.message())) + })?; + Ok(LoadedApi { + functions, + _module: module, + }) +} + +fn resolve_exports( + names: [&CStr; N], + resolve: &mut dyn FnMut(&CStr) -> napi::Result<*mut c_void>, +) -> napi::Result<[*mut c_void; N]> { + let mut addresses = [std::ptr::null_mut(); N]; + for (index, name) in names.into_iter().enumerate() { + let address = resolve(name)?; + if address.is_null() { + return Err(napi::Error::from_reason(format!( + "Lifecycle export `{}` has a null address", + name.to_string_lossy() + ))); + } + addresses[index] = address; + } + Ok(addresses) +} + +#[derive(Clone, Copy)] +pub(super) struct WinsockFunctions { + pub(super) startup: unsafe extern "system" fn(u16, *mut WSADATA) -> i32, + pub(super) cleanup: unsafe extern "system" fn() -> i32, + pub(super) last_error: unsafe extern "system" fn() -> i32, +} + +impl WinsockFunctions { + pub(super) fn resolve( + resolver: &mut dyn FnMut(&CStr) -> napi::Result<*mut c_void>, + ) -> napi::Result { + let [startup, cleanup, last_error] = + resolve_exports([c"WSAStartup", c"WSACleanup", c"WSAGetLastError"], resolver)?; + // The table uses the exact WINAPI signatures from winsock2.h. + Ok(Self { + startup: unsafe { + std::mem::transmute::<*mut c_void, unsafe extern "system" fn(u16, *mut WSADATA) -> i32>( + startup, + ) + }, + cleanup: unsafe { + std::mem::transmute::<*mut c_void, unsafe extern "system" fn() -> i32>(cleanup) + }, + last_error: unsafe { + std::mem::transmute::<*mut c_void, unsafe extern "system" fn() -> i32>(last_error) + }, + }) + } +} + +#[derive(Clone, Copy)] +pub(super) struct GdiPlusFunctions { + pub(super) startup: unsafe extern "system" fn( + *mut usize, + *const GdiplusStartupInput, + *mut GdiplusStartupOutput, + ) -> Status, + pub(super) shutdown: unsafe extern "system" fn(usize), +} + +impl GdiPlusFunctions { + pub(super) fn resolve( + resolver: &mut dyn FnMut(&CStr) -> napi::Result<*mut c_void>, + ) -> napi::Result { + let [startup, shutdown] = resolve_exports([c"GdiplusStartup", c"GdiplusShutdown"], resolver)?; + Ok(Self { + startup: unsafe { + std::mem::transmute::< + *mut c_void, + unsafe extern "system" fn( + *mut usize, + *const GdiplusStartupInput, + *mut GdiplusStartupOutput, + ) -> Status, + >(startup) + }, + shutdown: unsafe { + std::mem::transmute::<*mut c_void, unsafe extern "system" fn(usize)>(shutdown) + }, + }) + } +} + +#[derive(Clone, Copy)] +pub(super) struct MediaFoundationFunctions { + pub(super) startup: unsafe extern "system" fn(u32, u32) -> HRESULT, + pub(super) shutdown: unsafe extern "system" fn() -> HRESULT, +} + +impl MediaFoundationFunctions { + pub(super) fn resolve( + resolver: &mut dyn FnMut(&CStr) -> napi::Result<*mut c_void>, + ) -> napi::Result { + let [startup, shutdown] = resolve_exports([c"MFStartup", c"MFShutdown"], resolver)?; + Ok(Self { + startup: unsafe { + std::mem::transmute::<*mut c_void, unsafe extern "system" fn(u32, u32) -> HRESULT>(startup) + }, + shutdown: unsafe { + std::mem::transmute::<*mut c_void, unsafe extern "system" fn() -> HRESULT>(shutdown) + }, + }) + } +} + +#[derive(Clone, Copy)] +pub(super) struct MapiUtilityFunctions { + pub(super) initialize: unsafe extern "system" fn(u32) -> i32, + pub(super) deinitialize: unsafe extern "system" fn(), +} + +impl MapiUtilityFunctions { + pub(super) fn resolve( + resolver: &mut dyn FnMut(&CStr) -> napi::Result<*mut c_void>, + ) -> napi::Result { + let [initialize, deinitialize] = + resolve_exports([MAPI_INIT_EXPORT, MAPI_DEINIT_EXPORT], resolver)?; + Ok(Self { + initialize: unsafe { + std::mem::transmute::<*mut c_void, unsafe extern "system" fn(u32) -> i32>(initialize) + }, + deinitialize: unsafe { + std::mem::transmute::<*mut c_void, unsafe extern "system" fn()>(deinitialize) + }, + }) + } +} + +pub(super) fn winsock() -> napi::Result>> { + static API: SuccessCache> = SuccessCache::new(); + API.get_or_try_init(|| load_api("ws2_32.dll", WinsockFunctions::resolve)) +} + +pub(super) fn gdiplus() -> napi::Result>> { + static API: SuccessCache> = SuccessCache::new(); + API.get_or_try_init(|| load_api("gdiplus.dll", GdiPlusFunctions::resolve)) +} + +pub(super) fn media_foundation() -> napi::Result>> { + static API: SuccessCache> = SuccessCache::new(); + API.get_or_try_init(|| load_api("mfplat.dll", MediaFoundationFunctions::resolve)) +} + +pub(super) fn mapi() -> napi::Result>> { + static API: SuccessCache> = SuccessCache::new(); + API.get_or_try_init(|| load_api("mapi32.dll", MapiUtilityFunctions::resolve)) +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::{ + atomic::{AtomicUsize, Ordering}, + Barrier, + }; + + #[test] + fn failed_table_initialization_is_not_cached_and_complete_tables_are_reused() { + let cache = SuccessCache::new(); + let failed = + cache.get_or_try_init(|| Err::(napi::Error::from_reason("missing export"))); + assert!(failed.is_err()); + assert!(cache.value.lock().unwrap().is_none()); + let complete = cache.get_or_try_init(|| Ok(42)).unwrap(); + let cached = cache + .get_or_try_init(|| panic!("completed table rebuilt")) + .unwrap(); + assert!(Arc::ptr_eq(&complete, &cached)); + assert_eq!(*cached, 42); + } + + #[test] + fn incomplete_or_null_lifecycle_exports_never_publish_a_table() { + unsafe extern "system" fn startup(_: u32, _: u32) -> HRESULT { + panic!("startup must not run while resolving a table"); + } + let mut names = Vec::new(); + let missing = MediaFoundationFunctions::resolve(&mut |name| { + names.push(name.to_owned()); + if name == c"MFStartup" { + Ok(startup as *const () as *mut c_void) + } else { + Err(napi::Error::from_reason("MFShutdown missing")) + } + }); + assert!(missing.is_err()); + assert_eq!(names, [c"MFStartup".to_owned(), c"MFShutdown".to_owned()]); + assert!(WinsockFunctions::resolve(&mut |_| Ok(std::ptr::null_mut())).is_err()); + assert!(GdiPlusFunctions::resolve(&mut |_| Ok(std::ptr::null_mut())).is_err()); + assert!(MapiUtilityFunctions::resolve(&mut |_| Ok(std::ptr::null_mut())).is_err()); + } + + #[test] + fn concurrent_table_publication_keeps_one_complete_owner() { + struct Table(Arc); + impl Drop for Table { + fn drop(&mut self) { + self.0.fetch_add(1, Ordering::SeqCst); + } + } + let cache = Arc::new(SuccessCache::new()); + let barrier = Arc::new(Barrier::new(8)); + let dropped = Arc::new(AtomicUsize::new(0)); + let threads = (0..8) + .map(|_| { + let cache = Arc::clone(&cache); + let barrier = Arc::clone(&barrier); + let dropped = Arc::clone(&dropped); + std::thread::spawn(move || { + cache + .get_or_try_init(|| { + barrier.wait(); + Ok(Table(dropped)) + }) + .unwrap() + }) + }) + .collect::>(); + let tables = threads + .into_iter() + .map(|thread| thread.join().unwrap()) + .collect::>(); + assert!(tables.iter().all(|table| Arc::ptr_eq(table, &tables[0]))); + assert_eq!(dropped.load(Ordering::SeqCst), 7); + drop(tables); + drop(cache); + assert_eq!(dropped.load(Ordering::SeqCst), 8); + } +} diff --git a/bindings/js/src/win32_subsystem_lifecycle_tests.rs b/bindings/js/src/win32_subsystem_lifecycle_tests.rs new file mode 100644 index 00000000..06ad2958 --- /dev/null +++ b/bindings/js/src/win32_subsystem_lifecycle_tests.rs @@ -0,0 +1,354 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::tests::{assert_call_guard_blocks_close, lease_count, TEST_SERIAL}; +use super::*; +use windows::core::HRESULT; +use windows::Win32::Graphics::GdiPlus::{GdiplusStartupOutput, Status}; + +#[derive(Clone, Debug, PartialEq, Eq)] +enum Event { + Startup(u32, u32), + Shutdown(usize), + LastError, +} + +struct State { + kind: SubsystemKind, + load_failed: bool, + startup_status: i32, + shutdown_status: i32, + version: u16, + token: usize, + events: Vec, +} + +static FIXTURES: Mutex> = Mutex::new(Vec::new()); + +pub(super) struct Fixture(SubsystemKind); + +impl Fixture { + pub(super) fn new(kind: SubsystemKind) -> Self { + assert_eq!(lease_count(kind), 0); + let mut fixtures = FIXTURES.lock().unwrap(); + assert!(!fixtures.iter().any(|state| state.kind == kind)); + fixtures.push(State { + kind, + load_failed: false, + startup_status: 0, + shutdown_status: 0, + version: WINSOCK_VERSION_2_2, + token: 17, + events: Vec::new(), + }); + Self(kind) + } + + fn update(&self, update: impl FnOnce(&mut State)) { + let mut fixtures = FIXTURES.lock().unwrap(); + update( + fixtures + .iter_mut() + .find(|state| state.kind == self.0) + .unwrap(), + ); + } + + fn events(&self) -> Vec { + let fixtures = FIXTURES.lock().unwrap(); + fixtures + .iter() + .find(|state| state.kind == self.0) + .unwrap() + .events + .clone() + } +} + +impl Drop for Fixture { + fn drop(&mut self) { + assert_eq!(lease_count(self.0), 0); + if self.0 == SubsystemKind::Winsock { + assert!(!WINSOCK_STATE.lock().unwrap().rollback_pending); + } + FIXTURES + .lock() + .unwrap() + .retain(|state| state.kind != self.0); + } +} + +fn available(kind: SubsystemKind) -> Option> { + let fixtures = FIXTURES.lock().unwrap(); + let state = fixtures.iter().find(|state| state.kind == kind)?; + Some(if state.load_failed { + Err(napi::Error::from_reason( + "0x8007007E: fixture lifecycle DLL is unavailable", + )) + } else { + Ok(()) + }) +} + +fn native(kind: SubsystemKind, action: impl FnOnce(&mut State) -> i32) -> i32 { + let mut fixtures = FIXTURES.lock().unwrap(); + action( + fixtures + .iter_mut() + .find(|state| state.kind == kind) + .unwrap(), + ) +} + +unsafe extern "system" fn winsock_startup(version: u16, data: *mut WSADATA) -> i32 { + native(SubsystemKind::Winsock, |state| { + state.events.push(Event::Startup(u32::from(version), 0)); + if state.startup_status == 0 { + unsafe { + data.write(WSADATA::default()); + (*data).wVersion = state.version; + } + } + state.startup_status + }) +} + +unsafe extern "system" fn winsock_cleanup() -> i32 { + native(SubsystemKind::Winsock, |state| { + state.events.push(Event::Shutdown(0)); + state.shutdown_status + }) +} + +unsafe extern "system" fn winsock_last_error() -> i32 { + native(SubsystemKind::Winsock, |state| { + state.events.push(Event::LastError); + 10093 + }) +} + +unsafe extern "system" fn gdi_startup( + token: *mut usize, + input: *const GdiplusStartupInput, + _output: *mut GdiplusStartupOutput, +) -> Status { + Status(native(SubsystemKind::GdiPlus, |state| { + state + .events + .push(Event::Startup(unsafe { (*input).GdiplusVersion }, 0)); + if state.startup_status == 0 { + unsafe { token.write(state.token) }; + } + state.startup_status + })) +} + +unsafe extern "system" fn gdi_shutdown(token: usize) { + native(SubsystemKind::GdiPlus, |state| { + state.events.push(Event::Shutdown(token)); + 0 + }); +} + +unsafe extern "system" fn media_startup(version: u32, flags: u32) -> HRESULT { + HRESULT(native(SubsystemKind::MediaFoundation, |state| { + state.events.push(Event::Startup(version, flags)); + state.startup_status + })) +} + +unsafe extern "system" fn media_shutdown() -> HRESULT { + HRESULT(native(SubsystemKind::MediaFoundation, |state| { + state.events.push(Event::Shutdown(0)); + state.shutdown_status + })) +} + +pub(super) fn winsock_functions() -> Option> { + Some( + available(SubsystemKind::Winsock)?.map(|()| WinsockFunctions { + startup: winsock_startup, + cleanup: winsock_cleanup, + last_error: winsock_last_error, + }), + ) +} + +pub(super) fn gdiplus_functions() -> Option> { + Some( + available(SubsystemKind::GdiPlus)?.map(|()| GdiPlusFunctions { + startup: gdi_startup, + shutdown: gdi_shutdown, + }), + ) +} + +pub(super) fn media_foundation_functions() -> Option> { + Some( + available(SubsystemKind::MediaFoundation)?.map(|()| MediaFoundationFunctions { + startup: media_startup, + shutdown: media_shutdown, + }), + ) +} + +#[test] +fn unavailable_lifecycle_tables_publish_no_context_and_allow_retry() { + let _serial = TEST_SERIAL.lock().unwrap(); + for kind in [ + SubsystemKind::Winsock, + SubsystemKind::GdiPlus, + SubsystemKind::MediaFoundation, + ] { + let fixture = Fixture::new(kind); + fixture.update(|state| state.load_failed = true); + assert!(initialize(kind.name()) + .err() + .unwrap() + .reason + .contains("unavailable")); + assert_eq!(lease_count(kind), 0); + assert!(fixture.events().is_empty()); + fixture.update(|state| state.load_failed = false); + let context = initialize(kind.name()).unwrap(); + context.close().unwrap(); + assert_eq!(fixture.events().len(), 2); + } +} + +#[test] +fn startup_failure_is_retryable_and_multiple_contexts_share_one_activation() { + let _serial = TEST_SERIAL.lock().unwrap(); + for kind in [ + SubsystemKind::Winsock, + SubsystemKind::GdiPlus, + SubsystemKind::MediaFoundation, + ] { + let fixture = Fixture::new(kind); + fixture.update(|state| { + state.startup_status = if kind == SubsystemKind::MediaFoundation { + 0x80004005u32 as i32 + } else { + 1 + }; + }); + assert!(initialize(kind.name()).is_err()); + assert_eq!(lease_count(kind), 0); + assert_eq!(fixture.events().len(), 1); + fixture.update(|state| state.startup_status = 0); + let first = initialize(kind.name()).unwrap(); + let second = initialize(kind.name()).unwrap(); + first.close().unwrap(); + assert_eq!(lease_count(kind), 1); + require(&second, kind.name()).unwrap(); + assert_eq!(fixture.events().len(), 2); + second.close().unwrap(); + assert_eq!(fixture.events().len(), 3); + let restarted = initialize(kind.name()).unwrap(); + restarted.close().unwrap(); + assert_eq!(fixture.events().len(), 5); + } +} + +#[test] +fn final_shutdown_failure_keeps_context_active_and_retryable() { + let _serial = TEST_SERIAL.lock().unwrap(); + for kind in [SubsystemKind::Winsock, SubsystemKind::MediaFoundation] { + let fixture = Fixture::new(kind); + let context = initialize(kind.name()).unwrap(); + fixture.update(|state| state.shutdown_status = 0x80004005u32 as i32); + let failed = context.close().is_err(); + let still_active = !context.closed() && lease_count(kind) == 1; + let usable = require(&context, kind.name()).is_ok(); + fixture.update(|state| state.shutdown_status = 0); + context.close().unwrap(); + assert!(failed && still_active && usable); + assert!(context.closed()); + assert_eq!(lease_count(kind), 0); + if kind == SubsystemKind::Winsock { + assert!(fixture.events().contains(&Event::LastError)); + } + } +} + +#[test] +fn winsock_version_rollback_is_reported_and_retried_before_startup() { + let _serial = TEST_SERIAL.lock().unwrap(); + let fixture = Fixture::new(SubsystemKind::Winsock); + fixture.update(|state| { + state.version = 0x0101; + state.shutdown_status = -1; + }); + let failed = initialize("winsock").err().unwrap(); + assert!(failed.reason.contains("rollback failed")); + assert_eq!(lease_count(SubsystemKind::Winsock), 0); + assert!(WINSOCK_STATE.lock().unwrap().rollback_pending); + assert!(initialize("winsock") + .err() + .unwrap() + .reason + .contains("still pending")); + assert_eq!( + fixture.events(), + [ + Event::Startup(0x0202, 0), + Event::Shutdown(0), + Event::LastError, + Event::Shutdown(0), + Event::LastError, + ] + ); + fixture.update(|state| { + state.version = WINSOCK_VERSION_2_2; + state.shutdown_status = 0; + }); + let context = initialize("winsock").unwrap(); + assert!(!WINSOCK_STATE.lock().unwrap().rollback_pending); + context.close().unwrap(); + assert_eq!( + &fixture.events()[5..], + [ + Event::Shutdown(0), + Event::Startup(0x0202, 0), + Event::Shutdown(0), + ] + ); +} + +#[test] +fn invalid_gdiplus_token_is_not_published_or_guessed_for_shutdown() { + let _serial = TEST_SERIAL.lock().unwrap(); + let fixture = Fixture::new(SubsystemKind::GdiPlus); + fixture.update(|state| state.token = 0); + assert!(initialize("gdiplus") + .err() + .unwrap() + .reason + .contains("invalid token")); + assert_eq!(lease_count(SubsystemKind::GdiPlus), 0); + assert_eq!(fixture.events(), [Event::Startup(1, 0)]); + fixture.update(|state| state.token = 17); + initialize("gdiplus").unwrap().close().unwrap(); + assert_eq!( + fixture.events(), + [ + Event::Startup(1, 0), + Event::Startup(1, 0), + Event::Shutdown(17), + ] + ); +} + +#[test] +fn all_optional_lifecycle_tables_keep_call_guards_through_shutdown() { + let _serial = TEST_SERIAL.lock().unwrap(); + for kind in [ + SubsystemKind::Winsock, + SubsystemKind::GdiPlus, + SubsystemKind::MediaFoundation, + ] { + let fixture = Fixture::new(kind); + assert_call_guard_blocks_close(kind.name()); + assert_eq!(fixture.events().len(), 2); + } +} diff --git a/crates/dynwinrt-win32-contracts/Cargo.toml b/crates/dynwinrt-win32-contracts/Cargo.toml new file mode 100644 index 00000000..2ea28024 --- /dev/null +++ b/crates/dynwinrt-win32-contracts/Cargo.toml @@ -0,0 +1,19 @@ +[package] +name = "dynwinrt-win32-contracts" +version = "0.1.0" +edition = "2024" +license = "MIT" +description = "Native-independent Win32 call contracts and structural validation" +repository = "https://github.com/microsoft/dynwinrt" +authors = ["Microsoft"] + +[features] +schema = ["dep:schemars"] + +[dependencies] +serde = { version = "1", features = ["derive"] } +serde_json = "1" +schemars = { version = "1", optional = true } + +[dev-dependencies] +schemars = "1" diff --git a/crates/dynwinrt-win32-contracts/src/legacy.rs b/crates/dynwinrt-win32-contracts/src/legacy.rs new file mode 100644 index 00000000..91c6558f --- /dev/null +++ b/crates/dynwinrt-win32-contracts/src/legacy.rs @@ -0,0 +1,162 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use crate::*; + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct OutputRule { + pub parameter: usize, + pub when: Condition, + pub action: OutputAction, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde( + tag = "kind", + rename_all = "kebab-case", + rename_all_fields = "camelCase", + deny_unknown_fields +)] +pub enum OutputAction { + Unavailable {}, + AliasInput { parameter: usize }, +} + +impl CallContract { + /// Metadata ownership transfers alone do not prove an output pointer is + /// defined on failure. Such a guarantee requires an explicit result policy. + pub fn upgrade_metadata(&self, shape: &SignatureShape) -> Result { + let mut contract = self.upgrade(shape)?; + if self.version == LEGACY_VERSION { + for result in &mut contract.results { + if matches!( + result.on_failure, + ResultPolicy::Defined { + ownership: ResultOwnership::Owned { .. }, + .. + } + ) { + result.on_failure = ResultPolicy::Undefined {}; + } + } + } + Ok(contract) + } + + /// Resolves legacy behavior into explicit, versioned result policies. + /// Metadata planners may replace any policy with stronger reviewed evidence. + pub fn upgrade(&self, shape: &SignatureShape) -> Result { + self.validate_structure()?; + if matches!(self.version, SLOT_VERSION | CURRENT_VERSION) { + let mut contract = self.clone(); + contract.version = CURRENT_VERSION; + contract.validate_signature(shape)?; + return Ok(contract); + } + let mut contract = Self::defaults(shape); + contract.resource_effects.clone_from(&self.resource_effects); + for rule in &self.outputs { + let target = ResultTarget::Parameter { + index: rule.parameter, + }; + let output = contract + .results + .iter_mut() + .find(|output| output.target == target) + .ok_or_else(|| { + ContractError::new("Legacy output rule does not target a native output") + })?; + match rule.action { + OutputAction::Unavailable {} => { + output.overrides.push(ResultOverride { + when: rule.when.clone(), + policy: ResultPolicy::Undefined {}, + }); + } + OutputAction::AliasInput { parameter } => { + let source = shape + .parameters + .get(parameter) + .ok_or_else(|| ContractError::new("Legacy alias input is missing"))?; + let target_shape = &shape.parameters[rule.parameter]; + if target_shape.typ != NativeType::Handle + || target_shape.direction != Direction::Out + || !target_shape.cleanup.owns_resource() + || source.typ != NativeType::Handle + || source.direction != Direction::In + || source.consumes_resource + || source.resource_cleanup != target_shape.cleanup + { + return Err(ContractError::new( + "Legacy alias ownership does not match its input handle", + )); + } + for succeeded in [true, false] { + if !succeeded && shape.success_rule == SuccessRule::Always { + continue; + } + if rule + .when + .return_value + .is_some_and(|bits| shape.succeeds(bits) != succeeded) + { + continue; + } + let mut when = rule.when.clone(); + when.succeeded = Some(succeeded); + output.overrides.push(ResultOverride { + when, + policy: if succeeded { + ResultPolicy::delivered(ResultOwnership::AliasInput { parameter }) + } else { + ResultPolicy::Undefined {} + }, + }); + } + } + } + } + contract.validate_signature(shape)?; + Ok(contract) + } + + pub fn defaults(shape: &SignatureShape) -> Self { + let results = shape + .result_targets() + .map(|target| { + let typ = shape + .result_type(target) + .expect("a declared result has a type"); + let cleanup = shape.result_cleanup(target); + let ownership = if cleanup.owns_resource() { + ResultOwnership::Owned { cleanup } + } else if typ.is_pointer() { + ResultOwnership::Borrowed {} + } else { + ResultOwnership::Value {} + }; + ResultContract { + target, + on_success: ResultPolicy::delivered(ownership), + on_failure: match ownership { + ResultOwnership::Owned { .. } + if matches!( + target, + ResultTarget::Return {} | ResultTarget::AggregateField { .. } + ) => + { + ResultPolicy::Undefined {} + } + ResultOwnership::Owned { .. } => ResultPolicy::discarded(ownership), + _ => ResultPolicy::delivered(ownership), + }, + overrides: Vec::new(), + } + }) + .collect(); + Self::current(results, Vec::new()) + } +} diff --git a/crates/dynwinrt-win32-contracts/src/lib.rs b/crates/dynwinrt-win32-contracts/src/lib.rs new file mode 100644 index 00000000..3ba4330c --- /dev/null +++ b/crates/dynwinrt-win32-contracts/src/lib.rs @@ -0,0 +1,319 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Win32-only wire contracts. This crate has no Windows, libffi or language binding dependency. + +mod legacy; +mod shape; +mod validation; + +pub use legacy::{OutputAction, OutputRule}; +use serde::{Deserialize, Serialize}; +pub use shape::{ + Direction, NativeType, ParameterShape, ResultFieldShape, SignatureShape, SuccessRule, +}; +pub use validation::validate_condition_structure; + +pub const CURRENT_VERSION: u32 = 3; +pub const SLOT_VERSION: u32 = 2; +pub const LEGACY_VERSION: u32 = 1; +pub const MAX_CONTRACT_BYTES: usize = 1024 * 1024; +pub const MAX_PARAMETERS: usize = 1024; +pub type Result = std::result::Result; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ContractError(String); + +impl ContractError { + pub fn new(message: impl Into) -> Self { + Self(message.into()) + } +} + +impl std::fmt::Display for ContractError { + fn fmt(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + formatter.write_str(&self.0) + } +} + +impl std::error::Error for ContractError {} + +const fn legacy_version() -> u32 { + LEGACY_VERSION +} + +fn string_enum<'de, D, T>(deserializer: D) -> std::result::Result +where + D: serde::Deserializer<'de>, + T: Deserialize<'de>, +{ + T::deserialize(serde::de::value::StringDeserializer::::new( + String::deserialize(deserializer)?, + )) +} + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct CallContract { + #[serde(default = "legacy_version")] + pub version: u32, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub outputs: Vec, + #[serde(default, skip_serializing_if = "Vec::is_empty")] + pub results: Vec, + #[serde(default)] + pub resource_effects: Vec, +} + +impl Default for CallContract { + fn default() -> Self { + Self { + version: LEGACY_VERSION, + outputs: Vec::new(), + results: Vec::new(), + resource_effects: Vec::new(), + } + } +} + +impl CallContract { + pub fn decode(json: &str) -> Result { + if json.len() > MAX_CONTRACT_BYTES { + return Err(ContractError::new( + "Win32 call contract exceeds the descriptor size limit", + )); + } + let contract: Self = serde_json::from_str(json) + .map_err(|error| ContractError::new(format!("Invalid Win32 call contract: {error}")))?; + contract.validate_structure()?; + Ok(contract) + } + + pub fn is_empty(&self) -> bool { + self.outputs.is_empty() && self.results.is_empty() && self.resource_effects.is_empty() + } + + pub fn current(results: Vec, resource_effects: Vec) -> Self { + Self { + version: CURRENT_VERSION, + outputs: Vec::new(), + results, + resource_effects, + } + } + + pub fn result(&self, target: ResultTarget) -> Option<&ResultContract> { + self.results.iter().find(|result| result.target == target) + } + + pub fn changes_resource(&self, parameter: usize) -> bool { + self.resource_effects.iter().any(|effect| matches!( + effect, ResourceEffect::AddFileCompletionModes { handle_parameter, .. } if *handle_parameter == parameter + )) + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)] +pub enum ResultTarget { + Return {}, + Parameter { index: usize }, + AggregateField { parameter: usize, field: usize }, +} + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct ResultContract { + pub target: ResultTarget, + pub on_success: ResultPolicy, + pub on_failure: ResultPolicy, + #[serde(default)] + pub overrides: Vec, +} + +impl ResultContract { + pub fn policies(&self) -> impl Iterator { + [&self.on_success, &self.on_failure] + .into_iter() + .chain(self.overrides.iter().map(|rule| &rule.policy)) + } + + pub fn may_be_unavailable(&self) -> bool { + self.policies().any(|policy| !policy.is_delivered()) + } + + pub fn may_alias(&self) -> bool { + self.policies().any(|policy| { + matches!( + policy, + ResultPolicy::Defined { + ownership: ResultOwnership::AliasInput { .. }, + .. + } + ) + }) + } +} + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct ResultOverride { + pub when: Condition, + pub policy: ResultPolicy, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)] +pub enum ResultPolicy { + Undefined {}, + Defined { + ownership: ResultOwnership, + #[serde(deserialize_with = "string_enum")] + delivery: Delivery, + }, +} + +impl ResultPolicy { + pub const fn delivered(ownership: ResultOwnership) -> Self { + Self::Defined { + ownership, + delivery: Delivery::Deliver, + } + } + + pub const fn discarded(ownership: ResultOwnership) -> Self { + Self::Defined { + ownership, + delivery: Delivery::Discard, + } + } + + pub const fn is_delivered(self) -> bool { + matches!( + self, + Self::Defined { + delivery: Delivery::Deliver, + .. + } + ) + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(rename_all = "kebab-case")] +pub enum Delivery { + Deliver, + Discard, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)] +pub enum ResultOwnership { + Value {}, + Borrowed {}, + Owned { + #[serde(deserialize_with = "string_enum")] + cleanup: Cleanup, + }, + AliasInput { + parameter: usize, + }, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(rename_all = "kebab-case")] +pub enum Cleanup { + None, + CloseHandle, + RegCloseKey, + LocalFree, + GlobalFree, + FreeLibrary, + CloseServiceHandle, + CoTaskMemFree, + CredFree, +} + +impl Cleanup { + pub const fn owns_resource(self) -> bool { + !matches!(self, Self::None) + } +} + +#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub struct Condition { + #[serde(default)] + pub inputs: Vec, + #[serde(default)] + pub return_value: Option, + #[serde(default)] + pub succeeded: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde( + tag = "kind", + rename_all = "kebab-case", + rename_all_fields = "camelCase", + deny_unknown_fields +)] +pub enum InputPredicate { + BitsIn { + parameter: usize, + mask: u64, + values: Vec, + }, + HandleIn { + parameter: usize, + values: Vec, + }, + NullOrEmpty { + parameter: usize, + element_width: u8, + }, +} + +impl InputPredicate { + pub const fn parameter(&self) -> usize { + match self { + Self::BitsIn { parameter, .. } + | Self::HandleIn { parameter, .. } + | Self::NullOrEmpty { parameter, .. } => *parameter, + } + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, Deserialize, Serialize)] +#[cfg_attr(any(test, feature = "schema"), derive(schemars::JsonSchema))] +#[serde( + tag = "kind", + rename_all = "kebab-case", + rename_all_fields = "camelCase", + deny_unknown_fields +)] +pub enum ResourceEffect { + AddFileCompletionModes { + handle_parameter: usize, + flags_parameter: usize, + }, +} + +#[cfg(any(test, feature = "schema"))] +pub fn schema() -> serde_json::Value { + serde_json::to_value(schemars::schema_for!(CallContract)) + .expect("Win32 contract schema is serializable") +} + +#[cfg(test)] +mod tests; diff --git a/crates/dynwinrt-win32-contracts/src/shape.rs b/crates/dynwinrt-win32-contracts/src/shape.rs new file mode 100644 index 00000000..5f1ba9c9 --- /dev/null +++ b/crates/dynwinrt-win32-contracts/src/shape.rs @@ -0,0 +1,168 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use crate::{Cleanup, ContractError, Result, ResultTarget}; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum NativeType { + Bool32, + I8, + U8, + I16, + U16, + I32, + U32, + I64, + U64, + F32, + F64, + Pointer, + FunctionPointer, + Handle, + Aggregate, +} + +impl NativeType { + pub fn integer_mask(self, pointer_width: u8) -> Option { + Some(match self { + Self::I8 | Self::U8 => u8::MAX.into(), + Self::I16 | Self::U16 => u16::MAX.into(), + Self::Bool32 | Self::I32 | Self::U32 => u32::MAX.into(), + Self::I64 | Self::U64 => u64::MAX, + Self::Handle if pointer_width == 32 => u32::MAX.into(), + Self::Handle if pointer_width == 64 => u64::MAX, + _ => return None, + }) + } + + pub const fn is_pointer(self) -> bool { + matches!(self, Self::Pointer | Self::Handle | Self::FunctionPointer) + } +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum Direction { + In, + Out, + InOut, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum SuccessRule { + Always, + ReturnZero, + ReturnNonZero, + ReturnNonNull, + HResultSucceeded, + SignedNonNegative, + ReturnValidHandle, +} + +#[derive(Clone, Debug)] +pub struct ParameterShape { + pub typ: NativeType, + pub direction: Direction, + pub cleanup: Cleanup, + pub resource_cleanup: Cleanup, + pub consumes_resource: bool, + pub result_fields: Vec, +} + +#[derive(Clone, Debug)] +pub struct ResultFieldShape { + pub typ: NativeType, + pub cleanup: Cleanup, +} + +#[derive(Clone, Debug)] +pub struct SignatureShape { + pub pointer_width: u8, + pub parameters: Vec, + pub return_type: Option, + pub return_cleanup: Cleanup, + pub success_rule: SuccessRule, +} + +impl SignatureShape { + pub fn result_targets(&self) -> impl Iterator + '_ { + self.return_type + .iter() + .map(|_| ResultTarget::Return {}) + .chain( + self.parameters + .iter() + .enumerate() + .filter_map(|(index, parameter)| { + (parameter.direction != Direction::In) + .then_some(ResultTarget::Parameter { index }) + }), + ) + .chain( + self.parameters + .iter() + .enumerate() + .flat_map(|(parameter, shape)| { + (0..shape.result_fields.len()) + .map(move |field| ResultTarget::AggregateField { parameter, field }) + }), + ) + } + + pub fn result_type(&self, target: ResultTarget) -> Result { + match target { + ResultTarget::Return {} => self + .return_type + .ok_or_else(|| ContractError::new("Void return has no result slot")), + ResultTarget::Parameter { index } => self + .parameters + .get(index) + .filter(|parameter| parameter.direction != Direction::In) + .map(|parameter| parameter.typ) + .ok_or_else(|| { + ContractError::new("Result target is not a native output parameter") + }), + ResultTarget::AggregateField { parameter, field } => self + .parameters + .get(parameter) + .and_then(|parameter| parameter.result_fields.get(field)) + .map(|field| field.typ) + .ok_or_else(|| { + ContractError::new("Result target is not a declared aggregate field") + }), + } + } + + pub fn result_cleanup(&self, target: ResultTarget) -> Cleanup { + match target { + ResultTarget::Return {} => self.return_cleanup, + ResultTarget::Parameter { index } => self.parameters[index].cleanup, + ResultTarget::AggregateField { parameter, field } => { + self.parameters[parameter].result_fields[field].cleanup + } + } + } + + pub fn succeeds(&self, bits: u64) -> bool { + match self.success_rule { + SuccessRule::Always => true, + SuccessRule::ReturnZero => bits == 0, + SuccessRule::ReturnNonZero | SuccessRule::ReturnNonNull => bits != 0, + SuccessRule::HResultSucceeded => bits as u32 as i32 >= 0, + SuccessRule::SignedNonNegative => match self.return_type { + Some(NativeType::I8) => bits as u8 as i8 >= 0, + Some(NativeType::I16) => bits as u16 as i16 >= 0, + Some(NativeType::I32) => bits as u32 as i32 >= 0, + _ => bits as i64 >= 0, + }, + SuccessRule::ReturnValidHandle => { + bits != 0 + && bits + != if self.pointer_width == 32 { + u32::MAX.into() + } else { + u64::MAX + } + } + } + } +} diff --git a/crates/dynwinrt-win32-contracts/src/tests.rs b/crates/dynwinrt-win32-contracts/src/tests.rs new file mode 100644 index 00000000..b9b815d0 --- /dev/null +++ b/crates/dynwinrt-win32-contracts/src/tests.rs @@ -0,0 +1,291 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; + +fn registry_shape() -> SignatureShape { + SignatureShape { + pointer_width: 64, + parameters: vec![ + ParameterShape { + typ: NativeType::Handle, + direction: Direction::In, + cleanup: Cleanup::None, + resource_cleanup: Cleanup::RegCloseKey, + consumes_resource: false, + result_fields: Vec::new(), + }, + ParameterShape { + typ: NativeType::Pointer, + direction: Direction::In, + cleanup: Cleanup::None, + resource_cleanup: Cleanup::None, + consumes_resource: false, + result_fields: Vec::new(), + }, + ParameterShape { + typ: NativeType::Handle, + direction: Direction::Out, + cleanup: Cleanup::RegCloseKey, + resource_cleanup: Cleanup::None, + consumes_resource: false, + result_fields: Vec::new(), + }, + ], + return_type: Some(NativeType::I32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::ReturnZero, + } +} + +#[test] +fn legacy_descriptors_upgrade_to_complete_explicit_result_contracts() { + let legacy = CallContract::decode(r#"{"outputs":[{"parameter":2,"when":{"inputs":[{"kind":"null-or-empty","parameter":1,"elementWidth":2}]},"action":{"kind":"alias-input","parameter":0}}]}"#).unwrap(); + assert_eq!(legacy.version, LEGACY_VERSION); + let current = legacy.upgrade(®istry_shape()).unwrap(); + assert_eq!(current.version, CURRENT_VERSION); + assert!(current.outputs.is_empty()); + assert_eq!(current.results.len(), 2); + let output = current + .result(ResultTarget::Parameter { index: 2 }) + .unwrap(); + assert_eq!(output.overrides.len(), 2); + assert!(output.may_alias()); + assert_eq!(output.overrides[1].policy, ResultPolicy::Undefined {}); + assert_eq!(output.overrides[1].when.succeeded, Some(false)); + current.validate_signature(®istry_shape()).unwrap(); + let round_trip = CallContract::decode(&serde_json::to_string(¤t).unwrap()).unwrap(); + assert_eq!(round_trip, current); +} + +#[test] +fn every_return_and_output_slot_has_one_complete_policy() { + let shape = registry_shape(); + let mut current = CallContract::defaults(&shape); + current.validate_signature(&shape).unwrap(); + current.results.pop(); + assert!( + current + .validate_signature(&shape) + .unwrap_err() + .to_string() + .contains("every") + ); + let mut duplicate = CallContract::defaults(&shape); + duplicate.results.push(duplicate.results[0].clone()); + assert!(duplicate.validate_structure().is_err()); +} + +#[test] +fn undefined_and_defined_discarded_ownership_are_different_states() { + let shape = registry_shape(); + let current = CallContract::defaults(&shape); + let output = current + .result(ResultTarget::Parameter { index: 2 }) + .unwrap(); + assert_eq!( + output.on_failure, + ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: Cleanup::RegCloseKey + }) + ); + assert_ne!(output.on_failure, ResultPolicy::Undefined {}); + assert!(!output.on_failure.is_delivered()); + let invalid = r#"{"version":2,"results":[{"target":{"kind":"return"},"onSuccess":{"kind":"undefined","ownership":{"kind":"owned","cleanup":"reg-close-key"}},"onFailure":{"kind":"undefined"}}]}"#; + assert!(CallContract::decode(invalid).is_err()); +} + +#[test] +fn metadata_owned_output_does_not_infer_defined_failure_storage() { + let shape = registry_shape(); + let legacy = CallContract::default(); + let compatible = legacy.upgrade(&shape).unwrap(); + let generated = legacy.upgrade_metadata(&shape).unwrap(); + let target = ResultTarget::Parameter { index: 2 }; + assert_eq!( + compatible.result(target).unwrap().on_failure, + ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: Cleanup::RegCloseKey + }) + ); + assert_eq!( + generated.result(target).unwrap().on_failure, + ResultPolicy::Undefined {} + ); + generated.validate_signature(&shape).unwrap(); +} + +#[test] +fn direct_return_alias_and_owned_discard_are_validated_like_output_slots() { + let mut shape = registry_shape(); + shape.parameters.pop(); + shape.return_type = Some(NativeType::Handle); + shape.return_cleanup = Cleanup::RegCloseKey; + shape.success_rule = SuccessRule::ReturnNonNull; + let mut contract = CallContract::defaults(&shape); + contract.results[0].on_success = + ResultPolicy::delivered(ResultOwnership::AliasInput { parameter: 0 }); + contract.results[0].on_failure = ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: Cleanup::RegCloseKey, + }); + contract.validate_signature(&shape).unwrap(); + shape.parameters[0].consumes_resource = true; + assert!(contract.validate_signature(&shape).is_err()); +} + +#[test] +fn protocol_versions_and_unknown_fields_fail_closed() { + for json in [ + r#"{"version":0}"#, + r#"{"version":4}"#, + r#"{"version":2,"outputs":[{"parameter":0,"when":{},"action":{"kind":"unavailable"}}]}"#, + r#"{"version":1,"results":[{"target":{"kind":"return"},"onSuccess":{"kind":"undefined"},"onFailure":{"kind":"undefined"}}]}"#, + r#"{"version":2,"unknown":true}"#, + r#"{"version":2,"results":[{"target":{"kind":"return"},"onSuccess":{"kind":"defined","ownership":{"kind":"owned","cleanup":"none"},"delivery":"discard"},"onFailure":{"kind":"undefined"}}]}"#, + r#"{"version":2,"results":[{"target":{"kind":"return","extra":1},"onSuccess":{"kind":"undefined"},"onFailure":{"kind":"undefined"}}]}"#, + r#"{"version":2,"results":[{"target":{"kind":"return"},"onSuccess":{"kind":"defined","ownership":{"kind":"value","cleanup":"reg-close-key"},"delivery":"deliver"},"onFailure":{"kind":"undefined"}}]}"#, + r#"{"version":2,"results":[{"target":{"kind":"return"},"onSuccess":{"kind":"defined","ownership":{"kind":"value"},"delivery":{"deliver":null}},"onFailure":{"kind":"undefined"}}]}"#, + r#"{"version":2,"results":[{"target":{"kind":"return"},"onSuccess":{"kind":"defined","ownership":{"kind":"owned","cleanup":{"reg-close-key":null}},"delivery":"discard"},"onFailure":{"kind":"undefined"}}]}"#, + ] { + assert!(CallContract::decode(json).is_err(), "{json}"); + } + + assert!(CallContract::decode(&" ".repeat(MAX_CONTRACT_BYTES + 1)).is_err()); +} + +#[test] +fn structural_validation_bounds_indices_and_rejects_self_aliases() { + for json in [ + r#"{"outputs":[{"parameter":1024,"when":{},"action":{"kind":"unavailable"}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{"inputs":[{"kind":"handle-in","parameter":1024,"values":[-1]}]},"action":{"kind":"unavailable"}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{},"action":{"kind":"alias-input","parameter":0}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{},"action":{"kind":"alias-input","parameter":1024}}]}"#, + r#"{"resourceEffects":[{"kind":"add-file-completion-modes","handleParameter":0,"flagsParameter":1024}]}"#, + r#"{"version":2,"results":[{"target":{"kind":"parameter","index":1024},"onSuccess":{"kind":"undefined"},"onFailure":{"kind":"undefined"}}]}"#, + r#"{"version":2,"results":[{"target":{"kind":"parameter","index":0},"onSuccess":{"kind":"defined","ownership":{"kind":"alias-input","parameter":0},"delivery":"deliver"},"onFailure":{"kind":"undefined"}}]}"#, + ] { + assert!(CallContract::decode(json).is_err(), "{json}"); + } +} + +#[test] +fn ambiguous_or_contradictory_result_conditions_are_rejected() { + let shape = registry_shape(); + let mut contract = CallContract::defaults(&shape); + let case = ResultOverride { + when: Condition { + return_value: Some(5), + ..Condition::default() + }, + policy: ResultPolicy::Undefined {}, + }; + contract.results[1].overrides = vec![case.clone(), case.clone()]; + assert!( + contract + .validate_signature(&shape) + .unwrap_err() + .to_string() + .contains("overlapping") + ); + contract.results[1].overrides[1].when.return_value = Some(6); + contract.validate_signature(&shape).unwrap(); + contract.results[1].overrides[0].when.succeeded = Some(true); + assert!( + contract + .validate_signature(&shape) + .unwrap_err() + .to_string() + .contains("contradict") + ); +} + +#[test] +fn native_handle_predicates_validate_pointer_width_without_truncation() { + let mut shape = registry_shape(); + let mut contract = CallContract::defaults(&shape); + contract.results[1].overrides.push(ResultOverride { + when: Condition { + inputs: vec![InputPredicate::HandleIn { + parameter: 0, + values: vec![-2147483646], + }], + ..Condition::default() + }, + policy: ResultPolicy::Undefined {}, + }); + contract.validate_signature(&shape).unwrap(); + shape.pointer_width = 32; + contract.validate_signature(&shape).unwrap(); + let InputPredicate::HandleIn { values, .. } = + &mut contract.results[1].overrides[0].when.inputs[0] + else { + unreachable!() + }; + values.push(i64::MAX); + assert!(contract.validate_signature(&shape).is_err()); +} + +#[test] +fn schema_is_derived_from_the_same_serialized_types() { + let schema = schema(); + let defs = schema.get("$defs").unwrap(); + for name in [ + "ResultTarget", + "ResultContract", + "ResultPolicy", + "ResultOwnership", + "InputPredicate", + "ResourceEffect", + ] { + assert!(defs.get(name).is_some(), "{name}"); + } + assert_eq!(schema["additionalProperties"], false); +} + +#[test] +fn aggregate_field_results_are_complete_and_versioned_separately_from_physical_inputs() { + let mut shape = registry_shape(); + shape.parameters.truncate(1); + shape.parameters[0].typ = NativeType::Pointer; + shape.parameters[0].resource_cleanup = Cleanup::None; + shape.parameters[0].result_fields = vec![ + ResultFieldShape { + typ: NativeType::Handle, + cleanup: Cleanup::CloseHandle, + }, + ResultFieldShape { + typ: NativeType::U32, + cleanup: Cleanup::None, + }, + ]; + let mut contract = CallContract::default().upgrade_metadata(&shape).unwrap(); + assert_eq!(contract.version, 3); + assert_eq!(contract.results.len(), 3); + assert!( + contract + .result(ResultTarget::AggregateField { + parameter: 0, + field: 0 + }) + .is_some() + ); + assert!( + contract + .result(ResultTarget::Parameter { index: 0 }) + .is_none() + ); + contract.validate_signature(&shape).unwrap(); + let mut old = contract.clone(); + old.version = SLOT_VERSION; + assert!(old.validate_structure().is_err()); + contract.results.pop(); + assert!(contract.validate_signature(&shape).is_err()); + let previous = CallContract { + version: SLOT_VERSION, + ..CallContract::defaults(®istry_shape()) + }; + assert_eq!( + previous.upgrade(®istry_shape()).unwrap().version, + CURRENT_VERSION + ); +} diff --git a/crates/dynwinrt-win32-contracts/src/validation.rs b/crates/dynwinrt-win32-contracts/src/validation.rs new file mode 100644 index 00000000..519c1835 --- /dev/null +++ b/crates/dynwinrt-win32-contracts/src/validation.rs @@ -0,0 +1,392 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use crate::*; +use std::collections::BTreeSet; + +fn error(message: &str) -> ContractError { + ContractError::new(message) +} + +impl CallContract { + pub fn validate_structure(&self) -> Result<()> { + match self.version { + LEGACY_VERSION if !self.results.is_empty() => { + return Err(error("Version 1 cannot contain version 2 result contracts")); + } + SLOT_VERSION | CURRENT_VERSION if !self.outputs.is_empty() => { + return Err(error( + "Current result contracts cannot contain legacy output actions", + )); + } + LEGACY_VERSION | SLOT_VERSION | CURRENT_VERSION => {} + _ => { + return Err(error( + "Unsupported Win32 call contract version; regenerate bindings with a compatible generator", + )); + } + } + if self.outputs.len() > 1024 + || self.results.len() > 1025 + || self.resource_effects.len() > 1024 + { + return Err(error("Win32 call contract exceeds structural limits")); + } + let mut outputs = BTreeSet::new(); + for rule in &self.outputs { + if rule.parameter >= MAX_PARAMETERS || !outputs.insert(rule.parameter) { + return Err(error("Legacy output rules require unique parameters")); + } + if let OutputAction::AliasInput { parameter } = rule.action + && (parameter >= MAX_PARAMETERS || parameter == rule.parameter) + { + return Err(error( + "Legacy aliases require a distinct bounded input parameter", + )); + } + validate_condition_structure(&rule.when)?; + if rule.when.succeeded.is_some() { + return Err(error( + "Legacy output conditions cannot use version 2 success predicates", + )); + } + } + let mut results = BTreeSet::new(); + for result in &self.results { + if matches!(result.target, ResultTarget::Parameter { index } if index >= MAX_PARAMETERS) + { + return Err(error("Result target exceeds the native parameter limit")); + } + if let ResultTarget::AggregateField { parameter, field } = result.target { + if self.version < CURRENT_VERSION + || parameter >= MAX_PARAMETERS + || field >= MAX_PARAMETERS + { + return Err(error( + "Aggregate field results require version 3 and bounded field indices", + )); + } + } + if !results.insert(result.target) || result.overrides.len() > 32 { + return Err(error( + "Result contracts require unique targets and bounded cases", + )); + } + for policy in result.policies() { + validate_policy_structure(*policy)?; + if let ResultPolicy::Defined { + ownership: ResultOwnership::AliasInput { parameter }, + .. + } = policy + && matches!(result.target, ResultTarget::Parameter { index } if index == *parameter) + { + return Err(error("An output cannot alias itself")); + } + } + for case in &result.overrides { + validate_condition_structure(&case.when)?; + } + } + let mut resources = BTreeSet::new(); + for effect in &self.resource_effects { + let ResourceEffect::AddFileCompletionModes { + handle_parameter, + flags_parameter, + } = *effect; + if handle_parameter >= MAX_PARAMETERS + || flags_parameter >= MAX_PARAMETERS + || handle_parameter == flags_parameter + || !resources.insert(handle_parameter) + { + return Err(error( + "Resource effects require distinct parameters and unique state targets", + )); + } + } + Ok(()) + } + + pub fn validate_signature(&self, shape: &SignatureShape) -> Result<()> { + self.validate_structure()?; + if self.version != CURRENT_VERSION { + return Err(error( + "Legacy contracts must be upgraded before signature validation", + )); + } + if !matches!(shape.pointer_width, 32 | 64) || shape.parameters.len() > 1024 { + return Err(error("Unsupported native signature shape")); + } + for parameter in &shape.parameters { + if !parameter.result_fields.is_empty() + && (parameter.typ != NativeType::Pointer + || parameter.direction != Direction::In + || parameter.result_fields.len() > MAX_PARAMETERS) + { + return Err(error( + "Aggregate result fields require a bounded physical pointer input", + )); + } + } + let expected = shape.result_targets().collect::>(); + let actual = self + .results + .iter() + .map(|result| result.target) + .collect::>(); + if expected != actual { + return Err(error( + "The contract must describe every direct return, output slot and aggregate result field exactly once", + )); + } + for result in &self.results { + for policy in result.policies() { + validate_policy_signature(*policy, result.target, shape)?; + } + for (index, case) in result.overrides.iter().enumerate() { + validate_condition_signature(&case.when, shape)?; + for previous in &result.overrides[..index] { + if !conditions_disjoint(&previous.when, &case.when, shape) { + return Err(error("Ambiguous overlapping result contract cases")); + } + } + } + } + for effect in &self.resource_effects { + let ResourceEffect::AddFileCompletionModes { + handle_parameter, + flags_parameter, + } = *effect; + let handle = shape.parameters.get(handle_parameter); + let flags = shape.parameters.get(flags_parameter); + if !matches!(handle, Some(parameter) if parameter.typ == NativeType::Handle + && parameter.direction == Direction::In && !parameter.consumes_resource + && parameter.resource_cleanup == Cleanup::CloseHandle) + || !matches!(flags, Some(parameter) if parameter.typ == NativeType::U8 + && parameter.direction == Direction::In) + { + return Err(error( + "File state effects require a borrowed CloseHandle resource and native U8 flags", + )); + } + } + Ok(()) + } +} + +fn validate_policy_structure(policy: ResultPolicy) -> Result<()> { + if matches!(policy, ResultPolicy::Defined { + ownership: ResultOwnership::AliasInput { parameter }, .. + } if parameter >= MAX_PARAMETERS) + { + return Err(error("Alias input exceeds the native parameter limit")); + } + if matches!( + policy, + ResultPolicy::Defined { + ownership: ResultOwnership::Owned { + cleanup: Cleanup::None + }, + .. + } + ) { + return Err(error( + "An owned result requires a concrete cleanup contract", + )); + } + Ok(()) +} + +pub fn validate_condition_structure(condition: &Condition) -> Result<()> { + if condition.inputs.len() > 16 { + return Err(error("Too many native input predicates")); + } + for predicate in &condition.inputs { + if predicate.parameter() >= MAX_PARAMETERS { + return Err(error("Predicate input exceeds the native parameter limit")); + } + match predicate { + InputPredicate::BitsIn { mask, values, .. } => { + if *mask == 0 + || values.is_empty() + || values.len() > 64 + || values.iter().any(|value| value & !mask != 0) + || values.iter().copied().collect::>().len() != values.len() + { + return Err(error("Invalid native masked integer predicate")); + } + } + InputPredicate::HandleIn { values, .. } => { + if values.is_empty() + || values.len() > 64 + || values.iter().copied().collect::>().len() != values.len() + { + return Err(error("Invalid native signed handle predicate")); + } + } + InputPredicate::NullOrEmpty { element_width, .. } => { + if !matches!(element_width, 1 | 2) { + return Err(error( + "Native string predicates require byte or UTF-16 width", + )); + } + } + } + } + Ok(()) +} + +fn validate_condition_signature(condition: &Condition, shape: &SignatureShape) -> Result<()> { + if let Some(bits) = condition.return_value { + let mask = shape + .return_type + .and_then(|typ| typ.integer_mask(shape.pointer_width)) + .ok_or_else(|| error("Return predicates require an integer native return"))?; + if bits & !mask != 0 { + return Err(error("Return predicate exceeds the native return width")); + } + if condition + .succeeded + .is_some_and(|succeeded| shape.succeeds(bits) != succeeded) + { + return Err(error("Return and success predicates contradict each other")); + } + } + if condition.succeeded == Some(false) && shape.success_rule == SuccessRule::Always { + return Err(error( + "An always-successful signature cannot match a failure predicate", + )); + } + for (index, predicate) in condition.inputs.iter().enumerate() { + let input = shape + .parameters + .get(predicate.parameter()) + .filter(|input| input.direction != Direction::Out) + .ok_or_else(|| error("A condition refers to a missing native input"))?; + match predicate { + InputPredicate::BitsIn { mask, .. } => { + if !input + .typ + .integer_mask(shape.pointer_width) + .is_some_and(|width| mask & !width == 0) + { + return Err(error( + "Bits predicate does not match the native input width", + )); + } + } + InputPredicate::HandleIn { values, .. } => { + if input.typ != NativeType::Handle + || (shape.pointer_width == 32 + && values.iter().any(|value| i32::try_from(*value).is_err())) + { + return Err(error( + "Handle predicates require pointer-width signed handle values", + )); + } + } + InputPredicate::NullOrEmpty { .. } => { + if input.typ != NativeType::Pointer { + return Err(error("A string condition requires a native data pointer")); + } + } + } + for previous in &condition.inputs[..index] { + if predicates_disjoint(previous, predicate, shape.pointer_width) { + return Err(error("Contradictory native input predicates")); + } + } + } + Ok(()) +} + +fn validate_policy_signature( + policy: ResultPolicy, + target: ResultTarget, + shape: &SignatureShape, +) -> Result<()> { + let typ = shape.result_type(target)?; + let ResultPolicy::Defined { ownership, .. } = policy else { + return Ok(()); + }; + match ownership { + ResultOwnership::Value {} if typ.is_pointer() => { + return Err(error( + "A pointer-shaped result must declare borrowed, owned or alias ownership", + )); + } + ResultOwnership::Borrowed {} if !typ.is_pointer() => { + return Err(error("Borrowed ownership requires a pointer-shaped result")); + } + ResultOwnership::Owned { cleanup } => { + if !matches!(typ, NativeType::Pointer | NativeType::Handle) + || (shape.result_cleanup(target).owns_resource() + && shape.result_cleanup(target) != cleanup) + { + return Err(error( + "Owned result cleanup conflicts with the native result", + )); + } + } + ResultOwnership::AliasInput { parameter } => { + let input = shape + .parameters + .get(parameter) + .ok_or_else(|| error("Alias refers to a missing native input"))?; + if typ != NativeType::Handle + || input.typ != NativeType::Handle + || input.direction != Direction::In + || input.consumes_resource + || (shape.result_cleanup(target).owns_resource() + && input.resource_cleanup != shape.result_cleanup(target)) + { + return Err(error( + "Alias results require a matching non-consuming handle input", + )); + } + } + _ => {} + } + Ok(()) +} + +fn conditions_disjoint(left: &Condition, right: &Condition, shape: &SignatureShape) -> bool { + if matches!((left.succeeded, right.succeeded), (Some(a), Some(b)) if a != b) + || matches!((left.return_value, right.return_value), (Some(a), Some(b)) if a != b) + || matches!((left.return_value, right.succeeded), (Some(bits), Some(success)) if shape.succeeds(bits) != success) + || matches!((right.return_value, left.succeeded), (Some(bits), Some(success)) if shape.succeeds(bits) != success) + { + return true; + } + left.inputs.iter().any(|a| { + right + .inputs + .iter() + .any(|b| predicates_disjoint(a, b, shape.pointer_width)) + }) +} + +fn predicates_disjoint(left: &InputPredicate, right: &InputPredicate, pointer_width: u8) -> bool { + if left.parameter() != right.parameter() { + return false; + } + let bits = |predicate: &InputPredicate| match predicate { + InputPredicate::BitsIn { mask, values, .. } => Some((*mask, values.clone())), + InputPredicate::HandleIn { values, .. } => { + let mask = if pointer_width == 32 { + u32::MAX.into() + } else { + u64::MAX + }; + Some(( + mask, + values.iter().map(|value| (*value as u64) & mask).collect(), + )) + } + InputPredicate::NullOrEmpty { .. } => None, + }; + let (Some((a_mask, a)), Some((b_mask, b))) = (bits(left), bits(right)) else { + return false; + }; + let common = a_mask & b_mask; + a.iter().all(|a| b.iter().all(|b| a & common != b & common)) +} diff --git a/crates/dynwinrt/Cargo.toml b/crates/dynwinrt/Cargo.toml index c1424e96..48ee3908 100644 --- a/crates/dynwinrt/Cargo.toml +++ b/crates/dynwinrt/Cargo.toml @@ -12,9 +12,11 @@ test-hooks = ["windows/Win32_Media_MediaFoundation"] [dependencies] dynwinrt-com-contracts = { path = "../dynwinrt-com-contracts", version = "0.1.0" } +dynwinrt-win32-contracts = { path = "../dynwinrt-win32-contracts", version = "0.1.0" } libffi = "5.1.0" libffi-sys = "4.1.0" paste = "1" +serde = { version = "1", features = ["derive"] } windows-collections = "0.3.2" windows-core = "0.62.2" windows-future = "0.3.2" @@ -24,6 +26,8 @@ windows-metadata = "0.59.0" [dependencies.windows] version = ">=0.59, <=0.62" features = [ + "Wdk_Storage_FileSystem", + "Wdk_System_SystemServices", "ApplicationModel", "ApplicationModel_DataTransfer", "Data_Xml_Dom", @@ -36,12 +40,18 @@ features = [ "Win32_System_Com", "Win32_System_Com_StructuredStorage", "Win32_System_LibraryLoader", + "Win32_System_IO", + "Win32_Storage_FileSystem", + "Win32_System_WindowsProgramming", "Win32_System_Memory", + "Win32_System_Registry", + "Win32_System_Services", "Win32_System_Ole", "Win32_System_Threading", "Win32_System_Variant", "Win32_System_WinRT", "Win32_Graphics_Gdi", + "Win32_Security_Credentials", "Win32_UI_Shell", "Win32_UI_WindowsAndMessaging", "Win32_Storage_Packaging_Appx", @@ -57,7 +67,7 @@ tokio = { version = "1.49.0", features = ["macros", "rt"] } [dev-dependencies.windows] version = ">=0.59, <=0.62" -features = ["Win32_Graphics_Imaging", "Win32_Media_MediaFoundation", "ApplicationModel_Background"] +features = ["Win32_Graphics_Imaging", "Win32_Media_MediaFoundation", "ApplicationModel_Background", "Win32_System_Pipes"] [[bench]] name = "bench" diff --git a/crates/dynwinrt/src/call.rs b/crates/dynwinrt/src/call.rs index d4a92503..c1269668 100644 --- a/crates/dynwinrt/src/call.rs +++ b/crates/dynwinrt/src/call.rs @@ -433,6 +433,38 @@ pub fn get_vtable_function_ptr(obj: *mut c_void, method_index: usize) -> *mut c_ } } +/// Execute an already prepared flat native ABI without a COM receiver. +pub(crate) unsafe fn call_native_function( + cif: &libffi::middle::Cif, + function: *mut c_void, + args: &[Arg<'_>], + return_type: Option, +) -> Option { + use libffi::middle::CodePtr; + + match return_type { + None => { + unsafe { cif.call::<()>(CodePtr(function), args) }; + None + } + Some(AbiType::Bool) => Some(AbiValue::Bool(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::I8) => Some(AbiValue::I8(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::U8) => Some(AbiValue::U8(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::I16) => Some(AbiValue::I16(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::U16) => Some(AbiValue::U16(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::I32) => Some(AbiValue::I32(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::U32) => Some(AbiValue::U32(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::I64) => Some(AbiValue::I64(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::U64) => Some(AbiValue::U64(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::F32) => Some(AbiValue::F32(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::F64) => Some(AbiValue::F64(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::Guid) => Some(AbiValue::Guid(unsafe { cif.call(CodePtr(function), args) })), + Some(AbiType::Ptr) => Some(AbiValue::Pointer(unsafe { + cif.call(CodePtr(function), args) + })), + } +} + pub fn call_winrt_method_0(vtable_index: usize, obj: *mut c_void) -> HRESULT { let method_ptr = get_vtable_function_ptr(obj, vtable_index); unsafe { diff --git a/crates/dynwinrt/src/lib.rs b/crates/dynwinrt/src/lib.rs index a7c799ec..8c0ef736 100644 --- a/crates/dynwinrt/src/lib.rs +++ b/crates/dynwinrt/src/lib.rs @@ -16,6 +16,7 @@ mod result; mod roapi; mod signature; mod value; +pub mod win32; mod winapp; mod winrt_implementation; mod xaml_application; diff --git a/crates/dynwinrt/src/win32.rs b/crates/dynwinrt/src/win32.rs new file mode 100644 index 00000000..d37d71c1 --- /dev/null +++ b/crates/dynwinrt/src/win32.rs @@ -0,0 +1,2213 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Immutable call plans for flat Win32 exports. +//! +//! This module deliberately has its own ABI vocabulary. WinRT and Classic COM +//! types do not participate in flat export planning. + +use core::ffi::c_void; +#[cfg(not(all(windows, target_pointer_width = "32")))] +use std::ffi::CString; +use std::sync::Arc; +#[cfg(all(test, not(all(windows, target_pointer_width = "32"))))] +use std::sync::atomic::{AtomicUsize, Ordering}; + +use libffi::middle::Type as FfiType; +use libffi::middle::{Arg, Cif, Ret, arg}; +use windows::Win32::Foundation::{ + CloseHandle, FreeLibrary, GetLastError, HANDLE, HLOCAL, HMODULE, LocalFree, +}; +use windows::Win32::Security::Credentials::CredFree; +use windows::Win32::System::Registry::{HKEY, RegCloseKey}; +use windows::Win32::System::Services::{CloseServiceHandle, SC_HANDLE}; +use windows_core::HRESULT; + +use crate::abi::{AbiType, AbiValue}; +#[cfg(not(all(windows, target_pointer_width = "32")))] +use crate::native_call::system_cif; +use crate::result::{Error, Result}; + +#[path = "win32_aggregate.rs"] +mod aggregate; +pub use aggregate::{ + AggregateResultField, NativeAggregateBuffer, NativeAggregateLease, NativeAggregatePointerLayout, +}; + +#[path = "win32_contract.rs"] +mod contract; +pub use contract::{ + CallContract, Condition, Delivery, InputPredicate, OutputAction, OutputRule, ResourceEffect, + ResultContract, ResultOverride, ResultOwnership, ResultPolicy, ResultTarget, +}; + +#[path = "win32_resource.rs"] +mod resource; +pub use resource::{ + FileCapability, OwnedResource, OwnedResourceAsyncLease, OwnedResourceLease, ResourceAccess, +}; + +#[doc(hidden)] +#[path = "win32_module.rs"] +pub mod module; +#[cfg(not(all(windows, target_pointer_width = "32")))] +use module::{SystemModule, is_bare_system_module_name}; + +#[path = "win32_io.rs"] +pub mod io; + +const E_INVALIDARG: HRESULT = HRESULT(0x80070057u32 as i32); +#[cfg(all(windows, target_pointer_width = "32"))] +const E_NOTIMPL: HRESULT = HRESULT(0x80004001u32 as i32); +pub const MAX_NATIVE_AGGREGATE_SIZE: usize = 16 * 1024 * 1024; + +windows_link::link!("kernel32.dll" "system" "GlobalFree" fn global_free_raw(hmem: *mut c_void) -> *mut c_void); + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Type { + Bool32, + I8, + U8, + I16, + U16, + I32, + U32, + I64, + U64, + F32, + F64, + Pointer, + FunctionPointer, + Handle, +} + +#[derive(Debug, Clone)] +pub struct NativeAggregateLayout { + identity: String, + size: usize, + alignment: usize, + ffi_type: FfiType, +} + +impl PartialEq for NativeAggregateLayout { + fn eq(&self, other: &Self) -> bool { + self.identity == other.identity + && self.size == other.size + && self.alignment == other.alignment + && unsafe { same_ffi_type(self.ffi_type.as_raw_ptr(), other.ffi_type.as_raw_ptr()) } + } +} + +impl Eq for NativeAggregateLayout {} + +unsafe fn same_ffi_type( + left: *const libffi_sys::ffi_type, + right: *const libffi_sys::ffi_type, +) -> bool { + if left == right { + return true; + } + let (left, right) = unsafe { (&*left, &*right) }; + if left.type_ != right.type_ { + return false; + } + if left.type_ as u32 != libffi::low::type_tag::STRUCT as u32 { + return left.size == right.size && left.alignment == right.alignment; + } + // Aggregate size/alignment can be uncached in a cloned type graph. The + // complete element graph defines its ABI; the outer layout is validated + // against a prepared CIF before publication. + let (mut left, mut right) = (left.elements, right.elements); + loop { + let (left_child, right_child) = unsafe { (*left, *right) }; + if left_child.is_null() || right_child.is_null() { + return left_child == right_child; + } + if !unsafe { same_ffi_type(left_child, right_child) } { + return false; + } + (left, right) = unsafe { (left.add(1), right.add(1)) }; + } +} + +impl NativeAggregateLayout { + pub fn new( + identity: impl Into, + size: usize, + alignment: usize, + ffi_type: FfiType, + ) -> Result> { + let identity = identity.into(); + if identity.trim().is_empty() + || size == 0 + || alignment == 0 + || !alignment.is_power_of_two() + || size % alignment != 0 + || alignment > 8 + || size > MAX_NATIVE_AGGREGATE_SIZE + { + return Err(invalid_argument("invalid native aggregate call layout")); + } + let raw = unsafe { &*ffi_type.as_raw_ptr() }; + if raw.type_ as u32 != libffi::low::type_tag::STRUCT as u32 + || raw.elements.is_null() + || unsafe { (*raw.elements).is_null() } + { + return Err(invalid_argument( + "native aggregate requires a nonempty libffi struct", + )); + } + let probe = Cif::new(Vec::new(), ffi_type.clone()); + let actual = unsafe { &*(*probe.as_raw_ptr()).rtype }; + if actual.size != size || usize::from(actual.alignment) != alignment { + return Err(invalid_argument( + "native aggregate layout disagrees with the target ABI", + )); + } + Ok(Arc::new(Self { + identity, + size, + alignment, + ffi_type, + })) + } + + pub fn identity(&self) -> &str { + &self.identity + } + + pub const fn size(&self) -> usize { + self.size + } + + #[cfg(not(all(windows, target_pointer_width = "32")))] + fn libffi_type(&self) -> FfiType { + self.ffi_type.clone() + } +} + +impl Type { + fn abi_type(self) -> AbiType { + match self { + Self::Bool32 | Self::I32 => AbiType::I32, + Self::I8 => AbiType::I8, + Self::U8 => AbiType::U8, + Self::I16 => AbiType::I16, + Self::U16 => AbiType::U16, + Self::U32 => AbiType::U32, + Self::I64 => AbiType::I64, + Self::U64 => AbiType::U64, + Self::F32 => AbiType::F32, + Self::F64 => AbiType::F64, + Self::Pointer | Self::FunctionPointer | Self::Handle => AbiType::Ptr, + } + } + + #[cfg(not(all(windows, target_pointer_width = "32")))] + fn is_pointer_like(self) -> bool { + matches!(self, Self::Pointer | Self::FunctionPointer | Self::Handle) + } + + fn default_abi_value(self) -> AbiValue { + self.abi_type().default_value() + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Direction { + In, + Out, + InOut, +} + +impl Direction { + #[cfg(not(all(windows, target_pointer_width = "32")))] + fn is_input(self) -> bool { + matches!(self, Self::In | Self::InOut) + } + + fn is_output(self) -> bool { + matches!(self, Self::Out | Self::InOut) + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Cleanup { + None, + CloseHandle, + RegCloseKey, + LocalFree, + GlobalFree, + FreeLibrary, + CloseServiceHandle, + CoTaskMemFree, + CredFree, +} + +impl Cleanup { + fn owns_resource(self) -> bool { + self != Self::None + } + + unsafe fn run(self, value: usize) -> windows_core::Result<()> { + if value == 0 || self == Self::None { + return Ok(()); + } + let result = match self { + Self::None => Ok(()), + Self::CloseHandle => unsafe { CloseHandle(HANDLE(value as *mut c_void)) }, + Self::RegCloseKey => { + let status = unsafe { RegCloseKey(HKEY(value as *mut c_void)) }; + if status.0 == 0 { + Ok(()) + } else { + Err(windows_core::Error::from_hresult(hresult_from_win32( + status.0 as u32, + ))) + } + } + Self::LocalFree => { + let remaining = unsafe { LocalFree(Some(HLOCAL(value as *mut c_void))) }; + if remaining.is_invalid() { + Ok(()) + } else { + Err(windows_core::Error::from_hresult(hresult_from_win32( + unsafe { GetLastError().0 }, + ))) + } + } + Self::GlobalFree => { + let remaining = unsafe { global_free_raw(value as *mut c_void) }; + if remaining.is_null() { + Ok(()) + } else { + Err(windows_core::Error::from_hresult(hresult_from_win32( + unsafe { GetLastError().0 }, + ))) + } + } + Self::FreeLibrary => unsafe { FreeLibrary(HMODULE(value as *mut c_void)) }, + Self::CloseServiceHandle => unsafe { + CloseServiceHandle(SC_HANDLE(value as *mut c_void)) + }, + Self::CoTaskMemFree => { + unsafe { + windows::Win32::System::Com::CoTaskMemFree(Some(value as *const c_void)); + } + Ok(()) + } + Self::CredFree => { + unsafe { CredFree(value as *const c_void) }; + Ok(()) + } + }; + #[cfg(test)] + outcome_tests::record_cleanup(self, value, result.is_ok()); + result + } +} + +/// Releases a native resource whose cleanup contract was validated by a +/// semantic projection and whose ownership has not been adopted elsewhere. +pub unsafe fn cleanup_owned_resource(value: usize, cleanup: Cleanup) -> windows_core::Result<()> { + unsafe { cleanup.run(value) } +} + +fn hresult_from_win32(code: u32) -> HRESULT { + if code == 0 { + HRESULT(0) + } else { + HRESULT((0x80070000u32 | (code & 0xffff)) as i32) + } +} + +#[derive(Debug, Clone)] +pub enum Value { + Bool(bool), + I8(i8), + U8(u8), + I16(i16), + U16(u16), + I32(i32), + U32(u32), + I64(i64), + U64(u64), + F32(f32), + F64(f64), + Pointer(*mut c_void), + FunctionPointer(usize), + Handle(usize), + Resource(Arc), + AggregatePointer(Arc), + Aggregate { + layout: Arc, + pointer: *mut c_void, + }, + OwnedAggregate { + layout: Arc, + bytes: Vec, + }, + Null, + Unavailable, + Discarded, +} + +// Values contain immutable layouts and opaque pointer bits. Calling through a +// pointer is unsafe and requires the caller to preserve its validity and +// synchronization; publishing a Value never dereferences it. +unsafe impl Send for Value {} +unsafe impl Sync for Value {} + +impl Value { + pub fn resource(&self) -> Option<&Arc> { + match self { + Self::Resource(value) => Some(value), + _ => None, + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct Parameter { + pub typ: Type, + pub direction: Direction, + pub nullable: bool, + pub cleanup: Cleanup, + pub consumes_resource: bool, + pub resource_cleanup: Cleanup, +} + +impl Parameter { + pub const fn input(typ: Type, nullable: bool) -> Self { + Self { + typ, + direction: Direction::In, + nullable, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + } + } + + pub const fn output(typ: Type, cleanup: Cleanup) -> Self { + Self { + typ, + direction: Direction::Out, + nullable: false, + cleanup, + consumes_resource: false, + resource_cleanup: Cleanup::None, + } + } + + pub const fn input_output(typ: Type, nullable: bool, cleanup: Cleanup) -> Self { + Self { + typ, + direction: Direction::InOut, + nullable, + cleanup, + consumes_resource: false, + resource_cleanup: Cleanup::None, + } + } +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum SuccessRule { + Always, + ReturnZero, + ReturnNonZero, + ReturnNonNull, + HResultSucceeded, + SignedNonNegative, + ReturnValidHandle, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum CallingConvention { + System, + Cdecl, +} + +#[derive(Debug, Clone)] +pub struct CallPlanSpec { + pub dll: String, + pub entry_point: String, + pub parameters: Vec, + pub return_type: Option, + pub return_cleanup: Cleanup, + pub success_rule: SuccessRule, + pub capture_last_error: bool, + pub calling_convention: CallingConvention, + pub parameter_aggregates: Vec>>, + pub return_aggregate: Option>, +} + +#[derive(Debug)] +struct PlannedParameter { + spec: Parameter, + input_index: Option, + output_index: Option, +} + +#[derive(Debug)] +pub struct CallPlan { + dll: String, + entry_point: String, + function: usize, + parameters: Vec, + input_count: usize, + output_count: usize, + return_type: Option, + success_rule: SuccessRule, + capture_last_error: bool, + calling_convention: CallingConvention, + parameter_aggregates: Vec>>, + parameter_pointees: Vec>>, + return_aggregate: Option>, + contract: CallContract, + legacy_surface: contract::LegacySurface, + cif: Cif, +} + +// Safety: plans are completely built before publication and immutable +// afterwards. libffi reads the prepared CIF and type graph during ffi_call. +unsafe impl Send for CallPlan {} +unsafe impl Sync for CallPlan {} + +#[derive(Debug)] +pub struct CallResult { + pub return_value: Option, + pub outputs: Vec, + pub last_error: Option, + pub succeeded: bool, +} + +struct NativeOutputs<'a> { + values: Vec, + parameters: &'a [PlannedParameter], + initialized: bool, + cleanup: Vec, +} + +struct NativeReturn { + value: Option, + cleanup: Cleanup, +} + +impl Drop for NativeReturn { + fn drop(&mut self) { + if self.cleanup.owns_resource() + && let Some(AbiValue::Pointer(pointer)) = self.value.take() + { + if let Err(error) = unsafe { self.cleanup.run(pointer as usize) } { + eprintln!("[dynwinrt] native return cleanup failed: {error}"); + } + } + } +} + +impl Drop for NativeOutputs<'_> { + fn drop(&mut self) { + if !self.initialized { + return; + } + for parameter in self.parameters { + if let Some(index) = parameter.output_index + && self.cleanup[index].owns_resource() + && let AbiValue::Pointer(pointer) = &mut self.values[index] + { + let value = std::mem::replace(pointer, std::ptr::null_mut()); + if let Err(error) = unsafe { self.cleanup[index].run(value as usize) } { + eprintln!("[dynwinrt] native output cleanup failed: {error}"); + } + } + } + } +} + +impl CallPlan { + /// # Safety + /// + /// The specification must exactly match the target export's native ABI. + pub unsafe fn new(spec: CallPlanSpec) -> Result> { + unsafe { Self::new_with_contract(spec, CallContract::default()) } + } + + /// # Safety + /// + /// The ABI and versioned semantic descriptor must describe the native export exactly. + pub unsafe fn new_with_descriptor( + spec: CallPlanSpec, + descriptor: Option<&str>, + ) -> Result> { + let contract = descriptor + .map(CallContract::decode) + .transpose() + .map_err(|error| invalid_argument(&error.to_string()))? + .unwrap_or_default(); + unsafe { Self::new_with_contract(spec, contract) } + } + + /// # Safety + /// + /// Pointee layouts and result fields must match the native parameter contracts. + pub unsafe fn new_with_described_pointees( + spec: CallPlanSpec, + descriptor: Option<&str>, + pointees: Vec>>, + ) -> Result> { + let contract = descriptor + .map(CallContract::decode) + .transpose() + .map_err(|error| invalid_argument(&error.to_string()))? + .unwrap_or_default(); + unsafe { Self::new_with_contract_and_pointees(spec, contract, pointees) } + } + + /// # Safety + /// + /// The ABI and semantic contract must both describe the native export exactly. + pub unsafe fn new_with_contract( + spec: CallPlanSpec, + contract: CallContract, + ) -> Result> { + let pointees = vec![None; spec.parameters.len()]; + unsafe { Self::new_with_contract_and_pointees(spec, contract, pointees) } + } + + /// # Safety + /// + /// The aggregate field layouts, validity and ownership must match the export. + pub unsafe fn new_with_contract_and_pointees( + spec: CallPlanSpec, + contract: CallContract, + pointees: Vec>>, + ) -> Result> { + #[cfg(all(windows, target_pointer_width = "32"))] + { + let _ = (spec, contract, pointees); + return Err(not_implemented( + "flat Win32 plans currently reject 32-bit targets because metadata calling conventions are not yet projected", + )); + } + + #[cfg(not(all(windows, target_pointer_width = "32")))] + { + validate_spec(&spec)?; + if pointees.len() != spec.parameters.len() + || pointees.iter().enumerate().any(|(index, layout)| { + layout.is_some() + && (spec.parameters[index].typ != Type::Pointer + || spec.parameters[index].direction != Direction::In + || spec.parameter_aggregates[index].is_some()) + }) + { + return Err(invalid_argument( + "Aggregate pointee contracts require matching physical pointer inputs", + )); + } + let legacy_surface = contract::LegacySurface::new(&spec, &contract); + let contract = contract::resolve_with_pointees(&spec, &contract, &pointees)?; + let module = unsafe { SystemModule::cached(&spec.dll) }?; + let entry = CString::new(spec.entry_point.as_str()) + .map_err(|_| invalid_argument("invalid export name"))?; + let function = module.export(&entry)? as usize; + + let mut input_count = 0; + let mut output_count = 0; + let parameters = spec + .parameters + .iter() + .copied() + .map(|parameter| { + let input_index = parameter.direction.is_input().then(|| { + let index = input_count; + input_count += 1; + index + }); + let output_index = parameter.direction.is_output().then(|| { + let index = output_count; + output_count += 1; + index + }); + PlannedParameter { + spec: parameter, + input_index, + output_index, + } + }) + .collect::>(); + if spec.parameter_aggregates.len() != parameters.len() { + return Err(invalid_argument( + "flat Win32 aggregate descriptor count must match native parameters", + )); + } + let argument_types = parameters + .iter() + .enumerate() + .map(|(index, parameter)| { + if parameter.spec.direction.is_output() { + FfiType::pointer() + } else if let Some(layout) = &spec.parameter_aggregates[index] { + layout.libffi_type() + } else { + parameter.spec.typ.abi_type().libffi_type() + } + }) + .collect::>(); + let return_ffi_type = spec.return_aggregate.as_ref().map_or_else( + || { + spec.return_type + .map_or_else(FfiType::void, |typ| typ.abi_type().libffi_type()) + }, + |layout| layout.libffi_type(), + ); + let cif = match spec.calling_convention { + CallingConvention::System => system_cif(argument_types, return_ffi_type), + CallingConvention::Cdecl => Cif::new(argument_types, return_ffi_type), + }; + + Ok(Arc::new(Self { + dll: spec.dll, + entry_point: spec.entry_point, + function, + parameters, + input_count, + output_count, + return_type: spec.return_type, + success_rule: spec.success_rule, + capture_last_error: spec.capture_last_error, + calling_convention: spec.calling_convention, + parameter_aggregates: spec.parameter_aggregates, + parameter_pointees: pointees, + return_aggregate: spec.return_aggregate, + contract, + legacy_surface, + cif, + })) + } + } + + pub fn dll(&self) -> &str { + &self.dll + } + + pub fn entry_point(&self) -> &str { + &self.entry_point + } + + pub fn input_count(&self) -> usize { + self.input_count + } + + pub fn output_count(&self) -> usize { + self.output_count + } + + pub fn calling_convention(&self) -> CallingConvention { + self.calling_convention + } + + /// # Safety + /// + /// Every pointer and aggregate argument must remain valid for the complete + /// native call and satisfy the contract used to construct this plan. + pub unsafe fn invoke(&self, args: &[Value]) -> Result { + if args.len() != self.input_count { + return Err(invalid_argument(&format!( + "{}!{} expects {} inputs, received {}", + self.dll, + self.entry_point, + self.input_count, + args.len() + ))); + } + for parameter in &self.parameters { + if !parameter.spec.consumes_resource { + continue; + } + let input_index = parameter + .input_index + .expect("consuming parameter is an input"); + let Value::Resource(resource) = &args[input_index] else { + return Err(invalid_argument( + "consuming Win32 parameters require a managed resource object", + )); + }; + if resource.cleanup() != parameter.spec.resource_cleanup { + return Err(invalid_argument( + "managed Win32 resource cleanup kind does not match the consuming parameter", + )); + } + } + + let mut input_resources = args + .iter() + .enumerate() + .filter_map(|(index, value)| match value { + Value::Resource(resource) => Some((index, resource)), + _ => None, + }) + .collect::>(); + input_resources.sort_by_key(|(_, resource)| Arc::as_ptr(resource) as usize); + if input_resources + .windows(2) + .any(|pair| Arc::ptr_eq(pair[0].1, pair[1].1)) + { + return Err(invalid_argument( + "the same managed Win32 resource cannot occupy multiple parameters in one call", + )); + } + let mut aggregate_inputs = args + .iter() + .enumerate() + .filter_map(|(index, value)| { + if let Value::AggregatePointer(buffer) = value { + Some((index, buffer)) + } else { + None + } + }) + .collect::>(); + aggregate_inputs.sort_by_key(|(_, buffer)| Arc::as_ptr(buffer) as usize); + if aggregate_inputs + .windows(2) + .any(|pair| Arc::ptr_eq(pair[0].1, pair[1].1)) + { + return Err(invalid_argument( + "the same native aggregate cannot occupy multiple parameters in one call", + )); + } + let mut aggregate_by_arg = vec![None; args.len()]; + let mut aggregate_guards = Vec::with_capacity(aggregate_inputs.len()); + for (index, buffer) in aggregate_inputs { + aggregate_by_arg[index] = Some(aggregate_guards.len()); + aggregate_guards.push(buffer.lock()); + } + for (index, layout) in self.parameter_pointees.iter().enumerate() { + let Some(layout) = layout else { + continue; + }; + let input = self.parameters[index] + .input_index + .expect("validated pointee input"); + match &args[input] { + Value::AggregatePointer(buffer) if buffer.layout().as_ref() == layout.as_ref() => {} + Value::Null if self.parameters[index].spec.nullable => {} + _ => { + return Err(invalid_argument( + "Native aggregate output requires matching managed caller storage", + )); + } + } + } + + // Lock aggregate storage first, then one ordered set of input and retiring owners. + let mut resources = input_resources + .iter() + .map(|(index, resource)| (Some(*index), Arc::clone(resource))) + .collect::>(); + for (index, layout) in self.parameter_pointees.iter().enumerate() { + if layout.is_none() { + continue; + } + let input = self.parameters[index] + .input_index + .expect("validated aggregate input"); + if let Some(guard) = aggregate_by_arg[input] { + for resource in aggregate_guards[guard].owned_resources() { + let identity = Arc::as_ptr(resource) as usize; + if input_resources + .binary_search_by_key(&identity, |(_, owner)| Arc::as_ptr(owner) as usize) + .is_ok() + { + return Err(invalid_argument( + "Cannot retire an aggregate output owner used as an input in the same call; take the field before reusing the output buffer", + )); + } + resources.push((None, Arc::clone(resource))); + } + } + } + resources.sort_by_key(|(_, resource)| Arc::as_ptr(resource) as usize); + resources.dedup_by(|first, second| Arc::ptr_eq(&first.1, &second.1)); + let mut resource_guard_by_arg = vec![None; args.len()]; + let mut resource_guards = Vec::with_capacity(resources.len()); + for (arg_index, resource) in &resources { + let access = if let Some(arg_index) = *arg_index { + let consumes_resource = self.parameters.iter().any(|parameter| { + parameter.input_index == Some(arg_index) && parameter.spec.consumes_resource + }); + let changes_completion_modes = + self.parameters + .iter() + .enumerate() + .any(|(index, parameter)| { + parameter.input_index == Some(arg_index) + && self.contract.changes_resource(index) + }); + if consumes_resource { + ResourceAccess::Consume + } else if changes_completion_modes { + ResourceAccess::MutateState("file completion modes") + } else { + ResourceAccess::Borrow + } + } else { + ResourceAccess::Consume + }; + let guard = resource.lock_for_call(access)?; + #[cfg(test)] + outcome_tests::record_call_lock(Arc::as_ptr(resource) as usize); + if let Some(arg_index) = *arg_index { + resource_guard_by_arg[arg_index] = Some(resource_guards.len()); + } + resource_guards.push(guard); + } + + let input_storage = self + .parameters + .iter() + .enumerate() + .map(|(parameter_index, parameter)| { + if self.parameter_aggregates[parameter_index].is_some() { + return Ok(None); + } + parameter + .input_index + .map(|index| { + value_to_abi( + parameter.spec.typ, + &args[index], + parameter.spec.nullable, + parameter.spec.resource_cleanup, + resource_guard_by_arg[index] + .map(|guard_index| *resource_guards[guard_index]), + ) + }) + .transpose() + }) + .collect::>>()?; + let conditions = self + .contract + .results + .iter() + .map(|result| { + result + .overrides + .iter() + .map(|rule| unsafe { contract::matches_inputs(&rule.when, &input_storage) }) + .collect::>>() + }) + .collect::>>()?; + let mut output_policies = vec![ResultPolicy::Undefined {}; self.output_count]; + let mut legacy_null_outputs = vec![false; self.output_count]; + let mut legacy_null_return = false; + let mut return_policy = None; + let output_values = self + .parameters + .iter() + .filter(|parameter| parameter.spec.direction.is_output()) + .map(|parameter| { + if parameter.spec.direction == Direction::InOut { + value_to_abi( + parameter.spec.typ, + &args[parameter.input_index.expect("in/out input")], + parameter.spec.nullable, + parameter.spec.resource_cleanup, + parameter + .input_index + .and_then(|index| resource_guard_by_arg[index]) + .map(|guard_index| *resource_guards[guard_index]), + ) + } else { + Ok(parameter.spec.typ.default_abi_value()) + } + }) + .collect::>>()?; + let mut output_storage = NativeOutputs { + values: output_values, + parameters: &self.parameters, + initialized: false, + cleanup: vec![Cleanup::None; self.output_count], + }; + debug_assert_eq!(output_storage.values.len(), self.output_count); + let output_pointers = output_storage + .values + .iter() + .map(|value| value.as_out_ptr() as *mut c_void) + .collect::>(); + + let mut ffi_args = Vec::>::with_capacity(self.parameters.len()); + for (index, parameter) in self.parameters.iter().enumerate() { + if let Some(output_index) = parameter.output_index { + ffi_args.push(arg(&output_pointers[output_index])); + } else if let Some(expected) = &self.parameter_aggregates[index] { + let input_index = parameter.input_index.expect("aggregate input index"); + let Value::Aggregate { layout, pointer } = &args[input_index] else { + return Err(invalid_argument( + "flat Win32 argument does not match native aggregate", + )); + }; + if layout != expected || pointer.is_null() { + return Err(invalid_argument( + "flat Win32 native aggregate identity mismatch", + )); + } + ffi_args.push(Arg::new(unsafe { &*pointer.cast::() })); + } else { + ffi_args.push(abi_arg( + input_storage[index] + .as_ref() + .expect("input parameter has ABI storage"), + )); + } + } + + let mut aggregate_return_words = self + .return_aggregate + .as_ref() + .map(|layout| try_zeroed_words(layout.size())) + .transpose()?; + for (index, layout) in self.parameter_pointees.iter().enumerate() { + let Some(layout) = layout else { + continue; + }; + let input = self.parameters[index] + .input_index + .expect("validated aggregate input"); + if let Some(guard) = aggregate_by_arg[input] { + aggregate_guards[guard].prepare_with_owned_cleanup(layout, |resource| { + let identity = Arc::as_ptr(resource) as usize; + let index = resources + .binary_search_by_key(&identity, |(_, owner)| Arc::as_ptr(owner) as usize) + .expect("registered aggregate result owner"); + resource_guards[index].close() + })?; + } + } + let raw_return = if let (Some(layout), Some(words)) = + (&self.return_aggregate, aggregate_return_words.as_mut()) + { + let bytes = unsafe { + std::slice::from_raw_parts_mut(words.as_mut_ptr().cast::(), layout.size()) + }; + unsafe { + self.cif.call_return_into( + libffi::middle::CodePtr(self.function as *mut c_void), + &ffi_args, + Ret::new(bytes), + ) + }; + None + } else { + unsafe { + crate::call::call_native_function( + &self.cif, + self.function as *mut c_void, + &ffi_args, + self.return_type.map(Type::abi_type), + ) + } + }; + let last_error = self.capture_last_error.then(|| unsafe { GetLastError().0 }); + let succeeded = success_matches(self.success_rule, raw_return.as_ref())?; + let return_bits = if self.contract.results.iter().any(|result| { + result + .overrides + .iter() + .any(|rule| rule.when.return_value.is_some()) + }) { + raw_return.as_ref().and_then(contract::abi_bits) + } else { + None + }; + let mut return_storage = NativeReturn { + value: raw_return, + cleanup: Cleanup::None, + }; + for (result, inputs_match) in self.contract.results.iter().zip(conditions) { + let mut policy = if succeeded { + result.on_success + } else { + result.on_failure + }; + let mut overridden = false; + for (rule, inputs_match) in result.overrides.iter().zip(inputs_match) { + if inputs_match + && rule + .when + .succeeded + .is_none_or(|expected| expected == succeeded) + && rule + .when + .return_value + .is_none_or(|expected| return_bits == Some(expected)) + { + policy = rule.policy; + overridden = true; + break; + } + } + match result.target { + ResultTarget::Return {} => { + legacy_null_return = + self.legacy_surface + .null_on_failure(result.target, succeeded, overridden); + return_policy = Some(policy); + return_storage.cleanup = result_cleanup(policy); + } + ResultTarget::Parameter { index } => { + let output = self.parameters[index] + .output_index + .expect("validated result target"); + output_policies[output] = policy; + legacy_null_outputs[output] = + self.legacy_surface + .null_on_failure(result.target, succeeded, overridden); + output_storage.cleanup[output] = result_cleanup(policy); + } + ResultTarget::AggregateField { parameter, field } => { + let input = self.parameters[parameter] + .input_index + .expect("validated aggregate input"); + if let Some(guard) = aggregate_by_arg[input] { + aggregate_guards[guard].policies[field] = policy; + aggregate_guards[guard].raw_cleanup[field] = result_cleanup(policy); + } + } + } + } + output_storage.initialized = true; + // Publish every described aggregate's state before any field conversion or cleanup. + for (index, layout) in self.parameter_pointees.iter().enumerate() { + if layout.is_none() { + continue; + } + let input = self.parameters[index] + .input_index + .expect("validated aggregate input"); + if let Some(guard_index) = aggregate_by_arg[input] { + let state = &mut aggregate_guards[guard_index]; + state.succeeded = Some(succeeded); + state.native_recorded = true; + } + } + // Commit native side effects before any fallible result processing. + if succeeded { + for effect in &self.contract.resource_effects { + let ResourceEffect::AddFileCompletionModes { + handle_parameter, + flags_parameter, + } = *effect; + let input = self.parameters[handle_parameter] + .input_index + .expect("validated resource state input"); + if let Value::Resource(resource) = &args[input] { + let Some(AbiValue::U8(flags)) = &input_storage[flags_parameter] else { + unreachable!("validated file completion mode flags"); + }; + resource + .file_capability() + .record_completion_modes(u32::from(*flags)); + } + } + for parameter in &self.parameters { + if !parameter.spec.consumes_resource { + continue; + } + let input_index = parameter + .input_index + .expect("consuming parameter is an input"); + if let Some(guard_index) = resource_guard_by_arg[input_index] { + *resource_guards[guard_index] = 0; + } + } + } + for (index, layout) in self.parameter_pointees.iter().enumerate() { + let Some(layout) = layout else { + continue; + }; + let input = self.parameters[index] + .input_index + .expect("validated aggregate input"); + let Some(guard_index) = aggregate_by_arg[input] else { + continue; + }; + let state = &mut aggregate_guards[guard_index]; + for (field_index, field) in layout.fields().iter().enumerate() { + let policy = state.policies[field_index]; + if matches!(policy, ResultPolicy::Undefined {}) { + state.results[field_index] = Some(Value::Unavailable); + continue; + } + #[cfg(test)] + outcome_tests::check_result_decode(ResultTarget::AggregateField { + parameter: index, + field: field_index, + })?; + let raw = state.read_abi(field); + let value = self.decode_result(field.typ, raw, policy, args, &input_storage)?; + state.raw_cleanup[field_index] = Cleanup::None; + state.results[field_index] = Some(value); + } + } + + let mut return_value = + if let (Some(layout), Some(words)) = (&self.return_aggregate, aggregate_return_words) { + match return_policy.expect("validated aggregate return policy") { + ResultPolicy::Undefined {} => Some(Value::Unavailable), + ResultPolicy::Defined { + delivery: Delivery::Discard, + .. + } => Some(Value::Discarded), + ResultPolicy::Defined { + ownership: ResultOwnership::Value {}, + delivery: Delivery::Deliver, + } => { + let source = unsafe { + std::slice::from_raw_parts(words.as_ptr().cast::(), layout.size()) + }; + let mut bytes = Vec::new(); + #[cfg(test)] + outcome_tests::check_aggregate_return_allocation()?; + bytes + .try_reserve_exact(source.len()) + .map_err(|_| out_of_memory("native aggregate return"))?; + bytes.extend_from_slice(source); + Some(Value::OwnedAggregate { + layout: Arc::clone(layout), + bytes, + }) + } + _ => { + return Err(invalid_argument( + "Aggregate return has unsupported ownership", + )); + } + } + } else { + match (self.return_type, return_policy) { + (Some(_), Some(ResultPolicy::Undefined {})) => Some(Value::Unavailable), + (Some(typ), Some(policy)) => { + #[cfg(test)] + outcome_tests::check_result_decode(ResultTarget::Return {})?; + let value = return_storage + .value + .take() + .ok_or_else(|| invalid_argument("Missing native return storage"))?; + Some(self.decode_result(typ, value, policy, args, &input_storage)?) + } + (None, None) => None, + _ => { + return Err(invalid_argument( + "flat Win32 call plan produced an inconsistent return value", + )); + } + } + }; + if legacy_null_return { + return_value = Some(Value::Handle(0)); + } + + let mut outputs = Vec::with_capacity(self.output_count); + for (_parameter_index, parameter) in self.parameters.iter().enumerate() { + let Some(output_index) = parameter.output_index else { + continue; + }; + if matches!(output_policies[output_index], ResultPolicy::Undefined {}) { + outputs.push(if legacy_null_outputs[output_index] { + Value::Handle(0) + } else { + Value::Unavailable + }); + continue; + } + #[cfg(test)] + outcome_tests::check_result_decode(ResultTarget::Parameter { + index: _parameter_index, + })?; + #[cfg(test)] + outcome_tests::record_output_decode(output_index); + let raw = std::mem::replace( + &mut output_storage.values[output_index], + parameter.spec.typ.default_abi_value(), + ); + let decoded = self.decode_result( + parameter.spec.typ, + raw, + output_policies[output_index], + args, + &input_storage, + )?; + outputs.push(if legacy_null_outputs[output_index] { + Value::Handle(0) + } else { + decoded + }); + } + + Ok(CallResult { + return_value, + outputs, + last_error, + succeeded, + }) + } + + fn decode_result( + &self, + typ: Type, + value: AbiValue, + policy: ResultPolicy, + args: &[Value], + input_storage: &[Option], + ) -> Result { + let ResultPolicy::Defined { + ownership, + delivery, + } = policy + else { + return Err(invalid_argument( + "Undefined native output cannot be decoded", + )); + }; + let result = match ownership { + ResultOwnership::Owned { cleanup } => { + let AbiValue::Pointer(pointer) = value else { + return Err(invalid_argument( + "Owned native result is not pointer-shaped", + )); + }; + let bits = pointer as usize; + let cleanup = Cleanup::from(cleanup); + if delivery == Delivery::Discard { + unsafe { cleanup.run(bits) }.map_err(Error::WindowsError)?; + return Ok(Value::Discarded); + } + if bits == 0 { + Value::Handle(0) + } else { + Value::Resource(unsafe { OwnedResource::adopt(bits, cleanup) }?) + } + } + ResultOwnership::AliasInput { parameter } => { + let expected = input_storage[parameter] + .as_ref() + .and_then(contract::abi_bits) + .expect("validated alias input storage"); + if contract::abi_bits(&value) != Some(expected) { + return Err(invalid_argument( + "Win32 alias output does not equal its contracted input handle", + )); + } + if delivery == Delivery::Discard { + return Ok(Value::Discarded); + } + match &args[self.parameters[parameter] + .input_index + .expect("validated alias input")] + { + Value::Resource(resource) => Value::Resource(Arc::clone(resource)), + _ => Value::Handle(expected as usize), + } + } + ResultOwnership::Value {} | ResultOwnership::Borrowed {} => { + if delivery == Delivery::Discard { + return Ok(Value::Discarded); + } + decode_plain_value(typ, value)? + } + }; + Ok(result) + } +} + +fn result_cleanup(policy: ResultPolicy) -> Cleanup { + match policy { + ResultPolicy::Defined { + ownership: ResultOwnership::Owned { cleanup }, + .. + } => cleanup.into(), + _ => Cleanup::None, + } +} + +fn try_zeroed_words(byte_length: usize) -> Result> { + let word_length = byte_length.div_ceil(std::mem::size_of::()); + let mut words = Vec::new(); + words + .try_reserve_exact(word_length) + .map_err(|_| out_of_memory("native aggregate storage"))?; + words.resize(word_length, 0); + Ok(words) +} + +#[cfg(not(all(windows, target_pointer_width = "32")))] +fn validate_spec(spec: &CallPlanSpec) -> Result<()> { + if spec.parameters.len() > 1024 || spec.parameter_aggregates.len() != spec.parameters.len() { + return Err(invalid_argument( + "flat Win32 parameter/aggregate count is invalid or exceeds 1024", + )); + } + if !is_bare_system_module_name(&spec.dll) { + return Err(invalid_argument( + "flat Win32 DLL names must be bare .dll or .drv names loaded from System32", + )); + } + if spec.entry_point.is_empty() || spec.entry_point.as_bytes().contains(&0) { + return Err(invalid_argument( + "flat Win32 entry point must be a non-empty NUL-free export name", + )); + } + if spec.return_cleanup.owns_resource() && !spec.return_type.is_some_and(Type::is_pointer_like) { + return Err(invalid_argument( + "owned flat Win32 returns must be pointer or handle values", + )); + } + if spec.return_type.is_some() && spec.return_aggregate.is_some() { + return Err(invalid_argument( + "flat Win32 return cannot be both scalar and aggregate", + )); + } + if spec.return_aggregate.is_some() && spec.return_cleanup != Cleanup::None { + return Err(invalid_argument( + "native aggregate returns cannot use pointer cleanup", + )); + } + if spec.success_rule != SuccessRule::Always && spec.return_type.is_none() { + return Err(invalid_argument( + "flat Win32 success rules require a direct return value", + )); + } + if matches!( + spec.success_rule, + SuccessRule::HResultSucceeded | SuccessRule::SignedNonNegative + ) && spec.return_type != Some(Type::I32) + { + return Err(invalid_argument( + "signed success rules require an i32 return type", + )); + } + if matches!( + spec.success_rule, + SuccessRule::ReturnValidHandle | SuccessRule::ReturnNonNull + ) && !spec.return_type.is_some_and(Type::is_pointer_like) + { + return Err(invalid_argument( + "pointer success rules require a pointer or handle return", + )); + } + if matches!( + spec.success_rule, + SuccessRule::ReturnZero | SuccessRule::ReturnNonZero + ) && matches!(spec.return_type, Some(Type::F32 | Type::F64)) + { + return Err(invalid_argument( + "integer success rules cannot classify floating-point returns", + )); + } + for (index, parameter) in spec.parameters.iter().enumerate() { + if spec + .parameter_aggregates + .get(index) + .is_some_and(Option::is_some) + && (parameter.direction != Direction::In || parameter.typ != Type::Pointer) + { + return Err(invalid_argument( + "by-value native aggregates require direct pointer-typed input plans", + )); + } + if parameter.nullable && !parameter.typ.is_pointer_like() { + return Err(invalid_argument( + "only pointer and handle inputs may be nullable", + )); + } + if parameter.cleanup.owns_resource() + && (!parameter.direction.is_output() || !parameter.typ.is_pointer_like()) + { + return Err(invalid_argument( + "flat Win32 cleanup applies only to pointer or handle outputs", + )); + } + if parameter.consumes_resource + && (parameter.direction != Direction::In + || parameter.typ != Type::Handle + || !parameter.resource_cleanup.owns_resource()) + { + return Err(invalid_argument( + "consuming Win32 parameters must be direct managed handle inputs with exact cleanup", + )); + } + if parameter.resource_cleanup != Cleanup::None + && (parameter.direction == Direction::Out || parameter.typ != Type::Handle) + { + return Err(invalid_argument( + "managed resource compatibility applies only to handle inputs", + )); + } + } + Ok(()) +} + +fn value_to_abi( + typ: Type, + value: &Value, + nullable: bool, + resource_cleanup: Cleanup, + resource_bits: Option, +) -> Result { + let mismatch = || invalid_argument(&format!("flat Win32 argument does not match {typ:?}")); + Ok(match (typ, value) { + (Type::Bool32, Value::Bool(value)) => AbiValue::I32(i32::from(*value)), + (Type::I8, Value::I8(value)) => AbiValue::I8(*value), + (Type::U8, Value::U8(value)) => AbiValue::U8(*value), + (Type::I16, Value::I16(value)) => AbiValue::I16(*value), + (Type::U16, Value::U16(value)) => AbiValue::U16(*value), + (Type::I32, Value::I32(value)) => AbiValue::I32(*value), + (Type::U32, Value::U32(value)) => AbiValue::U32(*value), + (Type::I64, Value::I64(value)) => AbiValue::I64(*value), + (Type::U64, Value::U64(value)) => AbiValue::U64(*value), + (Type::F32, Value::F32(value)) => AbiValue::F32(*value), + (Type::F64, Value::F64(value)) => AbiValue::F64(*value), + (Type::Pointer, Value::Pointer(value)) if nullable || !value.is_null() => { + AbiValue::Pointer(*value) + } + (Type::Pointer, Value::AggregatePointer(value)) => AbiValue::Pointer(value.pointer()), + (Type::FunctionPointer, Value::FunctionPointer(value)) if nullable || *value != 0 => { + AbiValue::Pointer(*value as *mut c_void) + } + (Type::Handle, Value::Handle(value)) => AbiValue::Pointer(*value as *mut c_void), + (Type::Handle, Value::Resource(resource)) => { + if resource_cleanup == Cleanup::None || resource.cleanup() != resource_cleanup { + return Err(invalid_argument( + "managed Win32 resource cleanup kind does not match the handle parameter", + )); + } + let raw = resource_bits.ok_or_else(|| { + invalid_argument("managed Win32 resource has no active call lease") + })?; + if raw == 0 { + return Err(invalid_argument( + "cannot pass a closed flat Win32 resource handle", + )); + } + AbiValue::Pointer(raw as *mut c_void) + } + (Type::Pointer | Type::FunctionPointer | Type::Handle, Value::Null) if nullable => { + AbiValue::Pointer(std::ptr::null_mut()) + } + _ => return Err(mismatch()), + }) +} + +fn abi_arg(value: &AbiValue) -> Arg<'_> { + match value { + AbiValue::Bool(value) => arg(value), + AbiValue::I8(value) => arg(value), + AbiValue::U8(value) => arg(value), + AbiValue::I16(value) => arg(value), + AbiValue::U16(value) => arg(value), + AbiValue::I32(value) => arg(value), + AbiValue::U32(value) => arg(value), + AbiValue::I64(value) => arg(value), + AbiValue::U64(value) => arg(value), + AbiValue::F32(value) => arg(value), + AbiValue::F64(value) => arg(value), + AbiValue::Guid(value) => arg(value), + AbiValue::Pointer(value) => arg(value), + } +} + +fn decode_plain_value(typ: Type, value: AbiValue) -> Result { + Ok(match (typ, value) { + (Type::Bool32, AbiValue::I32(value)) => Value::Bool(value != 0), + (Type::I8, AbiValue::I8(value)) => Value::I8(value), + (Type::U8, AbiValue::U8(value)) => Value::U8(value), + (Type::I16, AbiValue::I16(value)) => Value::I16(value), + (Type::U16, AbiValue::U16(value)) => Value::U16(value), + (Type::I32, AbiValue::I32(value)) => Value::I32(value), + (Type::U32, AbiValue::U32(value)) => Value::U32(value), + (Type::I64, AbiValue::I64(value)) => Value::I64(value), + (Type::U64, AbiValue::U64(value)) => Value::U64(value), + (Type::F32, AbiValue::F32(value)) => Value::F32(value), + (Type::F64, AbiValue::F64(value)) => Value::F64(value), + (Type::Pointer, AbiValue::Pointer(value)) => Value::Pointer(value), + (Type::FunctionPointer, AbiValue::Pointer(value)) => Value::FunctionPointer(value as usize), + (Type::Handle, AbiValue::Pointer(value)) => Value::Handle(value as usize), + _ => { + return Err(invalid_argument( + "flat Win32 native result did not match its immutable call plan", + )); + } + }) +} + +fn success_matches(rule: SuccessRule, value: Option<&AbiValue>) -> Result { + let scalar = |value: &AbiValue| -> Option { + match value { + AbiValue::Bool(value) => Some(*value as i128), + AbiValue::I8(value) => Some(*value as i128), + AbiValue::U8(value) => Some(*value as i128), + AbiValue::I16(value) => Some(*value as i128), + AbiValue::U16(value) => Some(*value as i128), + AbiValue::I32(value) => Some(*value as i128), + AbiValue::U32(value) => Some(*value as i128), + AbiValue::I64(value) => Some(*value as i128), + AbiValue::U64(value) => Some(*value as i128), + AbiValue::Pointer(value) => Some(*value as usize as i128), + AbiValue::F32(_) | AbiValue::F64(_) | AbiValue::Guid(_) => None, + } + }; + match rule { + SuccessRule::Always => Ok(true), + SuccessRule::ReturnZero => value + .and_then(scalar) + .map(|value| value == 0) + .ok_or_else(|| invalid_argument("ReturnZero requires an integer or pointer return")), + SuccessRule::ReturnNonZero | SuccessRule::ReturnNonNull => value + .and_then(scalar) + .map(|value| value != 0) + .ok_or_else(|| invalid_argument("nonzero success rule requires a scalar return")), + SuccessRule::HResultSucceeded => match value { + Some(AbiValue::I32(value)) => Ok(*value >= 0), + _ => Err(invalid_argument( + "HRESULT success rule requires a signed 32-bit return", + )), + }, + SuccessRule::SignedNonNegative => match value { + Some(AbiValue::I32(value)) => Ok(*value >= 0), + _ => Err(invalid_argument( + "signed-nonnegative success rule requires a signed 32-bit return", + )), + }, + SuccessRule::ReturnValidHandle => match value { + Some(AbiValue::Pointer(value)) => { + let bits = *value as usize; + Ok(bits != 0 && bits != usize::MAX) + } + _ => Err(invalid_argument( + "valid-handle success rule requires a pointer return", + )), + }, + } +} + +fn invalid_argument(message: &str) -> Error { + Error::WindowsError(windows_core::Error::new(E_INVALIDARG, message)) +} + +fn out_of_memory(context: &str) -> Error { + Error::WindowsError(windows_core::Error::new( + HRESULT(0x8007000Eu32 as i32), + format!("Unable to allocate {context}"), + )) +} + +#[cfg(all(windows, target_pointer_width = "32"))] +fn not_implemented(message: &str) -> Error { + Error::WindowsError(windows_core::Error::new(E_NOTIMPL, message)) +} + +#[cfg(all(test, target_pointer_width = "64"))] +#[path = "win32_aggregate_tests.rs"] +mod aggregate_tests; +#[cfg(all(test, target_pointer_width = "64"))] +#[path = "win32_contract_tests.rs"] +mod contract_tests; +#[cfg(test)] +#[path = "win32_outcome_tests.rs"] +mod outcome_tests; +#[cfg(all(test, target_pointer_width = "64"))] +#[path = "win32_result_tests.rs"] +mod result_tests; + +#[cfg(test)] +mod tests { + use super::*; + + #[cfg(target_pointer_width = "64")] + pub(super) fn fake_plan( + function: usize, + parameters: Vec, + return_type: Option, + parameter_aggregates: Vec>>, + return_aggregate: Option>, + ) -> Arc { + let mut plan = Arc::try_unwrap( + unsafe { + CallPlan::new(CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "GetLastError".into(), + parameters, + return_type, + return_cleanup: Cleanup::None, + success_rule: SuccessRule::Always, + capture_last_error: false, + calling_convention: CallingConvention::System, + parameter_aggregates, + return_aggregate, + }) + } + .unwrap(), + ) + .unwrap(); + plan.function = function; + Arc::new(plan) + } + + #[test] + #[cfg(target_pointer_width = "64")] + fn flat_abi_round_trips_every_scalar_width() { + macro_rules! check { + ($native:ty, $typ:ident, $variant:ident, $value:expr) => {{ + extern "system" fn echo(value: $native) -> $native { + value + } + let plan = fake_plan( + echo as *const () as usize, + vec![Parameter::input(Type::$typ, false)], + Some(Type::$typ), + vec![None], + None, + ); + let output = unsafe { plan.invoke(&[Value::$variant($value)]) }.unwrap(); + let Some(Value::$variant(value)) = output.return_value else { + panic!("native ABI returned the wrong scalar kind"); + }; + assert_eq!(value, $value); + }}; + } + check!(i32, Bool32, Bool, true); + check!(i8, I8, I8, -123); + check!(u8, U8, U8, 250); + check!(i16, I16, I16, -30_000); + check!(u16, U16, U16, 60_000); + check!(i32, I32, I32, -2_000_000_000); + check!(u32, U32, U32, 4_000_000_000); + check!(i64, I64, I64, i64::MIN + 1); + check!(u64, U64, U64, u64::MAX - 1); + check!(f32, F32, F32, 12.5); + check!(f64, F64, F64, -123.25); + let mut byte = 7u8; + check!(*mut c_void, Pointer, Pointer, (&mut byte as *mut u8).cast()); + check!(usize, Handle, Handle, usize::MAX - 1); + check!(usize, FunctionPointer, FunctionPointer, usize::MAX - 2); + } + + #[test] + #[cfg(target_pointer_width = "64")] + fn flat_guid_values_and_returns_preserve_full_aggregate_abi() { + extern "system" fn echo(value: windows_core::GUID) -> windows_core::GUID { + value + } + let layout = + NativeAggregateLayout::new("Tests.GUID", 16, 4, crate::abi::guid_libffi_type()) + .unwrap(); + let plan = fake_plan( + echo as *const () as usize, + vec![Parameter::input(Type::Pointer, false)], + None, + vec![Some(Arc::clone(&layout))], + Some(Arc::clone(&layout)), + ); + let input = windows_core::GUID::from_u128(0x00112233_4455_6677_8899_aabbccddeeff); + let result = unsafe { + plan.invoke(&[Value::Aggregate { + layout, + pointer: (&input as *const windows_core::GUID).cast_mut().cast(), + }]) + } + .unwrap(); + let Some(Value::OwnedAggregate { bytes, .. }) = result.return_value else { + panic!("GUID aggregate return was lost"); + }; + assert_eq!(bytes.len(), 16); + assert_eq!( + unsafe { bytes.as_ptr().cast::().read_unaligned() }, + input + ); + } + + #[test] + #[cfg(target_pointer_width = "64")] + fn flat_mixed_aggregate_return_and_identity_are_validated() { + #[repr(C)] + #[derive(Clone, Copy)] + struct Pair { + integer: u32, + floating: f64, + } + static CALLS: AtomicUsize = AtomicUsize::new(0); + extern "system" fn echo(value: Pair) -> Pair { + CALLS.fetch_add(1, Ordering::SeqCst); + value + } + let layout = NativeAggregateLayout::new( + "Tests.Pair", + 16, + 8, + FfiType::structure([FfiType::u32(), FfiType::f64()]), + ) + .unwrap(); + let wrong = NativeAggregateLayout::new( + "Tests.Other", + 16, + 8, + FfiType::structure([FfiType::u32(), FfiType::f64()]), + ) + .unwrap(); + let wrong_abi = NativeAggregateLayout::new( + "Tests.Pair", + 16, + 8, + FfiType::structure([FfiType::u32(), FfiType::u64()]), + ) + .unwrap(); + let plan = fake_plan( + echo as *const () as usize, + vec![Parameter::input(Type::Pointer, false)], + None, + vec![Some(Arc::clone(&layout))], + Some(Arc::clone(&layout)), + ); + let input = Pair { + integer: 42, + floating: 12.5, + }; + CALLS.store(0, Ordering::SeqCst); + assert!( + unsafe { + plan.invoke(&[Value::Aggregate { + layout: wrong, + pointer: (&input as *const Pair).cast_mut().cast(), + }]) + } + .is_err() + ); + assert_eq!(CALLS.load(Ordering::SeqCst), 0); + assert!( + unsafe { + plan.invoke(&[Value::Aggregate { + layout: wrong_abi, + pointer: (&input as *const Pair).cast_mut().cast(), + }]) + } + .is_err() + ); + assert_eq!(CALLS.load(Ordering::SeqCst), 0); + let result = unsafe { + plan.invoke(&[Value::Aggregate { + layout, + pointer: (&input as *const Pair).cast_mut().cast(), + }]) + } + .unwrap(); + let Some(Value::OwnedAggregate { bytes, .. }) = result.return_value else { + panic!("mixed aggregate return was lost"); + }; + let output = unsafe { bytes.as_ptr().cast::().read_unaligned() }; + assert_eq!((output.integer, output.floating), (42, 12.5)); + assert_eq!(CALLS.load(Ordering::SeqCst), 1); + } + + #[test] + fn aggregate_libffi_size_and_alignment_must_match_native_layout() { + assert!( + NativeAggregateLayout::new( + "Tests.WrongSize", + 16, + 8, + FfiType::structure([FfiType::u64()]), + ) + .is_err() + ); + assert!( + NativeAggregateLayout::new( + "Tests.WrongAlignment", + 8, + 4, + FfiType::structure([FfiType::u64()]), + ) + .is_err() + ); + assert!(NativeAggregateLayout::new("Tests.NotAggregate", 8, 8, FfiType::u64()).is_err()); + } + + #[test] + fn failed_resource_close_retains_exact_value_for_retry() { + // RegCloseKey validates invalid HKEY bits without dereferencing them. + let resource = OwnedResource::new(0x1234_567b, Cleanup::RegCloseKey); + for _ in 0..2 { + let error = resource.close().unwrap_err(); + assert_eq!(error.code(), hresult_from_win32(6)); + assert_eq!(resource.raw(), 0x1234_567b); + assert_eq!(resource.cleanup(), Cleanup::RegCloseKey); + } + } + + #[cfg(not(all(windows, target_pointer_width = "32")))] + fn wide(value: &str) -> Vec { + value.encode_utf16().chain(std::iter::once(0)).collect() + } + + #[cfg(not(all(windows, target_pointer_width = "32")))] + fn mul_div_plan() -> Arc { + unsafe { + CallPlan::new(CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "MulDiv".into(), + parameters: vec![ + Parameter::input(Type::I32, false), + Parameter::input(Type::I32, false), + Parameter::input(Type::I32, false), + ], + return_type: Some(Type::I32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::Always, + capture_last_error: false, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None; 3], + return_aggregate: None, + }) + } + .unwrap() + } + + #[test] + fn immutable_plan_invokes_exact_scalar_signature() { + #[cfg(target_pointer_width = "64")] + { + let plan = mul_div_plan(); + let result = + unsafe { plan.invoke(&[Value::I32(100), Value::I32(3), Value::I32(2)]) }.unwrap(); + assert!(matches!(result.return_value, Some(Value::I32(150)))); + assert!(result.outputs.is_empty()); + } + } + + #[test] + fn immutable_plan_rejects_wrong_argument_kind_before_dispatch() { + #[cfg(target_pointer_width = "64")] + { + let plan = mul_div_plan(); + let error = unsafe { plan.invoke(&[Value::U32(100), Value::I32(3), Value::I32(2)]) } + .unwrap_err(); + assert!(error.message().contains("does not match I32")); + } + } + + #[test] + fn cdecl_plan_invokes_ldap_scalar_export() { + #[cfg(target_pointer_width = "64")] + { + let plan = unsafe { + CallPlan::new(CallPlanSpec { + dll: "wldap32.dll".into(), + entry_point: "LdapGetLastError".into(), + parameters: vec![], + return_type: Some(Type::U32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::Always, + capture_last_error: false, + calling_convention: CallingConvention::Cdecl, + parameter_aggregates: vec![], + return_aggregate: None, + }) + } + .unwrap(); + assert_eq!(plan.calling_convention(), CallingConvention::Cdecl); + let result = unsafe { plan.invoke(&[]) }.unwrap(); + assert!(matches!(result.return_value, Some(Value::U32(_)))); + } + } + + #[cfg(not(all(windows, target_pointer_width = "32")))] + #[test] + fn system32_policy_rejects_paths() { + assert!(!is_bare_system_module_name( + r"C:\Windows\System32\kernel32.dll" + )); + assert!(is_bare_system_module_name("kernel32.dll")); + } + + #[cfg(all(windows, target_pointer_width = "32"))] + #[test] + fn x86_plan_binding_fails_before_loading_or_dispatch() { + let error = unsafe { + CallPlan::new(CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "MulDiv".into(), + parameters: vec![ + Parameter::input(Type::I32, false), + Parameter::input(Type::I32, false), + Parameter::input(Type::I32, false), + ], + return_type: Some(Type::I32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::Always, + capture_last_error: false, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None; 3], + return_aggregate: None, + }) + } + .unwrap_err(); + assert!(error.message().contains("reject 32-bit targets")); + } + + #[test] + fn call_plan_is_publishable_across_threads() { + fn assert_send_sync() {} + assert_send_sync::(); + } + + #[test] + fn hresult_success_rule_accepts_s_false_and_rejects_failures() { + assert!(success_matches(SuccessRule::HResultSucceeded, Some(&AbiValue::I32(1))).unwrap()); + assert!(!success_matches(SuccessRule::HResultSucceeded, Some(&AbiValue::I32(-1))).unwrap()); + } + + #[test] + fn failed_direct_handle_sentinel_is_never_cleaned() { + outcome_tests::reset(); + let result = NativeReturn { + value: Some(AbiValue::Pointer(usize::MAX as *mut c_void)), + cleanup: result_cleanup(ResultPolicy::Undefined {}), + }; + drop(result); + assert_eq!(outcome_tests::cleanup_count_for(usize::MAX), 0); + } + + #[test] + fn registry_handle_output_is_adopted_only_on_success() { + #[cfg(target_pointer_width = "64")] + { + let plan = unsafe { + CallPlan::new(CallPlanSpec { + dll: "advapi32.dll".into(), + entry_point: "RegOpenKeyExW".into(), + parameters: vec![ + Parameter::input(Type::Handle, false), + Parameter::input(Type::Pointer, false), + Parameter::input(Type::U32, false), + Parameter::input(Type::U32, false), + Parameter::output(Type::Handle, Cleanup::RegCloseKey), + ], + return_type: Some(Type::I32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::ReturnZero, + capture_last_error: false, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None; 5], + return_aggregate: None, + }) + } + .unwrap(); + let existing = wide(r"SOFTWARE\Microsoft\Windows NT\CurrentVersion"); + let opened = unsafe { + plan.invoke(&[ + Value::Handle(0x80000002), + Value::Pointer(existing.as_ptr() as *mut c_void), + Value::U32(0), + Value::U32(0x20019), + ]) + } + .unwrap(); + assert!(opened.succeeded); + let resource = opened.outputs[0].resource().unwrap(); + assert_ne!(resource.raw(), 0); + let wrong_cleanup = unsafe { + CallPlan::new(CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "CloseHandle".into(), + parameters: vec![Parameter { + typ: Type::Handle, + direction: Direction::In, + nullable: false, + cleanup: Cleanup::None, + consumes_resource: true, + resource_cleanup: Cleanup::CloseHandle, + }], + return_type: Some(Type::Bool32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::ReturnNonZero, + capture_last_error: true, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None], + return_aggregate: None, + }) + } + .unwrap(); + let error = unsafe { wrong_cleanup.invoke(&[Value::Resource(Arc::clone(resource))]) } + .unwrap_err(); + assert!(error.message().contains("cleanup kind does not match")); + assert!(!resource.is_closed()); + let close = unsafe { + CallPlan::new(CallPlanSpec { + dll: "advapi32.dll".into(), + entry_point: "RegCloseKey".into(), + parameters: vec![Parameter { + typ: Type::Handle, + direction: Direction::In, + nullable: false, + cleanup: Cleanup::None, + consumes_resource: true, + resource_cleanup: Cleanup::RegCloseKey, + }], + return_type: Some(Type::I32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::ReturnZero, + capture_last_error: false, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None], + return_aggregate: None, + }) + } + .unwrap(); + let raw_error = unsafe { close.invoke(&[Value::Handle(resource.raw())]) }.unwrap_err(); + assert!( + raw_error + .message() + .contains("require a managed resource object") + ); + assert!(!resource.is_closed()); + let closed = unsafe { close.invoke(&[Value::Resource(Arc::clone(resource))]) }.unwrap(); + assert!(closed.succeeded); + assert!(resource.is_closed()); + resource.close().unwrap(); + + let missing = wide(r"SOFTWARE\DynWinRT\DefinitelyMissing"); + let failed = unsafe { + plan.invoke(&[ + Value::Handle(0x80000002), + Value::Pointer(missing.as_ptr() as *mut c_void), + Value::U32(0), + Value::U32(0x20019), + ]) + } + .unwrap(); + assert!(!failed.succeeded); + assert!(matches!(failed.outputs[0], Value::Handle(0))); + } + } + + #[test] + fn native_aggregate_layout_rejects_excessive_sizes() { + let error = NativeAggregateLayout::new( + "Tests.Huge", + MAX_NATIVE_AGGREGATE_SIZE + 8, + 8, + FfiType::structure(vec![FfiType::u64()]), + ) + .unwrap_err(); + assert!(error.message().contains("invalid native aggregate")); + } + + #[test] + fn global_alloc_resource_uses_global_free_once() { + use windows::Win32::System::Memory::{GMEM_FIXED, GlobalAlloc}; + + let allocation = unsafe { GlobalAlloc(GMEM_FIXED, 32) }.unwrap(); + let resource = OwnedResource::new(allocation.0 as usize, Cleanup::GlobalFree); + assert!(!resource.is_closed()); + resource.close().unwrap(); + assert!(resource.is_closed()); + resource.close().unwrap(); + } + + #[test] + fn consuming_call_lock_rejects_an_async_lease() { + use windows::Win32::System::Memory::{GMEM_FIXED, GlobalAlloc}; + + let allocation = unsafe { GlobalAlloc(GMEM_FIXED, 32) }.unwrap(); + let resource = + unsafe { OwnedResource::adopt(allocation.0 as usize, Cleanup::GlobalFree) }.unwrap(); + let lease = resource.async_lease(Cleanup::GlobalFree).unwrap(); + let error = resource.lock_for_call(ResourceAccess::Consume).unwrap_err(); + assert!(error.message().contains("asynchronous I/O is pending")); + drop(lease); + + let guard = resource.lock_for_call(ResourceAccess::Consume).unwrap(); + assert_eq!(*guard, allocation.0 as usize); + drop(guard); + resource.close().unwrap(); + } + + #[test] + fn async_lease_creation_is_atomic_with_consumption() { + use windows::Win32::System::Memory::{GMEM_FIXED, GlobalAlloc}; + let allocation = unsafe { GlobalAlloc(GMEM_FIXED, 16) }.unwrap(); + let resource = + unsafe { OwnedResource::adopt(allocation.0 as usize, Cleanup::GlobalFree) }.unwrap(); + let mut consuming = resource.lock_for_call(ResourceAccess::Consume).unwrap(); + let other = Arc::clone(&resource); + let (started, ready) = std::sync::mpsc::channel(); + let acquiring = std::thread::spawn(move || { + started.send(()).unwrap(); + other.async_lease(Cleanup::GlobalFree) + }); + ready.recv().unwrap(); + assert!(!resource.has_async_leases()); + unsafe { Cleanup::GlobalFree.run(*consuming) }.unwrap(); + *consuming = 0; + drop(consuming); + let result = acquiring.join().unwrap(); + assert!(result.is_err()); + assert!(resource.is_closed()); + assert!(!resource.has_async_leases()); + } + + #[test] + #[cfg(target_pointer_width = "64")] + fn void_exports_capture_last_error_without_a_synthetic_return() { + let plan = unsafe { + CallPlan::new(CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "SetLastError".into(), + parameters: vec![Parameter::input(Type::U32, false)], + return_type: None, + return_cleanup: Cleanup::None, + success_rule: SuccessRule::Always, + capture_last_error: true, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None], + return_aggregate: None, + }) + } + .unwrap(); + let result = unsafe { plan.invoke(&[Value::U32(1234)]) }.unwrap(); + assert!(result.succeeded); + assert!(result.return_value.is_none()); + assert!(result.outputs.is_empty()); + assert_eq!(result.last_error, Some(1234)); + } + + #[test] + fn last_error_is_captured_with_the_native_result() { + #[cfg(target_pointer_width = "64")] + { + let plan = unsafe { + CallPlan::new(CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "GetModuleHandleW".into(), + parameters: vec![Parameter::input(Type::Pointer, false)], + return_type: Some(Type::Handle), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::Always, + capture_last_error: true, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None], + return_aggregate: None, + }) + } + .unwrap(); + let missing = wide("dynwinrt-module-that-is-not-loaded.dll"); + let result = + unsafe { plan.invoke(&[Value::Pointer(missing.as_ptr() as *mut c_void)]) }.unwrap(); + assert!(matches!(result.return_value, Some(Value::Handle(0)))); + assert_eq!(result.last_error, Some(126)); + } + } +} diff --git a/crates/dynwinrt/src/win32_aggregate.rs b/crates/dynwinrt/src/win32_aggregate.rs new file mode 100644 index 00000000..36cd9d90 --- /dev/null +++ b/crates/dynwinrt/src/win32_aggregate.rs @@ -0,0 +1,526 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Caller-owned aggregate memory and independently owned native result fields. + +use std::{ + collections::BTreeSet, + ffi::c_void, + sync::{Arc, Mutex, MutexGuard}, +}; + +use super::{ + Cleanup, MAX_NATIVE_AGGREGATE_SIZE, OwnedResource, ResultPolicy, Type, Value, invalid_argument, + result_cleanup, +}; +use crate::{ + abi::AbiValue, + result::{Error, Result}, +}; + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct AggregateResultField { + pub name: String, + pub offset: usize, + pub typ: Type, + pub cleanup: Cleanup, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct NativeAggregatePointerLayout { + identity: String, + size: usize, + alignment: usize, + fields: Vec, +} + +impl NativeAggregatePointerLayout { + pub fn new( + identity: String, + size: usize, + alignment: usize, + fields: Vec, + ) -> Result> { + if identity.is_empty() + || size == 0 + || size > MAX_NATIVE_AGGREGATE_SIZE + || alignment == 0 + || alignment > 8 + || !alignment.is_power_of_two() + || size % alignment != 0 + || fields.len() > dynwinrt_win32_contracts::MAX_PARAMETERS + { + return Err(invalid_argument("Invalid native aggregate pointer layout")); + } + let mut names = BTreeSet::new(); + let mut ranges = Vec::new(); + for field in &fields { + let length = field_size(field.typ); + let end = field + .offset + .checked_add(length) + .filter(|end| *end <= size) + .ok_or_else(|| invalid_argument("Aggregate result field exceeds caller storage"))?; + if field.name.is_empty() + || !names.insert(field.name.clone()) + || ranges + .iter() + .any(|(start, prior_end)| field.offset < *prior_end && *start < end) + || (field.cleanup.owns_resource() + && !matches!(field.typ, Type::Handle | Type::Pointer)) + { + return Err(invalid_argument( + "Invalid or overlapping aggregate result field", + )); + } + ranges.push((field.offset, end)); + } + Ok(Arc::new(Self { + identity, + size, + alignment, + fields, + })) + } + + pub fn identity(&self) -> &str { + &self.identity + } + pub fn size(&self) -> usize { + self.size + } + pub fn alignment(&self) -> usize { + self.alignment + } + pub fn fields(&self) -> &[AggregateResultField] { + &self.fields + } +} + +#[derive(Debug)] +pub struct NativeAggregateBuffer { + layout: Arc, + pointer: usize, + state: Mutex, +} + +pub struct NativeAggregateLease<'a> { + _state: MutexGuard<'a, AggregateBufferState>, +} + +#[derive(Debug)] +pub(super) struct AggregateBufferState { + pub(super) words: Vec, + pub(super) results: Vec>, + pub(super) raw_cleanup: Vec, + pub(super) policies: Vec, + pub(super) succeeded: Option, + pub(super) native_recorded: bool, +} + +impl NativeAggregateBuffer { + pub fn new( + layout: Arc, + bytes: Option<&[u8]>, + ) -> Result> { + let mut words = super::try_zeroed_words(layout.size)?; + if let Some(bytes) = bytes { + if bytes.len() != layout.size { + return Err(invalid_argument( + "Native aggregate initialization has the wrong size", + )); + } + unsafe { + std::ptr::copy_nonoverlapping( + bytes.as_ptr(), + words.as_mut_ptr().cast::(), + bytes.len(), + ); + } + } + let pointer = words.as_mut_ptr() as usize; + let count = layout.fields.len(); + Ok(Arc::new(Self { + layout, + pointer, + state: Mutex::new(AggregateBufferState { + words, + results: vec![None; count], + raw_cleanup: vec![Cleanup::None; count], + policies: vec![ResultPolicy::Undefined {}; count], + succeeded: None, + native_recorded: false, + }), + })) + } + + pub fn layout(&self) -> &Arc { + &self.layout + } + pub fn pointer(&self) -> *mut c_void { + self.pointer as *mut c_void + } + + pub(super) fn lock(&self) -> MutexGuard<'_, AggregateBufferState> { + self.state.lock().unwrap_or_else(|error| error.into_inner()) + } + + pub fn lease(&self) -> NativeAggregateLease<'_> { + NativeAggregateLease { + _state: self.lock(), + } + } + + pub fn bytes(&self) -> Result> { + let state = self.lock(); + let mut bytes = Vec::new(); + bytes + .try_reserve_exact(self.layout.size) + .map_err(|_| super::out_of_memory("native aggregate bytes"))?; + let raw = unsafe { + std::slice::from_raw_parts(state.words.as_ptr().cast::(), self.layout.size) + }; + bytes.extend_from_slice(raw); + Ok(bytes) + } + + pub fn read(&self, offset: usize) -> Result<[u8; N]> { + self.check_range(offset, N)?; + let state = self.lock(); + let mut bytes = [0; N]; + unsafe { + std::ptr::copy_nonoverlapping( + state.words.as_ptr().cast::().add(offset), + bytes.as_mut_ptr(), + N, + ); + } + Ok(bytes) + } + + /// Copies caller storage without transferring resource ownership. Writes + /// overlapping owned fields that still await raw cleanup are rejected. + pub fn write(&self, offset: usize, bytes: &[u8]) -> Result<()> { + self.check_range(offset, bytes.len())?; + let mut state = self.lock(); + let end = offset + bytes.len(); + // Undecoded owned fields still use their stored bytes as cleanup targets. + if !bytes.is_empty() + && self.layout.fields.iter().enumerate().any(|(index, field)| { + state.raw_cleanup[index].owns_resource() + && offset < field.offset + field_size(field.typ) + && field.offset < end + }) + { + return Err(invalid_argument( + "Cannot overwrite an aggregate field while its owned result awaits cleanup", + )); + } + unsafe { + std::ptr::copy_nonoverlapping( + bytes.as_ptr(), + state.words.as_mut_ptr().cast::().add(offset), + bytes.len(), + ); + } + Ok(()) + } + + fn check_range(&self, offset: usize, size: usize) -> Result<()> { + if offset + .checked_add(size) + .is_none_or(|end| end > self.layout.size) + { + return Err(invalid_argument( + "Native aggregate field exceeds caller storage", + )); + } + Ok(()) + } + + pub fn prepare(&self) -> Result<()> { + self.lock().prepare(&self.layout) + } + + pub fn require_success(&self) -> Result<()> { + match self.lock().succeeded { + Some(true) => Ok(()), + Some(false) => Err(invalid_argument( + "native aggregate outputs are unavailable because the native call failed", + )), + None => Err(invalid_argument( + "native aggregate outputs are unavailable before a successful native call", + )), + } + } + + pub fn field_index(&self, name: &str) -> Option { + self.layout + .fields + .iter() + .position(|field| field.name == name) + } + + pub fn field_value(&self, index: usize) -> Result { + let state = self.lock(); + let value = state + .results + .get(index) + .and_then(Option::as_ref) + .ok_or_else(|| unavailable_field(state.succeeded))?; + if matches!(value, Value::Unavailable | Value::Discarded) { + return Err(unavailable_field(state.succeeded)); + } + Ok(value.clone()) + } + + pub fn take_field(&self, index: usize) -> Result { + let mut state = self.lock(); + let field = self + .layout + .fields + .get(index) + .ok_or_else(|| invalid_argument("Unknown native aggregate result field"))?; + let value = state.results[index] + .as_ref() + .ok_or_else(|| unavailable_field(state.succeeded))?; + if matches!(value, Value::Unavailable | Value::Discarded) { + return Err(unavailable_field(state.succeeded)); + } + let result = state.results[index] + .replace(Value::Handle(0)) + .expect("checked result"); + state.zero(field); + Ok(result) + } + + /// Compatibility for manually described calls. Generated contracts register + /// results inside CallPlan and cannot have that ownership erased by JS. + /// + /// # Safety + /// + /// When registering previously unrecorded successful legacy outputs, all + /// result fields must be initialized and valid for their declared types. Every non-null + /// owned field must transfer exclusive ownership of a live resource with the + /// exact declared cleanup. It must not alias another owning field or a + /// resource still owned elsewhere, including a borrowed `File`/`OwnedHandle`. + /// External native writes must have completed, and the resources must not be + /// freed or transferred concurrently with this call. Layout validation and + /// caller-written bytes do not establish any of these ownership guarantees. + /// + /// ```compile_fail,E0133 + /// #![forbid(unsafe_code)] + /// use std::{fs::File, os::windows::io::AsRawHandle}; + /// use dynwinrt::win32::{ + /// AggregateResultField, Cleanup, NativeAggregateBuffer, + /// NativeAggregatePointerLayout, Type, + /// }; + /// + /// fn cannot_adopt_a_borrowed_file(file: &File) { + /// let layout = NativeAggregatePointerLayout::new( + /// "BorrowedFile".into(), size_of::(), align_of::(), + /// vec![AggregateResultField { + /// name: "handle".into(), offset: 0, + /// typ: Type::Handle, cleanup: Cleanup::CloseHandle, + /// }], + /// ).unwrap(); + /// let buffer = NativeAggregateBuffer::new(layout, None).unwrap(); + /// buffer.write(0, &(file.as_raw_handle() as usize).to_ne_bytes()).unwrap(); + /// buffer.mark_legacy(true).unwrap(); + /// } + /// ``` + pub unsafe fn mark_legacy(&self, succeeded: bool) -> Result<()> { + let mut state = self.lock(); + if state.native_recorded || state.succeeded == Some(true) { + return if state.succeeded == Some(succeeded) { + Ok(()) + } else { + Err(invalid_argument( + "Cannot overwrite native aggregate result ownership", + )) + }; + } + state.succeeded = Some(succeeded); + for (index, field) in self.layout.fields.iter().enumerate() { + state.policies[index] = if succeeded { + let ownership = if field.cleanup.owns_resource() { + super::ResultOwnership::Owned { + cleanup: field.cleanup.into(), + } + } else if matches!( + field.typ, + Type::Handle | Type::Pointer | Type::FunctionPointer + ) { + super::ResultOwnership::Borrowed {} + } else { + super::ResultOwnership::Value {} + }; + ResultPolicy::delivered(ownership) + } else { + ResultPolicy::Undefined {} + }; + state.raw_cleanup[index] = result_cleanup(state.policies[index]); + } + for (index, field) in self.layout.fields.iter().enumerate() { + if !succeeded { + state.results[index] = Some(Value::Unavailable); + continue; + } + let raw = state.read_abi(field); + let value = if field.cleanup.owns_resource() { + let AbiValue::Pointer(pointer) = raw else { + unreachable!("validated owned field"); + }; + if pointer.is_null() { + Value::Handle(0) + } else { + Value::Resource(unsafe { + super::OwnedResource::adopt(pointer as usize, field.cleanup) + }?) + } + } else { + super::decode_plain_value(field.typ, raw)? + }; + state.raw_cleanup[index] = Cleanup::None; + state.results[index] = Some(value); + } + Ok(()) + } +} + +impl AggregateBufferState { + fn owned_resource(&self, index: usize) -> Option<&Arc> { + if matches!( + self.policies[index], + ResultPolicy::Defined { + ownership: super::ResultOwnership::Owned { .. }, + .. + } + ) { + self.results[index].as_ref().and_then(Value::resource) + } else { + None + } + } + + pub(super) fn owned_resources(&self) -> impl Iterator> { + (0..self.results.len()).filter_map(|index| self.owned_resource(index)) + } + + pub(super) fn prepare(&mut self, layout: &NativeAggregatePointerLayout) -> Result<()> { + self.prepare_with_owned_cleanup(layout, |resource| resource.close()) + } + + pub(super) fn prepare_with_owned_cleanup( + &mut self, + layout: &NativeAggregatePointerLayout, + mut close: impl FnMut(&Arc) -> windows_core::Result<()>, + ) -> Result<()> { + let mut first_error = self.cleanup_raw(layout).err(); + for (index, field) in layout.fields.iter().enumerate() { + if let Some(resource) = self.owned_resource(index) { + if let Err(error) = close(resource) { + first_error.get_or_insert(Error::WindowsError(error)); + continue; + } + } + if self.raw_cleanup[index].owns_resource() { + continue; + } + self.results[index] = None; + self.zero(field); + } + if let Some(error) = first_error { + return Err(error); + } + self.policies.fill(ResultPolicy::Undefined {}); + self.succeeded = Some(false); + self.native_recorded = false; + Ok(()) + } + + pub(super) fn read_abi(&self, field: &AggregateResultField) -> AbiValue { + let pointer = unsafe { self.words.as_ptr().cast::().add(field.offset) }; + unsafe { + match field.typ { + Type::Bool32 | Type::I32 => AbiValue::I32(pointer.cast::().read_unaligned()), + Type::I8 => AbiValue::I8(pointer.cast::().read_unaligned()), + Type::U8 => AbiValue::U8(pointer.read()), + Type::I16 => AbiValue::I16(pointer.cast::().read_unaligned()), + Type::U16 => AbiValue::U16(pointer.cast::().read_unaligned()), + Type::U32 => AbiValue::U32(pointer.cast::().read_unaligned()), + Type::I64 => AbiValue::I64(pointer.cast::().read_unaligned()), + Type::U64 => AbiValue::U64(pointer.cast::().read_unaligned()), + Type::F32 => AbiValue::F32(pointer.cast::().read_unaligned()), + Type::F64 => AbiValue::F64(pointer.cast::().read_unaligned()), + Type::Handle | Type::Pointer | Type::FunctionPointer => { + AbiValue::Pointer(pointer.cast::().read_unaligned() as *mut c_void) + } + } + } + } + + fn zero(&mut self, field: &AggregateResultField) { + unsafe { + std::ptr::write_bytes( + self.words.as_mut_ptr().cast::().add(field.offset), + 0, + field_size(field.typ), + ); + } + } + + fn cleanup_raw(&mut self, layout: &NativeAggregatePointerLayout) -> Result<()> { + let mut first_error = None; + for (index, field) in layout.fields.iter().enumerate() { + let cleanup = self.raw_cleanup[index]; + if cleanup.owns_resource() { + let AbiValue::Pointer(pointer) = self.read_abi(field) else { + unreachable!("validated owned field"); + }; + if let Err(error) = unsafe { cleanup.run(pointer as usize) } { + first_error.get_or_insert(Error::WindowsError(error)); + } else { + self.raw_cleanup[index] = Cleanup::None; + self.zero(field); + } + } + } + first_error.map_or(Ok(()), Err) + } +} + +impl Drop for NativeAggregateBuffer { + fn drop(&mut self) { + let state = self + .state + .get_mut() + .unwrap_or_else(|error| error.into_inner()); + if let Err(error) = state.cleanup_raw(&self.layout) { + eprintln!( + "[dynwinrt] native aggregate field cleanup failed: {}", + error.message() + ); + } + } +} + +pub(super) fn field_size(typ: Type) -> usize { + match typ { + Type::I8 | Type::U8 => 1, + Type::I16 | Type::U16 => 2, + Type::Bool32 | Type::I32 | Type::U32 | Type::F32 => 4, + Type::I64 | Type::U64 | Type::F64 => 8, + Type::Pointer | Type::FunctionPointer | Type::Handle => size_of::(), + } +} + +fn unavailable_field(succeeded: Option) -> Error { + invalid_argument(match succeeded { + None => "native aggregate outputs are unavailable before a successful native call", + Some(false) => "native aggregate outputs are unavailable because the native call failed", + Some(true) => { + "native aggregate outputs are unavailable because the native field is not deliverable" + } + }) +} diff --git a/crates/dynwinrt/src/win32_aggregate_effect_tests.rs b/crates/dynwinrt/src/win32_aggregate_effect_tests.rs new file mode 100644 index 00000000..6f1740e0 --- /dev/null +++ b/crates/dynwinrt/src/win32_aggregate_effect_tests.rs @@ -0,0 +1,299 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use std::{fs::OpenOptions, os::windows::fs::OpenOptionsExt}; +use windows::Win32::Storage::FileSystem::{ + FILE_FLAG_OVERLAPPED, SetFileCompletionNotificationModes, +}; + +#[derive(Clone, Copy, Debug)] +enum Failure { + None, + Field(usize), + DiscardCleanup, + Return, +} + +const FAILURES: [Failure; 5] = [ + Failure::None, + Failure::Field(0), + Failure::Field(1), + Failure::DiscardCleanup, + Failure::Return, +]; + +fn effect_plan( + function: usize, + parameters: Vec, + layout: Arc, + failure: Failure, + resource_effects: Vec, +) -> Arc { + let mut spec = spec(); + spec.parameter_aggregates = vec![None; parameters.len()]; + spec.parameters = parameters; + let mut pointees = vec![None; spec.parameters.len()]; + pointees[1] = Some(layout); + let mut contract = CallContract { + resource_effects, + ..CallContract::default() + } + .upgrade_metadata(&contract::shape_with_pointees(&spec, &pointees)) + .unwrap(); + for result in &mut contract.results { + if matches!(result.target, ResultTarget::AggregateField { .. }) { + result.on_failure = result.on_success; + } + if matches!(failure, Failure::DiscardCleanup) + && matches!( + result.target, + ResultTarget::AggregateField { + parameter: 1, + field: 0 + } + ) + { + let policy = ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: dynwinrt_win32_contracts::Cleanup::CloseHandle, + }); + result.on_success = policy; + result.on_failure = policy; + } + } + let mut plan = Arc::try_unwrap( + unsafe { CallPlan::new_with_contract_and_pointees(spec, contract, pointees) }.unwrap(), + ) + .unwrap(); + plan.function = function; + match failure { + Failure::Field(field) => outcome_tests::fail_decode(ResultTarget::AggregateField { + parameter: 1, + field, + }), + Failure::Return => outcome_tests::fail_decode(ResultTarget::Return {}), + Failure::None | Failure::DiscardCleanup => {} + } + Arc::new(plan) +} + +#[test] +fn native_consumption_commits_before_fallible_aggregate_results() { + unsafe extern "system" fn consume( + input: *mut c_void, + output: *mut NativeInfo, + succeeded: i32, + fail_cleanup: i32, + ) -> i32 { + unsafe { + produce(output); + if fail_cleanup != 0 { + protect_handle((*output).process, true); + } + // Create outputs before consuming the input so their HANDLEs cannot reuse it. + if succeeded != 0 { + CloseHandle(HANDLE(input)).unwrap(); + } + } + succeeded + } + + for succeeded in [false, true] { + for failure in FAILURES { + outcome_tests::reset(); + let handle = + unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + let raw = handle.0 as usize; + let input = unsafe { OwnedResource::adopt(raw, Cleanup::CloseHandle) }.unwrap(); + let alias = Arc::clone(&input); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let plan = effect_plan( + consume as *const () as usize, + vec![ + Parameter { + consumes_resource: true, + resource_cleanup: Cleanup::CloseHandle, + ..Parameter::input(Type::Handle, false) + }, + Parameter::input(Type::Pointer, false), + Parameter::input(Type::Bool32, false), + Parameter::input(Type::Bool32, false), + ], + layout, + failure, + Vec::new(), + ); + let discard = matches!(failure, Failure::DiscardCleanup); + let result = unsafe { + plan.invoke(&[ + Value::Resource(Arc::clone(&input)), + Value::AggregatePointer(Arc::clone(&buffer)), + Value::Bool(succeeded), + Value::Bool(discard), + ]) + }; + let returned_success = result.as_ref().ok().map(|result| result.succeeded); + let expected_success = matches!(failure, Failure::None).then_some(succeeded); + drop(result); + let observed = ( + input.is_closed(), + alias.raw(), + input + .lease(Cleanup::CloseHandle) + .ok() + .map(|lease| lease.raw()), + alias + .async_lease(Cleanup::CloseHandle) + .ok() + .map(|lease| lease.raw()), + ); + let expected = if succeeded { + (true, 0, None, None) + } else { + (false, raw, Some(raw), Some(raw)) + }; + // Observe first, then repair a stale fixture owner to avoid closing a reused HANDLE. + if succeeded { + *input.lock_for_call(ResourceAccess::Consume).unwrap() = 0; + } + let output_handles = native_handles(&buffer); + if discard { + protect_handle(output_handles[0], false); + } + drop(buffer); + input.close().unwrap(); + input.close().unwrap(); + drop(alias); + drop(input); + let output_counts = retirement_counts(output_handles); + assert_eq!( + returned_success, expected_success, + "{succeeded}, {failure:?}" + ); + assert_eq!(observed, expected, "{succeeded}, {failure:?}"); + assert_eq!( + outcome_tests::cleanup_count_for(raw), + usize::from(!succeeded) + ); + assert_eq!( + outcome_tests::successful_cleanup_count_for(raw), + usize::from(!succeeded) + ); + assert_eq!(output_counts, [(if discard { 2 } else { 1 }, 1), (1, 1)]); + } + } +} + +#[test] +fn native_resource_effects_commit_before_fallible_aggregate_results() { + const FILE_SKIP_SET_EVENT_ON_HANDLE: u8 = 2; + + unsafe extern "system" fn set_modes( + input: *mut c_void, + output: *mut NativeInfo, + modes: u8, + succeeded: i32, + fail_cleanup: i32, + ) -> i32 { + unsafe { + produce(output); + if fail_cleanup != 0 { + protect_handle((*output).process, true); + } + if succeeded != 0 { + SetFileCompletionNotificationModes(HANDLE(input), modes).unwrap(); + } + } + succeeded + } + + for succeeded in [false, true] { + for failure in FAILURES { + outcome_tests::reset(); + let file = OpenOptions::new() + .read(true) + .custom_flags(FILE_FLAG_OVERLAPPED.0) + .open(std::env::current_exe().unwrap()) + .unwrap(); + let raw = file.into_raw_handle() as usize; + let input = unsafe { OwnedResource::adopt(raw, Cleanup::CloseHandle) }.unwrap(); + let initial_modes = input + .async_lease(Cleanup::CloseHandle) + .unwrap() + .completion_modes() + .unwrap(); + assert_eq!(initial_modes & u32::from(FILE_SKIP_SET_EVENT_ON_HANDLE), 0); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let plan = effect_plan( + set_modes as *const () as usize, + vec![ + Parameter { + resource_cleanup: Cleanup::CloseHandle, + ..Parameter::input(Type::Handle, false) + }, + Parameter::input(Type::Pointer, false), + Parameter::input(Type::U8, false), + Parameter::input(Type::Bool32, false), + Parameter::input(Type::Bool32, false), + ], + layout, + failure, + vec![ResourceEffect::AddFileCompletionModes { + handle_parameter: 0, + flags_parameter: 2, + }], + ); + let discard = matches!(failure, Failure::DiscardCleanup); + let result = unsafe { + plan.invoke(&[ + Value::Resource(Arc::clone(&input)), + Value::AggregatePointer(Arc::clone(&buffer)), + Value::U8(FILE_SKIP_SET_EVENT_ON_HANDLE), + Value::Bool(succeeded), + Value::Bool(discard), + ]) + }; + let returned_success = result.as_ref().ok().map(|result| result.succeeded); + let expected_success = matches!(failure, Failure::None).then_some(succeeded); + drop(result); + let cached_modes = input.file_capability().cached_completion_modes(); + let native_modes = input + .async_lease(Cleanup::CloseHandle) + .unwrap() + .completion_modes() + .unwrap(); + let output_handles = native_handles(&buffer); + if discard { + protect_handle(output_handles[0], false); + } + drop(buffer); + let still_open = !input.is_closed() && input.raw() == raw; + input.close().unwrap(); + drop(input); + let output_counts = retirement_counts(output_handles); + let expected_modes = initial_modes + | if succeeded { + u32::from(FILE_SKIP_SET_EVENT_ON_HANDLE) + } else { + 0 + }; + assert_eq!( + returned_success, expected_success, + "{succeeded}, {failure:?}" + ); + assert_eq!(native_modes, expected_modes); + assert_eq!( + cached_modes, + Some(expected_modes), + "{succeeded}, {failure:?}" + ); + assert!(still_open); + assert_eq!(outcome_tests::cleanup_count_for(raw), 1); + assert_eq!(outcome_tests::successful_cleanup_count_for(raw), 1); + assert_eq!(output_counts, [(if discard { 2 } else { 1 }, 1), (1, 1)]); + } + } +} diff --git a/crates/dynwinrt/src/win32_aggregate_lock_tests.rs b/crates/dynwinrt/src/win32_aggregate_lock_tests.rs new file mode 100644 index 00000000..48c729a3 --- /dev/null +++ b/crates/dynwinrt/src/win32_aggregate_lock_tests.rs @@ -0,0 +1,409 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use std::{ + process::Command, + sync::{Barrier, mpsc}, + thread, + time::{Duration, Instant}, +}; +use windows::Win32::System::Threading::{CreateEventW, GetCurrentProcess}; + +fn event() -> Arc { + let handle = unsafe { CreateEventW(None, true, false, None) }.unwrap(); + unsafe { OwnedResource::adopt(handle.0 as usize, Cleanup::CloseHandle) }.unwrap() +} + +fn handle_layout() -> Arc { + NativeAggregatePointerLayout::new( + "Tests.DuplicatedHandle".into(), + size_of::(), + align_of::(), + vec![AggregateResultField { + name: "handle".into(), + offset: 0, + typ: Type::Handle, + cleanup: Cleanup::CloseHandle, + }], + ) + .unwrap() +} + +fn duplicate_plan(layout: Arc) -> Arc { + let mut spec = spec(); + spec.entry_point = "DuplicateHandle".into(); + spec.parameters = vec![ + Parameter::input(Type::Handle, false), + Parameter { + resource_cleanup: Cleanup::CloseHandle, + ..Parameter::input(Type::Handle, false) + }, + Parameter::input(Type::Handle, false), + Parameter::input(Type::Pointer, false), + Parameter::input(Type::U32, false), + Parameter::input(Type::Bool32, false), + Parameter::input(Type::U32, false), + ]; + spec.parameter_aggregates = vec![None; 7]; + spec.capture_last_error = true; + let mut pointees = vec![None; 7]; + pointees[3] = Some(layout); + let contract = CallContract::default() + .upgrade_metadata(&contract::shape_with_pointees(&spec, &pointees)) + .unwrap(); + unsafe { CallPlan::new_with_contract_and_pointees(spec, contract, pointees) }.unwrap() +} + +fn duplicate( + plan: &CallPlan, + input: &Arc, + buffer: &Arc, +) -> Result { + duplicate_with_access(plan, input, buffer, Value::U32(0)) +} + +fn duplicate_with_access( + plan: &CallPlan, + input: &Arc, + buffer: &Arc, + access: Value, +) -> Result { + let process = unsafe { GetCurrentProcess() }.0 as usize; + unsafe { + plan.invoke(&[ + Value::Handle(process), + Value::Resource(Arc::clone(input)), + Value::Handle(process), + Value::AggregatePointer(Arc::clone(buffer)), + access, + Value::Bool(false), + Value::U32(2), + ]) + } +} + +fn field_owner(buffer: &NativeAggregateBuffer) -> Arc { + Arc::clone(buffer.field_value(0).unwrap().resource().unwrap()) +} + +fn reuse(case: &str) { + let layout = handle_layout(); + let plan = duplicate_plan(Arc::clone(&layout)); + let buffer = NativeAggregateBuffer::new(layout, None).unwrap(); + let original = event(); + assert!(duplicate(&plan, &original, &buffer).unwrap().succeeded); + let old = field_owner(&buffer); + let before = buffer.bytes().unwrap(); + println!("[aggregate-locks] {case}: first DuplicateHandle succeeded"); + match case { + "shared" => { + let error = duplicate(&plan, &old, &buffer).unwrap_err(); + assert!( + error.message().contains("aggregate output owner"), + "{error:?}" + ); + assert_eq!(buffer.bytes().unwrap(), before); + assert!(Arc::ptr_eq(&field_owner(&buffer), &old)); + assert!(!old.is_closed()); + drop(old.lease(Cleanup::CloseHandle).unwrap()); + let taken = buffer.take_field(0).unwrap(); + assert!( + duplicate(&plan, taken.resource().unwrap(), &buffer) + .unwrap() + .succeeded + ); + assert!(!old.is_closed()); + } + "take" => { + let taken = buffer.take_field(0).unwrap(); + assert!( + duplicate(&plan, taken.resource().unwrap(), &buffer) + .unwrap() + .succeeded + ); + assert!(!old.is_closed()); + } + "distinct" | "lock-order" => { + outcome_tests::reset(); + assert!(duplicate(&plan, &original, &buffer).unwrap().succeeded); + assert!(old.is_closed()); + assert!(!original.is_closed()); + if case == "lock-order" { + let mut expected = + vec![Arc::as_ptr(&old) as usize, Arc::as_ptr(&original) as usize]; + expected.sort_unstable(); + assert_eq!(outcome_tests::call_lock_order(), expected); + } + } + _ => unreachable!(), + } + assert!(!Arc::ptr_eq(&field_owner(&buffer), &old)); + drop(buffer); + old.close().unwrap(); + original.close().unwrap(); +} + +fn borrowed_alias_reuse() { + unsafe extern "system" fn alias(input: usize, output: *mut usize) -> i32 { + unsafe { *output = input }; + 1 + } + let layout = handle_layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let original = event(); + let mut spec = spec(); + spec.parameters = vec![ + Parameter { + resource_cleanup: Cleanup::CloseHandle, + ..Parameter::input(Type::Handle, false) + }, + Parameter::input(Type::Pointer, false), + ]; + spec.parameter_aggregates = vec![None; 2]; + let pointees = vec![None, Some(layout)]; + let mut contract = CallContract::default() + .upgrade_metadata(&contract::shape_with_pointees(&spec, &pointees)) + .unwrap(); + for result in &mut contract.results { + if matches!(result.target, ResultTarget::AggregateField { .. }) { + result.on_success = + ResultPolicy::delivered(ResultOwnership::AliasInput { parameter: 0 }); + } + } + let mut plan = Arc::try_unwrap( + unsafe { CallPlan::new_with_contract_and_pointees(spec, contract, pointees) }.unwrap(), + ) + .unwrap(); + plan.function = alias as *const () as usize; + for _ in 0..2 { + assert!( + unsafe { + plan.invoke(&[ + Value::Resource(Arc::clone(&original)), + Value::AggregatePointer(Arc::clone(&buffer)), + ]) + } + .unwrap() + .succeeded + ); + assert!(Arc::ptr_eq(&field_owner(&buffer), &original)); + assert!(!original.is_closed()); + } + drop(buffer); + assert!(!original.is_closed()); + original.close().unwrap(); +} + +fn conflict_preflight_preserves_all_old_outputs() { + unsafe extern "system" fn outputs( + _input: *mut c_void, + first: *mut NativeInfo, + second: *mut NativeInfo, + ) -> i32 { + unsafe { + produce(first); + produce(second); + } + 1 + } + let layout = layout(); + let first = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let second = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let original = event(); + let mut spec = spec(); + spec.parameters = vec![ + Parameter { + resource_cleanup: Cleanup::CloseHandle, + ..Parameter::input(Type::Handle, false) + }, + Parameter::input(Type::Pointer, false), + Parameter::input(Type::Pointer, false), + ]; + spec.parameter_aggregates = vec![None; 3]; + let pointees = vec![None, Some(Arc::clone(&layout)), Some(layout)]; + let contract = CallContract::default() + .upgrade_metadata(&contract::shape_with_pointees(&spec, &pointees)) + .unwrap(); + let mut plan = Arc::try_unwrap( + unsafe { CallPlan::new_with_contract_and_pointees(spec, contract, pointees) }.unwrap(), + ) + .unwrap(); + plan.function = outputs as *const () as usize; + let invoke = |input: &Arc| unsafe { + plan.invoke(&[ + Value::Resource(Arc::clone(input)), + Value::AggregatePointer(Arc::clone(&first)), + Value::AggregatePointer(Arc::clone(&second)), + ]) + }; + assert!(invoke(&original).unwrap().succeeded); + let owners = [ + Arc::clone(first.field_value(0).unwrap().resource().unwrap()), + Arc::clone(first.field_value(1).unwrap().resource().unwrap()), + Arc::clone(second.field_value(0).unwrap().resource().unwrap()), + Arc::clone(second.field_value(1).unwrap().resource().unwrap()), + ]; + let before = [first.bytes().unwrap(), second.bytes().unwrap()]; + let error = invoke(&owners[3]).unwrap_err(); + assert!(error.message().contains("aggregate output owner")); + assert_eq!([first.bytes().unwrap(), second.bytes().unwrap()], before); + for owner in &owners { + assert!(!owner.is_closed()); + } + drop(first); + drop(second); + for owner in owners { + owner.close().unwrap(); + } + original.close().unwrap(); +} + +fn failed_retirement_keeps_retryable_owner_and_closes_other_fields() { + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let plan = planned(layout); + let invoke = || unsafe { plan.invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) }; + assert!(invoke().unwrap().succeeded); + let first = Arc::clone(buffer.field_value(0).unwrap().resource().unwrap()); + let second = Arc::clone(buffer.field_value(1).unwrap().resource().unwrap()); + let raw = first.raw(); + protect_handle(raw, true); + let failed = invoke().is_err(); + protect_handle(raw, false); + assert!(failed); + assert!(!first.is_closed()); + assert!(second.is_closed()); + assert_eq!(native_handles(&buffer), [raw, 0]); + assert!(invoke().unwrap().succeeded); + assert!(first.is_closed()); + assert!(second.is_closed()); + drop(buffer); +} + +fn busy_or_invalid_calls_do_not_retire_outputs(case: &str) { + let layout = handle_layout(); + let plan = duplicate_plan(Arc::clone(&layout)); + let buffer = NativeAggregateBuffer::new(layout, None).unwrap(); + let original = event(); + assert!(duplicate(&plan, &original, &buffer).unwrap().succeeded); + let old = field_owner(&buffer); + let before = buffer.bytes().unwrap(); + let lease = (case == "busy-retirement").then(|| old.async_lease(Cleanup::CloseHandle).unwrap()); + let error = if lease.is_some() { + duplicate(&plan, &original, &buffer).unwrap_err() + } else { + duplicate_with_access(&plan, &original, &buffer, Value::Bool(false)).unwrap_err() + }; + if lease.is_some() { + assert!(error.message().contains("asynchronous I/O is pending")); + } + assert!(!old.is_closed()); + assert!(!original.is_closed()); + assert_eq!(buffer.bytes().unwrap(), before); + drop(lease); + assert!(duplicate(&plan, &original, &buffer).unwrap().succeeded); + assert!(old.is_closed()); + drop(buffer); + original.close().unwrap(); +} + +fn crossed_retirement() { + fn worker( + plan: Arc, + source: Arc, + barrier: Arc, + send: mpsc::Sender>, + receive: mpsc::Receiver>, + ) -> bool { + let buffer = NativeAggregateBuffer::new(handle_layout(), None).unwrap(); + assert!(duplicate(&plan, &source, &buffer).unwrap().succeeded); + send.send(field_owner(&buffer)).unwrap(); + let other = receive.recv().unwrap(); + barrier.wait(); + match duplicate(&plan, &other, &buffer) { + Ok(result) => { + assert!(result.succeeded); + true + } + Err(error) => { + assert!(error.message().contains("closed"), "{error:?}"); + false + } + } + } + + let plan = duplicate_plan(handle_layout()); + for _ in 0..8 { + let source = event(); + let barrier = Arc::new(Barrier::new(2)); + let (a_send, b_receive) = mpsc::channel(); + let (b_send, a_receive) = mpsc::channel(); + let (a_plan, a_source, a_barrier) = + (Arc::clone(&plan), Arc::clone(&source), Arc::clone(&barrier)); + let a = thread::spawn(move || worker(a_plan, a_source, a_barrier, a_send, a_receive)); + let (b_plan, b_source) = (Arc::clone(&plan), Arc::clone(&source)); + let b = thread::spawn(move || worker(b_plan, b_source, barrier, b_send, b_receive)); + let successes = usize::from(a.join().unwrap()) + usize::from(b.join().unwrap()); + assert_eq!(successes, 1); + source.close().unwrap(); + } +} + +#[test] +fn aggregate_owner_lock_cases_complete_without_deadlock() { + const CHILD_CASE: &str = "DYNWINRT_AGGREGATE_LOCK_CASE"; + match std::env::var(CHILD_CASE) { + Ok(case) => { + match case.as_str() { + "take" | "distinct" | "shared" | "lock-order" => reuse(&case), + "borrowed-alias" => borrowed_alias_reuse(), + "preflight-conflict" => conflict_preflight_preserves_all_old_outputs(), + "failed-retirement" => { + failed_retirement_keeps_retryable_owner_and_closes_other_fields() + } + "busy-retirement" | "invalid-input" => { + busy_or_invalid_calls_do_not_retire_outputs(&case) + } + "crossed-retirement" => crossed_retirement(), + _ => panic!("Unknown aggregate lock case: {case}"), + } + return; + } + Err(std::env::VarError::NotPresent) => {} + Err(error) => panic!("Invalid aggregate lock case: {error}"), + } + let name = std::any::type_name_of_val(&aggregate_owner_lock_cases_complete_without_deadlock); + let name = name.split_once("::").unwrap().1; + for case in [ + "take", + "distinct", + "shared", + "borrowed-alias", + "preflight-conflict", + "failed-retirement", + "busy-retirement", + "invalid-input", + "lock-order", + "crossed-retirement", + ] { + let mut child = Command::new(std::env::current_exe().unwrap()) + .args(["--exact", name, "--nocapture"]) + .env(CHILD_CASE, case) + .spawn() + .unwrap(); + let deadline = Instant::now() + Duration::from_secs(10); + loop { + if let Some(status) = child.try_wait().unwrap() { + assert!(status.success(), "{case}: child failed with {status}"); + break; + } + if Instant::now() >= deadline { + child.kill().unwrap(); + child.wait().unwrap(); + panic!("{case}: aggregate owner lock case exceeded 10 seconds"); + } + thread::sleep(Duration::from_millis(10)); + } + } +} diff --git a/crates/dynwinrt/src/win32_aggregate_tests.rs b/crates/dynwinrt/src/win32_aggregate_tests.rs new file mode 100644 index 00000000..5118da48 --- /dev/null +++ b/crates/dynwinrt/src/win32_aggregate_tests.rs @@ -0,0 +1,824 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use std::{ + cell::Cell, + fs::File, + os::windows::io::{AsRawHandle, IntoRawHandle}, +}; +use windows::Win32::Foundation::{ + HANDLE_FLAG_PROTECT_FROM_CLOSE, HANDLE_FLAGS, SetHandleInformation, +}; + +#[path = "win32_aggregate_effect_tests.rs"] +mod effect_tests; +#[path = "win32_aggregate_lock_tests.rs"] +mod lock_tests; + +#[repr(C)] +struct NativeInfo { + process: usize, + thread: usize, + process_id: u32, + thread_id: u32, +} + +thread_local! { static WRITTEN: Cell<[usize; 2]> = const { Cell::new([0; 2]) }; } + +unsafe extern "system" fn produce(info: *mut NativeInfo) -> i32 { + let process = + unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + let thread = + unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + WRITTEN.set([process.0 as usize, thread.0 as usize]); + unsafe { + *info = NativeInfo { + process: process.0 as usize, + thread: thread.0 as usize, + process_id: 42, + thread_id: 84, + }; + } + 1 +} + +fn layout() -> Arc { + NativeAggregatePointerLayout::new( + "Tests.NativeInfo".into(), + size_of::(), + align_of::(), + vec![ + AggregateResultField { + name: "process".into(), + offset: std::mem::offset_of!(NativeInfo, process), + typ: Type::Handle, + cleanup: Cleanup::CloseHandle, + }, + AggregateResultField { + name: "thread".into(), + offset: std::mem::offset_of!(NativeInfo, thread), + typ: Type::Handle, + cleanup: Cleanup::CloseHandle, + }, + AggregateResultField { + name: "processId".into(), + offset: std::mem::offset_of!(NativeInfo, process_id), + typ: Type::U32, + cleanup: Cleanup::None, + }, + AggregateResultField { + name: "threadId".into(), + offset: std::mem::offset_of!(NativeInfo, thread_id), + typ: Type::U32, + cleanup: Cleanup::None, + }, + ], + ) + .unwrap() +} + +fn spec() -> CallPlanSpec { + CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "GetLastError".into(), + parameters: vec![Parameter::input(Type::Pointer, false)], + return_type: Some(Type::Bool32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::ReturnNonZero, + capture_last_error: false, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None], + return_aggregate: None, + } +} + +fn planned(layout: Arc) -> Arc { + let spec = spec(); + let pointees = vec![Some(layout)]; + let shape = contract::shape_with_pointees(&spec, &pointees); + let contracts = CallContract::default().upgrade_metadata(&shape).unwrap(); + assert_eq!(contracts.results.len(), 5); + let mut plan = Arc::try_unwrap( + unsafe { CallPlan::new_with_contract_and_pointees(spec, contracts, pointees) }.unwrap(), + ) + .unwrap(); + plan.function = produce as *const () as usize; + Arc::new(plan) +} + +fn native_handles(buffer: &NativeAggregateBuffer) -> [usize; 2] { + [ + usize::from_ne_bytes(buffer.read(0).unwrap()), + usize::from_ne_bytes(buffer.read(size_of::()).unwrap()), + ] +} + +fn protect_handle(raw: usize, protected: bool) { + unsafe { + SetHandleInformation( + HANDLE(raw as *mut c_void), + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + if protected { + HANDLE_FLAG_PROTECT_FROM_CLOSE + } else { + HANDLE_FLAGS(0) + }, + ) + } + .unwrap(); +} + +fn retirement_counts(handles: [usize; 2]) -> [(usize, usize); 2] { + let counts = handles.map(|raw| { + ( + outcome_tests::cleanup_count_for(raw), + outcome_tests::successful_cleanup_count_for(raw), + ) + }); + // Measure before reclaiming leaked fixture handles, so a regression still fails. + for (raw, (_, successes)) in handles.into_iter().zip(counts) { + if successes == 0 { + unsafe { CloseHandle(HANDLE(raw as *mut c_void)) }.unwrap(); + } + } + counts +} + +#[test] +#[forbid(unsafe_code)] +fn safe_aggregate_storage_does_not_adopt_borrowed_handles() { + outcome_tests::reset(); + let file = File::open(std::env::current_exe().unwrap()).unwrap(); + let handle = file.as_raw_handle() as usize; + let layout = layout(); + let mut bytes = vec![0; layout.size()]; + for offset in [ + std::mem::offset_of!(NativeInfo, process), + std::mem::offset_of!(NativeInfo, thread), + ] { + bytes[offset..offset + size_of::()].copy_from_slice(&handle.to_ne_bytes()); + } + for initialize in [false, true] { + for prepare in [false, true] { + let buffer = NativeAggregateBuffer::new( + Arc::clone(&layout), + initialize.then_some(bytes.as_slice()), + ) + .unwrap(); + if !initialize { + buffer.write(0, &bytes).unwrap(); + } + assert_eq!(buffer.bytes().unwrap(), bytes); + for field in 0..2 { + assert!(buffer.field_value(field).is_err()); + assert!(buffer.take_field(field).is_err()); + } + if prepare { + buffer.prepare().unwrap(); + assert!(file.metadata().is_ok()); + } + drop(buffer); + assert_eq!(outcome_tests::cleanup_count_for(handle), 0); + assert!(file.metadata().is_ok()); + } + } +} + +#[test] +fn unsafe_legacy_adoption_transfers_and_retires_ownership_once() { + for take in [false, true] { + outcome_tests::reset(); + let buffer = NativeAggregateBuffer::new(layout(), None).unwrap(); + let handle = File::open(std::env::current_exe().unwrap()) + .unwrap() + .into_raw_handle() as usize; + buffer.write(0, &handle.to_ne_bytes()).unwrap(); + // IntoRawHandle relinquished File's unique ownership; CloseHandle matches it. + unsafe { buffer.mark_legacy(true) }.unwrap(); + assert_eq!( + buffer.field_value(0).unwrap().resource().unwrap().raw(), + handle + ); + let taken = take.then(|| buffer.take_field(0).unwrap()); + drop(buffer); + assert_eq!(outcome_tests::cleanup_count_for(handle), usize::from(!take)); + if let Some(value) = taken { + let resource = value.resource().unwrap(); + assert_eq!(resource.raw(), handle); + resource.close().unwrap(); + resource.close().unwrap(); + drop(value); + } + assert_eq!(outcome_tests::cleanup_count_for(handle), 1); + } +} + +#[test] +fn fields_are_owned_before_direct_return_conversion_and_result_delivery() { + for failure in [Some(ResultTarget::Return {}), None] { + outcome_tests::reset(); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let plan = planned(layout); + if let Some(target) = failure { + outcome_tests::fail_decode(target); + } + let result = unsafe { plan.invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) }; + if failure.is_some() { + assert!(result.is_err()); + } else { + drop(result.unwrap()); + } + assert!(matches!(buffer.field_value(2).unwrap(), Value::U32(42))); + let handles = WRITTEN.get(); + for handle in handles { + assert_eq!(outcome_tests::cleanup_count_for(handle), 0); + } + drop(buffer); + for handle in handles { + assert_eq!(outcome_tests::cleanup_count_for(handle), 1); + } + } +} + +#[test] +fn partially_converted_fields_keep_all_native_cleanup_responsibilities() { + outcome_tests::reset(); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let plan = planned(layout); + outcome_tests::fail_decode(ResultTarget::AggregateField { + parameter: 0, + field: 1, + }); + assert!(unsafe { plan.invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) }.is_err()); + let handles = WRITTEN.get(); + assert!(buffer.field_value(0).unwrap().resource().is_some()); + assert!(buffer.field_value(1).is_err()); + drop(buffer); + for handle in handles { + assert_eq!(outcome_tests::cleanup_count_for(handle), 1); + } +} + +#[test] +fn safe_writes_cannot_replace_pending_raw_cleanup_targets() { + let file = File::open(std::env::current_exe().unwrap()).unwrap(); + let borrowed = file.as_raw_handle() as usize; + let borrowed_bytes = borrowed.to_ne_bytes(); + let offset = std::mem::offset_of!(NativeInfo, thread); + let width = size_of::(); + for prepare in [false, true] { + outcome_tests::reset(); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + outcome_tests::fail_decode(ResultTarget::AggregateField { + parameter: 0, + field: 1, + }); + assert!( + unsafe { planned(layout).invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) } + .is_err() + ); + let handles = WRITTEN.get(); + assert!(buffer.field_value(1).is_err()); + let original = buffer.bytes().unwrap(); + let mut replacement = original.clone(); + replacement[offset..offset + width].copy_from_slice(&borrowed_bytes); + for (start, bytes) in [ + (offset, borrowed_bytes.as_slice()), + (offset, &borrowed_bytes[..1]), + (offset + width - 1, &borrowed_bytes[..1]), + (offset - 1, &borrowed_bytes[..2]), + (offset + width - 1, &borrowed_bytes[..2]), + (0, replacement.as_slice()), + ] { + assert!( + buffer + .write(start, bytes) + .unwrap_err() + .message() + .contains("owned result awaits cleanup") + ); + assert_eq!(buffer.bytes().unwrap(), original); + } + buffer.write(offset, &[]).unwrap(); + buffer.write(buffer.layout().size(), &[]).unwrap(); + let scalar_offset = std::mem::offset_of!(NativeInfo, process_id); + buffer.write(scalar_offset, &99u32.to_ne_bytes()).unwrap(); + assert_eq!(u32::from_ne_bytes(buffer.read(scalar_offset).unwrap()), 99); + + // Captured owners no longer use mutable field bytes as their cleanup targets. + buffer.write(0, &borrowed_bytes).unwrap(); + assert_eq!( + buffer.field_value(0).unwrap().resource().unwrap().raw(), + handles[0] + ); + if prepare { + buffer.prepare().unwrap(); + for handle in handles { + assert_eq!(outcome_tests::cleanup_count_for(handle), 1); + } + buffer.write(offset, &borrowed_bytes).unwrap(); + } + drop(buffer); + for handle in handles { + assert_eq!(outcome_tests::cleanup_count_for(handle), 1); + } + assert_eq!(outcome_tests::cleanup_count_for(borrowed), 0); + assert!(file.metadata().is_ok()); + } +} + +#[test] +fn taking_one_field_transfers_its_owner_without_owning_the_structure() { + outcome_tests::reset(); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let plan = planned(layout); + drop(unsafe { plan.invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) }.unwrap()); + let handles = WRITTEN.get(); + let taken = buffer.take_field(0).unwrap(); + assert_eq!(taken.resource().unwrap().raw(), handles[0]); + assert!(matches!(buffer.take_field(0).unwrap(), Value::Handle(0))); + assert_eq!( + usize::from_ne_bytes(buffer.read::<{ size_of::() }>(0).unwrap()), + 0 + ); + drop(buffer); + assert_eq!(outcome_tests::cleanup_count_for(handles[0]), 0); + assert_eq!(outcome_tests::cleanup_count_for(handles[1]), 1); + drop(taken); + assert_eq!(outcome_tests::cleanup_count_for(handles[0]), 1); +} + +#[test] +fn undefined_field_outputs_are_never_adopted_or_cleaned() { + unsafe extern "system" fn failed(info: *mut NativeInfo) -> i32 { + let [first, second] = WRITTEN.get(); + unsafe { + (*info).process = first; + (*info).thread = second; + } + 0 + } + outcome_tests::reset(); + let first = unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + let second = + unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + WRITTEN.set([first.0 as usize, second.0 as usize]); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let mut plan = Arc::try_unwrap(planned(layout)).unwrap(); + plan.function = failed as *const () as usize; + assert!( + !unsafe { plan.invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) } + .unwrap() + .succeeded + ); + assert!(buffer.field_value(0).is_err()); + drop(buffer); + for handle in WRITTEN.get() { + assert_eq!(outcome_tests::cleanup_count_for(handle), 0); + } + unsafe { + CloseHandle(first).unwrap(); + CloseHandle(second).unwrap(); + } +} + +#[test] +fn caller_storage_identity_and_field_ranges_fail_before_dispatch() { + let layout = layout(); + let plan = planned(Arc::clone(&layout)); + let other = NativeAggregatePointerLayout::new( + "Other".into(), + layout.size(), + layout.alignment(), + layout.fields().to_vec(), + ) + .unwrap(); + let buffer = NativeAggregateBuffer::new(other, None).unwrap(); + assert!( + unsafe { plan.invoke(&[Value::AggregatePointer(buffer)]) } + .unwrap_err() + .message() + .contains("matching managed") + ); + let mut info = NativeInfo { + process: 0, + thread: 0, + process_id: 0, + thread_id: 0, + }; + assert!( + unsafe { plan.invoke(&[Value::Pointer((&mut info as *mut NativeInfo).cast())]) }.is_err() + ); + assert!( + NativeAggregatePointerLayout::new( + "Bad".into(), + 8, + 8, + vec![AggregateResultField { + name: "outside".into(), + offset: 8, + typ: Type::Handle, + cleanup: Cleanup::CloseHandle + },] + ) + .is_err() + ); + assert!( + NativeAggregatePointerLayout::new( + "Overlap".into(), + 16, + 8, + vec![ + AggregateResultField { + name: "a".into(), + offset: 0, + typ: Type::Handle, + cleanup: Cleanup::CloseHandle + }, + AggregateResultField { + name: "b".into(), + offset: 0, + typ: Type::Handle, + cleanup: Cleanup::CloseHandle + }, + ] + ) + .is_err() + ); +} + +#[test] +fn later_language_markers_cannot_erase_native_ownership() { + outcome_tests::reset(); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + drop( + unsafe { planned(layout).invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) }.unwrap(), + ); + // The completed native call has already established the fields' ownership. + assert!(unsafe { buffer.mark_legacy(false) }.is_err()); + unsafe { buffer.mark_legacy(true) }.unwrap(); + let handles = WRITTEN.get(); + drop(buffer); + for handle in handles { + assert_eq!(outcome_tests::cleanup_count_for(handle), 1); + } +} + +#[test] +fn real_create_process_fields_survive_a_failure_before_language_wrapping() { + use windows::Win32::System::Threading::STARTUPINFOW; + outcome_tests::reset(); + let output_layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&output_layout), None).unwrap(); + let mut startup = STARTUPINFOW { + cb: size_of::() as u32, + ..Default::default() + }; + let command = format!("\"{}\" /d /c exit 0", std::env::var("ComSpec").unwrap()); + let mut command = command.encode_utf16().chain([0]).collect::>(); + let spec = CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "CreateProcessW".into(), + parameters: vec![ + Parameter::input(Type::Pointer, true), + Parameter::input(Type::Pointer, false), + Parameter::input(Type::Pointer, true), + Parameter::input(Type::Pointer, true), + Parameter::input(Type::Bool32, false), + Parameter::input(Type::U32, false), + Parameter::input(Type::Pointer, true), + Parameter::input(Type::Pointer, true), + Parameter::input(Type::Pointer, false), + Parameter::input(Type::Pointer, false), + ], + return_type: Some(Type::Bool32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::ReturnNonZero, + capture_last_error: true, + calling_convention: CallingConvention::System, + parameter_aggregates: vec![None; 10], + return_aggregate: None, + }; + let mut pointees = vec![None; 10]; + pointees[9] = Some(output_layout); + let contract = CallContract::default() + .upgrade_metadata(&contract::shape_with_pointees(&spec, &pointees)) + .unwrap(); + let plan = + unsafe { CallPlan::new_with_contract_and_pointees(spec, contract, pointees) }.unwrap(); + outcome_tests::fail_decode(ResultTarget::Return {}); + let error = unsafe { + plan.invoke(&[ + Value::Null, + Value::Pointer(command.as_mut_ptr().cast()), + Value::Null, + Value::Null, + Value::Bool(false), + Value::U32(0x0800_0000), + Value::Null, + Value::Null, + Value::Pointer((&mut startup as *mut STARTUPINFOW).cast()), + Value::AggregatePointer(Arc::clone(&buffer)), + ]) + } + .unwrap_err(); + assert!(error.message().contains("conversion failure"), "{error:?}"); + assert!(matches!(buffer.field_value(2).unwrap(), Value::U32(pid) if pid > 0)); + let process = buffer.field_value(0).unwrap().resource().unwrap().raw(); + let thread = buffer.field_value(1).unwrap().resource().unwrap().raw(); + assert_ne!(process, 0); + assert_ne!(thread, 0); + drop(buffer); + assert_eq!(outcome_tests::cleanup_count_for(process), 1); + assert_eq!(outcome_tests::cleanup_count_for(thread), 1); +} + +#[test] +fn defined_but_discarded_field_resources_are_cleaned_on_business_failure() { + unsafe extern "system" fn partial(info: *mut NativeInfo) -> i32 { + unsafe { produce(info) }; + 0 + } + outcome_tests::reset(); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let spec = spec(); + let pointees = vec![Some(layout)]; + let mut contract = CallContract::default() + .upgrade_metadata(&contract::shape_with_pointees(&spec, &pointees)) + .unwrap(); + for result in &mut contract.results { + if matches!( + result.target, + ResultTarget::AggregateField { field: 0 | 1, .. } + ) { + result.on_failure = ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: dynwinrt_win32_contracts::Cleanup::CloseHandle, + }); + } + } + let mut plan = Arc::try_unwrap( + unsafe { CallPlan::new_with_contract_and_pointees(spec, contract, pointees) }.unwrap(), + ) + .unwrap(); + plan.function = partial as *const () as usize; + assert!( + !unsafe { plan.invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) } + .unwrap() + .succeeded + ); + let handles = WRITTEN.get(); + for handle in handles { + assert_eq!(outcome_tests::cleanup_count_for(handle), 1); + } + assert!(buffer.field_value(0).is_err()); + drop(buffer); + for handle in handles { + assert_eq!(outcome_tests::cleanup_count_for(handle), 1); + } +} + +#[test] +fn failed_discard_preserves_raw_cleanup_and_write_protection_until_retirement() { + unsafe extern "system" fn protected_outputs(info: *mut NativeInfo, succeeded: i32) -> i32 { + unsafe { produce(info) }; + protect_handle(unsafe { (*info).process }, true); + succeeded + } + + for succeeded in [false, true] { + for prepare in [false, true] { + outcome_tests::reset(); + let layout = layout(); + let buffer = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let mut spec = spec(); + spec.parameters.push(Parameter::input(Type::Bool32, false)); + spec.parameter_aggregates.push(None); + let pointees = vec![Some(layout), None]; + let mut contract = CallContract::default() + .upgrade_metadata(&contract::shape_with_pointees(&spec, &pointees)) + .unwrap(); + for result in &mut contract.results { + if matches!( + result.target, + ResultTarget::AggregateField { field: 0 | 1, .. } + ) { + let policy = ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: dynwinrt_win32_contracts::Cleanup::CloseHandle, + }); + result.on_success = policy; + result.on_failure = policy; + } + } + let mut plan = Arc::try_unwrap( + unsafe { CallPlan::new_with_contract_and_pointees(spec, contract, pointees) } + .unwrap(), + ) + .unwrap(); + plan.function = protected_outputs as *const () as usize; + let call_failed = unsafe { + plan.invoke(&[ + Value::AggregatePointer(Arc::clone(&buffer)), + Value::Bool(succeeded), + ]) + } + .is_err(); + let raw = native_handles(&buffer); + let guard_after_call = buffer.lock().raw_cleanup[0]; + let write_rejected = buffer.write(0, &raw[0].to_ne_bytes()).is_err(); + let partial_write_rejected = buffer + .write( + size_of::() - 1, + &raw[0].to_ne_bytes()[size_of::() - 1..], + ) + .is_err(); + let retry_failed = buffer.prepare().is_err(); + let guard_after_retry = buffer.lock().raw_cleanup[0]; + let raw_after_retry = native_handles(&buffer); + let retry_write_rejected = buffer.write(0, &raw[0].to_ne_bytes()).is_err(); + protect_handle(raw[0], false); + if prepare { + buffer.prepare().unwrap(); + buffer.prepare().unwrap(); + buffer.write(0, &0usize.to_ne_bytes()).unwrap(); + } + drop(buffer); + let counts = retirement_counts(raw); + assert!(call_failed); + assert!(retry_failed); + assert_eq!(guard_after_call, Cleanup::CloseHandle); + assert_eq!(guard_after_retry, Cleanup::CloseHandle); + assert!(write_rejected && partial_write_rejected && retry_write_rejected); + assert_eq!(raw_after_retry, [raw[0], 0]); + assert_eq!( + counts, + [(3, 1), (1, 1)], + "succeeded={succeeded}, prepare={prepare}" + ); + } + } +} + +#[test] +fn all_aggregate_states_are_recorded_before_fallible_field_processing() { + unsafe extern "system" fn outputs( + first: *mut NativeInfo, + second: *mut NativeInfo, + succeeded: i32, + protect_first: i32, + ) -> i32 { + unsafe { + produce(first); + produce(second); + if protect_first != 0 { + protect_handle((*first).process, true); + } + } + succeeded + } + + for succeeded in [false, true] { + for failed_field in [Some(0), Some(1), None] { + for prepare in [false, true] { + outcome_tests::reset(); + let layout = layout(); + let first = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let second = NativeAggregateBuffer::new(Arc::clone(&layout), None).unwrap(); + let mut spec = spec(); + spec.parameters.extend([ + Parameter::input(Type::Pointer, false), + Parameter::input(Type::Bool32, false), + Parameter::input(Type::Bool32, false), + ]); + spec.parameter_aggregates.resize(4, None); + let pointees = vec![Some(Arc::clone(&layout)), Some(layout), None, None]; + let mut contract = CallContract::default() + .upgrade_metadata(&contract::shape_with_pointees(&spec, &pointees)) + .unwrap(); + for result in &mut contract.results { + if matches!( + result.target, + ResultTarget::AggregateField { field: 0 | 1, .. } + ) { + result.on_failure = result.on_success; + } + if failed_field.is_none() + && result.target + == (ResultTarget::AggregateField { + parameter: 0, + field: 0, + }) + { + let policy = ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: dynwinrt_win32_contracts::Cleanup::CloseHandle, + }); + result.on_success = policy; + result.on_failure = policy; + } + } + let mut plan = Arc::try_unwrap( + unsafe { CallPlan::new_with_contract_and_pointees(spec, contract, pointees) } + .unwrap(), + ) + .unwrap(); + plan.function = outputs as *const () as usize; + if let Some(field) = failed_field { + outcome_tests::fail_decode(ResultTarget::AggregateField { + parameter: 0, + field, + }); + } + let error = unsafe { + plan.invoke(&[ + Value::AggregatePointer(Arc::clone(&first)), + Value::AggregatePointer(Arc::clone(&second)), + Value::Bool(succeeded), + Value::Bool(failed_field.is_none()), + ]) + } + .unwrap_err(); + let first_raw = native_handles(&first); + let second_raw = native_handles(&second); + if failed_field.is_none() { + protect_handle(first_raw[0], false); + } + let (recorded, native_succeeded, guards_before) = { + let state = second.lock(); + ( + state.native_recorded, + state.succeeded, + [state.raw_cleanup[0], state.raw_cleanup[1]], + ) + }; + // The native writes completed; this is their actual success/failure status. + let marker = unsafe { second.mark_legacy(succeeded) }; + let guards_after = { + let state = second.lock(); + [state.raw_cleanup[0], state.raw_cleanup[1]] + }; + let write_rejected = second.write(0, &second_raw[0].to_ne_bytes()).is_err(); + drop(first); + if prepare { + second.prepare().unwrap(); + } + drop(second); + let first_counts = retirement_counts(first_raw); + let second_counts = retirement_counts(second_raw); + if failed_field.is_some() { + assert!( + error + .message() + .contains("Injected native result conversion failure") + ); + } + assert!(recorded); + assert_eq!(native_succeeded, Some(succeeded)); + assert!(marker.is_ok()); + assert_eq!(guards_before, [Cleanup::CloseHandle; 2]); + assert_eq!(guards_after, guards_before); + assert!(write_rejected); + assert_eq!( + first_counts, + [(if failed_field.is_none() { 2 } else { 1 }, 1), (1, 1)] + ); + assert_eq!(second_counts, [(1, 1); 2]); + } + } + } +} + +#[test] +fn undescribed_aggregate_calls_keep_the_legacy_registration_path() { + outcome_tests::reset(); + let buffer = NativeAggregateBuffer::new(layout(), None).unwrap(); + buffer.prepare().unwrap(); + let mut plan = Arc::try_unwrap(unsafe { CallPlan::new(spec()) }.unwrap()).unwrap(); + plan.function = produce as *const () as usize; + let result = unsafe { plan.invoke(&[Value::AggregatePointer(Arc::clone(&buffer))]) }.unwrap(); + let raw = native_handles(&buffer); + let recorded = buffer.lock().native_recorded; + // This legacy call transferred both live event handles into the caller's fields. + unsafe { buffer.mark_legacy(result.succeeded) }.unwrap(); + let owned = [0, 1].map(|field| { + buffer + .field_value(field) + .is_ok_and(|value| value.resource().is_some()) + }); + drop(buffer); + let counts = retirement_counts(raw); + assert!(result.succeeded); + assert!(!recorded); + assert_eq!(owned, [true; 2]); + assert_eq!(counts, [(1, 1); 2]); +} diff --git a/crates/dynwinrt/src/win32_contract.rs b/crates/dynwinrt/src/win32_contract.rs new file mode 100644 index 00000000..757f6faa --- /dev/null +++ b/crates/dynwinrt/src/win32_contract.rs @@ -0,0 +1,258 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use dynwinrt_win32_contracts as protocol; +pub use dynwinrt_win32_contracts::{ + CallContract, Condition, Delivery, InputPredicate, OutputAction, OutputRule, ResourceEffect, + ResultContract, ResultOverride, ResultOwnership, ResultPolicy, ResultTarget, +}; + +use super::{ + CallPlanSpec, Cleanup, Direction, NativeAggregatePointerLayout, SuccessRule, Type, + invalid_argument, +}; +use crate::{abi::AbiValue, result::Result}; +use std::sync::Arc; + +#[derive(Debug)] +pub(super) struct LegacySurface { + owned: Vec, + explicit_undefined: Vec, +} + +impl LegacySurface { + pub(super) fn new(spec: &CallPlanSpec, contract: &CallContract) -> Self { + if contract.version != protocol::LEGACY_VERSION { + return Self { + owned: Vec::new(), + explicit_undefined: Vec::new(), + }; + } + Self { + owned: shape(spec) + .result_targets() + .filter(|target| match target { + ResultTarget::Return {} => spec.return_cleanup.owns_resource(), + ResultTarget::Parameter { index } => { + spec.parameters[*index].cleanup.owns_resource() + } + ResultTarget::AggregateField { .. } => false, + }) + .collect(), + explicit_undefined: contract + .outputs + .iter() + .filter_map(|rule| { + matches!(rule.action, OutputAction::Unavailable {}).then_some( + ResultTarget::Parameter { + index: rule.parameter, + }, + ) + }) + .collect(), + } + } + + pub(super) fn null_on_failure( + &self, + target: ResultTarget, + succeeded: bool, + overridden: bool, + ) -> bool { + !succeeded + && self.owned.contains(&target) + && !(overridden && self.explicit_undefined.contains(&target)) + } +} + +pub(super) fn shape(spec: &CallPlanSpec) -> protocol::SignatureShape { + shape_with_pointees(spec, &vec![None; spec.parameters.len()]) +} + +pub(super) fn shape_with_pointees( + spec: &CallPlanSpec, + pointees: &[Option>], +) -> protocol::SignatureShape { + protocol::SignatureShape { + pointer_width: usize::BITS as u8, + parameters: spec + .parameters + .iter() + .enumerate() + .map(|(index, parameter)| protocol::ParameterShape { + typ: if spec.parameter_aggregates[index].is_some() { + protocol::NativeType::Aggregate + } else { + native_type(parameter.typ) + }, + direction: match parameter.direction { + Direction::In => protocol::Direction::In, + Direction::Out => protocol::Direction::Out, + Direction::InOut => protocol::Direction::InOut, + }, + cleanup: parameter.cleanup.into(), + resource_cleanup: parameter.resource_cleanup.into(), + consumes_resource: parameter.consumes_resource, + result_fields: pointees[index] + .as_ref() + .map(|layout| { + layout + .fields() + .iter() + .map(|field| protocol::ResultFieldShape { + typ: native_type(field.typ), + cleanup: field.cleanup.into(), + }) + .collect() + }) + .unwrap_or_default(), + }) + .collect(), + return_type: if spec.return_aggregate.is_some() { + Some(protocol::NativeType::Aggregate) + } else { + spec.return_type.map(native_type) + }, + return_cleanup: spec.return_cleanup.into(), + success_rule: match spec.success_rule { + SuccessRule::Always => protocol::SuccessRule::Always, + SuccessRule::ReturnZero => protocol::SuccessRule::ReturnZero, + SuccessRule::ReturnNonZero => protocol::SuccessRule::ReturnNonZero, + SuccessRule::ReturnNonNull => protocol::SuccessRule::ReturnNonNull, + SuccessRule::HResultSucceeded => protocol::SuccessRule::HResultSucceeded, + SuccessRule::SignedNonNegative => protocol::SuccessRule::SignedNonNegative, + SuccessRule::ReturnValidHandle => protocol::SuccessRule::ReturnValidHandle, + }, + } +} + +#[cfg(test)] +pub(super) fn resolve(spec: &CallPlanSpec, contract: &CallContract) -> Result { + contract + .upgrade(&shape(spec)) + .map_err(|error| invalid_argument(&error.to_string())) +} + +pub(super) fn resolve_with_pointees( + spec: &CallPlanSpec, + contract: &CallContract, + pointees: &[Option>], +) -> Result { + contract + .upgrade(&shape_with_pointees(spec, pointees)) + .map_err(|error| invalid_argument(&error.to_string())) +} + +fn native_type(typ: Type) -> protocol::NativeType { + match typ { + Type::Bool32 => protocol::NativeType::Bool32, + Type::I8 => protocol::NativeType::I8, + Type::U8 => protocol::NativeType::U8, + Type::I16 => protocol::NativeType::I16, + Type::U16 => protocol::NativeType::U16, + Type::I32 => protocol::NativeType::I32, + Type::U32 => protocol::NativeType::U32, + Type::I64 => protocol::NativeType::I64, + Type::U64 => protocol::NativeType::U64, + Type::F32 => protocol::NativeType::F32, + Type::F64 => protocol::NativeType::F64, + Type::Pointer => protocol::NativeType::Pointer, + Type::FunctionPointer => protocol::NativeType::FunctionPointer, + Type::Handle => protocol::NativeType::Handle, + } +} + +impl From for protocol::Cleanup { + fn from(value: Cleanup) -> Self { + match value { + Cleanup::None => Self::None, + Cleanup::CloseHandle => Self::CloseHandle, + Cleanup::RegCloseKey => Self::RegCloseKey, + Cleanup::LocalFree => Self::LocalFree, + Cleanup::GlobalFree => Self::GlobalFree, + Cleanup::FreeLibrary => Self::FreeLibrary, + Cleanup::CloseServiceHandle => Self::CloseServiceHandle, + Cleanup::CoTaskMemFree => Self::CoTaskMemFree, + Cleanup::CredFree => Self::CredFree, + } + } +} + +impl From for Cleanup { + fn from(value: protocol::Cleanup) -> Self { + match value { + protocol::Cleanup::None => Self::None, + protocol::Cleanup::CloseHandle => Self::CloseHandle, + protocol::Cleanup::RegCloseKey => Self::RegCloseKey, + protocol::Cleanup::LocalFree => Self::LocalFree, + protocol::Cleanup::GlobalFree => Self::GlobalFree, + protocol::Cleanup::FreeLibrary => Self::FreeLibrary, + protocol::Cleanup::CloseServiceHandle => Self::CloseServiceHandle, + protocol::Cleanup::CoTaskMemFree => Self::CoTaskMemFree, + protocol::Cleanup::CredFree => Self::CredFree, + } + } +} + +pub(super) unsafe fn matches_inputs( + condition: &Condition, + inputs: &[Option], +) -> Result { + for predicate in &condition.inputs { + let value = inputs + .get(predicate.parameter()) + .and_then(Option::as_ref) + .ok_or_else(|| invalid_argument("Call condition is missing native input storage"))?; + let matched = match predicate { + InputPredicate::BitsIn { mask, values, .. } => { + let bits = abi_bits(value).ok_or_else(|| { + invalid_argument("Call condition has non-integer input storage") + })?; + values.contains(&(bits & mask)) + } + InputPredicate::HandleIn { values, .. } => { + let AbiValue::Pointer(pointer) = value else { + return Err(invalid_argument( + "Handle condition has non-handle input storage", + )); + }; + values.contains(&(*pointer as isize as i64)) + } + InputPredicate::NullOrEmpty { element_width, .. } => { + let AbiValue::Pointer(pointer) = value else { + return Err(invalid_argument( + "String condition has non-pointer input storage", + )); + }; + pointer.is_null() + || unsafe { + match element_width { + 1 => *pointer.cast::() == 0, + 2 => pointer.cast::().read_unaligned() == 0, + _ => return Err(invalid_argument("Unsupported native string width")), + } + } + } + }; + if !matched { + return Ok(false); + } + } + Ok(true) +} + +pub(super) fn abi_bits(value: &AbiValue) -> Option { + Some(match value { + AbiValue::Bool(value) => u64::from(*value), + AbiValue::I8(value) => *value as u8 as u64, + AbiValue::U8(value) => *value as u64, + AbiValue::I16(value) => *value as u16 as u64, + AbiValue::U16(value) => *value as u64, + AbiValue::I32(value) => *value as u32 as u64, + AbiValue::U32(value) => *value as u64, + AbiValue::I64(value) => *value as u64, + AbiValue::U64(value) => *value, + AbiValue::Pointer(value) => *value as usize as u64, + _ => return None, + }) +} diff --git a/crates/dynwinrt/src/win32_contract_tests.rs b/crates/dynwinrt/src/win32_contract_tests.rs new file mode 100644 index 00000000..fc2e3852 --- /dev/null +++ b/crates/dynwinrt/src/win32_contract_tests.rs @@ -0,0 +1,436 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; + +fn handle_input(cleanup: Cleanup) -> Parameter { + Parameter { + resource_cleanup: cleanup, + ..Parameter::input(Type::Handle, false) + } +} + +fn spec(parameters: Vec) -> CallPlanSpec { + CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "GetLastError".into(), + parameter_aggregates: vec![None; parameters.len()], + parameters, + return_type: Some(Type::I32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::ReturnZero, + capture_last_error: false, + calling_convention: CallingConvention::System, + return_aggregate: None, + } +} + +fn plan(function: usize, parameters: Vec, contract: CallContract) -> Arc { + let mut plan = Arc::try_unwrap( + unsafe { CallPlan::new_with_contract(spec(parameters), contract) }.unwrap(), + ) + .unwrap(); + plan.function = function; + Arc::new(plan) +} + +fn alias_contract(width: u8) -> CallContract { + CallContract { + outputs: vec![OutputRule { + parameter: 2, + when: Condition { + inputs: vec![InputPredicate::NullOrEmpty { + parameter: 1, + element_width: width, + }], + return_value: None, + ..Condition::default() + }, + action: OutputAction::AliasInput { parameter: 0 }, + }], + ..CallContract::default() + } +} + +fn alias_parameters(cleanup: Cleanup) -> Vec { + vec![ + handle_input(cleanup), + Parameter::input(Type::Pointer, true), + Parameter::output(Type::Handle, cleanup), + ] +} + +unsafe extern "system" fn alias( + input: *mut c_void, + _: *const c_void, + output: *mut *mut c_void, +) -> i32 { + unsafe { *output = input }; + 0 +} + +fn allocation() -> Arc { + let pointer = unsafe { windows::Win32::System::Com::CoTaskMemAlloc(16) }; + assert!(!pointer.is_null()); + unsafe { OwnedResource::adopt(pointer as usize, Cleanup::CoTaskMemFree) }.unwrap() +} + +#[test] +fn aliases_share_owner_close_state_and_exactly_one_cleanup() { + for width in [1, 2] { + for null in [false, true] { + outcome_tests::reset(); + let owner = allocation(); + let address = owner.raw(); + let empty = [0u16]; + let string = if null { + Value::Null + } else { + Value::Pointer(empty.as_ptr().cast_mut().cast()) + }; + let call = plan( + alias as *const () as usize, + alias_parameters(Cleanup::CoTaskMemFree), + alias_contract(width), + ); + let result = + unsafe { call.invoke(&[Value::Resource(Arc::clone(&owner)), string]) }.unwrap(); + let alias = result.outputs[0].resource().unwrap(); + assert!(Arc::ptr_eq(alias, &owner)); + alias.close().unwrap(); + assert!(owner.is_closed()); + assert!(alias.is_closed()); + assert!(owner.lease(Cleanup::CoTaskMemFree).is_err()); + drop(result); + drop(owner); + assert_eq!(outcome_tests::cleanup_count_for(address), 1); + } + } +} + +#[test] +fn dropping_an_alias_keeps_the_original_owner_live() { + outcome_tests::reset(); + let owner = allocation(); + let address = owner.raw(); + let call = plan( + alias as *const () as usize, + alias_parameters(Cleanup::CoTaskMemFree), + alias_contract(2), + ); + let result = + unsafe { call.invoke(&[Value::Resource(Arc::clone(&owner)), Value::Null]) }.unwrap(); + drop(result); + assert!(!owner.is_closed()); + assert_eq!(outcome_tests::cleanup_count_for(address), 0); + drop(owner); + assert_eq!(outcome_tests::cleanup_count_for(address), 1); +} + +#[test] +fn aliases_of_borrowed_inputs_remain_borrowed() { + outcome_tests::reset(); + let call = plan( + alias as *const () as usize, + alias_parameters(Cleanup::RegCloseKey), + alias_contract(2), + ); + let result = unsafe { call.invoke(&[Value::Handle(0x8000_0002), Value::Null]) }.unwrap(); + assert!(matches!(result.outputs[0], Value::Handle(0x8000_0002))); + drop(result); + assert_eq!(outcome_tests::cleanup_count_for(0x8000_0002), 0); +} + +#[test] +fn native_handle_conditions_preserve_the_complete_pointer_width() { + let condition = Condition { + inputs: vec![InputPredicate::HandleIn { + parameter: 0, + values: vec![-2147483646], + }], + return_value: None, + ..Condition::default() + }; + assert!( + unsafe { + contract::matches_inputs( + &condition, + &[Some(AbiValue::Pointer((-2147483646isize) as *mut c_void))], + ) + } + .unwrap() + ); + assert!( + !unsafe { + contract::matches_inputs( + &condition, + &[Some(AbiValue::Pointer(0x8000_0002usize as *mut c_void))], + ) + } + .unwrap() + ); +} + +#[test] +fn failed_and_mismatched_alias_outputs_never_close_the_input() { + unsafe extern "system" fn fail( + input: *mut c_void, + _: *const c_void, + output: *mut *mut c_void, + ) -> i32 { + unsafe { *output = input }; + 5 + } + unsafe extern "system" fn mismatch( + input: *mut c_void, + _: *const c_void, + output: *mut *mut c_void, + ) -> i32 { + unsafe { *output = input.wrapping_byte_add(1) }; + 0 + } + outcome_tests::reset(); + let owner = allocation(); + let address = owner.raw(); + let failed = plan( + fail as *const () as usize, + alias_parameters(Cleanup::CoTaskMemFree), + alias_contract(1), + ); + let result = + unsafe { failed.invoke(&[Value::Resource(Arc::clone(&owner)), Value::Null]) }.unwrap(); + assert!(!result.succeeded); + assert!(matches!(result.outputs[0], Value::Handle(0))); + assert!(outcome_tests::decoded_outputs().is_empty()); + let mismatched = plan( + mismatch as *const () as usize, + alias_parameters(Cleanup::CoTaskMemFree), + alias_contract(1), + ); + assert!( + unsafe { mismatched.invoke(&[Value::Resource(Arc::clone(&owner)), Value::Null]) } + .unwrap_err() + .message() + .contains("does not equal") + ); + assert!(!owner.is_closed()); + assert_eq!(outcome_tests::cleanup_count_for(address), 0); + owner.close().unwrap(); +} + +#[test] +fn conditions_snapshot_inputs_before_native_mutation() { + unsafe extern "system" fn change( + input: *mut c_void, + text: *mut u8, + output: *mut *mut c_void, + ) -> i32 { + unsafe { + *text = b'x'; + *output = input; + } + 0 + } + let owner = allocation(); + let mut text = [0u8; 2]; + let call = plan( + change as *const () as usize, + alias_parameters(Cleanup::CoTaskMemFree), + alias_contract(1), + ); + let result = unsafe { + call.invoke(&[ + Value::Resource(Arc::clone(&owner)), + Value::Pointer(text.as_mut_ptr().cast()), + ]) + } + .unwrap(); + assert_eq!(text[0], b'x'); + assert!(Arc::ptr_eq(result.outputs[0].resource().unwrap(), &owner)); +} + +#[test] +fn unavailable_outputs_are_not_decoded_for_the_contracted_input_and_status() { + unsafe extern "system" fn query(_: *mut c_void, status: i32, _: *mut u32) -> i32 { + status + } + let call = plan( + query as *const () as usize, + vec![ + Parameter::input(Type::Handle, false), + Parameter::input(Type::I32, false), + Parameter::input_output(Type::U32, false, Cleanup::None), + ], + CallContract { + outputs: vec![OutputRule { + parameter: 2, + when: Condition { + inputs: vec![InputPredicate::BitsIn { + parameter: 0, + mask: u32::MAX as u64, + values: vec![0x8000_0004], + }], + return_value: Some(234), + ..Condition::default() + }, + action: OutputAction::Unavailable {}, + }], + ..CallContract::default() + }, + ); + for (handle, status, unavailable) in [ + (0x8000_0004, 234, true), + (0xffff_ffff_8000_0004, 234, true), + (0x8000_0004, 0, false), + (0x8000_0002, 234, false), + ] { + for capacity in [1, 64] { + outcome_tests::reset(); + let result = unsafe { + call.invoke(&[ + Value::Handle(handle), + Value::I32(status), + Value::U32(capacity), + ]) + } + .unwrap(); + if unavailable { + assert!(matches!(result.outputs[0], Value::Unavailable)); + assert!(outcome_tests::decoded_outputs().is_empty()); + } else { + assert!(matches!(result.outputs[0], Value::U32(value) if value == capacity)); + assert_eq!(outcome_tests::decoded_outputs(), [0]); + } + } + } +} + +#[test] +fn unavailable_owned_output_is_neither_adopted_nor_cleaned_up() { + unsafe extern "system" fn undefined(input: *mut c_void, output: *mut *mut c_void) -> i32 { + unsafe { *output = input }; + 234 + } + outcome_tests::reset(); + let owner = allocation(); + let address = owner.raw(); + let call = plan( + undefined as *const () as usize, + vec![ + handle_input(Cleanup::CoTaskMemFree), + Parameter::output(Type::Handle, Cleanup::CoTaskMemFree), + ], + CallContract { + outputs: vec![OutputRule { + parameter: 1, + when: Condition { + return_value: Some(234), + ..Condition::default() + }, + action: OutputAction::Unavailable {}, + }], + ..CallContract::default() + }, + ); + let result = unsafe { call.invoke(&[Value::Resource(Arc::clone(&owner))]) }.unwrap(); + assert!(matches!(result.outputs[0], Value::Unavailable)); + drop(result); + assert!(outcome_tests::decoded_outputs().is_empty()); + assert_eq!(outcome_tests::cleanup_count_for(address), 0); + owner.close().unwrap(); +} + +#[test] +fn malformed_contracts_fail_before_module_resolution() { + let make_spec = || { + let mut spec = spec(alias_parameters(Cleanup::RegCloseKey)); + spec.dll = "absent-dynwinrt-test.dll".into(); + spec + }; + let mut cases = Vec::new(); + let mut invalid = alias_contract(1); + invalid.outputs[0].parameter = 9; + cases.push(invalid); + let mut invalid = alias_contract(1); + invalid.outputs.push(invalid.outputs[0].clone()); + cases.push(invalid); + cases.push(alias_contract(4)); + let mut invalid = alias_contract(1); + invalid.outputs[0].action = OutputAction::AliasInput { parameter: 1 }; + cases.push(invalid); + let mut invalid = alias_contract(1); + invalid.outputs[0].when.inputs = vec![InputPredicate::BitsIn { + parameter: 0, + mask: 0xff, + values: vec![0x100], + }]; + cases.push(invalid); + let mut invalid = alias_contract(1); + invalid.outputs[0].when.return_value = Some(u64::MAX); + cases.push(invalid); + cases.push(CallContract { + resource_effects: vec![ResourceEffect::AddFileCompletionModes { + handle_parameter: 0, + flags_parameter: 1, + }], + ..CallContract::default() + }); + for invalid in cases { + let error = unsafe { CallPlan::new_with_contract(make_spec(), invalid) }.unwrap_err(); + assert!( + !error.message().contains("absent-dynwinrt-test"), + "{error:?}" + ); + } +} + +#[test] +fn resource_mode_effects_are_monotonic_success_only_and_exclude_async_leases() { + use std::cell::Cell; + thread_local! { static CALLS: Cell = const { Cell::new(0) }; } + extern "system" fn set_modes(_: *mut c_void, flags: u8) -> i32 { + CALLS.set(CALLS.get() + 1); + i32::from(flags != u8::MAX) + } + let handle = + unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + let owner = unsafe { OwnedResource::adopt(handle.0 as usize, Cleanup::CloseHandle) }.unwrap(); + owner.file_capability().set_known_completion_modes(1); + let mut call = Arc::try_unwrap(plan( + set_modes as *const () as usize, + vec![ + handle_input(Cleanup::CloseHandle), + Parameter::input(Type::U8, false), + ], + CallContract { + resource_effects: vec![ResourceEffect::AddFileCompletionModes { + handle_parameter: 0, + flags_parameter: 1, + }], + ..CallContract::default() + }, + )) + .unwrap(); + call.success_rule = SuccessRule::ReturnNonZero; + let mut lease = owner.async_lease(Cleanup::CloseHandle).unwrap(); + for active in [false, true] { + if active { + lease.mark_active(); + } + let error = unsafe { call.invoke(&[Value::Resource(Arc::clone(&owner)), Value::U8(2)]) } + .unwrap_err(); + assert!(error.message().contains("completion modes")); + assert_eq!(CALLS.get(), 0); + } + drop(lease); + for (flags, succeeded) in [(2, true), (0, true), (u8::MAX, false)] { + let result = + unsafe { call.invoke(&[Value::Resource(Arc::clone(&owner)), Value::U8(flags)]) } + .unwrap(); + assert_eq!(result.succeeded, succeeded); + assert_eq!(owner.file_capability().cached_completion_modes(), Some(3)); + } + assert_eq!(CALLS.get(), 3); + owner.close().unwrap(); +} diff --git a/crates/dynwinrt/src/win32_io.rs b/crates/dynwinrt/src/win32_io.rs new file mode 100644 index 00000000..47696019 --- /dev/null +++ b/crates/dynwinrt/src/win32_io.rs @@ -0,0 +1,651 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Bounded native file I/O. An owning completion carries its buffer, resource +//! lease and capacity permit until the receiver consumes or drops it. Operations +//! publish tokenized records to native channels; adapters own their receivers +//! and notification registrations independently of this runtime. + +use core::ffi::c_void; +use std::collections::HashMap; +use std::fmt; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::mpsc::Sender; +use std::sync::{Arc, LazyLock, Mutex}; + +use windows::Win32::Foundation::{HANDLE, INVALID_HANDLE_VALUE}; +use windows::Win32::Storage::FileSystem::{ReadFile, WriteFile}; +use windows::Win32::System::IO::{ + CancelIoEx, CreateIoCompletionPort, GetOverlappedResult, GetQueuedCompletionStatus, OVERLAPPED, + OVERLAPPED_0_0, +}; +use windows::Win32::System::WindowsProgramming::FILE_SKIP_COMPLETION_PORT_ON_SUCCESS; + +use super::{Cleanup, OwnedResource, OwnedResourceAsyncLease}; + +pub const COMPLETION_WORKERS_MAX: usize = 4; +pub const MAX_PENDING_OPERATIONS: usize = 1024; +pub const MAX_OPERATION_BUFFER_BYTES: usize = 64 * 1024 * 1024; +pub const MAX_PENDING_BUFFER_BYTES: usize = 256 * 1024 * 1024; + +const ERROR_IO_PENDING: u32 = 997; +const ERROR_OPERATION_ABORTED: u32 = 995; +const ERROR_HANDLE_EOF: u32 = 38; +const ERROR_BROKEN_PIPE: u32 = 109; +const ERROR_NOT_FOUND: u32 = 1168; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum IoKind { + Read, + Write, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Submission { + Pending, + CompletionPacket, + Inline, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct IoError { + message: String, + code: Option, +} + +impl IoError { + fn new(message: impl Into) -> Self { + Self { + message: message.into(), + code: None, + } + } + + fn native(function: &str, code: u32) -> Self { + Self { + message: format!("{function} failed with Win32 error {code}"), + code: Some(code), + } + } + + pub fn code(&self) -> Option { + self.code + } +} + +impl fmt::Display for IoError { + fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { + self.message.fmt(formatter) + } +} + +impl std::error::Error for IoError {} + +type IoResult = std::result::Result; + +struct NativeControl { + active: bool, + handle: usize, + overlapped: *const OVERLAPPED, +} + +struct OperationState { + control: Mutex, + cancelled: AtomicBool, +} + +// The pointer is accessed only with `control` locked. It remains in a stable +// registry allocation until deactivation clears it under that same lock. +unsafe impl Send for OperationState {} +unsafe impl Sync for OperationState {} + +impl OperationState { + fn activate(&self, handle: usize, overlapped: *const OVERLAPPED) { + let mut control = self + .control + .lock() + .unwrap_or_else(|error| error.into_inner()); + control.handle = handle; + control.overlapped = overlapped; + control.active = true; + } + + fn deactivate(&self) { + let mut control = self + .control + .lock() + .unwrap_or_else(|error| error.into_inner()); + control.active = false; + control.handle = 0; + control.overlapped = std::ptr::null(); + } +} + +#[derive(Clone)] +pub struct IoCancellation(Arc); + +impl IoCancellation { + fn new() -> Self { + Self(Arc::new(OperationState { + control: Mutex::new(NativeControl { + active: false, + handle: 0, + overlapped: std::ptr::null(), + }), + cancelled: AtomicBool::new(false), + })) + } + + /// Requests cancellation; it does not retire OS-owned storage. + pub fn cancel(&self) { + self.0.cancelled.store(true, Ordering::Release); + let control = self + .0 + .control + .lock() + .unwrap_or_else(|error| error.into_inner()); + if control.active { + if let Err(error) = unsafe { + CancelIoEx( + HANDLE(control.handle as *mut c_void), + Some(control.overlapped), + ) + } { + if win32_error_code(&error) != ERROR_NOT_FOUND { + eprintln!("[dynwinrt] native I/O cancellation request failed: {error}"); + } + } + } + } + + fn is_cancelled(&self) -> bool { + self.0.cancelled.load(Ordering::Acquire) + } +} + +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)] +pub struct CapacityUsage { + pub operations: usize, + pub buffer_bytes: usize, +} + +struct CapacityPermit { + capacity: Arc>, + buffer_bytes: usize, +} + +impl CapacityPermit { + fn acquire(capacity: &Arc>, buffer_bytes: usize) -> IoResult { + let mut state = capacity.lock().unwrap_or_else(|error| error.into_inner()); + validate_capacity(state.operations, state.buffer_bytes, buffer_bytes)?; + state.operations += 1; + state.buffer_bytes += buffer_bytes; + drop(state); + Ok(Self { + capacity: Arc::clone(capacity), + buffer_bytes, + }) + } +} + +impl Drop for CapacityPermit { + fn drop(&mut self) { + let mut state = self + .capacity + .lock() + .unwrap_or_else(|error| error.into_inner()); + state.operations = state + .operations + .checked_sub(1) + .expect("IOCP operation accounting remains balanced"); + state.buffer_bytes = state + .buffer_bytes + .checked_sub(self.buffer_bytes) + .expect("IOCP buffer accounting remains balanced"); + } +} + +struct IoStorage { + kind: IoKind, + lease: OwnedResourceAsyncLease, + buffer: Vec, + _permit: CapacityPermit, +} + +/// Prepared work is not yet owned by the OS. Dropping it returns its lease and +/// capacity without submitting anything. +pub struct PreparedIo { + runtime: Arc, + storage: IoStorage, + offset: u64, + cancellation: IoCancellation, +} + +impl PreparedIo { + pub fn cancellation(&self) -> IoCancellation { + self.cancellation.clone() + } + + /// Publishes one terminal record to a native, nonblocking channel. The + /// capacity permit bounds queued records as well as active operations. + /// A closed receiver discards the record only after native completion. + /// Synchronous submission errors return without publishing a record. + pub fn submit(self, token: u64, completions: Sender) -> IoResult { + let runtime = Arc::clone(&self.runtime); + runtime.submit(self, token, completions) + } +} + +/// A terminal result, including ownership of all storage still awaiting +/// delivery. Merely receiving a native packet does not return capacity. +pub struct IoCompletion { + token: u64, + storage: IoStorage, + result: IoResult, +} + +impl IoCompletion { + pub fn token(&self) -> u64 { + self.token + } + + pub fn kind(&self) -> IoKind { + self.storage.kind + } + + pub fn result(&self) -> std::result::Result { + self.result.as_ref().copied() + } + + pub fn buffer(&self) -> &[u8] { + &self.storage.buffer + } +} + +struct NativeOperation { + overlapped: OVERLAPPED, + storage: IoStorage, + cancellation: IoCancellation, + token: u64, + completions: Sender, +} + +// The operation is moved only into or out of the mutex-protected registry. +// Windows can access its stable allocation only between activation and the +// terminal packet (or verified synchronous completion without a packet). +unsafe impl Send for NativeOperation {} + +impl NativeOperation { + fn deactivate(&mut self) { + self.cancellation.0.deactivate(); + self.storage.lease.mark_inactive(); + } + + fn deliver(mut self: Box, transferred: u32, error: Option) { + self.deactivate(); + let result = match error { + Some(error) if is_read_eof(self.storage.kind, error) => Ok(0), + Some(error) => Err(IoError::native( + if error == ERROR_OPERATION_ABORTED { + "OVERLAPPED operation" + } else { + "IOCP completion" + }, + error, + )), + None => Ok(transferred), + }; + let Self { + token, + storage, + completions, + .. + } = *self; + let completion = IoCompletion { + token, + storage, + result, + }; + // SendError owns the rejected record. Dropping it releases only native + // storage, after the OS has stopped accessing the OVERLAPPED and bytes. + drop(completions.send(completion)); + } +} + +pub struct IocpRuntime { + port: usize, + registry: Mutex>>, + capacity: Arc>, + shutting_down: AtomicBool, + worker_count: usize, +} + +static RUNTIME: LazyLock>> = LazyLock::new(IocpRuntime::new); + +impl IocpRuntime { + pub fn shared() -> IoResult<&'static Arc> { + RUNTIME.as_ref().map_err(Clone::clone) + } + + fn new() -> IoResult> { + use windows::Win32::Foundation::HMODULE; + use windows::Win32::System::LibraryLoader::{ + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, GET_MODULE_HANDLE_EX_FLAG_PIN, + GetModuleHandleExW, + }; + + // Workers can outlive the embedding environment and any loaded addon. + let mut module = HMODULE::default(); + unsafe { + GetModuleHandleExW( + GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, + windows_core::PCWSTR(Self::new as *const () as *const u16), + &mut module, + ) + } + .map_err(|error| IoError::new(format!("Cannot pin the IOCP worker module: {error}")))?; + let worker_count = std::thread::available_parallelism() + .map(|count| count.get().min(COMPLETION_WORKERS_MAX)) + .unwrap_or(2) + .max(1); + let port = + unsafe { CreateIoCompletionPort(INVALID_HANDLE_VALUE, None, 0, worker_count as u32) } + .map_err(|error| IoError::new(format!("CreateIoCompletionPort failed: {error}")))?; + let runtime = Arc::new(Self { + port: port.0 as usize, + registry: Mutex::new(HashMap::new()), + capacity: Arc::new(Mutex::new(CapacityUsage::default())), + shutting_down: AtomicBool::new(false), + worker_count, + }); + for index in 0..worker_count { + let worker = Arc::clone(&runtime); + if let Err(error) = std::thread::Builder::new() + .name(format!("dynwinrt-iocp-completion-{index}")) + .spawn(move || worker.completion_loop()) + { + runtime.shutting_down.store(true, Ordering::Release); + let _ = unsafe { windows::Win32::Foundation::CloseHandle(port) }; + return Err(IoError::new(format!( + "Failed to create IOCP completion worker: {error}" + ))); + } + } + Ok(runtime) + } + + pub fn worker_count(&self) -> usize { + self.worker_count + } + + pub fn capacity_usage(&self) -> CapacityUsage { + *self + .capacity + .lock() + .unwrap_or_else(|error| error.into_inner()) + } + + pub fn prepare_read( + self: &Arc, + resource: &Arc, + length: usize, + offset: u64, + ) -> IoResult { + self.prepare(resource, IoKind::Read, length, &[], offset) + } + + /// Takes an immediate native snapshot; no caller-owned buffer is retained + /// or subsequently read by Windows. + pub fn prepare_write( + self: &Arc, + resource: &Arc, + bytes: &[u8], + offset: u64, + ) -> IoResult { + self.prepare(resource, IoKind::Write, bytes.len(), bytes, offset) + } + + fn prepare( + self: &Arc, + resource: &Arc, + kind: IoKind, + length: usize, + bytes: &[u8], + offset: u64, + ) -> IoResult { + if resource.cleanup() != Cleanup::CloseHandle { + return Err(IoError::new( + "OVERLAPPED I/O requires a CloseHandle resource", + )); + } + validate_operation_buffer(length)?; + let permit = CapacityPermit::acquire(&self.capacity, length)?; + let lease = resource + .async_lease(Cleanup::CloseHandle) + .map_err(|error| IoError::new(error.message()))?; + if lease.raw() == usize::MAX { + return Err(IoError::new("OVERLAPPED I/O requires a valid file HANDLE")); + } + let mut buffer = Vec::new(); + buffer + .try_reserve_exact(length) + .map_err(|_| IoError::new("Unable to allocate private OVERLAPPED I/O buffer"))?; + match kind { + IoKind::Read => buffer.resize(length, 0), + IoKind::Write => buffer.extend_from_slice(bytes), + } + Ok(PreparedIo { + runtime: Arc::clone(self), + storage: IoStorage { + kind, + lease, + buffer, + _permit: permit, + }, + offset, + cancellation: IoCancellation::new(), + }) + } + + fn port(&self) -> HANDLE { + HANDLE(self.port as *mut c_void) + } + + fn submit( + &self, + task: PreparedIo, + token: u64, + completions: Sender, + ) -> IoResult { + if task.cancellation.is_cancelled() { + return Err(IoError::new("OVERLAPPED operation was aborted")); + } + let handle = task.storage.lease.raw(); + let mut overlapped = OVERLAPPED::default(); + overlapped.Anonymous.Anonymous = OVERLAPPED_0_0 { + Offset: task.offset as u32, + OffsetHigh: (task.offset >> 32) as u32, + }; + let mut operation = Box::new(NativeOperation { + overlapped, + storage: task.storage, + cancellation: task.cancellation, + token, + completions, + }); + let overlapped_ptr = &mut operation.overlapped as *mut OVERLAPPED; + let key = overlapped_ptr as usize; + let mut registry = self + .registry + .lock() + .unwrap_or_else(|error| error.into_inner()); + operation + .storage + .lease + .associate_completion_port(self.port) + .map_err(|error| IoError::new(error.message()))?; + let completion_modes = operation + .storage + .lease + .completion_modes() + .map_err(|error| IoError::new(error.message()))?; + if registry.contains_key(&key) { + return Err(IoError::new("duplicate OVERLAPPED operation address")); + } + operation.cancellation.0.activate(handle, overlapped_ptr); + operation.storage.lease.mark_active(); + registry.insert(key, operation); + let operation = registry + .get_mut(&key) + .expect("operation was just registered"); + let result = unsafe { + match operation.storage.kind { + IoKind::Read => ReadFile( + HANDLE(handle as *mut c_void), + Some(operation.storage.buffer.as_mut_slice()), + None, + Some(overlapped_ptr), + ), + IoKind::Write => WriteFile( + HANDLE(handle as *mut c_void), + Some(operation.storage.buffer.as_slice()), + None, + Some(overlapped_ptr), + ), + } + }; + let error = result.err().map(|error| win32_error_code(&error)); + if let Some(error) = error.filter(|error| *error != ERROR_IO_PENDING) { + let mut operation = registry + .remove(&key) + .expect("failed operation was registered"); + drop(registry); + if is_read_eof(operation.storage.kind, error) { + operation.deliver(0, None); + return Ok(Submission::Inline); + } + operation.deactivate(); + return Err(IoError::native( + match operation.storage.kind { + IoKind::Read => "ReadFile", + IoKind::Write => "WriteFile", + }, + error, + )); + } + if error.is_none() && completion_modes & FILE_SKIP_COMPLETION_PORT_ON_SUCCESS != 0 { + let mut transferred = 0; + let result = unsafe { + GetOverlappedResult( + HANDLE(handle as *mut c_void), + overlapped_ptr, + &mut transferred, + false, + ) + }; + let error = result.err().map(|error| win32_error_code(&error)); + let operation = registry + .remove(&key) + .expect("inline operation was registered"); + drop(registry); + operation.deliver(transferred, error); + return Ok(Submission::Inline); + } + let operation = registry + .get(&key) + .expect("submitted operation remains registered"); + if operation.cancellation.is_cancelled() { + // A request may have raced activation before ReadFile/WriteFile + // actually submitted the operation. Retry once after submission. + operation.cancellation.cancel(); + } + Ok(if error.is_some() { + Submission::Pending + } else { + Submission::CompletionPacket + }) + } + + fn completion_loop(self: &Arc) { + loop { + let mut transferred = 0; + let mut completion_key = 0; + let mut overlapped = std::ptr::null_mut(); + let result = unsafe { + GetQueuedCompletionStatus( + self.port(), + &mut transferred, + &mut completion_key, + &mut overlapped, + u32::MAX, + ) + }; + if overlapped.is_null() { + if self.shutting_down.load(Ordering::Acquire) { + return; + } + if let Err(error) = result { + eprintln!("[dynwinrt] IOCP completion wait failed: {error}"); + } + continue; + } + let operation = self + .registry + .lock() + .unwrap_or_else(|error| error.into_inner()) + .remove(&(overlapped as usize)); + if let Some(operation) = operation { + operation.deliver( + transferred, + result.err().map(|error| win32_error_code(&error)), + ); + } else { + eprintln!("[dynwinrt] ignored completion for unknown OVERLAPPED {overlapped:p}"); + } + } + } +} + +fn is_read_eof(kind: IoKind, error: u32) -> bool { + kind == IoKind::Read && matches!(error, ERROR_HANDLE_EOF | ERROR_BROKEN_PIPE) +} + +fn win32_error_code(error: &windows_core::Error) -> u32 { + let code = error.code().0 as u32; + if code & 0xffff_0000 == 0x8007_0000 { + code & 0xffff + } else { + code + } +} + +fn validate_operation_buffer(bytes: usize) -> IoResult<()> { + if bytes > MAX_OPERATION_BUFFER_BYTES { + return Err(IoError::new(format!( + "IOCP operation Buffer exceeds the {MAX_OPERATION_BUFFER_BYTES} byte limit" + ))); + } + Ok(()) +} + +fn validate_capacity(operations: usize, bytes: usize, requested: usize) -> IoResult<()> { + validate_operation_buffer(requested)?; + if operations >= MAX_PENDING_OPERATIONS { + return Err(IoError::new(format!( + "IOCP pending operation limit ({MAX_PENDING_OPERATIONS}) was reached" + ))); + } + let total = bytes + .checked_add(requested) + .ok_or_else(|| IoError::new("IOCP pending Buffer accounting overflow"))?; + if total > MAX_PENDING_BUFFER_BYTES { + return Err(IoError::new(format!( + "IOCP pending native Buffer limit ({MAX_PENDING_BUFFER_BYTES} bytes) would be exceeded" + ))); + } + Ok(()) +} + +#[cfg(test)] +#[path = "win32_io_tests.rs"] +mod tests; diff --git a/crates/dynwinrt/src/win32_io_tests.rs b/crates/dynwinrt/src/win32_io_tests.rs new file mode 100644 index 00000000..85294e23 --- /dev/null +++ b/crates/dynwinrt/src/win32_io_tests.rs @@ -0,0 +1,732 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use std::os::windows::fs::OpenOptionsExt; +use std::os::windows::io::IntoRawHandle; +use std::path::PathBuf; +use std::sync::atomic::AtomicUsize; +use std::sync::mpsc::{Receiver, RecvTimeoutError, TryRecvError, channel}; +use std::time::{Duration, Instant}; + +use windows::Win32::Foundation::{GENERIC_READ, GENERIC_WRITE}; +use windows::Win32::Storage::FileSystem::{ + CreateFileW, FILE_FLAG_OVERLAPPED, FILE_SHARE_READ, FILE_SHARE_WRITE, OPEN_EXISTING, + PIPE_ACCESS_DUPLEX, SetFileCompletionNotificationModes, +}; +use windows::Win32::System::Pipes::{ + ConnectNamedPipe, CreateNamedPipeW, PIPE_READMODE_BYTE, PIPE_REJECT_REMOTE_CLIENTS, + PIPE_TYPE_BYTE, PIPE_WAIT, +}; +use windows_core::HSTRING; + +use super::super::ResourceAccess; + +static TEST_LOCK: Mutex<()> = Mutex::new(()); +static NEXT_NAME: AtomicUsize = AtomicUsize::new(1); +const TIMEOUT: Duration = Duration::from_secs(10); +const COMPLETION_TOKEN: u64 = 0x1234_5678_9abc_def0; + +struct LocalFile { + resource: Arc, + path: PathBuf, +} + +impl LocalFile { + fn new(write: bool) -> Self { + let path = PathBuf::from(format!( + "dynwinrt-native-iocp-{}-{}.bin", + std::process::id(), + NEXT_NAME.fetch_add(1, Ordering::Relaxed), + )); + std::fs::write(&path, b"native-iocp").unwrap(); + let file = std::fs::OpenOptions::new() + .read(true) + .write(write) + .custom_flags(FILE_FLAG_OVERLAPPED.0) + .open(&path) + .unwrap(); + let resource = + unsafe { OwnedResource::adopt(file.into_raw_handle() as usize, Cleanup::CloseHandle) } + .unwrap(); + Self { resource, path } + } +} + +impl Drop for LocalFile { + fn drop(&mut self) { + let _ = self.resource.close(); + let _ = std::fs::remove_file(&self.path); + } +} + +struct Pipe { + client: Arc, + peer: Arc, +} + +impl Pipe { + fn new(modes: u8) -> Self { + let name = HSTRING::from(format!( + "\\\\.\\pipe\\dynwinrt-native-iocp-{}-{}", + std::process::id(), + NEXT_NAME.fetch_add(1, Ordering::Relaxed), + )); + let peer = unsafe { + CreateNamedPipeW( + &name, + PIPE_ACCESS_DUPLEX, + PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT | PIPE_REJECT_REMOTE_CLIENTS, + 1, + 4096, + 4096, + 0, + None, + ) + }; + assert!(!peer.is_invalid(), "CreateNamedPipeW failed"); + let peer = unsafe { OwnedResource::adopt(peer.0 as usize, Cleanup::CloseHandle) }.unwrap(); + let client = unsafe { + CreateFileW( + &name, + GENERIC_READ.0 | GENERIC_WRITE.0, + FILE_SHARE_READ | FILE_SHARE_WRITE, + None, + OPEN_EXISTING, + FILE_FLAG_OVERLAPPED, + None, + ) + } + .unwrap(); + let client = + unsafe { OwnedResource::adopt(client.0 as usize, Cleanup::CloseHandle) }.unwrap(); + let connected = unsafe { ConnectNamedPipe(HANDLE(peer.raw() as *mut c_void), None) }; + assert!( + connected.is_ok() + || connected + .as_ref() + .is_err_and(|error| win32_error_code(error) == 535), + "ConnectNamedPipe failed: {connected:?}" + ); + // Deliberately bypass the capability cache: submission must query the + // native file state, including changes made outside a tracked call. + unsafe { SetFileCompletionNotificationModes(HANDLE(client.raw() as *mut c_void), modes) } + .unwrap(); + unsafe { SetFileCompletionNotificationModes(HANDLE(client.raw() as *mut c_void), 0) } + .unwrap(); + Self { client, peer } + } + + fn write(&self, bytes: &[u8]) { + let lease = self.peer.lease(Cleanup::CloseHandle).unwrap(); + let mut written = 0; + unsafe { + WriteFile( + HANDLE(lease.raw() as *mut c_void), + Some(bytes), + Some(&mut written), + None, + ) + } + .unwrap(); + assert_eq!(written as usize, bytes.len()); + } + + fn read(&self, bytes: &mut [u8]) { + let lease = self.peer.lease(Cleanup::CloseHandle).unwrap(); + let mut read = 0; + unsafe { + ReadFile( + HANDLE(lease.raw() as *mut c_void), + Some(bytes), + Some(&mut read), + None, + ) + } + .unwrap(); + assert_eq!(read as usize, bytes.len()); + } +} + +struct CancelOnDrop(IoCancellation); + +impl Drop for CancelOnDrop { + fn drop(&mut self) { + self.0.cancel(); + } +} + +fn submit(task: PreparedIo) -> (Submission, Receiver, CancelOnDrop) { + let cancellation = CancelOnDrop(task.cancellation()); + let (sender, receiver) = channel(); + let submission = task.submit(COMPLETION_TOKEN, sender).unwrap(); + (submission, receiver, cancellation) +} + +fn receive(receiver: &Receiver) -> IoCompletion { + receiver + .recv_timeout(TIMEOUT) + .expect("native I/O did not complete") +} + +fn wait_for(mut condition: impl FnMut() -> bool) { + let deadline = Instant::now() + TIMEOUT; + while !condition() { + assert!(Instant::now() < deadline, "native I/O state did not settle"); + std::thread::yield_now(); + } +} + +fn assert_idle(runtime: &IocpRuntime, resource: &OwnedResource) { + assert!(!resource.has_async_leases()); + assert!(!resource.has_active_async_io()); + assert_eq!(runtime.capacity_usage(), CapacityUsage::default()); + assert!(runtime.registry.lock().unwrap().is_empty()); +} + +#[test] +fn native_io_types_are_send_without_a_language_runtime() { + fn send() {} + fn send_sync() {} + send::(); + send::(); + send_sync::>(); + send_sync::(); + send_sync::(); + send_sync::(); + let _: fn(PreparedIo, u64, Sender) -> IoResult = PreparedIo::submit; +} + +#[test] +fn capacity_bounds_operations_and_native_buffers() { + validate_capacity(MAX_PENDING_OPERATIONS - 1, 0, 1).unwrap(); + assert!( + validate_capacity(MAX_PENDING_OPERATIONS, 0, 1) + .unwrap_err() + .to_string() + .contains("operation limit") + ); + validate_capacity(0, MAX_PENDING_BUFFER_BYTES - 1, 1).unwrap(); + assert!( + validate_capacity(0, MAX_PENDING_BUFFER_BYTES, 1) + .unwrap_err() + .to_string() + .contains("Buffer limit") + ); + assert!( + validate_operation_buffer(MAX_OPERATION_BUFFER_BYTES + 1) + .unwrap_err() + .to_string() + .contains("operation Buffer") + ); + assert!( + validate_capacity(0, usize::MAX, 1) + .unwrap_err() + .to_string() + .contains("accounting overflow") + ); + let capacity = Arc::new(Mutex::new(CapacityUsage::default())); + let permit = CapacityPermit::acquire(&capacity, 16).unwrap(); + assert_eq!( + *capacity.lock().unwrap(), + CapacityUsage { + operations: 1, + buffer_bytes: 16, + } + ); + drop(permit); + assert_eq!(*capacity.lock().unwrap(), CapacityUsage::default()); + let error = windows_core::Error::from_hresult(windows_core::HRESULT( + 0x8007_0000u32.wrapping_add(ERROR_IO_PENDING) as i32, + )); + assert_eq!(win32_error_code(&error), ERROR_IO_PENDING); +} + +fn capacity_state(capacity: &Mutex) -> (usize, usize) { + let state = capacity.lock().unwrap(); + (state.operations, state.buffer_bytes) +} + +#[test] +fn byte_capacity_and_operation_capacity_are_independent_and_failure_is_transactional() { + let base = MAX_PENDING_BUFFER_BYTES - MAX_OPERATION_BUFFER_BYTES; + let capacity = Arc::new(Mutex::new(CapacityUsage { + operations: 0, + buffer_bytes: base, + })); + let permit = CapacityPermit::acquire(&capacity, MAX_OPERATION_BUFFER_BYTES).unwrap(); + assert_eq!(capacity_state(&capacity), (1, MAX_PENDING_BUFFER_BYTES)); + assert!(CapacityPermit::acquire(&capacity, 1).is_err()); + assert_eq!(capacity_state(&capacity), (1, MAX_PENDING_BUFFER_BYTES)); + let zero = CapacityPermit::acquire(&capacity, 0).unwrap(); + assert_eq!(capacity_state(&capacity), (2, MAX_PENDING_BUFFER_BYTES)); + drop((zero, permit)); + assert_eq!(capacity_state(&capacity), (0, base)); + assert!(CapacityPermit::acquire(&capacity, MAX_OPERATION_BUFFER_BYTES + 1).is_err()); + assert_eq!(capacity_state(&capacity), (0, base)); + let failure = (|| -> IoResult<()> { + let _permit = CapacityPermit::acquire(&capacity, 16)?; + Err(IoError::new("operation preparation failed")) + })(); + assert!(failure.is_err()); + assert_eq!(capacity_state(&capacity), (0, base)); + let panicked = std::panic::catch_unwind(|| { + let _permit = CapacityPermit::acquire(&capacity, 16).unwrap(); + panic!("operation preparation unwound"); + }); + assert!(panicked.is_err()); + assert_eq!(capacity_state(&capacity), (0, base)); +} + +#[test] +fn racing_capacity_reservations_admit_only_one_operation_without_timing_assumptions() { + use std::sync::Barrier; + const WORKERS: usize = 4; + let base = CapacityUsage { + operations: MAX_PENDING_OPERATIONS - 1, + buffer_bytes: MAX_PENDING_BUFFER_BYTES - 8, + }; + let capacity = Arc::new(Mutex::new(base)); + let gate = Arc::new(Barrier::new(WORKERS + 1)); + let (result_tx, result_rx) = channel(); + let mut releases = Vec::new(); + let mut workers = Vec::new(); + for _ in 0..WORKERS { + let capacity = Arc::clone(&capacity); + let gate = Arc::clone(&gate); + let result_tx = result_tx.clone(); + let (release_tx, release_rx) = channel(); + releases.push(release_tx); + workers.push(std::thread::spawn(move || { + gate.wait(); + let permit = CapacityPermit::acquire(&capacity, 8); + result_tx.send(permit.is_ok()).unwrap(); + let _ = release_rx.recv(); + drop(permit); + })); + } + gate.wait(); + let outcomes = (0..WORKERS) + .map(|_| result_rx.recv_timeout(TIMEOUT)) + .collect::>(); + let held = capacity_state(&capacity); + for release in releases { + let _ = release.send(()); + } + for worker in workers { + worker.join().unwrap(); + } + assert_eq!( + outcomes + .into_iter() + .map(Result::unwrap) + .filter(|admitted| *admitted) + .count(), + 1 + ); + assert_eq!(held, (MAX_PENDING_OPERATIONS, MAX_PENDING_BUFFER_BYTES)); + assert_eq!( + capacity_state(&capacity), + (base.operations, base.buffer_bytes) + ); +} + +#[test] +fn completion_deactivation_removes_addresses_before_late_cancellation() { + let state = IoCancellation::new(); + let event = unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + let event = unsafe { OwnedResource::adopt(event.0 as usize, Cleanup::CloseHandle) }.unwrap(); + let overlapped = Box::new(OVERLAPPED::default()); + state.0.activate(event.raw(), &*overlapped); + { + let control = state.0.control.lock().unwrap(); + assert!(control.active); + assert_eq!(control.overlapped, std::ptr::from_ref(&*overlapped)); + } + state.0.deactivate(); + drop(overlapped); + state.cancel(); + state.cancel(); + let control = state.0.control.lock().unwrap(); + assert!(!control.active); + assert_eq!(control.handle, 0); + assert!(control.overlapped.is_null()); + assert!(state.is_cancelled()); +} + +#[test] +fn native_modes_preserve_inline_packets_pending_cancellation_and_eof() { + let _serial = TEST_LOCK.lock().unwrap_or_else(|error| error.into_inner()); + let runtime = IocpRuntime::shared().unwrap(); + assert!((1..=COMPLETION_WORKERS_MAX).contains(&runtime.worker_count())); + for modes in [0, 1, 2, 3] { + let pipe = Pipe::new(modes); + assert_eq!( + pipe.client.file_capability().cached_completion_modes(), + None + ); + pipe.write(b"ready"); + let (submission, receiver, cancel) = + submit(runtime.prepare_read(&pipe.client, 5, 0).unwrap()); + assert_eq!( + submission, + if modes & 1 == 0 { + Submission::CompletionPacket + } else { + Submission::Inline + } + ); + let completed = receive(&receiver); + assert_eq!(completed.token(), COMPLETION_TOKEN); + assert_eq!(completed.result().unwrap(), 5); + assert_eq!(completed.buffer(), b"ready"); + assert_eq!( + pipe.client.file_capability().cached_completion_modes(), + Some(u32::from(modes)) + ); + assert!(!pipe.client.has_active_async_io()); + assert!(pipe.client.has_async_leases()); + assert!(pipe.client.close().is_err()); + assert!( + pipe.client + .lock_for_call(ResourceAccess::MutateState("file completion modes")) + .is_err() + ); + assert_eq!(runtime.capacity_usage().buffer_bytes, 5); + drop(completed); + cancel.0.cancel(); + assert_idle(runtime, &pipe.client); + + let (submission, receiver, cancel) = + submit(runtime.prepare_read(&pipe.client, 4, 0).unwrap()); + assert_eq!(submission, Submission::Pending); + { + // Hold registry retirement, not cancellation. Even after CancelIoEx + // returns, the OVERLAPPED, native bytes and lease remain owned. + let registry = runtime.registry.lock().unwrap(); + let operation = registry.values().next().unwrap(); + let pointer = operation.storage.buffer.as_ptr(); + cancel.0.cancel(); + cancel.0.cancel(); + assert!(pipe.client.has_active_async_io()); + assert!(pipe.client.has_async_leases()); + assert_eq!(operation.storage.buffer.as_ptr(), pointer); + assert_eq!(operation.storage.buffer.len(), 4); + assert_eq!(runtime.capacity_usage().operations, 1); + assert!(pipe.client.close().is_err()); + } + let completed = receive(&receiver); + assert_eq!( + completed.result().unwrap_err().code(), + Some(ERROR_OPERATION_ABORTED) + ); + assert!(!pipe.client.has_active_async_io()); + assert!(pipe.client.has_async_leases()); + assert_eq!(runtime.capacity_usage().buffer_bytes, 4); + drop(completed); + assert_idle(runtime, &pipe.client); + + let (_, receiver, _cancel) = submit(runtime.prepare_read(&pipe.client, 4, 0).unwrap()); + pipe.write(b"next"); + let completed = receive(&receiver); + assert_eq!(completed.result().unwrap(), 4); + assert_eq!(completed.buffer(), b"next"); + drop(completed); + + let mut original = Vec::from(b"back"); + let write = runtime.prepare_write(&pipe.client, &original, 0).unwrap(); + original.fill(0); + let (_, receiver, _cancel) = submit(write); + let completed = receive(&receiver); + assert_eq!(completed.kind(), IoKind::Write); + assert_eq!(completed.result().unwrap(), 4); + let mut received = [0; 4]; + pipe.read(&mut received); + assert_eq!(&received, b"back"); + drop(completed); + + pipe.peer.close().unwrap(); + let (_, receiver, _cancel) = submit(runtime.prepare_read(&pipe.client, 4, 0).unwrap()); + let completed = receive(&receiver); + assert_eq!(completed.result().unwrap(), 0); + drop(completed); + assert_idle(runtime, &pipe.client); + pipe.client.close().unwrap(); + } +} + +#[test] +fn prepared_cancellation_submission_errors_and_file_offsets_retire_once() { + let _serial = TEST_LOCK.lock().unwrap_or_else(|error| error.into_inner()); + let runtime = IocpRuntime::shared().unwrap(); + let file = LocalFile::new(false); + let prepared = runtime.prepare_read(&file.resource, 16, 0).unwrap(); + assert!(file.resource.has_async_leases()); + drop(prepared); + assert_idle(runtime, &file.resource); + + let prepared = runtime.prepare_read(&file.resource, 16, 0).unwrap(); + prepared.cancellation().cancel(); + let (sender, receiver) = channel(); + let error = prepared.submit(COMPLETION_TOKEN, sender).unwrap_err(); + assert!(error.to_string().contains("aborted")); + assert!(matches!( + receiver.try_recv(), + Err(TryRecvError::Disconnected) + )); + assert_idle(runtime, &file.resource); + + let write = runtime.prepare_write(&file.resource, b"denied", 0).unwrap(); + let (sender, receiver) = channel(); + let error = write.submit(COMPLETION_TOKEN, sender).unwrap_err(); + assert!(error.to_string().contains("WriteFile")); + assert!(matches!( + receiver.try_recv(), + Err(TryRecvError::Disconnected) + )); + assert_idle(runtime, &file.resource); + + let event = unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + let event = unsafe { OwnedResource::adopt(event.0 as usize, Cleanup::CloseHandle) }.unwrap(); + let invalid = runtime.prepare_read(&event, 1, 0).unwrap(); + let (sender, receiver) = channel(); + let error = invalid.submit(COMPLETION_TOKEN, sender).unwrap_err(); + assert!(error.to_string().contains("associate")); + assert!(matches!( + receiver.try_recv(), + Err(TryRecvError::Disconnected) + )); + assert_idle(runtime, &event); + event.close().unwrap(); + + let (_, receiver, _cancel) = submit(runtime.prepare_read(&file.resource, 12, 7).unwrap()); + let completed = receive(&receiver); + assert_eq!(completed.result().unwrap(), 4); + assert_eq!(&completed.buffer()[..4], b"iocp"); + assert!(completed.buffer()[4..].iter().all(|byte| *byte == 0)); + drop(completed); + let (_, receiver, _cancel) = submit(runtime.prepare_read(&file.resource, 4, 1 << 32).unwrap()); + let completed = receive(&receiver); + assert_eq!(completed.result().unwrap(), 0); + drop(completed); + assert_idle(runtime, &file.resource); +} + +#[test] +fn one_native_channel_routes_independent_operations_and_retains_their_leases() { + let _serial = TEST_LOCK.lock().unwrap_or_else(|error| error.into_inner()); + let runtime = IocpRuntime::shared().unwrap(); + let ready = Pipe::new(FILE_SKIP_COMPLETION_PORT_ON_SUCCESS as u8); + let pending = Pipe::new(0); + let (sender, receiver) = channel(); + ready.write(b"data"); + assert_eq!( + runtime + .prepare_read(&ready.client, 4, 0) + .unwrap() + .submit(u64::MAX, sender.clone()) + .unwrap(), + Submission::Inline + ); + let task = runtime.prepare_read(&pending.client, 4, 0).unwrap(); + let cancellation = CancelOnDrop(task.cancellation()); + assert_eq!(task.submit(0, sender).unwrap(), Submission::Pending); + cancellation.0.cancel(); + + let completed = receive(&receiver); + assert_eq!(completed.token(), u64::MAX); + assert_eq!(completed.result().unwrap(), 4); + assert_eq!(completed.buffer(), b"data"); + let cancelled = receive(&receiver); + assert_eq!(cancelled.token(), 0); + assert_eq!( + cancelled.result().unwrap_err().code(), + Some(ERROR_OPERATION_ABORTED) + ); + assert_eq!(runtime.capacity_usage().operations, 2); + assert!(ready.client.has_async_leases()); + assert!(pending.client.has_async_leases()); + assert!(!ready.client.has_active_async_io()); + assert!(!pending.client.has_active_async_io()); + assert!(matches!( + receiver.recv_timeout(TIMEOUT), + Err(RecvTimeoutError::Disconnected) + )); + drop(completed); + assert!(!ready.client.has_async_leases()); + assert!(pending.client.has_async_leases()); + assert_eq!(runtime.capacity_usage().operations, 1); + drop(cancelled); + assert_idle(runtime, &pending.client); +} + +#[test] +fn dropped_receivers_keep_pending_storage_until_terminal_and_retire_once() { + let _serial = TEST_LOCK.lock().unwrap_or_else(|error| error.into_inner()); + let runtime = IocpRuntime::shared().unwrap(); + let pipe = Pipe::new(0); + let prepared = runtime.prepare_read(&pipe.client, 4, 0).unwrap(); + let cancellation = CancelOnDrop(prepared.cancellation()); + let (sender, receiver) = channel(); + assert_eq!( + prepared.submit(COMPLETION_TOKEN, sender).unwrap(), + Submission::Pending + ); + drop(receiver); + { + let registry = runtime.registry.lock().unwrap(); + cancellation.0.cancel(); + assert_eq!(registry.len(), 1); + assert!(pipe.client.has_async_leases()); + assert!(pipe.client.has_active_async_io()); + assert_eq!(runtime.capacity_usage().buffer_bytes, 4); + } + wait_for(|| runtime.capacity_usage().operations == 0); + assert_idle(runtime, &pipe.client); + + for modes in [0, 1, 2, 3] { + let pipe = Pipe::new(modes); + pipe.write(b"drop"); + let (sender, receiver) = channel(); + drop(receiver); + assert_eq!( + runtime + .prepare_read(&pipe.client, 4, 0) + .unwrap() + .submit(COMPLETION_TOKEN, sender) + .unwrap(), + if modes & 1 == 0 { + Submission::CompletionPacket + } else { + Submission::Inline + } + ); + wait_for(|| runtime.capacity_usage().operations == 0); + assert_idle(runtime, &pipe.client); + } + + let (_, receiver, cancellation) = submit(runtime.prepare_read(&pipe.client, 4, 0).unwrap()); + let weak = Arc::downgrade(&pipe.client); + drop(pipe.client); + assert!(weak.upgrade().is_some()); + cancellation.0.cancel(); + let completed = receive(&receiver); + assert_eq!( + completed.result().unwrap_err().code(), + Some(ERROR_OPERATION_ABORTED) + ); + assert!(weak.upgrade().is_some()); + drop(completed); + assert!(weak.upgrade().is_none()); + assert_eq!(runtime.capacity_usage(), CapacityUsage::default()); +} + +#[test] +fn cancellation_racing_success_has_one_terminal_delivery() { + let _serial = TEST_LOCK.lock().unwrap_or_else(|error| error.into_inner()); + let runtime = IocpRuntime::shared().unwrap(); + for modes in [0, 1, 2, 3] { + for _ in 0..4 { + let pipe = Pipe::new(modes); + let (_, receiver, cancellation) = + submit(runtime.prepare_read(&pipe.client, 4, 0).unwrap()); + std::thread::scope(|scope| { + scope.spawn(|| pipe.write(b"race")); + cancellation.0.cancel(); + }); + let completed = receive(&receiver); + assert_eq!(completed.token(), COMPLETION_TOKEN); + match completed.result() { + Ok(bytes) => { + assert_eq!(bytes, 4); + assert_eq!(completed.buffer(), b"race"); + } + Err(error) => assert_eq!(error.code(), Some(ERROR_OPERATION_ABORTED)), + } + assert!(pipe.client.has_async_leases()); + assert!(!pipe.client.has_active_async_io()); + drop(completed); + cancellation.0.cancel(); + assert!(matches!( + receiver.recv_timeout(TIMEOUT), + Err(RecvTimeoutError::Disconnected) + )); + assert_idle(runtime, &pipe.client); + } + } +} + +#[test] +fn queued_completions_hold_operation_and_native_byte_quotas_until_consumed() { + let _serial = TEST_LOCK.lock().unwrap_or_else(|error| error.into_inner()); + let runtime = IocpRuntime::shared().unwrap(); + let pipe = Pipe::new(FILE_SKIP_COMPLETION_PORT_ON_SUCCESS as u8); + let (sender, receiver) = channel(); + pipe.write(&vec![b'q'; MAX_PENDING_OPERATIONS]); + for token in 0..MAX_PENDING_OPERATIONS { + assert_eq!( + runtime + .prepare_read(&pipe.client, 1, 0) + .unwrap() + .submit(token as u64, sender.clone()) + .unwrap(), + Submission::Inline + ); + } + assert!(!pipe.client.has_active_async_io()); + assert_eq!( + runtime.capacity_usage(), + CapacityUsage { + operations: MAX_PENDING_OPERATIONS, + buffer_bytes: MAX_PENDING_OPERATIONS, + } + ); + let error = runtime.prepare_read(&pipe.client, 0, 0).err().unwrap(); + assert!(error.to_string().contains("operation limit")); + assert!(pipe.client.close().is_err()); + drop(receiver); + assert_idle(runtime, &pipe.client); + + let (sender, receiver) = channel(); + for token in 0..MAX_PENDING_BUFFER_BYTES / MAX_OPERATION_BUFFER_BYTES { + pipe.write(b"native-iocp"); + assert_eq!( + runtime + .prepare_read(&pipe.client, MAX_OPERATION_BUFFER_BYTES, 0) + .unwrap() + .submit(token as u64, sender.clone()) + .unwrap(), + Submission::Inline + ); + } + assert!(!pipe.client.has_active_async_io()); + assert_eq!( + runtime.capacity_usage().buffer_bytes, + MAX_PENDING_BUFFER_BYTES + ); + let error = runtime.prepare_read(&pipe.client, 1, 0).err().unwrap(); + assert!(error.to_string().contains("Buffer limit")); + let error = runtime + .prepare_read(&pipe.client, MAX_OPERATION_BUFFER_BYTES + 1, 0) + .err() + .unwrap(); + assert!(error.to_string().contains("operation Buffer")); + let completed = receive(&receiver); + assert_eq!(completed.token(), 0); + assert_eq!(completed.result().unwrap(), 11); + assert_eq!(&completed.buffer()[..11], b"native-iocp"); + assert_eq!( + runtime.capacity_usage().buffer_bytes, + MAX_PENDING_BUFFER_BYTES + ); + drop(completed); + assert_eq!( + runtime.capacity_usage().buffer_bytes, + 3 * MAX_OPERATION_BUFFER_BYTES + ); + drop(runtime.prepare_read(&pipe.client, 1, 0).unwrap()); + drop(receiver); + assert_idle(runtime, &pipe.client); +} diff --git a/crates/dynwinrt/src/win32_module.rs b/crates/dynwinrt/src/win32_module.rs new file mode 100644 index 00000000..9f783f3a --- /dev/null +++ b/crates/dynwinrt/src/win32_module.rs @@ -0,0 +1,248 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Controlled module ownership shared by Win32 calls and lifecycle adapters. + +use std::{ + collections::HashMap, + ffi::{CStr, c_void}, + sync::{Arc, Mutex, OnceLock}, +}; +use windows::Win32::{ + Foundation::{FreeLibrary, HMODULE}, + System::LibraryLoader::{GetProcAddress, LOAD_LIBRARY_SEARCH_SYSTEM32, LoadLibraryExW}, +}; +use windows_core::{HRESULT, HSTRING, PCSTR}; + +use crate::result::{Error, Result}; + +#[derive(Debug)] +pub struct SystemModule { + name: String, + handle: HMODULE, + #[cfg(test)] + released: Option>, +} + +// Windows module references and export lookup are thread-safe. The handle is +// immutable, and the last Arc releases only this object's LoadLibrary reference. +unsafe impl Send for SystemModule {} +unsafe impl Sync for SystemModule {} + +#[derive(Default)] +struct ModuleCache { + modules: Mutex>>, +} + +impl ModuleCache { + fn get_or_load( + &self, + dll: &str, + load: impl FnOnce(&str) -> Result, + ) -> Result> { + if !is_bare_system_module_name(dll) { + return Err(super::invalid_argument("invalid System32 module name")); + } + let key = dll.to_ascii_lowercase(); + if let Some(module) = self + .modules + .lock() + .unwrap_or_else(|error| error.into_inner()) + .get(&key) + .cloned() + { + return Ok(module); + } + let loaded = Arc::new(load(&key)?); + let published = { + let mut modules = self + .modules + .lock() + .unwrap_or_else(|error| error.into_inner()); + Arc::clone(modules.entry(key).or_insert_with(|| Arc::clone(&loaded))) + }; + // A concurrent loser's reference is released outside the cache lock. + Ok(published) + } +} + +impl SystemModule { + /// Returns a process-cached system module. Failed loads are not cached. + /// + /// # Safety + /// + /// Loading a DLL can execute native initialization code. The caller must + /// ensure loading the selected system DLL is appropriate for this process. + pub unsafe fn cached(dll: &str) -> Result> { + static CACHE: OnceLock = OnceLock::new(); + CACHE + .get_or_init(ModuleCache::default) + .get_or_load(dll, |name| unsafe { Self::load(name) }) + } + + unsafe fn load(dll: &str) -> Result { + let handle = + unsafe { LoadLibraryExW(&HSTRING::from(dll), None, LOAD_LIBRARY_SEARCH_SYSTEM32) } + .map_err(|error| { + Error::WindowsError(windows_core::Error::new( + error.code(), + format!("System DLL `{dll}` could not be loaded from System32: {error}"), + )) + })?; + Ok(Self { + name: dll.into(), + handle, + #[cfg(test)] + released: None, + }) + } + + /// Resolves an export without invoking it. Calling the address requires an + /// exact native signature; the cached module keeps it valid for the process. + pub fn export(&self, name: &CStr) -> Result<*mut c_void> { + unsafe { GetProcAddress(self.handle, PCSTR(name.as_ptr().cast())) } + .map(|function| function as *const () as *mut c_void) + .ok_or_else(|| { + Error::WindowsError(windows_core::Error::new( + HRESULT(0x8007007Fu32 as i32), + format!( + "Export `{}` was not found in `{}`", + name.to_string_lossy(), + self.name + ), + )) + }) + } +} + +impl Drop for SystemModule { + fn drop(&mut self) { + if let Err(error) = unsafe { FreeLibrary(self.handle) } { + eprintln!( + "[dynwinrt] system module `{}` cleanup failed: {error}", + self.name + ); + } else { + #[cfg(test)] + if let Some(released) = &self.released { + released.fetch_add(1, std::sync::atomic::Ordering::SeqCst); + } + } + } +} + +pub(super) fn is_bare_system_module_name(dll: &str) -> bool { + let lower = dll.to_ascii_lowercase(); + !dll.is_empty() + && (lower.ends_with(".dll") || lower.ends_with(".drv")) + && !dll.encode_utf16().any(|unit| unit == 0) + && !dll + .chars() + .any(|character| matches!(character, '/' | '\\' | ':')) + && !matches!(dll, "." | "..") +} + +#[cfg(test)] +mod tests { + use super::*; + use std::sync::{ + Barrier, + atomic::{AtomicUsize, Ordering}, + }; + + #[test] + fn module_names_fail_before_native_loading() { + let cache = ModuleCache::default(); + for dll in [ + "", + "mfplat", + r"C:\Windows\System32\mfplat.dll", + r"..\mfplat.dll", + "../mfplat.dll", + "bad\0.dll", + ] { + assert!( + cache + .get_or_load(dll, |_| panic!("invalid DLL name reached the loader")) + .is_err() + ); + } + assert!(is_bare_system_module_name("kernel32.dll")); + assert!(is_bare_system_module_name("winspool.drv")); + } + + #[test] + fn failed_loads_retry_and_successful_modules_share_case_insensitive_identity() { + let cache = ModuleCache::default(); + let failure = cache.get_or_load("kernel32.dll", |_| { + Err(Error::WindowsError(windows_core::Error::new( + HRESULT(0x8007007Eu32 as i32), + "injected missing module", + ))) + }); + assert!(failure.is_err()); + assert!(cache.modules.lock().unwrap().is_empty()); + let module = cache + .get_or_load("KERNEL32.dll", |name| unsafe { SystemModule::load(name) }) + .unwrap(); + let reused = cache + .get_or_load("kernel32.dll", |_| panic!("cached module loaded again")) + .unwrap(); + assert!(Arc::ptr_eq(&module, &reused)); + assert!(module.export(c"GetCurrentProcess").is_ok()); + let missing = module.export(c"dynwinrt_missing_export").unwrap_err(); + assert!(missing.message().contains("dynwinrt_missing_export")); + assert!(missing.message().contains("kernel32.dll")); + assert!(module.export(c"GetCurrentProcess").is_ok()); + } + + #[test] + fn simultaneous_first_loads_release_every_losing_module_reference() { + let cache = Arc::new(ModuleCache::default()); + let barrier = Arc::new(Barrier::new(8)); + let released = Arc::new(AtomicUsize::new(0)); + let threads = (0..8) + .map(|_| { + let cache = Arc::clone(&cache); + let barrier = Arc::clone(&barrier); + let released = Arc::clone(&released); + std::thread::spawn(move || { + cache + .get_or_load("kernel32.dll", |name| { + let mut module = unsafe { SystemModule::load(name) }?; + module.released = Some(released); + barrier.wait(); + Ok(module) + }) + .unwrap() + }) + }) + .collect::>(); + let modules = threads + .into_iter() + .map(|thread| thread.join().unwrap()) + .collect::>(); + assert!( + modules + .iter() + .all(|module| Arc::ptr_eq(&modules[0], module)) + ); + assert_eq!(released.load(Ordering::SeqCst), 7); + drop(modules); + drop(cache); + assert_eq!(released.load(Ordering::SeqCst), 8); + } + + #[test] + fn module_ownership_and_exports_are_shareable_across_threads() { + fn send_sync() {} + send_sync::(); + send_sync::>(); + let module = unsafe { SystemModule::cached("kernel32.dll") }.unwrap(); + std::thread::spawn(move || { + assert!(!module.export(c"GetCurrentProcess").unwrap().is_null()); + }) + .join() + .unwrap(); + } +} diff --git a/crates/dynwinrt/src/win32_outcome_tests.rs b/crates/dynwinrt/src/win32_outcome_tests.rs new file mode 100644 index 00000000..9a96e711 --- /dev/null +++ b/crates/dynwinrt/src/win32_outcome_tests.rs @@ -0,0 +1,1104 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use std::cell::{Cell, RefCell}; + +#[derive(Debug, PartialEq, Eq)] +struct CleanupCall { + kind: Cleanup, + value: usize, + succeeded: bool, +} + +#[derive(Default)] +struct Observations { + cleanup: Vec, + locks: Vec, + fail_return_allocation: bool, + decoded_outputs: Vec, + fail_decode: Option, +} + +thread_local! { + static OBSERVED: RefCell = RefCell::default(); + static ALLOCATED: Cell<[usize; 2]> = const { Cell::new([0; 2]) }; + static DISPATCHES: Cell = const { Cell::new(0) }; +} + +pub(super) fn record_cleanup(kind: Cleanup, value: usize, succeeded: bool) { + OBSERVED.with(|observed| { + observed.borrow_mut().cleanup.push(CleanupCall { + kind, + value, + succeeded, + }); + }); +} + +pub(super) fn record_call_lock(value: usize) { + OBSERVED.with(|observed| observed.borrow_mut().locks.push(value)); +} + +pub(super) fn call_lock_order() -> Vec { + OBSERVED.with(|observed| observed.borrow().locks.clone()) +} + +pub(super) fn record_output_decode(index: usize) { + OBSERVED.with(|observed| observed.borrow_mut().decoded_outputs.push(index)); +} + +pub(super) fn check_result_decode(target: ResultTarget) -> Result<()> { + if OBSERVED.with(|observed| { + let mut observed = observed.borrow_mut(); + if observed.fail_decode == Some(target) { + observed.fail_decode = None; + true + } else { + false + } + }) { + return Err(invalid_argument( + "Injected native result conversion failure", + )); + } + Ok(()) +} + +pub(super) fn fail_decode(target: ResultTarget) { + OBSERVED.with(|observed| observed.borrow_mut().fail_decode = Some(target)); +} + +pub(super) fn decoded_outputs() -> Vec { + OBSERVED.with(|observed| observed.borrow().decoded_outputs.clone()) +} + +pub(super) fn cleanup_count_for(value: usize) -> usize { + OBSERVED.with(|observed| { + observed + .borrow() + .cleanup + .iter() + .filter(|call| call.value == value) + .count() + }) +} + +pub(super) fn successful_cleanup_count_for(value: usize) -> usize { + OBSERVED.with(|observed| { + observed + .borrow() + .cleanup + .iter() + .filter(|call| call.value == value && call.succeeded) + .count() + }) +} + +pub(super) fn check_aggregate_return_allocation() -> Result<()> { + if OBSERVED.with(|observed| std::mem::take(&mut observed.borrow_mut().fail_return_allocation)) { + Err(out_of_memory( + "native aggregate return (injected allocation failure)", + )) + } else { + Ok(()) + } +} + +pub(super) fn reset() { + OBSERVED.with(|observed| *observed.borrow_mut() = Observations::default()); + ALLOCATED.set([0; 2]); + DISPATCHES.set(0); +} + +fn cleanups() -> Vec { + OBSERVED.with(|observed| std::mem::take(&mut observed.borrow_mut().cleanup)) +} + +#[cfg(target_pointer_width = "64")] +fn policy(plan: Arc, rule: SuccessRule, cleanup: Cleanup) -> Arc { + let mut plan = Arc::try_unwrap(plan).unwrap(); + plan.success_rule = rule; + let spec = CallPlanSpec { + dll: plan.dll.clone(), + entry_point: plan.entry_point.clone(), + parameters: plan + .parameters + .iter() + .map(|parameter| parameter.spec) + .collect(), + return_type: plan.return_type, + return_cleanup: cleanup, + success_rule: rule, + capture_last_error: plan.capture_last_error, + calling_convention: plan.calling_convention, + parameter_aggregates: plan.parameter_aggregates.clone(), + return_aggregate: plan.return_aggregate.clone(), + }; + plan.contract = contract::resolve(&spec, &CallContract::default()).unwrap(); + plan.legacy_surface = contract::LegacySurface::new(&spec, &CallContract::default()); + Arc::new(plan) +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn every_success_rule_classifies_native_results_without_erasing_them() { + extern "system" fn integer(value: i32) -> i32 { + value + } + extern "system" fn pointer(value: *mut c_void) -> *mut c_void { + value + } + for rule in [ + SuccessRule::Always, + SuccessRule::ReturnZero, + SuccessRule::ReturnNonZero, + SuccessRule::HResultSucceeded, + SuccessRule::SignedNonNegative, + ] { + let plan = policy( + super::tests::fake_plan( + integer as *const () as usize, + vec![Parameter::input(Type::I32, false)], + Some(Type::I32), + vec![None], + None, + ), + rule, + Cleanup::None, + ); + for input in [i32::MIN, -1, 0, 1, i32::MAX] { + let result = unsafe { plan.invoke(&[Value::I32(input)]) }.unwrap(); + let expected = match rule { + SuccessRule::Always => true, + SuccessRule::ReturnZero => input == 0, + SuccessRule::ReturnNonZero => input != 0, + SuccessRule::HResultSucceeded | SuccessRule::SignedNonNegative => input >= 0, + _ => unreachable!(), + }; + assert_eq!(result.succeeded, expected, "{rule:?}, {input}"); + assert!(matches!(result.return_value, Some(Value::I32(value)) if value == input)); + assert!(result.outputs.is_empty()); + assert_eq!(result.last_error, None); + } + } + let mut byte = 0u8; + let valid = (&mut byte as *mut u8) as usize; + for rule in [ + SuccessRule::Always, + SuccessRule::ReturnZero, + SuccessRule::ReturnNonZero, + SuccessRule::ReturnNonNull, + SuccessRule::ReturnValidHandle, + ] { + let plan = policy( + super::tests::fake_plan( + pointer as *const () as usize, + vec![Parameter::input(Type::Handle, true)], + Some(Type::Handle), + vec![None], + None, + ), + rule, + Cleanup::None, + ); + for input in [0, valid, usize::MAX] { + let result = unsafe { plan.invoke(&[Value::Handle(input)]) }.unwrap(); + let expected = match rule { + SuccessRule::Always => true, + SuccessRule::ReturnZero => input == 0, + SuccessRule::ReturnNonZero | SuccessRule::ReturnNonNull => input != 0, + SuccessRule::ReturnValidHandle => input != 0 && input != usize::MAX, + _ => unreachable!(), + }; + assert_eq!(result.succeeded, expected, "{rule:?}, {input}"); + assert!(matches!(result.return_value, Some(Value::Handle(value)) if value == input)); + } + } +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn mixed_directions_keep_native_output_order_and_original_inputs() { + extern "system" fn mix( + input: i32, + byte: *mut u8, + wide: u64, + narrow: *mut i16, + floating: *mut f64, + pointer: *mut *mut c_void, + ) -> i32 { + DISPATCHES.set(DISPATCHES.get() + 1); + unsafe { + if *byte != 0 || *floating != 0.0 { + return E_INVALIDARG.0; + } + *byte = wide as u8; + *narrow += input as i16; + *floating = 6.25; + *pointer = std::ptr::null_mut(); + } + 1 + } + reset(); + let plan = policy( + super::tests::fake_plan( + mix as *const () as usize, + vec![ + Parameter::input(Type::I32, false), + Parameter::output(Type::U8, Cleanup::None), + Parameter::input(Type::U64, false), + Parameter::input_output(Type::I16, false, Cleanup::None), + Parameter::output(Type::F64, Cleanup::None), + Parameter::input_output(Type::Pointer, true, Cleanup::None), + ], + Some(Type::I32), + vec![None; 6], + None, + ), + SuccessRule::HResultSucceeded, + Cleanup::None, + ); + let mut anchor = 0u8; + let pointer = (&mut anchor as *mut u8).cast(); + let inputs = [ + Value::I32(23), + Value::U64(7), + Value::I16(-12), + Value::Pointer(pointer), + ]; + let result = unsafe { plan.invoke(&inputs) }.unwrap(); + assert!(result.succeeded); + assert_eq!((plan.input_count(), plan.output_count()), (4, 4)); + assert!(matches!(result.return_value, Some(Value::I32(1)))); + assert!(matches!(result.outputs.as_slice(), [ + Value::U8(7), Value::I16(11), Value::F64(value), Value::Pointer(pointer), + ] if *value == 6.25 && pointer.is_null())); + assert!(matches!(inputs[2], Value::I16(-12))); + assert!(matches!(inputs[3], Value::Pointer(value) if value == pointer)); + assert!(unsafe { plan.invoke(&inputs[..3]) }.is_err()); + let mut wrong = inputs.clone(); + wrong[1] = Value::U32(7); + assert!(unsafe { plan.invoke(&wrong) }.is_err()); + assert_eq!(DISPATCHES.get(), 1); +} + +#[cfg(target_pointer_width = "64")] +extern "system" fn allocate_outputs( + first: *mut *mut c_void, + scalar: *mut u32, + status: i32, + last: *mut *mut c_void, +) -> i32 { + use windows::Win32::System::Com::{CoTaskMemAlloc, CoTaskMemFree}; + unsafe { + if !(*first).is_null() || !(*last).is_null() || *scalar != 0 { + return E_INVALIDARG.0; + } + let a = CoTaskMemAlloc(16); + let b = CoTaskMemAlloc(16); + if a.is_null() || b.is_null() { + CoTaskMemFree(Some(a)); + CoTaskMemFree(Some(b)); + return 0x8007000eu32 as i32; + } + a.cast::().write(0x1122_3344); + b.cast::().write(0x5566_7788); + *first = a; + *last = b; + *scalar = 7; + ALLOCATED.set([a as usize, b as usize]); + } + status +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn owning_multi_outputs_cleanup_on_failure_and_last_alias_drop() { + let plan = policy( + super::tests::fake_plan( + allocate_outputs as *const () as usize, + vec![ + Parameter::output(Type::Pointer, Cleanup::CoTaskMemFree), + Parameter::output(Type::U32, Cleanup::None), + Parameter::input(Type::I32, false), + Parameter::output(Type::Pointer, Cleanup::CoTaskMemFree), + ], + Some(Type::I32), + vec![None; 4], + None, + ), + SuccessRule::HResultSucceeded, + Cleanup::None, + ); + for status in [0, 1, 0x80004005u32 as i32] { + reset(); + let result = unsafe { plan.invoke(&[Value::I32(status)]) }.unwrap(); + let [first, last] = ALLOCATED.get(); + assert_ne!(first, 0); + assert_ne!(last, 0); + assert!(matches!(result.outputs[1], Value::U32(7))); + assert_eq!(result.succeeded, status >= 0); + if status < 0 { + assert!(matches!(result.outputs[0], Value::Handle(0))); + assert!(matches!(result.outputs[2], Value::Handle(0))); + assert_eq!( + cleanups(), + vec![ + CleanupCall { + kind: Cleanup::CoTaskMemFree, + value: first, + succeeded: true + }, + CleanupCall { + kind: Cleanup::CoTaskMemFree, + value: last, + succeeded: true + }, + ] + ); + drop(result); + assert!(cleanups().is_empty()); + } else { + assert!(cleanups().is_empty()); + let alias = Arc::clone(result.outputs[0].resource().unwrap()); + assert_eq!(unsafe { (alias.raw() as *const u32).read() }, 0x1122_3344); + drop(result); + assert_eq!( + cleanups(), + vec![CleanupCall { + kind: Cleanup::CoTaskMemFree, + value: last, + succeeded: true + },] + ); + alias.close().unwrap(); + alias.close().unwrap(); + drop(alias); + assert_eq!( + cleanups(), + vec![CleanupCall { + kind: Cleanup::CoTaskMemFree, + value: first, + succeeded: true + },] + ); + } + } +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn aggregate_conversion_failure_cleans_all_initialized_owned_outputs() { + #[repr(C)] + struct Summary { + status: i32, + count: u32, + } + extern "system" fn produce(first: *mut *mut c_void, last: *mut *mut c_void) -> Summary { + let mut count = 0; + let status = allocate_outputs(first, &mut count, 0, last); + Summary { status, count } + } + let layout = NativeAggregateLayout::new( + "Tests.Summary", + 8, + 4, + FfiType::structure([FfiType::i32(), FfiType::u32()]), + ) + .unwrap(); + let plan = super::tests::fake_plan( + produce as *const () as usize, + vec![Parameter::output(Type::Pointer, Cleanup::CoTaskMemFree); 2], + None, + vec![None; 2], + Some(layout), + ); + reset(); + OBSERVED.with(|observed| observed.borrow_mut().fail_return_allocation = true); + let error = unsafe { plan.invoke(&[]) }.unwrap_err(); + assert!(error.message().contains("injected allocation failure")); + let [first, last] = ALLOCATED.get(); + assert_ne!(first, 0); + assert_ne!(last, 0); + assert_eq!( + cleanups(), + vec![ + CleanupCall { + kind: Cleanup::CoTaskMemFree, + value: first, + succeeded: true + }, + CleanupCall { + kind: Cleanup::CoTaskMemFree, + value: last, + succeeded: true + }, + ] + ); +} + +#[cfg(target_pointer_width = "64")] +extern "system" fn allocate_mixed(first: *mut HLOCAL, last: *mut *mut c_void, status: i32) -> i32 { + use windows::Win32::System::Memory::{LMEM_FIXED, LocalAlloc}; + let local = match unsafe { LocalAlloc(LMEM_FIXED, 16) } { + Ok(value) => value, + Err(error) => return error.code().0, + }; + let task = unsafe { windows::Win32::System::Com::CoTaskMemAlloc(16) }; + if task.is_null() { + unsafe { LocalFree(Some(local)) }; + return 0x8007000eu32 as i32; + } + unsafe { + first.write(local); + last.write(task); + } + ALLOCATED.set([local.0 as usize, task as usize]); + status +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn heterogeneous_output_cleanup_plans_do_not_share_allocator_policy() { + let plan = policy( + super::tests::fake_plan( + allocate_mixed as *const () as usize, + vec![ + Parameter::output(Type::Handle, Cleanup::LocalFree), + Parameter::output(Type::Pointer, Cleanup::CoTaskMemFree), + Parameter::input(Type::I32, false), + ], + Some(Type::I32), + vec![None; 3], + None, + ), + SuccessRule::HResultSucceeded, + Cleanup::None, + ); + for status in [0, 0x80004005u32 as i32] { + reset(); + let result = unsafe { plan.invoke(&[Value::I32(status)]) }.unwrap(); + let [first, last] = ALLOCATED.get(); + assert_ne!(first, 0); + assert_ne!(last, 0); + if status == 0 { + assert_eq!( + result.outputs[0].resource().unwrap().cleanup(), + Cleanup::LocalFree + ); + assert_eq!( + result.outputs[1].resource().unwrap().cleanup(), + Cleanup::CoTaskMemFree + ); + assert!(cleanups().is_empty()); + } else { + assert!(matches!( + result.outputs.as_slice(), + [Value::Handle(0), Value::Handle(0)] + )); + } + drop(result); + assert_eq!( + cleanups(), + vec![ + CleanupCall { + kind: Cleanup::LocalFree, + value: first, + succeeded: true + }, + CleanupCall { + kind: Cleanup::CoTaskMemFree, + value: last, + succeeded: true + }, + ] + ); + } +} + +fn allocated_resource(kind: Cleanup) -> Arc { + use windows::Win32::Security::Credentials::{ + CredMarshalCredentialW, USERNAME_TARGET_CREDENTIAL_INFO, UsernameTargetCredential, + }; + use windows::Win32::System::Memory::{GMEM_FIXED, GlobalAlloc, LMEM_FIXED, LocalAlloc}; + use windows::Win32::System::Services::{OpenSCManagerW, SC_MANAGER_CONNECT}; + use windows::Win32::System::Threading::CreateEventW; + use windows::core::{PWSTR, w}; + let raw = match kind { + Cleanup::CloseHandle => { + unsafe { CreateEventW(None, true, false, None) }.unwrap().0 as usize + } + Cleanup::RegCloseKey => { + use windows::Win32::System::Registry::{HKEY_LOCAL_MACHINE, KEY_READ, RegOpenKeyExW}; + let mut key = HKEY::default(); + unsafe { RegOpenKeyExW(HKEY_LOCAL_MACHINE, w!("SOFTWARE"), None, KEY_READ, &mut key) } + .ok() + .unwrap(); + key.0 as usize + } + Cleanup::LocalFree => unsafe { LocalAlloc(LMEM_FIXED, 16) }.unwrap().0 as usize, + Cleanup::GlobalFree => unsafe { GlobalAlloc(GMEM_FIXED, 16) }.unwrap().0 as usize, + Cleanup::FreeLibrary => { + unsafe { + windows::Win32::System::LibraryLoader::LoadLibraryExW( + w!("version.dll"), + None, + windows::Win32::System::LibraryLoader::LOAD_LIBRARY_SEARCH_SYSTEM32, + ) + } + .unwrap() + .0 as usize + } + Cleanup::CloseServiceHandle => { + unsafe { OpenSCManagerW(None, None, SC_MANAGER_CONNECT) } + .unwrap() + .0 as usize + } + Cleanup::CoTaskMemFree => { + (unsafe { windows::Win32::System::Com::CoTaskMemAlloc(16) }) as usize + } + Cleanup::CredFree => { + let mut name: Vec = "dynwinrt-unit-test".encode_utf16().chain(Some(0)).collect(); + let info = USERNAME_TARGET_CREDENTIAL_INFO { + UserName: PWSTR(name.as_mut_ptr()), + }; + let mut text = PWSTR::null(); + unsafe { + CredMarshalCredentialW( + UsernameTargetCredential, + std::ptr::from_ref(&info).cast(), + &mut text, + ) + } + .unwrap(); + text.0 as usize + } + Cleanup::None => panic!("test resource must have a real cleanup"), + }; + assert_ne!(raw, 0); + unsafe { OwnedResource::adopt(raw, kind) }.unwrap() +} + +#[test] +fn every_cleanup_kind_uses_its_real_allocator_once_on_close_and_drop() { + for kind in [ + Cleanup::CloseHandle, + Cleanup::RegCloseKey, + Cleanup::LocalFree, + Cleanup::GlobalFree, + Cleanup::FreeLibrary, + Cleanup::CloseServiceHandle, + Cleanup::CoTaskMemFree, + Cleanup::CredFree, + ] { + for explicit in [false, true] { + let resource = allocated_resource(kind); + let raw = resource.raw(); + let alias = Arc::clone(&resource); + reset(); + drop(resource); + assert!(cleanups().is_empty()); + if explicit { + alias.close().unwrap(); + assert!(alias.is_closed()); + alias.close().unwrap(); + } + drop(alias); + assert_eq!( + cleanups(), + vec![CleanupCall { + kind, + value: raw, + succeeded: true + }] + ); + } + reset(); + unsafe { cleanup_owned_resource(0, kind) }.unwrap(); + assert!(cleanups().is_empty()); + } + let mut value = 123u32; + unsafe { cleanup_owned_resource((&mut value as *mut u32) as usize, Cleanup::None) }.unwrap(); + assert_eq!(value, 123); + assert!(cleanups().is_empty()); +} + +struct CloseProtection(Arc); + +impl Drop for CloseProtection { + fn drop(&mut self) { + use windows::Win32::Foundation::{ + HANDLE_FLAG_PROTECT_FROM_CLOSE, HANDLE_FLAGS, SetHandleInformation, + }; + let raw = self.0.raw(); + if raw != 0 { + let _ = unsafe { + SetHandleInformation( + HANDLE(raw as *mut c_void), + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + HANDLE_FLAGS(0), + ) + }; + } + } +} + +#[test] +fn protected_handle_close_failure_can_be_retried_without_losing_ownership() { + use windows::Win32::Foundation::{ + HANDLE_FLAG_PROTECT_FROM_CLOSE, HANDLE_FLAGS, SetHandleInformation, + }; + let resource = allocated_resource(Cleanup::CloseHandle); + let protection = CloseProtection(Arc::clone(&resource)); + let raw = resource.raw(); + unsafe { + SetHandleInformation( + HANDLE(raw as *mut c_void), + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + HANDLE_FLAG_PROTECT_FROM_CLOSE, + ) + } + .unwrap(); + reset(); + assert!(resource.close().is_err()); + assert_eq!(resource.raw(), raw); + assert!(!resource.is_closed()); + unsafe { + SetHandleInformation( + HANDLE(raw as *mut c_void), + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + HANDLE_FLAGS(0), + ) + } + .unwrap(); + resource.close().unwrap(); + resource.close().unwrap(); + drop(protection); + drop(resource); + assert_eq!( + cleanups(), + vec![ + CleanupCall { + kind: Cleanup::CloseHandle, + value: raw, + succeeded: false + }, + CleanupCall { + kind: Cleanup::CloseHandle, + value: raw, + succeeded: true + }, + ] + ); +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn duplicate_aliases_reject_before_dispatch_and_distinct_handles_lock_in_one_order() { + extern "system" fn compare(first: *mut c_void, second: *mut c_void) -> i32 { + DISPATCHES.set(DISPATCHES.get() + 1); + i32::from(first != second) + } + let a = allocated_resource(Cleanup::CloseHandle); + let b = allocated_resource(Cleanup::CloseHandle); + let mut parameter = Parameter::input(Type::Handle, false); + parameter.resource_cleanup = Cleanup::CloseHandle; + let plan = super::tests::fake_plan( + compare as *const () as usize, + vec![parameter; 2], + Some(Type::Bool32), + vec![None; 2], + None, + ); + reset(); + assert!( + unsafe { + plan.invoke(&[ + Value::Resource(Arc::clone(&a)), + Value::Resource(Arc::clone(&a)), + ]) + } + .unwrap_err() + .message() + .contains("multiple parameters") + ); + assert_eq!(DISPATCHES.get(), 0); + assert!(OBSERVED.with(|observed| observed.borrow().locks.is_empty())); + let mut expected = vec![Arc::as_ptr(&a) as usize, Arc::as_ptr(&b) as usize]; + expected.sort_unstable(); + for (first, second) in [(&a, &b), (&b, &a)] { + OBSERVED.with(|observed| observed.borrow_mut().locks.clear()); + let result = unsafe { + plan.invoke(&[ + Value::Resource(Arc::clone(first)), + Value::Resource(Arc::clone(second)), + ]) + } + .unwrap(); + assert!(matches!(result.return_value, Some(Value::Bool(true)))); + assert_eq!( + OBSERVED.with(|observed| observed.borrow().locks.clone()), + expected + ); + } + assert_eq!(DISPATCHES.get(), 2); + a.close().unwrap(); + b.close().unwrap(); +} + +#[test] +fn async_leases_keep_resources_open_and_active_counts_balance_once() { + let resource = allocated_resource(Cleanup::CloseHandle); + let weak = Arc::downgrade(&resource); + reset(); + assert!(resource.async_lease(Cleanup::GlobalFree).is_err()); + assert!(!resource.has_async_leases()); + let mut first = resource.async_lease(Cleanup::CloseHandle).unwrap(); + let mut second = resource.async_lease(Cleanup::CloseHandle).unwrap(); + first.mark_active(); + first.mark_active(); + second.mark_active(); + assert_eq!(resource.active_async_io_count(), 2); + assert_eq!(resource.async_lease_count(), 2); + assert!(resource.close().is_err()); + first.mark_inactive(); + first.mark_inactive(); + assert_eq!(resource.active_async_io_count(), 1); + drop(first); + assert_eq!(resource.async_lease_count(), 1); + let raw = resource.raw(); + drop(resource); + assert!(weak.upgrade().is_some()); + assert!(cleanups().is_empty()); + second.mark_inactive(); + drop(second); + assert!(weak.upgrade().is_none()); + assert_eq!( + cleanups(), + vec![CleanupCall { + kind: Cleanup::CloseHandle, + value: raw, + succeeded: true + },] + ); +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn consumption_requires_ownership_and_native_success_and_rejects_reuse() { + use windows::Win32::Foundation::{ + HANDLE_FLAG_PROTECT_FROM_CLOSE, HANDLE_FLAGS, SetHandleInformation, + }; + extern "system" fn close(handle: *mut c_void) -> i32 { + DISPATCHES.set(DISPATCHES.get() + 1); + i32::from(unsafe { CloseHandle(HANDLE(handle)) }.is_ok()) + } + let resource = allocated_resource(Cleanup::CloseHandle); + let protection = CloseProtection(Arc::clone(&resource)); + let raw = resource.raw(); + let parameter = Parameter { + consumes_resource: true, + resource_cleanup: Cleanup::CloseHandle, + ..Parameter::input(Type::Handle, false) + }; + let plan = policy( + super::tests::fake_plan( + close as *const () as usize, + vec![parameter], + Some(Type::Bool32), + vec![None], + None, + ), + SuccessRule::ReturnNonZero, + Cleanup::None, + ); + reset(); + assert!( + unsafe { plan.invoke(&[Value::Handle(raw)]) } + .unwrap_err() + .message() + .contains("managed resource") + ); + assert_eq!(DISPATCHES.get(), 0); + unsafe { + SetHandleInformation( + HANDLE(raw as *mut c_void), + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + HANDLE_FLAG_PROTECT_FROM_CLOSE, + ) + } + .unwrap(); + let failed = unsafe { plan.invoke(&[Value::Resource(Arc::clone(&resource))]) }.unwrap(); + assert!(!failed.succeeded); + assert!(matches!(failed.return_value, Some(Value::Bool(false)))); + assert_eq!(resource.raw(), raw); + unsafe { + SetHandleInformation( + HANDLE(raw as *mut c_void), + HANDLE_FLAG_PROTECT_FROM_CLOSE.0, + HANDLE_FLAGS(0), + ) + } + .unwrap(); + let closed = unsafe { plan.invoke(&[Value::Resource(Arc::clone(&resource))]) }.unwrap(); + assert!(closed.succeeded); + assert!(resource.is_closed()); + assert!( + unsafe { plan.invoke(&[Value::Resource(Arc::clone(&resource))]) } + .unwrap_err() + .message() + .contains("closed") + ); + assert_eq!(DISPATCHES.get(), 2); + resource.close().unwrap(); + drop(protection); + drop(resource); + assert!(cleanups().is_empty()); +} + +#[test] +fn required_pointer_categories_reject_null_bits_without_rejecting_handle_sentinels() { + for (typ, null) in [ + (Type::Pointer, Value::Pointer(std::ptr::null_mut())), + (Type::FunctionPointer, Value::FunctionPointer(0)), + ] { + assert!( + value_to_abi(typ, &null, false, Cleanup::None, None).is_err(), + "{typ:?}" + ); + assert!(value_to_abi(typ, &Value::Null, false, Cleanup::None, None).is_err()); + assert!(matches!( + value_to_abi(typ, &null, true, Cleanup::None, None).unwrap(), + AbiValue::Pointer(pointer) if pointer.is_null() + )); + assert!(value_to_abi(typ, &Value::Null, true, Cleanup::None, None).is_ok()); + } + assert!(value_to_abi(Type::Handle, &Value::Handle(0), false, Cleanup::None, None).is_ok()); + assert!( + value_to_abi( + Type::Handle, + &Value::Handle(usize::MAX), + false, + Cleanup::None, + None + ) + .is_ok() + ); +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn invalid_plan_contracts_fail_before_module_loading_or_native_dispatch() { + let base = || CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "GetLastError".into(), + parameters: Vec::new(), + return_type: Some(Type::U32), + return_cleanup: Cleanup::None, + success_rule: SuccessRule::Always, + capture_last_error: false, + calling_convention: CallingConvention::System, + parameter_aggregates: Vec::new(), + return_aggregate: None, + }; + let mutations: &[fn(&mut CallPlanSpec)] = &[ + |spec| spec.dll = r"..\kernel32.dll".into(), + |spec| spec.entry_point = "GetLastError\0other".into(), + |spec| spec.parameter_aggregates.push(None), + |spec| { + spec.parameters = vec![Parameter::input(Type::U32, false); 1025]; + spec.parameter_aggregates = vec![None; 1025]; + }, + |spec| spec.return_cleanup = Cleanup::CoTaskMemFree, + |spec| { + spec.return_type = None; + spec.success_rule = SuccessRule::ReturnZero; + }, + |spec| spec.success_rule = SuccessRule::HResultSucceeded, + |spec| spec.success_rule = SuccessRule::ReturnValidHandle, + |spec| { + spec.return_type = Some(Type::F64); + spec.success_rule = SuccessRule::ReturnNonZero; + }, + |spec| { + spec.parameters.push(Parameter::input(Type::I32, true)); + spec.parameter_aggregates.push(None); + }, + |spec| { + let mut parameter = Parameter::input(Type::Pointer, false); + parameter.cleanup = Cleanup::CoTaskMemFree; + spec.parameters.push(parameter); + spec.parameter_aggregates.push(None); + }, + |spec| { + let mut parameter = Parameter::input(Type::Handle, false); + parameter.consumes_resource = true; + spec.parameters.push(parameter); + spec.parameter_aggregates.push(None); + }, + |spec| { + let mut parameter = Parameter::output(Type::Handle, Cleanup::None); + parameter.resource_cleanup = Cleanup::CloseHandle; + spec.parameters.push(parameter); + spec.parameter_aggregates.push(None); + }, + ]; + for (index, mutate) in mutations.iter().enumerate() { + let mut spec = base(); + mutate(&mut spec); + assert!( + validate_spec(&spec).is_err(), + "invalid contract case {index}" + ); + } +} + +#[test] +fn bounded_native_layout_rejects_invalid_identity_extent_and_alignment() { + for (identity, size, alignment) in [ + ("", 8, 8), + (" ", 8, 8), + ("Tests.Empty", 0, 8), + ("Tests.Unaligned", 8, 0), + ("Tests.NonPower", 12, 3), + ("Tests.BadExtent", 12, 8), + ("Tests.OverAligned", 16, 16), + ] { + assert!( + NativeAggregateLayout::new( + identity, + size, + alignment, + FfiType::structure([FfiType::u64()]), + ) + .is_err() + ); + } +} + +#[test] +fn simultaneous_close_and_lease_have_one_complete_ownership_outcome() { + use std::sync::{Barrier, mpsc}; + use std::time::Duration; + let resource = allocated_resource(Cleanup::CloseHandle); + let start = Arc::new(Barrier::new(3)); + let (close_tx, close_rx) = mpsc::channel(); + let (lease_tx, lease_rx) = mpsc::channel(); + let (release_tx, release_rx) = mpsc::channel(); + let closer = Arc::clone(&resource); + let close_start = Arc::clone(&start); + let close_thread = std::thread::spawn(move || { + close_start.wait(); + close_tx.send(closer.close().is_ok()).unwrap(); + }); + let borrower = Arc::clone(&resource); + let lease_start = Arc::clone(&start); + let lease_thread = std::thread::spawn(move || { + lease_start.wait(); + let lease = borrower.async_lease(Cleanup::CloseHandle); + lease_tx.send(lease.is_ok()).unwrap(); + let _ = release_rx.recv(); + drop(lease); + }); + start.wait(); + let leased = lease_rx.recv_timeout(Duration::from_secs(5)); + let closed = close_rx.recv_timeout(Duration::from_secs(5)); + let still_owned = if leased.is_ok() && closed.is_ok() { + Some(!resource.is_closed()) + } else { + None + }; + let _ = release_tx.send(()); + close_thread.join().unwrap(); + lease_thread.join().unwrap(); + let (leased, closed) = (leased.unwrap(), closed.unwrap()); + assert_ne!(leased, closed); + assert_eq!(still_owned, Some(leased)); + assert!(!resource.has_async_leases()); + resource.close().unwrap(); + assert!(resource.is_closed()); +} + +#[test] +#[cfg(target_pointer_width = "64")] +fn direct_owned_returns_adopt_only_valid_success_and_borrowed_returns_never_cleanup() { + extern "system" fn create(which: u32) -> *mut c_void { + match which { + 0 => std::ptr::null_mut(), + 1 => usize::MAX as *mut c_void, + _ => match unsafe { + windows::Win32::System::Threading::CreateEventW(None, true, false, None) + } { + Ok(handle) => handle.0, + Err(_) => std::ptr::null_mut(), + }, + } + } + let plan = policy( + super::tests::fake_plan( + create as *const () as usize, + vec![Parameter::input(Type::U32, false)], + Some(Type::Handle), + vec![None], + None, + ), + SuccessRule::ReturnValidHandle, + Cleanup::CloseHandle, + ); + reset(); + for sentinel in [0, 1] { + let failed = unsafe { plan.invoke(&[Value::U32(sentinel)]) }.unwrap(); + assert!(!failed.succeeded); + assert!(matches!(failed.return_value, Some(Value::Handle(0)))); + drop(failed); + assert!(cleanups().is_empty()); + } + let result = unsafe { plan.invoke(&[Value::U32(2)]) }.unwrap(); + assert!(result.succeeded); + let raw = result + .return_value + .as_ref() + .unwrap() + .resource() + .unwrap() + .raw(); + assert_ne!(raw, 0); + drop(result); + assert_eq!( + cleanups(), + vec![CleanupCall { + kind: Cleanup::CloseHandle, + value: raw, + succeeded: true + },] + ); + + extern "system" fn borrow(handle: *mut c_void) -> *mut c_void { + handle + } + let owner = allocated_resource(Cleanup::CloseHandle); + let raw = owner.raw(); + let borrowed = super::tests::fake_plan( + borrow as *const () as usize, + vec![Parameter::input(Type::Handle, false)], + Some(Type::Handle), + vec![None], + None, + ); + reset(); + let result = unsafe { borrowed.invoke(&[Value::Handle(raw)]) }.unwrap(); + assert!(matches!(result.return_value, Some(Value::Handle(value)) if value == raw)); + drop(result); + assert!(cleanups().is_empty()); + assert_eq!(owner.raw(), raw); + owner.close().unwrap(); + assert_eq!( + cleanups(), + vec![CleanupCall { + kind: Cleanup::CloseHandle, + value: raw, + succeeded: true + },] + ); +} diff --git a/crates/dynwinrt/src/win32_resource.rs b/crates/dynwinrt/src/win32_resource.rs new file mode 100644 index 00000000..5b002416 --- /dev/null +++ b/crates/dynwinrt/src/win32_resource.rs @@ -0,0 +1,457 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Win32 owner identity and access coordination, independent of projections. + +use core::ffi::c_void; +use std::ops::{Deref, DerefMut}; +use std::sync::atomic::{AtomicUsize, Ordering}; +use std::sync::{Arc, Mutex, MutexGuard, OnceLock}; + +use windows::Win32::Foundation::HANDLE; +use windows_core::HRESULT; + +use super::{Cleanup, invalid_argument}; +use crate::result::{Error, Result}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ResourceAccess { + Borrow, + Consume, + MutateState(&'static str), +} + +#[derive(Debug)] +struct ResourceControl { + value: Mutex, + retained: AtomicUsize, + active: AtomicUsize, +} + +impl ResourceControl { + fn lock(&self, access: ResourceAccess) -> Result> { + let value = self.value.lock().unwrap_or_else(|error| error.into_inner()); + if self.retained.load(Ordering::Acquire) != 0 { + match access { + ResourceAccess::Borrow => {} + ResourceAccess::Consume => { + return Err(invalid_argument( + "cannot consume a Win32 resource while asynchronous I/O is pending", + )); + } + ResourceAccess::MutateState(state) => { + return Err(invalid_argument(&format!( + "cannot change {state} while asynchronous I/O is pending" + ))); + } + } + } + Ok(value) + } +} + +#[derive(Debug, Default)] +struct ResourceCapabilities { + file: OnceLock, +} + +/// State acquired only by operations with a validated file contract. Its +/// identity is the resource owner, never the numeric HANDLE. +#[derive(Debug, Default)] +pub struct FileCapability { + state: Mutex, +} + +#[derive(Debug, Default)] +struct FileState { + completion_modes: Option, + completion_port: Option, +} + +impl FileCapability { + pub fn cached_completion_modes(&self) -> Option { + self.state + .lock() + .unwrap_or_else(|error| error.into_inner()) + .completion_modes + } + + /// Records a verified, successful monotonic mode update. Without a native + /// query, the other mode bits remain unknown. + pub fn record_completion_modes(&self, flags: u32) { + if let Some(modes) = self + .state + .lock() + .unwrap_or_else(|error| error.into_inner()) + .completion_modes + .as_mut() + { + *modes |= flags; + } + } + + fn query_completion_modes(&self, handle: usize) -> Result { + use windows::Wdk::Storage::FileSystem::{ + FileIoCompletionNotificationInformation, NtQueryInformationFile, + }; + use windows::Wdk::System::SystemServices::FILE_IO_COMPLETION_NOTIFICATION_INFORMATION; + use windows::Win32::System::IO::IO_STATUS_BLOCK; + + let mut state = self.state.lock().unwrap_or_else(|error| error.into_inner()); + let mut status_block = IO_STATUS_BLOCK::default(); + let mut information = FILE_IO_COMPLETION_NOTIFICATION_INFORMATION::default(); + let status = unsafe { + NtQueryInformationFile( + HANDLE(handle as *mut c_void), + &mut status_block, + (&mut information as *mut FILE_IO_COMPLETION_NOTIFICATION_INFORMATION).cast(), + size_of::() as u32, + FileIoCompletionNotificationInformation, + ) + }; + if status.0 != 0 { + return Err(Error::WindowsError(windows_core::Error::new( + HRESULT(status.0 | 0x1000_0000), + format!( + "Cannot query file completion notification modes: NTSTATUS 0x{:08x}", + status.0 as u32 + ), + ))); + } + state.completion_modes = Some(information.Flags); + Ok(information.Flags) + } + + pub(super) fn associate(&self, handle: usize, port: usize) -> Result<()> { + use windows::Win32::System::IO::CreateIoCompletionPort; + + let mut state = self.state.lock().unwrap_or_else(|error| error.into_inner()); + if let Some(existing) = state.completion_port { + return if existing == port { + Ok(()) + } else { + Err(invalid_argument( + "Win32 resource was associated with a different IOCP", + )) + }; + } + let port = HANDLE(port as *mut c_void); + let associated = + unsafe { CreateIoCompletionPort(HANDLE(handle as *mut c_void), Some(port), 0, 0) } + .map_err(|error| { + invalid_argument(&format!( + "Failed to associate Win32 resource with dynwinrt IOCP: {error}" + )) + })?; + if associated != port { + return Err(invalid_argument( + "Win32 resource was associated with an unexpected IOCP", + )); + } + state.completion_port = Some(port.0 as usize); + Ok(()) + } + + #[cfg(test)] + pub(super) fn set_known_completion_modes(&self, flags: u32) { + self.state.lock().unwrap().completion_modes = Some(flags); + } +} + +#[derive(Debug)] +pub struct OwnedResource { + control: ResourceControl, + cleanup: Cleanup, + capabilities: ResourceCapabilities, +} + +#[derive(Debug)] +pub(super) struct OwnedResourceCallGuard<'a> { + owner: &'a OwnedResource, + value: MutexGuard<'a, usize>, +} + +impl Deref for OwnedResourceCallGuard<'_> { + type Target = usize; + + fn deref(&self) -> &Self::Target { + &self.value + } +} + +impl DerefMut for OwnedResourceCallGuard<'_> { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.value + } +} + +impl OwnedResourceCallGuard<'_> { + pub(super) fn close(&mut self) -> windows_core::Result<()> { + self.owner.close_locked(&mut self.value) + } +} + +pub struct OwnedResourceLease<'a> { + value: MutexGuard<'a, usize>, +} + +pub struct OwnedResourceAsyncLease { + resource: Arc, + value: usize, + active: bool, +} + +impl OwnedResourceAsyncLease { + pub fn raw(&self) -> usize { + self.value + } + + pub fn completion_modes(&self) -> Result { + self.resource + .file_capability() + .query_completion_modes(self.value) + } + + pub(super) fn associate_completion_port(&self, port: usize) -> Result<()> { + self.resource.file_capability().associate(self.value, port) + } + + pub fn mark_active(&mut self) { + if !self.active { + self.resource.control.active.fetch_add(1, Ordering::AcqRel); + self.active = true; + } + } + + pub fn mark_inactive(&mut self) { + if self.active { + self.resource.control.active.fetch_sub(1, Ordering::AcqRel); + self.active = false; + } + } +} + +impl Drop for OwnedResourceAsyncLease { + fn drop(&mut self) { + self.mark_inactive(); + self.resource + .control + .retained + .fetch_sub(1, Ordering::AcqRel); + } +} + +impl OwnedResourceLease<'_> { + pub fn raw(&self) -> usize { + *self.value + } +} + +impl OwnedResource { + pub(super) fn new(value: usize, cleanup: Cleanup) -> Self { + debug_assert!(value != 0); + debug_assert!(cleanup.owns_resource()); + Self { + control: ResourceControl { + value: Mutex::new(value), + retained: AtomicUsize::new(0), + active: AtomicUsize::new(0), + }, + cleanup, + capabilities: ResourceCapabilities::default(), + } + } + + /// Adopts a native resource whose exact ownership and cleanup were + /// validated by the flat Win32 semantic projection. + pub unsafe fn adopt(value: usize, cleanup: Cleanup) -> Result> { + if value == 0 || !cleanup.owns_resource() { + return Err(invalid_argument( + "owned Win32 resource requires a nonzero value and cleanup", + )); + } + Ok(Arc::new(Self::new(value, cleanup))) + } + + pub fn raw(&self) -> usize { + *self + .control + .value + .lock() + .unwrap_or_else(|error| error.into_inner()) + } + + pub fn is_closed(&self) -> bool { + self.raw() == 0 + } + + pub fn cleanup(&self) -> Cleanup { + self.cleanup + } + + pub fn file_capability(&self) -> &FileCapability { + self.capabilities.file.get_or_init(FileCapability::default) + } + + pub fn has_async_leases(&self) -> bool { + self.control.retained.load(Ordering::Acquire) != 0 + } + + pub fn has_active_async_io(&self) -> bool { + self.control.active.load(Ordering::Acquire) != 0 + } + + pub fn lease(&self, expected_cleanup: Cleanup) -> Result> { + if self.cleanup != expected_cleanup { + return Err(invalid_argument( + "managed Win32 resource cleanup kind does not match", + )); + } + let value = self.control.lock(ResourceAccess::Borrow)?; + if *value == 0 { + return Err(invalid_argument("cannot lease a closed Win32 resource")); + } + Ok(OwnedResourceLease { value }) + } + + pub(super) fn lock_for_call( + &self, + access: ResourceAccess, + ) -> Result> { + Ok(OwnedResourceCallGuard { + owner: self, + value: self.control.lock(access)?, + }) + } + + pub fn async_lease( + self: &Arc, + expected_cleanup: Cleanup, + ) -> Result { + if self.cleanup != expected_cleanup { + return Err(invalid_argument( + "managed Win32 resource cleanup kind does not match", + )); + } + let value = self.control.lock(ResourceAccess::Borrow)?; + if *value == 0 { + return Err(invalid_argument("cannot lease a closed Win32 resource")); + } + self.control.retained.fetch_add(1, Ordering::AcqRel); + Ok(OwnedResourceAsyncLease { + resource: Arc::clone(self), + value: *value, + active: false, + }) + } + + pub fn close(&self) -> windows_core::Result<()> { + let mut value = self + .control + .value + .lock() + .unwrap_or_else(|error| error.into_inner()); + self.close_locked(&mut value) + } + + fn close_locked(&self, value: &mut usize) -> windows_core::Result<()> { + if self.has_async_leases() { + return Err(windows_core::Error::new( + HRESULT(0x800700AAu32 as i32), + "cannot close a Win32 resource while asynchronous I/O is pending", + )); + } + unsafe { self.cleanup.run(*value) }?; + *value = 0; + Ok(()) + } + + #[cfg(test)] + pub(super) fn async_lease_count(&self) -> usize { + self.control.retained.load(Ordering::Acquire) + } + + #[cfg(test)] + pub(super) fn active_async_io_count(&self) -> usize { + self.control.active.load(Ordering::Acquire) + } +} + +impl Drop for OwnedResource { + fn drop(&mut self) { + let value = *self + .control + .value + .get_mut() + .unwrap_or_else(|error| error.into_inner()); + if let Err(error) = unsafe { self.cleanup.run(value) } { + eprintln!( + "[dynwinrt] Win32 resource cleanup failed ({:?}): {error}", + self.cleanup + ); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + fn event() -> Arc { + let handle = + unsafe { windows::Win32::System::Threading::CreateEventW(None, true, false, None) } + .unwrap(); + unsafe { OwnedResource::adopt(handle.0 as usize, Cleanup::CloseHandle) }.unwrap() + } + + #[test] + fn generic_access_excludes_consumption_and_mutation_until_all_retained_leases_drop() { + let owner = event(); + let alias = Arc::clone(&owner); + let mut first = owner.async_lease(Cleanup::CloseHandle).unwrap(); + let second = alias.async_lease(Cleanup::CloseHandle).unwrap(); + first.mark_active(); + first.mark_inactive(); + assert!(!owner.has_active_async_io()); + assert!(owner.has_async_leases()); + for access in [ + ResourceAccess::Consume, + ResourceAccess::MutateState("native state"), + ] { + assert!(alias.lock_for_call(access).is_err()); + } + let borrow = alias.lock_for_call(ResourceAccess::Borrow).unwrap(); + assert_eq!(*borrow, first.raw()); + drop(borrow); + assert!(owner.close().is_err()); + drop(first); + assert!(alias.lock_for_call(ResourceAccess::Consume).is_err()); + drop(second); + drop( + alias + .lock_for_call(ResourceAccess::MutateState("native state")) + .unwrap(), + ); + alias.close().unwrap(); + assert!(owner.is_closed()); + } + + #[test] + fn typed_file_state_shares_owner_identity_without_guessing_unknown_mode_bits() { + let owner = event(); + let alias = Arc::clone(&owner); + let other = event(); + let file = owner.file_capability(); + assert!(std::ptr::eq(file, alias.file_capability())); + assert!(!std::ptr::eq(file, other.file_capability())); + file.record_completion_modes(1); + assert_eq!(file.cached_completion_modes(), None); + file.set_known_completion_modes(2); + file.record_completion_modes(1); + file.record_completion_modes(0); + assert_eq!(alias.file_capability().cached_completion_modes(), Some(3)); + assert_eq!(other.file_capability().cached_completion_modes(), None); + owner.close().unwrap(); + other.close().unwrap(); + } +} diff --git a/crates/dynwinrt/src/win32_result_tests.rs b/crates/dynwinrt/src/win32_result_tests.rs new file mode 100644 index 00000000..cda99468 --- /dev/null +++ b/crates/dynwinrt/src/win32_result_tests.rs @@ -0,0 +1,261 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use std::cell::RefCell; + +thread_local! { static ALLOCATED: RefCell> = const { RefCell::new(Vec::new()) }; } + +fn allocate() -> *mut c_void { + let pointer = unsafe { windows::Win32::System::Com::CoTaskMemAlloc(16) }; + assert!(!pointer.is_null()); + ALLOCATED.with(|values| values.borrow_mut().push(pointer as usize)); + pointer +} + +fn reset() { + outcome_tests::reset(); + ALLOCATED.with(|values| values.borrow_mut().clear()); +} + +fn assert_freed_once() { + ALLOCATED.with(|values| { + for pointer in values.borrow().iter().copied() { + assert_eq!( + outcome_tests::cleanup_count_for(pointer), + 1, + "0x{pointer:x}" + ); + } + }); +} + +fn spec( + parameters: Vec, + return_type: Type, + return_cleanup: Cleanup, + success_rule: SuccessRule, +) -> CallPlanSpec { + CallPlanSpec { + dll: "kernel32.dll".into(), + entry_point: "GetLastError".into(), + parameter_aggregates: vec![None; parameters.len()], + parameters, + return_type: Some(return_type), + return_cleanup, + success_rule, + capture_last_error: false, + calling_convention: CallingConvention::System, + return_aggregate: None, + } +} + +fn plan( + function: usize, + spec: CallPlanSpec, + configure: impl FnOnce(&mut CallContract), +) -> Arc { + let mut contract = CallContract::defaults(&contract::shape(&spec)); + configure(&mut contract); + let mut plan = + Arc::try_unwrap(unsafe { CallPlan::new_with_contract(spec, contract) }.unwrap()).unwrap(); + plan.function = function; + Arc::new(plan) +} + +fn owned(delivery: Delivery) -> ResultPolicy { + ResultPolicy::Defined { + ownership: ResultOwnership::Owned { + cleanup: dynwinrt_win32_contracts::Cleanup::CoTaskMemFree, + }, + delivery, + } +} + +#[test] +fn failed_valid_owned_outputs_can_be_delivered_or_discarded_with_exact_cleanup() { + unsafe extern "system" fn partial(output: *mut *mut c_void) -> i32 { + unsafe { *output = allocate() }; + 5 + } + for delivery in [Delivery::Deliver, Delivery::Discard] { + reset(); + let call = plan( + partial as *const () as usize, + spec( + vec![Parameter::output(Type::Handle, Cleanup::CoTaskMemFree)], + Type::I32, + Cleanup::None, + SuccessRule::ReturnZero, + ), + |contract| { + contract + .results + .iter_mut() + .find(|result| result.target == (ResultTarget::Parameter { index: 0 })) + .unwrap() + .on_failure = owned(delivery) + }, + ); + let result = unsafe { call.invoke(&[]) }.unwrap(); + assert!(!result.succeeded); + match delivery { + Delivery::Deliver => { + assert!(matches!(result.outputs[0], Value::Resource(_))); + ALLOCATED.with(|values| { + assert_eq!(outcome_tests::cleanup_count_for(values.borrow()[0]), 0) + }); + } + Delivery::Discard => assert!(matches!(result.outputs[0], Value::Discarded)), + } + drop(result); + assert_freed_once(); + } +} + +#[test] +fn direct_owned_returns_are_cleaned_even_when_not_delivered_on_business_failure() { + extern "system" fn partial() -> *mut c_void { + allocate() + } + reset(); + let call = plan( + partial as *const () as usize, + spec( + vec![], + Type::Handle, + Cleanup::CoTaskMemFree, + SuccessRule::ReturnZero, + ), + |contract| contract.results[0].on_failure = owned(Delivery::Discard), + ); + let result = unsafe { call.invoke(&[]) }.unwrap(); + assert!(!result.succeeded); + assert!(matches!(result.return_value, Some(Value::Discarded))); + drop(result); + assert_freed_once(); +} + +#[test] +fn direct_return_aliases_share_the_input_owner_without_adoption() { + extern "system" fn echo(input: *mut c_void) -> *mut c_void { + input + } + reset(); + let input = + unsafe { OwnedResource::adopt(allocate() as usize, Cleanup::CoTaskMemFree) }.unwrap(); + let call = plan( + echo as *const () as usize, + spec( + vec![Parameter { + resource_cleanup: Cleanup::CoTaskMemFree, + ..Parameter::input(Type::Handle, false) + }], + Type::Handle, + Cleanup::CoTaskMemFree, + SuccessRule::ReturnNonNull, + ), + |contract| { + contract.results[0].on_success = + ResultPolicy::delivered(ResultOwnership::AliasInput { parameter: 0 }) + }, + ); + let result = unsafe { call.invoke(&[Value::Resource(Arc::clone(&input))]) }.unwrap(); + let alias = result.return_value.as_ref().unwrap().resource().unwrap(); + assert!(Arc::ptr_eq(alias, &input)); + drop(result); + assert!(!input.is_closed()); + drop(input); + assert_freed_once(); +} + +#[test] +fn undefined_direct_pointer_is_not_adopted_or_freed() { + extern "system" fn opaque(input: *mut c_void) -> *mut c_void { + input + } + reset(); + let input = + unsafe { OwnedResource::adopt(allocate() as usize, Cleanup::CoTaskMemFree) }.unwrap(); + let call = plan( + opaque as *const () as usize, + spec( + vec![Parameter { + resource_cleanup: Cleanup::CoTaskMemFree, + ..Parameter::input(Type::Handle, false) + }], + Type::Handle, + Cleanup::CoTaskMemFree, + SuccessRule::Always, + ), + |contract| contract.results[0].on_success = ResultPolicy::Undefined {}, + ); + let result = unsafe { call.invoke(&[Value::Resource(Arc::clone(&input))]) }.unwrap(); + assert!(matches!(result.return_value, Some(Value::Unavailable))); + assert!(outcome_tests::decoded_outputs().is_empty()); + assert!(!input.is_closed()); + drop(result); + drop(input); + assert_freed_once(); +} + +#[test] +fn conversion_failure_cleans_all_valid_untransferred_results_once() { + unsafe extern "system" fn produce( + first: *mut *mut c_void, + second: *mut *mut c_void, + ) -> *mut c_void { + unsafe { + *first = allocate(); + *second = allocate(); + } + allocate() + } + for failure in [ + ResultTarget::Return {}, + ResultTarget::Parameter { index: 0 }, + ResultTarget::Parameter { index: 1 }, + ] { + reset(); + let call = plan( + produce as *const () as usize, + spec( + vec![Parameter::output(Type::Handle, Cleanup::CoTaskMemFree); 2], + Type::Handle, + Cleanup::CoTaskMemFree, + SuccessRule::Always, + ), + |_| {}, + ); + outcome_tests::fail_decode(failure); + assert!( + unsafe { call.invoke(&[]) } + .unwrap_err() + .message() + .contains("conversion failure") + ); + assert_freed_once(); + } +} + +#[test] +fn discarded_results_and_failed_delivery_do_not_skip_cleanup_or_double_release() { + unsafe extern "system" fn produce(output: *mut *mut c_void) -> *mut c_void { + unsafe { *output = allocate() }; + allocate() + } + reset(); + let call = plan( + produce as *const () as usize, + spec( + vec![Parameter::output(Type::Handle, Cleanup::CoTaskMemFree)], + Type::Handle, + Cleanup::CoTaskMemFree, + SuccessRule::Always, + ), + |contract| contract.results[0].on_success = owned(Delivery::Discard), + ); + outcome_tests::fail_decode(ResultTarget::Parameter { index: 0 }); + assert!(unsafe { call.invoke(&[]) }.is_err()); + assert_freed_once(); +} diff --git a/docs/architecture/classic-com-support.md b/docs/architecture/classic-com-support.md index b86465b9..5972fadb 100644 --- a/docs/architecture/classic-com-support.md +++ b/docs/architecture/classic-com-support.md @@ -765,9 +765,12 @@ Remaining apartment work includes: Examples include `CoGetMalloc`, `CreateBindCtx`, `D2D1CreateFactory`, `DWriteCreateFactory`, `D3D11CreateDevice`, and shell helper functions. -The current Classic COM layer can invoke an acquired interface, but a separate -flat-Win32 layer is needed for the 17,760 DLL exports, their calling -conventions, `GetLastError`, callbacks, and handle cleanup. +The Classic COM layer invokes acquired interfaces; DLL exports use the separate +[contract-driven flat Win32 layer](flat-win32-contracts.md) and +`@microsoft/dynwinrt/win32` entrypoint. Its supported calling conventions, +status/LastError behavior, buffers, and resource cleanup are validated +independently. This does not imply support for every interface-acquisition +function or native callback shape. ### Recommended implementation order @@ -779,12 +782,12 @@ conventions, `GetLastError`, callbacks, and handle cleanup. 6. Broaden generated COM sink/interface implementation beyond the initial same-thread interface-input subset. 7. Apartment-aware marshaling. -8. Separate flat-Win32 acquisition/invocation layer. +8. Keep DLL-export acquisition/invocation separate from COM vtable semantics. -## What the current PR handles +## Current Classic COM implementation -The PR establishes a safe Classic COM subset and rejects the rest. It should -not be described as solving every problem in the map above. +The Classic COM implementation provides a validated subset and rejects +unsupported contracts. It does not solve every problem in the map above. ### Implemented @@ -998,8 +1001,10 @@ and `@microsoft/dynwinrt/com`. FORMATETC/STGMEDIUM callback methods; - callback methods containing unmodeled ownership, Automation, union, array, or interface-replacement contracts; -- cross-thread/apartment marshaling; and -- the general flat-Win32 DLL-export and handle-cleanup layer. +- cross-thread/apartment marshaling. + +Flat Win32 DLL exports and handle cleanup are outside this COM model; they use +the separate [Win32 contract layer](flat-win32-contracts.md). ## Supported ABI surface @@ -1121,7 +1126,7 @@ of every type in the 24 MB metadata file. | Callback methods outside the validated implementation subset | Automation providers, custom marshaling, and resource-owning callbacks | The dynamic backend supports broad scalar/string/POD/buffer ABI shapes and multi-interface inheritance, but VARIANT/SAFEARRAY/PROPVARIANT callbacks, untagged unions, unknown pointers/allocators, interface replacement, and custom marshal contracts still fail the whole interface closed. | Runtime/codegen validation boundary | | COM aggregation | `IClassFactory::CreateInstance` with `pUnkOuter` | The public activation helper always creates a non-aggregated in-process object. | Runtime/public-API boundary | | General out-of-process activation controls | Custom `CLSCTX` scenarios | The unsafe runtime's `DynCom.coCreateInstance()` currently uses `CLSCTX_INPROC_SERVER`. | Runtime/public-API boundary | -| Flat Win32 DLL exports | `CreateFile`, registry functions, GDI, etc. | These are not COM interfaces and need a separate DLL-export/handle model. | Architecture boundary | +| Flat Win32 DLL exports | `CreateFile`, registry functions, GDI, etc. | These are not COM interfaces; supported exports use the separate [Win32 DLL-export/handle model](flat-win32-contracts.md). | Architecture boundary | Consequently, `IDataObject` now generates completely for the closed HGLOBAL subset. Unsupported target-device and storage-medium inputs cannot be diff --git a/docs/architecture/flat-win32-contracts.md b/docs/architecture/flat-win32-contracts.md new file mode 100644 index 00000000..05edad09 --- /dev/null +++ b/docs/architecture/flat-win32-contracts.md @@ -0,0 +1,345 @@ +# Contract-driven flat Win32 + +Flat Win32 bindings dynamically invoke DLL exports described by Windows +metadata. They use a Win32-local ABI model and explicit semantic contracts, +separate from WinRT activation and Classic COM vtables. + +## Metadata and supported capabilities + +Built-in contracts are validated against +`Microsoft.Windows.SDK.Win32Metadata 71.0.14-preview` with SHA-256 +`B64EE4818A7ED9F9D135038D58C51BD08369184D4D5ED428F20E9DE55DF8121D`. + +The measured inventory contains 18,321 eligible exports and 8,936 complete +projections: 8,934 synchronous functions and two asynchronous helpers. There +are 182 supported containers and 10,680 public exports including aliases, +enums and helper functions. These are generation counts, not a claim that +every API has been exercised against a live system. + +| Area | Supported behavior | +| --- | --- | +| Native ABI | All admitted scalars, enums, GUID/scalar pointers, native structures/unions, pointer and by-value aggregate shapes; system/cdecl calls and target availability. | +| Return contracts | Direct, void, status/HRESULT and LastError behavior, including expected failure results. | +| Strings and buffers | UTF-16/ANSI storage, double-NUL lists, reserved inputs, counted buffers, capacity/actual-size relationships and caller-owned output semantics. | +| Resources | Exact HKEY, HANDLE, HLOCAL, HGLOBAL, HMODULE, SC_HANDLE, CoTaskMem and credential cleanup; synchronized leases and consuming calls. | +| Native builders | SECURITY_ATTRIBUTES, STARTUPINFOA/W, PROCESS_INFORMATION and POD helpers, including retained pointer fields and owned outputs. | +| COM inputs | Exact-IID, borrowed managed interface inputs without changing the WinRT model. | +| Asynchronous I/O | IOCP-backed ReadFile/WriteFile Promises, cancellation, EOF, retained storage, detachment checks and bounded pending work. | +| Subsystems | Winsock, GDI+, Media Foundation and explicit unsafe MAPI utility context behavior. | +| Tooling | Safe/unsafe entrypoints, declarations, CLI/census, manifests, examples and stock-Windows scenarios. | + +The examples under `samples/js/win32` demonstrate system information, +Registry queries and asynchronous file I/O with the namespace layout. + +## Contract boundary + +```text +Windows.Win32.winmd facts + + independent Win32 JSON semantic evidence + -> validated Win32 model + -> typed language projection + -> generic renderer and immutable native call plans +``` + +`tools/dynwinrt-codegen/contracts/win32/` owns Win32-specific manual evidence. +COM retains its own interface/IID/vtable contracts. Both follow the +[contract evidence principles](classic-com-contract-evidence-registry.md); +their selectors and ABI models are not interchangeable. + +Generate-command routing uses one lazily loaded flat-function index for the +metadata set, rather than rereading and hashing WinMD for every requested COM +interface. Presence-only lookup preserves the existing DllImport-based routing +order and does not compute provenance hashes. Actual flat Win32 parsing still +performs the unchanged metadata-hash and contract-fingerprint validation. + +Metadata-complete shapes use generic projection. Manual facts such as missing +count relationships, ownership, cleanup, special layouts and lifecycle +requirements belong in typed, closed contracts with exact selectors, +fingerprints, metadata provenance and authoritative evidence. Contracts must +not contain JavaScript, declaration fragments, arbitrary cleanup functions or +unconstrained native adapter names. Unsupported facts remain explicit errors. + +Refactoring must not weaken an existing safety boundary to increase +coverage. If a behavior needs a correctness fix, implement and +document that fix and exercise its nearest failure case rather than silently +dropping the API or relabeling it as supported. + +### Shared protocol and result model + +`crates/dynwinrt-win32-contracts` is the single source of the Win32 wire types, +version handling and structural validation. It depends on neither Windows, +libffi nor a language binding. Metadata validation still proves pointer depth, +encoding, type identity and provenance against the selected WinMD; core still +checks the executing ABI and its supported capabilities. Sharing the protocol +does not merge these responsibilities or the WinRT/COM models. + +Version 3 describes every direct return, native output slot and declared +caller-aggregate result field with a +`ResultContract`: a target, explicit success/failure policies and bounded, +non-overlapping conditional overrides. The schema is derived from these Rust +types rather than separately maintained protocol definitions. Unknown fields, +unsupported versions, contradictory cases and incomplete slot coverage fail +before native dispatch. + +| Resolved result policy | Native behavior | +| --- | --- | +| Undefined | Do not decode the payload, adopt a resource or call a cleanup function on it. | +| Defined value or borrowed result | Deliver the value, or discard it without inventing an independent native owner. | +| Defined owned result | Transfer an owned value when delivered; otherwise run the exact declared cleanup even when the overall operation failed. | +| Defined input alias | Validate the declared input relationship and share its owner; never create a second owner by matching arbitrary handle numbers. | + +Delivery is independent from native validity and ownership. A valid discarded +resource uses `Value::Discarded`, not the undefined-output state. Direct returns +and out parameters have cleanup guards before any fallible conversion, so an +allocation or conversion failure also retires valid, untransferred resources. +Language projection chooses nullability and exception/result shape; it cannot +erase cleanup obligations. + +Descriptors without a version are read as version 1. Their historical null +resource results and cleanup behavior are isolated in an explicit compatibility +adapter and lowered to the common execution plan. Version 2 slot-only contracts +remain readable; aggregate field targets require version 3. New generated code emits +version 3. Metadata ownership evidence alone does not prove a pointer is defined +on failure: new generation leaves that failure result undefined unless reviewed +result evidence establishes validity and the required cleanup/delivery policy. + +An aggregate pointer remains a physical input pointer; it is not converted into +a pointer-to-pointer or an owned aggregate allocation. Its `pointeeDescriptor` +retains the exact native layout and ordered `outputFields`. The caller owns the +structure bytes, while the native buffer's result store independently owns +resources written into fields such as `PROCESS_INFORMATION.hProcess/hThread`. +Field validity, cleanup and native completion state for every described aggregate +are registered immediately after native dispatch, before any per-field conversion +or discard cleanup can fail, before return/out decoding and before N-API wraps +`_call`. Taking a field moves the existing resource owner rather than adopting +its handle a second time. Failed discard cleanup preserves the original field +bytes and cleanup guard for retry by `prepare()` or destruction; merely attempting +cleanup does not release ownership or remove overlapping-write protection. +Generated code does not rely on JS prepare/mark calls for this lifetime boundary. +Legacy manual mark helpers cannot erase already registered native ownership. + +Output-buffer reuse first locks the aggregate storage, then coordinates input +owners and old owned-field results in one identity-ordered resource lock set. +If retiring an old field would close an input owner in the same call, invocation +fails before any old output is retired or the native function is dispatched. +`field_value()` shares the field's owner; use `take_field()` to move that owner +out before reusing its buffer as an output. Input-alias result policies do not +retire their shared input owner. Retirement uses the already acquired owner +guards rather than recursively calling a locking `close()` method. + +Once all output guards and native aggregate states are registered, the call +commits successful input consumption and resource effects while input-resource +locks are still held, before any field/return/out conversion or discard cleanup. +The decision uses native success, not result-delivery success. A native failure +leaves consuming-input ownership and success-only resource effects unchanged, +even when valid failure outputs subsequently fail to decode or clean up. + +Legacy raw-field adoption is explicitly `unsafe` in Rust, including the binding +adapter entrypoint. The caller must prove that successful fields are initialized +and valid, that each non-null owned resource transfers exclusive ownership, and +that its declared cleanup matches the allocator/resource kind. Native writes must +have completed; borrowed handles and duplicated owning fields cannot be adopted. +Safe aggregate construction, reads and writes only manage bytes, not resource +ownership. If field conversion fails with raw cleanup still pending, safe writes +cannot overwrite any part of those cleanup targets until they are retired. +Version 3's native result registration does not use this legacy adoption boundary. + +## Runtime and package boundary + +Win32 stays outside the public WinRT model and the `@microsoft/dynwinrt` root. +Generated Win32 code uses `/win32`, with manual raw ABI capabilities isolated +under `/win32/unsafe`. Existing WinRT and COM entrypoints remain unchanged. +Sharing behavior-neutral private FFI storage/execution remains allowed. + +Native invocation follows completed plans; it does not infer pointer meanings +from JavaScript objects. Handle values, dereferenced storage and owned resources +remain distinct. Resource consumption and lease acquisition are synchronized. +Buffer bounds come from validated native backing storage, not spoofable JS +length properties. Unknown ownership or successful out-of-bounds lengths must +not produce success-shaped fallback values. + +Output relationships and validity are part of the native call contract, not +renderer-specific Registry rules. Bounded input predicates are evaluated before +the call; native return conditions are evaluated immediately after the call. +The resulting output disposition is applied before decoding, ownership adoption +or cleanup. Undefined outputs use `Value::Unavailable`; language projection maps +that outcome to `null`, rather than reading a native value and hiding it afterward. + +`RegOpenKeyA/W` with a null/empty subkey returns an alias of its input. +Managed aliases share the existing owner, close state and leases; borrowed input +handles stay borrowed. `RegOpenKeyExA/W` applies that relationship only to the +documented native predefined-key case. Its predicate compares the full, +pointer-sized signed handle value: on 64-bit Windows, a zero-extended +`0x80000002` can produce a new owned handle, whereas the native predefined value +is sign-extended. These representations must not be merged by masking away +the upper bits. Aliases are authorized by exact contracts and +checked against the specified input, never discovered by globally merging handle +numbers. For `RegQueryValueExA/W` and `RegGetValueA/W`, performance-data queries +remain supported: successful results retain their size, while +`HKEY_PERFORMANCE_DATA` combined with `ERROR_MORE_DATA` exposes `dataSize: null` +without decoding the undefined count. Callers grow a separate capacity and retry. +Normal-key size queries retain their prior behavior. + +Native Win32 carriers use type tags rather than mutable JavaScript prototypes. +Manual aggregate descriptors and MAPI utility initialization are available on +the explicit unsafe subpath; generated validated helpers call those primitives +internally. Win32 runtime types are exposed through the dedicated safe and +unsafe entrypoints. x86 plan invocation remains explicitly unsupported; +x64 is exercised live and ARM64 is compile-validated. + +Win32 optional lifecycle DLLs are loaded on explicit subsystem initialization, +not on addon or generated-wrapper import. Winsock, GDI+, Media Foundation and +MAPI use complete typed startup/shutdown function tables, including rollback +and native error-query entrypoints. Every required export is resolved before +Startup; neither a missing module/export nor a failed Startup publishes a +context. Module and function-table caches retain successful values only, so +later requests can retry failures. Winsock version-negotiation rollback failure +is reported and retried before any new Startup. + +The shared Win32 module loader accepts bare system DLL/DRV names, uses +`LOAD_LIBRARY_SEARCH_SYSTEM32`, and owns each successful load reference. +Concurrent first loads publish one module and release losing references outside +the cache lock. Cached modules and tables live for the process; their lifetime +is separate from subsystem activation. The last context closes the activation, +not the DLL. Explicit Shutdown failure leaves the context active for retry. +Ordinary export plans still bind lazily, and subsystem-exempt contracts do not +gain an initialization requirement. WinRT/COM models and foundational imports +remain unchanged. Normal shared-addon PE import tables must not contain these +optional lifecycle DLLs; test-hook-only COM media fixtures retain their separate +native test dependencies. + +MAPI utility symbols follow the same loading and caching policy. Their x86 +exports carry stdcall suffixes (`ScInitMapiUtil@4`, `DeinitMapiUtil@0`); +binding them as unconditional undecorated imports would prevent unrelated +WinRT/COM consumers from loading the addon. Missing utility exports produce +an explicit error when that subsystem is requested. The system DLL is a +dispatch stub, not a MAPI provider: utility initialization requires an installed, +configured provider matching the process architecture. Without one, the stub +can display a native initialization message before returning `E_FAIL`, as +documented in [MAPI stub registry settings](https://learn.microsoft.com/en-us/previous-versions/windows/desktop/windowsmapi/mapi32-dll-stub-registry-settings). +The unsafe entrypoint preserves that native behavior; it does not install a +provider, change mail-client registration, or substitute a successful no-op. + +The IOCP engine retains native state through terminal completion, including +cancellation. The limits are 1,024 pending operations, 64 MiB per +operation and 256 MiB of pending private buffers. These limits include completed +results waiting to be consumed or discarded, not only active OS requests. +A shared worker set is used, +not one blocked OS/libuv worker per operation. Subsystem call guards prevent +close from racing synchronous dependent calls. File I/O retains its native +resource leases independently and does not require these optional subsystems. +Opaque unsafe subsystem resources remain caller-managed: callers must retain +their context for the required native lifetime. A future managed subsystem-owned +resource or asynchronous operation requires an explicit retained subsystem +lease; DLL caching alone does not provide that activation lifetime. + +The native Win32 I/O module owns the operation registry, stable `OVERLAPPED`, +private buffers, cancellation and terminal completion. It can run from Rust +without loading Node. Native completion records keep their storage, resource +occupancy and quota ownership until consumption or discard; failed notification +or a dropped consumer cannot strand them. + +Native operations hand off owning records through a native queue/channel. They +do not retain an arbitrary callback closure that can capture adapter objects. +The Node adapter independently owns its completion receiver and TSFN +registrations; even indirectly, no native operation owns a TSFN. + +The private Node bridge keeps JS references and original backing information on +the owner thread. That thread revalidates the backing, performs read copy-back +and delivers the callback. No Node Buffer, N-API environment/reference or TSFN +type enters core I/O. Environment teardown cancels native work without freeing +OS-owned storage early, while JS references are released on their owner thread. +COM/WinRT carriers and their backing-storage ownership remain separate from +the native Win32 I/O engine. + +Generic resource coordination governs borrowing, consuming, state mutation and +asynchronous occupancy. File-specific modes and association state belong to a +typed file capability, not a growing collection of API-specific fields on the +generic owner. Neither a string-keyed state bag nor a global handle-value owner +registry is used. + +File completion notification changes have a typed resource state effect. +Native mode changes are serialized with managed calls and rejected while an +asynchronous lease exists, including a prepared operation not yet submitted. +Successful changes only add mode bits; failures do not update state. Before +each IOCP submission the runtime queries the actual native notification modes, +so a preconfigured handle is not assumed to use defaults. Synchronous success +with `FILE_SKIP_COMPLETION_PORT_ON_SUCCESS` completes locally through the same +retirement path; ordinary synchronous success and `ERROR_IO_PENDING` still wait +for their IOCP packet. Buffers and leases are retired exactly once in either path. +Raw/unsafe handle escape does not authorize concurrent foreign mutation or close +of a managed handle. + +## Namespace output + +Generated modules use a lowercase/kebab namespace directory mapping, for +example `win32/windows/win32/system/registry/Apis.js`. The Win32 output manifest +records namespace exports and generated file hashes. The CLI uses the shared +atomic output transaction, retaining other generated namespaces on incremental +runs and rejecting stale or conflicting output. + +Win32-only packages do not acquire a WinRT package-root entrypoint. Mixed +generation preserves existing root exports and adds explicit Win32 subpaths. +Namespaces containing COM interfaces retain explicit `--class-name` +selection; use their `Apis` container for flat exports. Python flat-Win32 +generation remains explicitly unsupported. + +Flags declarations permit normal bitwise combinations while ordinary enums +retain their member types. ABI-width validation remains separate from the +TypeScript surface. CI uploads the complete `dist` runtime tree, matching the +npm distribution boundary, rather than maintaining a second filename list. +It then downloads that artifact and checks every public package entrypoint +through CommonJS, ESM and native dispatch. + +## Tests + +Behavior is protected by contract, ABI, ownership, generated-output, package, +and live Windows API tests: + +| Tests | Assertions | +| --- | --- | +| Shared Win32 contract tests | Strict version decoding, legacy migration, complete result coverage, ownership/delivery combinations, disjoint conditions and Rust-derived schema consistency. | +| Codegen Win32 unit tests | Exact contract selectors and drift rejection, typed ABI and ownership plans, count/size relationships, native layouts, builders, return conventions and generated behavior. | +| Core Win32 unit tests | Real FFI scalar/aggregate calls, output ordering, success/failure and cleanup, handle leases and consuming calls. | +| Aggregate field result tests | Caller-owned storage identity, per-field validity and ownership, failed delivery before `_call` wrapping, partial and cross-aggregate conversion failures, unsafe legacy transfers, safe-write protection, extraction, failed discard cleanup retry and real `CreateProcessW` handle retirement. | +| Aggregate owner lock tests | Bounded real `DuplicateHandle` reuse, shared-owner rejection without mutation, moved/distinct owners, input-alias policies, failed/busy retirement, invalid-input preservation and ordered/cross-thread resource coordination. | +| Native side-effect tests | Input consumption, alias/lease state and real file completion-mode updates across native success/failure, field/return conversion errors and discard cleanup failure. | +| Native I/O tests | Real local file/pipe I/O without Node, synchronous/pending completion, cancellation, dropped consumers, queued-result quotas and exact lifetime retirement. | +| JS Win32 tests | Native carrier identity, argument/descriptor validation, encoded strings and buffers, resource lifetimes, IOCP cancellation/capacity and subsystem state. | +| Module/lifecycle loading tests | Controlled System32 paths, successful-cache identity, retryable failures, concurrent load reference balance, complete function-table publication, startup/shutdown/rollback state, and the actual shared-addon PE import boundary. | +| Win32 CLI tests | Namespace/enum files, relative runtime imports, CJS/ESM resolution, missing or malformed output, atomic failure/rollback and retry, incremental regeneration and coexistence with WinRT/COM. | +| Generated-module tests | Load every currently admitted JS/enum module as CJS and ESM without native dispatch, and compile its declarations with TypeScript. Expected behavior comes from actual exports and type rules, not stored implementation hashes. | +| Win32 E2E runners | Actual Registry, aggregate, resource, IOCP, subsystem and generated declaration behavior. | + +The existing CI jobs run these tests together with WinRT and Classic COM +regressions. The census minimum is an additional coverage signal, not proof +of correctness or a substitute for explicit behavioral assertions. +`npm test` includes Win32 consumer typechecking; the existing CI jobs run the +Rust binding tests and Node suite in addition to generated E2E scenarios. + +Real-metadata tests read `DYNWINRT_WIN32_WINMD`. CI also sets +`DYNWINRT_REQUIRE_WIN32_METADATA=1` so missing metadata is a failure, not an +unnoticed skip. Live scenarios require stock Windows; optional-device and +ARM64 execution coverage must be reported separately from compilation. +Native subsystem lifecycle tests run in isolated, time-bounded processes with +initialization/cleanup stage output, so a platform startup failure cannot +silently block unrelated tests behind a process-global lock. + +Deterministic lifecycle tests use test-only function tables to exercise the +same context, counting and call-guard implementation. They cover reserved +flags, first-lease initialization, last-lease cleanup, retries after startup +or shutdown failure, rollback, missing exports, aliases, idempotent close, +`Drop` and concurrent close. Separate integration cases invoke the installed +Winsock, GDI+ and Media Foundation APIs; only positively identified missing +optional DLLs or lifecycle exports permit a skip, not arbitrary Startup +failures. Architecture-specific MAPI system export resolution is mandatory +without invoking a provider. + +The real MAPI lifecycle test remains available separately on a machine with a +configured provider (for example, matching-bitness Outlook). It is ignored by +default, fails on initialization errors/timeouts, and never treats an unavailable +provider as success: + +```powershell +cargo test -p jswinrt_rs --lib win32_subsystem::tests::mapi_utility_contexts_use_installed_provider -- --exact --ignored --nocapture +``` diff --git a/docs/guides/windows/classic-com-usage.md b/docs/guides/windows/classic-com-usage.md index 694351be..f9f32258 100644 --- a/docs/guides/windows/classic-com-usage.md +++ b/docs/guides/windows/classic-com-usage.md @@ -203,8 +203,8 @@ This is still unsafe. Verify acquisition, apartment, optional-pointer, storage, and cleanup rules against the native contract. A failing HRESULT may throw after native code has mutated caller-owned slots; inspect and reconcile such storage according to the API contract. See the -[complete generated unsafe examples](generated-com-unsafe-example.zh-CN.md) for -synchronous/semisynchronous WMI and manual-contract raw calls. +[generated unsafe strategy reference](../../architecture/classic-com-generated-unsafe.md#generated-strategy-runtime) +for explicit pointer, buffer, and output-ownership strategies. Stage 2 also emits `raw_manual_contract` methods with required strategies from `generated/com/unsafe/runtime.js`. A pointer output with unknown ownership @@ -1466,8 +1466,11 @@ Handwritten signatures, vtable slots, and pointer cleanup are unsafe ABI operati ### Can Classic COM call ordinary Win32 DLL functions? -No. Flat DLL exports such as `CreateFileW`, registry APIs, and GDI APIs are not COM vtables. They require a separate -Win32 DLL and handle model. +Not through the COM entrypoint. Flat DLL exports such as `CreateFileW`, +Registry APIs, and GDI APIs are not COM vtables. Generate their `Apis` +containers and use `@microsoft/dynwinrt/win32` for supported exports. +See the [Win32 generation guide](../../../tools/dynwinrt-codegen/README.md#contract-driven-flat-win32) +and [native contract boundary](../../architecture/flat-win32-contracts.md). ## 13. Additional resources diff --git a/docs/status/CLASSIC_COM_API_SUPPORT_PLAN.md b/docs/status/CLASSIC_COM_API_SUPPORT_PLAN.md index 967dc67e..ab107567 100644 --- a/docs/status/CLASSIC_COM_API_SUPPORT_PLAN.md +++ b/docs/status/CLASSIC_COM_API_SUPPORT_PLAN.md @@ -161,7 +161,7 @@ implementation, aggregation, or custom marshaling. | Custom allocators and resource handles | The runtime lacks the exact cleanup operation. | Raw pointer plus explicit cleanup primitive where one exists. | | Cross-apartment callbacks | JavaScript is tied to its V8 owner thread while COM callbacks can be synchronous on foreign threads. | Not solved by raw ABI; requires marshaling and dispatch architecture. | | COM aggregation, custom marshaling, and registered servers | These change object identity, activation, and process semantics rather than only method ABI. | Separate architecture work. | -| Flat Win32 DLL exports | They are not COM vtable methods. | Separate Win32 raw function layer. | +| Flat Win32 DLL exports | They are not COM vtable methods. | Use the separate [contract-driven Win32 layer](../architecture/flat-win32-contracts.md) for supported exports. | ## How users check a specific API @@ -571,7 +571,8 @@ as ABI support. The legacy `com-census --json` output remains unchanged. - Expand Automation and native-layout semantic support. - Design apartment marshaling and agility independently from raw ABI. -- Keep flat Win32 exports and COM server support as separate projects. +- Keep DLL exports in the separate [Win32 contract layer](../architecture/flat-win32-contracts.md); + COM server support remains independent architecture work. ## Copyable user-facing statement diff --git a/docs/status/TODO.md b/docs/status/TODO.md index 4d052c51..ee7f80d1 100644 --- a/docs/status/TODO.md +++ b/docs/status/TODO.md @@ -72,6 +72,12 @@ _None currently. Reserved for issues that make v0.1 unshippable (crash on happy ## P2 — Feature completeness +- [x] **Contract-driven flat Win32 bindings**. + JavaScript/TypeScript generation, validated native ABI plans, managed + resource cleanup, namespace packaging, and asynchronous file I/O are + implemented with contract, runtime, and end-to-end regression coverage. + See [Win32 architecture and tests](../architecture/flat-win32-contracts.md). + - [ ] **Struct auto-marshaling**. Users still need `DynWinRtStruct.create()` + `setF64(...)` per field. Codegen generates `_packXxx` helpers for known structs already; the gap is user-defined / ad-hoc structs. Consider generic `pack(schema, obj)`. - [x] **Python `IReference` as struct field**. Generated structs read native diff --git a/eng/coverage/coverage.ps1 b/eng/coverage/coverage.ps1 index 915d9315..75609e54 100644 --- a/eng/coverage/coverage.ps1 +++ b/eng/coverage/coverage.ps1 @@ -619,6 +619,7 @@ try { Invoke-Step "Rust workspace tests" { & cargo test ` -p dynwinrt-com-contracts ` + -p dynwinrt-win32-contracts ` -p dynwinrt ` -p dynwinrt-codegen ` -p dynwinrt-py ` diff --git a/samples/js/README.md b/samples/js/README.md index 93b6f5ba..e026a71c 100644 --- a/samples/js/README.md +++ b/samples/js/README.md @@ -11,6 +11,7 @@ The JavaScript samples use generated bindings and the | [`electron-share-ui`](electron-share-ui/) | Electron Share UI with WinRT and Classic COM | | [`electron-smtc`](electron-smtc/) | Electron system media controls and GSMTC loopback | | [`interface-implementation`](interface-implementation/) | Standalone JavaScript-backed WinRT interfaces, native IBackgroundTask calls, and multi-interface lifetime | +| [`win32`](win32/) | Generated Win32 DLL exports, Registry buffers and handle cleanup, and IOCP-backed asynchronous file I/O | The WinUI samples use WinApp CLI to restore matching Windows App SDK metadata, runtime packages, bootstrap binaries, and generated npm bindings. diff --git a/samples/js/win32/.gitignore b/samples/js/win32/.gitignore new file mode 100644 index 00000000..1d4f48dc --- /dev/null +++ b/samples/js/win32/.gitignore @@ -0,0 +1,3 @@ +generated/ +node_modules/ +package-lock.json diff --git a/samples/js/win32/README.md b/samples/js/win32/README.md new file mode 100644 index 00000000..1f45c11b --- /dev/null +++ b/samples/js/win32/README.md @@ -0,0 +1,148 @@ +# Flat Win32 JavaScript samples + +These examples use generated JavaScript bindings to call real Windows DLL +exports. `generate.ps1` reads `Windows.Win32.winmd` and emits `.js` modules and +`.d.ts` declarations; the examples load those modules through the locally built +`@microsoft/dynwinrt/win32` runtime. No TypeScript compilation or handwritten +native call signatures are required. + +| Sample | Windows APIs | Demonstrates | +| --- | --- | --- | +| [system-info.mjs](system-info.mjs) | `GetTickCount64`, `GetSystemTime` | A `bigint` return and a native `SYSTEMTIME` output structure. | +| [registry-product-name.mjs](registry-product-name.mjs) | `RegOpenKeyExW`, `RegQueryValueExW`, `RegCloseKey` | Size probing, a caller-owned UTF-16 buffer, status handling, and deterministic `HKEY` cleanup. | +| [overlapped-file.mjs](overlapped-file.mjs) | `CreateFileW`, `ReadFile`, `WriteFile`, `CloseHandle` | IOCP-backed Promises, file offsets, retained buffers, and an `AbortSignal`. | + +None of the samples requires administrator privileges, network access at +runtime, package identity, or WinAppSDK initialization. Application code uses +the generated safe wrappers, not the manual unsafe Win32 entrypoint. + +## Prerequisites + +- Windows 10 or later with a 64-bit Node.js 18+ process (x64 or ARM64). + Flat Win32 invocation is not supported in a 32-bit process. +- Rust with the Windows MSVC build tools/SDK, PowerShell, and NuGet. +- `Microsoft.Windows.SDK.Win32Metadata` version `71.0.14-preview`, containing + `Windows.Win32.winmd`. + +The sample package references `bindings\js` in this checkout rather than a +published npm runtime. Dependency installation may require network access. + +From the repository root, build the runtime and code generator: + +```powershell +Push-Location bindings\js +npm install +npm run build +Pop-Location + +cargo build -p dynwinrt-codegen --release +``` + +Restore the same metadata package used by CI if it is not already installed: + +```powershell +$metadataRoot = Join-Path $env:TEMP "dynwinrt-win32metadata" +nuget install Microsoft.Windows.SDK.Win32Metadata ` + -Version 71.0.14-preview ` + -OutputDirectory $metadataRoot ` + -DirectDownload ` + -NonInteractive +$winmd = Get-ChildItem $metadataRoot -Filter Windows.Win32.winmd -File -Recurse | + Select-Object -First 1 +``` + +Generate the bindings and install the locally built runtime: + +```powershell +Push-Location samples\js\win32 +npm install +.\generate.ps1 ` + -Win32Winmd $winmd.FullName ` + -Codegen ..\..\..\target\release\dynwinrt-codegen.exe +``` + +Run any sample: + +```powershell +npm run system-info +npm run registry +npm run overlapped-file +Pop-Location +``` + +Generated files and `node_modules` are local artifacts and are not tracked. + +## Generated modules + +The three namespaces are kept in separate directories: + +```text +generated\ + package.json + win32\ + windows\win32\system\system-information\ + windows\win32\system\registry\ + windows\win32\storage\file-system\ +``` + +Each namespace contains `Apis.js`, `Apis.d.ts`, namespace indexes, and any +required enum modules. The samples import `index.mjs`; unsuffixed names such +as `regOpenKeyEx` and `regQueryValueEx` are aliases of the Unicode `W` APIs. +`generate.ps1` replaces this sample's entire `generated` directory, so do not +put handwritten files there. + +## Expected behavior + +### System information + +`npm run system-info` prints the system uptime in milliseconds and the current +UTC time. `createSYSTEMTIME()` allocates the native structure; +`getSystemTime()` fills it, and the sample reads its 16-bit fields. + +Illustrative output; values change on every run: + +```text +Windows uptime: 123456789 ms +System UTC time: 2026-09-11T10:00:00.000Z +``` + +### Registry product name + +`npm run registry` opens +`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion` with +`KEY_READ` and reads `ProductName`. It first passes `null` to obtain the +required byte count, allocates a `Buffer`, then decodes the filled UTF-16LE +data. The managed key is closed in `finally`; no registry values are changed. + +Example output: + +```text +Windows 10 Enterprise +``` + +The exact string depends on the machine's registry value and may still say +Windows 10 on a Windows 11 installation. + +### Asynchronous file round trip + +`npm run overlapped-file` creates a uniquely named file in the system temporary +directory with `FILE_FLAG_OVERLAPPED`. It writes and reads the same bytes at +offset `0n`, checks the transferred byte counts and payload, then closes the +handle and removes the file in `finally`. + +```text +Hello from OVERLAPPED Win32 I/O +``` + +The sample passes an `AbortSignal` but does not deliberately abort the +operation. The generated helpers support cancellation through +`AbortController.abort()`; cancellation and detached-buffer behavior are +covered separately by the Win32 E2E runners. + +## Common setup issues + +- Missing `generated` modules: run `generate.ps1` before an npm sample command. +- Missing native addon or `win32` entrypoint: build `bindings\js` and run + `npm install` in this sample directory, using a matching Node.js architecture. +- Metadata mismatch: use the pinned Win32Metadata version above rather than + substituting the WinRT `Windows.winmd` file. diff --git a/samples/js/win32/generate.ps1 b/samples/js/win32/generate.ps1 new file mode 100644 index 00000000..19636c4f --- /dev/null +++ b/samples/js/win32/generate.ps1 @@ -0,0 +1,52 @@ +#!/usr/bin/env pwsh + +param( + [Parameter(Mandatory)] + [string]$Win32Winmd, + + [string]$Codegen = "dynwinrt-codegen" +) + +$ErrorActionPreference = "Stop" +$caller = (Get-Location).Path + +function Resolve-CallerPath([string]$Path) { + if ([System.IO.Path]::IsPathRooted($Path)) { + return [System.IO.Path]::GetFullPath($Path) + } + return [System.IO.Path]::GetFullPath((Join-Path $caller $Path)) +} + +$Win32Winmd = Resolve-CallerPath $Win32Winmd +if (-not (Test-Path -LiteralPath $Win32Winmd -PathType Leaf)) { + throw "Windows.Win32.winmd was not found: $Win32Winmd" +} + +$codegenCandidate = Resolve-CallerPath $Codegen +if (Test-Path -LiteralPath $codegenCandidate -PathType Leaf) { + $codegenCommand = $codegenCandidate +} else { + $codegenCommand = (Get-Command $Codegen -ErrorAction Stop).Source +} + +$output = Join-Path $PSScriptRoot "generated" +if (Test-Path -LiteralPath $output) { + Remove-Item -LiteralPath $output -Recurse -Force +} + +foreach ($namespace in @( + "Windows.Win32.System.SystemInformation", + "Windows.Win32.System.Registry", + "Windows.Win32.Storage.FileSystem" +)) { + & $codegenCommand generate ` + --winmd $Win32Winmd ` + --namespace $namespace ` + --class-name Apis ` + --output $output + if ($LASTEXITCODE -ne 0) { + throw "dynwinrt-codegen failed for $namespace with exit code $LASTEXITCODE" + } +} + +Write-Host "Generated flat Win32 bindings in $output" diff --git a/samples/js/win32/overlapped-file.mjs b/samples/js/win32/overlapped-file.mjs new file mode 100644 index 00000000..b09a3346 --- /dev/null +++ b/samples/js/win32/overlapped-file.mjs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import assert from "node:assert/strict"; +import { rm } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; + +import { + createFileW, + readFileAsync, + writeFileAsync, +} from "./generated/win32/windows/win32/storage/file-system/index.mjs"; + +const GENERIC_READ_WRITE = 0xc0000000; +const CREATE_ALWAYS = 2; +const FILE_ATTRIBUTE_NORMAL = 0x80; +const FILE_FLAG_OVERLAPPED = 0x40000000; + +const path = join(tmpdir(), `dynwinrt-overlapped-${process.pid}-${Date.now()}.tmp`); +const opened = createFileW( + path, + GENERIC_READ_WRITE, + 0, + null, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, + null, +); +if (!opened.result) { + throw new Error(`CreateFileW failed with error ${opened.lastError}`); +} + +const file = opened.result; +try { + const controller = new AbortController(); + const expected = Buffer.from("Hello from OVERLAPPED Win32 I/O"); + + const written = await writeFileAsync(file, expected, 0n, controller.signal); + assert.equal(written, expected.length); + + const actual = Buffer.alloc(expected.length); + const read = await readFileAsync(file, actual, 0n, controller.signal); + assert.equal(read, expected.length); + assert.deepEqual(actual, expected); + + console.log(actual.toString("utf8")); +} finally { + file.close(); + await rm(path, { force: true }); +} diff --git a/samples/js/win32/package.json b/samples/js/win32/package.json new file mode 100644 index 00000000..30ab13fb --- /dev/null +++ b/samples/js/win32/package.json @@ -0,0 +1,13 @@ +{ + "name": "dynwinrt-win32-samples", + "private": true, + "type": "module", + "scripts": { + "system-info": "node system-info.mjs", + "registry": "node registry-product-name.mjs", + "overlapped-file": "node overlapped-file.mjs" + }, + "dependencies": { + "@microsoft/dynwinrt": "file:../../../bindings/js" + } +} diff --git a/samples/js/win32/registry-product-name.mjs b/samples/js/win32/registry-product-name.mjs new file mode 100644 index 00000000..cde075c1 --- /dev/null +++ b/samples/js/win32/registry-product-name.mjs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + regOpenKeyEx, + regQueryValueEx, +} from "./generated/win32/windows/win32/system/registry/index.mjs"; + +const HKEY_LOCAL_MACHINE = 0x80000002n; +const KEY_READ = 0x20019; +const ERROR_SUCCESS = 0; + +const opened = regOpenKeyEx( + HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + 0, + KEY_READ, +); +if (opened.status !== ERROR_SUCCESS || !opened.key) { + throw new Error(`RegOpenKeyEx failed with status ${opened.status}`); +} + +try { + const probe = regQueryValueEx(opened.key, "ProductName", null); + if (probe.status !== ERROR_SUCCESS) { + throw new Error(`RegQueryValueEx size query failed with status ${probe.status}`); + } + + const data = Buffer.alloc(probe.dataSize); + const result = regQueryValueEx(opened.key, "ProductName", data); + if (result.status !== ERROR_SUCCESS) { + throw new Error(`RegQueryValueEx failed with status ${result.status}`); + } + + let byteLength = result.dataSize; + if (byteLength >= 2 && data.readUInt16LE(byteLength - 2) === 0) { + byteLength -= 2; + } + console.log(data.toString("utf16le", 0, byteLength)); +} finally { + opened.key.close(); +} diff --git a/samples/js/win32/system-info.mjs b/samples/js/win32/system-info.mjs new file mode 100644 index 00000000..a9c6fffc --- /dev/null +++ b/samples/js/win32/system-info.mjs @@ -0,0 +1,26 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + createSYSTEMTIME, + getSystemTime, + getTickCount64, +} from "./generated/win32/windows/win32/system/system-information/index.mjs"; + +const uptimeMilliseconds = getTickCount64(); + +const systemTime = createSYSTEMTIME(); +getSystemTime(systemTime); +const bytes = systemTime.bytes; +const utc = new Date(Date.UTC( + bytes.readUInt16LE(0), + bytes.readUInt16LE(2) - 1, + bytes.readUInt16LE(6), + bytes.readUInt16LE(8), + bytes.readUInt16LE(10), + bytes.readUInt16LE(12), + bytes.readUInt16LE(14), +)); + +console.log(`Windows uptime: ${uptimeMilliseconds} ms`); +console.log(`System UTC time: ${utc.toISOString()}`); diff --git a/tests/e2e/e2e_test.ps1 b/tests/e2e/e2e_test.ps1 index 928c243b..66effb7f 100644 --- a/tests/e2e/e2e_test.ps1 +++ b/tests/e2e/e2e_test.ps1 @@ -12,6 +12,7 @@ # .\tests\e2e\e2e_test.ps1 -Lang py # Python only # .\tests\e2e\e2e_test.ps1 -Lang ts # TypeScript only # .\tests\e2e\e2e_test.ps1 -Lang com # Classic COM only +# .\tests\e2e\e2e_test.ps1 -Lang win32 # Contract-driven flat Win32 slice # .\tests\e2e\e2e_test.ps1 -SkipBuild -Suite implementations -Lang py,ts -KeepGenerated # .\tests\e2e\e2e_test.ps1 -SkipBuild -Suite standard # Existing WinRT/COM cases only @@ -23,8 +24,8 @@ param( [string]$Python, [ValidateSet("all", "standard", "implementations")] [string]$Suite = "all", - [ValidateSet("py", "ts", "com")] - [string[]]$Lang = @("py", "ts", "com") + [ValidateSet("py", "ts", "com", "win32")] + [string[]]$Lang = @("py", "ts", "com", "win32") ) $ErrorActionPreference = "Stop" @@ -46,6 +47,7 @@ $comStreamDir = Join-Path $comBindingsDir "stream" $comAutomationDir = Join-Path $comBindingsDir "automation" $comInfrastructureDir = Join-Path $comBindingsDir "infrastructure" $comSmtcDir = Join-Path $comBindingsDir "smtc" +$win32BindingsDir = Join-Path $e2eDir "win32" [string[]]$cargoProfileArgs = @( if ($CargoProfile -eq "release") { "--release" @@ -83,9 +85,9 @@ if ("py" -in $Lang -and -not $hasPython) { Write-Host " SKIP Python (not installed)" -ForegroundColor DarkYellow $Lang = $Lang | Where-Object { $_ -ne "py" } } -if (("ts" -in $Lang -or "com" -in $Lang) -and -not $hasNode) { +if (("ts" -in $Lang -or "com" -in $Lang -or "win32" -in $Lang) -and -not $hasNode) { Write-Host " SKIP JavaScript E2E (Node.js not installed)" -ForegroundColor DarkYellow - $Lang = @($Lang | Where-Object { $_ -notin @("ts", "com") }) + $Lang = @($Lang | Where-Object { $_ -notin @("ts", "com", "win32") }) } function Find-Win32Winmd { @@ -107,15 +109,15 @@ function Find-Win32Winmd { } $win32Winmd = $null -if ("com" -in $Lang) { +if ("com" -in $Lang -or "win32" -in $Lang) { $win32Winmd = Find-Win32Winmd if (-not $win32Winmd) { if ($langWasExplicit -or $env:DYNWINRT_REQUIRE_WIN32_METADATA -eq "1") { - Write-Error "Classic COM E2E requires Windows.Win32.winmd. Set DYNWINRT_WIN32_WINMD or install Microsoft.Windows.SDK.Win32Metadata." + Write-Error "Classic COM and flat Win32 E2E require Windows.Win32.winmd. Set DYNWINRT_WIN32_WINMD or install Microsoft.Windows.SDK.Win32Metadata." exit 1 } - Write-Host " SKIP Classic COM (Windows.Win32.winmd not found)" -ForegroundColor DarkYellow - $Lang = @($Lang | Where-Object { $_ -ne "com" }) + Write-Host " SKIP Classic COM and flat Win32 (Windows.Win32.winmd not found)" -ForegroundColor DarkYellow + $Lang = @($Lang | Where-Object { $_ -notin @("com", "win32") }) } else { $env:DYNWINRT_WIN32_WINMD = $win32Winmd Write-Host " Win32 metadata: $win32Winmd" @@ -124,6 +126,25 @@ if ("com" -in $Lang) { if ($Lang.Count -eq 0) { Write-Error "No languages available"; exit 1 } +function Invoke-NodeRunner([string]$runnerPath, [string[]]$runnerArguments = @(), [int]$timeoutSeconds = 180) { + $start = [System.Diagnostics.ProcessStartInfo]::new((Get-Command node).Source) + $start.UseShellExecute = $false + $start.ArgumentList.Add($runnerPath) + foreach ($argument in $runnerArguments) { $start.ArgumentList.Add($argument) } + $process = [System.Diagnostics.Process]::Start($start) + try { + if (-not $process.WaitForExit($timeoutSeconds * 1000)) { + Write-Host "TIMEOUT: $runnerPath exceeded ${timeoutSeconds}s" -ForegroundColor Red + Stop-Process -Id $process.Id -Force + $process.WaitForExit() + return 124 + } + return $process.ExitCode + } finally { + $process.Dispose() + } +} + # -------------------------------------------------------------------------- # Build (optional) # -------------------------------------------------------------------------- @@ -163,7 +184,7 @@ if (-not $SkipBuild) { Pop-Location } - if ("ts" -in $Lang -or "com" -in $Lang) { + if ("ts" -in $Lang -or "com" -in $Lang -or "win32" -in $Lang) { Push-Location (Join-Path $root "bindings\js") npm install --quiet 2>&1 | Out-Null if ($LASTEXITCODE -ne 0) { Write-Error "npm install failed"; exit 1 } @@ -333,6 +354,31 @@ if ("com" -in $Lang) { } # -------------------------------------------------------------------------- +if ("win32" -in $Lang) { + Write-Host "`n--- Generate contract-driven flat Win32 ---" -ForegroundColor Yellow + $win32Classes = @( + "Windows.Win32.System.Registry", + "Windows.Win32.System.SystemInformation", + "Windows.Win32.System.LibraryLoader", + "Windows.Win32.Graphics.Gdi", + "Windows.Win32.System.Threading", + "Windows.Win32.System.Com", + "Windows.Win32.Networking.Ldap", + "Windows.Win32.Networking.WinSock", + "Windows.Win32.NetworkManagement.IpHelper", + "Windows.Win32.Graphics.GdiPlus", + "Windows.Win32.Media.MediaFoundation", + "Windows.Win32.System.Pipes", + "Windows.Win32.Storage.FileSystem" + ) | ForEach-Object { "$_.Apis" } + & cargo run -p dynwinrt-codegen @cargoProfileArgs @cargoTargetArgs --quiet -- generate ` + --winmd $win32Winmd ` + --class-name ($win32Classes -join ",") ` + --output $win32BindingsDir ` + --import-name "../../../../bindings/js/dist/win32.js" + if ($LASTEXITCODE -ne 0) { Write-Error "Flat Win32 contract generation failed"; exit 1 } +} + # Run language-specific runners # -------------------------------------------------------------------------- $totalPass = 0 @@ -411,8 +457,8 @@ if ("com" -in $Lang) { $comFailed = 0 foreach ($runner in $comRunners) { Write-Host " $runner" - & node (Join-Path $runnersDir "com\$runner") - if ($LASTEXITCODE -eq 0) { + $runnerExitCode = Invoke-NodeRunner (Join-Path $runnersDir "com\$runner") + if ($runnerExitCode -eq 0) { $comPassed++ } else { $comFailed++ @@ -426,6 +472,30 @@ if ("com" -in $Lang) { } } +if ("win32" -in $Lang) { + Write-Host "`n--- Flat Win32 contract E2E ---" -ForegroundColor Yellow + $tsc = Join-Path $root "bindings\js\node_modules\.bin\tsc.cmd" + if (-not (Test-Path -LiteralPath $tsc)) { Write-Error "Flat Win32 typecheck requires the JS development dependencies."; exit 1 } + & $tsc --noEmit --strict --target ES2022 --module NodeNext --moduleResolution NodeNext ` + --types node --typeRoots (Join-Path $root "bindings\js\node_modules\@types") ` + (Join-Path $PSScriptRoot "typecheck\win32_contracts.ts") + if ($LASTEXITCODE -ne 0) { Write-Error "Flat Win32 declarations failed typecheck"; exit 1 } + $win32Runners = @("registry.mjs", "returns.mjs", "subsystems.mjs", "contracts.mjs", "owned-fields.mjs") + $win32Passed = 0 + foreach ($runner in $win32Runners) { + Write-Host " $runner" + $arguments = if ($runner -eq "contracts.mjs") { @("--generated", $win32BindingsDir) } else { @() } + $runnerExitCode = Invoke-NodeRunner (Join-Path $runnersDir "win32\$runner") -runnerArguments $arguments + if ($runnerExitCode -eq 0) { $win32Passed++ } + } + if ($win32Passed -eq $win32Runners.Count) { $totalPass++ } else { $totalFail++ } + $allResults += [pscustomobject]@{ + language = "win32" + passed = $win32Passed + total = $win32Runners.Count + } +} + if ($Suite -eq "all" -and ("py" -in $Lang -or "ts" -in $Lang)) { Write-Host "`n--- Generated WinRT implementations ---" -ForegroundColor Yellow $implementationLangs = @($Lang | Where-Object { $_ -in @("py", "ts") }) diff --git a/tests/e2e/runners/win32/contracts.mjs b/tests/e2e/runners/win32/contracts.mjs new file mode 100644 index 00000000..66c75a98 --- /dev/null +++ b/tests/e2e/runners/win32/contracts.mjs @@ -0,0 +1,53 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import assert from "node:assert/strict"; +import { createRequire } from "node:module"; +import { join, resolve } from "node:path"; +import { pathToFileURL } from "node:url"; +import * as runtime from "../../../../bindings/js/dist/win32.js"; +import * as winrt from "../../../../bindings/js/dist/winrt.js"; + +const option = process.argv.indexOf("--generated"); +assert(option >= 0 && process.argv[option + 1], "--generated is required"); +const generated = resolve(process.argv[option + 1]); +const requireGenerated = createRequire(join(generated, "package.json")); +const systemPath = "win32/windows/win32/system/system-information"; +const registryPath = "win32/windows/win32/system/registry"; +const system = requireGenerated(`@winapp/bindings/${systemPath}`); +const registry = requireGenerated(`@winapp/bindings/${registryPath}`); +const esm = await import(pathToFileURL(join(generated, systemPath, "index.mjs")).href); + +assert.equal(typeof system.getTickCount(), "number"); +assert.equal(typeof system.getTickCount64(), "bigint"); +assert.equal(typeof system.createSYSTEMTIME, "function"); +assert.equal(esm.getTickCount64, system.getTickCount64); +assert.equal(registry.regOpenKeyEx, registry.regOpenKeyExW); +assert.equal(registry.regQueryValueEx, registry.regQueryValueExW); +assert.throws(() => requireGenerated("@winapp/bindings"), { + code: "ERR_PACKAGE_PATH_NOT_EXPORTED", +}); +assert.equal(typeof runtime.DynWin32, "function"); +assert.equal(Object.hasOwn(runtime, "DynWin32Unsafe"), false); +assert.equal(Object.hasOwn(winrt, "DynWin32"), false); + +const opened = registry.regOpenKeyEx( + 0x80000002n, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + 0, + 1, +); +assert.equal(opened.status, 0); +assert(opened.key instanceof runtime.DynWin32Resource); +try { + const probe = registry.regQueryValueEx(opened.key, "ProductName", null); + assert.equal(probe.status, 0); + const data = Buffer.alloc(probe.dataSize); + const value = registry.regQueryValueEx(opened.key, "ProductName", data); + assert.equal(value.status, 0); + assert(value.dataSize > 0); + assert.match(data.toString("utf16le", 0, value.dataSize), /Windows/); +} finally { + opened.key.close(); +} +console.log("PASS Win32 contracts: package isolation, namespace imports, aliases and baseline calls"); diff --git a/tests/e2e/runners/win32/owned-fields.mjs b/tests/e2e/runners/win32/owned-fields.mjs new file mode 100644 index 00000000..9165b5ec --- /dev/null +++ b/tests/e2e/runners/win32/owned-fields.mjs @@ -0,0 +1,113 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import assert from "node:assert/strict"; +import { spawnSync } from "node:child_process"; +import { setImmediate as nextTurn } from "node:timers/promises"; +import { fileURLToPath } from "node:url"; +import { + createProcessInformation, + createStartupInfoW, + createProcessW, + takeProcessInformationProcess, + takeProcessInformationThread, +} from "../../e2e_generated/win32/win32/windows/win32/system/threading/Apis.js"; +import { + DynWin32, + DynWin32CallResult, + DynWin32Function, +} from "../../../../bindings/js/dist/win32-unsafe.js"; + +const stage = process.argv[2]; +if (!stage) { + for (const failure of ["control", "invoke", "returnValue", "outputs"]) { + const result = spawnSync( + process.execPath, + ["--expose-gc", fileURLToPath(import.meta.url), failure], + { encoding: "utf8", timeout: 30000 }, + ); + assert.equal(result.error, undefined, `${failure}: ${result.error}\n${result.stderr}`); + assert.equal(result.status, 0, `${failure}:\n${result.stdout}\n${result.stderr}`); + assert.match(result.stdout, /PASS owned fields/); + } + console.log("PASS owned fields: actual CreateProcessW delivery failures leave no handles"); +} else { + assert.equal(typeof global.gc, "function"); + const counter = DynWin32Function.bind({ + dll: "kernel32.dll", + entryPoint: "GetProcessHandleCount", + parameters: [ + { type: "handle", direction: "in" }, + { type: "u32", direction: "out" }, + ], + returnType: "bool32", + successRule: "nonzero", + }); + const countHandles = () => { + const count = counter.invoke([DynWin32.handle(-1n)]); + assert(count.succeeded); + return DynWin32.toNumber(count.outputs[0]); + }; + const collect = async () => { + for (let i = 0; i < 8; ++i) { + await nextTurn(); + global.gc(); + } + await nextTurn(); + }; + + function run(failure) { + const startup = createStartupInfoW(); + const information = createProcessInformation(); + const reference = new WeakRef(information); + const prototype = failure === "invoke" + ? DynWin32Function.prototype + : DynWin32CallResult.prototype; + const member = failure === "invoke" ? "invoke" : failure; + const descriptor = failure === "control" + ? undefined + : Object.getOwnPropertyDescriptor(prototype, member); + if (descriptor) { + Object.defineProperty(prototype, member, failure === "invoke" + ? { + ...descriptor, + value(...args) { + Reflect.apply(descriptor.value, this, args); + throw new Error("injected delivery failure"); + }, + } + : { + ...descriptor, + get() { throw new Error("injected delivery failure"); }, + }); + } + try { + const invoke = () => createProcessW( + null, + `"${process.env.ComSpec}" /d /c exit 0`, + null, null, false, 0x08000000, null, + startup, information, + ); + if (failure === "control") { + assert.equal(invoke().result, true); + takeProcessInformationProcess(information).close(); + takeProcessInformationThread(information).close(); + } else { + assert.throws(invoke, /injected delivery failure/); + } + } finally { + if (descriptor) Object.defineProperty(prototype, member, descriptor); + } + return reference; + } + + run("control"); + await collect(); + const before = countHandles(); + const references = Array.from({ length: 4 }, () => run(stage)); + await collect(); + for (const reference of references) assert.equal(reference.deref(), undefined); + const after = countHandles(); + assert.equal(after, before, `${stage}: leaked ${after - before} process/thread handles`); + console.log(`PASS owned fields ${stage}: 0 leaked handles`); +} diff --git a/tests/e2e/runners/win32/registry.mjs b/tests/e2e/runners/win32/registry.mjs new file mode 100644 index 00000000..9b28a666 --- /dev/null +++ b/tests/e2e/runners/win32/registry.mjs @@ -0,0 +1,174 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import assert from "node:assert/strict"; +import { + regCloseKey, + regGetValueA, + regGetValueW, + regOpenKeyA, + regOpenKeyW, + regOpenKeyExA, + regOpenKeyExW, + regOpenKeyEx, + regQueryValueExA, + regQueryValueEx, +} from "../../e2e_generated/win32/win32/windows/win32/system/registry/index.mjs"; +import { + DynWin32, + DynWin32Function, + DynWin32Resource, +} from "../../../../bindings/js/dist/win32-unsafe.js"; + +const HKEY_LOCAL_MACHINE = 0x80000002n; +const KEY_READ = 0x20019; + +const opened = regOpenKeyEx( + HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + 0, + KEY_READ, +); +assert.equal(opened.status, 0); +assert(opened.key); +assert.equal(opened.key.closed, false); + +try { + const probe = regQueryValueEx(opened.key, "ProductName", null); + assert.equal(probe.status, 0); + assert(probe.dataSize > 0); + + const data = Buffer.alloc(probe.dataSize); + const read = regQueryValueEx(opened.key, "ProductName", data); + assert.equal(read.status, 0); + let end = read.dataSize; + if (end >= 2 && data.readUInt16LE(end - 2) === 0) { + end -= 2; + } + const productName = data.toString("utf16le", 0, end); + assert.match(productName, /Windows/i); + assert.throws(() => regCloseKey(opened.key.value), /DynWin32Resource|resource/i); + assert.equal(opened.key.closed, false); +} finally { + const closed = regCloseKey(opened.key); + assert.equal(closed.status, 0); +} +assert.equal(opened.key.closed, true); + +const missing = regOpenKeyEx( + HKEY_LOCAL_MACHINE, + "SOFTWARE\\DynWinRT\\DefinitelyMissing", + 0, + KEY_READ, +); +assert.equal(missing.status, 2); +assert.equal(missing.key, null); + +for (const open of [regOpenKeyA, regOpenKeyW]) { + for (const subKey of [null, ""]) { + const owner = regOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE", 0, KEY_READ).key; + assert(owner instanceof DynWin32Resource); + try { + const result = open(owner, subKey); + assert.equal(result.status, 0); + assert(result.key instanceof DynWin32Resource); + assert.equal(result.key.value, owner.value); + result.key.close(); + assert.equal(owner.closed, true); + assert.throws(() => regQueryValueEx(owner, "Missing", null), /closed/); + result.key.close(); + } finally { + owner.close(); + } + const borrowed = open(HKEY_LOCAL_MACHINE, subKey); + assert.equal(borrowed.status, 0); + assert.equal(borrowed.key, HKEY_LOCAL_MACHINE); + } +} + +for (const open of [regOpenKeyExA, regOpenKeyExW]) { + const predefined = -2147483646n; + const borrowed = open(predefined, "", 0, KEY_READ); + assert.equal(borrowed.status, 0); + assert.equal(borrowed.key, DynWin32.toBigint(DynWin32.handle(predefined))); + const zeroExtended = open(HKEY_LOCAL_MACHINE, "", 0, KEY_READ); + assert.equal(zeroExtended.status, 0); + assert(zeroExtended.key instanceof DynWin32Resource); + zeroExtended.key.close(); + assert.equal(zeroExtended.key.closed, true); + const owner = regOpenKeyEx( + HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + 0, + KEY_READ, + ).key; + assert(owner instanceof DynWin32Resource); + try { + const independent = open(owner, null, 0, KEY_READ).key; + assert(independent instanceof DynWin32Resource); + independent.close(); + assert.equal(owner.closed, false); + assert.equal(regQueryValueEx(owner, "ProductName", null).status, 0); + } finally { + owner.close(); + } +} + +const performance = -2147483644n; +const normal = regOpenKeyEx( + HKEY_LOCAL_MACHINE, + "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + 0, + KEY_READ, +).key; +assert(normal instanceof DynWin32Resource); +try { + for (const read of [ + (key, name, data) => regQueryValueExA(key, name, data), + (key, name, data) => regQueryValueEx(key, name, data), + (key, name, data) => regGetValueA(key, null, name, 0xffff, data), + (key, name, data) => regGetValueW(key, null, name, 0xffff, data), + ]) { + for (const capacity of [1, 64]) { + const result = read(performance, "2", Buffer.alloc(capacity)); + assert.equal(result.status, 234); + assert.equal(result.dataSize, null); + } + let succeeded = false; + for (let capacity = 64 * 1024; capacity <= 64 * 1024 * 1024; capacity *= 2) { + const data = Buffer.alloc(capacity); + const result = read(performance, "2", data); + if (result.status === 234) { + assert.equal(result.dataSize, null); + continue; + } + assert.equal(result.status, 0); + assert(result.dataSize > 0 && result.dataSize <= capacity); + assert.equal(data.toString("utf16le", 0, 8), "PERF"); + succeeded = true; + break; + } + assert(succeeded); + const probe = read(normal, "ProductName", null); + assert.equal(probe.status, 0); + assert(probe.dataSize > 1); + const small = read(normal, "ProductName", Buffer.alloc(1)); + assert.equal(small.status, 234); + assert(small.dataSize > 1); + const result = read(normal, "ProductName", Buffer.alloc(probe.dataSize)); + assert.equal(result.status, 0); + assert(result.dataSize > 0 && result.dataSize <= probe.dataSize); + } +} finally { + normal.close(); + const closePerformance = DynWin32Function.bind({ + dll: "advapi32.dll", + entryPoint: "RegCloseKey", + parameters: [{ type: "handle", direction: "in" }], + returnType: "i32", + successRule: "zero", + }).invoke([DynWin32.handle(performance)]); + assert.equal(DynWin32.toNumber(closePerformance.returnValue), 0); +} + +console.log("PASS"); diff --git a/tests/e2e/runners/win32/returns.mjs b/tests/e2e/runners/win32/returns.mjs new file mode 100644 index 00000000..0ad92b5b --- /dev/null +++ b/tests/e2e/runners/win32/returns.mjs @@ -0,0 +1,443 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import assert from "node:assert/strict"; +import { + getModuleHandleW, + getProcAddress, + loadLibraryW, +} from "../../e2e_generated/win32/win32/windows/win32/system/library-loader/Apis.js"; +import { ldapGetLastError } from "../../e2e_generated/win32/win32/windows/win32/networking/ldap/Apis.js"; +import { getAdaptersAddresses } from "../../e2e_generated/win32/win32/windows/win32/network-management/ip-helper/Apis.js"; +import { + createPOINT, + createRECT, + ptInRect, +} from "../../e2e_generated/win32/win32/windows/win32/graphics/gdi/Apis.js"; +import { + createProcessInformation, + createStartupInfoW, + createProcessW, + getProcessInformationProcessId, + getProcessInformationThreadId, + openProcess, + takeProcessInformationProcess, + takeProcessInformationThread, +} from "../../e2e_generated/win32/win32/windows/win32/system/threading/Apis.js"; +import { + createSecurityAttributes, + createPipe, +} from "../../e2e_generated/win32/win32/windows/win32/system/pipes/Apis.js"; +import { + createFileW, + readFileAsync, + writeFileAsync, +} from "../../e2e_generated/win32/win32/windows/win32/storage/file-system/Apis.js"; +import { coIsHandlerConnected } from "../../e2e_generated/win32/win32/windows/win32/system/com/Apis.js"; +import { + DynWinRtValue, + roInitialize, +} from "../../../../bindings/js/dist/winrt.js"; +import { rm } from "node:fs/promises"; +import { pbkdf2 } from "node:crypto"; +import { once } from "node:events"; +import { createServer } from "node:net"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; +import { promisify } from "node:util"; +import { + createSYSTEMTIME, + getSystemTime, + getTickCount64, +} from "../../e2e_generated/win32/win32/windows/win32/system/system-information/Apis.js"; + +async function withTimeout(promise, timeoutMs, message, onTimeout = () => {}) { + let timer; + const timeout = new Promise((_, reject) => { + timer = setTimeout(() => { + try { + onTimeout(); + } finally { + reject(new Error(message)); + } + }, timeoutMs); + }); + try { + return await Promise.race([promise, timeout]); + } finally { + clearTimeout(timer); + } +} + +async function withAbortTimeout(start, timeoutMs, label) { + const controller = new AbortController(); + let timedOut = false; + const timer = setTimeout(() => { + timedOut = true; + controller.abort(); + }, timeoutMs); + try { + return await start(controller.signal); + } catch (error) { + if (timedOut && error.name === "AbortError") { + throw new Error(`${label} timed out`, { cause: error }); + } + throw error; + } finally { + clearTimeout(timer); + } +} + +const first = getTickCount64(); +await new Promise((resolve) => setTimeout(resolve, 10)); +const second = getTickCount64(); +assert.equal(typeof first, "bigint"); +assert(second >= first); + +const missing = getModuleHandleW("dynwinrt-module-that-is-not-loaded.dll"); +assert.equal(missing.result, 0n); +assert.equal(missing.lastError, 126); + +const kernel = getModuleHandleW("kernel32.dll").result; +assert.notEqual(kernel, 0n); +const proc = getProcAddress(kernel, Buffer.from("GetTickCount64\0", "ascii")); +assert.equal(typeof proc.result, "bigint"); +assert.notEqual(proc.result, 0n); + +const loadedKernelCall = loadLibraryW("kernel32.dll"); +const loadedKernel = loadedKernelCall.result; +assert(loadedKernel); +assert.equal(loadedKernel.closed, false); +assert.notEqual( + getProcAddress(loadedKernel, Buffer.from("GetTickCount64\0", "ascii")).result, + 0n, +); +loadedKernel.close(); +assert.equal(loadedKernel.closed, true); + +assert.equal(typeof ldapGetLastError(), "number"); +console.log("[win32-e2e] scalar, module, and cdecl calls passed"); + +let adapters = getAdaptersAddresses(0, 0, null); +assert.equal(adapters.result, 111); +assert(adapters.sizePointer > 0); +let adapterBuffer = Buffer.alloc(adapters.sizePointer); +adapters = getAdaptersAddresses(0, 0, adapterBuffer); +if (adapters.result === 111) { + adapterBuffer = Buffer.alloc(adapters.sizePointer); + adapters = getAdaptersAddresses(0, 0, adapterBuffer); +} +assert.equal(adapters.result, 0); +console.log("[win32-e2e] adapter buffer query passed"); + +const systemTime = createSYSTEMTIME(); +getSystemTime(systemTime); +const systemTimeBytes = systemTime.bytes; +const year = systemTimeBytes.readUInt16LE(0); +const month = systemTimeBytes.readUInt16LE(2); +assert(year >= 2020); +assert(month >= 1 && month <= 12); +console.log("[win32-e2e] system time aggregate passed"); + +const rectBytes = Buffer.alloc(16); +rectBytes.writeInt32LE(0, 0); +rectBytes.writeInt32LE(0, 4); +rectBytes.writeInt32LE(10, 8); +rectBytes.writeInt32LE(10, 12); +const pointBytes = Buffer.alloc(8); +pointBytes.writeInt32LE(5, 0); +pointBytes.writeInt32LE(5, 4); +assert.equal(ptInRect(createRECT(rectBytes), createPOINT(pointBytes)), true); +console.log("[win32-e2e] by-value POINT call passed"); + +const processHandle = openProcess(0x1000, false, process.pid); +assert(processHandle.result); +processHandle.result.close(); +assert(processHandle.result.closed); +console.log("[win32-e2e] OpenProcess ownership passed"); + +const attributes = createSecurityAttributes({ + securityDescriptor: null, + inheritHandle: false, +}); +console.log("[win32-e2e] SECURITY_ATTRIBUTES builder passed"); +const pipe = createPipe(attributes, 0); +console.log("[win32-e2e] CreatePipe call returned"); +assert.equal(pipe.result, true); +assert(pipe.hReadPipe); +assert(pipe.hWritePipe); +pipe.hReadPipe.close(); +pipe.hWritePipe.close(); +console.log("[win32-e2e] aggregate and resource calls passed"); + +const startupInfo = createStartupInfoW(); +const processInformation = createProcessInformation(); +const command = `"${process.env.ComSpec}" /d /c exit 0`; +const created = createProcessW( + null, + command, + null, + null, + false, + 0x08000000, + null, + startupInfo, + processInformation, +); +assert.equal( + created.result, + true, + `CreateProcessW failed: ${created.lastError}`, +); +assert(getProcessInformationProcessId(processInformation) > 0); +assert(getProcessInformationThreadId(processInformation) > 0); +const childProcess = takeProcessInformationProcess(processInformation); +const childThread = takeProcessInformationThread(processInformation); +assert(childProcess); +assert(childThread); +childProcess.close(); +childThread.close(); +assert.equal(takeProcessInformationProcess(processInformation), null); +assert.equal(takeProcessInformationThread(processInformation), null); + +const failedProcessInformation = createProcessInformation(); +const failedProcess = createProcessW( + null, + "dynwinrt-definitely-missing-executable.exe", + null, + null, + false, + 0x08000000, + null, + startupInfo, + failedProcessInformation, +); +assert.equal(failedProcess.result, false); +assert.throws( + () => getProcessInformationProcessId(failedProcessInformation), + /native call failed/, +); +assert.throws( + () => takeProcessInformationProcess(failedProcessInformation), + /native call failed/, +); +console.log("[win32-e2e] process creation and output ownership passed"); + +const asyncPath = join( + tmpdir(), + `dynwinrt-overlapped-${process.pid}-${Date.now()}.tmp`, +); +const asyncFileCall = createFileW( + asyncPath, + 0xc0000000, + 0, + null, + 2, + 0x40000080, + null, +); +assert(asyncFileCall.result, `CreateFileW failed: ${asyncFileCall.lastError}`); +const asyncFile = asyncFileCall.result; +console.log("[win32-e2e] starting file OVERLAPPED I/O"); +try { + const payload = Buffer.from("dynwinrt-overlapped"); + const aborted = new AbortController(); + aborted.abort(); + await assert.rejects( + readFileAsync(asyncFile, Buffer.alloc(1), 0n, aborted.signal), + (error) => error.name === "AbortError", + ); + let invalidSignal; + assert.doesNotThrow(() => { + invalidSignal = readFileAsync(asyncFile, Buffer.alloc(1), 0n, {}); + }); + await assert.rejects(invalidSignal, /signal must be an AbortSignal/); + assert.equal(asyncFile.busy, false); + assert.equal( + await withAbortTimeout( + (signal) => writeFileAsync(asyncFile, payload, 0n, signal), + 10000, + "file WriteFile", + ), + payload.length, + ); + const received = Buffer.alloc(payload.length); + assert.equal( + await withAbortTimeout( + (signal) => readFileAsync(asyncFile, received, 0n, signal), + 10000, + "file ReadFile", + ), + payload.length, + ); + assert.deepEqual(received, payload); + assert.equal( + await withAbortTimeout( + (signal) => + readFileAsync( + asyncFile, + Buffer.alloc(1), + BigInt(payload.length), + signal, + ), + 10000, + "file EOF ReadFile", + ), + 0, + ); +} finally { + asyncFile.close(); + await rm(asyncPath, { force: true }); +} +console.log("[win32-e2e] file OVERLAPPED I/O passed"); + +const pipePath = `\\\\.\\pipe\\dynwinrt-overlapped-cancel-${process.pid}-${Date.now()}`; +const pipeServer = createServer(); +pipeServer.listen(pipePath); +await withTimeout( + once(pipeServer, "listening"), + 10000, + "named-pipe server did not start", + () => pipeServer.close(), +); +const connected = once(pipeServer, "connection"); +const pipeClientCall = createFileW( + pipePath, + 0x80000000, + 0, + null, + 3, + 0x40000000, + null, +); +assert( + pipeClientCall.result, + `CreateFileW named pipe failed: ${pipeClientCall.lastError}`, +); +const pipeClient = pipeClientCall.result; +const [pipeServerSocket] = await withTimeout( + connected, + 10000, + "named-pipe client did not connect", + () => pipeServer.close(), +); +try { + const controller = new AbortController(); + const pendingRead = readFileAsync( + pipeClient, + Buffer.alloc(1), + 0n, + controller.signal, + ); + assert.equal(pipeClient.busy, true); + assert.throws(() => pipeClient.close(), /asynchronous I\/O is pending/); + const activeDeadline = Date.now() + 5000; + while (!pipeClient.active && Date.now() < activeDeadline) { + await new Promise((resolve) => setTimeout(resolve, 10)); + } + if (!pipeClient.active) { + controller.abort(); + await pendingRead.catch(() => {}); + assert.fail("named-pipe ReadFile did not enter ERROR_IO_PENDING"); + } + controller.abort(); + await assert.rejects( + pendingRead, + (error) => + error.name === "AbortError" && + /Win32 error 995/i.test(error.cause?.message ?? ""), + ); + assert.equal(pipeClient.active, false); + assert.equal(pipeClient.busy, false); + console.log("[win32-e2e] pending cancellation passed"); + + const poolController = new AbortController(); + const concurrentReads = Array.from({ length: 32 }, () => + readFileAsync(pipeClient, Buffer.alloc(1), 0n, poolController.signal), + ); + const poolDeadline = Date.now() + 5000; + while (!pipeClient.active && Date.now() < poolDeadline) { + await new Promise((resolve) => setTimeout(resolve, 10)); + } + assert.equal( + pipeClient.active, + true, + "concurrent reads did not enter pending I/O", + ); + await Promise.race([ + promisify(pbkdf2)("dynwinrt", "win32", 1, 16, "sha256"), + new Promise((_, reject) => + setTimeout( + () => + reject(new Error("OVERLAPPED reads exhausted the libuv worker pool")), + 2000, + ), + ), + ]); + poolController.abort(); + const cancelledReads = await withTimeout( + Promise.allSettled(concurrentReads), + 10000, + "bounded OVERLAPPED reads did not settle after cancellation", + () => pipeServerSocket.destroy(), + ); + assert( + cancelledReads.every( + (result) => + result.status === "rejected" && result.reason.name === "AbortError", + ), + ); + assert.equal(pipeClient.busy, false); + console.log("[win32-e2e] IOCP concurrency and libuv availability passed"); + + const detachable = new ArrayBuffer(1); + const detachedBuffer = Buffer.from(detachable); + const detachedController = new AbortController(); + const detachedRead = readFileAsync( + pipeClient, + detachedBuffer, + 0n, + detachedController.signal, + ); + const detachedDeadline = Date.now() + 5000; + while (!pipeClient.active && Date.now() < detachedDeadline) { + await new Promise((resolve) => setTimeout(resolve, 10)); + } + assert.equal( + pipeClient.active, + true, + "detachment read did not enter pending I/O", + ); + structuredClone(detachable, { transfer: [detachable] }); + assert.equal(detachedBuffer.length, 0); + pipeServerSocket.write(Buffer.from([42])); + await withTimeout( + assert.rejects(detachedRead, /backing ArrayBuffer was detached or changed/), + 10000, + "detached read did not settle", + () => detachedController.abort(), + ); + assert.equal(pipeClient.busy, false); + console.log("[win32-e2e] detached read rejection passed"); +} finally { + if (!pipeClient.busy) { + pipeClient.close(); + } + pipeServerSocket.destroy(); + await new Promise((resolve) => pipeServer.close(resolve)); +} +let closedRead; +assert.doesNotThrow(() => { + closedRead = readFileAsync(pipeClient, Buffer.alloc(1), 0n); +}); +await assert.rejects(closedRead, /closed Win32 resource/); + +roInitialize(1); +const activationFactory = DynWinRtValue.activationFactory( + "Windows.Foundation.Uri", +); +assert.equal(typeof coIsHandlerConnected(activationFactory), "boolean"); +activationFactory.release(); +console.log("[win32-e2e] WinRT compatibility assertion passed"); + +console.log("PASS"); diff --git a/tests/e2e/runners/win32/subsystems.mjs b/tests/e2e/runners/win32/subsystems.mjs new file mode 100644 index 00000000..625f10b1 --- /dev/null +++ b/tests/e2e/runners/win32/subsystems.mjs @@ -0,0 +1,108 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import assert from "node:assert/strict"; +import { createRequire } from "node:module"; +import { isMissingMediaFoundation } from "../../../../bindings/js/__test__/helpers/optional-media-foundation.mjs"; + +const require = createRequire(import.meta.url); +const native = require("../../../../bindings/js/dist/index.js"); +const originalRuntime = native.DynWin32; +const originalBind = native.win32Bind; +const initializers = new Set([ + "initializeWinsock", + "initializeGdiPlus", + "initializeMediaFoundation", + "initializeMapiUtilities", +]); +let importing = true; + +// Native static methods are immutable. Forward through a guarded class before +// the JS facades capture them; forbidden import-time calls fail, never fake success. +class ImportGuard {} +for (const name of Object.getOwnPropertyNames(originalRuntime)) { + if (["name", "length", "prototype"].includes(name)) continue; + const method = Object.getOwnPropertyDescriptor(originalRuntime, name).value; + if (typeof method !== "function") continue; + Object.defineProperty(ImportGuard, name, { + value: (...args) => { + if (initializers.has(name)) { + assert(!importing, `Namespace import must not call ${name}`); + } + return Reflect.apply(method, originalRuntime, args); + }, + }); +} +native.DynWin32 = ImportGuard; +native.win32Bind = (...args) => { + assert(!importing, "Namespace import must not bind Win32 exports"); + return Reflect.apply(originalBind, native, args); +}; +let namespaces; +try { + namespaces = await Promise.all([ + import("../../e2e_generated/win32/win32/windows/win32/networking/win-sock/Apis.js"), + import("../../e2e_generated/win32/win32/windows/win32/graphics/gdi-plus/Apis.js"), + import("../../e2e_generated/win32/win32/windows/win32/media/media-foundation/Apis.js"), + import("../../../../bindings/js/dist/winrt.js"), + import("../../../../bindings/js/dist/com.js"), + ]); +} finally { + importing = false; + native.DynWin32 = originalRuntime; + native.win32Bind = originalBind; +} +const [ + { initializeWinsock, wsaGetLastError, wsaSetLastError }, + { gdipGetImageDecodersSize, initializeGdiPlus }, + { initializeMediaFoundation, mfGetTimerPeriodicity }, + winrt, + com, +] = namespaces; +assert.equal(typeof winrt.WinGuid.parse, "function"); +assert.equal(typeof com.initializeCom, "function"); +console.log( + "PASS namespace and WinRT/COM imports without Win32 binding or subsystem startup", +); + +const winsock = initializeWinsock(); +assert.equal(winsock.subsystem, "winsock"); +wsaSetLastError(winsock, 12345); +assert.equal(wsaGetLastError().result, 12345); +winsock.close(); +assert.throws(() => wsaSetLastError(winsock, 0), /context is closed/); + +const gdiplus = initializeGdiPlus(); +assert.equal(gdiplus.subsystem, "gdiplus"); +const decoders = gdipGetImageDecodersSize(gdiplus); +assert.equal(decoders.result, 0); +assert(decoders.numDecoders > 0); +assert(decoders.size > 0); +gdiplus.close(); +assert.throws(() => gdipGetImageDecodersSize(gdiplus), /context is closed/); + +let mediaFoundation; +try { + mediaFoundation = initializeMediaFoundation(); +} catch (error) { + if (!isMissingMediaFoundation(error)) throw error; + console.log( + `SKIP optional Media Foundation calls; initialization reported: ${error.message}`, + ); +} +if (mediaFoundation) { + try { + assert.equal(mediaFoundation.subsystem, "mediaFoundation"); + const timer = mfGetTimerPeriodicity(mediaFoundation); + assert.equal(timer.status, 0); + assert(timer.periodicity > 0); + } finally { + mediaFoundation.close(); + } + assert.throws( + () => mfGetTimerPeriodicity(mediaFoundation), + /context is closed/, + ); +} + +console.log("PASS"); diff --git a/tests/e2e/typecheck/win32_contracts.ts b/tests/e2e/typecheck/win32_contracts.ts new file mode 100644 index 00000000..74f79b03 --- /dev/null +++ b/tests/e2e/typecheck/win32_contracts.ts @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DynWin32Resource } from "../../../bindings/js/dist/win32.js"; +import { + getTickCount, + getTickCount64, + createSYSTEMTIME, + getSystemTime, +} from "../e2e_generated/win32/win32/windows/win32/system/system-information/Apis.js"; +import { + regCloseKey, + regOpenKeyExW, + regQueryValueExW, +} from "../e2e_generated/win32/win32/windows/win32/system/registry/Apis.js"; +import { + readFileAsync, + writeFileAsync, +} from "../e2e_generated/win32/win32/windows/win32/storage/file-system/Apis.js"; + +const ticks: number = getTickCount(); +const ticks64: bigint = getTickCount64(); +void [ticks, ticks64]; +const time = createSYSTEMTIME(); +getSystemTime(time); +const machine = 0x80000002n; +const opened = regOpenKeyExW(machine, "SOFTWARE", 0, 1); +const status: number = opened.status; +void status; +if (opened.key instanceof DynWin32Resource) { + const key: DynWin32Resource = opened.key; + const result = regQueryValueExW(key, null, new Uint8Array(16)); + const count: number | null = result.dataSize; + void count; + const closed: number = regCloseKey(key).status; + void closed; +} + +function asyncIo(file: DynWin32Resource, bytes: Buffer, signal: AbortSignal) { + const read: Promise = readFileAsync(file, bytes, 0n, signal); + const write: Promise = writeFileAsync(file, bytes, 0n, signal); + return [read, write]; +} +void asyncIo; + +// @ts-expect-error raw handles cannot be consumed as managed resources +regCloseKey(machine); +// @ts-expect-error byte storage is not a numeric HKEY value +regOpenKeyExW(Buffer.alloc(8), null, 0, 1); +// @ts-expect-error raw addresses cannot supply byte storage +regQueryValueExW(machine, null, 123n); diff --git a/tools/dynwinrt-codegen/Cargo.toml b/tools/dynwinrt-codegen/Cargo.toml index e8b7e426..dca7ea07 100644 --- a/tools/dynwinrt-codegen/Cargo.toml +++ b/tools/dynwinrt-codegen/Cargo.toml @@ -9,6 +9,7 @@ authors = ["Microsoft"] [dependencies] dynwinrt-com-contracts = { path = "../../crates/dynwinrt-com-contracts", version = "0.1.0" } +dynwinrt-win32-contracts = { path = "../../crates/dynwinrt-win32-contracts", version = "0.1.0" } windows-metadata = "0.59.0" clap = { version = "4", features = ["derive"] } csv = "1" @@ -20,6 +21,7 @@ serde_json = "1" sha2 = "0.10" [dev-dependencies] +dynwinrt-win32-contracts = { path = "../../crates/dynwinrt-win32-contracts", features = ["schema"] } regex = "1" [dev-dependencies.windows] diff --git a/tools/dynwinrt-codegen/E2E_TEST.md b/tools/dynwinrt-codegen/E2E_TEST.md index 2668728a..ddbdd6af 100644 --- a/tools/dynwinrt-codegen/E2E_TEST.md +++ b/tools/dynwinrt-codegen/E2E_TEST.md @@ -169,14 +169,18 @@ A file picker dialog will open. Select a file (filtered to .png/.jpg/.txt) to co The repository's canonical cross-language specs are in [`tests/e2e/e2e_specs.json`](../../tests/e2e/e2e_specs.json). The orchestrator -generates temporary bindings and runs the JavaScript/TypeScript, Python, or -Classic COM runners. From the repository root: +generates temporary bindings and runs the WinRT JavaScript/TypeScript and +Python runners, plus separate Classic COM and flat Win32 runners. From the +repository root: ```powershell .\tests\e2e\e2e_test.ps1 -Lang ts .\tests\e2e\e2e_test.ps1 -Lang py .\tests\e2e\e2e_test.ps1 -Lang com +.\tests\e2e\e2e_test.ps1 -Lang win32 ``` -The Classic COM suite also requires `DYNWINRT_WIN32_WINMD` or an installed -`Microsoft.Windows.SDK.Win32Metadata` package. +The Classic COM and flat Win32 suites require `DYNWINRT_WIN32_WINMD` or an +installed `Microsoft.Windows.SDK.Win32Metadata` package. The Win32 suite uses +the runners in `tests\e2e\runners\win32` to exercise Registry buffers, resource +cleanup, native structures, IOCP, subsystem loading, and package isolation. diff --git a/tools/dynwinrt-codegen/README.md b/tools/dynwinrt-codegen/README.md index 22487db0..4be31bec 100644 --- a/tools/dynwinrt-codegen/README.md +++ b/tools/dynwinrt-codegen/README.md @@ -7,6 +7,8 @@ bindings for [dynwinrt](https://github.com/microsoft/dynwinrt): - WinRT Python (`.py`) with type stubs (`.pyi`) and a `py.typed` marker - Supported Classic COM APIs from `Windows.Win32.winmd` as JavaScript and TypeScript +- Contract-driven Win32 DLL exports from `Windows.Win32.winmd` as JavaScript + and TypeScript The command is available for Windows x64 and ARM64. Generated JavaScript uses `@microsoft/dynwinrt`; generated Python uses `dynwinrt`. @@ -50,7 +52,7 @@ package. | `--winmd-list FILE` | Newline-separated metadata paths to emit; blank lines and `#` comments are ignored. | | `--folder DIR` | Load every `.winmd` file directly inside a directory. | | `--namespace NS` | Generate one namespace. Without it, generate all non-`Windows.*` namespaces in the input. | -| `--class-name NAME[,NAME...]` | Generate specific classes or public interfaces. Use fully qualified names, or unqualified names together with `--namespace`. | +| `--class-name NAME[,NAME...]` | Generate specific classes, public interfaces, or native `Apis` containers. Use fully qualified names, or unqualified names together with `--namespace`. | | `--ref PATH[;PATH...]` | Metadata used only for type resolution. Sibling discovery is disabled for references. | | `--ref-list FILE` | Newline-separated reference metadata paths; blank lines and `#` comments are ignored. | | `--lang js\|py` | `js` emits CommonJS `.js`, an ESM facade, and `.d.ts` files (default); `py` emits `.py`, `.pyi`, and `py.typed`. | @@ -97,6 +99,31 @@ dynwinrt-codegen generate ` --dry-run ``` +### Contract-driven flat Win32 + +Generate JavaScript bindings and TypeScript declarations for Win32 DLL exports +from `Windows.Win32.winmd`. Built-in contracts are validated against the pinned +`Microsoft.Windows.SDK.Win32Metadata` `71.0.14-preview` package. Metadata +provides native ABI facts; the independent Win32 registry supplies explicit +ownership, buffer, and lifecycle evidence where required. + +```powershell +dynwinrt-codegen generate ` + --winmd $env:DYNWINRT_WIN32_WINMD ` + --class-name "Windows.Win32.System.SystemInformation.Apis,Windows.Win32.System.Registry.Apis" ` + --output .\generated +``` + +`--namespace Windows.Win32.System.Registry` is equivalent to selecting its +`Apis` container. Unsupported shapes are explicitly diagnosed. Generated modules live under +`win32/windows/win32/system/registry/` and +`win32/windows/win32/system/system-information/`, outside the WinRT root. +The runtime package must include the matching `win32` entrypoint. The +`win32-census --winmd --json` command reports eligible exports and complete +projections. Support requires validated ABI, ownership, and lifecycle contracts; +unsupported APIs remain explicit diagnostics. +See the [supported capabilities and contract architecture](../../docs/architecture/flat-win32-contracts.md). + ### Other commands `dynwinrt-codegen capabilities` prints the command's supported features, one @@ -159,6 +186,63 @@ cargo test -p dynwinrt-codegen Official npm and PyPI packages are built and published by the repository release pipelines. +### Win32 result contracts + +Flat Win32 generation uses `dynwinrt-win32-contracts` as its single wire-protocol +authority. Native metadata still determines pointer depth, constness, encoding, +type identity, and ownership provenance. After caller-owned buffers become +physical input pointers, projection resolves a version 3 descriptor covering +every direct return, native output cell, and declared aggregate result field. +Version 1 and slot-only version 2 descriptors remain readable; aggregate field +targets require version 3. + +`contracts\win32\function-contracts.json` accepts `result-contract` effects +containing the shared `ResultContract` type. These replace the default or +upgraded policy for that native target; legacy `call-contract` evidence remains +readable. New generation uses `upgrade_metadata()`: legacy ownership evidence +alone does not establish defined output storage on failure, so owned failure +results default to undefined. An explicit result policy may instead guarantee a +defined failure result, including a discarded owned value requiring cleanup. +Historical version 1 cleanup behavior is confined to compatibility decoding; +ordinary scalar/status/count defaults remain unchanged. +Success, failure, and disjoint conditional overrides distinguish +undefined storage from defined values, ownership/cleanup, and delivery/discard. +Projection derives nullable results and resource conversions from those +policies; renderers neither infer ownership nor bind native functions on import. + +An Out/InOut aggregate pointer retains its exact layout in `pointeeDescriptor`, +separately from the by-value-only `aggregateDescriptor`. Its physical ABI remains +Pointer/In, not pointer-to-pointer. The native descriptor's `outputFields` lists +evidenced result fields in native declaration order; `aggregate-field` targets +index that list and the native parameter, not the physical output cells. +`PROCESS_INFORMATION` therefore has four field results: two independently owned +CloseHandle resources and two scalar IDs. All four default to undefined on +failure unless reviewed result evidence states otherwise. + +Generated builders, native-struct arguments, and pointee specifications share +one descriptor constant. Native invocation prepares and registers field +lifetimes before any return conversion or JavaScript wrapping; generated code +does not call the manual `prepareNativeStructCall`/`markNativeStructCallResult` +helpers. The caller still owns the structure bytes, and existing field getters +and take-resource helpers keep their names and types. Unknown owned arrays, +unions, and nested result shapes fail closed. + +The production registry schema references generated +`contracts\win32\call-contract.schema.json`, not a second handwritten protocol. +After changing the shared protocol or reviewed registry data, update its schema +and LF-normalized production manifest hashes using the existing test runner: + +```powershell +$env:DYNWINRT_UPDATE_WIN32_SCHEMA = '1' +cargo test -p dynwinrt-codegen --test win32_contract_schema_test +Remove-Item Env:DYNWINRT_UPDATE_WIN32_SCHEMA +``` + +Without the update variable, the same test checks schema and manifest +consistency. Synthetic result matrices cover failure-only cleanup/delivery +combinations; metadata regressions and complete CommonJS/ESM/TypeScript module +tests preserve the pinned 8,936/18,321 export census. + ## License [MIT](https://github.com/microsoft/dynwinrt/blob/main/LICENSE) diff --git a/tools/dynwinrt-codegen/TYPE_COVERAGE.md b/tools/dynwinrt-codegen/TYPE_COVERAGE.md index 3b90b774..26b54b1e 100644 --- a/tools/dynwinrt-codegen/TYPE_COVERAGE.md +++ b/tools/dynwinrt-codegen/TYPE_COVERAGE.md @@ -8,8 +8,9 @@ This document summarizes the current language projections across: - the JavaScript/TypeScript and Python generators in `tools/dynwinrt-codegen`. -Classic COM has a separate semantic type system and safety boundary. See -[Classic COM support](../../docs/architecture/classic-com-support.md) instead +Classic COM and flat Win32 each have their own semantic type system and safety +boundary. See [Classic COM support](../../docs/architecture/classic-com-support.md) +and [flat Win32 support](../../docs/architecture/flat-win32-contracts.md) instead of applying the WinRT mappings below to `Windows.Win32.winmd`. ## Scalar and foundation types @@ -134,6 +135,7 @@ Current limits that affect type coverage: 2. JavaScript GUID and Boolean arrays use per-element conversion rather than a dedicated bulk fast path. 3. Python does not yet expose a zero-copy buffer protocol for WinRT buffers. -4. Classic COM, native Win32 pointers, Automation variants, SAFEARRAY, and - ownership-specific outputs use the separate fail-closed COM model and - currently generate only JavaScript/TypeScript. +4. Classic COM methods, including their native pointers, Automation variants, + SAFEARRAY, and ownership-specific outputs, use the fail-closed COM model. + Flat Win32 DLL exports use an independent native ABI and contract model. + Both currently generate only JavaScript/TypeScript. diff --git a/tools/dynwinrt-codegen/contracts/win32/aggregate-layouts.json b/tools/dynwinrt-codegen/contracts/win32/aggregate-layouts.json new file mode 100644 index 00000000..f856ae00 --- /dev/null +++ b/tools/dynwinrt-codegen/contracts/win32/aggregate-layouts.json @@ -0,0 +1,338 @@ +{ + "schemaVersion": 2, + "entries": [ + { + "id": "windows.win32.security.security_attributes.aggregate.v1", + "selector": { + "name": "SECURITY_ATTRIBUTES", + "namespace": "Windows.Win32.Security", + "sourceFingerprint": "0C8B0DFE8C63D2E716EF71F6E320E9CABF0C3B1C551CDEA5129D818E4481F1CD" + }, + "meaning": null, + "status": null, + "aggregate": { + "builder": "security-attributes", + "sizeField": "nLength", + "fields": [ + { + "name": "lpSecurityDescriptor", + "contract": { + "kind": "retained-pointer", + "nullable": true, + "optional": true + } + }, + { + "name": "bInheritHandle", + "contract": { + "kind": "boolean-input", + "optional": true + } + } + ], + "anonymousLayouts": [] + }, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wtypesbase/ns-wtypesbase-security_attributes" + } + ] + }, + { + "id": "windows.win32.system.systeminformation.system_info.aggregate.v1", + "selector": { + "name": "SYSTEM_INFO", + "namespace": "Windows.Win32.System.SystemInformation", + "sourceFingerprint": "D09B912AE8927F5812563C0D369B3CC911726F256FA5F032CE637EC0C0CF7AA9" + }, + "meaning": null, + "status": null, + "aggregate": { + "builder": null, + "sizeField": null, + "fields": [], + "anonymousLayouts": [ + { + "name": "_Anonymous_e__Union", + "kind": "union", + "fields": [ + { + "name": "dwOemId", + "typ": { + "kind": "scalar", + "scalar": "u32" + } + }, + { + "name": "Anonymous", + "typ": { + "kind": "record", + "layout": { + "name": "_Anonymous_e__Struct", + "kind": "struct", + "fields": [ + { + "name": "wProcessorArchitecture", + "typ": { + "kind": "named", + "namespace": "Windows.Win32.System.SystemInformation", + "name": "PROCESSOR_ARCHITECTURE" + } + }, + { + "name": "wReserved", + "typ": { + "kind": "scalar", + "scalar": "u16" + } + } + ] + } + } + } + ] + } + ] + }, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/sysinfoapi/ns-sysinfoapi-system_info" + } + ] + }, + { + "id": "windows.win32.system.threading.process_information.aggregate.v1", + "selector": { + "name": "PROCESS_INFORMATION", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "E7AF95290D9D7219964EBA8D741BA490EF6CB2CBE5EA142E037614358A9C2DCD" + }, + "meaning": null, + "status": null, + "aggregate": { + "builder": "process-information", + "sizeField": null, + "fields": [ + { + "name": "hProcess", + "contract": { + "kind": "owned-handle", + "cleanup": "close-handle" + } + }, + { + "name": "hThread", + "contract": { + "kind": "owned-handle", + "cleanup": "close-handle" + } + }, + { + "name": "dwProcessId", + "contract": { + "kind": "output-u32" + } + }, + { + "name": "dwThreadId", + "contract": { + "kind": "output-u32" + } + } + ], + "anonymousLayouts": [] + }, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/ns-processthreadsapi-process_information" + } + ] + }, + { + "id": "windows.win32.system.threading.startupinfoa.aggregate.v1", + "selector": { + "name": "STARTUPINFOA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "9B674C4E78BA214FF983509D5160DF065A790B7F345EB4844EA0FA07DB4D1916" + }, + "meaning": null, + "status": null, + "aggregate": { + "builder": "startup-info-ansi", + "sizeField": "cb", + "fields": [ + { + "name": "lpReserved", + "contract": { + "kind": "null-pointer" + } + }, + { + "name": "lpDesktop", + "contract": { + "kind": "null-pointer" + } + }, + { + "name": "lpTitle", + "contract": { + "kind": "null-pointer" + } + }, + { + "name": "lpReserved2", + "contract": { + "kind": "null-pointer" + } + }, + { + "name": "hStdInput", + "contract": { + "kind": "borrowed-handle" + } + }, + { + "name": "hStdOutput", + "contract": { + "kind": "borrowed-handle" + } + }, + { + "name": "hStdError", + "contract": { + "kind": "borrowed-handle" + } + } + ], + "anonymousLayouts": [] + }, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfoa" + } + ] + }, + { + "id": "windows.win32.system.threading.startupinfow.aggregate.v1", + "selector": { + "name": "STARTUPINFOW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "A73DE73910A1548283EF2EF21856412BDEC141ACC0CEFEFFC9E14013BF60219A" + }, + "meaning": null, + "status": null, + "aggregate": { + "builder": "startup-info-wide", + "sizeField": "cb", + "fields": [ + { + "name": "lpReserved", + "contract": { + "kind": "null-pointer" + } + }, + { + "name": "lpDesktop", + "contract": { + "kind": "null-pointer" + } + }, + { + "name": "lpTitle", + "contract": { + "kind": "null-pointer" + } + }, + { + "name": "lpReserved2", + "contract": { + "kind": "null-pointer" + } + }, + { + "name": "hStdInput", + "contract": { + "kind": "borrowed-handle" + } + }, + { + "name": "hStdOutput", + "contract": { + "kind": "borrowed-handle" + } + }, + { + "name": "hStdError", + "contract": { + "kind": "borrowed-handle" + } + } + ], + "anonymousLayouts": [] + }, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfow" + } + ] + }, + { + "id": "windows.win32.ui.input.keyboardandmouse.input.aggregate.v1", + "selector": { + "name": "INPUT", + "namespace": "Windows.Win32.UI.Input.KeyboardAndMouse", + "sourceFingerprint": "653DA3080AC93C9CA6CBF43F908E629485A6FB9EF5C7591BEA794165509A75BF" + }, + "meaning": null, + "status": null, + "aggregate": { + "builder": null, + "sizeField": null, + "fields": [], + "anonymousLayouts": [ + { + "name": "_Anonymous_e__Union", + "kind": "union", + "fields": [ + { + "name": "mi", + "typ": { + "kind": "named", + "namespace": "Windows.Win32.UI.Input.KeyboardAndMouse", + "name": "MOUSEINPUT" + } + }, + { + "name": "ki", + "typ": { + "kind": "named", + "namespace": "Windows.Win32.UI.Input.KeyboardAndMouse", + "name": "KEYBDINPUT" + } + }, + { + "name": "hi", + "typ": { + "kind": "named", + "namespace": "Windows.Win32.UI.Input.KeyboardAndMouse", + "name": "HARDWAREINPUT" + } + } + ] + } + ] + }, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winuser/ns-winuser-input" + } + ] + } + ] +} diff --git a/tools/dynwinrt-codegen/contracts/win32/call-contract.schema.json b/tools/dynwinrt-codegen/contracts/win32/call-contract.schema.json new file mode 100644 index 00000000..8ea81f1b --- /dev/null +++ b/tools/dynwinrt-codegen/contracts/win32/call-contract.schema.json @@ -0,0 +1,471 @@ +{ + "$defs": { + "Cleanup": { + "enum": [ + "none", + "close-handle", + "reg-close-key", + "local-free", + "global-free", + "free-library", + "close-service-handle", + "co-task-mem-free", + "cred-free" + ], + "type": "string" + }, + "Condition": { + "additionalProperties": false, + "properties": { + "inputs": { + "default": [], + "items": { + "$ref": "#/$defs/InputPredicate" + }, + "type": "array" + }, + "returnValue": { + "default": null, + "format": "uint64", + "minimum": 0, + "type": [ + "integer", + "null" + ] + }, + "succeeded": { + "default": null, + "type": [ + "boolean", + "null" + ] + } + }, + "type": "object" + }, + "Delivery": { + "enum": [ + "deliver", + "discard" + ], + "type": "string" + }, + "InputPredicate": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "bits-in", + "type": "string" + }, + "mask": { + "format": "uint64", + "minimum": 0, + "type": "integer" + }, + "parameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + }, + "values": { + "items": { + "format": "uint64", + "minimum": 0, + "type": "integer" + }, + "type": "array" + } + }, + "required": [ + "kind", + "parameter", + "mask", + "values" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "handle-in", + "type": "string" + }, + "parameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + }, + "values": { + "items": { + "format": "int64", + "type": "integer" + }, + "type": "array" + } + }, + "required": [ + "kind", + "parameter", + "values" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "elementWidth": { + "format": "uint8", + "maximum": 255, + "minimum": 0, + "type": "integer" + }, + "kind": { + "const": "null-or-empty", + "type": "string" + }, + "parameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + } + }, + "required": [ + "kind", + "parameter", + "elementWidth" + ], + "type": "object" + } + ] + }, + "OutputAction": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "unavailable", + "type": "string" + } + }, + "required": [ + "kind" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "alias-input", + "type": "string" + }, + "parameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + } + }, + "required": [ + "kind", + "parameter" + ], + "type": "object" + } + ] + }, + "OutputRule": { + "additionalProperties": false, + "properties": { + "action": { + "$ref": "#/$defs/OutputAction" + }, + "parameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + }, + "when": { + "$ref": "#/$defs/Condition" + } + }, + "required": [ + "parameter", + "when", + "action" + ], + "type": "object" + }, + "ResourceEffect": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "flagsParameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + }, + "handleParameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + }, + "kind": { + "const": "add-file-completion-modes", + "type": "string" + } + }, + "required": [ + "kind", + "handleParameter", + "flagsParameter" + ], + "type": "object" + } + ] + }, + "ResultContract": { + "additionalProperties": false, + "properties": { + "onFailure": { + "$ref": "#/$defs/ResultPolicy" + }, + "onSuccess": { + "$ref": "#/$defs/ResultPolicy" + }, + "overrides": { + "default": [], + "items": { + "$ref": "#/$defs/ResultOverride" + }, + "type": "array" + }, + "target": { + "$ref": "#/$defs/ResultTarget" + } + }, + "required": [ + "target", + "onSuccess", + "onFailure" + ], + "type": "object" + }, + "ResultOverride": { + "additionalProperties": false, + "properties": { + "policy": { + "$ref": "#/$defs/ResultPolicy" + }, + "when": { + "$ref": "#/$defs/Condition" + } + }, + "required": [ + "when", + "policy" + ], + "type": "object" + }, + "ResultOwnership": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "value", + "type": "string" + } + }, + "required": [ + "kind" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "borrowed", + "type": "string" + } + }, + "required": [ + "kind" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "cleanup": { + "$ref": "#/$defs/Cleanup" + }, + "kind": { + "const": "owned", + "type": "string" + } + }, + "required": [ + "kind", + "cleanup" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "alias-input", + "type": "string" + }, + "parameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + } + }, + "required": [ + "kind", + "parameter" + ], + "type": "object" + } + ] + }, + "ResultPolicy": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "undefined", + "type": "string" + } + }, + "required": [ + "kind" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "delivery": { + "$ref": "#/$defs/Delivery" + }, + "kind": { + "const": "defined", + "type": "string" + }, + "ownership": { + "$ref": "#/$defs/ResultOwnership" + } + }, + "required": [ + "kind", + "ownership", + "delivery" + ], + "type": "object" + } + ] + }, + "ResultTarget": { + "oneOf": [ + { + "additionalProperties": false, + "properties": { + "kind": { + "const": "return", + "type": "string" + } + }, + "required": [ + "kind" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "index": { + "format": "uint", + "minimum": 0, + "type": "integer" + }, + "kind": { + "const": "parameter", + "type": "string" + } + }, + "required": [ + "kind", + "index" + ], + "type": "object" + }, + { + "additionalProperties": false, + "properties": { + "field": { + "format": "uint", + "minimum": 0, + "type": "integer" + }, + "kind": { + "const": "aggregate-field", + "type": "string" + }, + "parameter": { + "format": "uint", + "minimum": 0, + "type": "integer" + } + }, + "required": [ + "kind", + "parameter", + "field" + ], + "type": "object" + } + ] + } + }, + "$schema": "https://json-schema.org/draft/2020-12/schema", + "additionalProperties": false, + "properties": { + "outputs": { + "items": { + "$ref": "#/$defs/OutputRule" + }, + "type": "array" + }, + "resourceEffects": { + "default": [], + "items": { + "$ref": "#/$defs/ResourceEffect" + }, + "type": "array" + }, + "results": { + "items": { + "$ref": "#/$defs/ResultContract" + }, + "type": "array" + }, + "version": { + "default": 1, + "format": "uint32", + "minimum": 0, + "type": "integer" + } + }, + "title": "CallContract", + "type": "object" +} diff --git a/tools/dynwinrt-codegen/contracts/win32/function-contracts.json b/tools/dynwinrt-codegen/contracts/win32/function-contracts.json new file mode 100644 index 00000000..34a583bc --- /dev/null +++ b/tools/dynwinrt-codegen/contracts/win32/function-contracts.json @@ -0,0 +1,2707 @@ +{ + "schemaVersion": 2, + "entries": [ + { + "id": "windows.win32.foundation.apis.closehandle.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CloseHandle", + "name": "CloseHandle", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "6CC40ADE2BD555C000E741D8BD165DC88E59B30DCEAAC602CB321B50DD80700F" + }, + "contracts": [ + { + "kind": "consumed-input", + "parameter": 0, + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/handleapi/nf-handleapi-closehandle" + } + ] + }, + { + "id": "windows.win32.foundation.apis.freelibrary.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "FreeLibrary", + "name": "FreeLibrary", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "DE7EC93DF2DC862859236646159AC421F3E79B671325DD7C423BFEDA3C258E66" + }, + "contracts": [ + { + "kind": "consumed-input", + "parameter": 0, + "cleanup": "free-library" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-freelibrary" + }, + { + "kind": "sdk-header", + "file": "libloaderapi.h" + } + ] + }, + { + "id": "windows.win32.globalization.apis.foldstringa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "FoldStringA", + "name": "FoldStringA", + "namespace": "Windows.Win32.Globalization", + "sourceFingerprint": "6E8160197FABAF9EB6486ABEB6B5E3326685FB1C10B18698E544E0401E8CA3CA" + }, + "contracts": [ + { + "kind": "counted-buffer", + "parameter": 3, + "countParameter": 4, + "nullable": true + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-foldstringa" + } + ] + }, + { + "id": "windows.win32.globalization.apis.foldstringw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "FoldStringW", + "name": "FoldStringW", + "namespace": "Windows.Win32.Globalization", + "sourceFingerprint": "1B5D2B3C7C259F5CB05D453BFE27104202E5EA6C9C88274BBE2FE6A5F5FF4162" + }, + "contracts": [ + { + "kind": "counted-buffer", + "parameter": 3, + "countParameter": 4, + "nullable": true + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/stringapiset/nf-stringapiset-foldstringw" + } + ] + }, + { + "id": "windows.win32.globalization.apis.getlocaleinfoa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "GetLocaleInfoA", + "name": "GetLocaleInfoA", + "namespace": "Windows.Win32.Globalization", + "sourceFingerprint": "3EEE9B5DB794DC2181E1018F6F97694D1401C6391A433C94FA2DDA1B9F32BD1C" + }, + "contracts": [ + { + "kind": "counted-buffer", + "parameter": 2, + "countParameter": 3, + "nullable": true + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-getlocaleinfoa" + } + ] + }, + { + "id": "windows.win32.globalization.apis.getlocaleinfoex.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "GetLocaleInfoEx", + "name": "GetLocaleInfoEx", + "namespace": "Windows.Win32.Globalization", + "sourceFingerprint": "AA5A178482745CF8E284C2A3FB1431ECA16E8CBA18C17BBA57FE8AFE91355D5A" + }, + "contracts": [ + { + "kind": "counted-buffer", + "parameter": 2, + "countParameter": 3, + "nullable": true + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-getlocaleinfoex" + } + ] + }, + { + "id": "windows.win32.globalization.apis.getlocaleinfow.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "GetLocaleInfoW", + "name": "GetLocaleInfoW", + "namespace": "Windows.Win32.Globalization", + "sourceFingerprint": "FAB4847056D4EDA237D39ABDD2E2DF06A439EDB4DC03BE2CD9B0056FD7729691" + }, + "contracts": [ + { + "kind": "counted-buffer", + "parameter": 2, + "countParameter": 3, + "nullable": true + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-getlocaleinfow" + } + ] + }, + { + "id": "windows.win32.globalization.apis.lcmapstringa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "LCMapStringA", + "name": "LCMapStringA", + "namespace": "Windows.Win32.Globalization", + "sourceFingerprint": "F34DF8704356CA87118A20BAA7639BB69CE51FABE1EA6799D1144134E753EF5A" + }, + "contracts": [ + { + "kind": "counted-buffer", + "parameter": 4, + "countParameter": 5, + "nullable": true + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-lcmapstringa" + } + ] + }, + { + "id": "windows.win32.globalization.apis.lcmapstringex.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "LCMapStringEx", + "name": "LCMapStringEx", + "namespace": "Windows.Win32.Globalization", + "sourceFingerprint": "B847145415B55F611524E6262A75FDE25C30A4E6747AB99946E2FB71630EBD74" + }, + "contracts": [ + { + "kind": "unsupported-count-unit", + "parameter": 4 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-lcmapstringex" + } + ] + }, + { + "id": "windows.win32.globalization.apis.lcmapstringw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "LCMapStringW", + "name": "LCMapStringW", + "namespace": "Windows.Win32.Globalization", + "sourceFingerprint": "641C40498EB13926BCB3336493FD30D25ABA1A2D948C010F9E9398F3B258A468" + }, + "contracts": [ + { + "kind": "unsupported-count-unit", + "parameter": 4 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-lcmapstringw" + } + ] + }, + { + "id": "windows.win32.storage.filesystem.apis.createfilea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateFileA", + "name": "CreateFileA", + "namespace": "Windows.Win32.Storage.FileSystem", + "sourceFingerprint": "1B942058C20D35F9BC690E89D2B0BFFC5A95738231CF8F180E9E56E198C127E1" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + }, + { + "kind": "result-contract", + "contract": { + "target": { "kind": "return" }, + "onSuccess": { + "kind": "defined", + "ownership": { "kind": "owned", "cleanup": "close-handle" }, + "delivery": "deliver" + }, + "onFailure": { "kind": "undefined" }, + "overrides": [] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-createfilea" + } + ] + }, + { + "id": "windows.win32.storage.filesystem.apis.createfilew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateFileW", + "name": "CreateFileW", + "namespace": "Windows.Win32.Storage.FileSystem", + "sourceFingerprint": "3C58D88E04386869F6EEA10BFD485C7E14D831144595EAE2540255FEA1669362" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + }, + { + "kind": "result-contract", + "contract": { + "target": { "kind": "return" }, + "onSuccess": { + "kind": "defined", + "ownership": { "kind": "owned", "cleanup": "close-handle" }, + "delivery": "deliver" + }, + "onFailure": { "kind": "undefined" }, + "overrides": [] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-createfilew" + } + ] + }, + { + "id": "windows.win32.storage.filesystem.apis.readfile.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "ReadFile", + "name": "ReadFile", + "namespace": "Windows.Win32.Storage.FileSystem", + "sourceFingerprint": "4E63EAF55ACE1640DC86F26A27472491850FC58565D69A25020A46DA8D30EC4B" + }, + "contracts": [ + { + "kind": "overlapped-io", + "operation": "read", + "fileParameter": 0, + "bufferParameter": 1, + "countParameter": 2, + "transferredParameter": 3, + "overlappedParameter": 4 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-readfile" + } + ] + }, + { + "id": "windows.win32.storage.filesystem.apis.setfilecompletionnotificationmodes.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "SetFileCompletionNotificationModes", + "name": "SetFileCompletionNotificationModes", + "namespace": "Windows.Win32.Storage.FileSystem", + "sourceFingerprint": "2E74759C4B8596718484FD123CD014E74C8BB71CF49A852DAB2547C7D8FCBBE6" + }, + "contracts": [ + { + "kind": "call-contract", + "contract": { + "resourceEffects": [ + { + "kind": "add-file-completion-modes", + "handleParameter": 0, + "flagsParameter": 1 + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setfilecompletionnotificationmodes" + } + ] + }, + { + "id": "windows.win32.storage.filesystem.apis.writefile.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "WriteFile", + "name": "WriteFile", + "namespace": "Windows.Win32.Storage.FileSystem", + "sourceFingerprint": "9663326055F7C9CA936AEAC07096EB8B86895052E112C280AACB6EF2CC68462C" + }, + "contracts": [ + { + "kind": "overlapped-io", + "operation": "write", + "fileParameter": 0, + "bufferParameter": 1, + "countParameter": 2, + "transferredParameter": 3, + "overlappedParameter": 4 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-writefile" + } + ] + }, + { + "id": "windows.win32.system.jobobjects.apis.createjobobjecta.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateJobObjectA", + "name": "CreateJobObjectA", + "namespace": "Windows.Win32.System.JobObjects", + "sourceFingerprint": "2336A6B855F785E39D305E35054CCA6D2369E93A564C81D256215AE789B52D0B" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-createjobobjecta" + } + ] + }, + { + "id": "windows.win32.system.jobobjects.apis.createjobobjectw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateJobObjectW", + "name": "CreateJobObjectW", + "namespace": "Windows.Win32.System.JobObjects", + "sourceFingerprint": "9026747185ED522B3B6649C5D21C8ACFA6A5EB6F630BF972791AA272ED1B911B" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/jobapi2/nf-jobapi2-createjobobjectw" + } + ] + }, + { + "id": "windows.win32.system.jobobjects.apis.openjobobjecta.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenJobObjectA", + "name": "OpenJobObjectA", + "namespace": "Windows.Win32.System.JobObjects", + "sourceFingerprint": "6DB94200E6874D8421AB726BD5A3E3833EBC91C1576538FFD3C197D5366ED4FE" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-openjobobjecta" + } + ] + }, + { + "id": "windows.win32.system.jobobjects.apis.openjobobjectw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenJobObjectW", + "name": "OpenJobObjectW", + "namespace": "Windows.Win32.System.JobObjects", + "sourceFingerprint": "F8C0330C7F1441B0842BD970AD0184A65D6E63E6B000792ADAB597DBC9F7C3FE" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/jobapi2/nf-jobapi2-openjobobjectw" + } + ] + }, + { + "id": "windows.win32.system.libraryloader.apis.getmodulehandlea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "GetModuleHandleA", + "name": "GetModuleHandleA", + "namespace": "Windows.Win32.System.LibraryLoader", + "sourceFingerprint": "E9ADD5CB234A08CF6E35676C6CA3632132176BDD30A2C9211095EAB600A616F2" + }, + "contracts": [ + { + "kind": "borrowed-return" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlea" + } + ] + }, + { + "id": "windows.win32.system.libraryloader.apis.getmodulehandlew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "GetModuleHandleW", + "name": "GetModuleHandleW", + "namespace": "Windows.Win32.System.LibraryLoader", + "sourceFingerprint": "5F06E8EE9276D70C12FFBFAF6F41EDA84B61BE85DB06FF0923E53DA6C2A358F0" + }, + "contracts": [ + { + "kind": "borrowed-return" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlew" + } + ] + }, + { + "id": "windows.win32.system.libraryloader.apis.loadlibrarya.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "LoadLibraryA", + "name": "LoadLibraryA", + "namespace": "Windows.Win32.System.LibraryLoader", + "sourceFingerprint": "3355058CF7FD3CAF5701661AEC8339C5B81AB92F6E8CC8ABF9EB6E0939C841AE" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "free-library" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibrarya" + } + ] + }, + { + "id": "windows.win32.system.libraryloader.apis.loadlibraryexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "LoadLibraryExA", + "name": "LoadLibraryExA", + "namespace": "Windows.Win32.System.LibraryLoader", + "sourceFingerprint": "CE07F74039CFC8D364C536BE41125C1610A3FEF4CDA725D298F3A6C24F0A668E" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "free-library" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexa" + } + ] + }, + { + "id": "windows.win32.system.libraryloader.apis.loadlibraryexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "LoadLibraryExW", + "name": "LoadLibraryExW", + "namespace": "Windows.Win32.System.LibraryLoader", + "sourceFingerprint": "42A15719E920E589D243A233E7CC774A0C055262527009FFA673EF986750C912" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "free-library" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryexw" + } + ] + }, + { + "id": "windows.win32.system.libraryloader.apis.loadlibraryw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "LoadLibraryW", + "name": "LoadLibraryW", + "namespace": "Windows.Win32.System.LibraryLoader", + "sourceFingerprint": "392AF912483F46A31BDD9EAC94349DC654B4902DD869F2C87C42DC7DC87FE248" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "free-library" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/libloaderapi/nf-libloaderapi-loadlibraryw" + } + ] + }, + { + "id": "windows.win32.system.memory.apis.globalalloc.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "GlobalAlloc", + "name": "GlobalAlloc", + "namespace": "Windows.Win32.System.Memory", + "sourceFingerprint": "CD99A309817DC8A370B95EEF5F95F35C59D362E9062FBD01117744483A63C08A" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "global-free" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-globalalloc" + } + ] + }, + { + "id": "windows.win32.system.memory.apis.localalloc.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "LocalAlloc", + "name": "LocalAlloc", + "namespace": "Windows.Win32.System.Memory", + "sourceFingerprint": "C2F8327F5EDFE130486001235C7111F82E74622C364EE905E29DBAEAFA9F37C1" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "local-free" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-localalloc" + } + ] + }, + { + "id": "windows.win32.system.pipes.apis.createnamedpipea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateNamedPipeA", + "name": "CreateNamedPipeA", + "namespace": "Windows.Win32.System.Pipes", + "sourceFingerprint": "6EDDD8351B30D0BDDF265C0910B7735293F0E8922B5BA740D5B628FD2BA745D5" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-createnamedpipea" + } + ] + }, + { + "id": "windows.win32.system.pipes.apis.createnamedpipew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateNamedPipeW", + "name": "CreateNamedPipeW", + "namespace": "Windows.Win32.System.Pipes", + "sourceFingerprint": "C8350B1B5CC223E59878CE46FDB9902FEA94AF26F3FA04FEB2B895ADE75A53E8" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/namedpipeapi/nf-namedpipeapi-createnamedpipew" + } + ] + }, + { + "id": "windows.win32.system.pipes.apis.createpipe.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreatePipe", + "name": "CreatePipe", + "namespace": "Windows.Win32.System.Pipes", + "sourceFingerprint": "93C21BB5691722C0AD8422F722A8CD501425F5F973F3533D3B491DE1511F8687" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 0, + "cleanup": "close-handle" + }, + { + "kind": "owned-output", + "parameter": 1, + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/namedpipeapi/nf-namedpipeapi-createpipe" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regclosekey.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegCloseKey", + "name": "RegCloseKey", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "23BF7F0DF79CA3DDBF947190AAACB4F9E68B7404E4ECA28DE7F8A0032917E209" + }, + "contracts": [ + { + "kind": "consumed-input", + "parameter": 0, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regclosekey" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regconnectregistrya.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegConnectRegistryA", + "name": "RegConnectRegistryA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "DCCE520440A475DC0E0053EE8A2CC1561B6735B989AAA6524DB9472D670ED989" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 2, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regconnectregistrya" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regconnectregistryexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegConnectRegistryExA", + "name": "RegConnectRegistryExA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "4B4743262AE4425B4F73C25C9FF9B493CD1AAD260E1D0EB25DEF7BC03ECED6B4" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 3, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regconnectregistryexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegConnectRegistryExW", + "name": "RegConnectRegistryExW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "DBA80107C4F83C9EAAE2C13926B2BACDD7A6C27448507B141780B540479A478F" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 3, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regconnectregistryw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegConnectRegistryW", + "name": "RegConnectRegistryW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "984F1A0F25629D26439D900672798515A85B6037C2EEC03AA6169756EDF1895F" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 2, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regconnectregistryw" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regcreatekeya.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegCreateKeyA", + "name": "RegCreateKeyA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "CC7652620702C927D005DB4BE75BD6640F42E0FEE2D32ECFBF070979B8BDA8A8" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 2, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regcreatekeya" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regcreatekeyexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegCreateKeyExA", + "name": "RegCreateKeyExA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "E7031E8B7218EBD69F5892B25878FEAFA1F4A89C0F124BAE7C483D1AFA1D8958" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 7, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regcreatekeyexa" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regcreatekeyexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegCreateKeyExW", + "name": "RegCreateKeyExW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "BF190A29FED832DD3CA923F3133D8CF33597EE5C985E91C106E11F561826D198" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 7, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regcreatekeyexw" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regcreatekeytransacteda.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegCreateKeyTransactedA", + "name": "RegCreateKeyTransactedA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "EF98F4AD8A54C5F4DC57BDB781225B3B3A23C2832D986B0AC8A459D589C2BCEF" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 7, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regcreatekeytransacteda" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regcreatekeytransactedw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegCreateKeyTransactedW", + "name": "RegCreateKeyTransactedW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "3A5D0F8CC86179CA8E0E0EFB6573CEDCA169B43E9DCD4A4BFC29E8CA8B7A0D47" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 7, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regcreatekeytransactedw" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regcreatekeyw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegCreateKeyW", + "name": "RegCreateKeyW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "1A97220CAE1BC3E99C0A45533386232EDBF56B434824B7AC0C5EB2D77D1AB36B" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 2, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regcreatekeyw" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.reggetvaluea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegGetValueA", + "name": "RegGetValueA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "E82626197D4317DB6FA2595045E022E70E3AE87B6C636D9877C3AA8CF2F91CC6" + }, + "contracts": [ + { + "kind": "call-contract", + "contract": { + "outputs": [ + { + "parameter": 6, + "when": { + "inputs": [ + { + "kind": "bits-in", + "parameter": 0, + "mask": 4294967295, + "values": [ + 2147483652 + ] + } + ], + "returnValue": 234 + }, + "action": { + "kind": "unavailable" + } + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-reggetvaluea" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.reggetvaluew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegGetValueW", + "name": "RegGetValueW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "C59829150B63B5DECDD56002EB293AC860DE827EFD8556D0B848CC36D2A9AFA3" + }, + "contracts": [ + { + "kind": "call-contract", + "contract": { + "outputs": [ + { + "parameter": 6, + "when": { + "inputs": [ + { + "kind": "bits-in", + "parameter": 0, + "mask": 4294967295, + "values": [ + 2147483652 + ] + } + ], + "returnValue": 234 + }, + "action": { + "kind": "unavailable" + } + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-reggetvaluew" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regloadappkeya.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegLoadAppKeyA", + "name": "RegLoadAppKeyA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "CB78FE1BA7033FE1EFF773B91AD759EFA9A766B7AFF100178C8D304E1536025A" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 1, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regloadappkeya" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regloadappkeyw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegLoadAppKeyW", + "name": "RegLoadAppKeyW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "2543F342C66EE1B4E1A299BF9F313CECABA9103F1EA7A6993F3FA146B91E0853" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 1, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regloadappkeyw" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regopencurrentuser.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegOpenCurrentUser", + "name": "RegOpenCurrentUser", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "33CF725EDFD28F2EC6C0562E9762B5DED6A0038EA661BD7F0F2704438B51B624" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 1, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regopencurrentuser" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regopenkeya.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegOpenKeyA", + "name": "RegOpenKeyA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "41FAA2B895FB290304778CD6A9798A7D4B6AFB6FFA8518DA7662F0EEB2F2D5BC" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 2, + "cleanup": "reg-close-key" + }, + { + "kind": "call-contract", + "contract": { + "outputs": [ + { + "parameter": 2, + "when": { + "inputs": [ + { + "kind": "null-or-empty", + "parameter": 1, + "elementWidth": 1 + } + ] + }, + "action": { + "kind": "alias-input", + "parameter": 0 + } + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regopenkeya" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regopenkeyexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegOpenKeyExA", + "name": "RegOpenKeyExA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "04F69363E76319FC88D4FD9B093A7003F190277E2BE73CA1590C096232449A5D" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 4, + "cleanup": "reg-close-key" + }, + { + "kind": "call-contract", + "contract": { + "outputs": [ + { + "parameter": 4, + "when": { + "inputs": [ + { + "kind": "handle-in", + "parameter": 0, + "values": [ + -2147483648, + -2147483647, + -2147483646, + -2147483645, + -2147483644, + -2147483643, + -2147483642, + -2147483568, + -2147483552 + ] + }, + { + "kind": "null-or-empty", + "parameter": 1, + "elementWidth": 1 + } + ] + }, + "action": { + "kind": "alias-input", + "parameter": 0 + } + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regopenkeyexa" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regopenkeyexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegOpenKeyExW", + "name": "RegOpenKeyExW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "0537F79814DF7AB942B2CCB06C6395F75380F95AEEDB39D827FBAFCB98C765A3" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 4, + "cleanup": "reg-close-key" + }, + { + "kind": "call-contract", + "contract": { + "outputs": [ + { + "parameter": 4, + "when": { + "inputs": [ + { + "kind": "handle-in", + "parameter": 0, + "values": [ + -2147483648, + -2147483647, + -2147483646, + -2147483645, + -2147483644, + -2147483643, + -2147483642, + -2147483568, + -2147483552 + ] + }, + { + "kind": "null-or-empty", + "parameter": 1, + "elementWidth": 2 + } + ] + }, + "action": { + "kind": "alias-input", + "parameter": 0 + } + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regopenkeyexw" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regopenkeytransacteda.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegOpenKeyTransactedA", + "name": "RegOpenKeyTransactedA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "F1DA368541CAC10758CA8D938B38FC176ED2203F5C956A9C049DD7E6CB72D4C6" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 4, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regopenkeytransacteda" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regopenkeytransactedw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegOpenKeyTransactedW", + "name": "RegOpenKeyTransactedW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "3F85BC8D2C391D5F811EC25A1BCBAD98426FED10416714CDD32EA5E00321082E" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 4, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regopenkeytransactedw" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regopenkeyw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegOpenKeyW", + "name": "RegOpenKeyW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "748721A0B36D3F1B21FEC4AA3F7F920DAC9C6A08A1DB3850EC019FF75BA0CBAF" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 2, + "cleanup": "reg-close-key" + }, + { + "kind": "call-contract", + "contract": { + "outputs": [ + { + "parameter": 2, + "when": { + "inputs": [ + { + "kind": "null-or-empty", + "parameter": 1, + "elementWidth": 2 + } + ] + }, + "action": { + "kind": "alias-input", + "parameter": 0 + } + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regopenkeyw" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regopenuserclassesroot.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegOpenUserClassesRoot", + "name": "RegOpenUserClassesRoot", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "3E6BA2195F0967EF3B4D7D47C775B754876996EE0AE81A6055A8B7A62A88C957" + }, + "contracts": [ + { + "kind": "owned-output", + "parameter": 3, + "cleanup": "reg-close-key" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winreg/nf-winreg-regopenuserclassesroot" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regqueryvalueexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegQueryValueExA", + "name": "RegQueryValueExA", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "6E8D7C4ABA09D0A33FB4410EF4E0C01EFF025933BC558A449D3ECB64C22778C8" + }, + "contracts": [ + { + "kind": "call-contract", + "contract": { + "outputs": [ + { + "parameter": 5, + "when": { + "inputs": [ + { + "kind": "bits-in", + "parameter": 0, + "mask": 4294967295, + "values": [ + 2147483652 + ] + } + ], + "returnValue": 234 + }, + "action": { + "kind": "unavailable" + } + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexa" + } + ] + }, + { + "id": "windows.win32.system.registry.apis.regqueryvalueexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "RegQueryValueExW", + "name": "RegQueryValueExW", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "5A98B9547E1B91B2D42D08FDBD4945482059FD6D54C50F3C1A5A5D7DB871A394" + }, + "contracts": [ + { + "kind": "call-contract", + "contract": { + "outputs": [ + { + "parameter": 5, + "when": { + "inputs": [ + { + "kind": "bits-in", + "parameter": 0, + "mask": 4294967295, + "values": [ + 2147483652 + ] + } + ], + "returnValue": 234 + }, + "action": { + "kind": "unavailable" + } + } + ] + } + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regqueryvalueexw" + } + ] + }, + { + "id": "windows.win32.system.services.apis.closeservicehandle.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "CloseServiceHandle", + "name": "CloseServiceHandle", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "598E7E838CE2B64E425893B883768815BB31740AEF4747EFD0802922449291AF" + }, + "contracts": [ + { + "kind": "consumed-input", + "parameter": 0, + "cleanup": "close-service-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsvc/nf-winsvc-closeservicehandle" + } + ] + }, + { + "id": "windows.win32.system.services.apis.createservicea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "CreateServiceA", + "name": "CreateServiceA", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "0F27068AE840169A47F7C422BEB138429A80157EE031D533F14E51342F020466" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-service-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsvc/nf-winsvc-createservicea" + } + ] + }, + { + "id": "windows.win32.system.services.apis.createservicew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "CreateServiceW", + "name": "CreateServiceW", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "45A82382B84B3A9C617EDE1E73E8F5CF2E5B0889F044252A97771CBEBA4E2EC3" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-service-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsvc/nf-winsvc-createservicew" + } + ] + }, + { + "id": "windows.win32.system.services.apis.openscmanagera.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "OpenSCManagerA", + "name": "OpenSCManagerA", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "94F1AA7F7442AA95EB89141CB0F856DFE56E6173FF734654FA644D45C85DF705" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-service-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsvc/nf-winsvc-openscmanagera" + } + ] + }, + { + "id": "windows.win32.system.services.apis.openscmanagerw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "OpenSCManagerW", + "name": "OpenSCManagerW", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "789CA675749C80AA337CDC1194756AD965BA79AC93A3AC7C89FD916AE8CEF203" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-service-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsvc/nf-winsvc-openscmanagerw" + } + ] + }, + { + "id": "windows.win32.system.services.apis.openservicea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "OpenServiceA", + "name": "OpenServiceA", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "75D216EAC7DCCAF4BD2C4A0964B7CF9D97DC774A94796E930847E7D7013B1025" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-service-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsvc/nf-winsvc-openservicea" + } + ] + }, + { + "id": "windows.win32.system.services.apis.openservicew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "OpenServiceW", + "name": "OpenServiceW", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "158047F11F129209BB366431A6CEDACE761CE5B3475CD981FCC058B5B3576361" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-service-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsvc/nf-winsvc-openservicew" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createeventa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateEventA", + "name": "CreateEventA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "8309F25D7A2D14855C9BC860EC9C13375F561B6056E3BAB4A0B52375A783E3F7" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createeventa" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createeventexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateEventExA", + "name": "CreateEventExA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "FEE5AEB21EA4B54D7FCF593451E53BAAAD02320327820152483F74EB118360F8" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createeventexa" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createeventexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateEventExW", + "name": "CreateEventExW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "2E1FA016D06ABC74A7F4DE0AC5E3B8A9FE9FA2270EEC1051DBC7E8D440A99CC6" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createeventexw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createeventw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateEventW", + "name": "CreateEventW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "CDBCAD6D0231932002947BF82BBEC943D5F02506AFA401CC661743598BF7BDE7" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createeventw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createmutexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateMutexA", + "name": "CreateMutexA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "6B10C1704C76CA5EC63A7455F7C680E09E756C5E3F8FE2970232A23CE3E4B1D2" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createmutexa" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createmutexexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateMutexExA", + "name": "CreateMutexExA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "BE41A563B926C5B3CDAB6CA6FADCB3B1589E130B5FE2E9706A800F3E781DA305" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createmutexexa" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createmutexexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateMutexExW", + "name": "CreateMutexExW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "95A4022D3F3F0EAD7E28E2EF9DBAA7FF5672D8D3C951BC760BBDCDABB3AEC556" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createmutexexw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createmutexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateMutexW", + "name": "CreateMutexW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "243D943D6D040AF372476F5CF475386FF5F1AA73088DA3DDB0BF72518D484DDB" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createmutexw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createprocessa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateProcessA", + "name": "CreateProcessA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "0AE596F4AFBF9A92874A4F99C0645B197B107EB9D4A5435DCC27C0128C64903A" + }, + "contracts": [ + { + "kind": "mutable-string", + "parameter": 1 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessa" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createprocessasusera.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "CreateProcessAsUserA", + "name": "CreateProcessAsUserA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "DE23D644ADC995B64C4A39D5AB0B73C81B7FD5A1B74D6EF2998BA541FA63F2AA" + }, + "contracts": [ + { + "kind": "mutable-string", + "parameter": 2 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessasusera" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createprocessasuserw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "CreateProcessAsUserW", + "name": "CreateProcessAsUserW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "E837F71C2BF818A3186492BB6BA068F835BCB520EBC8C5CF0795D422EABB228B" + }, + "contracts": [ + { + "kind": "mutable-string", + "parameter": 2 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessasuserw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createprocessw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateProcessW", + "name": "CreateProcessW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "C214D7338D44841FE906328D1106213B3B047E48EB69CDE05A01F2B841B1EBEE" + }, + "contracts": [ + { + "kind": "mutable-string", + "parameter": 1 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createprocesswithlogonw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "CreateProcessWithLogonW", + "name": "CreateProcessWithLogonW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "FC005BB14175F1141DB053C1F0469D20E61B92F8CDDAFD491F08B210E95A4622" + }, + "contracts": [ + { + "kind": "mutable-string", + "parameter": 5 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-createprocesswithlogonw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createprocesswithtokenw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ADVAPI32.dll", + "entryPoint": "CreateProcessWithTokenW", + "name": "CreateProcessWithTokenW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "84C12BCC53089556BC7FD5FFADEA780763B909BDD090E496F3E050C43EEA391E" + }, + "contracts": [ + { + "kind": "mutable-string", + "parameter": 3 + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-createprocesswithtokenw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createsemaphorea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateSemaphoreA", + "name": "CreateSemaphoreA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "23CB5053DF19DA220380E18A9FA1637D1E123EEA2CD3405C7CB757D2418FB830" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-createsemaphorea" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createsemaphoreexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateSemaphoreExA", + "name": "CreateSemaphoreExA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "C2DA3710E86468EFB092BDACD29E426A84A7475953CE65280544FE6A5C0505BE" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-createsemaphoreexa" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createsemaphoreexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateSemaphoreExW", + "name": "CreateSemaphoreExW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "84B175BD9E62BD906BC0E052C5A20AADD924E2BEC6EDB5EEC46556F53B9A87D8" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createsemaphoreexw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createsemaphorew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateSemaphoreW", + "name": "CreateSemaphoreW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "A70562D7B9BE54A8204A4077751B79043755EC7DD5F638CD63D0CEB0AC06973D" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createsemaphorew" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createwaitabletimera.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateWaitableTimerA", + "name": "CreateWaitableTimerA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "BFB5FDCC8BD6F9868BA2BF5D98ABF054C3F171ED572CC85BDCD605F2F79B47A6" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createwaitabletimerw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createwaitabletimerexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateWaitableTimerExA", + "name": "CreateWaitableTimerExA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "8453D7510D4C71107794B3C0EBCD87722AA66031CAC61839059B67568CADABF2" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createwaitabletimerexw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createwaitabletimerexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateWaitableTimerExW", + "name": "CreateWaitableTimerExW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "D475057A6DF56B2EF7059543284D7A5B0CB5224ACBAF3774CFAC4FFA79402CFA" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createwaitabletimerexw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.createwaitabletimerw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "CreateWaitableTimerW", + "name": "CreateWaitableTimerW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "EB234AB9CD46105DA1AA8985690C7F7AB7785DDA64337FE7E2CA388690FC0B9E" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-createwaitabletimerw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.openeventa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenEventA", + "name": "OpenEventA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "A6FB025AEB8EEBC617DE6CCC0DE1474C0498759E1DB4111B0E09187B64FF149F" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-openeventa" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.openeventw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenEventW", + "name": "OpenEventW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "362B4AD8C8B845D29F696EA115788A9D6167D6BC62F86C150E67EA64BE4DF8BE" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-openeventw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.openmutexw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenMutexW", + "name": "OpenMutexW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "2993320749D43B5F148DBCB3F8A04F5307C9AA45EB42DDC98BB50AF78C140C8A" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-openmutexw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.openprocess.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenProcess", + "name": "OpenProcess", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "B11BB7949B690F061EE25C5CCC18D0640BB865AB07E5EAEE4551FAE2B71ECA5F" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-openprocess" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.opensemaphorew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenSemaphoreW", + "name": "OpenSemaphoreW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "C418FA92A2A3D8912D3A29E21F033476D824A5962BEB162E2B2E8ACF484C0DBD" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-opensemaphorew" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.openthread.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenThread", + "name": "OpenThread", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "82B5AE735FE831C63219CF232ECA786AFC6E340BCEAEE05EECF2FFCAEA712550" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-openthread" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.openwaitabletimera.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenWaitableTimerA", + "name": "OpenWaitableTimerA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "17303C863D561B3CE3FE16F77814C92BDCE2951F0D1930B6310102C611D3BEA3" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-openwaitabletimerw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.openwaitabletimerw.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenWaitableTimerW", + "name": "OpenWaitableTimerW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "6DA14581AA0C504D87AD25756344E4C97426E992941FA16133B5C754592750A2" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-openwaitabletimerw" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.queryfullprocessimagenamea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "QueryFullProcessImageNameA", + "name": "QueryFullProcessImageNameA", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "66E2AF97F72B98E3CCC8C5D4E77F15F3DBDB53C09DAF286A41B2F70EA17FDE9F" + }, + "contracts": [ + { + "kind": "counted-buffer", + "parameter": 2, + "countParameter": 3, + "nullable": false + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-queryfullprocessimagenamea" + } + ] + }, + { + "id": "windows.win32.system.threading.apis.queryfullprocessimagenamew.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "QueryFullProcessImageNameW", + "name": "QueryFullProcessImageNameW", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "4CEA5BBAD410D1BD6195A0B0130C3D9994A569A912BDDB753C4BB6BE933F6A56" + }, + "contracts": [ + { + "kind": "counted-buffer", + "parameter": 2, + "countParameter": 3, + "nullable": false + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winbase/nf-winbase-queryfullprocessimagenamew" + } + ] + }, + { + "id": "windows.win32.system.windowsprogramming.apis.openmutexa.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenMutexA", + "name": "OpenMutexA", + "namespace": "Windows.Win32.System.WindowsProgramming", + "sourceFingerprint": "AB4309CC89F59B55026E71A193A29BD1BA3B62352A55223BF9E97F73B915E2DE" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-openmutexw" + } + ] + }, + { + "id": "windows.win32.system.windowsprogramming.apis.opensemaphorea.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "KERNEL32.dll", + "entryPoint": "OpenSemaphoreA", + "name": "OpenSemaphoreA", + "namespace": "Windows.Win32.System.WindowsProgramming", + "sourceFingerprint": "6EA53D49927B85E8CBBCB71C31BA1531D262B02D7E01394A32D187D069028B00" + }, + "contracts": [ + { + "kind": "owned-return", + "cleanup": "close-handle" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/synchapi/nf-synchapi-opensemaphorew" + } + ] + } + ] +} diff --git a/tools/dynwinrt-codegen/contracts/win32/manifest.json b/tools/dynwinrt-codegen/contracts/win32/manifest.json new file mode 100644 index 00000000..619eaf2f --- /dev/null +++ b/tools/dynwinrt-codegen/contracts/win32/manifest.json @@ -0,0 +1,38 @@ +{ + "files": [ + { + "file": "call-contract.schema.json", + "sha256": "6215BF38E52DEE3B5681B9609F2D68F4E4F76991DE14A0472249BE15C92C4ACF" + }, + { + "file": "function-contracts.json", + "sha256": "F23832CBAD1C83819C1ED7117778247DE1DEEFA30C3D424E1417E6E90FC701B8" + }, + { + "file": "subsystem-policies.json", + "sha256": "5A85F55046DEF2D92406060A5D6E82CD611829F71C4FB065B5C80D2876AB80E7" + }, + { + "file": "native-types.json", + "sha256": "076D3855E4601925D150F438A92BAE37A4B7B87F04EA941A0EC7FDBDC98FBF89" + }, + { + "file": "aggregate-layouts.json", + "sha256": "7D8325BD3957219A726FEF641B08A076C9D4005DDDBA7AE6A49A8A59A563D863" + }, + { + "file": "policy-domains.json", + "sha256": "A50067F25F729F29E1F02DB366F9D1EADE642407C7820628480F97347938EE57" + } + ], + "metadata": { + "package": "Microsoft.Windows.SDK.Win32Metadata", + "sha256": "B64EE4818A7ED9F9D135038D58C51BD08369184D4D5ED428F20E9DE55DF8121D", + "version": "71.0.14-preview" + }, + "schema": { + "file": "schema.json", + "sha256": "8C371DBEC78D0B913391168C1F407B507DD92FFD5A892EFC6445F9369C1F6E55" + }, + "schemaVersion": 2 +} diff --git a/tools/dynwinrt-codegen/contracts/win32/native-types.json b/tools/dynwinrt-codegen/contracts/win32/native-types.json new file mode 100644 index 00000000..45c834fd --- /dev/null +++ b/tools/dynwinrt-codegen/contracts/win32/native-types.json @@ -0,0 +1,3332 @@ +{ + "schemaVersion": 2, + "entries": [ + { + "id": "windows.win32.devices.bluetooth.hbluetooth_device_find.native-type.v1", + "selector": { + "name": "HBLUETOOTH_DEVICE_FIND", + "namespace": "Windows.Win32.Devices.Bluetooth", + "sourceFingerprint": "D3A6DB66E3F1001F7C7CE08D08579368511FCE1DFF51635463E2B01EEFDF7FC6" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.devices.bluetooth.hbluetooth_radio_find.native-type.v1", + "selector": { + "name": "HBLUETOOTH_RADIO_FIND", + "namespace": "Windows.Win32.Devices.Bluetooth", + "sourceFingerprint": "420729024C31E869567B6F570D31417C588233011DAACE1F8B94A4FE9F259576" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.devices.deviceanddriverinstallation.configret.native-type.v1", + "selector": { + "name": "CONFIGRET", + "namespace": "Windows.Win32.Devices.DeviceAndDriverInstallation", + "sourceFingerprint": "7EA382FB87AB3C3A85CBDA58BDB47F991BD0C99AFCC27EB57476D641D3FF88DF" + }, + "meaning": null, + "status": "zero", + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.devices.deviceanddriverinstallation.hcmnotification.native-type.v1", + "selector": { + "name": "HCMNOTIFICATION", + "namespace": "Windows.Win32.Devices.DeviceAndDriverInstallation", + "sourceFingerprint": "0A44EDA4F7B56E32088910EC7B9FF403F351DFA186A401659921D37EBB74C5CE" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.devices.deviceanddriverinstallation.hdevinfo.native-type.v1", + "selector": { + "name": "HDEVINFO", + "namespace": "Windows.Win32.Devices.DeviceAndDriverInstallation", + "sourceFingerprint": "4635C19ADDA0E7CC41BDCF486C83DD368E8DEE3A3C0B2D365B25DF4E31F32802" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.devices.display.hsemaphore.native-type.v1", + "selector": { + "name": "HSEMAPHORE", + "namespace": "Windows.Win32.Devices.Display", + "sourceFingerprint": "62457E96C77F70050952EFFA29B111BD60819DEE65BDE3A45BB8CD90F67311EA" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.devices.enumeration.pnp.hswdevice.native-type.v1", + "selector": { + "name": "HSWDEVICE", + "namespace": "Windows.Win32.Devices.Enumeration.Pnp", + "sourceFingerprint": "B599502895784393578455655236281C14DCD13C541036DAA564D45470B8989C" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.devices.serialcommunication.hcomdb.native-type.v1", + "selector": { + "name": "HCOMDB", + "namespace": "Windows.Win32.Devices.SerialCommunication", + "sourceFingerprint": "3F1ABD7F3926B42B69061CC7F4B68935408B9FF6BFEDDE079F22CD767C24E156" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.devices.usb.winusb_interface_handle.native-type.v1", + "selector": { + "name": "WINUSB_INTERFACE_HANDLE", + "namespace": "Windows.Win32.Devices.Usb", + "sourceFingerprint": "4DCF430DA44B4DB0246F723B3988E94AD3D7B5455755F1D7459717B366232A3C" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.bool.native-type.v1", + "selector": { + "name": "BOOL", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "EE7E5C10C1777B071DA1D3879BCE141A638C8EAB36646C1832DF08FEE90EE7CE" + }, + "meaning": { + "kind": "scalar", + "scalar": "bool32" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.boolean.native-type.v1", + "selector": { + "name": "BOOLEAN", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "DCF21AC36B28AF818B1A50EC2146A2F793FF29D79DE608259CF9C4FFA401A012" + }, + "meaning": { + "kind": "scalar", + "scalar": "u8" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.bstr.native-type.v1", + "selector": { + "name": "BSTR", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "FFB8FB56DD9086B1D16B20A9033F8C2948549D18355DA084143A5636C9A16DF9" + }, + "meaning": { + "kind": "unsupported" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.farproc.native-type.v1", + "selector": { + "name": "FARPROC", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "A11AFAD73C71930EF9435BCCF6996D3FFFA4781B3A8407F73622D0B6C9397AB4" + }, + "meaning": { + "kind": "function-pointer" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.handle.native-type.v1", + "selector": { + "name": "HANDLE", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "D1FB8BBFD4952CA2E3A0980100FE46AEB67D1FACC11F4EC348030A552F63B57A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.hglobal.native-type.v1", + "selector": { + "name": "HGLOBAL", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "6E4BFFED330AD889CA6E17C0E1B1E4307702E3D2A33D338BABA11E429D0F4F1D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.hinstance.native-type.v1", + "selector": { + "name": "HINSTANCE", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "42AB7BC3B562CE4C63AE3FC13C6DD8A5E4A8DAD8C22B167983F95348FC2CBC31" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.hlocal.native-type.v1", + "selector": { + "name": "HLOCAL", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "45CEBFEBBFEFA5E2DA078AF1DDF1A765A987339765717E1E6282CF5FC15D214A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.hmodule.native-type.v1", + "selector": { + "name": "HMODULE", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "DF9C1B98ED00E56D38A3C03A7D8A20F8AB3A1AB58D821B282A519BE2DB25EAA0" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.hresult.native-type.v1", + "selector": { + "name": "HRESULT", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "BE192035848AAA35CEEE1895A27BD7B82C3B6520E66D1FEEEB095DEC572EE921" + }, + "meaning": { + "kind": "scalar", + "scalar": "i32" + }, + "status": "signed-nonnegative", + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/office/client-developer/outlook/mapi/hresult" + } + ] + }, + { + "id": "windows.win32.foundation.hrsrc.native-type.v1", + "selector": { + "name": "HRSRC", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "D1A1AD550715D7E44033352BE7ACD9A376DF6CA888A0FE1B28447C879B0FE9E5" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.hwnd.native-type.v1", + "selector": { + "name": "HWND", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "00D0CAD4A438C7093CD04D42C42FF3BC2F9EBA3B21D6AFFDBBF16B5696C75AD9" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.nearproc.native-type.v1", + "selector": { + "name": "NEARPROC", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "0B626C4C966BEF597F70F9C48372286D9A7DF5E1036EBC2AB8D6599F4D475FF2" + }, + "meaning": { + "kind": "function-pointer" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.ntstatus.native-type.v1", + "selector": { + "name": "NTSTATUS", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "3F9AEF7F043D0637E4FB7DCFCF9F3196020493EB342C5C516D2D3BCE805697F3" + }, + "meaning": { + "kind": "scalar", + "scalar": "i32" + }, + "status": "signed-nonnegative", + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.proc.native-type.v1", + "selector": { + "name": "PROC", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "4F4B8DBC2FEFD78D40322A2DEC407C121A9CB94691F6845465BFAEC1A7D7D010" + }, + "meaning": { + "kind": "function-pointer" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.pstr.native-type.v1", + "selector": { + "name": "PSTR", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "60AB2A298F1A10B40E0D4E44A2D48896AA9A3D5302F5B20BF3AEE1F8F60B898D" + }, + "meaning": { + "kind": "string-pointer", + "encoding": "ansi", + "isConst": false + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.pwstr.native-type.v1", + "selector": { + "name": "PWSTR", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "F33CCD067FB27C623204D7E8024A528A508B9FD7CB87B8BDD19C644A5D91AF5B" + }, + "meaning": { + "kind": "string-pointer", + "encoding": "utf16", + "isConst": false + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.foundation.win32_error.native-type.v1", + "selector": { + "name": "WIN32_ERROR", + "namespace": "Windows.Win32.Foundation", + "sourceFingerprint": "9884F9F5E8B09A88DA011FF18091E3F0750E9B95122F255815AFEE6A048C80B5" + }, + "meaning": null, + "status": "zero", + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hbitmap.native-type.v1", + "selector": { + "name": "HBITMAP", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "76ED7DDD9969E06550388DB22222EE87A255ADC693EF18FB6E1756AC1DC3432A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hbrush.native-type.v1", + "selector": { + "name": "HBRUSH", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "B59D0818A5E43F0E6DFD8E934DC90F481DA60542F1B3D1174892082AD0CF111E" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hdc.native-type.v1", + "selector": { + "name": "HDC", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "80597D7277B6824034459AAA4A561BC68B743924D83CD340C6DC8F8C4A0FA845" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.henhmetafile.native-type.v1", + "selector": { + "name": "HENHMETAFILE", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "D3643B0E1E0E6B1DCFB9C33AB57D38161C8725FDC9F4ABF734E040E255EA276C" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hfont.native-type.v1", + "selector": { + "name": "HFONT", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "E361F3CA1653A8927DDB18F22D74BB866BFEFFFCC4B97ADD442B4D08413A191B" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hgdiobj.native-type.v1", + "selector": { + "name": "HGDIOBJ", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "F889A474B2A72C8B103E293D1EC44839462B41F950AAFDB4A5712686411F0F1D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hmetafile.native-type.v1", + "selector": { + "name": "HMETAFILE", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "39C2BEF4D9984E67C3861FD9AFD547595F135483E63299CFE25E42700FB12E53" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hmonitor.native-type.v1", + "selector": { + "name": "HMONITOR", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "F77564A2FC849465F30BE391532A4E46E9F6C725F8A4A2B25B09E9332846EBFD" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hpalette.native-type.v1", + "selector": { + "name": "HPALETTE", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "32B9B21AFDB0EFAEFD7DDC139B92F98A6673C4EE8C22DE3DEACD22C15009B95E" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hpen.native-type.v1", + "selector": { + "name": "HPEN", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "CA0AD7803BE2F06D1871D5A90018C877F73150E95735E195E0DC75EF9E65912F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdi.hrgn.native-type.v1", + "selector": { + "name": "HRGN", + "namespace": "Windows.Win32.Graphics.Gdi", + "sourceFingerprint": "D090188AE69B22698077EB10855AF9DE919E660390A5729FC3D06AD0B7660FDF" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.opengl.hglrc.native-type.v1", + "selector": { + "name": "HGLRC", + "namespace": "Windows.Win32.Graphics.OpenGL", + "sourceFingerprint": "EF2DC4AB01E057C3CBA918CEBB8176A8DD51A78D279E1103605531FF88FFAF91" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.printing.findprinterchangenotification_handle.native-type.v1", + "selector": { + "name": "FINDPRINTERCHANGENOTIFICATION_HANDLE", + "namespace": "Windows.Win32.Graphics.Printing", + "sourceFingerprint": "ECDD61D34DD2885270EC45F191088671C04F5E3A9D77E7F7BB09F11F8182E007" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.printing.printer_handle.native-type.v1", + "selector": { + "name": "PRINTER_HANDLE", + "namespace": "Windows.Win32.Graphics.Printing", + "sourceFingerprint": "6FEEA5F000E49B785F412DB5A26D0EA904B5644E004F2047D9064BFD7CC48848" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.printing.printticket.hptprovider.native-type.v1", + "selector": { + "name": "HPTPROVIDER", + "namespace": "Windows.Win32.Graphics.Printing.PrintTicket", + "sourceFingerprint": "D0A5BB03957B546D2B7B6C2C05B7A230334B8043036BCF1260151291D0F994CC" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.audio.hacmdriver.native-type.v1", + "selector": { + "name": "HACMDRIVER", + "namespace": "Windows.Win32.Media.Audio", + "sourceFingerprint": "7D7C070E05CE402CE21E9F88AD461E7FAD5254D5060CC281DEB104E13C96C83E" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.audio.hacmstream.native-type.v1", + "selector": { + "name": "HACMSTREAM", + "namespace": "Windows.Win32.Media.Audio", + "sourceFingerprint": "1F1B12A7B11373A123C4AB712C5E4A7CE3B4A8B58320CBE9ADAEB02AC0658EAA" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.audio.hmidiin.native-type.v1", + "selector": { + "name": "HMIDIIN", + "namespace": "Windows.Win32.Media.Audio", + "sourceFingerprint": "081F2248F2C0916460836E4C10829B36337B1089A8E79C6174483A8ABE5699C9" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.audio.hmidiout.native-type.v1", + "selector": { + "name": "HMIDIOUT", + "namespace": "Windows.Win32.Media.Audio", + "sourceFingerprint": "3ED9911EC053117A06D7AF870BB6083C30AC6DF3E46B53862E94EA0CBB4E1FA7" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.audio.hmidistrm.native-type.v1", + "selector": { + "name": "HMIDISTRM", + "namespace": "Windows.Win32.Media.Audio", + "sourceFingerprint": "E8DBF024602457E63C4C335CC776672B39EF504DCF58149434965F7D4B1E0793" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.audio.hmixer.native-type.v1", + "selector": { + "name": "HMIXER", + "namespace": "Windows.Win32.Media.Audio", + "sourceFingerprint": "BBA8713982FC779E8E3D560E33A20C763E081CD7CB69D85B8F9F19FBEF4C26FC" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.audio.hwavein.native-type.v1", + "selector": { + "name": "HWAVEIN", + "namespace": "Windows.Win32.Media.Audio", + "sourceFingerprint": "2CD0EEF82D6025A263DEB6C5C8980EA4C92AA1EE375450619518DEBE0BDC6FC7" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.audio.hwaveout.native-type.v1", + "selector": { + "name": "HWAVEOUT", + "namespace": "Windows.Win32.Media.Audio", + "sourceFingerprint": "62458DA1DC2DFC1F052A29CDA151E535100D402EFE23C210FDC33C00532878F6" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.multimedia.hic.native-type.v1", + "selector": { + "name": "HIC", + "namespace": "Windows.Win32.Media.Multimedia", + "sourceFingerprint": "C43CBBC2B2F15DB872256FF2BF39C564F5A0A26DBE684C4EAE7CD8A1A760BB49" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networking.httpserver.http_request_queue_handle.native-type.v1", + "selector": { + "name": "HTTP_REQUEST_QUEUE_HANDLE", + "namespace": "Windows.Win32.Networking.HttpServer", + "sourceFingerprint": "5984B12FE3645DF88F5E42B521FE8A07E867937221381F4CCF7E1553E1D27709" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networking.websocket.web_socket_handle.native-type.v1", + "selector": { + "name": "WEB_SOCKET_HANDLE", + "namespace": "Windows.Win32.Networking.WebSocket", + "sourceFingerprint": "606CCAACFDDE65878A6E9EBE232D4C1CE295B2CDCE2415B9B844ADEB5E0FD865" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networking.winsock.socket.native-type.v1", + "selector": { + "name": "SOCKET", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "35057FC3AF4B596814EE4325520B39C4DF40F06CFAEE5D6C9426B93156E659CB" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networking.winsock.wsaevent.native-type.v1", + "selector": { + "name": "WSAEVENT", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B9C42B692F5E36012CEF4CE0E52CDBA69B3498854198E46F91E367D22409C387" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.iphelper.hiftimestampchange.native-type.v1", + "selector": { + "name": "HIFTIMESTAMPCHANGE", + "namespace": "Windows.Win32.NetworkManagement.IpHelper", + "sourceFingerprint": "553412D6091F3B1084CA1578C976E4A0C21326D4B78CAEF86A47538BAEFF2909" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_callout_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_CALLOUT_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "2B9EAA0E5E6A1DA65C36DA748C67D86505B0480F239B31E450C7E492838676FD" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_connection_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_CONNECTION_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "B45543CC2C26030040B34F61F637C678A5F3A89BBC5CD4114CADDB378DF83EC4" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_engine_handle.native-type.v1", + "selector": { + "name": "FWPM_ENGINE_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "7E826FF84225B3A41C8CC2797F24441FBE501F50EE5D1C1B02B235335E9CF36D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_filter_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_FILTER_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "1A3E67A79074601517EACF5075E8F0B49880D4D80293B0D258281D9691FD695D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_layer_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_LAYER_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "01A3BA598E97339FFA61C0D82A6F90BEBD7115F4ED314AFEB6BAA51D2326C307" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_net_event_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_NET_EVENT_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "F113F19235DEB018DA70DCA5FA68A93019BB8C6DC0B7C85CAD5AEB71B4125823" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_provider_context_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_PROVIDER_CONTEXT_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "B5024E943507C21FDD6CA4795A9AABFB50708B6314AF719659393AD99CA22E8A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_provider_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_PROVIDER_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "9A0C685D33BA0CB191890BD2D664C2CA014B619AE33845A37DF8F7150B8DFFB8" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_session_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_SESSION_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "10EFA5AB3BA78520E22B77813985EAEEA9DF2391645D7FAB9C2BA604BC607E03" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.fwpm_sublayer_enum_handle.native-type.v1", + "selector": { + "name": "FWPM_SUBLAYER_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "2E469621A032D1276C181C4332C81C2DBC9C6CF58E4C02803F2747060F4359FB" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.ikeext_sa_enum_handle.native-type.v1", + "selector": { + "name": "IKEEXT_SA_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "4495DB9342E428CEF88D5DF92604029F1A3BFE40DC3DD76A5A4517B0D49EA790" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.ipsec_dosp_state_enum_handle.native-type.v1", + "selector": { + "name": "IPSEC_DOSP_STATE_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "F8ACFA993432E781E0998A44920E8DD415DB79311251A6656DB8A0BC204F03F4" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.ipsec_sa_context_enum_handle.native-type.v1", + "selector": { + "name": "IPSEC_SA_CONTEXT_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "A91A358A71431B378913768DCCD8AF8D523970BF6ADCAC8E9BF2D4A7E52B0FEF" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networkmanagement.windowsfilteringplatform.ipsec_sa_enum_handle.native-type.v1", + "selector": { + "name": "IPSEC_SA_ENUM_HANDLE", + "namespace": "Windows.Win32.NetworkManagement.WindowsFilteringPlatform", + "sourceFingerprint": "313B0842D4303C31CCAF900BA683344BF250801D28D5D61D4F3B94F008D9A2B3" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.authentication.identity.lsa_handle.native-type.v1", + "selector": { + "name": "LSA_HANDLE", + "namespace": "Windows.Win32.Security.Authentication.Identity", + "sourceFingerprint": "38CDA5201C4AAD02B50814F92E6F20EBAB41204A4C7E023B2107B4F30EAE105A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/SecMgmt/lsa-handle" + } + ] + }, + { + "id": "windows.win32.security.authorization.authz_access_check_results_handle.native-type.v1", + "selector": { + "name": "AUTHZ_ACCESS_CHECK_RESULTS_HANDLE", + "namespace": "Windows.Win32.Security.Authorization", + "sourceFingerprint": "CD042DB36BC51597C8BDF6BD886363D71466FEE730679B27431F9ED51A1F60F5" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.authorization.authz_audit_event_handle.native-type.v1", + "selector": { + "name": "AUTHZ_AUDIT_EVENT_HANDLE", + "namespace": "Windows.Win32.Security.Authorization", + "sourceFingerprint": "CF551CC2B2728FF907F8A3CF25819F90673D0C284DB9D7B008B3300A42BF8C89" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.authorization.authz_cap_change_subscription_handle.native-type.v1", + "selector": { + "name": "AUTHZ_CAP_CHANGE_SUBSCRIPTION_HANDLE", + "namespace": "Windows.Win32.Security.Authorization", + "sourceFingerprint": "3EB2CBC21C1CDE523B072D995A53203E66CF1DF6E0733C42FD606684D9608E76" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.authorization.authz_client_context_handle.native-type.v1", + "selector": { + "name": "AUTHZ_CLIENT_CONTEXT_HANDLE", + "namespace": "Windows.Win32.Security.Authorization", + "sourceFingerprint": "8CAD9E62FF175A8F4F2F507B199DE355892F692A2A186FEF39BFB2DB00825F16" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.authorization.authz_resource_manager_handle.native-type.v1", + "selector": { + "name": "AUTHZ_RESOURCE_MANAGER_HANDLE", + "namespace": "Windows.Win32.Security.Authorization", + "sourceFingerprint": "D3AA934CE7CA0DD018970DB20A5A94D1FA76B43248DD0117C9FFAA5BCF911AC7" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.bcrypt_alg_handle.native-type.v1", + "selector": { + "name": "BCRYPT_ALG_HANDLE", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "82DE7E905EC8202081874EDB72E7182083ECDFADB32B5DC140E1EED43730043A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.bcrypt_hash_handle.native-type.v1", + "selector": { + "name": "BCRYPT_HASH_HANDLE", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "13183BE9953C47F7A0E2932F014B329C9FD7BB9E314E7CBF1F32F0E02C57E89D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.bcrypt_key_handle.native-type.v1", + "selector": { + "name": "BCRYPT_KEY_HANDLE", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "A5CF43046441AA4CBB08488571BAE3E0F6AE964013661CD16A89FDB016995884" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.bcrypt_secret_handle.native-type.v1", + "selector": { + "name": "BCRYPT_SECRET_HANDLE", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "6F9A5CF220A860AA5793F0B0E8C88473855C13884889503F28B22479C6D6ECE0" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.hcertchainengine.native-type.v1", + "selector": { + "name": "HCERTCHAINENGINE", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "C701132140F6D73AF8727C5F7A55F573CE2524954C4F4E903E0654478C3C7A9A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.hcryptasync.native-type.v1", + "selector": { + "name": "HCRYPTASYNC", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "BC2D50C270E632AF7CA1D82083494B50F6252C9AC9F77E57C2DCFB1EE544117D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.ncrypt_handle.native-type.v1", + "selector": { + "name": "NCRYPT_HANDLE", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "26BE273452E7F27A7C15E958B217048BF29EFD825D8E947A0C49EA62E9FAAF09" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.ncrypt_key_handle.native-type.v1", + "selector": { + "name": "NCRYPT_KEY_HANDLE", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "A6161BAC1B0FBC5B21728648BD16CCC616A6A124E74E2917600B2510805C1205" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.cryptography.ncrypt_prov_handle.native-type.v1", + "selector": { + "name": "NCRYPT_PROV_HANDLE", + "namespace": "Windows.Win32.Security.Cryptography", + "sourceFingerprint": "B8EAD99AC1F042FCABCB5082A8CE5534ACD82311B15BBBA0BC71FE7AB603A9B4" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.diagnosticdataquery.hdiagnostic_data_query_session.native-type.v1", + "selector": { + "name": "HDIAGNOSTIC_DATA_QUERY_SESSION", + "namespace": "Windows.Win32.Security.DiagnosticDataQuery", + "sourceFingerprint": "71B88F51AEABCFF611B9B7C2B9E138D2CDE93A470B05F69055AC7F9695A9CD79" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.diagnosticdataquery.hdiagnostic_event_category_description.native-type.v1", + "selector": { + "name": "HDIAGNOSTIC_EVENT_CATEGORY_DESCRIPTION", + "namespace": "Windows.Win32.Security.DiagnosticDataQuery", + "sourceFingerprint": "E8438A8DAEB76C53989A3A2B29843E604D6BA5816F595A4415421A2EEDC00E4F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.diagnosticdataquery.hdiagnostic_event_producer_description.native-type.v1", + "selector": { + "name": "HDIAGNOSTIC_EVENT_PRODUCER_DESCRIPTION", + "namespace": "Windows.Win32.Security.DiagnosticDataQuery", + "sourceFingerprint": "91C6DDB76CF89019B6B30EB92A7EBBEEA44E269D772B2F19A9072D237C1C8275" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.diagnosticdataquery.hdiagnostic_event_tag_description.native-type.v1", + "selector": { + "name": "HDIAGNOSTIC_EVENT_TAG_DESCRIPTION", + "namespace": "Windows.Win32.Security.DiagnosticDataQuery", + "sourceFingerprint": "0837A2A63538D5BD973822DE91E7CCEF47F9C7D8FFD3875BCACFD3FC5BCD2355" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.diagnosticdataquery.hdiagnostic_record.native-type.v1", + "selector": { + "name": "HDIAGNOSTIC_RECORD", + "namespace": "Windows.Win32.Security.DiagnosticDataQuery", + "sourceFingerprint": "F98BB612DE1A1996AE2BE7F660F9F76BC5C5DBAFF4A589BA9BAC95EFE7790D8F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.diagnosticdataquery.hdiagnostic_report.native-type.v1", + "selector": { + "name": "HDIAGNOSTIC_REPORT", + "namespace": "Windows.Win32.Security.DiagnosticDataQuery", + "sourceFingerprint": "24BF0A3AB2D5BA566EC27D16EECE8444618E64A638EC8DD91A8BE6721DC78C3B" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.psecurity_descriptor.native-type.v1", + "selector": { + "name": "PSECURITY_DESCRIPTOR", + "namespace": "Windows.Win32.Security", + "sourceFingerprint": "AD6991F1B7C0A1DF898C0EA65B6D4164EA4FFF02C2633B1CADA1BEFBE94D0C1D" + }, + "meaning": { + "kind": "data-pointer" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.security.psid.native-type.v1", + "selector": { + "name": "PSID", + "namespace": "Windows.Win32.Security", + "sourceFingerprint": "9B1E6B1F77CF017E33F7A3AE470815BED786AD2820839F1F3671325A28C96721" + }, + "meaning": { + "kind": "data-pointer" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.storage.cloudfilters.cf_connection_key.native-type.v1", + "selector": { + "name": "CF_CONNECTION_KEY", + "namespace": "Windows.Win32.Storage.CloudFilters", + "sourceFingerprint": "C235D0EF7AEEE3AD7879DBA8FD712C4431C6B380E12EB078D4228EF137605C69" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.storage.compression.compressor_handle.native-type.v1", + "selector": { + "name": "COMPRESSOR_HANDLE", + "namespace": "Windows.Win32.Storage.Compression", + "sourceFingerprint": "A6A6758457C5DED3BC290517E76D20800C6F3C58E4FED3A8B4541A98F8779259" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.storage.compression.decompressor_handle.native-type.v1", + "selector": { + "name": "DECOMPRESSOR_HANDLE", + "namespace": "Windows.Win32.Storage.Compression", + "sourceFingerprint": "F1F6722414245DF3945E3D58C38CA8F03B177FA879EBA9BD4B8CA08DE3DE46F8" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.storage.filehistory.fh_service_pipe_handle.native-type.v1", + "selector": { + "name": "FH_SERVICE_PIPE_HANDLE", + "namespace": "Windows.Win32.Storage.FileHistory", + "sourceFingerprint": "977B51BA00429EFDA1309A60D6E7B44D480B9F647A02D7E5481EF3CD40FC7F3C" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.storage.filesystem.hioring.native-type.v1", + "selector": { + "name": "HIORING", + "namespace": "Windows.Win32.Storage.FileSystem", + "sourceFingerprint": "47E78CB69307900FA6F811797896FFCB3057FC607FBF8B9A60C2B881A209B672" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.storage.installablefilesystems.hfilter.native-type.v1", + "selector": { + "name": "HFILTER", + "namespace": "Windows.Win32.Storage.InstallableFileSystems", + "sourceFingerprint": "96A69F8D621A15A477B900A1F18E6469A07E53F44B04FCE59F7F10534A2871B1" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.storage.installablefilesystems.hfilter_instance.native-type.v1", + "selector": { + "name": "HFILTER_INSTANCE", + "namespace": "Windows.Win32.Storage.InstallableFileSystems", + "sourceFingerprint": "09177C9724B87453AF77C320C367CD124BE9FBD38CC6884855B18D738D9ECBCD" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.storage.jet.jet_instance.native-type.v1", + "selector": { + "name": "JET_INSTANCE", + "namespace": "Windows.Win32.Storage.Jet", + "sourceFingerprint": "5B25D450BA42FBF0367B74EE0B19DE4FAA0D10D94FA60267543387818099BA3D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/extensible-storage-engine/jet-instance" + } + ] + }, + { + "id": "windows.win32.storage.jet.jet_sesid.native-type.v1", + "selector": { + "name": "JET_SESID", + "namespace": "Windows.Win32.Storage.Jet", + "sourceFingerprint": "BB2FCF2A93348481D8C3BE9D360959F2AF5474D9CA48B256F330F3972FA0E8B9" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/extensible-storage-engine/jet-sesid-structure" + } + ] + }, + { + "id": "windows.win32.system.applicationinstallationandservicing.msihandle.native-type.v1", + "selector": { + "name": "MSIHANDLE", + "namespace": "Windows.Win32.System.ApplicationInstallationAndServicing", + "sourceFingerprint": "09FED42DDA01D8B9ED60F63E6CA8942093DF1725B739E319917517F0F43A080F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.com.co_device_catalog_cookie.native-type.v1", + "selector": { + "name": "CO_DEVICE_CATALOG_COOKIE", + "namespace": "Windows.Win32.System.Com", + "sourceFingerprint": "726A21DD713BA4397A6876F657483BC01C330EF2965CD54CA805B7F61FAF0C9D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.com.co_mta_usage_cookie.native-type.v1", + "selector": { + "name": "CO_MTA_USAGE_COOKIE", + "namespace": "Windows.Win32.System.Com", + "sourceFingerprint": "915C5C822AEEA17D41A6F2A91F36AA42D34D63C04882CE2B230275E3DAC42B93" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.console.hpcon.native-type.v1", + "selector": { + "name": "HPCON", + "namespace": "Windows.Win32.System.Console", + "sourceFingerprint": "D617D23DFB882E93DCA72BABB6C45FAD2A59421F75895DD6E874E590B046EA52" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.dataexchange.hconv.native-type.v1", + "selector": { + "name": "HCONV", + "namespace": "Windows.Win32.System.DataExchange", + "sourceFingerprint": "8F284B124C707F1A8B2DC53A6853966CDF4FA61D696BC5CEE666EF7FA0E7346F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.dataexchange.hconvlist.native-type.v1", + "selector": { + "name": "HCONVLIST", + "namespace": "Windows.Win32.System.DataExchange", + "sourceFingerprint": "A84BE1261782960194E1CBA9B91ECF834ABDA563457802C182F2181E215522AE" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.dataexchange.hddedata.native-type.v1", + "selector": { + "name": "HDDEDATA", + "namespace": "Windows.Win32.System.DataExchange", + "sourceFingerprint": "EF4244C669BDB123AC179EBF2ED79CFBDB5680E33B3BDB89C8DE7F6120D62BFA" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.diagnostics.etw.processtrace_handle.native-type.v1", + "selector": { + "name": "PROCESSTRACE_HANDLE", + "namespace": "Windows.Win32.System.Diagnostics.Etw", + "sourceFingerprint": "19A2976C762C1B007C37D9D898B0F532F6A8F59BD9BFD2756DA9573ED4B2976B" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.diagnostics.etw.reghandle.native-type.v1", + "selector": { + "name": "REGHANDLE", + "namespace": "Windows.Win32.System.Diagnostics.Etw", + "sourceFingerprint": "A9CED6E465C360FA99CE43A1B5524EDB1E08C21CE2BC9A8D6EB61BB76CF0AAB7" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.diagnostics.etw.tdh_handle.native-type.v1", + "selector": { + "name": "TDH_HANDLE", + "namespace": "Windows.Win32.System.Diagnostics.Etw", + "sourceFingerprint": "46B5B642CD6585599CC61D49019B27321D5141967ECD57F60A3912FCBCB9B2E7" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.diagnostics.processsnapshotting.hpsswalk.native-type.v1", + "selector": { + "name": "HPSSWALK", + "namespace": "Windows.Win32.System.Diagnostics.ProcessSnapshotting", + "sourceFingerprint": "6E7B0F82A4CCC222CB8EF8449B8FCB3277B1219C3F72D720CDF71EC21610E205" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.errorreporting.hreport.native-type.v1", + "selector": { + "name": "HREPORT", + "namespace": "Windows.Win32.System.ErrorReporting", + "sourceFingerprint": "ED0A3F06368CD8FAD257DBF985B5A5F30F8D0F8925A693A677854DCD6F97AEA2" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.errorreporting.hreportstore.native-type.v1", + "selector": { + "name": "HREPORTSTORE", + "namespace": "Windows.Win32.System.ErrorReporting", + "sourceFingerprint": "5266380C7214648C91232DCD797C13D5C9B1873EEE07155CA601A04D0A1A836E" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.eventlog.evt_handle.native-type.v1", + "selector": { + "name": "EVT_HANDLE", + "namespace": "Windows.Win32.System.EventLog", + "sourceFingerprint": "7D826986BCADE944EBC6681A04F16035A759CD2F819BE59F8473EA30A2C4D0CD" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.hostcomputesystem.hcs_operation.native-type.v1", + "selector": { + "name": "HCS_OPERATION", + "namespace": "Windows.Win32.System.HostComputeSystem", + "sourceFingerprint": "B662E205D2503CD0F9749B229EA14BA0331B87B5D74F6FE05F195A5B9F5C34E1" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.hostcomputesystem.hcs_process.native-type.v1", + "selector": { + "name": "HCS_PROCESS", + "namespace": "Windows.Win32.System.HostComputeSystem", + "sourceFingerprint": "4A06BDAAF448CBBF0BAE9ACC7F0517A7E00246628F098F8D7370E6B8B7D8EFA7" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.hostcomputesystem.hcs_system.native-type.v1", + "selector": { + "name": "HCS_SYSTEM", + "namespace": "Windows.Win32.System.HostComputeSystem", + "sourceFingerprint": "DF17E77CDCB19B8B952BE6AC549964013E3DE6BE2F30F12E2CDDCC8C24CFAE3C" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.hypervisor.whv_partition_handle.native-type.v1", + "selector": { + "name": "WHV_PARTITION_HANDLE", + "namespace": "Windows.Win32.System.Hypervisor", + "sourceFingerprint": "8DA0BA9DA032E608C81B761D17300BDC7B80AED3413B18B799D2DADD9059CAB6" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.memory.memory_mapped_view_address.native-type.v1", + "selector": { + "name": "MEMORY_MAPPED_VIEW_ADDRESS", + "namespace": "Windows.Win32.System.Memory", + "sourceFingerprint": "CF18DD34A4BA520FAF99D6B02D2694AEAA71795FCE3355CC1215084D39719396" + }, + "meaning": { + "kind": "data-pointer" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.performance.pdh_hlog.native-type.v1", + "selector": { + "name": "PDH_HLOG", + "namespace": "Windows.Win32.System.Performance", + "sourceFingerprint": "DB9B3C22EECD0F1986FA5D26CE88D40EE80ABCC5C8FF645D381D3A7813A2ADB8" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.performance.pdh_hquery.native-type.v1", + "selector": { + "name": "PDH_HQUERY", + "namespace": "Windows.Win32.System.Performance", + "sourceFingerprint": "8B6C6D03E131CEFEA618C21E1DF762A51DBAFE7AD51E10657285A3A3FF7CA011" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.power.hpowernotify.native-type.v1", + "selector": { + "name": "HPOWERNOTIFY", + "namespace": "Windows.Win32.System.Power", + "sourceFingerprint": "C775F0E8A8B2E5B81382BA70D3467E7803C16DE1B74FD103BD4F92830DD18B2A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.registry.hkey.native-type.v1", + "selector": { + "name": "HKEY", + "namespace": "Windows.Win32.System.Registry", + "sourceFingerprint": "195DA06A0E1516996DC1FAE37E24A56138F1B55601B8E36E2292E51A9587DD77" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.remotedesktop.wts_cloud_auth_handle.native-type.v1", + "selector": { + "name": "WTS_CLOUD_AUTH_HANDLE", + "namespace": "Windows.Win32.System.RemoteDesktop", + "sourceFingerprint": "8AC486F7F6736B0B604A6FB6A5289F3CD6D989B660AF11F334375DA0F4597740" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.rpc.rpc_status.native-type.v1", + "selector": { + "name": "RPC_STATUS", + "namespace": "Windows.Win32.System.Rpc", + "sourceFingerprint": "339F675245880DC1BD7E17BA3DAB38866D17DCE0262371605F9B6CD7910A6213" + }, + "meaning": null, + "status": "zero", + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/Rpc/rpc-status" + } + ] + }, + { + "id": "windows.win32.system.services.sc_handle.native-type.v1", + "selector": { + "name": "SC_HANDLE", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "02A7BF6AF27778591961EBBFC56667731CE3FC0A180A3F4D02D617CFF2BBFE4F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.services.service_status_handle.native-type.v1", + "selector": { + "name": "SERVICE_STATUS_HANDLE", + "namespace": "Windows.Win32.System.Services", + "sourceFingerprint": "40BFE85872BCFB49FB9766AD794FD2F3FCAE44BC7C19263E2AA496AE551EAE5B" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.stationsanddesktops.hdesk.native-type.v1", + "selector": { + "name": "HDESK", + "namespace": "Windows.Win32.System.StationsAndDesktops", + "sourceFingerprint": "6DDEB25E95014AF845617764AB656C9CE994FE661B1B448101917788345F9E75" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.stationsanddesktops.hwinsta.native-type.v1", + "selector": { + "name": "HWINSTA", + "namespace": "Windows.Win32.System.StationsAndDesktops", + "sourceFingerprint": "8E0C4C69C816590C9104675A0EB934F63A5A386920196759D5EFB3A6B6415C6F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.avrt_task_handle.native-type.v1", + "selector": { + "name": "AVRT_TASK_HANDLE", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "CAE2F3BDB5FC22F9091566EDE5DAAEEE55965349BF8A20A1F72F42C748431CC1" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.avrt_thread_ordering_group_handle.native-type.v1", + "selector": { + "name": "AVRT_THREAD_ORDERING_GROUP_HANDLE", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "EA8BDCAE60AB3737BD4B46D984C9821A6A8AC367654F310A658E918A251B81E2" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.lpproc_thread_attribute_list.native-type.v1", + "selector": { + "name": "LPPROC_THREAD_ATTRIBUTE_LIST", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "1BDC3BC48B21B124278D4999579768E9A59BA7016EDC4CFF5856BB3E40A5ABFD" + }, + "meaning": { + "kind": "data-pointer" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.ptp_cleanup_group.native-type.v1", + "selector": { + "name": "PTP_CLEANUP_GROUP", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "61FE4C41FA65009C7CF7BB312DC0EB3E158190A191C1231492354B9C4AB11E9F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.ptp_io.native-type.v1", + "selector": { + "name": "PTP_IO", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "FDD5B79B189FD619EAE3CE1239ABBBA2ED6D0E4380140FA9E1F82BACDCB792D3" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.ptp_pool.native-type.v1", + "selector": { + "name": "PTP_POOL", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "F55F45887D0870D2A4910784F7891BD88B20F91956AC235518CCC1BF4F35EE65" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.ptp_timer.native-type.v1", + "selector": { + "name": "PTP_TIMER", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "C5B2BBA127FDA8F4C728C6283EE8DFC5DDEA87B193FD673EB7157249955D6B6A" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.ptp_wait.native-type.v1", + "selector": { + "name": "PTP_WAIT", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "E08FDCFE07F809DBAFA846865E994DDFF6D76E6ED124A8979BE1661ECDD49F20" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.threading.ptp_work.native-type.v1", + "selector": { + "name": "PTP_WORK", + "namespace": "Windows.Win32.System.Threading", + "sourceFingerprint": "10E1C9D7873533C60E0BAA9671307B55A881A38FD78879515711BA6C7D81C4E8" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.windowsprogramming.feature_state_change_subscription.native-type.v1", + "selector": { + "name": "FEATURE_STATE_CHANGE_SUBSCRIPTION", + "namespace": "Windows.Win32.System.WindowsProgramming", + "sourceFingerprint": "94463D9C0E3ED3A7C998A6DC5B91054CDB82B15EBBE12C6903D61E57A720EF46" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.system.winrt.hstring.native-type.v1", + "selector": { + "name": "HSTRING", + "namespace": "Windows.Win32.System.WinRT", + "sourceFingerprint": "064569B0267AF1AB94CDFF7EF79303C64F8DCCA2E567B6AD8937449F9C8C9E8D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/WinRT/hstring" + } + ] + }, + { + "id": "windows.win32.system.winrt.hstring_buffer.native-type.v1", + "selector": { + "name": "HSTRING_BUFFER", + "namespace": "Windows.Win32.System.WinRT", + "sourceFingerprint": "61934D89695722C5FADB684754385176F1194B0C82BC76B8E3B1C40CC13C5567" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/WinRT/hstring-buffer" + } + ] + }, + { + "id": "windows.win32.system.winrt.metadata.roparamiidhandle.native-type.v1", + "selector": { + "name": "ROPARAMIIDHANDLE", + "namespace": "Windows.Win32.System.WinRT.Metadata", + "sourceFingerprint": "EBC5BA41CD20A7DC64ADED937430057D0CCDA4AD96669AE5D0C6DEE0EB8015D1" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.accessibility.huiaevent.native-type.v1", + "selector": { + "name": "HUIAEVENT", + "namespace": "Windows.Win32.UI.Accessibility", + "sourceFingerprint": "5FBEBEB67073232F7B083CEF311E4BE7D33F20A2CA6879D2E7C954DBDDD67C2C" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.accessibility.huianode.native-type.v1", + "selector": { + "name": "HUIANODE", + "namespace": "Windows.Win32.UI.Accessibility", + "sourceFingerprint": "7867A891B72E07C68B6AE64A473C027F60CED91AC093C30600500EF27CB04276" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.accessibility.huiapatternobject.native-type.v1", + "selector": { + "name": "HUIAPATTERNOBJECT", + "namespace": "Windows.Win32.UI.Accessibility", + "sourceFingerprint": "7CD4BD94BBB3F86CA7A5B195B4D16CF2C00B4417FDECCAD88AA93D8BBD279C02" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.accessibility.huiatextrange.native-type.v1", + "selector": { + "name": "HUIATEXTRANGE", + "namespace": "Windows.Win32.UI.Accessibility", + "sourceFingerprint": "75A8FEC11962EDA274C13873D3F3481A350D7521C8435618AD0CD085F3761BD4" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.accessibility.hwineventhook.native-type.v1", + "selector": { + "name": "HWINEVENTHOOK", + "namespace": "Windows.Win32.UI.Accessibility", + "sourceFingerprint": "067000BE4C25FEF72F4069A9DB335FD60B45EA0E5B2EA6D32DAC251CEF190491" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/WinAuto/hwineventhook" + } + ] + }, + { + "id": "windows.win32.ui.colorsystem.hcolorspace.native-type.v1", + "selector": { + "name": "HCOLORSPACE", + "namespace": "Windows.Win32.UI.ColorSystem", + "sourceFingerprint": "4318B41A1700B3F5212EC8FD0DE2683A733C6AFB1D6A1B6BDC881839380ED629" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.controls.hdpa.native-type.v1", + "selector": { + "name": "HDPA", + "namespace": "Windows.Win32.UI.Controls", + "sourceFingerprint": "2A89D84F9DC7CBE8B3F15689CB70E6FFB153395E43EA8BFF0F5954A3B109488E" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.controls.hdsa.native-type.v1", + "selector": { + "name": "HDSA", + "namespace": "Windows.Win32.UI.Controls", + "sourceFingerprint": "3E68A1B0A4ABBAC66B051A1D777CBE4A3E59E11CE06B7EC86D64DFC4248D5697" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.controls.himagelist.native-type.v1", + "selector": { + "name": "HIMAGELIST", + "namespace": "Windows.Win32.UI.Controls", + "sourceFingerprint": "5956EBB5C30F8883210E754F3F7797FCC664B75BFFF3BF55C1874A1CB3D39832" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.controls.hpropsheetpage.native-type.v1", + "selector": { + "name": "HPROPSHEETPAGE", + "namespace": "Windows.Win32.UI.Controls", + "sourceFingerprint": "70FD3F674A5D65B1A1DD845501AE6E007CF58724B30BA7D9EEF896DB1EEFFFBB" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.controls.htheme.native-type.v1", + "selector": { + "name": "HTHEME", + "namespace": "Windows.Win32.UI.Controls", + "sourceFingerprint": "F565DC59FDC00B74497AAC09263B5B869AEA689C86D82C84C0BE18AFC0E6E447" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.hidpi.dpi_awareness_context.native-type.v1", + "selector": { + "name": "DPI_AWARENESS_CONTEXT", + "namespace": "Windows.Win32.UI.HiDpi", + "sourceFingerprint": "FFDAE9E079636A2D7346781F3B0B344DA22E857D3C14FB7FF32ECB4E8925AC3E" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.input.hrawinput.native-type.v1", + "selector": { + "name": "HRAWINPUT", + "namespace": "Windows.Win32.UI.Input", + "sourceFingerprint": "59F287AE5159D42E231ACFF4BF3EB6C325798E4CF2662F5953A5ACDD751DC865" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.input.ime.himc.native-type.v1", + "selector": { + "name": "HIMC", + "namespace": "Windows.Win32.UI.Input.Ime", + "sourceFingerprint": "EDBA912FCE19DCBD2776EC08F538F6233567A123FBDD36E7BB90CB21EF84A522" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.input.keyboardandmouse.hkl.native-type.v1", + "selector": { + "name": "HKL", + "namespace": "Windows.Win32.UI.Input.KeyboardAndMouse", + "sourceFingerprint": "D8DD31678E14BF635A14B2DBF9A2FC953B55B1FF0EE1DDF94D9C1EB0C18EE168" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.input.pointer.hsyntheticpointerdevice.native-type.v1", + "selector": { + "name": "HSYNTHETICPOINTERDEVICE", + "namespace": "Windows.Win32.UI.Input.Pointer", + "sourceFingerprint": "0FE98F98A29B55933124440944B5EE4DA6390BDD6A8124BD048F60355D7375A3" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.input.touch.hgestureinfo.native-type.v1", + "selector": { + "name": "HGESTUREINFO", + "namespace": "Windows.Win32.UI.Input.Touch", + "sourceFingerprint": "5FD977C608F570ECE52A5A49BEF2B9223CF957C1357348C9E5A2010566F7C01C" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.input.touch.htouchinput.native-type.v1", + "selector": { + "name": "HTOUCHINPUT", + "namespace": "Windows.Win32.UI.Input.Touch", + "sourceFingerprint": "A0F252EF7431ED0AF151BCBCD4251E90D6A52644292A1DD9ED26F467F6746E48" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.interactioncontext.hinteractioncontext.native-type.v1", + "selector": { + "name": "HINTERACTIONCONTEXT", + "namespace": "Windows.Win32.UI.InteractionContext", + "sourceFingerprint": "4E161A62EB519BD0B38796F8F69060DB52934A9475FB2B153F961FF58AA36BA4" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.shell.hpsxa.native-type.v1", + "selector": { + "name": "HPSXA", + "namespace": "Windows.Win32.UI.Shell", + "sourceFingerprint": "2E7451EAC9AA5308D6602D8E31595236C0AB059206554149DFEE92E89C7E136D" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.tabletpc.hrecoalt.native-type.v1", + "selector": { + "name": "HRECOALT", + "namespace": "Windows.Win32.UI.TabletPC", + "sourceFingerprint": "A35FD503FCDC225045C17E0B3925EDBDBEA230598394769D12E43C3E58944972" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/tablet/hrecoalt-handle" + } + ] + }, + { + "id": "windows.win32.ui.tabletpc.hrecocontext.native-type.v1", + "selector": { + "name": "HRECOCONTEXT", + "namespace": "Windows.Win32.UI.TabletPC", + "sourceFingerprint": "30276F09DBD43B83CB48AD1706D6B9CD960D550294DE04A8FA595DE487403A15" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/tablet/hrecocontext-handle" + } + ] + }, + { + "id": "windows.win32.ui.tabletpc.hrecognizer.native-type.v1", + "selector": { + "name": "HRECOGNIZER", + "namespace": "Windows.Win32.UI.TabletPC", + "sourceFingerprint": "611242B0FCBE9447A5B413269ACC14C32DE64BDAECE45550408AA333BF6B0CFC" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/tablet/hrecognizer-handle" + } + ] + }, + { + "id": "windows.win32.ui.tabletpc.hrecowordlist.native-type.v1", + "selector": { + "name": "HRECOWORDLIST", + "namespace": "Windows.Win32.UI.TabletPC", + "sourceFingerprint": "AFB04399F969BAEAC5CC096F6CA7BDAA9087E0E61E9BCFBFCEFC9F1AF74F8441" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/tablet/hrecowordlist-handle" + } + ] + }, + { + "id": "windows.win32.ui.windowsandmessaging.haccel.native-type.v1", + "selector": { + "name": "HACCEL", + "namespace": "Windows.Win32.UI.WindowsAndMessaging", + "sourceFingerprint": "8D330D92D8FC7DF77E9409A8F2D44DC620D1E7BBE9493FE42498AD5B0A7B5104" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.windowsandmessaging.hcursor.native-type.v1", + "selector": { + "name": "HCURSOR", + "namespace": "Windows.Win32.UI.WindowsAndMessaging", + "sourceFingerprint": "4D0EB2BE3970E8DDE11EF583E5D32DFDC8C1008D59155038A303CC41BA40307F" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.windowsandmessaging.hdevnotify.native-type.v1", + "selector": { + "name": "HDEVNOTIFY", + "namespace": "Windows.Win32.UI.WindowsAndMessaging", + "sourceFingerprint": "CD753F4193FD3965C1CA324BC0330F841A2ABEF60CC07BA423763E45BC5CB9B3" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.windowsandmessaging.hdwp.native-type.v1", + "selector": { + "name": "HDWP", + "namespace": "Windows.Win32.UI.WindowsAndMessaging", + "sourceFingerprint": "A924213A0C146A09A59AEA7F19C4590B1C5A8819CF7C4029031E139676874515" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.windowsandmessaging.hhook.native-type.v1", + "selector": { + "name": "HHOOK", + "namespace": "Windows.Win32.UI.WindowsAndMessaging", + "sourceFingerprint": "04DB023159673BBB56525FCD22BC440D9184646BE628DD33FA5D5804EE864267" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.windowsandmessaging.hicon.native-type.v1", + "selector": { + "name": "HICON", + "namespace": "Windows.Win32.UI.WindowsAndMessaging", + "sourceFingerprint": "FFB8B9A5A94F62E359113428CE19941DD3EC876014E9E20B33D901E047BA380E" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.ui.windowsandmessaging.hmenu.native-type.v1", + "selector": { + "name": "HMENU", + "namespace": "Windows.Win32.UI.WindowsAndMessaging", + "sourceFingerprint": "03A2B0FDA0138A8A19633F85E23EB3B9CD2202E91AD0263F337D02AB04AEA482" + }, + "meaning": { + "kind": "handle" + }, + "status": null, + "aggregate": null, + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + } + ] +} diff --git a/tools/dynwinrt-codegen/contracts/win32/policy-domains.json b/tools/dynwinrt-codegen/contracts/win32/policy-domains.json new file mode 100644 index 00000000..5cad3a7a --- /dev/null +++ b/tools/dynwinrt-codegen/contracts/win32/policy-domains.json @@ -0,0 +1,24 @@ +{ + "schemaVersion": 2, + "entries": [ + { + "kind": "subsystem", + "namespace": "Windows.Win32.Networking.WinSock", + "subsystem": "winsock" + }, + { + "kind": "subsystem", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "subsystem": "gdi-plus" + }, + { + "kind": "subsystem", + "namespace": "Windows.Win32.Media.MediaFoundation", + "subsystem": "media-foundation" + }, + { + "kind": "provider-lifecycle", + "dll": "mapi32.dll" + } + ] +} diff --git a/tools/dynwinrt-codegen/contracts/win32/schema.json b/tools/dynwinrt-codegen/contracts/win32/schema.json new file mode 100644 index 00000000..9c84e2c9 --- /dev/null +++ b/tools/dynwinrt-codegen/contracts/win32/schema.json @@ -0,0 +1,995 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://github.com/microsoft/dynwinrt/contracts/win32/schema.json", + "title": "Win32 native semantic evidence, version 2", + "type": "object", + "additionalProperties": false, + "required": [ + "schemaVersion", + "entries" + ], + "properties": { + "schemaVersion": { + "const": 2 + }, + "entries": { + "type": "array", + "items": { + "oneOf": [ + { + "$ref": "#/$defs/functionEntry" + }, + { + "$ref": "#/$defs/typeEntry" + }, + { + "$ref": "#/$defs/domain" + } + ] + } + } + }, + "$defs": { + "functionSelector": { + "type": "object", + "additionalProperties": false, + "required": [ + "namespace", + "container", + "name", + "dll", + "entryPoint", + "callingConvention", + "architectures", + "sourceFingerprint" + ], + "properties": { + "namespace": { + "type": "string", + "pattern": "^Windows\\.Win32\\.[A-Za-z0-9_.]+$" + }, + "container": { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" + }, + "dll": { + "type": "string", + "pattern": "^[A-Za-z0-9_.-]+\\.([dD][lL][lL]|[dD][rR][vV])$" + }, + "entryPoint": { + "type": "string", + "minLength": 1 + }, + "callingConvention": { + "enum": [ + "system", + "cdecl", + "unsupported" + ] + }, + "architectures": { + "type": "integer", + "minimum": 0, + "maximum": 7 + }, + "sourceFingerprint": { + "type": "string", + "pattern": "^[0-9A-F]{64}$" + } + } + }, + "typeSelector": { + "type": "object", + "additionalProperties": false, + "required": [ + "namespace", + "name", + "sourceFingerprint" + ], + "properties": { + "namespace": { + "type": "string", + "pattern": "^Windows\\.Win32\\.[A-Za-z0-9_.]+$" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" + }, + "sourceFingerprint": { + "type": "string", + "pattern": "^[0-9A-F]{64}$" + } + } + }, + "citation": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "url" + ], + "properties": { + "kind": { + "const": "microsoft-learn" + }, + "url": { + "type": "string", + "pattern": "^https://learn\\.microsoft\\.com/[^\\s]+$" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "file" + ], + "properties": { + "kind": { + "const": "sdk-header" + }, + "file": { + "type": "string", + "pattern": "^[A-Za-z0-9_.-]+\\.h$" + } + } + } + ] + }, + "nativeParameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "callContract": { + "$ref": "call-contract.schema.json" + }, + "resultContract": { + "$ref": "call-contract.schema.json#/$defs/ResultContract" + }, + "effect": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "parameter", + "countParameter", + "nullable" + ], + "properties": { + "kind": { + "const": "counted-buffer" + }, + "parameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "countParameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "nullable": { + "type": "boolean" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "parameter" + ], + "properties": { + "kind": { + "const": "unsupported-count-unit" + }, + "parameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "cleanup" + ], + "properties": { + "kind": { + "const": "owned-return" + }, + "cleanup": { + "enum": [ + "none", + "close-handle", + "reg-close-key", + "local-free", + "global-free", + "free-library", + "close-service-handle", + "co-task-mem-free", + "cred-free" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "borrowed-return" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "parameter", + "cleanup" + ], + "properties": { + "kind": { + "const": "owned-output" + }, + "parameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "cleanup": { + "enum": [ + "none", + "close-handle", + "reg-close-key", + "local-free", + "global-free", + "free-library", + "close-service-handle", + "co-task-mem-free", + "cred-free" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "parameter", + "cleanup" + ], + "properties": { + "kind": { + "const": "consumed-input" + }, + "parameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "cleanup": { + "enum": [ + "none", + "close-handle", + "reg-close-key", + "local-free", + "global-free", + "free-library", + "close-service-handle", + "co-task-mem-free", + "cred-free" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "parameter" + ], + "properties": { + "kind": { + "const": "mutable-string" + }, + "parameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "contract" + ], + "properties": { + "kind": { + "const": "call-contract" + }, + "contract": { + "$ref": "#/$defs/callContract" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "contract" + ], + "properties": { + "kind": { + "const": "result-contract" + }, + "contract": { + "$ref": "#/$defs/resultContract" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "operation", + "fileParameter", + "bufferParameter", + "countParameter", + "transferredParameter", + "overlappedParameter" + ], + "properties": { + "kind": { + "const": "overlapped-io" + }, + "operation": { + "enum": [ + "read", + "write" + ] + }, + "fileParameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "bufferParameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "countParameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "transferredParameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + }, + "overlappedParameter": { + "type": "integer", + "minimum": 0, + "maximum": 1023 + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "subsystem" + ], + "properties": { + "kind": { + "const": "subsystem" + }, + "subsystem": { + "enum": [ + "winsock", + "gdi-plus", + "media-foundation" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "subsystem-exempt" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "subsystem" + ], + "properties": { + "kind": { + "const": "managed-lifecycle" + }, + "subsystem": { + "enum": [ + "winsock", + "gdi-plus", + "media-foundation" + ] + } + } + } + ] + }, + "typeMeaning": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "scalar" + ], + "properties": { + "kind": { + "const": "scalar" + }, + "scalar": { + "enum": [ + "bool8", + "i8", + "u8", + "i16", + "u16", + "i32", + "u32", + "i64", + "u64", + "f32", + "f64", + "char16", + "bool32", + "native-isize", + "native-usize" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "handle" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "data-pointer" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "function-pointer" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "unsupported" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "encoding", + "isConst" + ], + "properties": { + "kind": { + "const": "string-pointer" + }, + "encoding": { + "enum": [ + "utf16", + "ansi" + ] + }, + "isConst": { + "type": "boolean" + } + } + } + ] + }, + "fieldContract": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "nullable", + "optional" + ], + "properties": { + "kind": { + "const": "retained-pointer" + }, + "nullable": { + "type": "boolean" + }, + "optional": { + "type": "boolean" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "null-pointer" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "borrowed-handle" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "cleanup" + ], + "properties": { + "kind": { + "const": "owned-handle" + }, + "cleanup": { + "enum": [ + "none", + "close-handle", + "reg-close-key", + "local-free", + "global-free", + "free-library", + "close-service-handle", + "co-task-mem-free", + "cred-free" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "optional" + ], + "properties": { + "kind": { + "const": "boolean-input" + }, + "optional": { + "type": "boolean" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind" + ], + "properties": { + "kind": { + "const": "output-u32" + } + } + } + ] + }, + "fieldPolicy": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "contract" + ], + "properties": { + "name": { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" + }, + "contract": { + "$ref": "#/$defs/fieldContract" + } + } + }, + "recipeType": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "scalar" + ], + "properties": { + "kind": { + "const": "scalar" + }, + "scalar": { + "enum": [ + "bool8", + "i8", + "u8", + "i16", + "u16", + "i32", + "u32", + "i64", + "u64", + "f32", + "f64", + "char16", + "bool32", + "native-isize", + "native-usize" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "namespace", + "name" + ], + "properties": { + "kind": { + "const": "named" + }, + "namespace": { + "type": "string", + "pattern": "^Windows\\.Win32\\.[A-Za-z0-9_.]+$" + }, + "name": { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "layout" + ], + "properties": { + "kind": { + "const": "record" + }, + "layout": { + "$ref": "#/$defs/layoutRecipe" + } + } + } + ] + }, + "recipeField": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "typ" + ], + "properties": { + "name": { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" + }, + "typ": { + "$ref": "#/$defs/recipeType" + } + } + }, + "layoutRecipe": { + "type": "object", + "additionalProperties": false, + "required": [ + "name", + "kind", + "fields" + ], + "properties": { + "name": { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" + }, + "kind": { + "enum": [ + "struct", + "union" + ] + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/$defs/recipeField" + } + } + } + }, + "aggregate": { + "type": "object", + "additionalProperties": false, + "required": [ + "builder", + "sizeField", + "fields", + "anonymousLayouts" + ], + "properties": { + "builder": { + "anyOf": [ + { + "enum": [ + "security-attributes", + "startup-info-ansi", + "startup-info-wide", + "process-information" + ] + }, + { + "type": "null" + } + ] + }, + "sizeField": { + "anyOf": [ + { + "type": "string", + "pattern": "^[A-Za-z_][A-Za-z0-9_]*$" + }, + { + "type": "null" + } + ] + }, + "fields": { + "type": "array", + "items": { + "$ref": "#/$defs/fieldPolicy" + } + }, + "anonymousLayouts": { + "type": "array", + "items": { + "$ref": "#/$defs/layoutRecipe" + } + } + } + }, + "functionEntry": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "evidence", + "selector", + "contracts" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^[a-z0-9_.-]+$" + }, + "evidence": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/$defs/citation" + } + }, + "selector": { + "$ref": "#/$defs/functionSelector" + }, + "contracts": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/$defs/effect" + } + } + } + }, + "typeEntry": { + "type": "object", + "additionalProperties": false, + "required": [ + "id", + "evidence", + "selector", + "meaning", + "status", + "aggregate" + ], + "properties": { + "id": { + "type": "string", + "pattern": "^[a-z0-9_.-]+$" + }, + "evidence": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/$defs/citation" + } + }, + "selector": { + "$ref": "#/$defs/typeSelector" + }, + "meaning": { + "anyOf": [ + { + "$ref": "#/$defs/typeMeaning" + }, + { + "type": "null" + } + ] + }, + "status": { + "anyOf": [ + { + "enum": [ + "zero", + "signed-nonnegative" + ] + }, + { + "type": "null" + } + ] + }, + "aggregate": { + "anyOf": [ + { + "$ref": "#/$defs/aggregate" + }, + { + "type": "null" + } + ] + } + } + }, + "domain": { + "oneOf": [ + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "namespace", + "subsystem" + ], + "properties": { + "kind": { + "const": "subsystem" + }, + "namespace": { + "type": "string", + "pattern": "^Windows\\.Win32\\.[A-Za-z0-9_.]+$" + }, + "subsystem": { + "enum": [ + "winsock", + "gdi-plus", + "media-foundation" + ] + } + } + }, + { + "type": "object", + "additionalProperties": false, + "required": [ + "kind", + "dll" + ], + "properties": { + "kind": { + "const": "provider-lifecycle" + }, + "dll": { + "type": "string", + "pattern": "^[A-Za-z0-9_.-]+\\.dll$" + } + } + } + ] + } + } +} diff --git a/tools/dynwinrt-codegen/contracts/win32/subsystem-policies.json b/tools/dynwinrt-codegen/contracts/win32/subsystem-policies.json new file mode 100644 index 00000000..4b560668 --- /dev/null +++ b/tools/dynwinrt-codegen/contracts/win32/subsystem-policies.json @@ -0,0 +1,26929 @@ +{ + "schemaVersion": 2, + "entries": [ + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpatharc.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathArc", + "name": "GdipAddPathArc", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DFC17D0B4CE71233488DD9DA12184B9766D92E3B8B714F7D1F93AB26A6F95DA8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpatharci.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathArcI", + "name": "GdipAddPathArcI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "848494BF4575E06C8B5BF93005066358B28C7CC103EDE74E876D80A22303627C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathbezier.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathBezier", + "name": "GdipAddPathBezier", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CF9711C23DCAD0A24B36B6B570F0E61006A1AE6DE48ABC37F40D4555C197FAD6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathbezieri.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathBezierI", + "name": "GdipAddPathBezierI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7406437277C66B276A17BCC54ADFAF0DA6376E20495D19857515D44646A82359" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathbeziers.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathBeziers", + "name": "GdipAddPathBeziers", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8BDA38B0B25FB4A5FC51B76935EB4C1882189E217EC369CE3F25CB1BEA1227CC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathbeziersi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathBeziersI", + "name": "GdipAddPathBeziersI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A1526704AB9FA2613895E89A2A47DE65277CE5064B45F754B86E26E259E0578A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathclosedcurve.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathClosedCurve", + "name": "GdipAddPathClosedCurve", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D9CF4B98A5226B330A6982D34822421FB28180137AC6B1F5B44265E64D41ECD5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathclosedcurve2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathClosedCurve2", + "name": "GdipAddPathClosedCurve2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B1C515FA81E7E6F44D3EB4E81624F0A56675BD53723770745AE82120E41B15B8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathclosedcurve2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathClosedCurve2I", + "name": "GdipAddPathClosedCurve2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2E1B5732D2255F419F7AF28FC2CAD19B0873ABB92396F5C54220540014BB4E79" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathclosedcurvei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathClosedCurveI", + "name": "GdipAddPathClosedCurveI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "91B36BCD9D18A66A8EE7EC832994955146F4B6DC978184D010AA7786DAA771BB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathcurve.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathCurve", + "name": "GdipAddPathCurve", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "402B9C1DE4F5E31B3EDD3B190BA0820335BDEE3B99EBB0B9F05B1B0BE7B54396" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathcurve2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathCurve2", + "name": "GdipAddPathCurve2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5A4209AEF4206D38D23BD6698FF43EB634F3D81D2AB4776567605846E1AD7709" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathcurve2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathCurve2I", + "name": "GdipAddPathCurve2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EDCCCD1B2F181DC33226E5B5CB44A1C02A72693C0D39A518224739F545F006DB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathcurve3.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathCurve3", + "name": "GdipAddPathCurve3", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3C5AE334C7A0C607203CF5BE4040C111186941BEEC18000CCAD40C37F0BCE590" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathcurve3i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathCurve3I", + "name": "GdipAddPathCurve3I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F076F45653050FCA152854DAAA5EE8B76E419C071ED0729E7DCED89ACDA621BD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathcurvei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathCurveI", + "name": "GdipAddPathCurveI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "096F47201941350A0C2A5C2BBD180F9DCFA5DE38A8DD403D187D4FEC11864077" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathellipse.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathEllipse", + "name": "GdipAddPathEllipse", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3970E89933B1B3DD8D9F82997F1145BA1ACAA32004613144718C5A069BE0DE48" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathellipsei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathEllipseI", + "name": "GdipAddPathEllipseI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7354C46D28865E2E01628D7E7DAC99587D4B5E7E1DC50BEB59BBB16249137AB1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathline.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathLine", + "name": "GdipAddPathLine", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5EFD28C4044E5706EAB3A3A23A02273B74040B6C120C1BD0AB1A81BCA92527BF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathline2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathLine2", + "name": "GdipAddPathLine2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9B8E1B44ED1CD2329049F9AAC68B983AE8F7A90B3AC0515CB11236F161B1B74B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathline2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathLine2I", + "name": "GdipAddPathLine2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F3988E8400E4741EDAEED15828F9ACD7A5F8592C38E2F66156DBFA82C9FB5940" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathlinei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathLineI", + "name": "GdipAddPathLineI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "105F10FB14DA7C7356909021080507E5988B3C7C731DBAFD2470BAD659024390" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathPath", + "name": "GdipAddPathPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "878BE54769258F240279D34378D687DE1D9A8CE2C7D35DDA475E03D313ACBD4E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathpie.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathPie", + "name": "GdipAddPathPie", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "61B3E960FC8A4FFC91F650587046A3F54D45714EC744CE4F6D35AB1A292D6E0F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathpiei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathPieI", + "name": "GdipAddPathPieI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2636DFEA8F9EF0D66E89C3FA9BFEE5CCD9A5F87174CDE7E2A5CFDA651B1B40B4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathpolygon.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathPolygon", + "name": "GdipAddPathPolygon", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "14FF4283AFC4339B4E8AE2B7E35FFE59B5AFAC6965DF72CC692E4212736E8950" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathpolygoni.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathPolygonI", + "name": "GdipAddPathPolygonI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "231B49F8577BA39A28781D6FF0F984ED4FAB3F6C40979CA7A8C8213C9CD3D9BE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathrectangle.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathRectangle", + "name": "GdipAddPathRectangle", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A9C819F97D222945988E91574BFB78F71F1EB53DD3CA3C9783957EFD530EEEF5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathrectanglei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathRectangleI", + "name": "GdipAddPathRectangleI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9FCC92C945E2541AC23C12BBDDAE462B8DEEA8357C0666D55FADC6B25DA0F41E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathrectangles.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathRectangles", + "name": "GdipAddPathRectangles", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5EAD5764769FB98F3ABE1F8DB51ACD133AED0301C415DD1D58578507190C9402" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathrectanglesi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathRectanglesI", + "name": "GdipAddPathRectanglesI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "87890C2863DC222494CDE2482426D9E16E1DF08D1AE119F89874628F04A666FF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathstring.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathString", + "name": "GdipAddPathString", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "68A178A695C9E9111549CA665E31020E56D12280AE648465B8629BD55AA31391" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipaddpathstringi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAddPathStringI", + "name": "GdipAddPathStringI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E8626E153E23576761E44BEFE49C6A4366950D40AC079B50FC927B96E74FAD60" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipalloc.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipAlloc", + "name": "GdipAlloc", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CEDCE77656EE0988FDB55825F57B6AC63C38CFC06EAFD4C777AEA41E78AF81A7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbegincontainer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBeginContainer", + "name": "GdipBeginContainer", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9C3D2E6C51AF27661156CE810426DE4AB561A49E26B2F37452BAB1F426C4CCED" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbegincontainer2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBeginContainer2", + "name": "GdipBeginContainer2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A9F3543CA1CEEFDF0E41C0E645538444476C1658E41082FB2E517407285460A0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbegincontaineri.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBeginContainerI", + "name": "GdipBeginContainerI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A68217E3A1549B1BCD8D5B7CF289673184EF4DE6AE7A293CB6A137B459E7C6A6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapapplyeffect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapApplyEffect", + "name": "GdipBitmapApplyEffect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A557B8E91F6AF761321EFACE8ED757C1DA0B31A83E996A87710C3690D5DE1A9D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapconvertformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapConvertFormat", + "name": "GdipBitmapConvertFormat", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "14993850A68D85570B819EB5F70FFBCE157BD3B1524785CE560CC99EDE56B4C5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapcreateapplyeffect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapCreateApplyEffect", + "name": "GdipBitmapCreateApplyEffect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "92E28BBA58184866CBDAAFEE7ECA673F2EE18C09FDBED0F3B11791AA6F826983" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapgethistogram.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapGetHistogram", + "name": "GdipBitmapGetHistogram", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4F8AF30A838F85D2BFAD01F97A09E1223A8F53483F87D8DEEDAF9E68A841CB04" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapgethistogramsize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapGetHistogramSize", + "name": "GdipBitmapGetHistogramSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A83BBBD66FC404D992D74EBB2729221A84F1881791EA1740D669FD24D98ABA9B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapgetpixel.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapGetPixel", + "name": "GdipBitmapGetPixel", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "79BF6707BAD1E50CDD575F2C432B1B01E414A3ED37E5E0517FEAA354D81F0492" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmaplockbits.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapLockBits", + "name": "GdipBitmapLockBits", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E5C587974F9C8479995A884E56C17A6D243ED48754AAFC549037CB5A6286418D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapsetpixel.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapSetPixel", + "name": "GdipBitmapSetPixel", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8D2671601CFE6FD62BD547A7AD3E7C38AE57F5E0626351024541E65E9450D8F3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapsetresolution.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapSetResolution", + "name": "GdipBitmapSetResolution", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AF6B75AA197E004DB6B8BEC2E8A68CDF2270A75C546B6C26553C416EECE1B416" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipbitmapunlockbits.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipBitmapUnlockBits", + "name": "GdipBitmapUnlockBits", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3089F386AD3B93F487ED6387561D972E053EA51F305C71668A15204F5C264635" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclearpathmarkers.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipClearPathMarkers", + "name": "GdipClearPathMarkers", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "97CBB863D03B4AEBA230036E5A193F51694B5CBB1F2E6B503A28EAB3A61A9128" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonebitmaparea.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneBitmapArea", + "name": "GdipCloneBitmapArea", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AA517C651D66F88E0A05C6A834D625AC697E2A1E099F4751FCA1AFF62559C489" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonebitmapareai.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneBitmapAreaI", + "name": "GdipCloneBitmapAreaI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "34E70D812A2928634222355A927BAA76461D678F8C3CAD3BBC324D0E23C75D98" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonebrush.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneBrush", + "name": "GdipCloneBrush", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8EC532FA098F2E603BDDAF6748FE8104B95370EA7582A407D76E764137FD8EF9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonecustomlinecap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneCustomLineCap", + "name": "GdipCloneCustomLineCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "52FE881C036E8EDB0C85B78179DA96A33436623ED70F527AB3DC1D663780DFCE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonefont.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneFont", + "name": "GdipCloneFont", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7A6BAB8BD54260AAC2CC3CB28CA406C30CFE51C95C9562A9B49B2D38E852487D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonefontfamily.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneFontFamily", + "name": "GdipCloneFontFamily", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "65892A55FE9582DC5D6872BEC32537DEABD6B6240510D17C999116EAD9A9562E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcloneimage.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneImage", + "name": "GdipCloneImage", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6437BB2A586E1A5913DA219480F51FCCE439924EA91770DC03AB4A9564EF0233" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcloneimageattributes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneImageAttributes", + "name": "GdipCloneImageAttributes", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D51DC58FA7DEF23A28370318520BE78569DB83150377C0997011FEF07717F0E8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonematrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneMatrix", + "name": "GdipCloneMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "864A2B50170F92852DF2C8609F8F372BEF8C4D82D78A60F24128C8F2AAEE48C1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonepath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipClonePath", + "name": "GdipClonePath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9D83C1BBF84F5785A6F87C991395E647F6DDD3014C81F6CD0A7955F382ED7ABF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonepen.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipClonePen", + "name": "GdipClonePen", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C16F2318EF6078C2573A66FD298AF9AB7049331F29610AED9279FFEBCD998147" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcloneregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneRegion", + "name": "GdipCloneRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "275B0272ACDDE14913B91DDAB138B2FC7A22C2B639F0033E980D987DB5AC10BD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclonestringformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCloneStringFormat", + "name": "GdipCloneStringFormat", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8A820CB26E086086FC308134434A50248A2D6B68274404EDA7C3E1F15CB7DABA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclosepathfigure.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipClosePathFigure", + "name": "GdipClosePathFigure", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B683C0A11BC8EC1D4200832023ED2B39AA61B381840EE9BDE8B077FA18A2BBD6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipclosepathfigures.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipClosePathFigures", + "name": "GdipClosePathFigures", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8BAF984603D448978F64031FB5AA5F4906015D2291B2D0962D70FF5E41C1AE75" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcombineregionpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCombineRegionPath", + "name": "GdipCombineRegionPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1D701DD8335608E502A5CDD57E1A42C0311F11F3D1A279C7CC149B8A4387A709" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcombineregionrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCombineRegionRect", + "name": "GdipCombineRegionRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9BD00742F4014251B15530B88F43D565867D73A3A29F57001C988B63FBE78D73" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcombineregionrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCombineRegionRectI", + "name": "GdipCombineRegionRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F7FF8CAA815853A8A79467809BD8C4BB6ABB726C0383069E8278E3836F05D934" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcombineregionregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCombineRegionRegion", + "name": "GdipCombineRegionRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F0238373440061CE74C8D6D2B6DBD43FFC15D1CD3218671465828411BB46D0F9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcomment.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipComment", + "name": "GdipComment", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0C385F84C797A0B3A1F15ECB87DF4B0D39543A66919753882C0350FA8EE4250A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipconverttoemfplus.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipConvertToEmfPlus", + "name": "GdipConvertToEmfPlus", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AE4CC03BDD1523588F4A6DE09BCBF7EECFC1A859FA94F8BC1510B788695912D8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipconverttoemfplustofile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipConvertToEmfPlusToFile", + "name": "GdipConvertToEmfPlusToFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7F14C28F7F0C1F95F4B2823D54A6619E48D5CD877213903918D431543FD98A3D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipconverttoemfplustostream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipConvertToEmfPlusToStream", + "name": "GdipConvertToEmfPlusToStream", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "709988FE5C7F0B28F4AD326BCFDD5D1B6379C48EEE900B77A5AD76687BB524D2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateadjustablearrowcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateAdjustableArrowCap", + "name": "GdipCreateAdjustableArrowCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "68B3C82C629B7A41306223DB738B3665BD0878899065565E478872F9C4866EE0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromdirectdrawsurface.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromDirectDrawSurface", + "name": "GdipCreateBitmapFromDirectDrawSurface", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C183FECF922D3F03CC3ED6F9812CD5C1079AA2FB681299FEFF372EBCF6C62795" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromfile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromFile", + "name": "GdipCreateBitmapFromFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E08AD5C3DE148DF4DEEB433C1301D9CD15756281FCDC4C1931994135B458EAEF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromfileicm.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromFileICM", + "name": "GdipCreateBitmapFromFileICM", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "16E42980ECC2AEF8FD730D7B15E23D90FEFCC62E8E94A0077B22CEF841BE3011" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromgdidib.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromGdiDib", + "name": "GdipCreateBitmapFromGdiDib", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "517919379883D4C8525411525817C9DF0341003B91248BCBB418438F204A4CA4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromgraphics.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromGraphics", + "name": "GdipCreateBitmapFromGraphics", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "12EBF912A48ADA4CD0BA1C1F6330B019E1AAB3360102653D604715924D3ECF7F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromhbitmap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromHBITMAP", + "name": "GdipCreateBitmapFromHBITMAP", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8102353EC33F968A41FB2D1AB05CFB657B1000FB5F8E1AB76EFB614C8B66A50F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromhicon.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromHICON", + "name": "GdipCreateBitmapFromHICON", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "82AAD005AA5BE65E657C5E5BB837FBB576AD4B898239C5BFEF4787D9365579AA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromresource.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromResource", + "name": "GdipCreateBitmapFromResource", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "855EB4011D0B93F345FB03B22199ADF0F96ADB414BBE2D3333F94A6621287594" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromscan0.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromScan0", + "name": "GdipCreateBitmapFromScan0", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3C76CD74D635C13E5E43422E00FC491859C798C5990133E44B3CD383718B9365" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromstream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromStream", + "name": "GdipCreateBitmapFromStream", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B0364CD288B32D622493CE93FF6D8F8EA322126AED2F49AA1B8582CA1ED78769" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatebitmapfromstreamicm.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateBitmapFromStreamICM", + "name": "GdipCreateBitmapFromStreamICM", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AB55B57B9CB51E2F8265656D98AF44A33DE81C887D7E8A2A0223CC4BC6EAE40C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatecachedbitmap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateCachedBitmap", + "name": "GdipCreateCachedBitmap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6F9CB5412414EBB4EB593FF691096B6CEAE98BA9679A90ACF2C319644C5EC80B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatecustomlinecap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateCustomLineCap", + "name": "GdipCreateCustomLineCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D573F37A3B23561F9E9C54C508ADB3C5A3D6D63D74504D01DCE76B0E740C54DA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateeffect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateEffect", + "name": "GdipCreateEffect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3B3F9E60968FD791FCC3044E9BC66CF0FAC701AC41ACBBCC1CAB8ADE8F64AD6C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefont.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFont", + "name": "GdipCreateFont", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6A80839D048E7119518DE2A93620C11762E567582E3733B97C889C0D8678A745" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefontfamilyfromname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFontFamilyFromName", + "name": "GdipCreateFontFamilyFromName", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "297427524B16FFAFCF60D03B25B7906F746036759A9CBFCBB723DC7610CCF654" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefontfromdc.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFontFromDC", + "name": "GdipCreateFontFromDC", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7AE273DF9227F1ECAC507700448B4EC68EF76B74288C527C13136D1EEE0E3CC8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefontfromlogfonta.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFontFromLogfontA", + "name": "GdipCreateFontFromLogfontA", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "72FCC4C3BAD88786C8116D055C0F47FE1CD85745003EB0A8768FD83423005B49" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefontfromlogfontw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFontFromLogfontW", + "name": "GdipCreateFontFromLogfontW", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1C647B1553EC096C4E659F5EE3F5919C87C9B13EC7D65AF3A9B209DFB7B5F94A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefromhdc.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFromHDC", + "name": "GdipCreateFromHDC", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E67492FCB44062ED3767F643D2F6C084731133C13E2FE0CC1BC623474D404C31" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefromhdc2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFromHDC2", + "name": "GdipCreateFromHDC2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6F6B6BE4726A7671E9AA90DBE302B50C38C7F01E8FE7860BC8771BA2BC75210E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefromhwnd.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFromHWND", + "name": "GdipCreateFromHWND", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B7D08756DB0454730074178B465CD05D5CDA5A64ED48ACC69D6F0C09325B71DE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatefromhwndicm.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateFromHWNDICM", + "name": "GdipCreateFromHWNDICM", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "95B845B4D9E02AB889839D506EA34D8A470BBBCCB7EE4014C45FA0BAB32BC6A9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatehalftonepalette.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateHalftonePalette", + "name": "GdipCreateHalftonePalette", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BA03074F1CF3DAF9529E326A77214A2CD2B3E6138F70539C3B894A2200510776" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatehatchbrush.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateHatchBrush", + "name": "GdipCreateHatchBrush", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6A56C1E7E56B6765AC533DA807987286502AA57C87F37121E713DC18A930A673" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatehbitmapfrombitmap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateHBITMAPFromBitmap", + "name": "GdipCreateHBITMAPFromBitmap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F2C728C3050EE19F80778A9712ED3C726EF597F999854E2E7855A8A5C545866F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatehiconfrombitmap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateHICONFromBitmap", + "name": "GdipCreateHICONFromBitmap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4F946BCBECEFC227942BBB067FBDA9DA82EFA1B59451755494925D7360F1E990" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateimageattributes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateImageAttributes", + "name": "GdipCreateImageAttributes", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D8DA9A81FB912AD1CEEC064A38E09FFC3372C39566D4A92A83293F98ED21E6E1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatelinebrush.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateLineBrush", + "name": "GdipCreateLineBrush", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "02B997B22477C1417E0AC4C6E1303084EC35484C1159FA56C4232D7C0795BF16" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatelinebrushfromrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateLineBrushFromRect", + "name": "GdipCreateLineBrushFromRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6414D7B95A49CEB8EF68F590492767DEA258FC6B270A27211B9BB9B44AC21B62" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatelinebrushfromrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateLineBrushFromRectI", + "name": "GdipCreateLineBrushFromRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2DF95B6CE34539A596FC272F99BB35C84386D98833F4955453D586087D18C941" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatelinebrushfromrectwithangle.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateLineBrushFromRectWithAngle", + "name": "GdipCreateLineBrushFromRectWithAngle", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "068A836CBD0787526A932054A890FF4FE3CC36B44637F75ACB107311F9AF3FC3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatelinebrushfromrectwithanglei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateLineBrushFromRectWithAngleI", + "name": "GdipCreateLineBrushFromRectWithAngleI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "21E9A72FB34F7244E3580F086F29507AB70A97F82EB3535F222F63603B5F2F14" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatelinebrushi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateLineBrushI", + "name": "GdipCreateLineBrushI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "30FD5888FC4D9B0CD0C797E7FE95AD541970F3A7BA8364914CB3EBD2C79CE0A5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatematrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMatrix", + "name": "GdipCreateMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D1E2E510F5DCE10878A793C07B2E13E36EA1A33EACB3B28E91EA6E6F76799A8A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatematrix2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMatrix2", + "name": "GdipCreateMatrix2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4F2D26102BC4B1B1800B62D2D7074BDEF0396E8502AF81363536D365D52B77D9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatematrix3.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMatrix3", + "name": "GdipCreateMatrix3", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "08EBAC0708739480CD19D96D38F2F34AC38E16E535067AF4C044C2DC435FAA50" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatematrix3i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMatrix3I", + "name": "GdipCreateMatrix3I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B1CDDF5F289B301AA9165E486C38F3ABF405DC856BB2F46318444F2FC0CC1FAC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatemetafilefromemf.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMetafileFromEmf", + "name": "GdipCreateMetafileFromEmf", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0B3853548771C9074D70F22870933D812DE27C32321F1C8914ED96E824848249" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatemetafilefromfile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMetafileFromFile", + "name": "GdipCreateMetafileFromFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D68E75D07E8BDE7325BCB2EA99C53BF0ACCC52B20C29BA4673944B1CA2F65736" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatemetafilefromstream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMetafileFromStream", + "name": "GdipCreateMetafileFromStream", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "933B63DEA8FFC5D626CC393D7127AD2CB3D5EEB1AF7E40AC82551A405463E023" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatemetafilefromwmf.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMetafileFromWmf", + "name": "GdipCreateMetafileFromWmf", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EEB7FDC7C5EC372A7DAC27E5DDE720EC6DD554458E2A0B023A1C2E80B6133928" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatemetafilefromwmffile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateMetafileFromWmfFile", + "name": "GdipCreateMetafileFromWmfFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "73BBECB039A269A80D0AD23E0733A42F5FA18ED3841BB972FA705A5E925CB44A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePath", + "name": "GdipCreatePath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7CFB6BB7E0C1CEB21879316C3636F35AACE777EA763867AB0DA15346434F0220" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepath2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePath2", + "name": "GdipCreatePath2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9C001E9D72D13713DC6E092D20935BFD4675EA0FB0E81D9F54972142D6307696" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepath2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePath2I", + "name": "GdipCreatePath2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0A277D44B69BDEAC591AE2FF7137389D49EAE997825C8A3A3A9207F8F949FDDB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepathgradient.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePathGradient", + "name": "GdipCreatePathGradient", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F0088AFCCD43FDCBFD7628D5D44864344E58B0DF47539C786B06C01CFE53E1D8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepathgradientfrompath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePathGradientFromPath", + "name": "GdipCreatePathGradientFromPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3787F0CFBBE9392BDBA98B32616C4BCB71CAA262C19F25205B65527E99B17F81" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepathgradienti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePathGradientI", + "name": "GdipCreatePathGradientI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D89CE8D59999425D344F7421AC98F772C82C7704B865A63A933928CF61055FB7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepathiter.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePathIter", + "name": "GdipCreatePathIter", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7AC246661660D58DC36C407F33EEEFE2FB6ACB69C004245BE50EAA7F2118C4DE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepen1.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePen1", + "name": "GdipCreatePen1", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CD35B8F36D7C66859EC037FF447A31018FB9D59642EF27FEB21282B96C468C3B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatepen2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreatePen2", + "name": "GdipCreatePen2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FFD7D236933624A1B16E5919499FE14503FF2EB9783C3E595F5DDA4C67C9BB17" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateRegion", + "name": "GdipCreateRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "117B369DE27E6BE0D345E72F0F1BD2DE55F8E0D28E4573F3528177E306B31805" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateregionhrgn.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateRegionHrgn", + "name": "GdipCreateRegionHrgn", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "41EB17BA9AED74A7DEA2DCAAD2413F5F4F24B9212078C338FB5137AB466C4DEC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateregionpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateRegionPath", + "name": "GdipCreateRegionPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "682C8A6323D8B3F9DDDBF8BA5CA5FC26139B34EA0F27547CF39A919FCF965C03" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateregionrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateRegionRect", + "name": "GdipCreateRegionRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CC5D20DDF6783173BEBEC3EBF9A11C4C7FA6015DBC4FB84D993E63399F6B3A5D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateregionrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateRegionRectI", + "name": "GdipCreateRegionRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7BA8AED0379769E7257FFAE7F8A579C5F98A9A97574A1D9F8BB5A73DE937629B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreateregionrgndata.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateRegionRgnData", + "name": "GdipCreateRegionRgnData", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0A6791AF5608F0F9C4EE6D5615F4FAE9936880D44E1EC6C87C41434002519241" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatesolidfill.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateSolidFill", + "name": "GdipCreateSolidFill", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3B648F9645FC09F3B4526365DC01494247C41BAFD3517F645D2B8B55F19FAC31" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatestreamonfile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateStreamOnFile", + "name": "GdipCreateStreamOnFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "258974AEE5DEFBC2DC7802ED65F0FDFE79F58DA7E85DCE9194E3D0110A80B81F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatestringformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateStringFormat", + "name": "GdipCreateStringFormat", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D0D45D342CC85C3A1DCB27123B4CE995C4FAF92D380310ABEFC7FD37A3BEA5E5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatetexture.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateTexture", + "name": "GdipCreateTexture", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B0E0AFFCA759EA1E3F70D7E9D0205CADC27211B609F08C92384C6E80272A9362" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatetexture2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateTexture2", + "name": "GdipCreateTexture2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A653F25327EEF633E380738224A26062AB5E372E55421F6028168E2389F1A458" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatetexture2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateTexture2I", + "name": "GdipCreateTexture2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4B7727F3D763B01C57E75028EC30C967DFF826F65D88FE4EB0C01EC80E00FD46" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatetextureia.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateTextureIA", + "name": "GdipCreateTextureIA", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0783667F227F6326AC79523B3D77C8CF5AF9A00D3CF80DE4031B71C770FE53A7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipcreatetextureiai.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipCreateTextureIAI", + "name": "GdipCreateTextureIAI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "75BCDC4406585B7F738E48D5E3E08A1DD00A786D4A7B4F501226FF6685F16AC5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletebrush.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteBrush", + "name": "GdipDeleteBrush", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BF2B73AFD96C4968524C4EDD4CACA251ECD134DD6F11B71D2E5ED50E277313A4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletecachedbitmap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteCachedBitmap", + "name": "GdipDeleteCachedBitmap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CB680E47CE0465009FC5C8C1428E7C0A5AFB6820E5BD8AA064D9E0142935AA44" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletecustomlinecap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteCustomLineCap", + "name": "GdipDeleteCustomLineCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "49E77C942ADC7055A663E754A888F62CBA4182EA3BA4F17FC96E6C6DDD8F0563" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeleteeffect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteEffect", + "name": "GdipDeleteEffect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D2A982B507A4AA7C52E9C869901265F8D12CA00F3A8B861D265A09C02920DCED" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletefont.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteFont", + "name": "GdipDeleteFont", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "20F0755A831D6DA4110CB613C7898F38289A112AC11B402FD6166B6D55C60294" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletefontfamily.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteFontFamily", + "name": "GdipDeleteFontFamily", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "163032666191241275AD5D9B524294CFE0F7320F85A56FC7E3C8F0CD4877B2E6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletegraphics.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteGraphics", + "name": "GdipDeleteGraphics", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D29B97574559142D7DAEF816A620EE18C38184FD8AF9DE5EEC45AAC1D61717A3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletematrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteMatrix", + "name": "GdipDeleteMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4EEB33C9744113D55F7F0D04FC5C41F419CD4226274F5AE49AABD1E5DAD19A78" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletepath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeletePath", + "name": "GdipDeletePath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0E66F14C3E2212CF582DE1A67E17CBC6ED3666AE2CF1D10B437CB094EF2EF242" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletepathiter.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeletePathIter", + "name": "GdipDeletePathIter", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5784F4B64AB6DBBEB4A4A085ED9915DA6C2E455802CA7DCA0215B4B33B45668F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletepen.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeletePen", + "name": "GdipDeletePen", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9520D9E4C0885FD6C3F3A66E00CFFBFD57E2562E7686C2EB3B324D5C8D8F05CC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeleteprivatefontcollection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeletePrivateFontCollection", + "name": "GdipDeletePrivateFontCollection", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D6E3B5D9B6FCDA5E8DF13A3FDFA86858CB77238E4435CD09D81F523AE5ACB8CD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeleteregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteRegion", + "name": "GdipDeleteRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D327571B7B21312EEF01A30B806F644092114407928695C96CA887787E4A0B2E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdeletestringformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDeleteStringFormat", + "name": "GdipDeleteStringFormat", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "53E94F0B0F71D1D26C2CD3997E50B8C1C13430B683EFE383CB3D68DAD50CD36A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdisposeimage.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDisposeImage", + "name": "GdipDisposeImage", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B1462F595584109AAFCB15AFD9D3DB7CABBDDA9E7CEBDD51E81C2030865E83EA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdisposeimageattributes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDisposeImageAttributes", + "name": "GdipDisposeImageAttributes", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A76AF97496FB54F59F916DE3AF1D0E007867FBA9ECD7208628E495E655CEC27A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawarc.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawArc", + "name": "GdipDrawArc", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "247792E24E08B2A9D79B65179360D71EAE502EEBF0E1B29A48C01983D25B5C56" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawarci.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawArcI", + "name": "GdipDrawArcI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C85D98B5015172C5C0FEF5C0EBE1F7FD66905554489AD8CCF44CE278C17D4AEC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawbezier.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawBezier", + "name": "GdipDrawBezier", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FA7FEE01B5CE047A9002BCA2BA1D9AF4C0620C7708642BB796770B6E94439BE1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawbezieri.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawBezierI", + "name": "GdipDrawBezierI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F64E14C536DBFA2112D8FE96ECC84EEE3352B444B52700E2C26FDB4DEEABA8EE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawbeziers.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawBeziers", + "name": "GdipDrawBeziers", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A1928865BFD21B24C1DDEE9F2297FF70D171D7E295C0E55F68B60DE403A652F1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawbeziersi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawBeziersI", + "name": "GdipDrawBeziersI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EC9795FE5C5A7914156CE4C052245FEB26F211131E9559E4BE6B124ACEE4629C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawcachedbitmap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawCachedBitmap", + "name": "GdipDrawCachedBitmap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E5C252BC0B148C89970379AA49BFFBD501F6355BC72B226129B3FC8F8044CA0B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawclosedcurve.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawClosedCurve", + "name": "GdipDrawClosedCurve", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1292A7C456576256E621C5E8CA43F2B0188645FB17004619BCD51A5CD33B5869" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawclosedcurve2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawClosedCurve2", + "name": "GdipDrawClosedCurve2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0C9A9F9B979F0DCA915B45E65088722DD4BF3B9A61A9CD2236FBC32908D8933C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawclosedcurve2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawClosedCurve2I", + "name": "GdipDrawClosedCurve2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0AF2D890A40D0C0DCDAB65F11A47E80A6411BB71121A36B1F46A645DD6934F33" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawclosedcurvei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawClosedCurveI", + "name": "GdipDrawClosedCurveI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4B4BE6D731741EE349DF1AE9D16F1683418097E79D7B7FB2C9C1A1A90515540F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawcurve.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawCurve", + "name": "GdipDrawCurve", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "82EA446E10A7AC9774E91B3F47B2A6B762B59F573D0C9B2674D16C21703F36D4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawcurve2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawCurve2", + "name": "GdipDrawCurve2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C45FA87621231CF4D750CC3E9D741B67FA9ED06BFE0F6929338049FF01A59AE4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawcurve2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawCurve2I", + "name": "GdipDrawCurve2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8C6B2A6B77D56CECD0BDECD8A87238BD1F29ECE058002C62F6380D63B950101F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawcurve3.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawCurve3", + "name": "GdipDrawCurve3", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4C6269657C7D1D794A54CAA9786DAED15C4913CE72929113F510A90B0D3F7C58" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawcurve3i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawCurve3I", + "name": "GdipDrawCurve3I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4E1B0E488F11FD3263AA935AD0DDE89E9AB105354BFE105DB5D89013A5BD652D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawcurvei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawCurveI", + "name": "GdipDrawCurveI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "39E662630018F078FB3F919CC61B6B7A396A6615D6BB130A79646BA6DEEB4392" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawdriverstring.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawDriverString", + "name": "GdipDrawDriverString", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "044ECB695FDDEBE5AA24A482596BD615987377A4F32A56E1A1F9BA708AA2C975" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawellipse.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawEllipse", + "name": "GdipDrawEllipse", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "ECB73E19A2240FFD8E31D04F6D04CBC5660B01F7517BEADEE4A5DE7F58B2B81E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawellipsei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawEllipseI", + "name": "GdipDrawEllipseI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8501AB0ABE159A4126DEBEFAFDD50180A9284D0205BBABDC649ADC681206A9AD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimage.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImage", + "name": "GdipDrawImage", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "731B53DEC3BDC345258B52206E27295E5F95F68C461A7F2BA449F9DD0478AE61" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagefx.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImageFX", + "name": "GdipDrawImageFX", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "54DE42E9CEC1FB3C8B2BDAC309A876A9F963B97CF30D4584F7E67E3802D8BBF9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImageI", + "name": "GdipDrawImageI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "398C7FAF5F7714A370CBEDBBA84370A5FADE8DBC1F6D0D5332DE81ACC4E67452" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagepointrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImagePointRect", + "name": "GdipDrawImagePointRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "80F2FA686F554EDCF0FBD8806E45B62DBC5FBF3760D3BDE2DD523D8666B22C82" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagepointrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImagePointRectI", + "name": "GdipDrawImagePointRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "241969DD82AC744153C8393D09B8BB85A057399AF814711F6B0D2217F1EB6D5F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagepoints.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImagePoints", + "name": "GdipDrawImagePoints", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A05221F6285DE407D03C717AD9CD8F0080497AC12BEE2D30E0E117C56F0B5C15" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagepointsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImagePointsI", + "name": "GdipDrawImagePointsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EF79E6C989D230FDA4DBE33A76AEEDEFDC9B3027EBD3C5450256D7270FD5391B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagepointsrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImagePointsRect", + "name": "GdipDrawImagePointsRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "84263DCF0C6AA783EBA1F9B763CD797EF72F0E5156C761A3E43AD8575671283C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagepointsrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImagePointsRectI", + "name": "GdipDrawImagePointsRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FD23B29E451DED61DE93660752D306C7F8E490DE0F7E19861901E5DF7A3E2D92" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagerect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImageRect", + "name": "GdipDrawImageRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3F06C2CE4C5DFD38E5998AC7EB6C30CA610A8DE67C3900DA2617FF491A76C949" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagerecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImageRectI", + "name": "GdipDrawImageRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9EFB4B1C1B8B0B64C7A6116F168AD4A84C231C274B0B1E93910B24C5CD2066DE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagerectrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImageRectRect", + "name": "GdipDrawImageRectRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "791681F5FD97FC2609DAFD426357B8DE774D3410ECF8E83C9F6223FFEE151374" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawimagerectrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawImageRectRectI", + "name": "GdipDrawImageRectRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E92B76311791D35399D4DEC32285E5FDC68C7AED21B9466380343B06DC16D9BE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawline.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawLine", + "name": "GdipDrawLine", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CC7D9FF02E10107296C9A40CAD156CE877F34C122BB38FC8DF8C5EDCE6FC3FA9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawlinei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawLineI", + "name": "GdipDrawLineI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "30A0D3FACDA5FA10F638FAC47C95FBC41CC45CAE842B9DA7C04FF6601D21DD8C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawlines.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawLines", + "name": "GdipDrawLines", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EEF742242862DB1A8FDE44044C8448050BD5CD3BEB463F6A0146AC4E5FE749C2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawlinesi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawLinesI", + "name": "GdipDrawLinesI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F26525609539200BDD69B423318C094DFBBB171825DD59CA5B0220F550B4C048" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawPath", + "name": "GdipDrawPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5BFD0296B36ECD60F56FF7C3C1823AEC2898A60515C2AA6C800EB976652A4DAB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawpie.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawPie", + "name": "GdipDrawPie", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5949BFBEA4A0D3BDB85A86E043DE280BD3CF04B4E560A016BEE14711908FBC39" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawpiei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawPieI", + "name": "GdipDrawPieI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5FC0D720E65E6E230C7259E96C885B253913DA3E824D0E93D581E29F6CF2A34A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawpolygon.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawPolygon", + "name": "GdipDrawPolygon", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "97F678FB19AB43D85146E00702BF4EAD344FEF1D3E4E613916AAD90B44DA4852" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawpolygoni.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawPolygonI", + "name": "GdipDrawPolygonI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DE963BBC1478C92D8EACE0DB1FDA39C8CB873338656CE4D39807BDA0C433A573" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawrectangle.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawRectangle", + "name": "GdipDrawRectangle", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DB8057B3A8A4A13DE1CD1682D401CE780E04EF5D99729905B1895BEFBAD667AD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawrectanglei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawRectangleI", + "name": "GdipDrawRectangleI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DC4839DF9588C783B1B3A50D7C1FA1C3032C8F3BBB9EDD162FA79B9335BCC2FD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawrectangles.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawRectangles", + "name": "GdipDrawRectangles", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E5C9241CA9F1716DB42D50E318974CFA1C21A00F961D241D35F0CED2CE1D3303" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawrectanglesi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawRectanglesI", + "name": "GdipDrawRectanglesI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6F83369182BE58E43CD7BC21325C11D976D1BB9BDA4690FD7B757007744182E5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipdrawstring.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipDrawString", + "name": "GdipDrawString", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C84EEBF268386A2B855BA3523977769A6FAE02BCFDD60D84E8E086E7A0CC86F9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipemftowmfbits.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEmfToWmfBits", + "name": "GdipEmfToWmfBits", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6B0C1F20DEC2F08C5C01BFB2D2BB8E0547AAA2B7B782BCF71B2A71CA69191FCF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipendcontainer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEndContainer", + "name": "GdipEndContainer", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F98796F9D69547523BC39809806375A9413F09BFE21CFB40ACD45AE14C3EB4EE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafiledestpoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileDestPoint", + "name": "GdipEnumerateMetafileDestPoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5495968879A3C7762D1015A279D885A4CF6F9538D3C018A963D91A02882FF6F9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafiledestpointi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileDestPointI", + "name": "GdipEnumerateMetafileDestPointI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "949BD53035E7EF6EFBFD8B7B7D5282EDE7D7C07EF8C05A6BA92007D9EDE5D3E6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafiledestpoints.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileDestPoints", + "name": "GdipEnumerateMetafileDestPoints", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2388DD9598C561399D7F91736953E5B8231A9EFAAF63AF719CB92D205084D709" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafiledestpointsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileDestPointsI", + "name": "GdipEnumerateMetafileDestPointsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EA677FDC53848F1FE3FBAC6E27D997C1DD95B37D0764570049C9DD08F5B2BE0D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafiledestrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileDestRect", + "name": "GdipEnumerateMetafileDestRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4D28C6D82DDB204DB58C28407F76F7EBA0048D0035E6CD697487765315423CAF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafiledestrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileDestRectI", + "name": "GdipEnumerateMetafileDestRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FEC6989177A92E3BDFA144A5B5CAE01D75D09464D3DA03C530F7B12D0D88F865" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafilesrcrectdestpoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileSrcRectDestPoint", + "name": "GdipEnumerateMetafileSrcRectDestPoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2362E4B46FC01BE160BED227E94B8B3A06058A39C61A3AD5BA03ECA5F77592BA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafilesrcrectdestpointi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileSrcRectDestPointI", + "name": "GdipEnumerateMetafileSrcRectDestPointI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "82C1DC4E20630B6A8BF48E34A8D95B533ED7167FFFF3436A32207C3C4D64870E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafilesrcrectdestpoints.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileSrcRectDestPoints", + "name": "GdipEnumerateMetafileSrcRectDestPoints", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DCD089E5C4ED56BAB8F83D7BF8F42B8F2943E0FF56E2BC1289DF4F3E2D282005" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafilesrcrectdestpointsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileSrcRectDestPointsI", + "name": "GdipEnumerateMetafileSrcRectDestPointsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A2227533F71B53D6ADFF06C92F6CA8935BA23798552BFBE3A21184ADF9B03FC6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafilesrcrectdestrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileSrcRectDestRect", + "name": "GdipEnumerateMetafileSrcRectDestRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "848498CE8C24913A5A70FEFBEECF162B6189217F01B7E0E3BD13F5B46A5FB3E6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipenumeratemetafilesrcrectdestrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipEnumerateMetafileSrcRectDestRectI", + "name": "GdipEnumerateMetafileSrcRectDestRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EC1B5CF97C9571236987592C343DB2BA50E1FC8D009CFB5ABED3042601D7D386" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillclosedcurve.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillClosedCurve", + "name": "GdipFillClosedCurve", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "365BD19455826032C08C774F749178FCAF7FABDC293A4457821AF66888B72457" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillclosedcurve2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillClosedCurve2", + "name": "GdipFillClosedCurve2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "64C0F443E65468C60BBA3F238D5ED517CAECF3BFF413FEEE9451E81961E11921" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillclosedcurve2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillClosedCurve2I", + "name": "GdipFillClosedCurve2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EBA2D08AF60797C10B475F0C311FBC33F23D41B2C6C219B589ADBA3A89E66E25" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillclosedcurvei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillClosedCurveI", + "name": "GdipFillClosedCurveI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "481217466FEC061B8DF7119E981A17B41ED15694A61F8BF591BF79660F3D1C3E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillellipse.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillEllipse", + "name": "GdipFillEllipse", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D756671B656AD09003141E011E773C8370DA240337D49EA7BA0C7E5BA4FEA30C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillellipsei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillEllipseI", + "name": "GdipFillEllipseI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A8246264FC6276156BCCB2DB0102DD2F43EF943B6B71D5225D4DE4098B6DA935" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillPath", + "name": "GdipFillPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CD194EEAA28A38B7A4B6CFBEB018E620FDBF728336E2DF1A6C26A582C4DB7C02" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillpie.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillPie", + "name": "GdipFillPie", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C44559169E397EF855E02A16F387E9C0A4F6FE2482D052F01AA77C5C647CE863" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillpiei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillPieI", + "name": "GdipFillPieI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3BD3C0255660666F0FBBE11D44AA42ABB2D9769CD26C4438D6321C1CFA6E93DE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillpolygon.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillPolygon", + "name": "GdipFillPolygon", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AE397EAFC646F205E91425287CFB64988F845A9DEA85E42713CE15D57A7F4583" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillpolygon2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillPolygon2", + "name": "GdipFillPolygon2", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7EA51AB1B4BE743E5C2B5B0C2A45B61C3CD1205DD885DA12A32AC44B2D29542E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillpolygon2i.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillPolygon2I", + "name": "GdipFillPolygon2I", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "862033DEA5F2F7F546443406AD3715BE9FB170872C7A66C753A5310BAF17A88D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillpolygoni.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillPolygonI", + "name": "GdipFillPolygonI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "11E9381BA32BED1923ED51B37741F2BE1B4BD28A8A3E28549DAD5DCEC2F5B6D4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillrectangle.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillRectangle", + "name": "GdipFillRectangle", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "89363A15E84E2A1EA3DBE60E5BBFE644D7F16235D34ADE893764E2459E001F42" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillrectanglei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillRectangleI", + "name": "GdipFillRectangleI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A2EFE1FE00445942837C49E81732047173A990FBEF32DB8B16FE9304C478C7EF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillrectangles.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillRectangles", + "name": "GdipFillRectangles", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E603BCB18FC7655F5562C64671A55D51CB03CC8506544E85F8F8BEEBAFC06F2C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillrectanglesi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillRectanglesI", + "name": "GdipFillRectanglesI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2DE0F64CCF71C371173FF11BE54CDDA47903EBFF6A0505F134300B899B5A011E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfillregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFillRegion", + "name": "GdipFillRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B1EE5195A5ACB4F8CBC483140795A89A2CF31F2CFD3B4DADE78CA4DB7D9E3D1A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfindfirstimageitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFindFirstImageItem", + "name": "GdipFindFirstImageItem", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B928A811BD9F254B7728846500B45F69BB78AA8CB41A9D6C3E337EC8635A0EA1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfindnextimageitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFindNextImageItem", + "name": "GdipFindNextImageItem", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B487B680A9022A77B5D3F6E92A4DD51C8C7CE57FC23E2F2A3407047381E3A5AA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipflattenpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFlattenPath", + "name": "GdipFlattenPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F2E0921259D6DBA406A26DA6DED5191A03509FE7A83293A97F36C4E8820C311C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipflush.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFlush", + "name": "GdipFlush", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A2260C80326115FB7EBB55D21BC78ED94D1EEF52DA1D1773F96E8BF77E3FA412" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipfree.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipFree", + "name": "GdipFree", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "07F00DEB385CDB95B5A62BCC388A95A74DEA31A6E2C6809D1514945B313E6BF5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetadjustablearrowcapfillstate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetAdjustableArrowCapFillState", + "name": "GdipGetAdjustableArrowCapFillState", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DFBE488B63E35D536B010F3D43E12AB3B9B90D0FA4300AD6DAD88599B5CDCF8F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetadjustablearrowcapheight.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetAdjustableArrowCapHeight", + "name": "GdipGetAdjustableArrowCapHeight", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "765F37EEA9F40AE67EE4723FEEDF809E46B86EECA7873FA8498B5848E9D22E10" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetadjustablearrowcapmiddleinset.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetAdjustableArrowCapMiddleInset", + "name": "GdipGetAdjustableArrowCapMiddleInset", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "711B5B06CDCA4631E5D6665786D67FE452B24D0772EDF311FF2B1A3498F23FE8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetadjustablearrowcapwidth.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetAdjustableArrowCapWidth", + "name": "GdipGetAdjustableArrowCapWidth", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "82E610535E56155E23070CDFC948C3A73BE0859CBCCF47A4C11B2EA6AAC18E28" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetallpropertyitems.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetAllPropertyItems", + "name": "GdipGetAllPropertyItems", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2068EC4C321D017F2FE7DF62F00F6E51B7947FC7376302C9A88FF1DC0E7449E7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetbrushtype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetBrushType", + "name": "GdipGetBrushType", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B9BC5795BCCE9472B363D261D5A5063D9EB46BC6F32EF96B9EE76CA03E9E0B65" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcellascent.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCellAscent", + "name": "GdipGetCellAscent", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "18A61E590441582C74F6FDC1401D386B8086DEDF40B3916966E0DF81142B5D57" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcelldescent.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCellDescent", + "name": "GdipGetCellDescent", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "310797713E328A1814CD6F612AD3FB48A1FF32ECAEF4B8340EA336117DE45D51" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetclip.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetClip", + "name": "GdipGetClip", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A71E2A623FC3F5ABF0B92F607AAA3D82AEBC4D0090961F61CC8A9F0DF3706FB4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetclipbounds.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetClipBounds", + "name": "GdipGetClipBounds", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "363F64517924692E9D53768E7B021FF5A72AEF7A0FBF5E934CF506822EE133D7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetclipboundsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetClipBoundsI", + "name": "GdipGetClipBoundsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EE8F3ED8238D476FF9CF828B0AA2795D80DFDE4AD5F3C26427ABB544684F977E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcompositingmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCompositingMode", + "name": "GdipGetCompositingMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4898B6EEF5A601F8147FB71EEF750E258E0AA66180B68BE70312661FFB0C4B4A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcompositingquality.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCompositingQuality", + "name": "GdipGetCompositingQuality", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E9F3626FE37CDF465ACA5874E7FCFF735322105213445DE4778007D8BF4CDCB3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcustomlinecapbasecap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCustomLineCapBaseCap", + "name": "GdipGetCustomLineCapBaseCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "51FB772DD9BE05D9A6A8B6B045F3C7A185903C73BFA10F6B0E2984C2005B7420" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcustomlinecapbaseinset.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCustomLineCapBaseInset", + "name": "GdipGetCustomLineCapBaseInset", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "23005D420D62813C5D34C4007BBFD4DEDF3E5F353536DFC090FA7BCC3C26B2C0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcustomlinecapstrokecaps.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCustomLineCapStrokeCaps", + "name": "GdipGetCustomLineCapStrokeCaps", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "455E7A66E017D5A7C52C3A694EDAE7D2D98E923910655EF6264975237D4AB42D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcustomlinecapstrokejoin.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCustomLineCapStrokeJoin", + "name": "GdipGetCustomLineCapStrokeJoin", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E2C33981E587242B0A151C7256E2A20CAAB85C99430312ABD6B0A5AF4C1603AB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcustomlinecaptype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCustomLineCapType", + "name": "GdipGetCustomLineCapType", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BE5D15969710632E3B0EF65413E2173DD62EF016F2EF657A91721956253D310C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetcustomlinecapwidthscale.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetCustomLineCapWidthScale", + "name": "GdipGetCustomLineCapWidthScale", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7863D941C0F0DA7AFED92F7DDC7E90C70467EB43B3A41F7EC9EAEC4777B62C57" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetdc.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetDC", + "name": "GdipGetDC", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5B02C2890E0D2D48CCD9360377CFF1F03BEAEB670075AD35FA2EC4839E5044CD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetdpix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetDpiX", + "name": "GdipGetDpiX", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EF7CF8DAE41168C5CEB21E2AF2B66CE691DD71C3434A7C9683EE56356A6ED613" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetdpiy.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetDpiY", + "name": "GdipGetDpiY", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E5916B2961DB7BACDAE4B08A7341DBBFC94D90EECCF2EB9423FE330B12BA0619" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgeteffectparameters.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetEffectParameters", + "name": "GdipGetEffectParameters", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "86A6045876C15DDB4EC77C49639349D689EB9293325AFC569D0ACA4AEBC9A78C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgeteffectparametersize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetEffectParameterSize", + "name": "GdipGetEffectParameterSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9138B6A94FB0551E8828E0D6BCFF2D95EF79015230E206C621D26D21AA710320" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetemheight.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetEmHeight", + "name": "GdipGetEmHeight", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E17158B0B42D4EF893484D9226F74619DDA913AA268E40E8304429C3689D74D5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetencoderparameterlist.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetEncoderParameterList", + "name": "GdipGetEncoderParameterList", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C1B8FA72912A3F628FE06BB77495A0C40E67D8E1B020E23A38F79152C230EC16" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetencoderparameterlistsize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetEncoderParameterListSize", + "name": "GdipGetEncoderParameterListSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "42820D1649F635970AA69BF56C4305C2F23BA5C5BD892439388336F285AA6323" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfamily.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFamily", + "name": "GdipGetFamily", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "62A7A3FC8160E28A01A04E179FC4D9DD70223C4DBD26AAB07C734166862BEA53" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfamilyname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFamilyName", + "name": "GdipGetFamilyName", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "736DD9F8400FE9D174BE8A030796F160D0A8FC553BBCE94B28F8C23C42664A47" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfontcollectionfamilycount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFontCollectionFamilyCount", + "name": "GdipGetFontCollectionFamilyCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CD06563FE8E04C1E88E003CC4B2FB5DB4EF98A0812E33E9004C9FDE81A437930" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfontcollectionfamilylist.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFontCollectionFamilyList", + "name": "GdipGetFontCollectionFamilyList", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D7E1B9023EC5506E3556F5BA4171016B2A403165AB5F1FD7976CE86834139AE1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfontheight.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFontHeight", + "name": "GdipGetFontHeight", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "95F6B786B00C095DDF42F94F081C42DED0A670F68B82FC316F4D1FC33EA00A50" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfontheightgivendpi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFontHeightGivenDPI", + "name": "GdipGetFontHeightGivenDPI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E006A6E171C4058624D13A1E6D5553F55BAD66F9E51CD4DFED25394DB622B4E8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfontsize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFontSize", + "name": "GdipGetFontSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "689263A7DFFB4CBA9080A75D4F5461CA766E68875DA4B837C80D43CF7FEA7625" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfontstyle.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFontStyle", + "name": "GdipGetFontStyle", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "042FAE9062D7EBAB703B46F3E0D190B56DF86C2DD5F92C879801A44CC646A1C0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetfontunit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetFontUnit", + "name": "GdipGetFontUnit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "23437397925A3506E20353A2706AC440B601CB7591733403D6C1A6EB983C4EE8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetgenericfontfamilymonospace.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetGenericFontFamilyMonospace", + "name": "GdipGetGenericFontFamilyMonospace", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D1F3061FD41E5C1B7807DBA0B69D50FCD68CEE2426CF707796C03542536515D4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetgenericfontfamilysansserif.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetGenericFontFamilySansSerif", + "name": "GdipGetGenericFontFamilySansSerif", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E24189C9FFCE520DB263650213AA519D660559591D22906C96A7896B5FC0D8A1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetgenericfontfamilyserif.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetGenericFontFamilySerif", + "name": "GdipGetGenericFontFamilySerif", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "626ECC294C6B649C891233E5908122166045D1A860B576B968682FD3B7A9C529" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgethatchbackgroundcolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetHatchBackgroundColor", + "name": "GdipGetHatchBackgroundColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D97D9E760B60BFD061C5BA009C78637E3F2B31C065DF8B4CA98FD59C583BC65E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgethatchforegroundcolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetHatchForegroundColor", + "name": "GdipGetHatchForegroundColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2206DAD26CE9A29B998DFC486BF22241FE38857B30F0A925915FB3579C93E221" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgethatchstyle.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetHatchStyle", + "name": "GdipGetHatchStyle", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E94FF05FC16F80A76058532EADB08B0C082280D5E150EF66CA26EB15CC58FA0D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgethemffrommetafile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetHemfFromMetafile", + "name": "GdipGetHemfFromMetafile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6C04E644480B58C2822D0D7BAFB9D5B07FEED386757032B447BDB26426031FA1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimageattributesadjustedpalette.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageAttributesAdjustedPalette", + "name": "GdipGetImageAttributesAdjustedPalette", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9755A3AD052DF8232C04CCAE15B1B8157F558DA2EB8BA981FE008B7D9EDCBF98" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagebounds.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageBounds", + "name": "GdipGetImageBounds", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DE548E67B34E04B23A6EE82F86DD6D191AC3F7A3642318A3EA3014CD61FF4361" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagedecoders.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageDecoders", + "name": "GdipGetImageDecoders", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "705566E772C0A96F90807EB2CBA27A8C12DBA13D75DC0671E377B99D9048BEAB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagedecoderssize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageDecodersSize", + "name": "GdipGetImageDecodersSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4DAA557A9E42CD995697BC10374F19C84446F815E4FE6FD2D51D9E2A39F5EA5E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagedimension.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageDimension", + "name": "GdipGetImageDimension", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BBB1C75DE60CB39A194E9D450033B55DBE4B1D429DF01577ECECA08C89CF3EC8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimageencoders.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageEncoders", + "name": "GdipGetImageEncoders", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6440AA1A3E8750B37A40622A359C8704C747DF76B3EFEE96DB5CAE8EB1DD915B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimageencoderssize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageEncodersSize", + "name": "GdipGetImageEncodersSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EADFF1A9F6A7F7E665D13DB37BC86629610DD4BF1A31136A0E2FDDF4B98E9FA3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimageflags.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageFlags", + "name": "GdipGetImageFlags", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6E42B4A9D8F6F36529BE5FE91A51212EF4E62E195E3E4D785E29462D89CFE173" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagegraphicscontext.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageGraphicsContext", + "name": "GdipGetImageGraphicsContext", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6A44B7C9F83DF50A195C7AE0A5803EB450291172DD019A0BC51484B5552AAD8A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimageheight.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageHeight", + "name": "GdipGetImageHeight", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D19C4614A62094C2451B37484C996045093F68FBEB36B73203AD7A847952D362" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagehorizontalresolution.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageHorizontalResolution", + "name": "GdipGetImageHorizontalResolution", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2CCABD0BA2904013E4915738A9E74EE8F87E9AAF985AA0ED4B55FA57619067AF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimageitemdata.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageItemData", + "name": "GdipGetImageItemData", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "36CF792A0810EBF3D41FFEF16E5F36B61986062730B5B0947D5E1EEBECACD0BB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagepalette.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImagePalette", + "name": "GdipGetImagePalette", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "81B06F19E433FB51E43EA2272B459DB47528027D563A8FFB1F9B7351889A559E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagepalettesize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImagePaletteSize", + "name": "GdipGetImagePaletteSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6A4461A9FC8C70163D94818FA8422B21A71505E038B7C529BD49B0D4105D060F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagepixelformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImagePixelFormat", + "name": "GdipGetImagePixelFormat", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F92F940322430CF8D01AAF64E09905EBC0C94DD74C6245711D0F4797AFFD117F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagerawformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageRawFormat", + "name": "GdipGetImageRawFormat", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8C417311E1F70148B8F299547CAED7DBBC0295FD1029673DA423B07E35DA7BED" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagethumbnail.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageThumbnail", + "name": "GdipGetImageThumbnail", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3C24A588D4EE92A70A41881D0A8EA2A111FC5AB1A0E79BB3CA954E3920294BD0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagetype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageType", + "name": "GdipGetImageType", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2428B112572D5DEDF8D83122832C37C776A338A2BEFF8EE2E8C4B3BDB4CDAE50" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimageverticalresolution.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageVerticalResolution", + "name": "GdipGetImageVerticalResolution", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9B26D4CF782493D0374DEAE15E5430BEF95BB7C5A3B80DBB5D9F736E52CC0DDE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetimagewidth.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetImageWidth", + "name": "GdipGetImageWidth", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "23F541ED9E40DB0715218A0D101AA2E6A0149F745F7F98C575927CF2D93A5651" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetinterpolationmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetInterpolationMode", + "name": "GdipGetInterpolationMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0639691DEE78E90DBBBD3B615C54CAE1DF723B41D287443D8AB53CEB38F4229B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlineblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineBlend", + "name": "GdipGetLineBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5DEABB3DD90010068C3236B335B50B6C592ECE8C76D7D57D8532CAF15B7507EB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlineblendcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineBlendCount", + "name": "GdipGetLineBlendCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DEAA56AA5E6A144D75691999BE4A82E8D0935BB2111EA9ED85F5F01EF0D0D5A5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinecolors.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineColors", + "name": "GdipGetLineColors", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F70B94FEA1F56FCBE33AA91A20C960B8244C9A7D214CB785E370129492D8435D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinegammacorrection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineGammaCorrection", + "name": "GdipGetLineGammaCorrection", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2377A1DBCC857603260CCC2E199E13BA6B18D05F2F8E0593B0E35DC0C5013135" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinepresetblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLinePresetBlend", + "name": "GdipGetLinePresetBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6AA81FD00B2BA4EDFB182A8EC52C46F29803E7A946450C1F60C4927C0EB6408B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinepresetblendcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLinePresetBlendCount", + "name": "GdipGetLinePresetBlendCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EC5DE0828A068C8DFAFD35CBA3443A6F1DC7FAA61BD2F191753BB797F3509EA0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinerect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineRect", + "name": "GdipGetLineRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B4D42437A13852C9C50AB6DB8A948EB45F25F359C96BCDF5F04B7D8686322E51" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinerecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineRectI", + "name": "GdipGetLineRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A2CFFC37A2DAA5E03BA0FFB8EDCB98A14D6FE2D8978B75D479A9BE53BB904354" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinespacing.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineSpacing", + "name": "GdipGetLineSpacing", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "539606E70B22C37C8B3234D69D12EA36706009B21E8C75351AE6B9B2B01C40E2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineTransform", + "name": "GdipGetLineTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DDF71845F2C73C869D767BFDD1CE1F57A54A4779243EC70D7BB8AE35DC7558C7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlinewrapmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLineWrapMode", + "name": "GdipGetLineWrapMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B0B57CDF2B1DF801EAB4D3E23D9E0A8630D37DE3C881DC98918FB90B6A6C53ED" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlogfonta.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLogFontA", + "name": "GdipGetLogFontA", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3EDCCCE29AC5DF7964C43C2397B72FCADC2029F72348BBD8E9764EB5610D29FA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetlogfontw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetLogFontW", + "name": "GdipGetLogFontW", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8E10322DEAC1DF2C853CD737BE4DBE80886EE56369D75EC96BC5587FA93CF671" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetmatrixelements.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetMatrixElements", + "name": "GdipGetMatrixElements", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DE6B022F000C95C9A734ACA4C4A835AD69319ABDC8CCB88BAD87F450891FC6D3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetmetafiledownlevelrasterizationlimit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetMetafileDownLevelRasterizationLimit", + "name": "GdipGetMetafileDownLevelRasterizationLimit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "46152722ADFC38E19C59FD59D4067AEB9609B30D2AA40309A127B485FFBD8A6C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetmetafileheaderfromemf.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetMetafileHeaderFromEmf", + "name": "GdipGetMetafileHeaderFromEmf", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0CA8B310E9927DCDFD306C09128071CCA43913D31EE41F89375C4A2A43548022" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetmetafileheaderfromfile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetMetafileHeaderFromFile", + "name": "GdipGetMetafileHeaderFromFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "778BCA809A55CC4474E1A47DE27627446CE4B9FA6A2682871DA243A594B48420" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetmetafileheaderfrommetafile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetMetafileHeaderFromMetafile", + "name": "GdipGetMetafileHeaderFromMetafile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0CFC6AF97799B833FCEAD33D95176836BAA9E390C67559BDA50AF5C46236F08C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetmetafileheaderfromstream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetMetafileHeaderFromStream", + "name": "GdipGetMetafileHeaderFromStream", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9DC9D90DD0BE6F57A415588391AB4C9AFBF1180F491F4C442B00AA4149B671B9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetmetafileheaderfromwmf.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetMetafileHeaderFromWmf", + "name": "GdipGetMetafileHeaderFromWmf", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "46330B1FA310BEF3F386BBE3BF4B0519095E2A3B2B7AC1685CB4F61ACBE2095F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetnearestcolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetNearestColor", + "name": "GdipGetNearestColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8888D0423CC3DD17D235E99C13213223E42D5F09486E975C4578671A764184ED" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpagescale.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPageScale", + "name": "GdipGetPageScale", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "036B88BDFAF07CAF4D6598F55B02769CF6D4D7544441DE22110EA943A6247D26" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpageunit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPageUnit", + "name": "GdipGetPageUnit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DBDA23B9A5D7672B18753C0C09A14C5EB05465A465DD2C8E9F4EFA93449EDF60" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathdata.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathData", + "name": "GdipGetPathData", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BF0EF8129AC10E3DA3A14204318F2CF5C54AF97F9CC5E2C271683EA150AB6F04" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathfillmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathFillMode", + "name": "GdipGetPathFillMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DA3DAB251B3D4DF878DA668446E15AC14467C9D488DCF4B5249A0B79100FCAA0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientBlend", + "name": "GdipGetPathGradientBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9D892329041AC83A20CA8A1039F276574D6D61B43606CA33F679BC692706F15F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientblendcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientBlendCount", + "name": "GdipGetPathGradientBlendCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "332F6923363724BBF281354984A58A46F8C0E2DD29D21CC92A8689B0417B155B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientcentercolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientCenterColor", + "name": "GdipGetPathGradientCenterColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8B83535AD651F0FADC1BEBFC74BF5D3F627FFFF7B47DE9DAEE87C8E7C3574398" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientcenterpoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientCenterPoint", + "name": "GdipGetPathGradientCenterPoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C3E6F41EFD86DAE758F659FEBC6BE16A96ADBBCF0366DD971A5967094808F385" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientcenterpointi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientCenterPointI", + "name": "GdipGetPathGradientCenterPointI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "96E7AED0CD0316ABD44CEFC3850C97AC285E4979FB19ABAE019A475F35BB6FE8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientfocusscales.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientFocusScales", + "name": "GdipGetPathGradientFocusScales", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "778936E38679685E2020C0F23C4594846252E936653BCAB021EEB0511B81DF01" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientgammacorrection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientGammaCorrection", + "name": "GdipGetPathGradientGammaCorrection", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "80284780A6CD8E27DB05B6F19AF7F555B1D2A96C32F1393CDF29D614A0C6D5CF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientPath", + "name": "GdipGetPathGradientPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "946D1B5F99ACB7F6282E4B33B628033FB14131DD3CB029D30A9CC9E021924101" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientpointcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientPointCount", + "name": "GdipGetPathGradientPointCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DC9853FBB57A7C72C9D52E931FEBED54DC5B53C4527E6C5505075BA90DCF398B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientpresetblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientPresetBlend", + "name": "GdipGetPathGradientPresetBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "413E6081E097743DFE8425B0D410F201D23908C52D003F4ADC1B8A038ACE6FE5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientpresetblendcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientPresetBlendCount", + "name": "GdipGetPathGradientPresetBlendCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "54F82BF31588DF69633B89AE02FF4BA4AEC096AF9334E5AB8946C05CFFB63263" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientRect", + "name": "GdipGetPathGradientRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3157E01BEB3FDE36A060E4AF34BD77FE08539D2047B2C00C5F5B95F7731AB30A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientRectI", + "name": "GdipGetPathGradientRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AB0683EDC19708E879EB127B8D7B94A26D7F4BD40DA36D53B59A1A2A5A3FE6C8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientsurroundcolorcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientSurroundColorCount", + "name": "GdipGetPathGradientSurroundColorCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FEA280E49C788E04C5AEE4EC5C9C7AE7B70F48BCAD98A40BD10B0C65D8E8F905" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientsurroundcolorswithcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientSurroundColorsWithCount", + "name": "GdipGetPathGradientSurroundColorsWithCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "06E2F1BB2030FF4069CFE00B81C057495C4E0F93378162BFB8395058AC5428D8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradienttransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientTransform", + "name": "GdipGetPathGradientTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "716F2A6567477514DD028C99D8FA1DDD9E0DD0B920D11EA6A2474866EF72BC75" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathgradientwrapmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathGradientWrapMode", + "name": "GdipGetPathGradientWrapMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0F4BA9C9D0B717C55FBE0A643F6234487271EF34F8C2502E000397E49C18C31F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathlastpoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathLastPoint", + "name": "GdipGetPathLastPoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C79B3E6E082E9BEC1966768AE84D10B27B7EC7014D3709F4D96A4FDB4B7B2BAD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathpoints.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathPoints", + "name": "GdipGetPathPoints", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CAB670964D07C43E85BA4F570A03E4BA1B93D5DB0F14EA6CE6060CD68731411E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathpointsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathPointsI", + "name": "GdipGetPathPointsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "00CC2BA1F7C9256588ED3FDA60F528145E51849A6F8E84966D12BAA1B1774200" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathtypes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathTypes", + "name": "GdipGetPathTypes", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4AD20E74FAA995D5587053F604E642C44C20246BFEB2D9A60902CCCED3842E40" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathworldbounds.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathWorldBounds", + "name": "GdipGetPathWorldBounds", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1765F9031892F384709834C225728CB77B362E6AE13EB79974CEF864C5904F6E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpathworldboundsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPathWorldBoundsI", + "name": "GdipGetPathWorldBoundsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C890C42C2B88BDDEAC04D8B0CB7346810B73A34E6A4E1EF280FF442CFD98543F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenbrushfill.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenBrushFill", + "name": "GdipGetPenBrushFill", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9049B6343C96B9589088BF80A4584A4738D123C5E89276C53830FD6A4A4C710E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpencolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenColor", + "name": "GdipGetPenColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D69B85B528DF11DE346874CC1FC9EE78A1A5FE1CDF3054ECAEA5E9E1493ADE8E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpencompoundarray.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenCompoundArray", + "name": "GdipGetPenCompoundArray", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "315E2F748511DDA570CDFD0CB57AE1371AE56BA970F6FEC1B65B92EFE0E80ABB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpencompoundcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenCompoundCount", + "name": "GdipGetPenCompoundCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5573C495717B0A1F81D7115757FC184E823166440FCBA849EC2CFB9C084B05CE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpencustomendcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenCustomEndCap", + "name": "GdipGetPenCustomEndCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F048E921909249B63B4108BD33E019002E7E8F552B8C88A34BB6A2438C52F709" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpencustomstartcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenCustomStartCap", + "name": "GdipGetPenCustomStartCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "902A0D3B4BB4D7428DC506DF5CE530FC3079B39613E87F30670D87E29FD6A5C3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpendasharray.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenDashArray", + "name": "GdipGetPenDashArray", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "640A1F65A301E77075E663742E3DF6AB9AF7E56B8B80A1D24FB0230BC80EBDF1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpendashcap197819.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenDashCap197819", + "name": "GdipGetPenDashCap197819", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4D5C29F2EC45D3C49D089CB6055FED9C7E3D845365075F7148A1BBFF276BB691" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpendashcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenDashCount", + "name": "GdipGetPenDashCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D8506AEAE4FAE32D08E6C7FDE6324BE58C08F21B8F3112CA347B8A8AAEC26558" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpendashoffset.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenDashOffset", + "name": "GdipGetPenDashOffset", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1C7F10AFEBEC6744411D88476B6B884F0764EDB005B39AA538C786BE0819A297" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpendashstyle.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenDashStyle", + "name": "GdipGetPenDashStyle", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9EBF59CD4B2216849C778337CB2B8119F7971D676A5CB4B239A0B932930F7243" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenendcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenEndCap", + "name": "GdipGetPenEndCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "00339C2AD9C6A5C9D93ECF87F6EF7917486242C907A9B50041B3DA2F1AC96FA8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenfilltype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenFillType", + "name": "GdipGetPenFillType", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DEC7CF39AD040894E6668977908DEC7A9596950F08A3788761B0BE8C5DD8ACCC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenlinejoin.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenLineJoin", + "name": "GdipGetPenLineJoin", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EE92351B8BCC3BCEB1FDE7B29791A5BA5FC0A442825F06AC24EE6AA92559786A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenmiterlimit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenMiterLimit", + "name": "GdipGetPenMiterLimit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "195F27EDA30502F8BAD27C645B999A027D91516C243C7A30164F1C0539BD10CC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenMode", + "name": "GdipGetPenMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "457A22930D7DB0AD78C0030C9493DE4035719F3D9073F004E099EC089DD68A02" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenstartcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenStartCap", + "name": "GdipGetPenStartCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "99C04754EAA21703199432F2D0DFCE0ABEFECD477EE6868B956A77E3C0A3AE0B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpentransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenTransform", + "name": "GdipGetPenTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4DCC229AE54D8B2F3936C95A401A75C7699E05DB7D20D268451B03AF902292AE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenunit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenUnit", + "name": "GdipGetPenUnit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C6751D49FC7ADFACF783C836823E654C45378179C53626D5E1DE0CFCD88156F3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpenwidth.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPenWidth", + "name": "GdipGetPenWidth", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "326B15FD92432020018A665F004F7A8554D1957FA7AAD10F5F628B3BAB83EC0B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpixeloffsetmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPixelOffsetMode", + "name": "GdipGetPixelOffsetMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1C03B4CE0E4F4E5D47B49CF06549359D5743A799D8375BACA3B15C7157B03B60" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpointcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPointCount", + "name": "GdipGetPointCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6AB649426E74B10EFDF01C47D58A4A17893F490B966A5A4710B5FA5E6B841D29" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpropertycount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPropertyCount", + "name": "GdipGetPropertyCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F003EC92D82ADD667C48CA60FF24AFCBC3905CB63D9C66171CA4C9CE04A71579" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpropertyidlist.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPropertyIdList", + "name": "GdipGetPropertyIdList", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FAD3028DDB8CFD3AADEA818323EFCB0249322FE91FE6B8C06CC6663F065BD64C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpropertyitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPropertyItem", + "name": "GdipGetPropertyItem", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AC98EBEA61960FF76C6B415EE1F5AA38D04CFCBC216C82F5B83C7BE3413208B3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpropertyitemsize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPropertyItemSize", + "name": "GdipGetPropertyItemSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A016DFEDD3213EFA2B266D80491B1713DECD78E92B5AE195F4724EF2D75341A9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetpropertysize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetPropertySize", + "name": "GdipGetPropertySize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5F195E286CED2B8CC52CBB52D37BB30EDEF9C881E3E6731FDA47EA31D7B7EC93" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetregionbounds.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRegionBounds", + "name": "GdipGetRegionBounds", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0B28820E4A2C36F7A907D40650127F281EC2A706D59CEDABCDD35D30B19D4046" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetregionboundsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRegionBoundsI", + "name": "GdipGetRegionBoundsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1B3037A0DBBE0008AA72BFB301772635CD692678024B0BA14A81385D787C6379" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetregiondata.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRegionData", + "name": "GdipGetRegionData", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DE9EB6BC99F035360D6EE904BA5077512DC30B25FE3BE066489A5885BCC9DA3D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetregiondatasize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRegionDataSize", + "name": "GdipGetRegionDataSize", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2F7D12C068612A06359A8F017ED5545A91FCBD1F4BE0C64BB085A05AEBAEE8AA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetregionhrgn.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRegionHRgn", + "name": "GdipGetRegionHRgn", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FD66A26003726D66A4BE5E2D125E5763CD82E01217A0FDDC0CABD253AEAEB69E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetregionscans.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRegionScans", + "name": "GdipGetRegionScans", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E64E2A429310880E4B053AE168FF193C4A12B6B9CCB6E46180E0C7E12BDFBF36" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetregionscanscount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRegionScansCount", + "name": "GdipGetRegionScansCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "885ABEB24C1172F13A3011D166DBA6E45F58C4D3EF24F61B41B967DCE24BC24D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetregionscansi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRegionScansI", + "name": "GdipGetRegionScansI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4B462803D3DDBC78F1C13457C8C286AB0D01C657E4C646F8821FBBEFEFB9C2D5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetrenderingorigin.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetRenderingOrigin", + "name": "GdipGetRenderingOrigin", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C1D1035EE77B9FAC53F3A37D3B8280E638ECCCFC6E578FF42D3415E9F7182618" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetsmoothingmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetSmoothingMode", + "name": "GdipGetSmoothingMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4B64281AA34E1C835606457BE02A61790C77F44A17D6A22EA61C1C68778FE1A3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetsolidfillcolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetSolidFillColor", + "name": "GdipGetSolidFillColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F5300A87C26A280A24C2BCD24C5633BD9A82DFBE7DBE7204308E1CCE23813E05" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformatalign.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatAlign", + "name": "GdipGetStringFormatAlign", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AB9ECE2B341949A7EE4907FBAF332FE9525E91EA1CCD3F8A437FCF0E6AB1869A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformatdigitsubstitution.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatDigitSubstitution", + "name": "GdipGetStringFormatDigitSubstitution", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "75A3EEC3B339C6244720745586C5ABA8B09802902AD5A6AE478BA71101B5B976" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformatflags.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatFlags", + "name": "GdipGetStringFormatFlags", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1B1CEC91851E4EE4F98D5A3187743ECEB7DC675B524D585656C061021F8FD438" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformathotkeyprefix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatHotkeyPrefix", + "name": "GdipGetStringFormatHotkeyPrefix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B0CCEEB823204C57869F9252C3AF24617205812195CC85F0D2224690B740F1CD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformatlinealign.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatLineAlign", + "name": "GdipGetStringFormatLineAlign", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A47AE9010B24ED24B20E2ABFC023E1DB3D21C41B7B9F25CD117E5350BDA7D4F3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformatmeasurablecharacterrangecount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatMeasurableCharacterRangeCount", + "name": "GdipGetStringFormatMeasurableCharacterRangeCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0F05C89192F2AFD9FD2D7BD12B40F97688F313C186B1A78C4C778FD8FFFB15CC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformattabstopcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatTabStopCount", + "name": "GdipGetStringFormatTabStopCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AA3F6D71FF7B3E6C53E53895C09D3C4F4AA5C6CEB96B20481F65A74AFF4B4F2C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformattabstops.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatTabStops", + "name": "GdipGetStringFormatTabStops", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6CDB6413FEF85AF7CB1D6ECE761BE1891E3309D020E758BC66B73429B955A463" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetstringformattrimming.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetStringFormatTrimming", + "name": "GdipGetStringFormatTrimming", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1D4199C17E675701CFE7232D759F0A731F48EEC7EAC656A9B3B3C26A9120D940" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgettextcontrast.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetTextContrast", + "name": "GdipGetTextContrast", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8043FB5982C6785C29B21029074F780C9EEF98067A3AE4AA4C8D9BA3D996B084" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgettextrenderinghint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetTextRenderingHint", + "name": "GdipGetTextRenderingHint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1E33E3F3E6CB3AB79DB871661B59C3E30A6A21EF5CD63E41F869BE0ECCE4A1F8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgettextureimage.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetTextureImage", + "name": "GdipGetTextureImage", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6C21302A5730455EF63391702A7147449AC9855D45F05D7EEC02C95172DB742B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgettexturetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetTextureTransform", + "name": "GdipGetTextureTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C681882C5AA783E8E067A58C8823C4FB06E8AE6D49CB18D116D522279179CCAD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgettexturewrapmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetTextureWrapMode", + "name": "GdipGetTextureWrapMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "57E9ADD287AFD9D65A275E2BC99F7B95B311902E467B25F9659AF1CFABE66CFF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetvisibleclipbounds.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetVisibleClipBounds", + "name": "GdipGetVisibleClipBounds", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "31993C5593E8C29DD8D4F50FE2E9763C54FF74FA1E84FB643A352C1BAB6C5E58" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetvisibleclipboundsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetVisibleClipBoundsI", + "name": "GdipGetVisibleClipBoundsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "71222DBA6F39B2F461D5CCA3F00AE7068E615E75A95A4F253E6D82EE841368AD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgetworldtransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGetWorldTransform", + "name": "GdipGetWorldTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D647098D0280C1EA54AC605A02D0AEA19BD5A7ABB008292725C6028618EAB945" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgraphicsclear.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGraphicsClear", + "name": "GdipGraphicsClear", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FFFF220306328F21004D12C21C746A71CBD5D9EDF35EDC40175281AFCCBFD95D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipgraphicssetabort.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipGraphicsSetAbort", + "name": "GdipGraphicsSetAbort", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4DF2A10B1B39CDF8E30E32DA675D82ADC384178DB5639FB86A504F34899E94C2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipimageforcevalidation.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipImageForceValidation", + "name": "GdipImageForceValidation", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "78885E5052E65076FEECF41B40C5091540EADDDB0AFE6F0825BEB2A391CA8BE2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipimagegetframecount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipImageGetFrameCount", + "name": "GdipImageGetFrameCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4C52B7C947FA082B0C2E9372AFE631A6E27B1595AB0E304E8452C4F498A26C31" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipimagegetframedimensionscount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipImageGetFrameDimensionsCount", + "name": "GdipImageGetFrameDimensionsCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D7975358DACC61CEF11975B10A13E5E27B91F301A0495D219B14DDF4C275AA3C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipimagegetframedimensionslist.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipImageGetFrameDimensionsList", + "name": "GdipImageGetFrameDimensionsList", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1256F57FDFF3747F1716B789D4DB2CEBB93B0C048551314A65B44282A5DE9A58" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipimagerotateflip.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipImageRotateFlip", + "name": "GdipImageRotateFlip", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "15378E9C746F6BD3E51E1805F5BD273797B3A0CA544B66A468E289E5F6CB9068" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipimageselectactiveframe.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipImageSelectActiveFrame", + "name": "GdipImageSelectActiveFrame", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3209DE3A778C1A3ED1E4A74922168DB73649EB4B3DCC24A3943F0606115C6D2F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipimagesetabort.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipImageSetAbort", + "name": "GdipImageSetAbort", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B42FAABE87F97F7D6305A2E170E4699E754566C44993768E0E3F7A109B022E1C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipinitializepalette.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipInitializePalette", + "name": "GdipInitializePalette", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1BEFFAF4804173AAA861B277C5861F09CB8755397DAE69E70AE08EF5F83C7814" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipinvertmatrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipInvertMatrix", + "name": "GdipInvertMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B8C141A3214808585398EBB5803B60512A1F1BE305706613579FECD0944AA353" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisclipempty.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsClipEmpty", + "name": "GdipIsClipEmpty", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7583664CBBAEF45E4085557B6C38430496A60AA30177CB65CB129C5D0AE20B8D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisemptyregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsEmptyRegion", + "name": "GdipIsEmptyRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DBC34A71E8A35DF3274DFD8668BECFA029C53B4F0C472F60D46349A4048D4067" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisequalregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsEqualRegion", + "name": "GdipIsEqualRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D1F9E581EDD6D81257EE44D21B4D85942937F4A0CCCF0CB3695C9174EFD67262" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisinfiniteregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsInfiniteRegion", + "name": "GdipIsInfiniteRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "45368881CE001F5751354D83F6A65CAF17FAFE3C1D0FB3523FF11FB9BA930453" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipismatrixequal.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsMatrixEqual", + "name": "GdipIsMatrixEqual", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C0A55B452395C6DA5C63ED588B254FC2C9999A5DDDADB352E63C4C8C23566385" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipismatrixidentity.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsMatrixIdentity", + "name": "GdipIsMatrixIdentity", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0AE00E71DB0F907C1C7DB71EF8E6A277252B36694BDBFE6DFCE1B3F18459ADA5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipismatrixinvertible.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsMatrixInvertible", + "name": "GdipIsMatrixInvertible", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8EA03DF7ABE6D2DB07EBE7DFD9F7C17CD0D2F091721BA8FDCF78A81CFE77E351" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisoutlinevisiblepathpoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsOutlineVisiblePathPoint", + "name": "GdipIsOutlineVisiblePathPoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AF098A46B821ADA63268A45B95526A6FEF2314029A9A2F217FADE904F6FF7325" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisoutlinevisiblepathpointi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsOutlineVisiblePathPointI", + "name": "GdipIsOutlineVisiblePathPointI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "672E7AB17B59CDD2B7EF078BE6D68CAC43803A22DD6BF02D69E281D2E100D6BA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisstyleavailable.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsStyleAvailable", + "name": "GdipIsStyleAvailable", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1676D0EE805CFAD102F2AB5813D90AC6E1ED4ADEB9C3E351CFCD4DAC814E36BA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisibleclipempty.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisibleClipEmpty", + "name": "GdipIsVisibleClipEmpty", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "28E34A32C71E01676BDF81F35659BCFE21C40DEEFA15082A058B2810F2CCA564" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisiblepathpoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisiblePathPoint", + "name": "GdipIsVisiblePathPoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "89D8D8A741DB29EEBB317BF438431BB1D0CD1EAB9BFD443584BFFF693F064446" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisiblepathpointi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisiblePathPointI", + "name": "GdipIsVisiblePathPointI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "99672FBF31E28A13C3E747DA8CF50B12B27A9C18CF6433FE1D65C10C0B64E759" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisiblepoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisiblePoint", + "name": "GdipIsVisiblePoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "726516A918419C018B4C701C0B7C8FCF5944BE1F58F4310775C9FCA2F394B317" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisiblepointi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisiblePointI", + "name": "GdipIsVisiblePointI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1F4DD8B795DB4B5BCA86A198EF5C85207FE780F35D1CFDFF15123CA08894E12D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisiblerect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisibleRect", + "name": "GdipIsVisibleRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D272CE839AB3F1DDDD37BA2E2E833DEB71BE862BB9E24E5F04AF083686CD3349" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisiblerecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisibleRectI", + "name": "GdipIsVisibleRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D5885539FD9E358C7E939EA554C42038C9579415212FE86BB16F5443E7AC3FD4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisibleregionpoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisibleRegionPoint", + "name": "GdipIsVisibleRegionPoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "07530662547505CCF309DC17470AAE80A564273B2CC18B3F4A2DCFD3FD5C79E8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisibleregionpointi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisibleRegionPointI", + "name": "GdipIsVisibleRegionPointI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E3850B8EEA6E06605BDBC6DDA711A7D9864A81C8A41FF910B51B00CD6B354434" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisibleregionrect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisibleRegionRect", + "name": "GdipIsVisibleRegionRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BD8EA652DB22B7DF4C430B9A884E9D5ED64B0A6220631FEDBD37C41926A1DFC6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipisvisibleregionrecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipIsVisibleRegionRectI", + "name": "GdipIsVisibleRegionRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8B96289EC8E5F67F46F05B265637D44BBEDF628112F9B7AFF1F82705EE5B95AE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiploadimagefromfile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipLoadImageFromFile", + "name": "GdipLoadImageFromFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "680B114F2CAC6272F4CBAD89D88480BC91200F5A47D74830263EE3105C165473" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiploadimagefromfileicm.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipLoadImageFromFileICM", + "name": "GdipLoadImageFromFileICM", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5A17247DF6972B9E900AD8DAC3A9F2FC1AE49844F6DA3F846E6BA1A73D6D3950" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiploadimagefromstream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipLoadImageFromStream", + "name": "GdipLoadImageFromStream", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F5C0B91202EA2A13FEDD059C2E3B2D5AF13B8561CB70F8882BF6D604A56AB851" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiploadimagefromstreamicm.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipLoadImageFromStreamICM", + "name": "GdipLoadImageFromStreamICM", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8CE7E1686FA3EBC715897988D209807267480C29747C83D68A6687D0D6DE7F8C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiplusnotificationhook.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdiplusNotificationHook", + "name": "GdiplusNotificationHook", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1C472ECEA7491727627FD07A4E5634175ACC5F81E6A91A135F4446D348CB5E14" + }, + "contracts": [ + { + "kind": "managed-lifecycle", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiplusnotificationunhook.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdiplusNotificationUnhook", + "name": "GdiplusNotificationUnhook", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BED66CAA7F53815EDEAD3B9A2A6F1E9998CFD835634F030F05FA5AE9096AE93F" + }, + "contracts": [ + { + "kind": "managed-lifecycle", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiplusshutdown.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdiplusShutdown", + "name": "GdiplusShutdown", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D03E62F39F56AAFBB08EA71F5B4557383E73297BAC2EB06E3772926203D674EF" + }, + "contracts": [ + { + "kind": "managed-lifecycle", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiplusstartup.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdiplusStartup", + "name": "GdiplusStartup", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5C211911748025EF932FC2649E03E9B445842F310D887461BB27FD48DCF4C5C8" + }, + "contracts": [ + { + "kind": "managed-lifecycle", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmeasurecharacterranges.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMeasureCharacterRanges", + "name": "GdipMeasureCharacterRanges", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A2BCCE44C1E5488096BBB5986031D071B1B3EFF04DC60EF891E0124979EDE9E6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmeasuredriverstring.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMeasureDriverString", + "name": "GdipMeasureDriverString", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DB1867CC212DDF02C50814A015CC78842AAC7A83508E00C5F63F63478C2F99EE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmeasurestring.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMeasureString", + "name": "GdipMeasureString", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "695C3E2688FA77030AB17D7A5C71664A378C3F4309067D21BB0293E1812B7528" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmultiplylinetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMultiplyLineTransform", + "name": "GdipMultiplyLineTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7AB6D52F069F3A9C3CF013C65A67537CC414BB7FD367AE2D547A8D304E27241E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmultiplymatrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMultiplyMatrix", + "name": "GdipMultiplyMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D08197866C2A38C1E7D61A72A075826D5F6FB8992DD483C25038C9490839B99D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmultiplypathgradienttransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMultiplyPathGradientTransform", + "name": "GdipMultiplyPathGradientTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8F2F1873F193C2A5E597CEB288F44E61B8870A6900F13582CC840BC2D8977EAF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmultiplypentransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMultiplyPenTransform", + "name": "GdipMultiplyPenTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "76356A42253CA69561FB55113D1AE6BDB2B89914EB552A9F6878F85124587A84" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmultiplytexturetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMultiplyTextureTransform", + "name": "GdipMultiplyTextureTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4884E3CBEA7D58C8D625B2B201DB5F82AC342BC830D2EF4F7D781EFE0DA4DFB6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipmultiplyworldtransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipMultiplyWorldTransform", + "name": "GdipMultiplyWorldTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "04674CC5A7179934D9F75E31DA300D24B0E457BC631F89ABA37C3B801F337D04" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipnewinstalledfontcollection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipNewInstalledFontCollection", + "name": "GdipNewInstalledFontCollection", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CBF7A96AC0CE6458E568B77467B496F066FF75E20AACEEE98DF000728AACBBC2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipnewprivatefontcollection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipNewPrivateFontCollection", + "name": "GdipNewPrivateFontCollection", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CF20A9E51B1FA2B605DDF9D94C10351D194E6EE4E707DAAB53CFCA2A44199601" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathitercopydata.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterCopyData", + "name": "GdipPathIterCopyData", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9218246CE8913F0E332923807F8C79C1F16CFC9746BF5A0540EDF2CE8B8EA796" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiterenumerate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterEnumerate", + "name": "GdipPathIterEnumerate", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CACB8D2C92CF0A4A617FFFF102A0D3C671943E4920DAD033DFE9C898680CEA06" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathitergetcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterGetCount", + "name": "GdipPathIterGetCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C0C33658D391D26465554CEA65B8356895D7F6ACAF7E012B6D5E7CD59F84658E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathitergetsubpathcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterGetSubpathCount", + "name": "GdipPathIterGetSubpathCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1AF88D6C7E0B52695581E9484E3D665227E5A7AA7640BBCA9DB4E80C7A761FC9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiterhascurve.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterHasCurve", + "name": "GdipPathIterHasCurve", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "22683400E8FF75E59B863790C1E0852C4AE1B8870AE449D590C37AA1A349A493" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiterisvalid.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterIsValid", + "name": "GdipPathIterIsValid", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D478F53B19F7E103D6FF1108CDEACD351CE84D052BBAF758265D2AE161597A14" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiternextmarker.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterNextMarker", + "name": "GdipPathIterNextMarker", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AA03FEC393976BA970656C587E898FE098AEF0D761777B87C8A345FBD613E822" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiternextmarkerpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterNextMarkerPath", + "name": "GdipPathIterNextMarkerPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8F5DB806C8DA06ACFBDC020F04EC7C7BAB8C17F51BE9CA225C1582068EC414D2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiternextpathtype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterNextPathType", + "name": "GdipPathIterNextPathType", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CBC86DE66009AE0BE09E1488F9CFD0633829AE9A18ECB4761CEF0A35E65D3C47" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiternextsubpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterNextSubpath", + "name": "GdipPathIterNextSubpath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D1ED88292A60D7667EF582DDF7F63F2B936E690221E3F04D35A98915EB3865FF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiternextsubpathpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterNextSubpathPath", + "name": "GdipPathIterNextSubpathPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B4F98871DE05B5199EC45065C6A957919DFA7CC94FC927A4A64FCBE49FA1B484" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdippathiterrewind.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPathIterRewind", + "name": "GdipPathIterRewind", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B8F50DF88D0AF0E20291964BBB11EEFBF23D9CC2080AE49153D517DDC7B6790D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipplaymetafilerecord.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPlayMetafileRecord", + "name": "GdipPlayMetafileRecord", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9DC56F14CA8039BAA6F939E441DE9CD4C3F8E68E2F02152E9084582EA3697D1E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipprivateaddfontfile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPrivateAddFontFile", + "name": "GdipPrivateAddFontFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B5138BE28BBF2162E8D59C09567DA0391B14F75B2A9276B15888C22BE8FFD756" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipprivateaddmemoryfont.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipPrivateAddMemoryFont", + "name": "GdipPrivateAddMemoryFont", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "ABCCD65A5EC5064592BE378F3E9E5289B8F0F53E3AD6ED8BC6D49E69847A2EA9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprecordmetafile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRecordMetafile", + "name": "GdipRecordMetafile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "554DD6B3A989A5F89EC73FB0AA1A48B7D617FBEBE04028BABD4C5DB5F06938CA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprecordmetafilefilename.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRecordMetafileFileName", + "name": "GdipRecordMetafileFileName", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F45BD229DFB25FEFA28162FB30DC30D12360E0B099FD1BBA86E58D97D868E4BC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprecordmetafilefilenamei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRecordMetafileFileNameI", + "name": "GdipRecordMetafileFileNameI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "661428C87CC630885F04E1FB7BE97F464C5AD8A60D085ED3A43961C70969A7F5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprecordmetafilei.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRecordMetafileI", + "name": "GdipRecordMetafileI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0F073DFC2126C953D5675ED51749F500ADAE428C8CA5EE360A122D4375F0BC91" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprecordmetafilestream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRecordMetafileStream", + "name": "GdipRecordMetafileStream", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4A88A20AF6DE142E7EB671000B8793BD6E6666838BE218C842AF6B19594C68B0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprecordmetafilestreami.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRecordMetafileStreamI", + "name": "GdipRecordMetafileStreamI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "821EDAA9E05C103D900AEC6D74A62E93B5997A5D31839130C97DAED395AE98DD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipreleasedc.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipReleaseDC", + "name": "GdipReleaseDC", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6D82DEBEF243EA8DBDF57E69ABD2AFEC97F29C7F68543103AADCBB488F7E06F0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipremovepropertyitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRemovePropertyItem", + "name": "GdipRemovePropertyItem", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EFB81DB5E440D7F1BD59E76BCEA252E2F40D1ABD77EF64F11D1ACDE1A69CF189" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresetclip.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetClip", + "name": "GdipResetClip", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E6FF8B9F78835247F60FF6E04EE9A0EB39A0536280CA369DEF0961A5C6106A18" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresetimageattributes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetImageAttributes", + "name": "GdipResetImageAttributes", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "871CCDC59538F6151529C9BDFCDED2767E916B2676570BB5A4E7E43FDD70193B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresetlinetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetLineTransform", + "name": "GdipResetLineTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FD8485F816FFBFCAEFC8EE380AB3D4B94B94FE81524145DC98484AA0668213B3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresetpagetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetPageTransform", + "name": "GdipResetPageTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FFFD1CAE1D491ED658BB6BE2C5AD875DA0F894A82D54C0B4A207EF7F479D0215" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresetpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetPath", + "name": "GdipResetPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EA2D29CDAE78DDB9C4D1B18DC12A5A12EFB9F27C3B459F1A12B95DD3BD6DA16E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresetpathgradienttransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetPathGradientTransform", + "name": "GdipResetPathGradientTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0ED1E5025502E878F1B8A6E4D0464E1FE7C345C760C5D3C107CA0813E5DAB776" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresetpentransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetPenTransform", + "name": "GdipResetPenTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "823CF2D3DDC3B3826AD668EC1BD434391F422264A39340679E0BD3A5E6A4360C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresettexturetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetTextureTransform", + "name": "GdipResetTextureTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E9EA4101A9B0FE32A99EFACCB55AA6D0D24153DDD61C1A27B662B17C97A81DB1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipresetworldtransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipResetWorldTransform", + "name": "GdipResetWorldTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6DBA6EA99FAD9AEF1EC25219DD330066706E56F1985FA890943E32663381E942" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprestoregraphics.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRestoreGraphics", + "name": "GdipRestoreGraphics", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9F99100C7C71A40CE60F8D50EC51DEEB6124A5D5368CB33FE12BD21FC1D7ACC4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipreversepath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipReversePath", + "name": "GdipReversePath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DF213392C8FF4A82EB3701B73F7486B0FDB5A775D52BECCA13016A56DA732CC8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprotatelinetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRotateLineTransform", + "name": "GdipRotateLineTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EFB014712D6832BE4F4485C32252660FD3F3BA06EB6D89FA89020B839D42A192" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprotatematrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRotateMatrix", + "name": "GdipRotateMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1C8E474F90F1F07C0ADA8A72773FEBB0F1430F1653FD75D48654AE1DC8C64013" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprotatepathgradienttransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRotatePathGradientTransform", + "name": "GdipRotatePathGradientTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "ED9A6D98186AE9D8F91C439E0FAB288BB23D4D07CE4006AF6EB3D79AB0602D50" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprotatepentransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRotatePenTransform", + "name": "GdipRotatePenTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "61CB8438DE4A8B834E4395034BD736BB2444A4F8113C1BAB63A6678C01C46E71" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprotatetexturetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRotateTextureTransform", + "name": "GdipRotateTextureTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "59A09258EB830D9BF9936E82DA8EA333B8097ED6513B3A4F5EA762B541F7BB6C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiprotateworldtransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipRotateWorldTransform", + "name": "GdipRotateWorldTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BC6D44ACE9DDD1201B06366F55E3BF3730E4BE249E53B5CB88E8AA1CD12723EE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsaveadd.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSaveAdd", + "name": "GdipSaveAdd", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E68C840C876D4EA8665309D3BFC5433D3D05AFF641734CC0F1FB34C25599380B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsaveaddimage.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSaveAddImage", + "name": "GdipSaveAddImage", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B158FD291FB28AE6D2406D86ABFC14CFDF923C3B9F0F6601946282DF7EA470BC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsavegraphics.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSaveGraphics", + "name": "GdipSaveGraphics", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "AB5138A7384772149EB7260E4C067EDB5AB4089B445FE31F15ABB92301293FBF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsaveimagetofile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSaveImageToFile", + "name": "GdipSaveImageToFile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A4F9844CD1F1BBCB6B77165317FD7158148BD3BA575ABBFFA9FC652932E06853" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsaveimagetostream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSaveImageToStream", + "name": "GdipSaveImageToStream", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DCA477441C5B05894982C5D4A00C4A9C38BA4FF318B67A1691A04D339E63CC8A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipscalelinetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipScaleLineTransform", + "name": "GdipScaleLineTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2D24F55A36B3D5B08620B8D6CB02E9F09D5F089BEA3CC3540BCDF3E8BD4B3451" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipscalematrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipScaleMatrix", + "name": "GdipScaleMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "23172C9BC3B5E5116F1ADDFF655007ED1DF4BD05D616EF2DADE9919299A01D63" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipscalepathgradienttransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipScalePathGradientTransform", + "name": "GdipScalePathGradientTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8B4B15702524F3241A8C6CB2A23C6DA37A494E26656550FAA00BBB4B8756B11D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipscalepentransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipScalePenTransform", + "name": "GdipScalePenTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "36C93176A02F5D5092556229812489720D9DA3DDAEE0BEED27CD33F87E221936" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipscaletexturetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipScaleTextureTransform", + "name": "GdipScaleTextureTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "95B757BA302B9C0485E6B37F770AAABEE124D8021C07E9C13AC5B2D1A1A83403" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipscaleworldtransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipScaleWorldTransform", + "name": "GdipScaleWorldTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BC007764EB906D5F17432C226B07DA7EB677661728841EF953A151633C05765B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetadjustablearrowcapfillstate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetAdjustableArrowCapFillState", + "name": "GdipSetAdjustableArrowCapFillState", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A9E066464F0E4D258D3C6803D37D7BC2B9B260A6DBDEF38068B4906B03089653" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetadjustablearrowcapheight.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetAdjustableArrowCapHeight", + "name": "GdipSetAdjustableArrowCapHeight", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1FCF79DA39184066EDE2C63F09B67890E9151253F354F15C744BE161BA4DDF46" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetadjustablearrowcapmiddleinset.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetAdjustableArrowCapMiddleInset", + "name": "GdipSetAdjustableArrowCapMiddleInset", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "930093494A89A766474ADDE4825C2DD2B937A8E448DE9F9F4C1F10914E2050DE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetadjustablearrowcapwidth.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetAdjustableArrowCapWidth", + "name": "GdipSetAdjustableArrowCapWidth", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "723E1296462A3C6EE9F000CB43D4A5757E81453A721F557CF90462F59C5AC259" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetclipgraphics.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetClipGraphics", + "name": "GdipSetClipGraphics", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9EDB466333B302C4A1E819621B61D7C5E1B929A8B00BFE4EFA52F67D8F3AE178" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcliphrgn.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetClipHrgn", + "name": "GdipSetClipHrgn", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4C67656ED3AFFD423104C228C28876D68BDE62B818BB5E1F04BC1C3146DBA6EB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetclippath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetClipPath", + "name": "GdipSetClipPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A58A079581A95FEFEBA6F7D6CE1F4B9C1FD48F4A39DE305ED0C71028769FEBB1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcliprect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetClipRect", + "name": "GdipSetClipRect", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F4EE7122F2D69C11E07AD8EDC9FB7B6BFAA5355D3727ED2DEAC26031608E1DC8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcliprecti.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetClipRectI", + "name": "GdipSetClipRectI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "013EDADB133C1022C55180BE4DA43F3FDE2513C64325D5F43AAE0D91C471CE79" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetclipregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetClipRegion", + "name": "GdipSetClipRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3AD9999C93E87BBB958221709CAA4DA24CC7E313FDD145AC3CB977E3B19BCB3B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcompositingmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetCompositingMode", + "name": "GdipSetCompositingMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8FBF949C5F95BBC2811C9138993106AF0E3304903370508E3789D0F1DDF9139F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcompositingquality.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetCompositingQuality", + "name": "GdipSetCompositingQuality", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3A6EAD37E3B62D386B366D4E7C4C9593F1B68DC5F6C98A504AF7EF42AC8503D0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcustomlinecapbasecap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetCustomLineCapBaseCap", + "name": "GdipSetCustomLineCapBaseCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2111847C881FC8748B23B01E0FB1B91221AF58C9BBAAFEEEAE529D7B3693574B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcustomlinecapbaseinset.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetCustomLineCapBaseInset", + "name": "GdipSetCustomLineCapBaseInset", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EA058D5DC49E63C874A88EFE0EE288A8E422CAF11B48C87202C6D87404E001DE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcustomlinecapstrokecaps.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetCustomLineCapStrokeCaps", + "name": "GdipSetCustomLineCapStrokeCaps", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DD1F1A6EE4BA79EAEE7094C1A31174D98597D09918762F01DD2D6FD4AC87A63A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcustomlinecapstrokejoin.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetCustomLineCapStrokeJoin", + "name": "GdipSetCustomLineCapStrokeJoin", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0132A86DDBF563E72B77B9EEF94347E3CBC99000E27AAACEFC1F30D23BEEC206" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetcustomlinecapwidthscale.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetCustomLineCapWidthScale", + "name": "GdipSetCustomLineCapWidthScale", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C916151305E764DEDC1B7DF789E31F9A9448BB2971EE3A54ADD097DAE88EDA9E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipseteffectparameters.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetEffectParameters", + "name": "GdipSetEffectParameters", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "776053939060BDCD38C4CA768F63BFAC5172E1550E59167EAA05D68EC52E4606" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetempty.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetEmpty", + "name": "GdipSetEmpty", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "29628BE3F9C9DD31A2BA71D86C3BA371532BE7371D6A9E5FDB83C8E1096ADF9C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributescachedbackground.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesCachedBackground", + "name": "GdipSetImageAttributesCachedBackground", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C433DD1C70D5766FE3A7542F2D8A3FA9074E9E800142D09A37890D9331B84363" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributescolorkeys.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesColorKeys", + "name": "GdipSetImageAttributesColorKeys", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C97CE6FC90CB9A52769492BFBD369AC6D6B46C4A62EE896F1B6AB0837F038C38" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributescolormatrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesColorMatrix", + "name": "GdipSetImageAttributesColorMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4C166095A53A3304915E350E21C88AEB83324169B93EC895478FADB6DC05B660" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributesgamma.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesGamma", + "name": "GdipSetImageAttributesGamma", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7D5E2C88064A100872113A43A54DE354FA79E14002F583C5F9D392F9DB63AAEA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributesnoop.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesNoOp", + "name": "GdipSetImageAttributesNoOp", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CFAF211437431546E9F8A86FB4A3ADFC1450800A9E0FD552069AAAAE783E5E2A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributesoutputchannel.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesOutputChannel", + "name": "GdipSetImageAttributesOutputChannel", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6556ED8750BB97F4FE82348A5BE13EA0345E2601DCF10E70A23097C8C120E83C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributesoutputchannelcolorprofile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesOutputChannelColorProfile", + "name": "GdipSetImageAttributesOutputChannelColorProfile", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CAF1433A443F9F669E8EB488470E533A21B9C00517E3E224087015A45C325A37" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributesremaptable.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesRemapTable", + "name": "GdipSetImageAttributesRemapTable", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BE77E88A150B0C0D487FCBD4B004C70932C41D308025BEC3EA02018612EC9C6C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributesthreshold.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesThreshold", + "name": "GdipSetImageAttributesThreshold", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "676DCCFD64A17EB0F71A46AE0D01B5E3F735CECC8F62985237B14D62B1459B6D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributestoidentity.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesToIdentity", + "name": "GdipSetImageAttributesToIdentity", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8F0F7CB2494EAD3041FADE3BE44D5471D2870BC0F6AF87AE738CC497228D7F98" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimageattributeswrapmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImageAttributesWrapMode", + "name": "GdipSetImageAttributesWrapMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8E45B1F47E1CD7D0495132086D9AAB85FA929A93006F3586D569CF2402FC429A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetimagepalette.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetImagePalette", + "name": "GdipSetImagePalette", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "94C0A1C038DCE4D2E33BA29C6696D82EDC85566807F0925250B8870F00E081EF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetinfinite.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetInfinite", + "name": "GdipSetInfinite", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E6AF5B16EE57976EFD20A53B2E4E19B7244C9FBFD803878F2B1B717FC6373ACC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetinterpolationmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetInterpolationMode", + "name": "GdipSetInterpolationMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A56E2342E56B72913DE3965E5A6E228497B0C1157402080FC9A40FE2C57301B9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetlineblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetLineBlend", + "name": "GdipSetLineBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8C2FEA3DECE529957745798516AC4D4E877709C27C357A5C37ACED3FA2653AD3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetlinecolors.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetLineColors", + "name": "GdipSetLineColors", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3FAFFE4201811BFF79B7E4171D530C5DE3D9B09BB80EA8852E6AC50327FE215C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetlinegammacorrection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetLineGammaCorrection", + "name": "GdipSetLineGammaCorrection", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E76E79DB8854EE754A2672595B0D76FF6B766E397EEB61FC5740D04C20897DDA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetlinelinearblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetLineLinearBlend", + "name": "GdipSetLineLinearBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "453F9D3E7266DB0C5C31FAB02D1F9EB3E707BEBD419420F6C56A88BA042EB147" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetlinepresetblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetLinePresetBlend", + "name": "GdipSetLinePresetBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "29530156917A79EE22AF00A3FAE1475DB47C18B11EEEE1C6B577B3A0EBE6BC17" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetlinesigmablend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetLineSigmaBlend", + "name": "GdipSetLineSigmaBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8616B061C22C648C35853958C11E2CD12BEF0D6E9FCFE6BD007CD39328642DFE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetlinetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetLineTransform", + "name": "GdipSetLineTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "454CC1D76F4F115A7215320C49EAF3B4F6A2DE56975A69D8FE9E62D34688FDF9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetlinewrapmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetLineWrapMode", + "name": "GdipSetLineWrapMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D90A3B521318BE513F9432269DA1E6EE237373DF4499189A2303C9146DF06B56" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetmatrixelements.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetMatrixElements", + "name": "GdipSetMatrixElements", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8447D23C194FA337B344A0333D044D44DCDF88DFC43CA89BEDEEAE32DD09DC0B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetmetafiledownlevelrasterizationlimit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetMetafileDownLevelRasterizationLimit", + "name": "GdipSetMetafileDownLevelRasterizationLimit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "3A89DB759AE243B44DB5CA8F10864B3C3B696BD4175CFFD58182E3B74DAB27DD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpagescale.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPageScale", + "name": "GdipSetPageScale", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "93DC99BF436A602B07B60DBC4678941985AD4F65FE0D53D546CC4F6A91671FDF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpageunit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPageUnit", + "name": "GdipSetPageUnit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E10C401D028AF32B14EB7F78026CAE6D77A7AC6FA2C4645EF007AA88CAD93771" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathfillmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathFillMode", + "name": "GdipSetPathFillMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4252F9A350F1B77E6558B5CAEF0B43D9D2C6F7D84B01EC621122EE2A7C91FD33" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientBlend", + "name": "GdipSetPathGradientBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "ABBE7642847ABC6697F6D1589FBDF3F32F81D04E0ADB2ADFF1F583F839D196F7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientcentercolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientCenterColor", + "name": "GdipSetPathGradientCenterColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1537D1977772B565F727E434356AA6D79021D61C4CF970002C9344DC05F42BC1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientcenterpoint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientCenterPoint", + "name": "GdipSetPathGradientCenterPoint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F5039AF00E27403233066BC57E56BC3D16D8100202F347E88905B40984934536" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientcenterpointi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientCenterPointI", + "name": "GdipSetPathGradientCenterPointI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "BD9EA207DDF228A424F6BA8BC8B8FC335F2258448D9DCC31FC6D427CC05FC2A2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientfocusscales.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientFocusScales", + "name": "GdipSetPathGradientFocusScales", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D4FBE4C82FADACB02353BB3924ABB570231E8CB790FBB8D5A968F32F12C250D4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientgammacorrection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientGammaCorrection", + "name": "GdipSetPathGradientGammaCorrection", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F9514A45D3F5E2286EFC88336C34EF2ADE40020D679EA58750E45E9981EC579E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientlinearblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientLinearBlend", + "name": "GdipSetPathGradientLinearBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E8C1ECBBF1853A208E6D57F4061ED4B666967988580CE530F4AF8005E0CDC34D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientPath", + "name": "GdipSetPathGradientPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CE75762A306C68D46BA28E8F726788E39A60E51295BF3E6225E3594375472A61" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientpresetblend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientPresetBlend", + "name": "GdipSetPathGradientPresetBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1234F9B358E06009E1C37BC93119FCD42A0B154433613EB194157635D136A3C3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientsigmablend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientSigmaBlend", + "name": "GdipSetPathGradientSigmaBlend", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1998C0C5D4A23B8BF469F8DB2F24FCA26C703797AE0F596206D206F2CAD7AAB7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientsurroundcolorswithcount.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientSurroundColorsWithCount", + "name": "GdipSetPathGradientSurroundColorsWithCount", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "569B41AB4863780E96049D6772561018BA6BB2655F1F20FDB425A3C0E5A25BD3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradienttransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientTransform", + "name": "GdipSetPathGradientTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C1275C01F518BDE8772B9488CD1FF1DF8C70E8C56E19929434410E2015E10CAC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathgradientwrapmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathGradientWrapMode", + "name": "GdipSetPathGradientWrapMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "68D990210D634F67B0864353897851B6529E62C477A93BEF3B66781CC446B0FD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpathmarker.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPathMarker", + "name": "GdipSetPathMarker", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A237A1992F3C40393B2A6832BCF70C2D7A35B29477C42EAC0CB97F8BE0B1F7DB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenbrushfill.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenBrushFill", + "name": "GdipSetPenBrushFill", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "93CCFE2BDAA2C4BE1EF808C6D29E6102270616E62184AF4F0FCF79125D9F3836" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpencolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenColor", + "name": "GdipSetPenColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "01289D46B503C6F04680F56F4F0195F5D8862FAC423FC2184781FA3E09055C64" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpencompoundarray.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenCompoundArray", + "name": "GdipSetPenCompoundArray", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5578518F0C1EA5A028C6111D7A95F7E4D93153B1821A5CCA5EFBF6534217CEEC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpencustomendcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenCustomEndCap", + "name": "GdipSetPenCustomEndCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B2BD9B39E067F9AD0A445C1A877D1C9315C9F6DA377A095EC2226416560CAA4F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpencustomstartcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenCustomStartCap", + "name": "GdipSetPenCustomStartCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "DC38F1237A54A1178C51E1DB0B42CE6965F4043FB39DFE899AB91621B86AD228" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpendasharray.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenDashArray", + "name": "GdipSetPenDashArray", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4FA94D53358CA2B6BA563B85D33C058B38458CAA3719AB2D4B4581D619CEC131" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpendashcap197819.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenDashCap197819", + "name": "GdipSetPenDashCap197819", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1F20626CD616C3E7AE23330EA6AA4FB60480F52A25B27ECE2BCCF60703F277FE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpendashoffset.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenDashOffset", + "name": "GdipSetPenDashOffset", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0D0547D057DA8C92B83D4CC999EB773506B6C1123E6D01C5A88E15091A36B189" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpendashstyle.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenDashStyle", + "name": "GdipSetPenDashStyle", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "98C2D170096151F4A07FFB8C2FEC0AB5B284591F45064D148839C45866D97245" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenendcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenEndCap", + "name": "GdipSetPenEndCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "071454E14343AA5284523F23B95BCC59E205E3D342D6DED63E029B2DC4B89FA9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenlinecap197819.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenLineCap197819", + "name": "GdipSetPenLineCap197819", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "82EB30FB50E422AA1974ABA561EE81AA4ECBA7A1604131E05812E78D8B9D4FB2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenlinejoin.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenLineJoin", + "name": "GdipSetPenLineJoin", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "958B413B49DB299F430747B87C641A8A7203889FB2A5671FAC8D5E439BC0E24C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenmiterlimit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenMiterLimit", + "name": "GdipSetPenMiterLimit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "5CFC19B2412C628BC75ACA9AB32E026FBF2278A3E3E71CE8D48DDFACEBC3FB66" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenMode", + "name": "GdipSetPenMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2C0A1A90D02D5C04E15A6CC5E7AAAEB142C672201EC8798E01D39218C5A12661" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenstartcap.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenStartCap", + "name": "GdipSetPenStartCap", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "C6295E323220E8472D77FE43B96C20835EB67EBF889628004F91D67A0003B068" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpentransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenTransform", + "name": "GdipSetPenTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F11748711E9AB1EE3E23F6A48A46A0284325750CE3630118B42825F9A90B935E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenunit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenUnit", + "name": "GdipSetPenUnit", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9CB99758C555C568FFC7C33DF205AA12E8618C3E320F53D4AB3A07D7769D317F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpenwidth.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPenWidth", + "name": "GdipSetPenWidth", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2BEB2113C492599FE44810CAAF6BFB4FADABF24168B9800FF9BF7F7488EB4591" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpixeloffsetmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPixelOffsetMode", + "name": "GdipSetPixelOffsetMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "1C692BF8A26DB1D96377C34285F2C6E5E5118BDCE1DF03A9900415729C2D5FED" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetpropertyitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetPropertyItem", + "name": "GdipSetPropertyItem", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A8C28F4EE7EB7669C8B5A629FB5EA87C9A3E0E4686808D43F8016A6BE8308A84" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetrenderingorigin.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetRenderingOrigin", + "name": "GdipSetRenderingOrigin", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "172F09AA576BBDD43246CD54F78CED6AEB39A804681E508F982C4997B48F2BE5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetsmoothingmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetSmoothingMode", + "name": "GdipSetSmoothingMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "55A76F23FF6D01BB1E78168C1B5D6C577194F34A68107B68DCC706D659D5932B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetsolidfillcolor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetSolidFillColor", + "name": "GdipSetSolidFillColor", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "69F0B92C605575794593B8CA8956160A61C567A5F51EC3F53C56BB432CC48311" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetstringformatalign.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetStringFormatAlign", + "name": "GdipSetStringFormatAlign", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "6FA9AB8617392BA38148227FC520163F9EC68F0B53E81CC08C734719E4A89F43" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetstringformatdigitsubstitution.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetStringFormatDigitSubstitution", + "name": "GdipSetStringFormatDigitSubstitution", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "FB2200D3DD381208FEEBDD314005C705B2892718194AFC6F6993C3EEE37C81AC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetstringformatflags.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetStringFormatFlags", + "name": "GdipSetStringFormatFlags", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "4EE93D3CA1BF78C5E3E63A03AE6F24C4ECC1E196B5DBD0028ED7019C523E8991" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetstringformathotkeyprefix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetStringFormatHotkeyPrefix", + "name": "GdipSetStringFormatHotkeyPrefix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "921C0E693CD655213A70EDB6317D953A71B28B4AF7B3BCE63ACD294B99D78097" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetstringformatlinealign.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetStringFormatLineAlign", + "name": "GdipSetStringFormatLineAlign", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "249E01E74DD0A48FE4EAB46A1F25E679D052779751CFA9EA888489D29C71D497" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetstringformatmeasurablecharacterranges.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetStringFormatMeasurableCharacterRanges", + "name": "GdipSetStringFormatMeasurableCharacterRanges", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8FB460F4D32C70BF8FB5C0C7E9C223A4EA7098B9AB3E6B58173591B9E735978F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetstringformattabstops.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetStringFormatTabStops", + "name": "GdipSetStringFormatTabStops", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "941F27F9668724BC335287D08FEEE3CD422CAE4653C997262B695B8A44DCB581" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetstringformattrimming.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetStringFormatTrimming", + "name": "GdipSetStringFormatTrimming", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E88E56B0F5391C3F4A91EDC105F4CE77ABBCFA6E2DEF483C5E394C61ED71C548" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsettextcontrast.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetTextContrast", + "name": "GdipSetTextContrast", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "2A5F1A623FD9507CC0520DA087D74404CC382F6D08299A306CA0C9388C550099" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsettextrenderinghint.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetTextRenderingHint", + "name": "GdipSetTextRenderingHint", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B964461EAE42143D302B6105A0B8D2786FAA1254B0455DB3DDCBD307CC60300D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsettexturetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetTextureTransform", + "name": "GdipSetTextureTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E2D7DCB0CD8B19B6C65C7309B4E6BF7ED1C0E21C9AEC20F987AD450207753881" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsettexturewrapmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetTextureWrapMode", + "name": "GdipSetTextureWrapMode", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "751436F049B22BE67AEC307C2FCA477E4E33BCA4412E0C2FD6DA7ECF5BE0109B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipsetworldtransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipSetWorldTransform", + "name": "GdipSetWorldTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0C71F2D9B6BD9F3C14E84F10A905CEF775CC6B3305BFAB3BC37F7963C5651ADE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipshearmatrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipShearMatrix", + "name": "GdipShearMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "E12EF21C6910191B63A33C17597111C2FC2E4F216D4BE35B13952DD180027274" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipstartpathfigure.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipStartPathFigure", + "name": "GdipStartPathFigure", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "002CE87183C57DDBE470939BFFAAA656E9F7303C19DAAF07DAA2731713E0D6B1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipstringformatgetgenericdefault.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipStringFormatGetGenericDefault", + "name": "GdipStringFormatGetGenericDefault", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "71F89C2051B775A20EDED7220D5EC46537B2252B1F266B76E53AC15FE9A18E43" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipstringformatgetgenerictypographic.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipStringFormatGetGenericTypographic", + "name": "GdipStringFormatGetGenericTypographic", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "563DF45DED13165D753F2AA1C3C2DD2ADF9DE4E0CC4FE32C3A4788FD3A2BB98B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptestcontrol.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTestControl", + "name": "GdipTestControl", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "76FC3383D68B16755F2BAC46F0C6332929A78BF88C38CC65A1D000C3E7BB4357" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptransformmatrixpoints.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTransformMatrixPoints", + "name": "GdipTransformMatrixPoints", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "80E3780E0136A872F50E564520A0F66E326F881387D5B382DFA469339897E66B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptransformmatrixpointsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTransformMatrixPointsI", + "name": "GdipTransformMatrixPointsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "23F893EA60A4D69C38173EC6CF3CD7A35AFCA30B5DA14B39EF6E66D139A31380" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptransformpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTransformPath", + "name": "GdipTransformPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7F74F8E751BF685338B5378502954558C1557C5CC11315BE2FFA228E3C52844E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptransformpoints.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTransformPoints", + "name": "GdipTransformPoints", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "EB1E6B5E42618B2A68EB8A3F469E8304112204E08A3163AFE75BC80BB03FD13F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptransformpointsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTransformPointsI", + "name": "GdipTransformPointsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "CF45F4B570D2327E8EB4C92328FEF3ED52FA71AC7CE085FB90733AA535374EBA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptransformregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTransformRegion", + "name": "GdipTransformRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F583E6BD5B7B7D14CD0811351A06EAB658687C7EBCC8C22F477FED5AB25D027C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslateclip.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslateClip", + "name": "GdipTranslateClip", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "A28B5F1E9D7F4AFEE93EBBE9B66C83A588DAA34150B38D3C26402E791E2874D4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslateclipi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslateClipI", + "name": "GdipTranslateClipI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "24D10737AD60B7110929586E27427E8555B3E522717EE2A311E1D70A47EFDFF2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslatelinetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslateLineTransform", + "name": "GdipTranslateLineTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F9B9E513855BFBDF9FB827A723579254EE7E32A2BC2B63DAE4A3165D9DDB4E2B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslatematrix.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslateMatrix", + "name": "GdipTranslateMatrix", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "33732C6098CBF21739AA64E6919BBBBCE46FC2BFEA545EE209EA9497177A8BB7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslatepathgradienttransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslatePathGradientTransform", + "name": "GdipTranslatePathGradientTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "7FAFED561CB44FCCE0CC92818144C5A177EE6004A82FE602CB94710CB297AD29" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslatepentransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslatePenTransform", + "name": "GdipTranslatePenTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "B031640905D8C19654CEE3EA6FFE7B9D4FA86C702CCEADEC56FBC5BC5AB6A86A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslateregion.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslateRegion", + "name": "GdipTranslateRegion", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "F04DDA2EEE1ED1B40C1FBD4804B49A7482DDA296E25DD05C592BFF02580CBD74" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslateregioni.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslateRegionI", + "name": "GdipTranslateRegionI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "D7EDD7DDE293C4C32FCB4850BA8BB1B07B3B0F5D5CB13C2567EB9CA20996259A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslatetexturetransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslateTextureTransform", + "name": "GdipTranslateTextureTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "308E462297D6F24F42C3786CC1FE0F0CD040818914C4B66DE8AF45572041C54B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdiptranslateworldtransform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipTranslateWorldTransform", + "name": "GdipTranslateWorldTransform", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "8CAAAE04B01393FDB185E2E34059D9E0FAC542A627D054917A50696C7683EFC6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipvectortransformmatrixpoints.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipVectorTransformMatrixPoints", + "name": "GdipVectorTransformMatrixPoints", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "9945A58106280E20CF226D6E12980DBB1C975E258E9300F305DB0FA85FD0C1D3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipvectortransformmatrixpointsi.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipVectorTransformMatrixPointsI", + "name": "GdipVectorTransformMatrixPointsI", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "761EE54A3FB317164C430A8357A2995A159D65C0F9F6A0CD75907787CF138DFE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipwarppath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipWarpPath", + "name": "GdipWarpPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "73F1D9BBC8D8A4AC2FEA85B2CE501F8E340743D5914CC52B697FF603C512A824" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipwidenpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipWidenPath", + "name": "GdipWidenPath", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "0DD90516D50234AA9FE3431F16668F5A5BD077E70383DFABF8333E29A3F2233E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.graphics.gdiplus.apis.gdipwindingmodeoutline.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "gdiplus.dll", + "entryPoint": "GdipWindingModeOutline", + "name": "GdipWindingModeOutline", + "namespace": "Windows.Win32.Graphics.GdiPlus", + "sourceFingerprint": "57DDA06FE493A94229142B17D2C976F8D092BC864DE4F69C13E5BCDC4E1D919C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "gdi-plus" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.createnamedpropertystore.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "CreateNamedPropertyStore", + "name": "CreateNamedPropertyStore", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "9A8DAF663193F6DED28A3C201ABA106456676C6565728506349202222857299A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-createnamedpropertystore" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.createpropertystore.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "CreatePropertyStore", + "name": "CreatePropertyStore", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "B9BC855202B383138E6A8BDC916F7BB5ACEBD7666CEEA169DF06AA813FCBDCD9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-createpropertystore" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.dxva2createdirect3ddevicemanager9.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "dxva2.dll", + "entryPoint": "DXVA2CreateDirect3DDeviceManager9", + "name": "DXVA2CreateDirect3DDeviceManager9", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "82EB44B3A2FA4A4C0D1D651B10C64DA5195487E94002298DD4775BAD96D358B0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/dxva2api/nf-dxva2api-dxva2createdirect3ddevicemanager9" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.dxva2createvideoservice.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "dxva2.dll", + "entryPoint": "DXVA2CreateVideoService", + "name": "DXVA2CreateVideoService", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "22163B86EC51B2D301B728DA682D6E2B2BC7203AA1494DE14CBD3A1B6ABC9C7F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/dxva2api/nf-dxva2api-dxva2createvideoservice" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.dxvahd_createdevice.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "dxva2.dll", + "entryPoint": "DXVAHD_CreateDevice", + "name": "DXVAHD_CreateDevice", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "49C0FE912FC9D9FFD39D5F72DF6AE3C8B5489AC3C609EC3659ABF58E62A98D67" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/dxvahd/nf-dxvahd-dxvahd_createdevice" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfaddperiodiccallback.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFAddPeriodicCallback", + "name": "MFAddPeriodicCallback", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "26CD081198E708C6361C39B46D25E6C49838E10047DF5D5D3096625F2C5A8F3C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfaddperiodiccallback" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfallocateserialworkqueue.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFAllocateSerialWorkQueue", + "name": "MFAllocateSerialWorkQueue", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "B31F02550E07F3E5D5451414B60642A201EE0EF766C890C444C16BFF8A5B24D3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfallocateserialworkqueue" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfallocateworkqueue.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFAllocateWorkQueue", + "name": "MFAllocateWorkQueue", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "44001ABF1A299349F246918E9E654A20D2A857595D4622A9224EB6CF1F894A89" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfallocateworkqueue" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfallocateworkqueueex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFAllocateWorkQueueEx", + "name": "MFAllocateWorkQueueEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "202A24090912CFE86BB818598BAF51C65184237FFD97D8D70BD7864248246775" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfallocateworkqueueex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfaveragetimeperframetoframerate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFAverageTimePerFrameToFrameRate", + "name": "MFAverageTimePerFrameToFrameRate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "6AC33CA718C4C7DEEDEF30763E8146E679FA0DCA0E6A53A9B8B2324899C73DD0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfaveragetimeperframetoframerate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfbegincreatefile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFBeginCreateFile", + "name": "MFBeginCreateFile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "64C929AA34218215C266F20CF1EA0AC40A99681D3BE7FBC39E9FD40E4A31F6D5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfbegincreatefile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfbeginregisterworkqueuewithmmcss.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFBeginRegisterWorkQueueWithMMCSS", + "name": "MFBeginRegisterWorkQueueWithMMCSS", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "BE4BCBBD4EF145AD90F60406D5991D53A854A124E7AE2E8C34E42921686FD47C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfbeginregisterworkqueuewithmmcss" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfbeginregisterworkqueuewithmmcssex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFBeginRegisterWorkQueueWithMMCSSEx", + "name": "MFBeginRegisterWorkQueueWithMMCSSEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "9F386DF0EFD7D8FDFB2875F4E401864E02B29E588D289053456886CA29E19210" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfbeginregisterworkqueuewithmmcssex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfbeginunregisterworkqueuewithmmcss.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFBeginUnregisterWorkQueueWithMMCSS", + "name": "MFBeginUnregisterWorkQueueWithMMCSS", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "11240BD30C702DB055BE988F3D2DBCE53FC58AF6D6B6019CB7C20B29EC43CA08" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfbeginunregisterworkqueuewithmmcss" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcalculatebitmapimagesize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCalculateBitmapImageSize", + "name": "MFCalculateBitmapImageSize", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3330DB8452F284DE61155C21229AC7650F14EF0214896DADDF6F68A35BD2020E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcalculatebitmapimagesize" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcalculateimagesize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCalculateImageSize", + "name": "MFCalculateImageSize", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "87DED09D9D5E404C5503E64BAFC0D422BD79219DF577957C93F2F468CB867F74" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcalculateimagesize" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcancelcreatefile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCancelCreateFile", + "name": "MFCancelCreateFile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A223A824D674966755036D09A63E54B622A7F52EF1674261321AE4EE13015A43" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcancelcreatefile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcancelworkitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCancelWorkItem", + "name": "MFCancelWorkItem", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2F8A2D2445885E608D668D36FDF7497E0F31520615A38EB7B38DDCEA0F4DC766" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcancelworkitem" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcombinesamples.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCombineSamples", + "name": "MFCombineSamples", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4AF4057C909B5CEA8F9671C5AFBFAC912500742A1E0C83F768ABA83683FB8911" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcombinesamples" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcomparefulltopartialmediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCompareFullToPartialMediaType", + "name": "MFCompareFullToPartialMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5A10BD1BDE25E970A6FD261E60503F497E22E6FC6F5D8C3487EECCD7FEC01C22" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcomparefulltopartialmediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfconvertcolorinfofromdxva.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFConvertColorInfoFromDXVA", + "name": "MFConvertColorInfoFromDXVA", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "39D4FA69BF7240A42927DF5FCA508386403F4A302FF6079FC415F59B8E60D38C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfconvertcolorinfofromdxva" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfconvertcolorinfotodxva.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFConvertColorInfoToDXVA", + "name": "MFConvertColorInfoToDXVA", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "592853066533D50B97A54CAB47D2C6988F31CCE854CD07D980761E683F891D5E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfconvertcolorinfotodxva" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfconvertfromfp16array.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFConvertFromFP16Array", + "name": "MFConvertFromFP16Array", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "89DC58B3C8039D4C4709F674C364CFF33843D9870C9BBA265618FE6C8A3E6EC9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfconvertfromfp16array" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfconverttofp16array.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFConvertToFP16Array", + "name": "MFConvertToFP16Array", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "9A3414C052E8A810F61E2AA8C411A7A38E2EB3A24BE402E935A43D548B2319B5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfconverttofp16array" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcopyimage.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCopyImage", + "name": "MFCopyImage", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "EDB027EA10AF4A4D23CA837A26439FF49BFCE1D6E358A3A776F193F0471C62F2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcopyimage" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreate2dmediabuffer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreate2DMediaBuffer", + "name": "MFCreate2DMediaBuffer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2977138177F5D3389332B1E74484F1DCB10E1F9D32DFB1C30E2ABAB5E981E0B4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreate2dmediabuffer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreate3gpmediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreate3GPMediaSink", + "name": "MFCreate3GPMediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "AF7D2451FF9E40BE3C65B89A84BDDB8B4CCE702132A2C91115D3CCAC5F1201E8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreate3gpmediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateac3mediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateAC3MediaSink", + "name": "MFCreateAC3MediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3C608A593EAEB9B74C0578D41BE030DA725B5AD20F55B9BEE87377F80BFC07F3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateac3mediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateadtsmediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateADTSMediaSink", + "name": "MFCreateADTSMediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "31F619048E716CD5F7ADDF0B86CBECB227840E7D17F24A51696CD5415F472C87" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateadtsmediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateaggregatesource.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateAggregateSource", + "name": "MFCreateAggregateSource", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "EA454FE296448E6855DD0EC89FDA7402DD834C5E220506F0CCFA72202D4F3D3C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateaggregatesource" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatealignedmemorybuffer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateAlignedMemoryBuffer", + "name": "MFCreateAlignedMemoryBuffer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "565E1A9E5C8DDAA25959F9132C7CC510D2C004191B284625E30625FE39CF7512" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatealignedmemorybuffer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateammediatypefrommfmediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateAMMediaTypeFromMFMediaType", + "name": "MFCreateAMMediaTypeFromMFMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "BAF8D31664B6087D9784AEC1D6F8366C818DB826D969D92C4106DD79193CC252" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreateammediatypefrommfmediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfcontentinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFContentInfo", + "name": "MFCreateASFContentInfo", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "BFA61DB54DE8F29E0021F1AA78D54107BDC25BA1B4254C8820A0B7B0081A6E70" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfcontentinfo" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfindexer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFIndexer", + "name": "MFCreateASFIndexer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "E2F1D376AFFF6AEE4568E4E02BBA49BB02445AEEEC15A5349FC3F18E866904C9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfindexer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfindexerbytestream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFIndexerByteStream", + "name": "MFCreateASFIndexerByteStream", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8B660BBE0423F2DF056BB1B04DF60B157DE4BC15991C3326E9E3F1DA038FDAC6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfindexerbytestream" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfmediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFMediaSink", + "name": "MFCreateASFMediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "9CEE60895AE099A732E087625F7272E81D92D44EBAF78F756F629DD24DDAFBD5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfmediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfmediasinkactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFMediaSinkActivate", + "name": "MFCreateASFMediaSinkActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "C0F82B53BD2A9F04D405D553E7D22A49C2429D2073575ED77F60D00EC04C979B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfmediasinkactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfmultiplexer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFMultiplexer", + "name": "MFCreateASFMultiplexer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8DD73F13BC83B674CE8613E1E160AE967DB9AAEFA1891A3341FE72F612DD6573" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfmultiplexer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfprofile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFProfile", + "name": "MFCreateASFProfile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2A24265A9A899AB5AFA2B70EB63AAC3167A5528ED12017F4C7A18DCEF06C53B8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfprofile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfprofilefrompresentationdescriptor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFProfileFromPresentationDescriptor", + "name": "MFCreateASFProfileFromPresentationDescriptor", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "937AA13FC2C83A22BDB9F094BFB860A65AA288B42E9A779D4A1003A44BE95164" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfprofilefrompresentationdescriptor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfsplitter.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFSplitter", + "name": "MFCreateASFSplitter", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "29C18812A0F9394E6060570C756CBDD5E4493D02F49E3D787DBFC4335E745CD8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfsplitter" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfstreamingmediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFStreamingMediaSink", + "name": "MFCreateASFStreamingMediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F204B6DE0E68AE2260BFA29A0960DE16227B146438B09C260C8CE4C4F9E31243" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfstreamingmediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfstreamingmediasinkactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFStreamingMediaSinkActivate", + "name": "MFCreateASFStreamingMediaSinkActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "255F54B1D17DF59DB600E67C91E37AFDB2D7B98994BCC8436DA793A73E44B23E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfstreamingmediasinkactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasfstreamselector.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateASFStreamSelector", + "name": "MFCreateASFStreamSelector", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "70E0F5930DFA2601F3CDCB573FE876A01D7C330673F012F34214CE1E210264CA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreateasfstreamselector" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateasyncresult.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateAsyncResult", + "name": "MFCreateAsyncResult", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3F78517E696B7D9E6014502420FA295D9EFFA9049084A98E0B4504CB7FAC5391" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreateasyncresult" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateattributes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateAttributes", + "name": "MFCreateAttributes", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "47E37269442F08E5377B6F04DF857CC3B5529E7438434F4BCB150F2AC1361553" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreateattributes" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateaudiomediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateAudioMediaType", + "name": "MFCreateAudioMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "418798D4A55E14E0BD8E6C89EEBC5A458E48665AE7DF90F2C4B15BF0B213055D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreateaudiomediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateaudiorenderer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateAudioRenderer", + "name": "MFCreateAudioRenderer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4AE40C05640C9A2711D9882729333C17C82F8B4D631A2D749C0658940A765AA7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateaudiorenderer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateaudiorendereractivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateAudioRendererActivate", + "name": "MFCreateAudioRendererActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5A0A6379FE1CD3822FE1E3CAD93409808C14AEEA38824AB440F05CB9A6F81D8C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateaudiorendereractivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateavimediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "mfsrcsnk.dll", + "entryPoint": "MFCreateAVIMediaSink", + "name": "MFCreateAVIMediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4147049BF01234B90A5124273A1A1774E80B2E2E2CB0DBC18932B3C41C4A35E7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateavimediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatecameracontrolmonitor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateCameraControlMonitor", + "name": "MFCreateCameraControlMonitor", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "92EC99299303D59709FA6AD2C41B4FD1622F3A87472DAEE94439A038B5C7FF2E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatecameracontrolmonitor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatecameraocclusionstatemonitor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateCameraOcclusionStateMonitor", + "name": "MFCreateCameraOcclusionStateMonitor", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "B6AFC4963983C5D3728399B096E3E797563EBE0E19FB407DA43F73A1381E9FA3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatecameraocclusionstatemonitor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatecollection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateCollection", + "name": "MFCreateCollection", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "9A31A5C0CB021DF0FD79CF154AEC77B46888F650266B0904269D83C0E693B458" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatecollection" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatecontentdecryptorcontext.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateContentDecryptorContext", + "name": "MFCreateContentDecryptorContext", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F6702C68CD7F42BA08339E33D63F21DB1BBDA20BCBC1448592E3456F2EB47FAA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatecontentdecryptorcontext" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatecontentprotectiondevice.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateContentProtectionDevice", + "name": "MFCreateContentProtectionDevice", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F1E7D8299209411AB183AF09148B9EB2FC82B6AA54C329E8DA1E315136E632A2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatecontentprotectiondevice" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatecredentialcache.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateCredentialCache", + "name": "MFCreateCredentialCache", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "64CEBF378F2D915EE42B9D0DAC9018D6C63EF00F9EB6AD1FBB49C69913CD3E15" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatecredentialcache" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreated3d12synchronizationobject.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateD3D12SynchronizationObject", + "name": "MFCreateD3D12SynchronizationObject", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "D6DEE346F42872E69D6D3017BA4A1C3A34BCA1F7CA2E4D7B3993E4ADABD518FD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfd3d12/nf-mfd3d12-mfcreated3d12synchronizationobject" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatedevicesource.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateDeviceSource", + "name": "MFCreateDeviceSource", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2C272489BDBD1528E6D25ECFA6E223E98751A00DA68F2E027EE93751761982FA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatedevicesource" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatedevicesourceactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateDeviceSourceActivate", + "name": "MFCreateDeviceSourceActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A301DE9B1E091EC998E6326413009D863DF06754743BD09FFF986CA0904B139C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatedevicesourceactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatedxgicrossadapterbuffer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.DLL", + "entryPoint": "MFCreateDXGICrossAdapterBuffer", + "name": "MFCreateDXGICrossAdapterBuffer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "AC2CB320361683FDE481DDF447D7E8412F8FDA2673504041D025AAC90C5B99AA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatedxgidevicemanager.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateDXGIDeviceManager", + "name": "MFCreateDXGIDeviceManager", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "C01A01ED3F3E7280917638AFAA3FA3234E6325BB60DBAE40165D5130CC0655A0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatedxgidevicemanager" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatedxgisurfacebuffer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateDXGISurfaceBuffer", + "name": "MFCreateDXGISurfaceBuffer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "536933D26BED83E997DD1C2BD584915DB6504355CB8F8E379D5D3837E29F9859" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatedxgisurfacebuffer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatedxsurfacebuffer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateDXSurfaceBuffer", + "name": "MFCreateDXSurfaceBuffer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "EF0A0EA8C947C60A28F1A7D62C249B88C86CB149826F4A2EF287B58E5962F410" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatedxsurfacebuffer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateencryptedmediaextensionsstoreactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateEncryptedMediaExtensionsStoreActivate", + "name": "MFCreateEncryptedMediaExtensionsStoreActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "0C4D72306166419A27E2CB8FCC52191FBDBE3929289E77106264D09B7337DDCB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfcontentdecryptionmodule/nf-mfcontentdecryptionmodule-mfcreateencryptedmediaextensionsstoreactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateeventqueue.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateEventQueue", + "name": "MFCreateEventQueue", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "0F2AE69C0D426029288423BF06F12813C118A726B2591FFD778853589C8833FD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreateeventqueue" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateextendedcameraintrinsicmodel.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFCORE.dll", + "entryPoint": "MFCreateExtendedCameraIntrinsicModel", + "name": "MFCreateExtendedCameraIntrinsicModel", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "622FDC64600261B411B9D40930F315451E23DBB26F5D2C07786B1A259BD72C31" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateextendedcameraintrinsics.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFCORE.dll", + "entryPoint": "MFCreateExtendedCameraIntrinsics", + "name": "MFCreateExtendedCameraIntrinsics", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "AC996AC025BFC9035B616169927A78F6BA58904AD28CC3C3124BBDABA24EB060" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatefile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateFile", + "name": "MFCreateFile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "67ECD25B5B39F632C29546C13BA54CC2741590CFFB7FE727BBD2D5552E48645F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatefile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatefmpeg4mediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateFMPEG4MediaSink", + "name": "MFCreateFMPEG4MediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "6B576C4C40B91242A7B4611716CC32AA1ED141A8ED51FC9A6B01702887205CDF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatefmpeg4mediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatelegacymediabufferonmfmediabuffer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateLegacyMediaBufferOnMFMediaBuffer", + "name": "MFCreateLegacyMediaBufferOnMFMediaBuffer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "89B37FC4DD710380C522075843E90FCDE4708DB0C1646BAE085ED6DCF601F1C1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatelegacymediabufferonmfmediabuffer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemediabufferfrommediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMediaBufferFromMediaType", + "name": "MFCreateMediaBufferFromMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A8609B6FD08FA0AFC1D8E8C254F170B17AA994A043055E6E6384F3C080611578" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemediabufferfrommediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemediabufferwrapper.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMediaBufferWrapper", + "name": "MFCreateMediaBufferWrapper", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "88E9169D2087FACFF95794D78A1D0535E5B1B28C954D2A524B856277CA2C72AD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemediabufferwrapper" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemediaevent.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMediaEvent", + "name": "MFCreateMediaEvent", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "41EA8E8F6F6337CD0AC5048F2CF36863F35ECCD9BF1C69C5D648B66252CB01E3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemediaevent" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemediaextensionactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMediaExtensionActivate", + "name": "MFCreateMediaExtensionActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "30916129C8FD4136B4AB313D2D45B71E7B141FE6CBF22B280E57884DC071AA49" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemediaextensionactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemediasession.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateMediaSession", + "name": "MFCreateMediaSession", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "85D8A0382891A49BC420530F9C76BFB036C44B1BC53E0767F1695F9714057EE0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatemediasession" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMediaType", + "name": "MFCreateMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "6E286C8DD52C6C2F2F2A02DB5B7308990FA6ABF372E4D97F9DBDCB5501FF33F7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemediatypefromproperties.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMediaTypeFromProperties", + "name": "MFCreateMediaTypeFromProperties", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "37F26300ED3552BE778E1CEA65AED9C83099AC587F7A0D12ED69F343F9A15524" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatemediatypefromproperties" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemediatypefromrepresentation.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMediaTypeFromRepresentation", + "name": "MFCreateMediaTypeFromRepresentation", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2AF978BDC6202914B9BAA95D097CD60B657EFE89275CB68BA67C4E7D2E76C16A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemediatypefromrepresentation" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatememorybuffer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMemoryBuffer", + "name": "MFCreateMemoryBuffer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3D6BAA3D226461E7C771644CA5D33349C7434A991F387AC65551F611AEB15DFA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatememorybuffer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemfbytestreamonstream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMFByteStreamOnStream", + "name": "MFCreateMFByteStreamOnStream", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "E25D83EFAD3DBC49EE3BE880B0C5B3309E8AA9A9D554A1F35FE3D23F128A6C6A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatemfbytestreamonstream" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemfbytestreamonstreamex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMFByteStreamOnStreamEx", + "name": "MFCreateMFByteStreamOnStreamEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "D95B1982AF61E9B0689214622D061A214B26D3CFD29311DFC7C5DE03BF60F3FC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatemfbytestreamonstreamex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemfbytestreamwrapper.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMFByteStreamWrapper", + "name": "MFCreateMFByteStreamWrapper", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "705AA354DCEA09D8F179C074D6182A648FACD7606666A867D8CB342B4460666D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemfbytestreamwrapper" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemfvideoformatfrommfmediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMFVideoFormatFromMFMediaType", + "name": "MFCreateMFVideoFormatFromMFMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "547CB60ECB690C648E95C093E8A2431F41D49CA1C4556C2EEA71CB2B7CD0C8E7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemfvideoformatfrommfmediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemp3mediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateMP3MediaSink", + "name": "MFCreateMP3MediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "1DB3182CDC7B83987BB2F212BEC01A8AED010675D0150428B56C5AA018C08E79" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatemp3mediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatempeg4mediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateMPEG4MediaSink", + "name": "MFCreateMPEG4MediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F0F43014090BDBC5E1070BDD719A100D5C22BD95D4474F1EF24DB2F951496E36" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatempeg4mediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemuxsink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateMuxSink", + "name": "MFCreateMuxSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "396D41C4D20DB774B6AF83E9AFC6095E257C5C230C02AF6B32E592858D8E0142" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatemuxsink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemuxstreamattributes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMuxStreamAttributes", + "name": "MFCreateMuxStreamAttributes", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5649E7726746710F9143115F79D13B9446BD6A0D4228FB4C23CBB9A6D5494B7B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemuxstreamattributes" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemuxstreammediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMuxStreamMediaType", + "name": "MFCreateMuxStreamMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A45F08D8E15120D8245D268C408081403C1C87C763D4918296417420C941AA16" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemuxstreammediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatemuxstreamsample.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateMuxStreamSample", + "name": "MFCreateMuxStreamSample", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2AE4838044E0A4D09FD2110A5D47716A10CEE26D92B6CFA78E5DB2969D312899" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatemuxstreamsample" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatenetschemeplugin.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateNetSchemePlugin", + "name": "MFCreateNetSchemePlugin", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "BEBDEF2BAC87DC44912A9438C2D7FFAF8BCA77521AA9B6FF1422688EDFD9B702" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatenetschemeplugin" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatepmpmediasession.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreatePMPMediaSession", + "name": "MFCreatePMPMediaSession", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "474C287E8441462F1E7E4472DDBFF1F8AC53F1CA34CE03AD949760E390AF27E3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatepmpmediasession" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatepmpserver.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreatePMPServer", + "name": "MFCreatePMPServer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "49652BDA20F72C43A302F625A75E201C61FD1B37CB73A23078D4DD730B51F943" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatepmpserver" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatepresentationclock.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreatePresentationClock", + "name": "MFCreatePresentationClock", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "C78715CB5DF7E91AA4D9B7FA608690EBE0FE522E66E0BF1BB63BE92092701408" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatepresentationclock" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatepresentationdescriptor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreatePresentationDescriptor", + "name": "MFCreatePresentationDescriptor", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "115F5AC4C276E9CEC41BE04DD842327178CBDA91CEA7B6BF8E2A8CE9DCCD1A7F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatepresentationdescriptor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatepresentationdescriptorfromasfprofile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreatePresentationDescriptorFromASFProfile", + "name": "MFCreatePresentationDescriptorFromASFProfile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F73D162186111F2E53393E81D19780A7BCF32C6FB6C12928C8527FBC7ED7030A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreatepresentationdescriptorfromasfprofile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatepropertiesfrommediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreatePropertiesFromMediaType", + "name": "MFCreatePropertiesFromMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "6714362014E8D900D81469430317FA25DB7D110D3AE65D3DEC2ABB07D2CBD681" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatepropertiesfrommediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateprotectedenvironmentaccess.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateProtectedEnvironmentAccess", + "name": "MFCreateProtectedEnvironmentAccess", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "B4C4DAB452DCA26E82426DEE283E6A4A66E1E71C34A0002F7D57BE8F04CA6E42" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateprotectedenvironmentaccess" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateproxylocator.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateProxyLocator", + "name": "MFCreateProxyLocator", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "87D6FB51EA35AE13AFBA5B55F597CC5D5CCFCD60063F72D4DC665FFAF75B0354" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateproxylocator" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreaterelativepanelwatcher.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateRelativePanelWatcher", + "name": "MFCreateRelativePanelWatcher", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "6F93E420E13CA87C7A3CF8FCD0609E68E84AE9A44DE921A496F021C94E17EA4F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreaterelativepanelwatcher" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreateremotedesktopplugin.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateRemoteDesktopPlugin", + "name": "MFCreateRemoteDesktopPlugin", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "370A10AABAEFD9D4162A8068D6595C189520F21C1A506BCC75F5A30870879142" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreateremotedesktopplugin" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesample.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateSample", + "name": "MFCreateSample", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "95D583245E2EC8C520AB6AD3C2EBF7343AD949A6BFC3ECF220612BB3A65CF4AA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatesample" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesamplecopiermft.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateSampleCopierMFT", + "name": "MFCreateSampleCopierMFT", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A5405AA749A07364652F6B9CED7E8014328DADF4EACBC8A28EB7034B13E8A13F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesamplecopiermft" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesamplegrabbersinkactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateSampleGrabberSinkActivate", + "name": "MFCreateSampleGrabberSinkActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "6CCBF98B755E28BBC2EF0E165B9519CDC5E8E6B1211470A08AFCBFD1486B871D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesamplegrabbersinkactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesensoractivitymonitor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateSensorActivityMonitor", + "name": "MFCreateSensorActivityMonitor", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "88C44F1A0A7047F805580D9186D04B04872CA3AF02CA0E8F8DEC507E61BB0F79" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesensoractivitymonitor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesensorgroup.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateSensorGroup", + "name": "MFCreateSensorGroup", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "EA766012042A5FF6CA5DBEF14DAE80093A600B2CAC0513A296EA78EDAD9CC519" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesensorgroup" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesensorprofile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateSensorProfile", + "name": "MFCreateSensorProfile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "08EE706E1888E0A8C97B4AAFF36269E7CB19EE54339544D824F324974F6B9A20" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesensorprofile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesensorprofilecollection.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateSensorProfileCollection", + "name": "MFCreateSensorProfileCollection", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "D0ACECA9348E0A0E9E87E024285F1AC7ACAC753E4F21693DDB971DDC23256CC1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesensorprofilecollection" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesensorstream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateSensorStream", + "name": "MFCreateSensorStream", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "74BF7D58C3B29373E9E195DD281FF84EA8AA3EA66E18419EDDF095966C474FE6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesensorstream" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesequencersegmentoffset.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateSequencerSegmentOffset", + "name": "MFCreateSequencerSegmentOffset", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "284A52F3095628A13595020BB4CFCBBE4771EEC89A8903B36762CA27DB106FA4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesequencersegmentoffset" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesequencersource.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateSequencerSource", + "name": "MFCreateSequencerSource", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4562A95C2FB7743B7C17C88D5FAF8DCEEC3406E46F742CE3BAC04B9ACB8CB20D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesequencersource" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesimpletypehandler.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateSimpleTypeHandler", + "name": "MFCreateSimpleTypeHandler", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2CC6390327E7CAA1267A40B623DE3979CCAD5E9EC3DAB02A679CF86C320C6005" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesimpletypehandler" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesinkwriterfrommediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFReadWrite.dll", + "entryPoint": "MFCreateSinkWriterFromMediaSink", + "name": "MFCreateSinkWriterFromMediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "53D8AA9ED3232828F019C2B10C0100F7CD3726278B5EA111087E370EADFFA75C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfreadwrite/nf-mfreadwrite-mfcreatesinkwriterfrommediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesinkwriterfromurl.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFReadWrite.dll", + "entryPoint": "MFCreateSinkWriterFromURL", + "name": "MFCreateSinkWriterFromURL", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "1C38F418BF6DB4A5FAB980B4E7BAA07D118DE347E74D7086755F5DD84C0A85FF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfreadwrite/nf-mfreadwrite-mfcreatesinkwriterfromurl" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesourcereaderfrombytestream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFReadWrite.dll", + "entryPoint": "MFCreateSourceReaderFromByteStream", + "name": "MFCreateSourceReaderFromByteStream", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "AF8D751C2771EED07C3DE1F3A2EEE9D2D78EC23EE00F3ED0088DE197DFDFC8DF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfreadwrite/nf-mfreadwrite-mfcreatesourcereaderfrombytestream" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesourcereaderfrommediasource.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFReadWrite.dll", + "entryPoint": "MFCreateSourceReaderFromMediaSource", + "name": "MFCreateSourceReaderFromMediaSource", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "581308AECFB98C05E6E435CFDCE41A1EF4E6EDFB4F3AEBCB1FDE4B2715D53DD1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfreadwrite/nf-mfreadwrite-mfcreatesourcereaderfrommediasource" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesourcereaderfromurl.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFReadWrite.dll", + "entryPoint": "MFCreateSourceReaderFromURL", + "name": "MFCreateSourceReaderFromURL", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3B70188B6D686AACA23AA4FB72C71191812DD2AF0383A83CC6B2D4AAE85516F6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfreadwrite/nf-mfreadwrite-mfcreatesourcereaderfromurl" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesourceresolver.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateSourceResolver", + "name": "MFCreateSourceResolver", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F35FE818301BF39BA9320521B1DAD71608B5719DFB826BE56D83EB22014C4252" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesourceresolver" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatestandardqualitymanager.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateStandardQualityManager", + "name": "MFCreateStandardQualityManager", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "D2D91BA54011B05B063E81BA03AC22FA4E553528FA608D2A7D0959B76A25C6E0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatestandardqualitymanager" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatestreamdescriptor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateStreamDescriptor", + "name": "MFCreateStreamDescriptor", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "317DED9411E0C192A31B1FAB062DAF49E6FCCA721EAFEBCEA11E16263164AA57" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatestreamdescriptor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatestreamonmfbytestream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateStreamOnMFByteStream", + "name": "MFCreateStreamOnMFByteStream", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "777D0F9C953C94D246B993588DDED14D9B8573C26A7CB9FD718674B585EB903F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatestreamonmfbytestream" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatestreamonmfbytestreamex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateStreamOnMFByteStreamEx", + "name": "MFCreateStreamOnMFByteStreamEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "D56248CFAB9B7096EBBD8EF1BCA60B2B8E978AD8458A14B95026A2091DE82AF2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatestreamonmfbytestreamex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatesystemtimesource.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateSystemTimeSource", + "name": "MFCreateSystemTimeSource", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "57DC0892534DDFF7003FFB1B95634BBBA0CA5C896537755CEBB80B7FAB4175E8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatesystemtimesource" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetempfile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateTempFile", + "name": "MFCreateTempFile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "25C2245AA5842BB1194A0D7637EB8DD27590F448D7707DDFF68E6B7AB2F4C2B6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatetempfile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetopoloader.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateTopoLoader", + "name": "MFCreateTopoLoader", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "E81A6097DF06F4FAA81334C4ABE0AA4C2A4177B8F684B69D489CA0F75AF0B55D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatetopoloader" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetopology.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateTopology", + "name": "MFCreateTopology", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8847BD4AC0E647C86C8D50770F97796B2F388B1022EADD28002A36B643CAEB35" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatetopology" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetopologynode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateTopologyNode", + "name": "MFCreateTopologyNode", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A77A05DC6E0256D19D8C178ACF100103AEA5E2E8940D436E353E631E745A342B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatetopologynode" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetrackedsample.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateTrackedSample", + "name": "MFCreateTrackedSample", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A8298C4D2FC209A1143F075339D297A84793561E12078ED63947472F15505311" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatetrackedsample" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetranscodeprofile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateTranscodeProfile", + "name": "MFCreateTranscodeProfile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "171CF51B5D57C4A12B4E682F95D92B0666FD8756E28357DFFF1E3523CEA8ECB7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatetranscodeprofile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetranscodesinkactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateTranscodeSinkActivate", + "name": "MFCreateTranscodeSinkActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "53ACC0BB354403AAF506D4834B861EDD1B713A6C3DD4E194877A7DD20B4824FF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatetranscodesinkactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetranscodetopology.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateTranscodeTopology", + "name": "MFCreateTranscodeTopology", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F4D20C1C4DF4FF21110D2164F851D49C8BA84080653366836E1AF64CAA4EE37E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatetranscodetopology" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetranscodetopologyfrombytestream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateTranscodeTopologyFromByteStream", + "name": "MFCreateTranscodeTopologyFromByteStream", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "94C2C37326DFB434A8189C416BA55994D47CF239598071AB86EED5B1E580F039" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatetranscodetopologyfrombytestream" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatetransformactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateTransformActivate", + "name": "MFCreateTransformActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "9C6816E809525BFE054885E3DF3E24D9BF9FB0FE0767762478479D759E1F7DFF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mftransform/nf-mftransform-mfcreatetransformactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideomediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateVideoMediaType", + "name": "MFCreateVideoMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2C4CE89CE4CF10762A19CB11E1726724768F3EA76373DCC9E8AB24FBC4742511" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatevideomediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideomediatypefrombitmapinfoheader.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateVideoMediaTypeFromBitMapInfoHeader", + "name": "MFCreateVideoMediaTypeFromBitMapInfoHeader", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "C09A59195A50499915ADD3B49248A4266FFCFF2AD70A74735039246F898501FA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatevideomediatypefrombitmapinfoheader" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideomediatypefrombitmapinfoheaderex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateVideoMediaTypeFromBitMapInfoHeaderEx", + "name": "MFCreateVideoMediaTypeFromBitMapInfoHeaderEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8FB7EDD8726B60F5F913C2BED1AFDB7F704B3CB4E2D8CBE3CFEDCF2E0A62D149" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatevideomediatypefrombitmapinfoheaderex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideomediatypefromsubtype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateVideoMediaTypeFromSubtype", + "name": "MFCreateVideoMediaTypeFromSubtype", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2D3A54ECB662E7B048440DCB4F2AB48D1A9F13666E1BBAEFC7EA793E33CE802A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatevideomediatypefromsubtype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideomixer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "EVR.dll", + "entryPoint": "MFCreateVideoMixer", + "name": "MFCreateVideoMixer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "C86E6EE0AAADE4AFF74800596CB2E1ECAEC219167EB3B2AB6CBC00EFA9C07990" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/evr/nc-evr-mfcreatevideomixer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideomixerandpresenter.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "EVR.dll", + "entryPoint": "MFCreateVideoMixerAndPresenter", + "name": "MFCreateVideoMixerAndPresenter", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "0D52EDEABD56EEBB80F241BCB13CEFC23C45E857193F4CC1BC8BC4356F1ADE01" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/evr/nc-evr-mfcreatevideomixerandpresenter" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideopresenter.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "EVR.dll", + "entryPoint": "MFCreateVideoPresenter", + "name": "MFCreateVideoPresenter", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "FD3F370706EF78BDD3780D823A8E692A8ADE87530988224B345C7939A3C7C268" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/evr/nc-evr-mfcreatevideopresenter" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideorenderer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateVideoRenderer", + "name": "MFCreateVideoRenderer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "6A825EF5BBBA84B9EA46F074C7BAA2891CC5EE2A1C6BAFC4BAA144D8697C5ACB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/evr/nc-evr-mfcreatevideorenderer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideorendereractivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateVideoRendererActivate", + "name": "MFCreateVideoRendererActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "7509D7B530EEF889AAE9863A0C79288E021FDF2616F6FBC471E5B439575C08F8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatevideorendereractivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideosampleallocator.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "EVR.dll", + "entryPoint": "MFCreateVideoSampleAllocator", + "name": "MFCreateVideoSampleAllocator", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "1F9899774ED1620B70BE225E35D39C018CECACFEA9766BE714C92AF30ECD5D55" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/evr/nc-evr-mfcreatevideosampleallocator" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideosampleallocatorex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateVideoSampleAllocatorEx", + "name": "MFCreateVideoSampleAllocatorEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F2773640BF5686AFE17BBE6575C48C7D0BEF65C72F5C51AD41D1DED46759D4FA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatevideosampleallocatorex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevideosamplefromsurface.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "EVR.dll", + "entryPoint": "MFCreateVideoSampleFromSurface", + "name": "MFCreateVideoSampleFromSurface", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "031A070E9F10C9A7BF0A315D44C656857BDB78AE2887B23FD37FE75E55AC8A90" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/evr/nc-evr-mfcreatevideosamplefromsurface" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatevirtualcamera.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFCreateVirtualCamera", + "name": "MFCreateVirtualCamera", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4AAD9CF5DAC7765878B714D66B4C77F66BDC1165984A48A1BAE08AFDC464F64B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfvirtualcamera/nf-mfvirtualcamera-mfcreatevirtualcamera" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatewaveformatexfrommfmediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateWaveFormatExFromMFMediaType", + "name": "MFCreateWaveFormatExFromMFMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "DBBE9BA4C484C3F798E3EC8EB2EB4F256DADE78116FC79C3E2C966CD4AA37BC5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatewaveformatexfrommfmediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatewavemediasink.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "mfsrcsnk.dll", + "entryPoint": "MFCreateWAVEMediaSink", + "name": "MFCreateWAVEMediaSink", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "397B21A55249134B64FCCA1B4D4185E5F2FE269C9E8C562E378048BB01B958A3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfcreatewavemediasink" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatewicbitmapbuffer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFCreateWICBitmapBuffer", + "name": "MFCreateWICBitmapBuffer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F369139EA6BEDFDAB52739D9A7996B11721319DD3D8BA5E79593ADD693E25ECA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfcreatewicbitmapbuffer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatewmaencoderactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateWMAEncoderActivate", + "name": "MFCreateWMAEncoderActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "C74439B583BEB057456C05F0D5F3190D265D62E11A8CA09A727C2B6E25ADC5FE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreatewmaencoderactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfcreatewmvencoderactivate.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFCreateWMVEncoderActivate", + "name": "MFCreateWMVEncoderActivate", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5578B01BC8045A9DCD7B952DBF5D021899A3FDB3EFDD31C161EA64918A857EDA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wmcontainer/nf-wmcontainer-mfcreatewmvencoderactivate" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfdeserializeattributesfromstream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFDeserializeAttributesFromStream", + "name": "MFDeserializeAttributesFromStream", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4420BB24CA2B0FD2CE3FC29517A950E2199B71CC0128F50889B9AFF4BADC6687" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfobjects/nf-mfobjects-mfdeserializeattributesfromstream" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfdeserializepresentationdescriptor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFDeserializePresentationDescriptor", + "name": "MFDeserializePresentationDescriptor", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "0CC040BE78BC5696E3FB7FC9C33EE5B5D63BE139A42CF1F112BA21BDB161FE98" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfdeserializepresentationdescriptor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfendcreatefile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFEndCreateFile", + "name": "MFEndCreateFile", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3A81571B547616674E1027163A18D9313448329DF37A6605D4B4EEF38E369C3A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfendcreatefile" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfendregisterworkqueuewithmmcss.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFEndRegisterWorkQueueWithMMCSS", + "name": "MFEndRegisterWorkQueueWithMMCSS", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "87EA0077B6F45E22930AC612E86BD99B58854D9EFF08D37EE4DBF781C1CEB643" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfendregisterworkqueuewithmmcss" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfendunregisterworkqueuewithmmcss.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFEndUnregisterWorkQueueWithMMCSS", + "name": "MFEndUnregisterWorkQueueWithMMCSS", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5FEA866CE35EE08E1644B93D65BA9FC494A651CFBE6BBF9344AC149477F7B493" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfendunregisterworkqueuewithmmcss" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfenumdevicesources.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFEnumDeviceSources", + "name": "MFEnumDeviceSources", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "291C48D9418195B2B605FDA571BE0A74F8A00E6031A30B19FC432BD16AE93D0E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfenumdevicesources" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfframeratetoaveragetimeperframe.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFFrameRateToAverageTimePerFrame", + "name": "MFFrameRateToAverageTimePerFrame", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "79BE86B0A94EB600EECFD6C9883219610F670D3D101001A7ED9C34B7F68F5DF5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfframeratetoaveragetimeperframe" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetattributesasblob.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetAttributesAsBlob", + "name": "MFGetAttributesAsBlob", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8EDE8459AE33529E94817AE4E1976F83256E9B415C3E2679C0EE99C99FBF6BA6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetattributesasblob" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetattributesasblobsize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetAttributesAsBlobSize", + "name": "MFGetAttributesAsBlobSize", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "61ACE2F85C81FA40D820F00169EA4B46E03977FD9554DAF426AD5C1A20D1662E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetattributesasblobsize" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetcontentprotectionsystemclsid.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetContentProtectionSystemCLSID", + "name": "MFGetContentProtectionSystemCLSID", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3932EEB7DF305879DC75C743D7ABF7C64C5635F580204FFE379A4FB3A87204A8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetcontentprotectionsystemclsid" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetdxgidevicemanagemode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.DLL", + "entryPoint": "MFGetDXGIDeviceManageMode", + "name": "MFGetDXGIDeviceManageMode", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F88EAE04C23C7931DFAA55E9F2863CCAF1A3D28CB236BD2A5C5B608A0DAC0CA7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetlocalid.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFGetLocalId", + "name": "MFGetLocalId", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5F60778F8110161A991AC1C170BA87B2036FFF2AC87197A422FFCB7747EAC727" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfgetlocalid" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetmftmerit.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetMFTMerit", + "name": "MFGetMFTMerit", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5811BEC8857CBA4A13D0366C31E1AFC4817D3FD94D0742A908BB678C7D1CF86D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetmftmerit" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetplanesize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "EVR.dll", + "entryPoint": "MFGetPlaneSize", + "name": "MFGetPlaneSize", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "0CCF14978FF33A0FDE966251CAB1DBCB86D8B60A9EC05C16335A269969288D04" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetplanesize" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetplugincontrol.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetPluginControl", + "name": "MFGetPluginControl", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "130587153069242FD2143D6528D3FBD607EA660D5A8FB66E65B42581D328B771" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetplugincontrol" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetservice.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFGetService", + "name": "MFGetService", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "B76F6EE6316A9BCFDBFC26A9A5C72DC556DF0522BAB32864FE76CA1304836260" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfgetservice" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetstrideforbitmapinfoheader.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetStrideForBitmapInfoHeader", + "name": "MFGetStrideForBitmapInfoHeader", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "42444497FC3A87CA3DF94D5F35333C570EB251D6374E3F237B692025F334211F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetstrideforbitmapinfoheader" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetsupportedmimetypes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetSupportedMimeTypes", + "name": "MFGetSupportedMimeTypes", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3B9A4C08B384F6FDB797780BF474DA22370A47C69D66E09FA4F910F1ECCC8A5D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfgetsupportedmimetypes" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetsupportedschemes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetSupportedSchemes", + "name": "MFGetSupportedSchemes", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "0B8C02ECB40F5C343E1D0822376E7F7BB31EBD21A644AFB39C05DFD0EA13A057" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfgetsupportedschemes" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetsystemid.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFGetSystemId", + "name": "MFGetSystemId", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4F8BE2AD53C2C2022463CB06D5F2B99A7A488FF520ADC387F37902A6CE7C518C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfgetsystemid" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetsystemtime.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetSystemTime", + "name": "MFGetSystemTime", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "02E7E47D93E24F9FC78E959938A96F4A2671A6DFD91258B002E7C56B15BF0246" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfgetsystemtime" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgettimerperiodicity.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetTimerPeriodicity", + "name": "MFGetTimerPeriodicity", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A99584CD1E4C3AC76EF3466B51CD378384CA868CFA5D565FF21D41271F9524EE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgettimerperiodicity" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgettoponodecurrenttype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFGetTopoNodeCurrentType", + "name": "MFGetTopoNodeCurrentType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "B145AFCC113179D86F438818276D6B73A6D44DA93BBF9A5AC2E3E4F3ACEF61DB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfgettoponodecurrenttype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetuncompressedvideoformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetUncompressedVideoFormat", + "name": "MFGetUncompressedVideoFormat", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4F00DCE0CFA099349C5486897913E6DEFA13B31E0E10E2C4C9A6C4DEAA1B3916" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetuncompressedvideoformat" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetworkqueuemmcssclass.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetWorkQueueMMCSSClass", + "name": "MFGetWorkQueueMMCSSClass", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2912BB93FBC853678E76283A7973B60ECB6AA704AC4A8DB1C83A4411D3816879" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetworkqueuemmcssclass" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetworkqueuemmcsspriority.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetWorkQueueMMCSSPriority", + "name": "MFGetWorkQueueMMCSSPriority", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3E8217BB932C9F0AD3A2CF930F9B4EFF852A013FFA92B65253BCED679570928C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetworkqueuemmcsspriority" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfgetworkqueuemmcsstaskid.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFGetWorkQueueMMCSSTaskId", + "name": "MFGetWorkQueueMMCSSTaskId", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "CDEAB0BEA9B1E27E67C1D2CC02EEC930ABFEDE1D4458C1E19FECEC94FAACB1EB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfgetworkqueuemmcsstaskid" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfheapalloc.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFHeapAlloc", + "name": "MFHeapAlloc", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "D812E1427734D26306142B06933946742C76D999B573208775D34EA617C40A5C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfheapalloc" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfheapfree.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFHeapFree", + "name": "MFHeapFree", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "76F39843F07F0F08A2DC51388EF3664BD89C1C53E56E81BBE355C270A88DE0EE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfheapfree" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitammediatypefrommfmediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitAMMediaTypeFromMFMediaType", + "name": "MFInitAMMediaTypeFromMFMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A1F56DEA3CE7BA3ABDE7A9ACCA44953FFF43B83293E50A20E580FF00C2EBF1DD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitammediatypefrommfmediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitattributesfromblob.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitAttributesFromBlob", + "name": "MFInitAttributesFromBlob", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A615982F4C6DC9C2D61238DDD7BFD0E8FEBD567E9BCE268A1BB1A0CB7255BC09" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitattributesfromblob" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitmediatypefromammediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitMediaTypeFromAMMediaType", + "name": "MFInitMediaTypeFromAMMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A342CAB001B922C5BD32B18B6D078FF840CADC6F417A7AD4D631F45D26D7D8BB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitmediatypefromammediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitmediatypefrommfvideoformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitMediaTypeFromMFVideoFormat", + "name": "MFInitMediaTypeFromMFVideoFormat", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3800AFF00CDD232571443C030C9539243B946A623E7D54D3D2759F0A30ADD99C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitmediatypefrommfvideoformat" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitmediatypefrommpeg1videoinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitMediaTypeFromMPEG1VideoInfo", + "name": "MFInitMediaTypeFromMPEG1VideoInfo", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "EB3F3339FE179BDDBC72D1248BE0BF81889669546D0EC12EF1FDF5D2F7103424" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitmediatypefrommpeg1videoinfo" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitmediatypefrommpeg2videoinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitMediaTypeFromMPEG2VideoInfo", + "name": "MFInitMediaTypeFromMPEG2VideoInfo", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2CCF9200EEAEEC98FE12D4038A81661AB091F2A7BBE0754EE6E028610C7802FD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitmediatypefrommpeg2videoinfo" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitmediatypefromvideoinfoheader.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitMediaTypeFromVideoInfoHeader", + "name": "MFInitMediaTypeFromVideoInfoHeader", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "60EF87AB1219B6F154D67A51E58A946DBD4AD3891B1719DA2A1F5BD730B70824" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitmediatypefromvideoinfoheader" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitmediatypefromvideoinfoheader2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitMediaTypeFromVideoInfoHeader2", + "name": "MFInitMediaTypeFromVideoInfoHeader2", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "55FB1D6A227A514DE80C30D583D0A60A3C364B0222F63B4FBF21FB5CD02176ED" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitmediatypefromvideoinfoheader2" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitmediatypefromwaveformatex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitMediaTypeFromWaveFormatEx", + "name": "MFInitMediaTypeFromWaveFormatEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "B904CB4E7F73A562325DB9C6D8813EE5A8D534DCB2BF62F19BDD3A55E9499646" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitmediatypefromwaveformatex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitvideoformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitVideoFormat", + "name": "MFInitVideoFormat", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2C9996376E9DB313C69A20EFE523122D0018F50FAA7347A8B8298C873DA49ABF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitvideoformat" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinitvideoformat_rgb.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInitVideoFormat_RGB", + "name": "MFInitVideoFormat_RGB", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "DCFDFFF77D3EAB8500FDD352C2E2CA1F0C25261801B70302A1507E79507FDF2B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinitvideoformat_rgb" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfinvokecallback.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFInvokeCallback", + "name": "MFInvokeCallback", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "E2BE9DCB7D05A42D45D722F6B053CFF9AD8931609192DE78ABC94EC8A0DA0E97" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfinvokecallback" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfiscontentprotectiondevicesupported.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFIsContentProtectionDeviceSupported", + "name": "MFIsContentProtectionDeviceSupported", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A9D8185AF878E85A176F502913E8066895C27B614EE83C2A14B00B76769A5A3E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfiscontentprotectiondevicesupported" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfisformatyuv.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "EVR.dll", + "entryPoint": "MFIsFormatYUV", + "name": "MFIsFormatYUV", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "DEF8BB637038F6A19F9A1C077664DD25234BB991252EB9FDEF60A5D1C39019A5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfisformatyuv" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfisvirtualcameratypesupported.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFSENSORGROUP.dll", + "entryPoint": "MFIsVirtualCameraTypeSupported", + "name": "MFIsVirtualCameraTypeSupported", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "B8B9263A91313DA09C7257D8E2154FAD9E27811F2FB20D879149ED3193136F36" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfvirtualcamera/nf-mfvirtualcamera-mfisvirtualcameratypesupported" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfllmuldiv.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFllMulDiv", + "name": "MFllMulDiv", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "DD19D24BBBB9DD4EAD57AF9F78F0373E36AD29A78D18BC5BDD6F73E02CA241D3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfllmuldiv" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfloadsignedlibrary.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFLoadSignedLibrary", + "name": "MFLoadSignedLibrary", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5075730A87459F1C0CE4BD525D0766A9EABF66E6DD2BF99140B811022F673F99" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfloadsignedlibrary" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mflockdxgidevicemanager.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFLockDXGIDeviceManager", + "name": "MFLockDXGIDeviceManager", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "73F0539A4A295F96E49E15BF669FB3A61F1ED927297FCA34FF6940E9CDD6C487" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mflockdxgidevicemanager" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mflockplatform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFLockPlatform", + "name": "MFLockPlatform", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "02C991A5038C642E48056C266F06388E3E4A49B7F9242FFF6D7BF6923B1C86B9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mflockplatform" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mflocksharedworkqueue.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFLockSharedWorkQueue", + "name": "MFLockSharedWorkQueue", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "C456C47971F25257888BCBB23C4725E42BB61B8EA656B3F27AED39103ED2F7D5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mflocksharedworkqueue" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mflockworkqueue.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFLockWorkQueue", + "name": "MFLockWorkQueue", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "7B635394285EBD32E0C191555CAFD04507756B08004658A5F47855479CB36EDE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mflockworkqueue" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfmapdx9formattodxgiformat.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFMapDX9FormatToDXGIFormat", + "name": "MFMapDX9FormatToDXGIFormat", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8504F6BCB5619059A0354949213C4866C0F2DE83F26D92E203FA38C2986D8774" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfmapdx9formattodxgiformat" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfmapdxgiformattodx9format.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFMapDXGIFormatToDX9Format", + "name": "MFMapDXGIFormatToDX9Format", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3D5059ECC4876344D1B7A7E323E57D726B8D8FDC6CF7799E48F227CA47432E7C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfmapdxgiformattodx9format" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfpcreatemediaplayer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlay.dll", + "entryPoint": "MFPCreateMediaPlayer", + "name": "MFPCreateMediaPlayer", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4EC1487CFEE9F9072B8B93BC4F8C1ADB83808AB4173F1DD9B2CB3856DD07A803" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfplay/nf-mfplay-mfpcreatemediaplayer" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfputwaitingworkitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFPutWaitingWorkItem", + "name": "MFPutWaitingWorkItem", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "DA635533673AF1AD6175CFBFC7FCEBCBD9557BF335E8723949306D259BCBFBE8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfputwaitingworkitem" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfputworkitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFPutWorkItem", + "name": "MFPutWorkItem", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "43829EAACB732A07290587CA71F03BC93C7E209AC29B4942694A053E45EB375F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfputworkitem" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfputworkitem2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFPutWorkItem2", + "name": "MFPutWorkItem2", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8CF43484C767CA7234C14F2C5B2835323E997580F00D6478A38E12D50BD81506" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfputworkitem2" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfputworkitemex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFPutWorkItemEx", + "name": "MFPutWorkItemEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "28DBB83E95F3A1697099AC2E7EE3110AD9E9E6EF7FB10FE49344AAFCCCA766BE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfputworkitemex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfputworkitemex2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFPutWorkItemEx2", + "name": "MFPutWorkItemEx2", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "AD881F4B508E247DE0DFDB57DE570CED5C737F91227E53DFF93F136D8C2E3399" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfputworkitemex2" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfregisterlocalbytestreamhandler.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFRegisterLocalByteStreamHandler", + "name": "MFRegisterLocalByteStreamHandler", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "91332C440DA387CE2897D7961BA7C991A6286326E8B78E7A7EFD71892DBF0A2D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfregisterlocalbytestreamhandler" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfregisterlocalschemehandler.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFRegisterLocalSchemeHandler", + "name": "MFRegisterLocalSchemeHandler", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2E11A3C50689186EE96B1E7E407A2B3B331118D91336C2100B48E3AB31B87B96" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfregisterlocalschemehandler" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfregisterplatformwithmmcss.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFRegisterPlatformWithMMCSS", + "name": "MFRegisterPlatformWithMMCSS", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2A68CAE89D1151DAF7AAE7D1BD1CB899079C35C32435D3395516B9398511809A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfregisterplatformwithmmcss" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfremoveperiodiccallback.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFRemovePeriodicCallback", + "name": "MFRemovePeriodicCallback", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "343D6D2A28D1B3407CC08BB137717F8A60A43B598DAFD41086AD962B87876E1A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfremoveperiodiccallback" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfrequireprotectedenvironment.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFRequireProtectedEnvironment", + "name": "MFRequireProtectedEnvironment", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8CA946679D9B8DAC2AECC327385CF7CBF48B438D798FCA9CBF3C81F09AB9E49F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfrequireprotectedenvironment" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfscheduleworkitem.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFScheduleWorkItem", + "name": "MFScheduleWorkItem", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "635AE29A14CAE2620643803856E7BB3EEBAEBEEEFD51342647DF03E563E9D780" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfscheduleworkitem" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfscheduleworkitemex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFScheduleWorkItemEx", + "name": "MFScheduleWorkItemEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3D2BB389638ABC935899A8214A77C2B4F96D6C9E3B00F3D915884514DE5297AA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfscheduleworkitemex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfserializeattributestostream.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFSerializeAttributesToStream", + "name": "MFSerializeAttributesToStream", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "CD887E39B75961C9128269A42F6A65659FE713DDC27001F720B0547B10EAC37E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfobjects/nf-mfobjects-mfserializeattributestostream" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfserializepresentationdescriptor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFSerializePresentationDescriptor", + "name": "MFSerializePresentationDescriptor", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A513A88B180B147B1E4BFAE7DF3590817E4873BA48EBCFFEA1A5E62F5DEF40EB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfserializepresentationdescriptor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfshutdown.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFShutdown", + "name": "MFShutdown", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "BF04DD2A6FD97359268A9DE9533BCE8CE4CACC4D7CC80D69017210DEB22524F4" + }, + "contracts": [ + { + "kind": "managed-lifecycle", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfshutdown" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfshutdownobject.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFShutdownObject", + "name": "MFShutdownObject", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2533E11636DB1552729E785CAE2923996D5003085CD7DB81023C03CBB5AEA6AD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mfshutdownobject" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfsplitsample.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFSplitSample", + "name": "MFSplitSample", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F3F46DB74062CB15EF54147DECEE4B76AD5BE8C6F52E430943B6EBA12349F190" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfsplitsample" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfstartup.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFStartup", + "name": "MFStartup", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "1BD7A003E237DB706BEE02EA1DA7CDCB876F990161835BDF170396B92FF3D982" + }, + "contracts": [ + { + "kind": "managed-lifecycle", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfstartup" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftenum.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTEnum", + "name": "MFTEnum", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "C8D5374F0E6B6FAC981E4E62FE47A470075134FA9BA97EF1D10124C59298BAC2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftenum" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftenum2.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTEnum2", + "name": "MFTEnum2", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2C2F62489A0AF2DBEF03862D91A0B2B461EDF1EF4516E7B823CF9B1F22506FC8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftenum2" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftenumex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTEnumEx", + "name": "MFTEnumEx", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "02580964948EE35C19D3998452E85F7835307BDFFF19A3D7B48427D3660D2C34" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftenumex" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftgetinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTGetInfo", + "name": "MFTGetInfo", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "BABAADD962846F722241638DF027FA6309C16C3CBCA97D539D33BF65C99BA138" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftgetinfo" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftranscodegetaudiooutputavailabletypes.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MF.dll", + "entryPoint": "MFTranscodeGetAudioOutputAvailableTypes", + "name": "MFTranscodeGetAudioOutputAvailableTypes", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "5470A9A5036BFB6EC23BD7DD8B142A47B797CB3711B04607427CF02E32A6BF53" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfidl/nf-mfidl-mftranscodegetaudiooutputavailabletypes" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftregister.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTRegister", + "name": "MFTRegister", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2A80F874B074EC7E414AD9F21FE84409CE572EB56E5871FDA12B927FA89C5EF1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftregister" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftregisterlocal.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTRegisterLocal", + "name": "MFTRegisterLocal", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "2E03CDCA5B2B4394568466B4F3DF6C9F610867736DDC92CDAEDD52F407285A43" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftregisterlocal" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftregisterlocalbyclsid.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTRegisterLocalByCLSID", + "name": "MFTRegisterLocalByCLSID", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "3E4B79A3CDC67E3F4321093F7954F6A76D2D71FC7E0192321952435E6B649B60" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftregisterlocalbyclsid" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftunregister.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTUnregister", + "name": "MFTUnregister", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "6E7CC90DABC6CB2AFBC54EEAF351D44E1E736D5C2C6AF96ECC16BF489AF965FB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftunregister" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftunregisterlocal.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTUnregisterLocal", + "name": "MFTUnregisterLocal", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "D6274FC316BFD8D09E455018D82E1470B18C521C3CD70E41B6AA4EB5FAC91B51" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftunregisterlocal" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mftunregisterlocalbyclsid.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFTUnregisterLocalByCLSID", + "name": "MFTUnregisterLocalByCLSID", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "4B2BFB08E748F7F83D351513A80E5031793C7C1FC47B17645905E73FB1FBD784" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mftunregisterlocalbyclsid" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfunlockdxgidevicemanager.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFUnlockDXGIDeviceManager", + "name": "MFUnlockDXGIDeviceManager", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "E072D7F7713588D55D5687EA40C91D146099757BC9E00D27ECE76D1E88A0D556" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfunlockdxgidevicemanager" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfunlockplatform.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFUnlockPlatform", + "name": "MFUnlockPlatform", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8D3E9CB3AB5AA322613B17BF0AF93080C30A51A65D4CABF621A94B7BAC9151D1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfunlockplatform" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfunlockworkqueue.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFUnlockWorkQueue", + "name": "MFUnlockWorkQueue", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "FFBC0DCD0BB1E88CFB4DA29B5367D29065A9C812465478FCC21C60A8456E998F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfunlockworkqueue" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfunregisterplatformfrommmcss.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFUnregisterPlatformFromMMCSS", + "name": "MFUnregisterPlatformFromMMCSS", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8D92BB77BF7B5D4EDA1E81F032A83FC4BAC7BC8DAAA5EA04475A40EFC78FB4A1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfunregisterplatformfrommmcss" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfunwrapmediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFUnwrapMediaType", + "name": "MFUnwrapMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "81A2DA996C29B233F82593ED3539232BFC1663DED0828AB4A48DF4AF5CFB8C3A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfunwrapmediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfvalidatemediatypesize.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFValidateMediaTypeSize", + "name": "MFValidateMediaTypeSize", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "9EBEE2161296F628F12A79368BDC7D49C6E8D8FBE31C58AD509EDB37213D8BD3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfvalidatemediatypesize" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.mfwrapmediatype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MFPlat.dll", + "entryPoint": "MFWrapMediaType", + "name": "MFWrapMediaType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "826DA011CFEE8BB2D4D3D7A851902DD61B1522709DDD262B7A5B918871713A76" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mfapi/nf-mfapi-mfwrapmediatype" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.opmgetvideooutputfortarget.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "dxva2.dll", + "entryPoint": "OPMGetVideoOutputForTarget", + "name": "OPMGetVideoOutputForTarget", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "E36CC1FEE4F2C1FA1B100CA396544F73FAEC06D259AC7D6B8CE208B59A38175A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/opmapi/nf-opmapi-opmgetvideooutputfortarget" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.opmgetvideooutputsfromhmonitor.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "dxva2.dll", + "entryPoint": "OPMGetVideoOutputsFromHMONITOR", + "name": "OPMGetVideoOutputsFromHMONITOR", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "14F4C3734535E8D68332A603A92E8F0F4575846C53BAE1804137DAF39580C56B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/opmapi/nf-opmapi-opmgetvideooutputsfromhmonitor" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.opmgetvideooutputsfromidirect3ddevice9object.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "dxva2.dll", + "entryPoint": "OPMGetVideoOutputsFromIDirect3DDevice9Object", + "name": "OPMGetVideoOutputsFromIDirect3DDevice9Object", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "F8A9EA3ECCB3F9D0B30F8A8C1EBCADAB2AF9B8AECDAA27E9CD0F3AA7A5F4BA45" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/opmapi/nf-opmapi-opmgetvideooutputsfromidirect3ddevice9object" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.opmxboxenablehdcp.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "OPMXbox.dll", + "entryPoint": "OPMXboxEnableHDCP", + "name": "OPMXboxEnableHDCP", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "A6D70EF34A61673D14D2BD97660866ECB7992ABFAAD2AFA4D0BBFD1C7F625097" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.opmxboxgethdcpstatus.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "OPMXbox.dll", + "entryPoint": "OPMXboxGetHDCPStatus", + "name": "OPMXboxGetHDCPStatus", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "DF2B44F7F2BB917D4FAFAD48FC208398145427E2267693179E13051C9CA876D4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.media.mediafoundation.apis.opmxboxgethdcpstatusandtype.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "OPMXbox.dll", + "entryPoint": "OPMXboxGetHDCPStatusAndType", + "name": "OPMXboxGetHDCPStatusAndType", + "namespace": "Windows.Win32.Media.MediaFoundation", + "sourceFingerprint": "8D51265FD5D85AD1D1CA486B0A93A2B3037C3103FFF388E2F19234777FD510A3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "media-foundation" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.__wsafdisset.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "__WSAFDIsSet", + "name": "__WSAFDIsSet", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "0E8708DA84E3042D40E5F8730C9E5D51CFD7DD58E9B0F2B7976426D543485C08" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-__wsafdisset" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.accept.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "accept", + "name": "accept", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "1416EF84076CFF42A9A946B6B713D4B3D05F9F0F2267C2250FE9C4DBDA794BDA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-accept" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.acceptex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "AcceptEx", + "name": "AcceptEx", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3D27C9EF04F64E04CBA114D6358BA017B2E0B798B3AC3B99725FFAABA0952FC7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mswsock/nf-mswsock-acceptex" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.bind.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "bind", + "name": "bind", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "068A7AA07B964C43176141602E50935C0A3EAC4614622AA3DE640058B1BD3EC8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-bind" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.closesocket.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "closesocket", + "name": "closesocket", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "E8CB70D64F001D41048217C65E50B93D9E8176DB8887FFC3808578D56EF05E25" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-closesocket" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.connect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "connect", + "name": "connect", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B2FA77260BE1ABB2414BACC83BDE958D503829BE595DF889B9AF098F99B12BB3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-connect" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.enumprotocolsa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "EnumProtocolsA", + "name": "EnumProtocolsA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "FD01397652E46955F00BEAAF6ED55A25B1F3F6D0213113259CBB287D5B1B6A3E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-enumprotocolsa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.enumprotocolsw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "EnumProtocolsW", + "name": "EnumProtocolsW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "78478AB5BF5AC3985031E98302968505B8A20D0BDC49D0FDD82674FF430646E3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-enumprotocolsw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.freeaddrinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "freeaddrinfo", + "name": "freeaddrinfo", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "0401ADEAA884BECD07E6C0E745B2E0335797D115AF023398B45A51634D5FC1A8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfo" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.freeaddrinfoex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "FreeAddrInfoEx", + "name": "FreeAddrInfoEx", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "0E75BA7DDEFD55D52DC04E4FDCB1E25D8B7943741CB7689C198C7351FDFADA15" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfoex" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.freeaddrinfoexw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "FreeAddrInfoExW", + "name": "FreeAddrInfoExW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "D2AA3BAC295DEA210D90AD9ED1B8550FDA071B8F342E09C3AAB79734E53791BF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfoexw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.freeaddrinfow.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "FreeAddrInfoW", + "name": "FreeAddrInfoW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "6465FA395500B28F8080CD9259A075D487D9B045DDE902EABD5A42B996077579" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-freeaddrinfow" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getacceptexsockaddrs.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetAcceptExSockaddrs", + "name": "GetAcceptExSockaddrs", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "38E7C7652D7D1CD27FC1BD80BF30A3C9C5C9AE5728CEA24389ABA19F9051C62A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mswsock/nf-mswsock-getacceptexsockaddrs" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getaddressbynamea.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetAddressByNameA", + "name": "GetAddressByNameA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "96A7E0E13E90E71A8C43865400B4D030DB720BFF647C68FC59FA9B6116357998" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-getaddressbynamea" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getaddressbynamew.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetAddressByNameW", + "name": "GetAddressByNameW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A7CE3718EFE66C1C9DD5B2FA3BF91EE90A8E773DA32B5BFF0A6CCA3DD9597D47" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-getaddressbynamew" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getaddrinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getaddrinfo", + "name": "getaddrinfo", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F8AE262E67130ED6B1D101C66DA9C9521C5E6DC55E2B2EEE6A73D4A669ECDD3C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getaddrinfoexa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "GetAddrInfoExA", + "name": "GetAddrInfoExA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "74002D89C9C368970BA88D52184BAB5F9995432E2C53CEAF644FDF87BB297A2F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfoexa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getaddrinfoexcancel.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "GetAddrInfoExCancel", + "name": "GetAddrInfoExCancel", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7AD6FBD65E3A4F9C6B01F7A21B64EC6F2CAE0269302803F456F64DBE641B2700" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfoexcancel" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getaddrinfoexoverlappedresult.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "GetAddrInfoExOverlappedResult", + "name": "GetAddrInfoExOverlappedResult", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "6B379E5D6C9B74583C5662C560DF965D19BC4618CB6457B330D33B1EE1640464" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfoexoverlappedresult" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getaddrinfoexw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "GetAddrInfoExW", + "name": "GetAddrInfoExW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "BDB931CA34C6655AE1BE01AFAC9D33B81E546B1936A670089196E24FD0DF2354" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfoexw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getaddrinfow.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "GetAddrInfoW", + "name": "GetAddrInfoW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "12AFCF95A120AC5D94A67C98A391D872374BB1885C30B752EB5C2663C4136A02" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfow" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.gethostbyaddr.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "gethostbyaddr", + "name": "gethostbyaddr", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "5B15ECAB96315CE8B50F870AE1BA02C5A6CC59079CD68E398260D8C91C4FF004" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wsipv6ok/nf-wsipv6ok-gethostbyaddr" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.gethostbyname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "gethostbyname", + "name": "gethostbyname", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F6BFDA71EACD7DC9DABE75E1A2D2545EC3C964E5C27E77F9FB1F318F792735CE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wsipv6ok/nf-wsipv6ok-gethostbyname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.gethostname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "gethostname", + "name": "gethostname", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "69E439B6E76EF1E05D5775FB415023B22129C48D35E621832892D653A48120F7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-gethostname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.gethostnamew.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "GetHostNameW", + "name": "GetHostNameW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "333D5BA05845A8D95FCA6515133019B7A39F690656E3B28510461D3732A0BEA5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-gethostnamew" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getnamebytypea.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetNameByTypeA", + "name": "GetNameByTypeA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "6410DCCEE8F37C512A1F652AB9FC9F2A8F892CD595621F0B3B3C9AA001B2222F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-getnamebytypea" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getnamebytypew.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetNameByTypeW", + "name": "GetNameByTypeW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "36E2CC2A3174A03198E921037FCFB79BED1265D33BF2E45598A3C942351D4E60" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-getnamebytypew" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getnameinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getnameinfo", + "name": "getnameinfo", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "5681AAD768080270F7DD1600B2D2BF6C31DB6B6A360D6F4923F113C34BC74DB8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-getnameinfo" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getnameinfow.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "GetNameInfoW", + "name": "GetNameInfoW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "FD516C204823DF34BA67D42D11EC0A864B38E08F511C02A487E2163ED865EBFD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-getnameinfow" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getpeername.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getpeername", + "name": "getpeername", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "37C1FA3364F9AD4D4F1C265494C7E3F297FA7BF43FC5FAF29C49336D0E23B16D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-getpeername" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getprotobyname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getprotobyname", + "name": "getprotobyname", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "1AB6564FD6043D8AE4B32454B85C15807A531DFD3C5D90AB8A5795A9CEA7A01A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-getprotobyname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getprotobynumber.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getprotobynumber", + "name": "getprotobynumber", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "663A3F87D04B4C61FBDB4F3D6C0EC604DE4E8BE43BB6DF4711F9E2A1C7051CAF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-getprotobynumber" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getservbyname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getservbyname", + "name": "getservbyname", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "E227BF8E36439446819C9DAE9A9CA0579A7F16123B9637052E3710B81476B828" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-getservbyname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getservbyport.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getservbyport", + "name": "getservbyport", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "98159DBA5FBD7848E191E69961E9BA549B60C53C83213B8DE1C00365F40E04BE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-getservbyport" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getservicea.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetServiceA", + "name": "GetServiceA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "FFCFD44334A32576FA893D16401CE160930DF07136B2DE281E3ACEF114462C68" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-getservicea" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getservicew.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetServiceW", + "name": "GetServiceW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A45566F2638BC7B194364716B7E911081171861406B39A3313BF2C0E638D0380" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-getservicew" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getsockname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getsockname", + "name": "getsockname", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "778FF3683A84A55C9417DF5F400F9B9314F5CA7E932497D301A452DC84BEEA12" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-getsockname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.getsockopt.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "getsockopt", + "name": "getsockopt", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "2447CA9FD8B47D16119ABD19B1B75A090715571D5EA5813BA027F0E2390FEC25" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-getsockopt" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.gettypebynamea.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetTypeByNameA", + "name": "GetTypeByNameA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "84E69FDC8F73E870DBCF64FF935EA9B7AD7625F307FF9E0466ACD640E03F165A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-gettypebynamea" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.gettypebynamew.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "GetTypeByNameW", + "name": "GetTypeByNameW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "C016983C38BECE47725087F782168F7D20076623C679F874E104CC45FF9EB5F4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-gettypebynamew" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.htonl.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "htonl", + "name": "htonl", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F2A55C8726BAC44332D784E6CD98BFD321A175A1AAA0B777FC0AAA3ED2C1A784" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-htonl" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.htons.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "htons", + "name": "htons", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A489CD9B77C9EB0156B51FAF65A79A140E1A6A243DD5672F349AA25C1DDB0659" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-htons" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.inet_addr.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "inet_addr", + "name": "inet_addr", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "5AF77A074127C0E15BEFA07CED158A4C6B877428D115F719F25247F368DD4AD0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wsipv6ok/nf-wsipv6ok-inet_addr" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.inet_ntoa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "inet_ntoa", + "name": "inet_ntoa", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "342F1180FA66BF5C540CE4E4515CF056CA9AEB64B76AD0DEEFACAE6CA3BF2499" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wsipv6ok/nf-wsipv6ok-inet_ntoa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.inet_ntop.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "inet_ntop", + "name": "inet_ntop", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F6D20649DFD433EF8EA091B0ECBC76A3EFDBBE6ACEFC7518176AEEF92DC3605D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_ntop" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.inet_pton.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "inet_pton", + "name": "inet_pton", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "BB9E14D187F38CE358A0B20019B2650846745FC41EA1732F724395B2C9864711" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inet_pton" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.inetntopw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "InetNtopW", + "name": "InetNtopW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "6363DD6E8DF86DE69C1533377FB37EED3651F368A628417ADA206B684F569F87" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inetntopw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.inetptonw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "InetPtonW", + "name": "InetPtonW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "BF6D5758EDF2B73C414AD259F9FDD49C24D14D55DDB6C1174F323C2D3354BD40" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-inetptonw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.ioctlsocket.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "ioctlsocket", + "name": "ioctlsocket", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7621ADC79EC22C56A8B75CD8359D1637F8BD015370AEEF55419FC27B03CE1ED7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-ioctlsocket" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.listen.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "listen", + "name": "listen", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "C1434961ACD195FBF7EC4C13B3DB14EF593B11224A764701E1FBF4337260824D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-listen" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.ntohl.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "ntohl", + "name": "ntohl", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "303FEBCC92204257E25C0D1572D149E8147AD003B223E403C59B2CA5BD31CFBB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-ntohl" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.ntohs.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "ntohs", + "name": "ntohs", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "2968965448F3E34EED8362BEEDF9B660CDA184EF9889F569ADD59653256C542A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-ntohs" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.processsocketnotifications.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "ProcessSocketNotifications", + "name": "ProcessSocketNotifications", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B58987D4923CDE4CDF6DDCDB30D50F64A4D61062F6C872ADCEB348F6D0D9836B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-processsocketnotifications" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.recv.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "recv", + "name": "recv", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F41CF1D0E70E6D18D6B6F21137E07FA4B8B7EF177E0CCC6E89E52870FB973066" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-recv" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.recvfrom.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "recvfrom", + "name": "recvfrom", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "140010736EDBD3FBEFE8A189A0B21F62CDE4CE65D5EFE23A42D6EC8EDA4F979A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-recvfrom" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlethernetaddresstostringa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlEthernetAddressToStringA", + "name": "RtlEthernetAddressToStringA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "78B78CC9FE3F6A17833584BA5AED03FF4A8FD328B38D294600A3C6867ACC34F0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlethernetaddresstostringa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlethernetaddresstostringw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlEthernetAddressToStringW", + "name": "RtlEthernetAddressToStringW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "422D20885BDA0099FB4C55777F0866A8E1F3D3B494718F2804B024BFC96C3005" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlethernetaddresstostringw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlethernetstringtoaddressa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlEthernetStringToAddressA", + "name": "RtlEthernetStringToAddressA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "EF988B6D8A03C01E2A3001D64A0742D43F3BAA24916024C4001FCB1D748FB0D7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlethernetstringtoaddressa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlethernetstringtoaddressw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlEthernetStringToAddressW", + "name": "RtlEthernetStringToAddressW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "D7BA265F3908E8E79C1CC3B762005ED079D0EB7B2AD3C561F92747BAE45D73C9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlethernetstringtoaddressw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv4addresstostringa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv4AddressToStringA", + "name": "RtlIpv4AddressToStringA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7D8BCE75490C090450BBDD0F1A6681AF019999761EDD671E03ECE4A3ABD888B2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv4addresstostringa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv4addresstostringexa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv4AddressToStringExA", + "name": "RtlIpv4AddressToStringExA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "20B7BD0F6685953D3BA57DF6DC8AEA69B9B52D660E5E05C72D61BA520CB1CBFA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv4addresstostringexa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv4addresstostringexw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv4AddressToStringExW", + "name": "RtlIpv4AddressToStringExW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "2798B225ADF64F472C5B6DA12308D6C53202E91A1B85DCBC1EBA4BC4070E411E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv4addresstostringexw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv4addresstostringw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv4AddressToStringW", + "name": "RtlIpv4AddressToStringW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7D8C557E68A2666307B000207178C56AE09C4213364A91189008C459B6EA4253" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv4addresstostringw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv4stringtoaddressa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv4StringToAddressA", + "name": "RtlIpv4StringToAddressA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "0FB2F4D092CE0F05863A1ED1CC3829855AE10D0667BE508C9749CEE271C6D7E1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv4stringtoaddressa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv4stringtoaddressexa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv4StringToAddressExA", + "name": "RtlIpv4StringToAddressExA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B7F015C09E9092D75BE72E696DE7A83D0DB00CA57A3B8A1A94DE2B266AA9FA72" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv4stringtoaddressexa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv4stringtoaddressexw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv4StringToAddressExW", + "name": "RtlIpv4StringToAddressExW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "0DAAA76B0819561385C0957490DEB4BAC5C9064002979F983971B09FDF7F72CA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv4stringtoaddressexw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv4stringtoaddressw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv4StringToAddressW", + "name": "RtlIpv4StringToAddressW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "96BE13D65772B28F57C76312444ABFB8FB8DEC9ADE8ADBDD7145235923C1C70D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv4stringtoaddressw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv6addresstostringa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv6AddressToStringA", + "name": "RtlIpv6AddressToStringA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "6B0AD5CBD7C697C550FFE1402CC54E0123DB208B58F7383C8DFCB2D27C07D8AE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv6addresstostringa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv6addresstostringexa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv6AddressToStringExA", + "name": "RtlIpv6AddressToStringExA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "05A3C5B6677880554EE3EB6CA48FE7CBC8190A28632803A25EF01A36D7406EA8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv6addresstostringexa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv6addresstostringexw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv6AddressToStringExW", + "name": "RtlIpv6AddressToStringExW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "935AE3D51E930D735B57CA4511143A7BD928D4684B2E14A0C3CB5C5FA7B22C1E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv6addresstostringexw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv6addresstostringw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv6AddressToStringW", + "name": "RtlIpv6AddressToStringW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "8A7292B7423D4036F9894AD12D962ECC88EBFC458FE5B880632029EF5AA9BA80" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv6addresstostringw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv6stringtoaddressa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv6StringToAddressA", + "name": "RtlIpv6StringToAddressA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "00454620AF78AFD2E59D3765B78CF74B345E83C41C1421AA95B2390CCD2FB6BD" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv6stringtoaddressa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv6stringtoaddressexa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv6StringToAddressExA", + "name": "RtlIpv6StringToAddressExA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A28B17D83FA1E9EA70868680B1B8E573235E66F5DACA270F5EA859DDAE32B3A1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv6stringtoaddressexa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv6stringtoaddressexw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv6StringToAddressExW", + "name": "RtlIpv6StringToAddressExW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B3F574BB55A9AEA3410F9321DC65528FCFD2F39F0CA5831316CEBD40516210D3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv6stringtoaddressexw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.rtlipv6stringtoaddressw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "ntdll.dll", + "entryPoint": "RtlIpv6StringToAddressW", + "name": "RtlIpv6StringToAddressW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "37C6833B64B2B5D0FD37C0248BFEAEC016A8EF95223A76BA3F6A9C35A962AC88" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ip2string/nf-ip2string-rtlipv6stringtoaddressw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.select.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "select", + "name": "select", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A063275EDC93C48E1B8D55A07201B2F71BF30F500100C3E548424CC4207FB11E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-select" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.send.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "send", + "name": "send", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "AB946C26BB50EB3C813E8185DBF10BF583A48AEC4E00017DAD0D042459F7CB5B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-send" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.sendto.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "sendto", + "name": "sendto", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3366CBEE8A648EDB2F842F073ABDA9C3811B96C37B84204ACE14B4666FFF8CFE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-sendto" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.setaddrinfoexa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "SetAddrInfoExA", + "name": "SetAddrInfoExA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7BB5E60054EF44C196B42C198599CC62BC23648F4C2B772CD307453EA3311E8A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-setaddrinfoexa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.setaddrinfoexw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "SetAddrInfoExW", + "name": "SetAddrInfoExW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "2460534D17BF265981B57FB7CDA3342E4F05D1071D7502E0BF2A5A98E085A786" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-setaddrinfoexw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.setservicea.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "SetServiceA", + "name": "SetServiceA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "741C4804DE698538965A255CC054DB27AF9A070B59CAB856CC340B5AA74F33F3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-setservicea" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.setservicew.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "SetServiceW", + "name": "SetServiceW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3216C2316364FFF46F7E38433878B5571899CF42BD8951659B1582EC77EB7D77" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/nspapi/nf-nspapi-setservicew" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.setsocketmediastreamingmode.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "Windows.Networking.dll", + "entryPoint": "SetSocketMediaStreamingMode", + "name": "SetSocketMediaStreamingMode", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "94BBD100E985041821188EDE1013621FD1C302E8CB8A6F680CB260B2898D7A82" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/socketapi/nf-socketapi-setsocketmediastreamingmode" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.setsockopt.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "setsockopt", + "name": "setsockopt", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "37515B19FD346CC16B72D3F5AEEE953A692414BD45B2223E2F2E8436D9C090E1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-setsockopt" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.shutdown.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "shutdown", + "name": "shutdown", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "EAF0DC87C13E41FAED4568F13FD50B306854C675D4066C16A9A6345D5F8D9D6E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-shutdown" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.socket.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "socket", + "name": "socket", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7E1BE4BC544AAB7B61ADAA25D4CC1930D6339E9E48A3E49843C5D4711B0BCEC9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-socket" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.transmitfile.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "TransmitFile", + "name": "TransmitFile", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "2A8F3A28FD54B4A676F62E11C9253DC91FDC7221C642FCE5DDB986B32970B74D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mswsock/nf-mswsock-transmitfile" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wpucompleteoverlappedrequest.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WPUCompleteOverlappedRequest", + "name": "WPUCompleteOverlappedRequest", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "473EB7E0A443526BE5637512424B27DC278F89D8BCBEA34521C1CA6E98A8B065" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wpucompleteoverlappedrequest" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaaccept.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAccept", + "name": "WSAAccept", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "EE9C48EA22B6D16D68A25C7A0247564C500894AAC670D2D2F2DE8FACA3FB3E51" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaaccept" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaaddresstostringa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAddressToStringA", + "name": "WSAAddressToStringA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3C55D650EA7A5558069851608A2DDF7F6B5F738EB529ECC7630BE7BA13BB1617" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaaddresstostringa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaaddresstostringw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAddressToStringW", + "name": "WSAAddressToStringW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "C75A6C6D6CF4B32F661F70300C68B9D0FE045591795E8E7671F6BBD41D655174" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaaddresstostringw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaadvertiseprovider.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAdvertiseProvider", + "name": "WSAAdvertiseProvider", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F8C5C1DBAD6EECCF4CAA4B3F81E604C3FEBCB4A745D2D75E694B0F6C31619701" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wsaadvertiseprovider" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaasyncgethostbyaddr.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAsyncGetHostByAddr", + "name": "WSAAsyncGetHostByAddr", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B5699FEC4B2F32FE6CC2FAE1ECCBA0B3CD994A53A8065B650E23CB8C1D7FFBB5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wsipv6ok/nf-wsipv6ok-wsaasyncgethostbyaddr" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaasyncgethostbyname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAsyncGetHostByName", + "name": "WSAAsyncGetHostByName", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "DE98EFEA78AD7F940FDB33EEB90EE80AE392AFE898BCB9D3F4C4C3E938708AC5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/wsipv6ok/nf-wsipv6ok-wsaasyncgethostbyname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaasyncgetprotobyname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAsyncGetProtoByName", + "name": "WSAAsyncGetProtoByName", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "84C3D4D357CE8B8CF464FB94DB6DF3D3B6443D92EE9AE82BBDEB54DEE277223E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsaasyncgetprotobyname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaasyncgetprotobynumber.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAsyncGetProtoByNumber", + "name": "WSAAsyncGetProtoByNumber", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "E314487D3DDC3F49C62B33A926DDA1F7396BAAF6511D271B855B037F8E3DADEA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsaasyncgetprotobynumber" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaasyncgetservbyname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAsyncGetServByName", + "name": "WSAAsyncGetServByName", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "2287965135FDA87B402DA3AAF16C5A92451F6BDD314D1910C36373B57BF0813B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsaasyncgetservbyname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaasyncgetservbyport.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAsyncGetServByPort", + "name": "WSAAsyncGetServByPort", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "04758918FCAB1CCD32842F25E12883A82E3431502DF5A2B8B59C5D15AA7D975B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsaasyncgetservbyport" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaasyncselect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAAsyncSelect", + "name": "WSAAsyncSelect", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3511682D5164F6C9F5CC8B503A28D152754B273E55EFA142F61ECAC17CC9AE32" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsaasyncselect" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsacancelasyncrequest.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSACancelAsyncRequest", + "name": "WSACancelAsyncRequest", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "DD42CD788B7B25C237C187E1382BE06F05829AC4638BEC664694E0394BC56929" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsacancelasyncrequest" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsacancelblockingcall.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSACancelBlockingCall", + "name": "WSACancelBlockingCall", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "5059A0E93B558C56DB042827FFEFEEC0F59F589713655FCADB1D88A35290934C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsacancelblockingcall" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsacleanup.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSACleanup", + "name": "WSACleanup", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "E3D084633C0D56934B9F38338C024D385ACA57E5083A01D02F707BC7237BD8F9" + }, + "contracts": [ + { + "kind": "managed-lifecycle", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsacleanup" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsacloseevent.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSACloseEvent", + "name": "WSACloseEvent", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A9929046A91E141422B2D48403314EC9A82CB647AC346EBF4B78BE7133B104BA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsacloseevent" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaconnect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAConnect", + "name": "WSAConnect", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "772E121BF259C1355990C47C10857308A7A1B752AD49BAEFE57392BBCEC320C2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaconnect" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaconnectbylist.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAConnectByList", + "name": "WSAConnectByList", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "E98F240B7FF00044BC544FC9F3B7E2FA0BF419A7BC2105907E014E205711854A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaconnectbylist" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaconnectbynamea.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAConnectByNameA", + "name": "WSAConnectByNameA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F9F55806747C6E215F9E0D0A3C49E5DD0BCAD981727892756601AC8542FC46C0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaconnectbynamea" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaconnectbynamew.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAConnectByNameW", + "name": "WSAConnectByNameW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "C6AA62D226344B9552E887841AEB613F9A1484B9C30CCEF6F15E780B61879504" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaconnectbynamew" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsacreateevent.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSACreateEvent", + "name": "WSACreateEvent", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "9F5F4D138178DDF86C958C9A4BABC84F3993E19C487A51740DFE1088A635D991" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsacreateevent" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsadeletesocketpeertargetname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "fwpuclnt.dll", + "entryPoint": "WSADeleteSocketPeerTargetName", + "name": "WSADeleteSocketPeerTargetName", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "BCAEB340384D81BD5ABA092575C91E49969F686FCAE8D5429B3BFC2E0240B621" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-wsadeletesocketpeertargetname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaduplicatesocketa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSADuplicateSocketA", + "name": "WSADuplicateSocketA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "36DF5DCA282E72FEB498C0787AE120D873EECBFD4EB0190FD41C6E3E73A9DBB3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaduplicatesocketw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSADuplicateSocketW", + "name": "WSADuplicateSocketW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A0B74AAB85B52722BBB228191A1F4D537DDD12B24BEB78208686D949ED1532C5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaduplicatesocketw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaenumnamespaceprovidersa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAEnumNameSpaceProvidersA", + "name": "WSAEnumNameSpaceProvidersA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "BBED66129D07F2FFD28B2BFBC34C104D910D1A1A8C8423FD8BB701CF0D39A1E9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaenumnamespaceprovidersa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaenumnamespaceprovidersexa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAEnumNameSpaceProvidersExA", + "name": "WSAEnumNameSpaceProvidersExA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "C7BAFD638EB2F277DE085833853C264113D3DE67EC32894EAA9B2CCE6E7951E9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaenumnamespaceprovidersexa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaenumnamespaceprovidersexw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAEnumNameSpaceProvidersExW", + "name": "WSAEnumNameSpaceProvidersExW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "D2FE1F86F0A524B1E2FBFB131D510CE1CB2405EC3D9E90788AEA5F7890687D15" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaenumnamespaceprovidersexw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaenumnamespaceprovidersw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAEnumNameSpaceProvidersW", + "name": "WSAEnumNameSpaceProvidersW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "749FCF70532FB33E6A9F2FDF5F207E702BA69B9468AAB52E12E6547FB8F2566E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaenumnamespaceprovidersw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaenumnetworkevents.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAEnumNetworkEvents", + "name": "WSAEnumNetworkEvents", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "FD8955808A3BE2E26A36FC2E2E0B1A9AC18793982561CCDE5B541D316F59421D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaenumnetworkevents" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaenumprotocolsa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAEnumProtocolsA", + "name": "WSAEnumProtocolsA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "109453E315730AEB073494BA5A8BD5D1157FA3DC18588ED53C6EA5777EC28B4B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaenumprotocolsa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaenumprotocolsw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAEnumProtocolsW", + "name": "WSAEnumProtocolsW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "1F77A0345157C67C50FFA09D2AF50533843F42934CC808B0460B684A7CCB95F3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaenumprotocolsw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaeventselect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAEventSelect", + "name": "WSAEventSelect", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "01A0E982339BEC0B41CAFE9C73BD85E7822A14DC8281BD5236517D32999B4745" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaeventselect" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsagetlasterror.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAGetLastError", + "name": "WSAGetLastError", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "84B39A8F075C8834752CE2319437661B6373583DA47D9917742DA5D33E6EDBF6" + }, + "contracts": [ + { + "kind": "subsystem-exempt" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsagetlasterror" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsagetoverlappedresult.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAGetOverlappedResult", + "name": "WSAGetOverlappedResult", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B51CAEE3D16F79CDF2E46FE60FA08896DF8847FCA18EDAA97A47E1708C7DDAFE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsagetoverlappedresult" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsagetqosbyname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAGetQOSByName", + "name": "WSAGetQOSByName", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7DC8F5461E239F2980FF4B9AE74892D1AC6F8FEB044C0B708BDC3E9BFC7FD09C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsagetqosbyname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsagetserviceclassinfoa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAGetServiceClassInfoA", + "name": "WSAGetServiceClassInfoA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "771B5706198C179CD9749F18C5B9DA8EAAE3311EC6AE7862B551AE35B1615A09" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsagetserviceclassinfoa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsagetserviceclassinfow.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAGetServiceClassInfoW", + "name": "WSAGetServiceClassInfoW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "47D6681D50C9208584FE7A909B5ACADCD01DC16FB6DE22B9A56C1F64642F3DAB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsagetserviceclassinfow" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsagetserviceclassnamebyclassida.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAGetServiceClassNameByClassIdA", + "name": "WSAGetServiceClassNameByClassIdA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "CBCE88F397FFB7B966103BFD1EE2F297C57698BF7D8B170BC6AE0C404FCB8C96" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsagetserviceclassnamebyclassida" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsagetserviceclassnamebyclassidw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAGetServiceClassNameByClassIdW", + "name": "WSAGetServiceClassNameByClassIdW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "D1FED11D3EAC933C59584AFA21C1B033FD66FA74DCDC1FE2A0CF197C9C6DD10A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsagetserviceclassnamebyclassidw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsahtonl.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAHtonl", + "name": "WSAHtonl", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "CE153CC9F4B5E5E6D19163E98178E0C27FEE582E150140059FF9431E5A7B5CFF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsahtonl" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsahtons.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAHtons", + "name": "WSAHtons", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3893AD26E2A216CEC40C6BBD9AD743AEFCAE97280E9ED73D879718493C5C6C6D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsahtons" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaimpersonatesocketpeer.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "fwpuclnt.dll", + "entryPoint": "WSAImpersonateSocketPeer", + "name": "WSAImpersonateSocketPeer", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "12B9360AF2F1A7206B84FDCF6A78660ECA5B3F5FD70703A20172CABB82473F91" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-wsaimpersonatesocketpeer" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsainstallserviceclassa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAInstallServiceClassA", + "name": "WSAInstallServiceClassA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "264150CDA6CCE75CA9DF0B6EC46ED86184355C28561E67C0E908F8D0B6597633" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsainstallserviceclassa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsainstallserviceclassw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAInstallServiceClassW", + "name": "WSAInstallServiceClassW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "79D6C8A44979AAB8D63296E968F3ED7818C98902F6CB96FE718135ED3113C6EB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsainstallserviceclassw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaioctl.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAIoctl", + "name": "WSAIoctl", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "9BAB0C170413137C2628D79AD61254D1337A64EF09022210E53005B4913365D0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaioctl" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaisblocking.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAIsBlocking", + "name": "WSAIsBlocking", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "86FB607E161C84FC61DFFC1292DF19B18FC7DA05FA8B68EEEF86E5B9542ABB2D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaisblocking" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsajoinleaf.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAJoinLeaf", + "name": "WSAJoinLeaf", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "1B0F895974A2BC3BA28C150B28EAE4202C58FA6D6396C3CC0797FED15DE6912A" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsajoinleaf" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsalookupservicebegina.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSALookupServiceBeginA", + "name": "WSALookupServiceBeginA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "39D13D53F45709200E07E06A8AEAC23BB54E5D24D85EF2080582B76E04B1F1B4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsalookupservicebegina" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsalookupservicebeginw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSALookupServiceBeginW", + "name": "WSALookupServiceBeginW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "1DFA977A0C2E498C56AC0282EBAE9DA7E5FCABD9F414BBC47E5F8191692033E9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsalookupservicebeginw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsalookupserviceend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSALookupServiceEnd", + "name": "WSALookupServiceEnd", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "58E40F9C39AA9B7994888CE60DE058D09450CCA9DE43AE83729EE0E061777DBC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsalookupserviceend" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsalookupservicenexta.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSALookupServiceNextA", + "name": "WSALookupServiceNextA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "357AD9704E9BDF8325FA02ED3B712336DB0BE13037FC30E3428FBA0B8512E6D2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsalookupservicenexta" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsalookupservicenextw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSALookupServiceNextW", + "name": "WSALookupServiceNextW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "8B0A849CA6AA15CA05A3EFD2DB4366207836436B8F523342E224D95F399E7193" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsalookupservicenextw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsanspioctl.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSANSPIoctl", + "name": "WSANSPIoctl", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "9593882982EB190DFE40C4EF7D9F42F854A87719C07EEC8D443F4136A8F65D1D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsanspioctl" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsantohl.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSANtohl", + "name": "WSANtohl", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F0C2254E1D855158659F963FCA40EB8E7D329BE2E6C01498745E6FD9A21BF1DB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsantohl" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsantohs.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSANtohs", + "name": "WSANtohs", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A86FAAF59F3924DA4A6C12A7E125E15EAA513AF6FDAAB1879CFAD59476AAE5B1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsantohs" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsapoll.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAPoll", + "name": "WSAPoll", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "8D65A064EDADD2A6D93878BA75568A94F5CE0A17D14B4EB97319E5D701B16948" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsapoll" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaprovidercompleteasynccall.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAProviderCompleteAsyncCall", + "name": "WSAProviderCompleteAsyncCall", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "528E9A5B3C8BF4EBDFEF325F44E184A5BE17DD73C0FB4582C263C6810E216809" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wsaprovidercompleteasynccall" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaproviderconfigchange.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAProviderConfigChange", + "name": "WSAProviderConfigChange", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7C21BD174D332C1FF346B6B68160A78F2AB8D76DFA6C44FB0D6F17DC864DD113" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaproviderconfigchange" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaquerysocketsecurity.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "fwpuclnt.dll", + "entryPoint": "WSAQuerySocketSecurity", + "name": "WSAQuerySocketSecurity", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "63601FA3B55A8FA824BE02C354576C4093CB839601841F08F30B27A6A54A2830" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-wsaquerysocketsecurity" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsarecv.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSARecv", + "name": "WSARecv", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "39D950D6D7CC5D86521321537D7F9CF446B587E5E9F780BCCD319E21405B9B92" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsarecv" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsarecvdisconnect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSARecvDisconnect", + "name": "WSARecvDisconnect", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "C43E26B44215C9CC6B0701460E1DDD02236F931F75E4E6A12CF5CF2AF093C876" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsarecvdisconnect" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsarecvex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "MSWSOCK.dll", + "entryPoint": "WSARecvEx", + "name": "WSARecvEx", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F66B0D3A68779A33474248716DDF19C01D65C56FB6B7ACEF41F6B0FA438E3B3C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/mswsock/nf-mswsock-wsarecvex" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsarecvfrom.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSARecvFrom", + "name": "WSARecvFrom", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3A146EEA1AF9E3C3A79BD64FFEE9D31A3E98CD13C2FD2F1F891E430A17B7368C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsarecvfrom" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaremoveserviceclass.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSARemoveServiceClass", + "name": "WSARemoveServiceClass", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F2100D2460BBF2AE218BD5E40E0050357F0638B1D4886753F1E769878FBBABF6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaremoveserviceclass" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaresetevent.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAResetEvent", + "name": "WSAResetEvent", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "D89A859DECAE9F3FAED81CC8CCD0AF2388D894B00FED5BA4EBE89BBCF8C304B1" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaresetevent" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsarevertimpersonation.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "fwpuclnt.dll", + "entryPoint": "WSARevertImpersonation", + "name": "WSARevertImpersonation", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "E134482FB9527035F3F09BE62EA4E6A107F00BBC485548E86F3F2692271659E3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-wsarevertimpersonation" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasend.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASend", + "name": "WSASend", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "0F150B0749E0039408534D49EBA391C1819427EF89F792A58B2BF71EE4FC84DF" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasend" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasenddisconnect.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASendDisconnect", + "name": "WSASendDisconnect", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "222C8B346DD3C6C80826DD4E38E7F99199CAC49660A698539AFADD76FC6E28E0" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasenddisconnect" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasendmsg.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASendMsg", + "name": "WSASendMsg", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "83D1E6DD6669AC58A1CF81EA86A85005C3E063CC1B71D9C0B3DD1EB3B75FBC47" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasendmsg" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasendto.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASendTo", + "name": "WSASendTo", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B626386E2AB8712A7EE00036A90EFB1AD4B3A618C7C7B745885F24F5748C9D42" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasendto" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasetblockinghook.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASetBlockingHook", + "name": "WSASetBlockingHook", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "D0E751762B6C920C68A08053461C103D278DE15645EC584B403307AC5AA41F8B" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasetblockinghook" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasetevent.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASetEvent", + "name": "WSASetEvent", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "1CBEE36E85A2CE6A4C0B6FDA1AF725FD8C5905869CC45CD18EFC9F97378DCF07" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasetevent" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasetlasterror.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASetLastError", + "name": "WSASetLastError", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3BE15D206ABF8C39EED9705013E6995131713A1B568D5B356E77E7E6C3925677" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsasetlasterror" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasetservicea.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASetServiceA", + "name": "WSASetServiceA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "35758465A3039514132ACFF41E62AD5BEA7BB1442151BEC18248C60A70F6C10C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasetservicea" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasetservicew.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASetServiceW", + "name": "WSASetServiceW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "78A72245C6F05C63FC6881FABF90C9BF5A5001DC83A25048B3F85AF133DAD3FC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasetservicew" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasetsocketpeertargetname.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "fwpuclnt.dll", + "entryPoint": "WSASetSocketPeerTargetName", + "name": "WSASetSocketPeerTargetName", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "6685EF812862AF878617C56FAF65EAEE0F820A74BB8FE904CD9921A685ADCD7C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-wsasetsocketpeertargetname" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasetsocketsecurity.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "fwpuclnt.dll", + "entryPoint": "WSASetSocketSecurity", + "name": "WSASetSocketSecurity", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3D110D17CFB97AD1B66369BA337C071065A651FCC2E60516FE59E26BDA7A6DC3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2tcpip/nf-ws2tcpip-wsasetsocketsecurity" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasocketa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASocketA", + "name": "WSASocketA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "CDAD69DBE9358E64EBC1C931D85B72A9E4AFFC394577969A2C5470EDA3B36DBE" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasocketa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsasocketw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSASocketW", + "name": "WSASocketW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B70A0F5E50D343156FEF028D25E47642D8F36524B6BC0ECCA85D82FC8AA764F2" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsasocketw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsastartup.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAStartup", + "name": "WSAStartup", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "724BACFB84F3F650D790F611B3CE416D8FCF361DCDDF9B45888144CCDDD8CE81" + }, + "contracts": [ + { + "kind": "managed-lifecycle", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock/nf-winsock-wsastartup" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsastringtoaddressa.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAStringToAddressA", + "name": "WSAStringToAddressA", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "77E75A59A007CC7ECDFE3976EF6F2508D98EF395001C7585DF039BF13D67FCCA" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsastringtoaddressa" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsastringtoaddressw.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAStringToAddressW", + "name": "WSAStringToAddressW", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "58EF4A1176661BF1D469B73E080CAF773032F1AD6773D249BBCA61A5E4AC8711" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsastringtoaddressw" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaunadvertiseprovider.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAUnadvertiseProvider", + "name": "WSAUnadvertiseProvider", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "62624C255D3E9FDC19946D58860A66539C4281912E2EC2243CACE6AF55454BAC" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wsaunadvertiseprovider" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsaunhookblockinghook.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAUnhookBlockingHook", + "name": "WSAUnhookBlockingHook", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "B96945AB7A8D76B6E6FD85C5B81DE2D174C773FA1690E4A729A55A26FF42093F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsaunhookblockinghook" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wsawaitformultipleevents.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSAWaitForMultipleEvents", + "name": "WSAWaitForMultipleEvents", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "7C5EB88826FB000615BC0DF605B4B1D86AE1C1477971621E8665EC6299FCC8F7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/winsock2/nf-winsock2-wsawaitformultipleevents" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscdeinstallprovider.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCDeinstallProvider", + "name": "WSCDeinstallProvider", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "D85819ED23D7BDB51CD0EB36AC853CC7DE18596C268305475A54E99074815444" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscdeinstallprovider" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscdeinstallprovider32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCDeinstallProvider32", + "name": "WSCDeinstallProvider32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "E06693227BBA1C20DCE61EA9785BDE585C5E182A0A52EB8EC361B1D85E1CA0F5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscdeinstallprovider32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscenablensprovider.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCEnableNSProvider", + "name": "WSCEnableNSProvider", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "5D3715695287B04C967F099A27355B181B1BA02929CA50069FA255252261D653" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscenablensprovider" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscenablensprovider32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCEnableNSProvider32", + "name": "WSCEnableNSProvider32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "96F7F524CF05BAD8C1CFAF22781CF96C98256CB7CEEE0ACE3A8F4A969818EED5" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscenablensprovider32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscenumnamespaceproviders32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCEnumNameSpaceProviders32", + "name": "WSCEnumNameSpaceProviders32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "41C65DB15222E9800B42A09440143A6D2070FEF7BEF99D02BAE9A000B239B782" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscenumnamespaceproviders32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscenumnamespaceprovidersex32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCEnumNameSpaceProvidersEx32", + "name": "WSCEnumNameSpaceProvidersEx32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "8EA3281517B25F6AD4412589416FE1D8A4BBC26269043A6EB22317A44FC08AB4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscenumnamespaceprovidersex32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscenumprotocols.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCEnumProtocols", + "name": "WSCEnumProtocols", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "911010A110577724FD4AC3C6AFF60D56C155BB63B4F528AD4FA59AF564321369" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscenumprotocols" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscenumprotocols32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCEnumProtocols32", + "name": "WSCEnumProtocols32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "3DE51325B1952D3E76702CFE23848446A6782C4727CC10E328151B38D6AF455F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscenumprotocols32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscgetapplicationcategory.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCGetApplicationCategory", + "name": "WSCGetApplicationCategory", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "C118EB0D3D48641717F24B0EE8C000D9097426C8C5DC6464B3401B29D3B20091" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscgetapplicationcategory" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscgetproviderinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCGetProviderInfo", + "name": "WSCGetProviderInfo", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "2D6791F4A8817F7231BF0B2F542C3517F94A97DC3469488EC1653B0604BD3BB9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscgetproviderinfo" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscgetproviderinfo32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCGetProviderInfo32", + "name": "WSCGetProviderInfo32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "79F21C9D01358EC69E3A9ED279DDF5C6D8D58A3D320495C5253AFB6B879977C3" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscgetproviderinfo32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscgetproviderpath.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCGetProviderPath", + "name": "WSCGetProviderPath", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "71DA09264FF91B913602C62E624AC7217D7743BAEB07B0B46C8E89F8A87585F6" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscgetproviderpath" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscgetproviderpath32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCGetProviderPath32", + "name": "WSCGetProviderPath32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "008738EDBD278DD5E753673A3900C351654E49F938FAC5BB8399A877D6F67EA7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscgetproviderpath32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscinstallnamespace.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCInstallNameSpace", + "name": "WSCInstallNameSpace", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "8E770B653BFA38E4616B75835EF9AF94C1BCB2FF15977BC2D009B0A8A9252192" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscinstallnamespace" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscinstallnamespace32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCInstallNameSpace32", + "name": "WSCInstallNameSpace32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "1CB518F620E0D27F0FBFA11690163310AD9042DFB0F270BE9C9F8985551C3457" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscinstallnamespace32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscinstallnamespaceex.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCInstallNameSpaceEx", + "name": "WSCInstallNameSpaceEx", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "36E6CC793ECC8EEEB9C36D87D3FCB019CF4056A4A4E0005FC06FDC6C0ADC86DB" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscinstallnamespaceex" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscinstallnamespaceex32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCInstallNameSpaceEx32", + "name": "WSCInstallNameSpaceEx32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "5201C2322BE73A4C2E39A26147B9311F5F4A8C31E48E7AD485425941A0D5278C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscinstallnamespaceex32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscinstallprovider.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCInstallProvider", + "name": "WSCInstallProvider", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "6E26A2B56185DD85E4A5C6B516E41719524476AF5872AA998EE4295A894BAB4E" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscinstallprovider" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscinstallprovider64_32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCInstallProvider64_32", + "name": "WSCInstallProvider64_32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "722C817B975D6B007F44EEAC84DA8721B9A63CF6B75C881E5C4C8DB361BBE297" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscinstallprovider64_32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscinstallproviderandchains64_32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCInstallProviderAndChains64_32", + "name": "WSCInstallProviderAndChains64_32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "4B504A7CA9FF39065CE9593FD4D73829DACE6D16146EC7CBEEF61A8F4D8B796D" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscinstallproviderandchains64_32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscsetapplicationcategory.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCSetApplicationCategory", + "name": "WSCSetApplicationCategory", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "688161312FFA1BC5CF58ADAAEA45556A32844D2BA691C9156BAF8C100CBA761F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscsetapplicationcategory" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscsetproviderinfo.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCSetProviderInfo", + "name": "WSCSetProviderInfo", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "93A713062F1E3484BC90A576C186DA67B6A92ACB58E6706F1F2CC218BC3A5FE9" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscsetproviderinfo" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscsetproviderinfo32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCSetProviderInfo32", + "name": "WSCSetProviderInfo32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "6E51C05E64E08A3E97E90D4B3AACBD48AC475D029A45DC6C2CFC73680FFB586F" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscsetproviderinfo32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscuninstallnamespace.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCUnInstallNameSpace", + "name": "WSCUnInstallNameSpace", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "95AD15531283F987B4DCD42C0F02B174833760F571A69F2B8C070595BB11D46C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscuninstallnamespace" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscuninstallnamespace32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCUnInstallNameSpace32", + "name": "WSCUnInstallNameSpace32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "558F6362A69F13A67050CADFF2CA74508D9F5A2CBFD24FA651FE80C37F70771C" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscuninstallnamespace32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscupdateprovider.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCUpdateProvider", + "name": "WSCUpdateProvider", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "5EAAA8B9304E0BDF009D8534185E05D310316F3E9D50B401E584990FC349A761" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscupdateprovider" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscupdateprovider32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCUpdateProvider32", + "name": "WSCUpdateProvider32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "F0A787470FED7D67C93F551C70F1BD78193FB64628D3E4475322698839B295F7" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/ws2spi/nf-ws2spi-wscupdateprovider32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscwritenamespaceorder.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCWriteNameSpaceOrder", + "name": "WSCWriteNameSpaceOrder", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "FF2EA8C6351A73379B77B0D452FA0D07FF5B3B6F3DA59AAA38B2BC87E945D6B8" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/sporder/nf-sporder-wscwritenamespaceorder" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscwritenamespaceorder32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCWriteNameSpaceOrder32", + "name": "WSCWriteNameSpaceOrder32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "709A2A0D772DE81D39D8452EA4359CC81500C9D47D640793E2FEF96D280D9C87" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/sporder/nf-sporder-wscwritenamespaceorder32" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscwriteproviderorder.subsystem.v1", + "selector": { + "architectures": 7, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCWriteProviderOrder", + "name": "WSCWriteProviderOrder", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "560ECF9E44363DBCB4E2214B7F3EC4AAD08CF0A56D64651A9E029033CA738046" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/sporder/nf-sporder-wscwriteproviderorder" + } + ] + }, + { + "id": "windows.win32.networking.winsock.apis.wscwriteproviderorder32.subsystem.v1", + "selector": { + "architectures": 6, + "callingConvention": "system", + "container": "Apis", + "dll": "WS2_32.dll", + "entryPoint": "WSCWriteProviderOrder32", + "name": "WSCWriteProviderOrder32", + "namespace": "Windows.Win32.Networking.WinSock", + "sourceFingerprint": "A29D1EA2B63BA1ACB05BAB40B060B802A3B08BE5EB24FACB386E6B9AC50802B4" + }, + "contracts": [ + { + "kind": "subsystem", + "subsystem": "winsock" + } + ], + "evidence": [ + { + "kind": "microsoft-learn", + "url": "https://learn.microsoft.com/windows/win32/api/sporder/nf-sporder-wscwriteproviderorder32" + } + ] + } + ] +} diff --git a/tools/dynwinrt-codegen/npm/README.md b/tools/dynwinrt-codegen/npm/README.md index dbb206de..06a8d1af 100644 --- a/tools/dynwinrt-codegen/npm/README.md +++ b/tools/dynwinrt-codegen/npm/README.md @@ -55,8 +55,8 @@ npx dynwinrt-codegen generate \ |---|---| | `--winmd PATH[;PATH...]` | Path to `.winmd` file(s) (auto-detects Windows SDK if omitted) | | `--folder PATH` | Directory containing `.winmd` files | -| `--namespace NAMESPACE` | WinRT namespace to generate (omit for all non-`Windows.*` namespaces) | -| `--class-name CLASS` | Specific class (transitively pulls in dependencies) | +| `--namespace NAMESPACE` | Metadata namespace to generate (omit for all non-`Windows.*` namespaces) | +| `--class-name CLASS` | Specific classes, interfaces, or native `Apis` containers (comma-separated; transitively pulls in dependencies) | | `--ref PATH` | Additional `.winmd` files for type resolution only (no code emitted) | | `--lang LANG` | `js` (default, emits `.js` + `.d.ts`) or `py` (Python) | | `--output DIR` | Output directory (default `./generated`) | @@ -88,6 +88,27 @@ contracts are emitted under the generated `com/` subpackage; unsupported interfaces fail closed. See the [Classic COM usage guide](https://github.com/microsoft/dynwinrt/blob/main/docs/guides/windows/classic-com-usage.md). +### Flat Win32 DLL exports + +Generate namespace-organized JavaScript modules and TypeScript declarations +from `Windows.Win32.winmd` by selecting an `Apis` container: + +```powershell +npx dynwinrt-codegen generate ` + --winmd $env:DYNWINRT_WIN32_WINMD ` + --class-name Windows.Win32.System.Registry.Apis ` + --output .\generated +``` + +Generated modules live under `win32/` and use `@microsoft/dynwinrt/win32`, +separately from WinRT and Classic COM. Metadata and explicit contracts validate +native layout, buffers, ownership, and lifecycle requirements; unsupported +exports produce diagnostics. Supported wrappers include managed resource +cleanup and IOCP-backed asynchronous file I/O. Subsystem initialization remains +explicit, with lifecycle DLLs loaded on demand. +See the [Win32 capabilities and contract boundary](https://github.com/microsoft/dynwinrt/blob/main/docs/architecture/flat-win32-contracts.md) +and [JavaScript samples](https://github.com/microsoft/dynwinrt/tree/main/samples/js/win32). + ## Platform - **Windows only** (x64 / arm64) — the binary is built per architecture and selected automatically by the npm install diff --git a/tools/dynwinrt-codegen/python/README.md b/tools/dynwinrt-codegen/python/README.md index 6cabb82f..516ea134 100644 --- a/tools/dynwinrt-codegen/python/README.md +++ b/tools/dynwinrt-codegen/python/README.md @@ -138,9 +138,9 @@ complete output. `py3-none-win_arm64` wheels for Python 3.8–3.14. - Generated bindings and the `dynwinrt` runtime require CPython 3.11–3.14 on Windows x64 or ARM64. -- Python generation currently supports WinRT metadata. Classic COM generation - from `Windows.Win32.winmd` is currently available only for JavaScript and - TypeScript. +- Python generation currently supports WinRT metadata. Classic COM and flat + Win32 DLL-export generation from `Windows.Win32.winmd` are available only + for JavaScript and TypeScript. - Some APIs require their Windows component, package identity, or framework bootstrap to be present at runtime. diff --git a/tools/dynwinrt-codegen/src/codegen/mod.rs b/tools/dynwinrt-codegen/src/codegen/mod.rs index 402aa120..be1d83cf 100644 --- a/tools/dynwinrt-codegen/src/codegen/mod.rs +++ b/tools/dynwinrt-codegen/src/codegen/mod.rs @@ -5,6 +5,7 @@ pub mod com; pub mod common; mod javascript_layout; pub mod package; +pub mod win32; pub mod winrt; // Preserve the existing public module paths while callers migrate to diff --git a/tools/dynwinrt-codegen/src/codegen/package.rs b/tools/dynwinrt-codegen/src/codegen/package.rs index af79c4f5..bed4130c 100644 --- a/tools/dynwinrt-codegen/src/codegen/package.rs +++ b/tools/dynwinrt-codegen/src/codegen/package.rs @@ -2,7 +2,7 @@ // Licensed under the MIT License. //! Emit `package.json` for a generated bindings package containing WinRT, -//! Classic COM, or both domains. +//! Classic COM, and flat Win32 domains. use std::collections::BTreeSet; @@ -34,10 +34,17 @@ pub fn render_package_json(input: &PackageManifestInput<'_>) -> String { } pub fn render_bindings_package_json(input: &BindingsPackageManifestInput<'_>) -> String { + render_bindings_package_json_with_win32(input, &BTreeSet::new()) +} + +pub fn render_bindings_package_json_with_win32( + input: &BindingsPackageManifestInput<'_>, + win32_namespaces: &BTreeSet, +) -> String { if input.has_winrt_root { - render_winrt_package(input) + render_winrt_package(input, win32_namespaces) } else { - render_com_only_package(input.has_com_output) + render_native_package(input.has_com_output, win32_namespaces) } } @@ -93,7 +100,10 @@ pub fn render_python_setup_cfg(build_cache_key: &str) -> String { ) } -fn render_winrt_package(input: &BindingsPackageManifestInput<'_>) -> String { +fn render_winrt_package( + input: &BindingsPackageManifestInput<'_>, + win32_namespaces: &BTreeSet, +) -> String { let mut out = String::new(); out.push_str("{\n"); out.push_str(" \"name\": \"@winapp/bindings\",\n"); @@ -123,12 +133,13 @@ fn render_winrt_package(input: &BindingsPackageManifestInput<'_>) -> String { } append_com_exports(&mut out, input.has_com_output, true); + append_win32_exports(&mut out, win32_namespaces, true); out.push_str("\n }\n"); out.push_str("}\n"); out } -fn render_com_only_package(has_com_output: bool) -> String { +fn render_native_package(has_com_output: bool, win32_namespaces: &BTreeSet) -> String { let mut out = String::new(); out.push_str("{\n"); out.push_str(" \"name\": \"@winapp/bindings\",\n"); @@ -136,6 +147,7 @@ fn render_com_only_package(has_com_output: bool) -> String { out.push_str(" \"sideEffects\": false,\n"); out.push_str(" \"exports\": {\n"); append_com_exports(&mut out, has_com_output, false); + append_win32_exports(&mut out, win32_namespaces, has_com_output); out.push_str("\n }\n"); out.push_str("}\n"); out @@ -161,6 +173,38 @@ fn append_com_exports(out: &mut String, include_com: bool, has_previous: bool) { out.push_str(" }"); } +fn append_win32_exports(out: &mut String, namespaces: &BTreeSet, has_previous: bool) { + if namespaces.is_empty() { + return; + } + if has_previous { + out.push_str(",\n"); + } + out.push_str(" \"./win32\": {\n"); + out.push_str(" \"types\": \"./win32/index.d.ts\",\n"); + out.push_str(" \"import\": \"./win32/index.mjs\",\n"); + out.push_str(" \"require\": \"./win32/index.js\"\n"); + out.push_str(" },\n"); + out.push_str(" \"./win32/*\": {\n"); + out.push_str(" \"types\": \"./win32/*.d.ts\",\n"); + out.push_str(" \"import\": \"./win32/*.js\",\n"); + out.push_str(" \"require\": \"./win32/*.js\"\n"); + out.push_str(" }"); + for namespace in namespaces { + out.push_str(&format!(",\n \"./win32/{namespace}\": {{\n")); + out.push_str(&format!( + " \"types\": \"./win32/{namespace}/index.d.ts\",\n" + )); + out.push_str(&format!( + " \"import\": \"./win32/{namespace}/index.mjs\",\n" + )); + out.push_str(&format!( + " \"require\": \"./win32/{namespace}/index.js\"\n" + )); + out.push_str(" }"); + } +} + #[cfg(test)] mod tests { use super::*; @@ -239,6 +283,38 @@ mod tests { assert!(out.contains("\"require\": \"./com/*.js\"")); } + #[test] + fn win32_package_preserves_root_isolation_and_namespace_exports() { + let namespaces = BTreeSet::from(["windows/win32/system/registry".to_string()]); + for has_winrt_root in [false, true] { + for has_com_output in [false, true] { + let names = BTreeSet::from(["windows/foundation/Uri".to_string()]); + let input = BindingsPackageManifestInput { + has_winrt_root, + has_com_output, + winrt_subpath_names: &names, + }; + let output = render_bindings_package_json_with_win32(&input, &namespaces); + let output: serde_json::Value = serde_json::from_str(&output).unwrap(); + let exports = output["exports"].as_object().unwrap(); + assert_eq!(exports.contains_key("."), has_winrt_root); + assert_eq!(exports.contains_key("./com"), has_com_output); + assert!(exports.contains_key("./win32")); + assert_eq!( + exports["./win32/windows/win32/system/registry"]["import"], + "./win32/windows/win32/system/registry/index.mjs" + ); + if has_winrt_root { + let baseline: serde_json::Value = + serde_json::from_str(&render_bindings_package_json(&input)).unwrap(); + for (key, value) in baseline["exports"].as_object().unwrap() { + assert_eq!(&exports[key], value); + } + } + } + } + } + #[test] fn com_only_package_exposes_only_explicit_com_subpaths() { let module = "windows/win32/ui/shell/ITaskbarList3"; diff --git a/tools/dynwinrt-codegen/src/codegen/win32/aggregate_result_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/aggregate_result_tests.rs new file mode 100644 index 00000000..34dda700 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/aggregate_result_tests.rs @@ -0,0 +1,594 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::sync::Arc; + +use dynwinrt_win32_contracts::NativeType; + +use super::{ir::*, test_support::*, *}; +use crate::{ + win32_contracts::{METADATA_SHA256, Registry}, + win32_metadata::*, +}; + +fn raw_layout(function: &mut RawFunction) -> &mut RawNativeLayoutSet { + let RawBaseType::Named { + kind: RawNamedKind::NativeStruct { layout }, + .. + } = &mut function.parameters[1].typ.base + else { + panic!("aggregate parameter") + }; + layout +} + +fn layout(function: &mut FunctionContract) -> &mut NativeLayout { + let ValueType::NativeStructPointer { layout } = &mut function.parameters[1].typ else { + panic!("aggregate parameter") + }; + layout +} + +fn synthetic_layout_evidence(layout: &mut RawNativeLayoutSet) { + let entry = Registry::builtin() + .unwrap() + .type_entry("Windows.Win32.System.Threading", "PROCESS_INFORMATION") + .unwrap(); + layout.evidence = Some(Arc::new(RawLayoutEvidence { + selector: entry.selector.clone(), + metadata_sha256: METADATA_SHA256.into(), + shape_fingerprint: layout_shape_fingerprint(layout), + })); +} + +fn raw_result_function(direction: RawDirection) -> RawFunction { + let handle = RawType { + base: RawBaseType::Named { + namespace: "Windows.Win32.Foundation".into(), + name: "HANDLE".into(), + kind: RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }; + let fields = [ + ("hProcess", handle.clone()), + ("hThread", handle), + ("dwProcessId", scalar(RawScalar::U32)), + ("dwThreadId", scalar(RawScalar::U32)), + ] + .into_iter() + .map(|(name, typ)| RawNativeField { + name: name.into(), + typ, + fixed_count: None, + bitfield: false, + flexible_array: false, + }) + .collect(); + let mut function = synthetic_function("ProduceRecord"); + function.return_type = scalar(RawScalar::Bool32); + function.supports_last_error = true; + function.parameters = vec![ + parameter("flags", scalar(RawScalar::U32), RawDirection::In), + parameter( + "record", + RawType { + base: RawBaseType::Named { + namespace: "Windows.Win32.System.Threading".into(), + name: "PROCESS_INFORMATION".into(), + kind: RawNamedKind::NativeStruct { + layout: Box::new(RawNativeLayoutSet { + recursive: false, + evidence: None, + variants: vec![RawNativeLayout { + architectures: function.architectures, + kind: RawLayoutKind::Sequential, + packing: RawPacking::Default, + declared_size: None, + forced_alignment: None, + fields, + }], + }), + }, + }, + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction, + ), + parameter( + "pCount", + pointer(scalar(RawScalar::U32), 1, RawConstness::Mutable), + RawDirection::Out, + ), + ]; + synthetic_layout_evidence(raw_layout(&mut function)); + function +} + +fn field_target(field: usize) -> ResultTarget { + ResultTarget::AggregateField { + parameter: 1, + field, + } +} + +#[test] +fn logical_aggregate_results_survive_physical_pointer_input_lowering() { + for direction in [RawDirection::Out, RawDirection::InOut] { + let function = project_one(raw_result_function(direction)); + let parameter = &function.runtime.parameters[1]; + assert_eq!(parameter.abi, AbiType::Pointer); + assert_eq!(parameter.direction, Direction::In); + assert_eq!(parameter.cleanup, Cleanup::None); + assert!(parameter.aggregate.is_none()); + let layout = parameter.pointee_aggregate.as_ref().unwrap(); + assert_eq!( + layout.output_fields, + ["hProcess", "hThread", "dwProcessId", "dwThreadId"] + ); + assert_eq!( + function + .runtime + .call_contract + .results + .iter() + .map(|result| result.target) + .collect::>(), + [ + ResultTarget::Return {}, + ResultTarget::Parameter { index: 2 }, + field_target(0), + field_target(1), + field_target(2), + field_target(3), + ] + ); + for width in [32, 64] { + let shape = function.runtime.signature_shape(width); + function + .runtime + .call_contract + .validate_signature(&shape) + .unwrap(); + assert_eq!(shape.parameters[1].typ, NativeType::Pointer); + assert_eq!(shape.parameters[1].direction, Direction::In); + assert_eq!(shape.parameters[1].result_fields.len(), 4); + for field in 0..4 { + let target = field_target(field); + let (typ, cleanup, ownership) = if field < 2 { + ( + NativeType::Handle, + Cleanup::CloseHandle, + ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle, + }, + ) + } else { + (NativeType::U32, Cleanup::None, ResultOwnership::Value {}) + }; + assert_eq!(shape.result_type(target).unwrap(), typ); + assert_eq!(shape.result_cleanup(target), cleanup); + let result = function.runtime.call_contract.result(target).unwrap(); + assert_eq!(result.on_success, ResultPolicy::delivered(ownership)); + assert_eq!(result.on_failure, ResultPolicy::Undefined {}); + assert!(result.overrides.is_empty()); + } + } + assert!( + matches!(&function.return_shape, ReturnShape::Object { outputs, .. } + if outputs.len() == 1 && outputs[0].output_index == 0) + ); + } +} + +#[test] +fn result_field_indices_follow_declared_outputs_not_native_fields_or_output_cells() { + let mut raw = raw_result_function(RawDirection::Out); + let native = raw_layout(&mut raw); + native.variants[0].fields.rotate_left(2); + native.variants[0].fields.insert( + 0, + RawNativeField { + name: "inputOnly".into(), + typ: scalar(RawScalar::U32), + fixed_count: None, + bitfield: false, + flexible_array: false, + }, + ); + synthetic_layout_evidence(native); + let function = project_one(raw); + let layout = function.runtime.parameters[1] + .pointee_aggregate + .as_ref() + .unwrap(); + assert_eq!(layout.x64.fields[0].name, "inputOnly"); + assert_eq!( + layout.output_fields, + ["dwProcessId", "dwThreadId", "hProcess", "hThread"] + ); + let shape = function.runtime.signature_shape(64); + assert_eq!(shape.result_type(field_target(0)).unwrap(), NativeType::U32); + assert_eq!( + shape.result_type(field_target(2)).unwrap(), + NativeType::Handle + ); + assert!( + shape + .result_type(ResultTarget::Parameter { index: 1 }) + .is_err() + ); + assert!(shape.result_type(field_target(4)).is_err()); +} + +#[test] +fn input_pointees_and_unproven_output_field_names_do_not_acquire_result_contracts() { + let mut raw = raw_result_function(RawDirection::In); + let input = project_one(raw.clone()); + assert!(input.runtime.parameters[1].pointee_aggregate.is_none()); + assert!( + input.runtime.signature_shape(64).parameters[1] + .result_fields + .is_empty() + ); + + raw.parameters[1].direction = RawDirection::Out; + let native = raw_layout(&mut raw); + native.evidence = None; + for field in &mut native.variants[0].fields { + field.typ = scalar(RawScalar::U32); + } + let RawBaseType::Named { + namespace, name, .. + } = &mut raw.parameters[1].typ.base + else { + unreachable!() + }; + *namespace = "Tests".into(); + *name = "UnprovenFields".into(); + let output = project_one(raw); + assert!(output.runtime.parameters[1].pointee_aggregate.is_none()); + assert!( + output.runtime.signature_shape(64).parameters[1] + .result_fields + .is_empty() + ); +} + +#[test] +fn dropped_pointee_contracts_and_invalid_field_targets_fail_before_dispatch() { + let base = semantic(&raw_result_function(RawDirection::Out)); + let function = project::project_function(&base).unwrap(); + let mut runtime = function.runtime.clone(); + runtime.parameters[1].pointee_aggregate = None; + assert!( + runtime + .call_contract + .validate_signature(&runtime.signature_shape(64)) + .is_err() + ); + for target in [ + field_target(4), + field_target(usize::MAX), + ResultTarget::AggregateField { + parameter: 0, + field: 0, + }, + ResultTarget::AggregateField { + parameter: 99, + field: 0, + }, + ResultTarget::Parameter { index: 1 }, + ] { + let mut native = base.clone(); + native.result_contracts.push(ResultContract { + target, + on_success: ResultPolicy::Undefined {}, + on_failure: ResultPolicy::Undefined {}, + overrides: Vec::new(), + }); + assert!(project::project_function(&native).is_err(), "{target:?}"); + } + for direction in [Direction::Out, Direction::InOut] { + let mut shape = function.runtime.signature_shape(64); + shape.parameters[1].direction = direction; + assert!( + function + .runtime + .call_contract + .validate_signature(&shape) + .is_err() + ); + } + let mut shape = function.runtime.signature_shape(64); + shape.parameters[1].result_fields[0].typ = NativeType::U32; + assert!( + function + .runtime + .call_contract + .validate_signature(&shape) + .is_err() + ); +} + +#[test] +fn aggregate_result_layout_drift_never_silently_drops_or_reinterprets_owned_fields() { + let base = semantic(&raw_result_function(RawDirection::Out)); + let mutations: &[fn(&mut NativeLayout)] = &[ + |layout| layout.output_fields.clear(), + |layout| { + layout.output_fields.remove(0); + }, + |layout| layout.output_fields.push("unknown".into()), + |layout| layout.output_fields.push(layout.output_fields[0].clone()), + |layout| layout.output_fields.swap(0, 1), + |layout| layout.kind = NativeAggregateKind::Union, + |layout| layout.x64.fields[0].typ = NativeFieldType::Pointer, + |layout| { + layout.x64.fields[0].typ = NativeFieldType::Handle { + cleanup: Cleanup::None, + } + }, + |layout| { + layout.x64.fields[0].typ = NativeFieldType::Handle { + cleanup: Cleanup::RegCloseKey, + } + }, + |layout| layout.x64.fields[0].count = 2, + |layout| layout.x64.fields[1].offset = 0, + |layout| layout.x64.fields[3].offset = layout.x64.size, + |layout| layout.x86.fields[0].typ = NativeFieldType::Scalar(NativeScalar::U32), + |layout| layout.arm64.fields[3].name = layout.arm64.fields[2].name.clone(), + |layout| layout.arm64.size = 1, + |layout| layout.arm64.alignment = 0, + ]; + for (index, mutate) in mutations.iter().enumerate() { + let mut native = base.clone(); + mutate(layout(&mut native)); + assert!( + project::project_function(&native).is_err(), + "layout mutation {index}" + ); + } +} + +#[test] +fn field_policies_require_exact_scalar_or_independent_handle_ownership() { + let base = semantic(&raw_result_function(RawDirection::Out)); + for (field, ownership) in [ + (0, ResultOwnership::Value {}), + (0, ResultOwnership::Borrowed {}), + (0, ResultOwnership::AliasInput { parameter: 0 }), + ( + 0, + ResultOwnership::Owned { + cleanup: Cleanup::None, + }, + ), + ( + 0, + ResultOwnership::Owned { + cleanup: Cleanup::RegCloseKey, + }, + ), + ( + 2, + ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle, + }, + ), + (2, ResultOwnership::Borrowed {}), + ] { + let mut native = base.clone(); + native.result_contracts.push(ResultContract { + target: field_target(field), + on_success: ResultPolicy::delivered(ownership), + on_failure: ResultPolicy::Undefined {}, + overrides: Vec::new(), + }); + assert!( + project::project_function(&native).is_err(), + "{field}: {ownership:?}" + ); + } + let mut native = base; + native.result_contracts = vec![ + ResultContract { + target: field_target(0), + on_success: ResultPolicy::delivered(ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle, + }), + on_failure: ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle, + }), + overrides: Vec::new(), + }, + ResultContract { + target: field_target(2), + on_success: ResultPolicy::delivered(ResultOwnership::Value {}), + on_failure: ResultPolicy::delivered(ResultOwnership::Value {}), + overrides: Vec::new(), + }, + ]; + let projected = project::project_function(&native).unwrap(); + for evidence in &native.result_contracts { + assert_eq!( + projected.runtime.call_contract.result(evidence.target), + Some(evidence) + ); + } + assert_eq!( + projected + .runtime + .call_contract + .result(field_target(1)) + .unwrap() + .on_failure, + ResultPolicy::Undefined {} + ); +} + +#[test] +fn new_owned_union_array_nested_and_cleanup_mismatches_fail_closed() { + for mutation in [ + (|layout: &mut RawNativeLayoutSet| layout.variants[0].kind = RawLayoutKind::Union) + as fn(&mut RawNativeLayoutSet), + |layout| layout.variants[0].fields[0].fixed_count = Some(2), + |layout| { + let RawBaseType::Named { + kind: RawNamedKind::Handle { cleanup }, + .. + } = &mut layout.variants[0].fields[0].typ.base + else { + unreachable!() + }; + *cleanup = Some("RegCloseKey".into()); + }, + ] { + let mut raw = raw_result_function(RawDirection::Out); + mutation(raw_layout(&mut raw)); + synthetic_layout_evidence(raw_layout(&mut raw)); + assert!( + project_apis(&apis(vec![raw])) + .projected + .functions + .is_empty() + ); + } + let mut raw = raw_result_function(RawDirection::Out); + let mut nested = raw.parameters[1].typ.clone(); + nested.pointer_depth = 0; + let native = raw_layout(&mut raw); + native.evidence = None; + native.variants[0].fields = vec![RawNativeField { + name: "nested".into(), + typ: nested, + fixed_count: None, + bitfield: false, + flexible_array: false, + }]; + let RawBaseType::Named { + namespace, name, .. + } = &mut raw.parameters[1].typ.base + else { + unreachable!() + }; + *namespace = "Tests".into(); + *name = "NestedResults".into(); + let projected = project_apis(&apis(vec![raw])); + assert!(projected.projected.functions.is_empty()); + assert!( + projected.omitted[0] + .reason + .contains("nested native aggregate result fields") + ); +} + +#[test] +fn rendered_wrappers_delegate_field_lifetimes_before_any_javascript_result_operation() { + let (generated, omitted) = generate_apis_files( + &apis(vec![raw_result_function(RawDirection::Out)]), + "@test/runtime/win32", + ); + assert!(omitted.is_empty()); + assert!(!generated.js.contains("prepareNativeStructCall")); + assert!(!generated.js.contains("markNativeStructCallResult")); + assert!( + generated + .js + .contains("pointeeDescriptor: _nativeLayout_PROCESS_INFORMATION") + ); + run_js( + &generated, + r#" +const assert = require('node:assert/strict') +let failAt +let invoked = 0 +const owned = new Map() +const runtime = {DynWin32: { + u32: value => value, + toBoolean(value) { if (failAt === 'convert') throw new Error('convert'); return value !== 0 }, + toNumber: value => value, + createNativeStruct(descriptor) { return { descriptor, length: JSON.parse(descriptor).x64.size } }, + nativeStruct(value, descriptor, nullable) { + assert.equal(nullable, false) + assert.equal(value.descriptor, descriptor) + return value + }, + takeNativeStructResource(value, descriptor, field, cleanup) { + assert.equal(value.descriptor, descriptor) + assert.equal(cleanup, 'closeHandle') + const fields = owned.get(value) + const resource = fields.get(field) + fields.delete(field) + return resource + }, + getNativeStructU32(value, descriptor, field) { + assert.equal(value.descriptor, descriptor) + return owned.get(value).get(field) + }, + prepareNativeStructCall() { throw new Error('JS preparation is not a native ownership boundary') }, + markNativeStructCallResult() { throw new Error('JS cannot register native field lifetimes') }, +}, DynWin32Function: {bind(spec) { + const parameter = spec.parameters[1] + assert.equal(parameter.type, 'pointer') + assert.equal(parameter.direction, 'in') + assert.equal(parameter.aggregateDescriptor, undefined) + assert.equal(parameter.cleanup, 'none') + const layout = JSON.parse(parameter.pointeeDescriptor) + assert.deepEqual(layout.outputFields, ['hProcess','hThread','dwProcessId','dwThreadId']) + const contract = JSON.parse(spec.callContractDescriptor) + assert.equal(contract.version, 3) + assert.equal(contract.results.length, 6) + for (let field = 0; field < 4; field++) { + const result = contract.results.find(result => result.target.kind === 'aggregate-field' && result.target.field === field) + assert.equal(result.target.parameter, 1) + assert.deepEqual(result.onSuccess, { + kind: 'defined', + ownership: field < 2 ? {kind: 'owned', cleanup: 'close-handle'} : {kind: 'value'}, + delivery: 'deliver' + }) + assert.deepEqual(result.onFailure, {kind: 'undefined'}) + } + return {invoke([flags, record]) { + assert.equal(record.descriptor, parameter.pointeeDescriptor) + invoked++ + // The native adapter must have registered field owners before wrapping its return. + owned.set(record, new Map([ + ['hProcess', {kind:'process', call:invoked}], + ['hThread', {kind:'thread', call:invoked}], + ['dwProcessId', 31], ['dwThreadId', 47] + ])) + if (failAt === 'wrap') throw new Error('wrap') + return { + get returnValue() { if (failAt === 'returnValue') throw new Error('returnValue'); return 1 }, + get outputs() { if (failAt === 'outputs') throw new Error('outputs'); return [7] }, + get succeeded() { throw new Error('JS success marking is forbidden') }, + lastError: 0 + } + }} +}}} +"#, + r#" +for (failAt of ['wrap', 'returnValue', 'outputs', 'convert', undefined]) { + const record = projected.createProcessInformation() + if (failAt) assert.throws(() => projected.produceRecord(0, record), new RegExp(failAt)) + else assert.equal(projected.produceRecord(0, record).count, 7) + const process = projected.takeProcessInformationProcess(record) + const thread = projected.takeProcessInformationThread(record) + assert.equal(process.kind, 'process') + assert.equal(thread.kind, 'thread') + assert.notEqual(process, thread) + assert.equal(process.call, invoked) + assert.equal(thread.call, invoked) + assert.equal(projected.getProcessInformationProcessId(record), 31) + assert.equal(projected.getProcessInformationThreadId(record), 47) +} +assert.equal(invoked, 5) +"#, + ); +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/call_contract_json_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/call_contract_json_tests.rs new file mode 100644 index 00000000..635af638 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/call_contract_json_tests.rs @@ -0,0 +1,434 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use serde_json::{Value, json}; + +fn descriptor() -> Value { + json!({ + "version": 1, + "outputs": [ + { + "parameter": 2, + "when": { + "inputs": [{ + "kind": "bits-in", "parameter": 0, "mask": 255, "values": [7, 9] + }], + "returnValue": 234, + "succeeded": null + }, + "action": {"kind": "unavailable"} + }, + { + "parameter": 4, + "when": { + "inputs": [ + {"kind": "null-or-empty", "parameter": 1, "elementWidth": 2}, + {"kind": "handle-in", "parameter": 0, "values": [-2147483646]} + ], + "returnValue": null, + "succeeded": null + }, + "action": {"kind": "alias-input", "parameter": 0} + } + ], + "resourceEffects": [{ + "kind": "add-file-completion-modes", "handleParameter": 0, "flagsParameter": 3 + }] + }) +} + +#[test] +fn native_call_contract_wire_roundtrips_closed_data_and_defaults() { + let value = descriptor(); + let contract: CallContract = serde_json::from_value(value.clone()).unwrap(); + contract.validate_structure().unwrap(); + assert_eq!(serde_json::to_value(contract).unwrap(), value); + assert!( + serde_json::from_str::("{}") + .unwrap() + .is_empty() + ); + assert_eq!( + serde_json::from_str::("{}").unwrap(), + Condition::default() + ); + for data in [ + r#"{"inputs":[]}"#, + r#"{"returnValue":null}"#, + r#"{"inputs":[],"returnValue":null}"#, + ] { + assert_eq!( + serde_json::from_str::(data).unwrap(), + Condition::default() + ); + } + let mut value = descriptor(); + value["outputs"][0]["when"]["returnValue"] = u64::MAX.into(); + let condition = &serde_json::from_value::(value) + .unwrap() + .outputs[0] + .when; + assert_eq!(condition.return_value, Some(u64::MAX)); + let handles = InputPredicate::HandleIn { + parameter: 0, + values: vec![i64::MIN, -2147483646, 0, i64::MAX], + }; + assert_eq!( + serde_json::from_str::(&serde_json::to_string(&handles).unwrap()).unwrap(), + handles + ); + for data in [ + r#"{"kind":"handle-in","parameter":0,"values":[9223372036854775808]}"#, + r#"{"kind":"handle-in","parameter":0,"values":[-9223372036854775809]}"#, + r#"{"kind":"handle-in","parameter":0,"values":[-2147483646],"mask":4294967295}"#, + ] { + assert!( + serde_json::from_str::(data).is_err(), + "{data}" + ); + } +} + +#[test] +fn native_call_contract_rejects_unknown_fields_and_missing_required_roles() { + for path in [ + "", + "/outputs/0", + "/outputs/0/when", + "/outputs/0/when/inputs/0", + "/outputs/0/action", + "/outputs/1/when/inputs/0", + "/outputs/1/when/inputs/1", + "/outputs/1/action", + "/resourceEffects/0", + ] { + let mut value = descriptor(); + value + .pointer_mut(path) + .unwrap() + .as_object_mut() + .unwrap() + .insert("script".into(), "arbitrary()".into()); + assert!( + serde_json::from_value::(value).is_err(), + "{path}" + ); + } + for (path, fields) in [ + ("/outputs/0", &["parameter", "when", "action"][..]), + ( + "/outputs/0/when/inputs/0", + &["kind", "parameter", "mask", "values"][..], + ), + ( + "/outputs/1/when/inputs/0", + &["kind", "parameter", "elementWidth"][..], + ), + ( + "/outputs/1/when/inputs/1", + &["kind", "parameter", "values"][..], + ), + ("/outputs/0/action", &["kind"][..]), + ("/outputs/1/action", &["kind", "parameter"][..]), + ( + "/resourceEffects/0", + &["kind", "handleParameter", "flagsParameter"][..], + ), + ] { + for field in fields { + let mut value = descriptor(); + value + .pointer_mut(path) + .unwrap() + .as_object_mut() + .unwrap() + .remove(*field); + assert!( + serde_json::from_value::(value).is_err(), + "{path}/{field}" + ); + } + } + for data in [ + r#"{"outputs":null}"#, + r#"{"resourceEffects":null}"#, + r#"{"outputs":[{"parameter":0,"when":null,"action":{"kind":"unavailable"}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{"returnValue":-1},"action":{"kind":"unavailable"}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{"returnValue":18446744073709551616},"action":{"kind":"unavailable"}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{"returnValue":"234"},"action":{"kind":"unavailable"}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{"inputs":null},"action":{"kind":"unavailable"}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{},"action":{"unavailable":{}}}]}"#, + r#"{"outputs":[{"parameter":0,"when":{},"action":{"kind":"execute","code":"unchecked()"}}]}"#, + r#"{"resourceEffects":[{"kind":"custom-adapter","name":"arbitrary"}]}"#, + ] { + assert!( + serde_json::from_str::(data).is_err(), + "{data}" + ); + } +} + +#[test] +fn native_call_contract_bounds_and_ambiguous_rules_fail_closed() { + let mutations: &[fn(&mut Value)] = &[ + |v| v["outputs"][0]["parameter"] = 1024.into(), + |v| v["outputs"][0]["parameter"] = (-1).into(), + |v| v["outputs"][1]["parameter"] = v["outputs"][0]["parameter"].clone(), + |v| v["outputs"][0]["when"]["inputs"][0]["parameter"] = 1024.into(), + |v| v["outputs"][0]["when"]["inputs"][0]["mask"] = 0.into(), + |v| v["outputs"][0]["when"]["inputs"][0]["mask"] = (-1).into(), + |v| v["outputs"][0]["when"]["inputs"][0]["values"] = json!([]), + |v| v["outputs"][0]["when"]["inputs"][0]["values"] = json!([7, 7]), + |v| v["outputs"][0]["when"]["inputs"][0]["values"] = json!([256]), + |v| v["outputs"][0]["when"]["inputs"][0]["values"] = json!([7.5]), + |v| v["outputs"][0]["when"]["inputs"][0]["values"] = json!((0..65).collect::>()), + |v| { + let predicate = v["outputs"][0]["when"]["inputs"][0].clone(); + v["outputs"][0]["when"]["inputs"] = json!(vec![predicate; 17]); + }, + |v| v["outputs"][1]["when"]["inputs"][0]["elementWidth"] = 0.into(), + |v| v["outputs"][1]["when"]["inputs"][0]["elementWidth"] = 3.into(), + |v| v["outputs"][1]["when"]["inputs"][0]["elementWidth"] = 257.into(), + |v| v["outputs"][1]["when"]["inputs"][1]["parameter"] = 1024.into(), + |v| v["outputs"][1]["when"]["inputs"][1]["values"] = json!([]), + |v| v["outputs"][1]["when"]["inputs"][1]["values"] = json!([-2147483646, -2147483646]), + |v| v["outputs"][1]["when"]["inputs"][1]["values"] = json!((0..65).collect::>()), + |v| v["outputs"][1]["when"]["inputs"][1]["values"] = json!([-1.5]), + |v| v["outputs"][1]["when"]["inputs"][1]["values"] = json!(["-2147483646"]), + |v| v["outputs"][1]["action"]["parameter"] = 4.into(), + |v| v["outputs"][1]["action"]["parameter"] = 1024.into(), + |v| v["resourceEffects"][0]["handleParameter"] = 1024.into(), + |v| v["resourceEffects"][0]["flagsParameter"] = 1024.into(), + |v| v["resourceEffects"][0]["flagsParameter"] = 0.into(), + |v| { + let effect = v["resourceEffects"][0].clone(); + v["resourceEffects"].as_array_mut().unwrap().push(effect); + }, + ]; + for (index, mutate) in mutations.iter().enumerate() { + let mut value = descriptor(); + mutate(&mut value); + let accepted = serde_json::from_value::(value) + .is_ok_and(|contract| contract.validate_structure().is_ok()); + assert!(!accepted, "mutation {index}"); + } +} + +#[test] +fn native_call_contract_schema_is_closed_at_every_wire_level() { + let schema: Value = serde_json::from_str(CALL_CONTRACT_SCHEMA).unwrap(); + assert_eq!(schema["additionalProperties"], false); + for name in [ + "OutputRule", + "Condition", + "ResultContract", + "ResultOverride", + ] { + assert_eq!( + schema["$defs"][name]["additionalProperties"], false, + "{name}" + ); + } + for name in [ + "InputPredicate", + "OutputAction", + "ResourceEffect", + "ResultTarget", + "ResultPolicy", + "ResultOwnership", + ] { + for variant in schema["$defs"][name]["oneOf"].as_array().unwrap() { + assert_eq!(variant["additionalProperties"], false, "{name}"); + assert_eq!( + variant["required"] + .as_array() + .unwrap() + .iter() + .map(|field| field.as_str().unwrap()) + .collect::>(), + variant["properties"] + .as_object() + .unwrap() + .keys() + .map(String::as_str) + .collect(), + "{name}" + ); + } + } + assert_eq!(schema["properties"]["version"]["default"], json!(1)); + assert_eq!( + schema["$defs"]["Condition"]["properties"]["inputs"]["default"], + json!([]) + ); + assert_eq!( + schema["$defs"]["Condition"]["properties"]["returnValue"]["default"], + Value::Null + ); + assert_eq!( + schema["$defs"]["Condition"]["properties"]["succeeded"]["default"], + Value::Null + ); +} + +fn result_descriptor() -> Value { + json!({ + "version": 3, + "results": [{ + "target": {"kind":"return"}, + "onSuccess": {"kind":"defined","ownership":{"kind":"owned","cleanup":"close-handle"},"delivery":"deliver"}, + "onFailure": {"kind":"undefined"}, + "overrides": [{ + "when":{"succeeded":false,"inputs":[],"returnValue":null}, + "policy":{"kind":"defined","ownership":{"kind":"owned","cleanup":"close-handle"},"delivery":"discard"} + }] + }], + "resourceEffects":[] + }) +} + +#[test] +fn shared_version_decoder_preserves_legacy_and_current_evidence_without_mixing_protocols() { + let legacy = descriptor(); + let mut unversioned = legacy.clone(); + unversioned.as_object_mut().unwrap().remove("version"); + assert_eq!( + CallContract::decode(&legacy.to_string()).unwrap(), + CallContract::decode(&unversioned.to_string()).unwrap() + ); + let current = result_descriptor(); + for version in [ + dynwinrt_win32_contracts::SLOT_VERSION, + dynwinrt_win32_contracts::CURRENT_VERSION, + ] { + let mut value = current.clone(); + value["version"] = version.into(); + assert_eq!( + serde_json::to_value(CallContract::decode(&value.to_string()).unwrap()).unwrap(), + value + ); + } + for value in [ + json!({"version":0}), + json!({"version":4}), + json!({"version":"3"}), + json!({"version":2,"outputs":legacy["outputs"]}), + json!({"results":current["results"]}), + json!({"version":1,"results":current["results"]}), + json!({"version":2,"results":null}), + ] { + assert!(CallContract::decode(&value.to_string()).is_err(), "{value}"); + } + assert!( + CallContract::decode(&" ".repeat(dynwinrt_win32_contracts::MAX_CONTRACT_BYTES + 1)) + .is_err() + ); +} + +#[test] +fn aggregate_field_wire_targets_require_version_three_and_closed_bounded_indices() { + let mut value = result_descriptor(); + value["results"][0]["target"] = json!({"kind":"aggregate-field","parameter":9,"field":1}); + let contract = CallContract::decode(&value.to_string()).unwrap(); + assert_eq!( + contract.results[0].target, + super::ResultTarget::AggregateField { + parameter: 9, + field: 1 + } + ); + for version in [1, 2] { + let mut old = value.clone(); + old["version"] = version.into(); + assert!(CallContract::decode(&old.to_string()).is_err()); + } + for target in [ + json!({"kind":"aggregate-field","parameter":9}), + json!({"kind":"aggregate-field","field":1}), + json!({"kind":"aggregate-field","parameter":-1,"field":1}), + json!({"kind":"aggregate-field","parameter":9,"field":-1}), + json!({"kind":"aggregate-field","parameter":1024,"field":0}), + json!({"kind":"aggregate-field","parameter":9,"field":1024}), + json!({"kind":"aggregate-field","parameter":9,"field":1,"offset":8}), + json!({"kind":"aggregate-field","parameter":9,"field":"1"}), + ] { + value["results"][0]["target"] = target; + assert!(CallContract::decode(&value.to_string()).is_err(), "{value}"); + } +} + +#[test] +fn shared_result_evidence_is_closed_and_keeps_validity_ownership_and_delivery_separate() { + for path in [ + "", + "/results/0", + "/results/0/target", + "/results/0/onSuccess", + "/results/0/onSuccess/ownership", + "/results/0/onFailure", + "/results/0/overrides/0", + "/results/0/overrides/0/when", + "/results/0/overrides/0/policy", + "/results/0/overrides/0/policy/ownership", + ] { + let mut value = result_descriptor(); + value.pointer_mut(path).unwrap()["code"] = "unchecked()".into(); + assert!(CallContract::decode(&value.to_string()).is_err(), "{path}"); + } + let mutations: &[fn(&mut Value)] = &[ + |v| { + v["results"][0]["onFailure"]["ownership"] = + json!({"kind":"owned","cleanup":"close-handle"}); + }, + |v| { + v["results"][0]["onSuccess"]["ownership"]["cleanup"] = "none".into(); + }, + |v| { + v["results"][0]["onSuccess"]["ownership"]["cleanup"] = "unknown".into(); + }, + |v| { + v["results"][0]["onSuccess"]["ownership"]["cleanup"] = json!({"close-handle":null}); + }, + |v| { + v["results"][0]["onSuccess"]["delivery"] = json!({"deliver":null}); + }, + |v| { + v["results"][0]["onSuccess"]["delivery"] = "undefined".into(); + }, + |v| { + v["results"][0]["onSuccess"] + .as_object_mut() + .unwrap() + .remove("ownership"); + }, + |v| { + v["results"][0]["onSuccess"] + .as_object_mut() + .unwrap() + .remove("delivery"); + }, + |v| { + v["results"][0].as_object_mut().unwrap().remove("onFailure"); + }, + |v| { + v["results"][0]["target"] = json!({"kind":"parameter","index":-1}); + }, + |v| { + let duplicate = v["results"][0].clone(); + v["results"].as_array_mut().unwrap().push(duplicate); + }, + |v| { + let case = v["results"][0]["overrides"][0].clone(); + v["results"][0]["overrides"] = json!(vec![case; 33]); + }, + ]; + for (index, mutate) in mutations.iter().enumerate() { + let mut value = result_descriptor(); + mutate(&mut value); + assert!( + CallContract::decode(&value.to_string()).is_err(), + "mutation {index}" + ); + } +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/call_contract_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/call_contract_tests.rs new file mode 100644 index 00000000..6f173f26 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/call_contract_tests.rs @@ -0,0 +1,488 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::{ir::*, test_support::*, *}; +use crate::win32_metadata::*; + +fn conditional_function() -> FunctionContract { + let handle = RawType { + base: RawBaseType::Named { + namespace: "Tests.Resources".into(), + name: "NATIVE_FILE_HANDLE".into(), + kind: RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }; + let mut string = parameter( + "subKey", + RawType { + base: RawBaseType::Named { + namespace: "Tests.Strings".into(), + name: "NATIVE_WIDE_STRING".into(), + kind: RawNamedKind::StringPointer { + encoding: RawStringEncoding::Utf16, + }, + }, + pointer_depth: 0, + constness: RawConstness::Const, + }, + RawDirection::In, + ); + string.nullable = true; + let mut alias = parameter( + "pAlias", + pointer(handle.clone(), 1, RawConstness::Mutable), + RawDirection::Out, + ); + alias.free_with = Some("CloseHandle".into()); + let mut data = parameter( + "data", + pointer(scalar(RawScalar::U8), 1, RawConstness::Mutable), + RawDirection::Out, + ); + data.buffer = Some(RawBuffer { + element: scalar(RawScalar::U8), + size: RawBufferSize::ByteCountParam(4), + }); + let mut raw = synthetic_function("ConditionalNative"); + raw.return_status = RawStatusSemantics::ZeroIsSuccess; + raw.parameters = vec![ + parameter( + "tag", + pointer(scalar(RawScalar::I16), 1, RawConstness::Mutable), + RawDirection::Out, + ), + parameter("file", handle, RawDirection::In), + string, + alias, + parameter( + "count", + pointer(scalar(RawScalar::U32), 1, RawConstness::Mutable), + RawDirection::InOut, + ), + parameter("flags", scalar(RawScalar::U8), RawDirection::In), + data, + ]; + let mut function = semantic(&raw); + function.call_contract = CallContract { + outputs: vec![ + OutputRule { + parameter: 3, + when: Condition { + inputs: vec![InputPredicate::NullOrEmpty { + parameter: 2, + element_width: 2, + }], + return_value: None, + ..Condition::default() + }, + action: OutputAction::AliasInput { parameter: 1 }, + }, + OutputRule { + parameter: 4, + when: Condition { + inputs: vec![InputPredicate::BitsIn { + parameter: 1, + mask: 0xff, + values: vec![7], + }], + return_value: Some(234), + ..Condition::default() + }, + action: OutputAction::Unavailable {}, + }, + ], + resource_effects: vec![ResourceEffect::AddFileCompletionModes { + handle_parameter: 1, + flags_parameter: 5, + }], + ..CallContract::default() + }; + function +} + +#[test] +fn native_call_rules_keep_native_indices_through_hidden_inputs_and_output_slots() { + let function = conditional_function(); + let projected = project::project_function(&function).unwrap(); + let resolved = function + .call_contract + .upgrade_metadata(&projected.runtime.signature_shape(64)) + .unwrap(); + assert_eq!(projected.runtime.call_contract, resolved); + assert_eq!( + projected + .parameters + .iter() + .map(|p| p.name.as_str()) + .collect::>(), + ["file", "subKey", "flags", "data"] + ); + assert_eq!( + projected.runtime.parameters[3].cleanup, + Cleanup::CloseHandle + ); + assert_eq!(projected.runtime.parameters[4].direction, Direction::InOut); + assert_eq!( + projected.inputs[2], + InputExpression::BufferLength { + parameter_index: 3, + divisor: 1, + abi: AbiType::U32, + } + ); + let ReturnShape::Object { outputs, .. } = &projected.return_shape else { + panic!("native output slots") + }; + assert_eq!( + outputs, + &[ + ProjectedOutput { + name: "tag".into(), + output_index: 0, + typ: SurfaceType::Number, + conversion: Conversion::Number, + may_be_unavailable: false, + }, + ProjectedOutput { + name: "alias".into(), + output_index: 1, + typ: SurfaceType::ResourceOrHandle, + conversion: Conversion::ResourceOrHandle, + may_be_unavailable: true, + }, + ProjectedOutput { + name: "count".into(), + output_index: 2, + typ: SurfaceType::Number, + conversion: Conversion::Number, + may_be_unavailable: true, + }, + ] + ); + let mut renamed = function.clone(); + renamed.name = "UnrelatedNativeOperation".into(); + renamed.entry_point = "DifferentExport".into(); + renamed.dll = "other-native.dll".into(); + assert_eq!( + project::project_function(&renamed) + .unwrap() + .runtime + .call_contract, + resolved + ); + let generated = render::render( + &ProjectedApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![projected], + enums: Vec::new(), + native_builders: Vec::new(), + async_functions: Vec::new(), + }, + "@test/runtime/win32", + ); + assert!(generated.dts.contains("readonly count: number | null")); + assert!( + generated + .dts + .contains("readonly alias: DynWin32Resource | bigint | null") + ); + run_js( + &generated, + &format!( + r#" +const assert=require('node:assert/strict') +const expected={} +const unavailable=Symbol('native unavailable') +const owner={{}} +let count=unavailable +let alias=owner +let status=0 +let binds=0 +let reads=0 +const runtime={{DynWin32:{{ + handle:value=>value,wideString:value=>value,u8:value=>value,u32:value=>value, + dataPointer:value=>value,byteLength:value=>value.length, + isUnavailable:value=>value===unavailable, + toNumber(value) {{ assert.notEqual(value,unavailable); return Number(value) }}, + toResourceOrHandle:value=>value +}},DynWin32Function:{{bind(spec){{ + binds++ + assert.equal(typeof spec.callContractDescriptor,'string') + assert.deepEqual(JSON.parse(spec.callContractDescriptor),expected) + assert.equal(spec.parameters[3].cleanup,'closeHandle') + return {{invoke(args){{ + assert.equal(args[0],owner) + assert.equal(args[2],4) + assert.equal(args[3],3) + assert.equal(args[4].length,4) + return {{returnValue:status,get outputs(){{reads++;return [-5,alias,count]}}}} + }}}} +}}}}}} +"#, + serde_json::to_string(&resolved).unwrap() + ), + r#" +for(const nativeAlias of [owner,77n,null]) { + alias=nativeAlias + for(const nativeCount of [unavailable,4096]) { + count=nativeCount + status=count===unavailable ? 0 : 234 + const result=projected.conditionalNative(owner,'not empty',3,Buffer.alloc(4)) + assert.equal(result.status,status) + assert.equal(result.tag,-5) + assert.equal(result.alias,nativeAlias) + assert.equal(result.count,count===unavailable ? null : 4096) + } +} +assert.equal(binds,1) +assert.equal(reads,6) +"#, + ); +} + +#[test] +fn native_handle_predicates_preserve_signed_constants_and_require_handle_inputs() { + let mut function = conditional_function(); + let predicate = InputPredicate::HandleIn { + parameter: 1, + values: vec![i64::MIN, -2147483646, 0, i64::MAX], + }; + function.call_contract.outputs[0] + .when + .inputs + .push(predicate.clone()); + let projected = project::project_function(&function).unwrap(); + assert_eq!( + projected.runtime.call_contract, + function + .call_contract + .upgrade_metadata(&projected.runtime.signature_shape(64)) + .unwrap() + ); + assert_eq!( + projected + .runtime + .call_contract + .result(ResultTarget::Parameter { index: 3 }) + .unwrap() + .overrides[0] + .when + .inputs[1], + predicate + ); + assert_eq!( + projected + .runtime + .call_contract + .result(ResultTarget::Parameter { index: 3 }) + .unwrap() + .overrides[0] + .policy, + ResultPolicy::delivered(ResultOwnership::AliasInput { parameter: 1 }) + ); + for index in [0, 2, 3, 4, 5, 6, 99] { + let mut invalid = function.clone(); + invalid.call_contract.outputs[0].when.inputs[1] = InputPredicate::HandleIn { + parameter: index, + values: vec![-2147483646], + }; + assert!( + project::project_function(&invalid).is_err(), + "parameter {index}" + ); + } + let mutations: &[fn(&mut FunctionContract)] = &[ + |f| f.parameters[1].abi = AbiType::U64, + |f| f.parameters[1].typ = ValueType::Scalar(Scalar::NativeIsize), + |f| f.parameters[1].direction = Direction::Out, + |f| f.parameters[1].pointer_depth = 1, + ]; + for (index, mutate) in mutations.iter().enumerate() { + let mut invalid = function.clone(); + mutate(&mut invalid); + assert!( + project::project_function(&invalid).is_err(), + "mutation {index}" + ); + } +} + +#[test] +fn native_call_rule_shapes_fail_before_projection() { + let mutations: &[(&str, fn(&mut FunctionContract))] = &[ + ("missing output", |f| { + f.call_contract.outputs[0].parameter = 99 + }), + ("input target", |f| f.call_contract.outputs[0].parameter = 1), + ("caller buffer target", |f| { + f.call_contract.outputs[1].parameter = 6 + }), + ("duplicate output", |f| { + f.call_contract + .outputs + .push(f.call_contract.outputs[0].clone()); + }), + ("alias to non-handle", |f| { + f.call_contract.outputs[0].action = OutputAction::AliasInput { parameter: 5 }; + }), + ("alias to output", |f| { + f.call_contract.outputs[0].action = OutputAction::AliasInput { parameter: 0 }; + }), + ("missing alias input", |f| { + f.call_contract.outputs[0].action = OutputAction::AliasInput { parameter: 99 }; + }), + ("non-owning alias target", |f| { + f.parameters[3].cleanup = Cleanup::None + }), + ("alias cleanup mismatch", |f| { + f.parameters[3].cleanup = Cleanup::RegCloseKey + }), + ("consuming alias input", |f| { + f.parameters[1].consumes_resource = true + }), + ("owning alias input", |f| { + f.parameters[1].cleanup = Cleanup::CloseHandle + }), + ("indirect alias input", |f| { + f.parameters[1].pointer_depth = 1 + }), + ("InOut alias target", |f| { + f.parameters[3].direction = Direction::InOut + }), + ("missing predicate input", |f| { + f.call_contract.outputs[0].when.inputs[0] = InputPredicate::NullOrEmpty { + parameter: 99, + element_width: 2, + }; + }), + ("wrong string encoding width", |f| { + f.call_contract.outputs[0].when.inputs[0] = InputPredicate::NullOrEmpty { + parameter: 2, + element_width: 1, + }; + }), + ("unclassified data pointer", |f| { + f.parameters[2].typ = ValueType::DataPointer + }), + ("string pointer slot", |f| f.parameters[2].pointer_depth = 1), + ("output string", |f| { + f.parameters[2].direction = Direction::Out + }), + ("pointer bits", |f| { + f.call_contract.outputs[1].when.inputs[0] = InputPredicate::BitsIn { + parameter: 2, + mask: 255, + values: vec![7], + }; + }), + ("output bits", |f| { + f.call_contract.outputs[1].when.inputs[0] = InputPredicate::BitsIn { + parameter: 0, + mask: 255, + values: vec![7], + }; + }), + ("overwide input bits", |f| { + f.call_contract.outputs[1].when.inputs[0] = InputPredicate::BitsIn { + parameter: 5, + mask: 256, + values: vec![256], + }; + }), + ("overwide return bits", |f| { + f.call_contract.outputs[1].when.return_value = Some(1 << 32); + }), + ("floating return condition", |f| { + f.return_abi = Some(AbiType::F32) + }), + ("void return condition", |f| f.return_abi = None), + ("non-file resource state", |f| { + f.parameters[1].resource_cleanup = Cleanup::RegCloseKey; + f.parameters[3].cleanup = Cleanup::RegCloseKey; + }), + ("wide file modes", |f| { + f.parameters[5].abi = AbiType::U16; + f.parameters[5].typ = ValueType::Scalar(Scalar::U16); + }), + ("indirect file modes", |f| f.parameters[5].pointer_depth = 1), + ("output file modes", |f| { + f.parameters[5].direction = Direction::Out + }), + ("missing file state role", |f| { + f.call_contract.resource_effects[0] = ResourceEffect::AddFileCompletionModes { + handle_parameter: 99, + flags_parameter: 5, + }; + }), + ("missing file flags role", |f| { + f.call_contract.resource_effects[0] = ResourceEffect::AddFileCompletionModes { + handle_parameter: 1, + flags_parameter: 99, + }; + }), + ("duplicate file state role", |f| { + f.call_contract + .resource_effects + .push(f.call_contract.resource_effects[0]); + }), + ]; + for (name, mutate) in mutations { + let mut function = conditional_function(); + mutate(&mut function); + assert!(model::validate_call_contract(&function).is_err(), "{name}"); + assert!(project::project_function(&function).is_err(), "{name}"); + } +} + +#[test] +fn native_bits_predicates_support_exact_signed_unsigned_and_inout_widths() { + for (scalar, abi, mask) in [ + (Scalar::I8, AbiType::I8, u8::MAX as u64), + (Scalar::U8, AbiType::U8, u8::MAX as u64), + (Scalar::I16, AbiType::I16, u16::MAX as u64), + (Scalar::U16, AbiType::U16, u16::MAX as u64), + (Scalar::Bool32, AbiType::Bool32, u32::MAX as u64), + (Scalar::I32, AbiType::I32, u32::MAX as u64), + (Scalar::U32, AbiType::U32, u32::MAX as u64), + (Scalar::I64, AbiType::I64, u64::MAX), + (Scalar::U64, AbiType::U64, u64::MAX), + ] { + let mut function = conditional_function(); + function.call_contract.outputs.remove(0); + function.call_contract.resource_effects.clear(); + function.parameters[5].typ = ValueType::Scalar(scalar); + function.parameters[5].abi = abi; + function.call_contract.outputs[0].when.inputs = vec![InputPredicate::BitsIn { + parameter: 5, + mask, + values: vec![mask], + }]; + function.return_abi = Some(abi); + function.return_type = Some(ValueType::Scalar(scalar)); + function.call_contract.outputs[0].when.return_value = Some(mask); + model::validate_call_contract(&function).unwrap(); + if let Some(overwide) = mask.checked_add(1) { + function.call_contract.outputs[0].when.return_value = Some(overwide); + assert!(model::validate_call_contract(&function).is_err()); + function.call_contract.outputs[0].when.return_value = Some(mask); + function.call_contract.outputs[0].when.inputs = vec![InputPredicate::BitsIn { + parameter: 5, + mask: overwide, + values: vec![overwide], + }]; + assert!(model::validate_call_contract(&function).is_err()); + } + } + let mut function = conditional_function(); + function.call_contract.outputs[1].when.inputs = vec![InputPredicate::BitsIn { + parameter: 4, + mask: 0xffff_ffff, + values: vec![4], + }]; + assert!(project::project_function(&function).is_ok()); +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/contract_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/contract_tests.rs new file mode 100644 index 00000000..64e35413 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/contract_tests.rs @@ -0,0 +1,948 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +#[path = "call_contract_json_tests.rs"] +mod call_contract_json; +#[path = "contract_validation_tests.rs"] +mod validation; + +use crate::codegen::win32::{ + ir::{ + AbiType, CallingConvention, Condition, Conversion, Direction, EnumUnderlying, + InputExpression, InputPredicate, OutputAction, OutputRule, ProjectedOutput, ResourceEffect, + ReturnShape, RuntimeParameter, RuntimePlan, StringEncoding, SuccessRule, SurfaceParameter, + SurfaceType, ValueType, + }, + test_support::{metadata, metadata_function, project_one, semantic}, +}; +use crate::win32_metadata::{ + RawBaseType, RawBufferSize, RawCallingConvention, RawConstness, RawDirection, RawNamedKind, + RawStatusSemantics, +}; + +#[test] +fn win32_contracts_are_strict_and_integrity_checked() { + let registry = Registry::builtin().unwrap(); + let schema: serde_json::Value = serde_json::from_str(SCHEMA).unwrap(); + let dll_pattern = regex::Regex::new( + schema["$defs"]["functionSelector"]["properties"]["dll"]["pattern"] + .as_str() + .unwrap(), + ) + .unwrap(); + for entry in registry.functions.values() { + assert!(dll_pattern.is_match(&entry.selector.dll), "{}", entry.id); + } + assert!(registry.functions.contains_key(&( + "Windows.Win32.Foundation".into(), + "Apis".into(), + "FreeLibrary".into(), + ))); + assert!(matches!( + registry + .type_entry("Windows.Win32.Foundation", "BOOL") + .unwrap() + .meaning, + Some(TypeMeaning::Scalar { + scalar: RawScalar::Bool32 + }) + )); + assert!(Registry::load(MANIFEST, &format!("{SCHEMA} "), FILES).is_err()); + let mut changed = FILES.to_vec(); + let altered = format!("{} ", changed[0].1); + changed[0].1 = &altered; + assert!(Registry::load(MANIFEST, SCHEMA, &changed).is_err()); + let mut manifest: serde_json::Value = serde_json::from_str(MANIFEST).unwrap(); + manifest["unexpected"] = true.into(); + assert!(Registry::load(&manifest.to_string(), SCHEMA, FILES).is_err()); + for data in [ + r#"{"kind":"callback","body":"anything"}"#, + r#"{"kind":"borrowed-return","js":"unsafe()"}"#, + r#"{"kind":"owned-return","cleanup":"arbitraryCleaner"}"#, + r#"{"kind":"owned-return","cleanup":{"close-handle":null}}"#, + r#"{"kind":"overlapped-io","runtimeMethod":"beginWhatever"}"#, + r#"{"kind":"reject-hkey-performance-data","parameter":0}"#, + r#"{"kind":"hkey-performance-data-count","handleParameter":0,"countParameter":5,"undefinedOn":"more-data"}"#, + r#"{"kind":"borrowed-predefined-hkey-output","handleParameter":0,"stringParameter":1,"outputParameter":4}"#, + r#"{"kind":"call-contract","contract":{"outputs":[],"javascript":"unchecked()"} }"#, + ] { + assert!( + serde_json::from_str::(data).is_err(), + "{data}" + ); + } + assert!( + serde_json::from_str::(r#"{"kind":"handle","typescript":"bigint"}"#).is_err() + ); + assert!( + serde_json::from_str::(r#"{"kind":"scalar","scalar":{"u32":null}}"#).is_err() + ); + assert!( + serde_json::from_str::(r#"{"kind":"null-pointer","snippet":"0"}"#).is_err() + ); + let mut entries = registry.functions.values().cloned().collect::>(); + entries.push(entries[0].clone()); + assert!(Registry::validate(entries.clone(), Vec::new(), Vec::new()).is_err()); + entries.last_mut().unwrap().id += ".duplicate"; + assert!(Registry::validate(entries, Vec::new(), Vec::new()).is_err()); + let mut one = registry.functions.values().next().unwrap().clone(); + one.contracts.push(one.contracts[0].clone()); + assert!(Registry::validate(vec![one], Vec::new(), Vec::new()).is_err()); +} + +#[test] +fn win32_contract_text_pins_use_lf_normalization_without_changing_binary_fingerprints() { + let files = FILES + .iter() + .map(|(name, contents)| (*name, contents.replace('\n', "\r\n"))) + .collect::>(); + let files = files + .iter() + .map(|(name, contents)| (*name, contents.as_str())) + .collect::>(); + Registry::load( + &MANIFEST.replace('\n', "\r\n"), + &SCHEMA.replace('\n', "\r\n"), + &files, + ) + .unwrap(); + assert_ne!(sha256(b"native\r\nbytes"), sha256(b"native\nbytes")); +} + +#[test] +fn win32_contracts_pin_every_official_selector() { + let Some(path) = metadata() else { + return; + }; + let bytes = std::fs::read(path).unwrap(); + assert_eq!(sha256(&bytes), METADATA_SHA256); + let index = reader::Index::new(vec![reader::File::new(bytes).unwrap()]); + let registry = Registry::builtin().unwrap(); + let mut found = BTreeSet::new(); + for definition in index.all() { + for method in definition.methods() { + let key = ( + definition.namespace().to_string(), + definition.name().to_string(), + method.name().to_string(), + ); + let Some(entry) = registry.functions.get(&key) else { + continue; + }; + assert_eq!( + method_fingerprint(definition.namespace(), definition.name(), &method), + entry.selector.source_fingerprint, + "{}", + entry.id + ); + let import = method.impl_map().unwrap(); + assert_eq!(import.import_scope().name(), entry.selector.dll); + assert_eq!(import.import_name(), entry.selector.entry_point); + assert!(found.insert(key), "duplicate official declaration"); + } + } + assert_eq!(found.len(), registry.functions.len()); + for entry in registry.types.values() { + assert_eq!( + type_fingerprint(&index, &entry.selector.namespace, &entry.selector.name), + entry.selector.source_fingerprint, + "{}", + entry.id + ); + } +} + +#[test] +fn win32_contract_drift_and_forged_facts_fail_closed() { + let Some(path) = metadata() else { + return; + }; + let raw = crate::win32_metadata::parse_apis(&path, "Windows.Win32.System.Registry", "Apis") + .unwrap() + .functions + .into_iter() + .find(|f| f.name == "RegOpenKeyExW") + .unwrap(); + let registry = Registry::builtin().unwrap(); + registry.function_policy(&raw).unwrap(); + let key = ( + raw.namespace.clone(), + raw.container.clone(), + raw.name.clone(), + ); + let entry = registry.function_entry(&raw).unwrap().clone(); + let mutations: &[fn(&mut FunctionSelector)] = &[ + |s| s.namespace.push('x'), + |s| s.container.push('x'), + |s| s.name.push('x'), + |s| s.dll.push('x'), + |s| s.entry_point.push('x'), + |s| s.calling_convention.push('x'), + |s| s.architectures = 1, + |s| s.source_fingerprint = "0".repeat(64), + ]; + for mutation in mutations { + let mut entry = entry.clone(); + mutation(&mut entry.selector); + let changed = Registry { + functions: BTreeMap::from([(key.clone(), entry)]), + types: BTreeMap::new(), + domains: Vec::new(), + }; + assert!(changed.function_policy(&raw).is_err()); + } + + let mutations: &[fn(&mut RawFunction)] = &[ + |f| f.parameters[0].nullable = true, + |f| f.parameters[0].typ.pointer_depth = 1, + |f| f.parameters[1].typ.constness = crate::win32_metadata::RawConstness::Mutable, + |f| f.parameters[1].direction = crate::win32_metadata::RawDirection::Out, + |f| f.parameters[4].free_with = Some("CloseHandle".into()), + |f| f.supports_last_error = !f.supports_last_error, + |f| f.evidence = None, + ]; + for mutation in mutations { + let mut changed = raw.clone(); + mutation(&mut changed); + assert!(registry.function_policy(&changed).is_err()); + } + let mut forged = entry; + forged.contracts = vec![FunctionEffect::OwnedOutput { + parameter: 0, + cleanup: Cleanup::RegCloseKey, + }]; + let changed = Registry { + functions: BTreeMap::from([(key, forged)]), + types: BTreeMap::new(), + domains: Vec::new(), + }; + assert!(changed.function_policy(&raw).is_err()); +} + +#[test] +fn win32_free_library_has_a_consuming_hmodule_abi_and_ordered_bool_result() { + let Some(path) = metadata() else { + return; + }; + let raw = metadata_function(&path, "Windows.Win32.Foundation", "FreeLibrary"); + assert_eq!(raw.calling_convention, RawCallingConvention::System); + assert!(raw.architectures.x86 && raw.architectures.x64 && raw.architectures.arm64); + assert!(!raw.variadic); + assert!(raw.supports_last_error); + assert_eq!(raw.return_status, RawStatusSemantics::None); + assert_eq!(raw.return_type.base, RawBaseType::Scalar(RawScalar::Bool32)); + let [module] = raw.parameters.as_slice() else { + panic!("FreeLibrary takes one HMODULE") + }; + assert_eq!(module.name, "hLibModule"); + assert_eq!(module.direction, RawDirection::In); + assert_eq!(module.typ.pointer_depth, 0); + assert!(!module.nullable && !module.reserved); + assert!( + matches!(&module.typ.base, RawBaseType::Named { namespace, name, kind:RawNamedKind::Handle { cleanup:Some(cleanup) } } + if namespace == "Windows.Win32.Foundation" && name == "HMODULE" && cleanup == "FreeLibrary") + ); + + let projected = project_one(raw); + assert_eq!(projected.metadata_name, "FreeLibrary"); + assert_eq!(projected.js_name, "freeLibrary"); + assert_eq!(projected.unicode_alias, None); + assert_eq!(projected.subsystem, None); + assert_eq!( + projected.runtime.call_contract, + CallContract::defaults(&projected.runtime.signature_shape(64)) + ); + assert_eq!( + projected.parameters, + vec![surface( + "hLibModule", + SurfaceType::ManagedResource, + false, + None + )] + ); + assert_eq!( + projected.inputs, + vec![InputExpression::Surface { + parameter_index: 0, + conversion: Conversion::ResourceInput(Cleanup::FreeLibrary), + }] + ); + let mut module = slot( + AbiType::Handle, + Direction::In, + false, + Cleanup::None, + Cleanup::FreeLibrary, + ); + module.consumes_resource = true; + assert_eq!( + projected.runtime, + RuntimePlan { + dll: "KERNEL32.dll".into(), + entry_point: "FreeLibrary".into(), + parameters: vec![module], + return_abi: Some(AbiType::Bool32), + return_aggregate: None, + return_cleanup: Cleanup::None, + success_rule: SuccessRule::ReturnNonZero, + capture_last_error: true, + calling_convention: CallingConvention::System, + call_contract: projected.runtime.call_contract.clone(), + } + ); + assert_eq!( + projected.return_shape, + ReturnShape::Object { + status: false, + return_may_be_unavailable: false, + return_value: Some((SurfaceType::Boolean, Conversion::Boolean)), + outputs: Vec::new(), + last_error: true, + } + ); +} + +#[test] +fn win32_registry_abis_keep_ownership_counts_and_status_validity_explicit() { + let Some(path) = metadata() else { + return; + }; + let raw = + crate::win32_metadata::parse_apis(&path, "Windows.Win32.System.Registry", "Apis").unwrap(); + for (suffix, encoding, conversion) in [ + ("A", StringEncoding::Ansi, Conversion::AnsiString), + ("W", StringEncoding::Wide, Conversion::WideString), + ] { + let open = raw + .functions + .iter() + .find(|f| f.name == format!("RegOpenKeyEx{suffix}")) + .unwrap(); + assert_eq!( + open.parameters + .iter() + .map(|p| p.direction) + .collect::>(), + [ + RawDirection::In, + RawDirection::In, + RawDirection::In, + RawDirection::In, + RawDirection::Out + ] + ); + assert_eq!( + open.parameters + .iter() + .map(|p| p.typ.pointer_depth) + .collect::>(), + [0, 0, 0, 0, 1] + ); + assert_eq!(open.parameters[1].typ.constness, RawConstness::Const); + assert!(open.parameters[1].nullable); + assert_eq!(open.return_status, RawStatusSemantics::ZeroIsSuccess); + let native = semantic(open); + assert_eq!(native.return_abi, Some(AbiType::U32)); + assert_eq!(native.success_rule, SuccessRule::ReturnZero); + assert_eq!(native.parameters[4].cleanup, Cleanup::RegCloseKey); + assert_eq!(native.parameters[1].typ, ValueType::StringPointer(encoding)); + let open = project_one(open.clone()); + assert_eq!( + open.parameters, + vec![ + surface("hKey", SurfaceType::Handle("HKEY".into()), false, None), + surface("subKey", SurfaceType::String(encoding), true, None), + surface("ulOptions", SurfaceType::Number, false, None), + surface( + "samDesired", + SurfaceType::Enum("REG_SAM_FLAGS".into()), + false, + None + ), + ] + ); + assert_eq!( + open.inputs, + vec![ + InputExpression::Surface { + parameter_index: 0, + conversion: Conversion::Handle + }, + InputExpression::Surface { + parameter_index: 1, + conversion + }, + InputExpression::Surface { + parameter_index: 2, + conversion: Conversion::U32 + }, + InputExpression::Surface { + parameter_index: 3, + conversion: Conversion::U32Flags + }, + ] + ); + assert_eq!( + open.runtime.parameters, + vec![ + slot( + AbiType::Handle, + Direction::In, + false, + Cleanup::None, + Cleanup::RegCloseKey + ), + slot( + AbiType::Pointer, + Direction::In, + true, + Cleanup::None, + Cleanup::None + ), + slot( + AbiType::U32, + Direction::In, + false, + Cleanup::None, + Cleanup::None + ), + slot( + AbiType::U32, + Direction::In, + false, + Cleanup::None, + Cleanup::None + ), + slot( + AbiType::Handle, + Direction::Out, + false, + Cleanup::RegCloseKey, + Cleanup::None + ), + ] + ); + assert_status_plan(&open.runtime, &format!("RegOpenKeyEx{suffix}")); + assert_eq!( + open.return_shape, + ReturnShape::Object { + status: true, + return_may_be_unavailable: false, + return_value: None, + outputs: vec![ProjectedOutput { + name: "key".into(), + output_index: 0, + typ: SurfaceType::ResourceOrHandle, + conversion: Conversion::ResourceOrHandle, + may_be_unavailable: true, + }], + last_error: false, + } + ); + assert_eq!( + native.call_contract, + CallContract { + outputs: vec![OutputRule { + parameter: 4, + when: Condition { + inputs: vec![ + InputPredicate::HandleIn { + parameter: 0, + values: vec![ + -2147483648, + -2147483647, + -2147483646, + -2147483645, + -2147483644, + -2147483643, + -2147483642, + -2147483568, + -2147483552, + ], + }, + InputPredicate::NullOrEmpty { + parameter: 1, + element_width: if encoding == StringEncoding::Wide { + 2 + } else { + 1 + }, + }, + ], + return_value: None, + ..Condition::default() + }, + action: OutputAction::AliasInput { parameter: 0 }, + }], + resource_effects: Vec::new(), + ..CallContract::default() + } + ); + assert_eq!( + native + .call_contract + .upgrade_metadata(&open.runtime.signature_shape(64)) + .unwrap(), + open.runtime.call_contract + ); + + let query = raw + .functions + .iter() + .find(|f| f.name == format!("RegQueryValueEx{suffix}")) + .unwrap(); + assert_eq!( + query + .parameters + .iter() + .map(|p| p.direction) + .collect::>(), + [ + RawDirection::In, + RawDirection::In, + RawDirection::In, + RawDirection::Out, + RawDirection::Out, + RawDirection::InOut + ] + ); + assert_eq!( + query + .parameters + .iter() + .map(|p| p.typ.pointer_depth) + .collect::>(), + [0, 0, 1, 1, 1, 1] + ); + assert!( + query.parameters[2].reserved + && query.parameters[4].nullable + && query.parameters[5].nullable + ); + let buffer = query.parameters[4].buffer.as_ref().unwrap(); + assert_eq!(buffer.size, RawBufferSize::ByteCountParam(5)); + assert_eq!(buffer.element.base, RawBaseType::Scalar(RawScalar::U8)); + assert_eq!(buffer.element.pointer_depth, 0); + let native = semantic(query); + assert!( + matches!(&native.parameters[3].typ, ValueType::Enum { name, underlying: EnumUnderlying::U32, .. } if name == "REG_VALUE_TYPE") + ); + let query = project_one(query.clone()); + assert_eq!( + query.parameters, + vec![ + surface("hKey", SurfaceType::Handle("HKEY".into()), false, None), + surface("valueName", SurfaceType::String(encoding), true, None), + surface("data", SurfaceType::Buffer, true, Some(1)), + ] + ); + assert_eq!( + query.inputs, + vec![ + InputExpression::Surface { + parameter_index: 0, + conversion: Conversion::Handle + }, + InputExpression::Surface { + parameter_index: 1, + conversion + }, + InputExpression::NullPointer, + InputExpression::Surface { + parameter_index: 2, + conversion: Conversion::DataPointer + }, + InputExpression::BufferLength { + parameter_index: 2, + divisor: 1, + abi: AbiType::U32 + }, + ] + ); + assert_eq!( + query.runtime.parameters, + vec![ + slot( + AbiType::Handle, + Direction::In, + false, + Cleanup::None, + Cleanup::RegCloseKey + ), + slot( + AbiType::Pointer, + Direction::In, + true, + Cleanup::None, + Cleanup::None + ), + slot( + AbiType::Pointer, + Direction::In, + true, + Cleanup::None, + Cleanup::None + ), + slot( + AbiType::U32, + Direction::Out, + false, + Cleanup::None, + Cleanup::None + ), + slot( + AbiType::Pointer, + Direction::In, + true, + Cleanup::None, + Cleanup::None + ), + slot( + AbiType::U32, + Direction::InOut, + false, + Cleanup::None, + Cleanup::None + ), + ] + ); + assert_status_plan(&query.runtime, &format!("RegQueryValueEx{suffix}")); + assert_eq!( + query.return_shape, + ReturnShape::Object { + status: true, + return_may_be_unavailable: false, + return_value: None, + last_error: false, + outputs: vec![ + ProjectedOutput { + name: "type".into(), + output_index: 0, + typ: SurfaceType::Enum("REG_VALUE_TYPE".into()), + conversion: Conversion::Number, + may_be_unavailable: false, + }, + ProjectedOutput { + name: "dataSize".into(), + output_index: 1, + typ: SurfaceType::Number, + conversion: Conversion::Number, + may_be_unavailable: true, + }, + ], + } + ); + assert_eq!( + native.call_contract, + CallContract { + outputs: vec![OutputRule { + parameter: 5, + when: Condition { + inputs: vec![InputPredicate::BitsIn { + parameter: 0, + mask: 0xffff_ffff, + values: vec![0x8000_0004], + }], + return_value: Some(234), + ..Condition::default() + }, + action: OutputAction::Unavailable {}, + }], + resource_effects: Vec::new(), + ..CallContract::default() + } + ); + assert_eq!( + native + .call_contract + .upgrade_metadata(&query.runtime.signature_shape(64)) + .unwrap(), + query.runtime.call_contract + ); + for function in [&open, &query] { + assert_eq!(function.subsystem, None); + assert_eq!(function.unicode_alias.is_some(), suffix == "W"); + } + } +} + +#[test] +fn win32_registry_base_open_and_get_value_use_exact_native_output_rules() { + let Some(path) = metadata() else { + return; + }; + let raw = + crate::win32_metadata::parse_apis(&path, "Windows.Win32.System.Registry", "Apis").unwrap(); + for (suffix, encoding, width) in [ + ("A", StringEncoding::Ansi, 1), + ("W", StringEncoding::Wide, 2), + ] { + let open = raw + .functions + .iter() + .find(|f| f.name == format!("RegOpenKey{suffix}")) + .unwrap(); + assert_eq!(open.parameters.len(), 3); + assert_eq!(open.parameters[0].direction, RawDirection::In); + assert_eq!(open.parameters[0].typ.pointer_depth, 0); + assert!(open.parameters[1].nullable); + assert_eq!(open.parameters[1].typ.constness, RawConstness::Const); + assert_eq!(open.parameters[2].direction, RawDirection::Out); + assert_eq!(open.parameters[2].typ.pointer_depth, 1); + let native = semantic(open); + assert_eq!(native.parameters[0].resource_cleanup, Cleanup::RegCloseKey); + assert_eq!(native.parameters[1].typ, ValueType::StringPointer(encoding)); + assert_eq!(native.parameters[2].cleanup, Cleanup::RegCloseKey); + assert_eq!( + native.call_contract, + CallContract { + outputs: vec![OutputRule { + parameter: 2, + when: Condition { + inputs: vec![InputPredicate::NullOrEmpty { + parameter: 1, + element_width: width, + }], + return_value: None, + ..Condition::default() + }, + action: OutputAction::AliasInput { parameter: 0 }, + }], + resource_effects: Vec::new(), + ..CallContract::default() + } + ); + let projected = project_one(open.clone()); + assert_eq!(projected.parameters.len(), 2); + assert_eq!( + projected.runtime.parameters[2].cleanup, + Cleanup::RegCloseKey + ); + assert_eq!( + projected.runtime.call_contract, + native + .call_contract + .upgrade_metadata(&projected.runtime.signature_shape(64)) + .unwrap() + ); + assert_status_plan(&projected.runtime, &format!("RegOpenKey{suffix}")); + assert_eq!( + projected.return_shape, + ReturnShape::Object { + status: true, + return_may_be_unavailable: false, + return_value: None, + outputs: vec![ProjectedOutput { + name: "key".into(), + output_index: 0, + typ: SurfaceType::ResourceOrHandle, + conversion: Conversion::ResourceOrHandle, + may_be_unavailable: true, + }], + last_error: false, + } + ); + + let get = raw + .functions + .iter() + .find(|f| f.name == format!("RegGetValue{suffix}")) + .unwrap(); + assert_eq!(get.parameters.len(), 7); + assert_eq!(get.parameters[5].direction, RawDirection::Out); + assert_eq!(get.parameters[5].typ.pointer_depth, 1); + assert_eq!( + get.parameters[5].buffer.as_ref().unwrap().size, + RawBufferSize::ByteCountParam(6) + ); + assert_eq!(get.parameters[6].direction, RawDirection::InOut); + assert_eq!(get.parameters[6].typ.pointer_depth, 1); + assert_eq!( + get.parameters[6].typ.base, + RawBaseType::Scalar(RawScalar::U32) + ); + assert!(get.parameters[5].nullable && get.parameters[6].nullable); + let native = semantic(get); + assert_eq!( + native.call_contract, + CallContract { + outputs: vec![OutputRule { + parameter: 6, + when: Condition { + inputs: vec![InputPredicate::BitsIn { + parameter: 0, + mask: 0xffff_ffff, + values: vec![0x8000_0004], + }], + return_value: Some(234), + ..Condition::default() + }, + action: OutputAction::Unavailable {}, + }], + resource_effects: Vec::new(), + ..CallContract::default() + } + ); + let projected = project_one(get.clone()); + assert_eq!(projected.parameters.len(), 5); + assert_eq!( + projected.runtime.call_contract, + native + .call_contract + .upgrade_metadata(&projected.runtime.signature_shape(64)) + .unwrap() + ); + assert_eq!(projected.runtime.parameters[6].abi, AbiType::U32); + assert_eq!(projected.runtime.parameters[6].direction, Direction::InOut); + assert_eq!( + projected.inputs[3], + InputExpression::Surface { + parameter_index: 3, + conversion: Conversion::U32Flags + } + ); + assert_eq!( + projected.inputs[5], + InputExpression::BufferLength { + parameter_index: 4, + divisor: 1, + abi: AbiType::U32 + } + ); + assert_status_plan(&projected.runtime, &format!("RegGetValue{suffix}")); + let ReturnShape::Object { outputs, .. } = &projected.return_shape else { + panic!("native status and output slots") + }; + assert_eq!(outputs.len(), 2); + assert!(!outputs[0].may_be_unavailable); + assert_eq!( + outputs[1], + ProjectedOutput { + name: "dataSize".into(), + output_index: 1, + typ: SurfaceType::Number, + conversion: Conversion::Number, + may_be_unavailable: true, + } + ); + } +} + +#[test] +fn win32_file_completion_modes_declare_shared_native_resource_state() { + let Some(path) = metadata() else { + return; + }; + let raw = metadata_function( + &path, + "Windows.Win32.Storage.FileSystem", + "SetFileCompletionNotificationModes", + ); + assert_eq!(raw.parameters.len(), 2); + assert_eq!(raw.parameters[0].direction, RawDirection::In); + assert_eq!(raw.parameters[0].typ.pointer_depth, 0); + assert_eq!(raw.parameters[1].direction, RawDirection::In); + assert_eq!(raw.parameters[1].typ.pointer_depth, 0); + assert_eq!( + raw.parameters[1].typ.base, + RawBaseType::Scalar(RawScalar::U8) + ); + assert_eq!(raw.return_type.base, RawBaseType::Scalar(RawScalar::Bool32)); + assert!(raw.supports_last_error); + let native = semantic(&raw); + assert_eq!(native.parameters[0].cleanup, Cleanup::None); + assert_eq!(native.parameters[0].resource_cleanup, Cleanup::CloseHandle); + assert!(!native.parameters[0].consumes_resource); + assert_eq!( + native.call_contract, + CallContract { + outputs: Vec::new(), + resource_effects: vec![ResourceEffect::AddFileCompletionModes { + handle_parameter: 0, + flags_parameter: 1, + }], + ..CallContract::default() + } + ); + let projected = project_one(raw); + assert_eq!( + projected.runtime.call_contract, + native + .call_contract + .upgrade_metadata(&projected.runtime.signature_shape(64)) + .unwrap() + ); + assert_eq!(projected.runtime.return_abi, Some(AbiType::Bool32)); + assert_eq!(projected.runtime.success_rule, SuccessRule::ReturnNonZero); + assert!(projected.runtime.capture_last_error); + assert_eq!( + projected.inputs, + [ + InputExpression::Surface { + parameter_index: 0, + conversion: Conversion::Handle + }, + InputExpression::Surface { + parameter_index: 1, + conversion: Conversion::U8 + }, + ] + ); + assert_eq!( + projected.return_shape, + ReturnShape::Object { + status: false, + return_may_be_unavailable: false, + return_value: Some((SurfaceType::Boolean, Conversion::Boolean)), + outputs: Vec::new(), + last_error: true, + } + ); +} + +fn slot( + abi: AbiType, + direction: Direction, + nullable: bool, + cleanup: Cleanup, + resource_cleanup: Cleanup, +) -> RuntimeParameter { + RuntimeParameter { + abi, + direction, + nullable, + cleanup, + resource_cleanup, + consumes_resource: false, + aggregate: None, + pointee_aggregate: None, + } +} + +fn surface( + name: &str, + typ: SurfaceType, + nullable: bool, + alignment: Option, +) -> SurfaceParameter { + SurfaceParameter { + name: name.into(), + typ, + nullable, + minimum_bytes: None, + alignment, + } +} + +fn assert_status_plan(plan: &RuntimePlan, entry: &str) { + assert_eq!(plan.dll, "ADVAPI32.dll"); + assert_eq!(plan.entry_point, entry); + assert_eq!(plan.calling_convention, CallingConvention::System); + assert_eq!(plan.return_abi, Some(AbiType::U32)); + assert_eq!(plan.return_aggregate, None); + assert_eq!(plan.return_cleanup, Cleanup::None); + assert_eq!(plan.success_rule, SuccessRule::ReturnZero); + assert!(!plan.capture_last_error); +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/contract_validation_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/contract_validation_tests.rs new file mode 100644 index 00000000..440318b1 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/contract_validation_tests.rs @@ -0,0 +1,758 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; +use serde_json::{Value, json}; + +fn function_entry() -> FunctionEntry { + Registry::builtin() + .unwrap() + .functions + .get(&( + "Windows.Win32.Foundation".into(), + "Apis".into(), + "FreeLibrary".into(), + )) + .unwrap() + .clone() +} + +fn aggregate_entry() -> TypeEntry { + Registry::builtin() + .unwrap() + .type_entry("Windows.Win32.Security", "SECURITY_ATTRIBUTES") + .unwrap() + .clone() +} + +fn load_modified_group(name: &str, edit: impl FnOnce(&mut Value)) -> Result { + let mut files = FILES + .iter() + .map(|(name, data)| ((*name).to_owned(), (*data).to_owned())) + .collect::>(); + let selected = files + .iter_mut() + .find(|(candidate, _)| candidate == name) + .unwrap(); + let mut group: Value = serde_json::from_str(&selected.1).unwrap(); + edit(&mut group); + selected.1 = group.to_string(); + let digest = sha256(selected.1.as_bytes()); + let mut manifest: Value = serde_json::from_str(MANIFEST).unwrap(); + manifest["files"] + .as_array_mut() + .unwrap() + .iter_mut() + .find(|file| file["file"] == name) + .unwrap()["sha256"] = digest.into(); + Registry::load( + &manifest.to_string(), + SCHEMA, + &files + .iter() + .map(|(name, data)| (name.as_str(), data.as_str())) + .collect::>(), + ) +} + +#[test] +fn every_closed_function_effect_has_typed_json_and_rejects_extra_or_missing_fields() { + let cases: Vec<(Value, fn(FunctionEffect) -> bool)> = vec![ + ( + json!({"kind":"counted-buffer","parameter":0,"countParameter":1,"nullable":true}), + |e| { + matches!( + e, + FunctionEffect::CountedBuffer { + parameter: 0, + count_parameter: 1, + nullable: true + } + ) + }, + ), + ( + json!({"kind":"unsupported-count-unit","parameter":1}), + |e| matches!(e, FunctionEffect::UnsupportedCountUnit { parameter: 1 }), + ), + (json!({"kind":"owned-return","cleanup":"local-free"}), |e| { + matches!( + e, + FunctionEffect::OwnedReturn { + cleanup: Cleanup::LocalFree + } + ) + }), + (json!({"kind":"borrowed-return"}), |e| { + matches!(e, FunctionEffect::BorrowedReturn {}) + }), + ( + json!({"kind":"owned-output","parameter":2,"cleanup":"close-handle"}), + |e| { + matches!( + e, + FunctionEffect::OwnedOutput { + parameter: 2, + cleanup: Cleanup::CloseHandle + } + ) + }, + ), + ( + json!({"kind":"consumed-input","parameter":0,"cleanup":"free-library"}), + |e| { + matches!( + e, + FunctionEffect::ConsumedInput { + parameter: 0, + cleanup: Cleanup::FreeLibrary + } + ) + }, + ), + (json!({"kind":"mutable-string","parameter":1}), |e| { + matches!(e, FunctionEffect::MutableString { parameter: 1 }) + }), + ( + json!({"kind":"call-contract","contract":{}}), + |e| matches!(e, FunctionEffect::CallContract { contract } if contract.is_empty()), + ), + ( + json!({"kind":"result-contract","contract":{ + "target":{"kind":"return"}, + "onSuccess":{"kind":"defined","ownership":{"kind":"owned","cleanup":"close-handle"},"delivery":"deliver"}, + "onFailure":{"kind":"defined","ownership":{"kind":"owned","cleanup":"close-handle"},"delivery":"discard"} + }}), + |e| matches!(e, FunctionEffect::ResultContract { contract } if contract.target == ResultTarget::Return {} && contract.may_be_unavailable()), + ), + ( + json!({"kind":"overlapped-io","operation":"read","fileParameter":0,"bufferParameter":1,"countParameter":2,"transferredParameter":3,"overlappedParameter":4}), + |e| { + matches!( + e, + FunctionEffect::OverlappedIo { + operation: AsyncIoKind::Read, + file_parameter: 0, + buffer_parameter: 1, + count_parameter: 2, + transferred_parameter: 3, + overlapped_parameter: 4 + } + ) + }, + ), + (json!({"kind":"subsystem","subsystem":"winsock"}), |e| { + matches!( + e, + FunctionEffect::Subsystem { + subsystem: Subsystem::Winsock + } + ) + }), + (json!({"kind":"subsystem-exempt"}), |e| { + matches!(e, FunctionEffect::SubsystemExempt {}) + }), + ( + json!({"kind":"managed-lifecycle","subsystem":"media-foundation"}), + |e| { + matches!( + e, + FunctionEffect::ManagedLifecycle { + subsystem: Subsystem::MediaFoundation + } + ) + }, + ), + ]; + let schema: Value = serde_json::from_str(SCHEMA).unwrap(); + for (value, accepts) in cases { + let parsed = serde_json::from_value::(value.clone()).unwrap(); + assert!(accepts(parsed), "{value}"); + let definition = schema["$defs"]["effect"]["oneOf"] + .as_array() + .unwrap() + .iter() + .find(|definition| definition["properties"]["kind"]["const"] == value["kind"]) + .unwrap(); + assert_eq!(definition["additionalProperties"], false); + let required = definition["required"] + .as_array() + .unwrap() + .iter() + .map(|v| v.as_str().unwrap()) + .collect::>(); + assert_eq!( + required, + value + .as_object() + .unwrap() + .keys() + .map(String::as_str) + .collect() + ); + for field in value.as_object().unwrap().keys() { + let mut missing = value.clone(); + missing.as_object_mut().unwrap().remove(field); + assert!( + serde_json::from_value::(missing).is_err(), + "missing {field}: {value}" + ); + } + let mut extra = value; + extra["runtimeMethod"] = "unchecked".into(); + assert!(serde_json::from_value::(extra).is_err()); + } +} + +#[test] +fn every_closed_type_and_aggregate_field_meaning_is_typed() { + let cases: Vec<(Value, fn(TypeMeaning) -> bool)> = vec![ + (json!({"kind":"scalar","scalar":"bool32"}), |t| { + matches!( + t, + TypeMeaning::Scalar { + scalar: RawScalar::Bool32 + } + ) + }), + (json!({"kind":"handle"}), |t| { + matches!(t, TypeMeaning::Handle {}) + }), + (json!({"kind":"data-pointer"}), |t| { + matches!(t, TypeMeaning::DataPointer {}) + }), + ( + json!({"kind":"string-pointer","encoding":"utf16","isConst":true}), + |t| { + matches!( + t, + TypeMeaning::StringPointer { + encoding: Encoding::Utf16, + is_const: true + } + ) + }, + ), + ( + json!({"kind":"string-pointer","encoding":"ansi","isConst":false}), + |t| { + matches!( + t, + TypeMeaning::StringPointer { + encoding: Encoding::Ansi, + is_const: false + } + ) + }, + ), + (json!({"kind":"function-pointer"}), |t| { + matches!(t, TypeMeaning::FunctionPointer {}) + }), + (json!({"kind":"unsupported"}), |t| { + matches!(t, TypeMeaning::Unsupported {}) + }), + ]; + for (mut value, accepts) in cases { + assert!(accepts(serde_json::from_value(value.clone()).unwrap())); + value["typescript"] = "unknown".into(); + assert!(serde_json::from_value::(value).is_err()); + } + for (token, expected) in [ + ("bool8", RawScalar::Bool8), + ("i8", RawScalar::I8), + ("u8", RawScalar::U8), + ("i16", RawScalar::I16), + ("u16", RawScalar::U16), + ("i32", RawScalar::I32), + ("u32", RawScalar::U32), + ("i64", RawScalar::I64), + ("u64", RawScalar::U64), + ("f32", RawScalar::F32), + ("f64", RawScalar::F64), + ("char16", RawScalar::Char16), + ("bool32", RawScalar::Bool32), + ("native-isize", RawScalar::NativeIsize), + ("native-usize", RawScalar::NativeUsize), + ] { + let value = + serde_json::from_value::(json!({"kind":"scalar","scalar":token})).unwrap(); + assert!( + matches!(value,TypeMeaning::Scalar { scalar } if scalar == expected), + "{token}" + ); + } + let fields: Vec<(Value, fn(FieldContract) -> bool)> = vec![ + ( + json!({"kind":"retained-pointer","nullable":true,"optional":false}), + |v| { + matches!( + v, + FieldContract::RetainedPointer { + nullable: true, + optional: false + } + ) + }, + ), + (json!({"kind":"null-pointer"}), |v| { + matches!(v, FieldContract::NullPointer {}) + }), + (json!({"kind":"borrowed-handle"}), |v| { + matches!(v, FieldContract::BorrowedHandle {}) + }), + ( + json!({"kind":"owned-handle","cleanup":"close-handle"}), + |v| { + matches!( + v, + FieldContract::OwnedHandle { + cleanup: Cleanup::CloseHandle + } + ) + }, + ), + (json!({"kind":"boolean-input","optional":true}), |v| { + matches!(v, FieldContract::BooleanInput { optional: true }) + }), + (json!({"kind":"output-u32"}), |v| { + matches!(v, FieldContract::OutputU32 {}) + }), + ]; + for (mut value, accepts) in fields { + assert!(accepts(serde_json::from_value(value.clone()).unwrap())); + value["allocatorCode"] = "not data".into(); + assert!(serde_json::from_value::(value).is_err()); + } + for value in [ + json!({"kind":"scalar","scalar":"i128"}), + json!({"kind":"string-pointer","encoding":"utf8","isConst":true}), + json!({"kind":"union","rust":"native_wrapper()"}), + json!({"kind":"scalar","scalar":{"u32":null}}), + ] { + assert!(serde_json::from_value::(value).is_err()); + } +} + +#[test] +fn manifest_and_group_validation_rejects_each_integrity_and_schema_boundary() { + let mutations: &[fn(&mut Value)] = &[ + |v| v["schemaVersion"] = 1.into(), + |v| v["metadata"]["package"] = "unreviewed".into(), + |v| v["metadata"]["version"] = "new".into(), + |v| v["metadata"]["sha256"] = "0".repeat(64).into(), + |v| v["schema"]["file"] = "other.json".into(), + |v| v["schema"]["sha256"] = "0".repeat(64).into(), + |v| { + v["files"].as_array_mut().unwrap().pop(); + }, + |v| v["files"][1] = v["files"][0].clone(), + |v| v["files"][0]["file"] = "..\\outside.json".into(), + |v| v["files"][0]["sha256"] = "not a digest".into(), + |v| v["metadata"]["unknown"] = true.into(), + |v| v["files"][0]["unknown"] = true.into(), + ]; + for (index, mutate) in mutations.iter().enumerate() { + let mut manifest = serde_json::from_str::(MANIFEST).unwrap(); + mutate(&mut manifest); + assert!( + Registry::load(&manifest.to_string(), SCHEMA, FILES).is_err(), + "manifest mutation {index}" + ); + } + for (name, _) in FILES { + if *name == "call-contract.schema.json" { + continue; + } + assert!( + load_modified_group(name, |group| group["schemaVersion"] = 0.into()).is_err(), + "{name}" + ); + assert!( + load_modified_group(name, |group| group["extra"] = true.into()).is_err(), + "{name}" + ); + assert!( + load_modified_group(name, |group| group["entries"][0]["extra"] = true.into()).is_err(), + "{name}" + ); + } + let mut manifest = serde_json::from_str::(MANIFEST).unwrap(); + manifest["files"].as_array_mut().unwrap().reverse(); + assert!(Registry::load(&manifest.to_string(), SCHEMA, FILES).is_ok()); + assert!( + load_modified_group("function-contracts.json", |group| { + let mut entry = group["entries"][0].clone(); + entry["id"] = "tests.additional-existing-kind.v1".into(); + entry["selector"]["name"] = "AdditionalCleanup".into(); + entry["selector"]["entryPoint"] = "AdditionalCleanup".into(); + group["entries"].as_array_mut().unwrap().push(entry); + }) + .is_ok(), + "same-kind additions must not require a Rust manifest checksum change" + ); +} + +#[test] +fn contract_conflicts_and_invalid_roles_are_rejected_not_prioritized() { + let base = function_entry(); + let mut same_id = base.clone(); + same_id.selector.name += "Different"; + assert!(Registry::validate(vec![base.clone(), same_id], Vec::new(), Vec::new()).is_err()); + for effects in [ + vec![ + FunctionEffect::OwnedReturn { + cleanup: Cleanup::LocalFree, + }, + FunctionEffect::BorrowedReturn {}, + ], + vec![FunctionEffect::CountedBuffer { + parameter: 0, + count_parameter: 0, + nullable: true, + }], + vec![ + FunctionEffect::CountedBuffer { + parameter: 0, + count_parameter: 1, + nullable: true, + }, + FunctionEffect::UnsupportedCountUnit { parameter: 0 }, + ], + vec![ + FunctionEffect::OwnedOutput { + parameter: 1, + cleanup: Cleanup::CloseHandle, + }, + FunctionEffect::ConsumedInput { + parameter: 1, + cleanup: Cleanup::CloseHandle, + }, + ], + vec![FunctionEffect::OwnedReturn { + cleanup: Cleanup::None, + }], + vec![FunctionEffect::ConsumedInput { + parameter: 1024, + cleanup: Cleanup::CloseHandle, + }], + vec![FunctionEffect::CallContract { + contract: CallContract { + outputs: vec![OutputRule { + parameter: 0, + when: Condition::default(), + action: OutputAction::AliasInput { parameter: 0 }, + }], + resource_effects: Vec::new(), + ..CallContract::default() + }, + }], + vec![FunctionEffect::OverlappedIo { + operation: AsyncIoKind::Read, + file_parameter: 0, + buffer_parameter: 1, + count_parameter: 2, + transferred_parameter: 3, + overlapped_parameter: 3, + }], + vec![ + FunctionEffect::Subsystem { + subsystem: Subsystem::Winsock, + }, + FunctionEffect::SubsystemExempt {}, + ], + ] { + let mut entry = base.clone(); + entry.contracts = effects; + assert!(Registry::validate(vec![entry], Vec::new(), Vec::new()).is_err()); + } + let base = aggregate_entry(); + let mutations: &[fn(&mut TypeEntry)] = &[ + |e| e.selector.namespace = "Untrusted".into(), + |e| e.selector.name = "../Unsafe".into(), + |e| e.selector.source_fingerprint = "not a digest".into(), + |e| e.meaning = Some(TypeMeaning::Handle {}), + |e| { + let a = e.aggregate.as_mut().unwrap(); + a.fields.push(a.fields[0].clone()); + }, + |e| { + e.aggregate.as_mut().unwrap().fields[0].contract = FieldContract::OwnedHandle { + cleanup: Cleanup::None, + } + }, + |e| e.aggregate.as_mut().unwrap().size_field = Some("not.a.field".into()), + ]; + for mutate in mutations { + let mut entry = base.clone(); + mutate(&mut entry); + assert!(Registry::validate(Vec::new(), vec![entry], Vec::new()).is_err()); + } + let mut duplicate = base.clone(); + duplicate.id += ".another"; + assert!(Registry::validate(Vec::new(), vec![base, duplicate], Vec::new()).is_err()); + for domains in [ + vec![DomainPolicy::ProviderLifecycle { + dll: "..\\mapi32.dll".into(), + }], + vec![DomainPolicy::Subsystem { + namespace: "Unknown".into(), + subsystem: Subsystem::Winsock, + }], + vec![ + DomainPolicy::ProviderLifecycle { + dll: "mapi32.dll".into(), + }, + DomainPolicy::ProviderLifecycle { + dll: "MAPI32.dll".into(), + }, + ], + ] { + assert!(Registry::validate(Vec::new(), Vec::new(), domains).is_err()); + } +} + +#[test] +fn ordinary_registry_data_can_override_direct_and_output_result_policies() { + use crate::codegen::win32::test_support::{ + parameter, pointer, project_with_policy, scalar, synthetic_function, + }; + use crate::win32_metadata::{RawFunctionEvidence, RawType, function_shape_fingerprint}; + use std::sync::Arc; + + let handle = RawType { + base: RawBaseType::Named { + namespace: "Windows.Win32.Foundation".into(), + name: "HANDLE".into(), + kind: RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }; + let mut raw = synthetic_function("ResultEvidenceFixture"); + raw.namespace = "Windows.Win32.Tests".into(); + raw.return_type = handle.clone(); + raw.parameters = vec![ + parameter("source", handle.clone(), RawDirection::In), + parameter( + "count", + pointer(scalar(RawScalar::U32), 1, RawConstness::Mutable), + RawDirection::InOut, + ), + parameter( + "result", + pointer(handle, 1, RawConstness::Mutable), + RawDirection::Out, + ), + ]; + let mut entry = function_entry(); + entry.id = "tests.result-evidence.v2".into(); + entry.selector.namespace = raw.namespace.clone(); + entry.selector.name = raw.name.clone(); + entry.selector.entry_point = raw.entry_point.clone(); + entry.selector.dll = raw.dll.clone(); + entry.selector.source_fingerprint = "A".repeat(64); + raw.evidence = Some(Arc::new(RawFunctionEvidence { + selector: entry.selector.clone(), + metadata_sha256: METADATA_SHA256.into(), + shape_fingerprint: function_shape_fingerprint(&raw), + })); + let effects = json!([ + {"kind":"call-contract","contract":{"outputs":[{ + "parameter":1, + "when":{"returnValue":0}, + "action":{"kind":"unavailable"} + }]}}, + {"kind":"result-contract","contract":{ + "target":{"kind":"return"}, + "onSuccess":{"kind":"defined","ownership":{"kind":"owned","cleanup":"close-handle"},"delivery":"deliver"}, + "onFailure":{"kind":"defined","ownership":{"kind":"owned","cleanup":"close-handle"},"delivery":"discard"} + }}, + {"kind":"result-contract","contract":{ + "target":{"kind":"parameter","index":2}, + "onSuccess":{"kind":"defined","ownership":{"kind":"owned","cleanup":"close-handle"},"delivery":"discard"}, + "onFailure":{"kind":"defined","ownership":{"kind":"owned","cleanup":"close-handle"},"delivery":"deliver"}, + "overrides":[{ + "when":{"succeeded":true,"inputs":[{"kind":"handle-in","parameter":0,"values":[-2147483646]}]}, + "policy":{"kind":"defined","ownership":{"kind":"alias-input","parameter":0},"delivery":"deliver"} + }] + }} + ]); + entry.contracts = serde_json::from_value(effects).unwrap(); + let registry = Registry::validate(vec![entry.clone()], Vec::new(), Vec::new()).unwrap(); + let policy = registry.function_policy(&raw).unwrap(); + assert_eq!(policy.owned_return(), Some(Cleanup::CloseHandle)); + assert_eq!(policy.output_cleanup(2), Some(Cleanup::CloseHandle)); + let projected = project_with_policy(&raw, &policy).unwrap(); + let contract = &projected.runtime.call_contract; + assert_eq!(contract.version, dynwinrt_win32_contracts::CURRENT_VERSION); + assert!(contract.outputs.is_empty()); + assert_eq!(contract.results.len(), 3); + assert_eq!( + contract.result(ResultTarget::Return {}).unwrap().on_failure, + ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle + }) + ); + assert_eq!( + contract + .result(ResultTarget::Parameter { index: 1 }) + .unwrap() + .overrides[0] + .policy, + ResultPolicy::Undefined {} + ); + let output = contract + .result(ResultTarget::Parameter { index: 2 }) + .unwrap(); + assert_eq!( + output.on_success, + ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle + }) + ); + assert_eq!( + output.on_failure, + ResultPolicy::delivered(ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle + }) + ); + assert!(output.may_alias()); + assert!(matches!(&projected.return_shape, ReturnShape::Object { + return_value: Some((SurfaceType::Resource, Conversion::Resource)), + return_may_be_unavailable: true, outputs, .. + } if outputs[1].conversion == Conversion::ResourceOrHandle && outputs[1].may_be_unavailable)); + + let mut duplicate = entry.clone(); + duplicate.contracts.push(duplicate.contracts[1].clone()); + assert!(Registry::validate(vec![duplicate], Vec::new(), Vec::new()).is_err()); + let mut conflicting = entry.clone(); + let FunctionEffect::ResultContract { contract } = &mut conflicting.contracts[1] else { + unreachable!() + }; + contract.on_success = ResultPolicy::delivered(ResultOwnership::Owned { + cleanup: Cleanup::RegCloseKey, + }); + let conflicting = Registry::validate(vec![conflicting], Vec::new(), Vec::new()).unwrap(); + assert!(project_with_policy(&raw, &conflicting.function_policy(&raw).unwrap()).is_err()); + let mut asynchronous = entry; + asynchronous.contracts.push(FunctionEffect::OverlappedIo { + operation: AsyncIoKind::Read, + file_parameter: 0, + buffer_parameter: 1, + count_parameter: 2, + transferred_parameter: 3, + overlapped_parameter: 4, + }); + assert!(Registry::validate(vec![asynchronous], Vec::new(), Vec::new()).is_err()); +} + +#[test] +fn anonymous_layout_recipes_are_bounded_and_retain_native_field_identity() { + let mut recipe = LayoutRecipe { + name: "Anonymous".into(), + kind: RecordKind::Union, + fields: vec![RecipeField { + name: "value".into(), + typ: RecipeType::Scalar { + scalar: RawScalar::U32, + }, + }], + }; + assert!(validate_recipe(&recipe, 0).is_ok()); + assert!(validate_recipe(&recipe, 17).is_err()); + recipe.fields.push(recipe.fields[0].clone()); + assert!(validate_recipe(&recipe, 0).is_err()); + recipe.fields.pop(); + recipe.fields[0].typ = RecipeType::Named { + namespace: "Tests".into(), + name: "Unproven".into(), + }; + assert!(validate_recipe(&recipe, 0).is_err()); + recipe.fields.clear(); + assert!(validate_recipe(&recipe, 0).is_err()); +} + +#[test] +fn real_aggregate_provenance_and_nested_field_drift_fail_closed() { + let Some(path) = metadata() else { return }; + let raw = metadata_function(&path, "Windows.Win32.System.Threading", "CreateProcessW"); + let RawBaseType::Named { + kind: RawNamedKind::NativeStruct { layout }, + .. + } = &raw.parameters[2].typ.base + else { + panic!("SECURITY_ATTRIBUTES retains its native layout"); + }; + let registry = Registry::builtin().unwrap(); + assert!(registry.layout_contract(layout).unwrap().is_some()); + let mutations: &[fn(&mut crate::win32_metadata::RawNativeLayoutSet)] = &[ + |l| l.variants[0].fields[0].name.push('x'), + |l| l.variants[0].fields[1].typ.pointer_depth += 1, + |l| l.variants[0].declared_size = Some(1), + |l| l.variants[0].packing = crate::win32_metadata::RawPacking::Explicit(1), + |l| std::sync::Arc::make_mut(l.evidence.as_mut().unwrap()).metadata_sha256 = "0".repeat(64), + |l| { + std::sync::Arc::make_mut(l.evidence.as_mut().unwrap()) + .selector + .source_fingerprint = "0".repeat(64) + }, + ]; + for mutate in mutations { + let mut changed = (**layout).clone(); + mutate(&mut changed); + assert!(registry.layout_contract(&changed).is_err()); + } +} + +#[test] +fn real_aggregate_result_evidence_targets_logical_fields_not_physical_output_cells() { + let Some(path) = metadata() else { return }; + let raw = metadata_function(&path, "Windows.Win32.System.Threading", "CreateProcessW"); + let registry = Registry::builtin().unwrap(); + for field in 0..4 { + let target = ResultTarget::AggregateField { + parameter: 9, + field, + }; + assert!(raw_result_target(registry, &raw, target)); + let contract = ResultContract { + target, + on_success: ResultPolicy::Undefined {}, + on_failure: ResultPolicy::Undefined {}, + overrides: Vec::new(), + }; + let effect = FunctionEffect::ResultContract { contract }; + assert_eq!(effect.key(), format!("result:aggregate-field:9:{field}")); + let encoded = serde_json::to_value(&effect).unwrap(); + assert_eq!(encoded["contract"]["target"]["kind"], "aggregate-field"); + assert!(serde_json::from_value::(encoded).is_ok()); + } + for target in [ + ResultTarget::AggregateField { + parameter: 9, + field: 4, + }, + ResultTarget::AggregateField { + parameter: 4, + field: 0, + }, + ResultTarget::AggregateField { + parameter: 99, + field: 0, + }, + ] { + assert!(!raw_result_target(registry, &raw, target)); + } + let target = ResultTarget::AggregateField { + parameter: 9, + field: 0, + }; + let mut input = raw.clone(); + input.parameters[9].direction = RawDirection::In; + assert!(!raw_result_target(registry, &input, target)); + let mut indirect = raw; + indirect.parameters[9].typ.pointer_depth = 2; + assert!(!raw_result_target(registry, &indirect, target)); +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/flags_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/flags_tests.rs new file mode 100644 index 00000000..3d95e5bf --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/flags_tests.rs @@ -0,0 +1,201 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::{ir::*, test_support::*, *}; +use crate::win32_metadata::*; + +fn enum_type(name: &str, underlying: RawScalar, is_flags: bool, high: i128) -> RawType { + RawType { + base: RawBaseType::Named { + namespace: "Tests.Enums".into(), + name: name.into(), + kind: RawNamedKind::Enum { + underlying, + is_flags, + members: vec![ + RawEnumMember { + name: "FIRST".into(), + value: 1, + }, + RawEnumMember { + name: "SECOND".into(), + value: 2, + }, + RawEnumMember { + name: "HIGH".into(), + value: high, + }, + ], + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + } +} + +#[test] +fn flags_allow_combinations_without_widening_ordinary_enum_members() { + for (underlying, high, abi, conversion) in [ + (RawScalar::I8, -128, AbiType::I8, Conversion::I8), + (RawScalar::U8, 128, AbiType::U8, Conversion::U8), + (RawScalar::I16, -32768, AbiType::I16, Conversion::I16), + (RawScalar::U16, 32768, AbiType::U16, Conversion::U16), + (RawScalar::I32, -2147483648, AbiType::I32, Conversion::I32), + ( + RawScalar::U32, + 2147483648, + AbiType::U32, + Conversion::U32Flags, + ), + ] { + let mut function = synthetic_function("UseEnums"); + function.parameters = vec![ + parameter( + "flags", + enum_type("MODE_FLAGS", underlying, true, high), + RawDirection::In, + ), + parameter( + "mode", + enum_type("MODE", underlying, false, high), + RawDirection::In, + ), + ]; + let native = semantic(&function); + assert!( + native + .enums + .iter() + .find(|e| e.name == "MODE_FLAGS") + .unwrap() + .is_flags + ); + assert!( + !native + .enums + .iter() + .find(|e| e.name == "MODE") + .unwrap() + .is_flags + ); + let projected = project_one(function.clone()); + assert_eq!(projected.runtime.parameters[0].abi, abi); + assert_eq!(projected.runtime.parameters[1].abi, abi); + assert_eq!( + projected.parameters[0].typ, + SurfaceType::Enum("MODE_FLAGS".into()) + ); + assert_eq!( + projected.inputs[0], + InputExpression::Surface { + parameter_index: 0, + conversion + } + ); + if abi == AbiType::U32 { + assert_eq!( + projected.inputs[1], + InputExpression::Surface { + parameter_index: 1, + conversion: Conversion::U32 + } + ); + } + let (generated, omitted) = + generate_apis_files(&apis(vec![function]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + let file = |name: &str| { + generated + .extra_files + .iter() + .find(|(file, _)| file == name) + .unwrap() + .1 + .as_str() + }; + assert!(file("MODE_FLAGS.d.ts").contains("export type MODE_FLAGS = number\n")); + assert!( + file("MODE.d.ts").contains("export type MODE = (typeof MODE)[keyof typeof MODE]\n") + ); + for name in ["MODE_FLAGS.d.ts", "MODE.d.ts"] { + assert!(file(name).contains(&format!("readonly HIGH: {high}\n"))); + } + assert_eq!( + generated.js.contains("function _u32Flags("), + abi == AbiType::U32 + ); + } +} + +#[test] +fn unsigned_flags_preserve_signed_javascript_bitwise_results_without_silent_truncation() { + let mut function = synthetic_function("UseEnums"); + function.parameters = vec![ + parameter( + "flags", + enum_type("MODE_FLAGS", RawScalar::U32, true, 0x8000_0000), + RawDirection::In, + ), + parameter( + "mode", + enum_type("MODE", RawScalar::U32, false, 0x8000_0000), + RawDirection::In, + ), + ]; + let (generated, omitted) = generate_apis_files(&apis(vec![function]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + let flags_js = generated + .extra_files + .iter() + .find(|(name, _)| name == "MODE_FLAGS.js") + .unwrap(); + run_js( + &generated, + &format!( + r#" +const assert=require('node:assert/strict') +const constants={{}} +require('node:vm').runInNewContext({},{{exports:constants}}) +const flags=constants.MODE_FLAGS +let calls=0 +let received +const runtime={{DynWin32:{{ + u32(value) {{ + if(!Number.isInteger(value) || value<0 || value>0xffffffff) throw new RangeError('native u32') + return value + }}, + toNumber:Number +}},DynWin32Function:{{bind(spec){{ + assert.equal(spec.parameters[0].type,'u32') + assert.equal(spec.parameters[1].type,'u32') + assert.equal(JSON.parse(spec.callContractDescriptor).version,3) + return {{invoke(args){{calls++;received=args;return {{returnValue:9,outputs:[]}}}}}} +}}}}}} +"#, + serde_json::to_string(&flags_js.1).unwrap() + ), + r#" +for(const [value, expected] of [ + [flags.FIRST | flags.SECOND, 3], + [flags.HIGH | flags.FIRST, 0x80000001], + [flags.HIGH | flags.SECOND, 0x80000002], + [flags.HIGH, 0x80000000], + [-1, 0xffffffff], + [0xffffffff, 0xffffffff], + [0, 0], +]) { + assert.equal(projected.useEnums(value,1),9) + assert.equal(received[0],expected) + assert.equal(received[1],1) +} +for(const invalid of [-0x80000001,0x100000000,1.5,NaN,Infinity,-Infinity,'1',true,null,undefined,1n,Symbol('flags'),{}]) { + const before=calls + assert.throws(()=>projected.useEnums(invalid,1),/native 32-bit integer/) + assert.equal(calls,before) +} +const before=calls +assert.throws(()=>projected.useEnums(1,flags.HIGH|flags.FIRST),/native u32/) +assert.equal(calls,before) +"#, + ); +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/ir.rs b/tools/dynwinrt-codegen/src/codegen/win32/ir.rs new file mode 100644 index 00000000..01608cf2 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/ir.rs @@ -0,0 +1,599 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +pub use dynwinrt_win32_contracts::{ + CallContract, Cleanup, Condition, Delivery, Direction, InputPredicate, OutputAction, + OutputRule, ResourceEffect, ResultContract, ResultOverride, ResultOwnership, ResultPolicy, + ResultTarget, SuccessRule, +}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum AbiType { + Bool32, + I8, + U8, + I16, + U16, + I32, + U32, + I64, + U64, + F32, + F64, + Pointer, + FunctionPointer, + Handle, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Constness { + Const, + Mutable, + Unspecified, + Mixed, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum CallingConvention { + System, + Cdecl, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] +pub enum Subsystem { + Winsock, + GdiPlus, + MediaFoundation, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum StringEncoding { + Wide, + Ansi, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Scalar { + Bool8, + Bool32, + I8, + U8, + I16, + U16, + I32, + U32, + I64, + U64, + F32, + F64, + NativeIsize, + NativeUsize, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum EnumUnderlying { + I8, + U8, + I16, + U16, + I32, + U32, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct EnumMember { + pub name: String, + pub value: i128, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct EnumDefinition { + pub namespace: String, + pub name: String, + pub underlying: EnumUnderlying, + pub members: Vec, + pub is_flags: bool, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum NativeScalar { + I8, + U8, + I16, + U16, + I32, + U32, + I64, + U64, + F32, + F64, + NativeIsize, + NativeUsize, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum NativeAggregateKind { + Struct, + Union, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum NativeFieldType { + Scalar(NativeScalar), + Guid, + Pointer, + Handle { + cleanup: Cleanup, + }, + Struct { + name: String, + layout: Box, + by_value_compatible: bool, + }, + Union { + name: String, + layout: Box, + by_value_compatible: bool, + }, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct NativeField { + pub name: String, + pub offset: usize, + pub count: u32, + pub typ: NativeFieldType, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct NativeArchitectureLayout { + pub size: usize, + pub alignment: usize, + pub fields: Vec, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct NativeLayout { + pub namespace: String, + pub name: String, + pub kind: NativeAggregateKind, + pub by_value_compatible: bool, + pub output_fields: Vec, + pub x86: NativeArchitectureLayout, + pub x64: NativeArchitectureLayout, + pub arm64: NativeArchitectureLayout, +} + +impl NativeLayout { + fn result_fields(&self, pointer_width: u8) -> Vec { + use dynwinrt_win32_contracts::{NativeType, ResultFieldShape}; + let layout = if pointer_width == 32 { + &self.x86 + } else { + &self.x64 + }; + self.output_fields + .iter() + .map(|name| { + let field = layout + .fields + .iter() + .find(|field| field.name == *name) + .expect("validated native result field"); + let (typ, cleanup) = match field.typ { + NativeFieldType::Handle { cleanup } => (NativeType::Handle, cleanup), + NativeFieldType::Scalar(scalar) => { + (scalar.native_type(pointer_width), Cleanup::None) + } + NativeFieldType::Guid + | NativeFieldType::Pointer + | NativeFieldType::Struct { .. } + | NativeFieldType::Union { .. } => { + unreachable!("validated native result field type") + } + }; + ResultFieldShape { typ, cleanup } + }) + .collect() + } +} + +impl NativeScalar { + fn native_type(self, pointer_width: u8) -> dynwinrt_win32_contracts::NativeType { + use dynwinrt_win32_contracts::NativeType; + match self { + Self::I8 => NativeType::I8, + Self::U8 => NativeType::U8, + Self::I16 => NativeType::I16, + Self::U16 => NativeType::U16, + Self::I32 => NativeType::I32, + Self::U32 => NativeType::U32, + Self::I64 => NativeType::I64, + Self::U64 => NativeType::U64, + Self::F32 => NativeType::F32, + Self::F64 => NativeType::F64, + Self::NativeIsize if pointer_width == 32 => NativeType::I32, + Self::NativeIsize => NativeType::I64, + Self::NativeUsize if pointer_width == 32 => NativeType::U32, + Self::NativeUsize => NativeType::U64, + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum ValueType { + Scalar(Scalar), + Enum { + namespace: String, + name: String, + underlying: EnumUnderlying, + }, + Handle { + namespace: String, + name: String, + }, + DataPointer, + StringPointer(StringEncoding), + FunctionPointer, + NativeStructPointer { + layout: NativeLayout, + }, + NativeUnionPointer { + layout: NativeLayout, + }, + NativeStruct { + layout: NativeLayout, + }, + ScalarPointer { + scalar: Scalar, + }, + GuidPointer, + NullPointer, + ComInterface { + name: String, + iid: String, + }, + StringPointerPointer(StringEncoding), +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ParameterContract { + pub name: String, + pub native_name: Option<(String, String)>, + pub typ: ValueType, + pub abi: AbiType, + pub pointer_depth: u8, + pub constness: Constness, + pub direction: Direction, + pub nullable: bool, + pub reserved: bool, + pub null_null_terminated: bool, + pub cleanup: Cleanup, + pub consumes_resource: bool, + pub resource_cleanup: Cleanup, + pub buffer: Option, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct BufferContract { + pub count_parameter: Option, + pub constant_count: Option, + pub count_is_bytes: bool, + pub element_size: usize, + pub element_alignment: usize, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct FunctionContract { + pub namespace: String, + pub container: String, + pub name: String, + pub dll: String, + pub entry_point: String, + pub parameters: Vec, + pub return_type: Option, + pub return_abi: Option, + pub return_aggregate: Option, + pub return_native_name: Option<(String, String)>, + pub return_pointer_depth: u8, + pub return_constness: Constness, + pub return_cleanup: Cleanup, + pub return_is_status: bool, + pub success_rule: SuccessRule, + pub capture_last_error: bool, + pub calling_convention: CallingConvention, + pub subsystem: Option, + pub enums: Vec, + pub call_contract: CallContract, + pub result_contracts: Vec, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum SurfaceType { + Boolean, + Number, + BigInt, + Enum(String), + Handle(String), + Buffer, + String(StringEncoding), + MultiString(StringEncoding), + ManagedResource, + Resource, + ResourceOrHandle, + NativeStruct(String), + NativeUnion(String), + ComInterface(String), +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct SurfaceParameter { + pub name: String, + pub typ: SurfaceType, + pub nullable: bool, + pub minimum_bytes: Option, + pub alignment: Option, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum InputExpression { + Surface { + parameter_index: usize, + conversion: Conversion, + }, + BufferLength { + parameter_index: usize, + divisor: usize, + abi: AbiType, + }, + NullPointer, + Zero(AbiType), + NativeAggregate { + parameter_index: usize, + layout: NativeLayout, + nullable: bool, + by_value: bool, + }, + ScalarPointer { + parameter_index: usize, + scalar: Scalar, + nullable: bool, + }, + ComInterface { + parameter_index: usize, + iid: String, + }, + StringPointerPointer { + parameter_index: usize, + encoding: StringEncoding, + nullable: bool, + }, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum Conversion { + Boolean8, + Boolean, + I8, + U8, + I16, + U16, + I32, + U32, + U32Flags, + I64, + U64, + F32, + F64, + Handle, + DataPointer, + WideString, + AnsiString, + WideMultiString, + AnsiMultiString, + ResourceInput(Cleanup), + Number, + BigInt, + Resource, + ResourceOrHandle, + NativeAggregate, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProjectedOutput { + pub name: String, + pub output_index: usize, + pub typ: SurfaceType, + pub conversion: Conversion, + pub may_be_unavailable: bool, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RuntimeParameter { + pub abi: AbiType, + pub direction: Direction, + pub nullable: bool, + pub cleanup: Cleanup, + pub consumes_resource: bool, + pub resource_cleanup: Cleanup, + pub aggregate: Option, + pub pointee_aggregate: Option, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RuntimePlan { + pub dll: String, + pub entry_point: String, + pub parameters: Vec, + pub return_abi: Option, + pub return_aggregate: Option, + pub return_cleanup: Cleanup, + pub success_rule: SuccessRule, + pub capture_last_error: bool, + pub calling_convention: CallingConvention, + pub call_contract: CallContract, +} + +impl RuntimePlan { + pub fn signature_shape(&self, pointer_width: u8) -> dynwinrt_win32_contracts::SignatureShape { + use dynwinrt_win32_contracts::{NativeType, ParameterShape, SignatureShape}; + SignatureShape { + pointer_width, + parameters: self + .parameters + .iter() + .map(|parameter| ParameterShape { + typ: parameter + .aggregate + .as_ref() + .map_or_else(|| parameter.abi.native_type(), |_| NativeType::Aggregate), + direction: parameter.direction, + cleanup: parameter.cleanup, + resource_cleanup: parameter.resource_cleanup, + consumes_resource: parameter.consumes_resource, + result_fields: parameter + .pointee_aggregate + .as_ref() + .map_or_else(Vec::new, |layout| layout.result_fields(pointer_width)), + }) + .collect(), + return_type: if self.return_aggregate.is_some() { + Some(NativeType::Aggregate) + } else { + self.return_abi.map(AbiType::native_type) + }, + return_cleanup: self.return_cleanup, + success_rule: self.success_rule, + } + } +} + +impl AbiType { + pub fn native_type(self) -> dynwinrt_win32_contracts::NativeType { + use dynwinrt_win32_contracts::NativeType; + match self { + Self::Bool32 => NativeType::Bool32, + Self::I8 => NativeType::I8, + Self::U8 => NativeType::U8, + Self::I16 => NativeType::I16, + Self::U16 => NativeType::U16, + Self::I32 => NativeType::I32, + Self::U32 => NativeType::U32, + Self::I64 => NativeType::I64, + Self::U64 => NativeType::U64, + Self::F32 => NativeType::F32, + Self::F64 => NativeType::F64, + Self::Pointer => NativeType::Pointer, + Self::FunctionPointer => NativeType::FunctionPointer, + Self::Handle => NativeType::Handle, + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum ReturnShape { + Void, + Direct { + typ: SurfaceType, + conversion: Conversion, + may_be_unavailable: bool, + }, + Object { + status: bool, + return_value: Option<(SurfaceType, Conversion)>, + return_may_be_unavailable: bool, + outputs: Vec, + last_error: bool, + }, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProjectedFunction { + pub metadata_name: String, + pub js_name: String, + pub unicode_alias: Option, + pub parameters: Vec, + pub inputs: Vec, + pub runtime: RuntimePlan, + pub return_shape: ReturnShape, + pub subsystem: Option, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProjectedApis { + pub namespace: String, + pub class_name: String, + pub functions: Vec, + pub enums: Vec, + pub native_builders: Vec, + pub async_functions: Vec, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] +pub enum AsyncIoKind { + Read, + Write, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProjectedAsyncFunction { + pub js_name: String, + pub kind: AsyncIoKind, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProjectedNativeBuilder { + pub layout_name: String, + pub js_name: String, + pub size_field: Option, + pub fields: Vec, + pub outputs: Vec, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum NativeBuilderFieldKind { + Boolean, + DataPointer { nullable: bool }, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProjectedNativeBuilderField { + pub native_name: String, + pub surface_name: String, + pub kind: NativeBuilderFieldKind, + pub optional: bool, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum NativeOutputFieldKind { + U32, + Resource { cleanup: Cleanup }, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProjectedNativeOutputField { + pub native_name: String, + pub surface_name: String, + pub kind: NativeOutputFieldKind, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct OmittedFunction { + pub identity: String, + pub reason: String, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct ProjectionResult { + pub projected: ProjectedApis, + pub omitted: Vec, +} + +impl ProjectionResult { + pub fn complete_count(&self) -> usize { + self.projected.functions.len() + self.projected.async_functions.len() + } +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/metadata_semantics_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/metadata_semantics_tests.rs new file mode 100644 index 00000000..6d3efc8d --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/metadata_semantics_tests.rs @@ -0,0 +1,615 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::{ir::*, test_support::*, *}; +use crate::win32_metadata::*; + +#[test] +fn metadata_complete_exports_do_not_require_method_allowlisting() { + let Some(path) = metadata() else { return }; + for (namespace, name, abi, shape) in [ + ( + "Windows.Win32.System.SystemInformation", + "GetTickCount", + AbiType::U32, + SurfaceType::Number, + ), + ( + "Windows.Win32.System.SystemInformation", + "GetTickCount64", + AbiType::U64, + SurfaceType::BigInt, + ), + ] { + let raw = metadata_function(&path, namespace, name); + assert!( + crate::win32_contracts::Registry::builtin() + .unwrap() + .function_entry(&raw) + .is_none() + ); + let projected = project_one(raw); + assert!(projected.parameters.is_empty() && projected.inputs.is_empty()); + assert_eq!(projected.runtime.return_abi, Some(abi)); + assert_eq!(projected.runtime.success_rule, SuccessRule::Always); + assert_eq!(projected.runtime.return_cleanup, Cleanup::None); + assert_eq!( + projected.runtime.call_contract, + CallContract::defaults(&projected.runtime.signature_shape(64)) + ); + assert!(matches!(&projected.return_shape,ReturnShape::Direct { typ,.. } if typ == &shape)); + } + let function = metadata_function( + &path, + "Windows.Win32.System.SystemInformation", + "GetFirmwareType", + ); + assert!( + crate::win32_contracts::Registry::builtin() + .unwrap() + .function_entry(&function) + .is_none() + ); + assert_eq!(function.parameters[0].direction, RawDirection::InOut); + let projected = project_one(function); + assert_eq!(projected.runtime.parameters[0].direction, Direction::InOut); + assert_eq!(projected.runtime.parameters[0].abi, AbiType::I32); + assert!( + matches!(&projected.return_shape,ReturnShape::Object { outputs,.. } + if outputs[0].typ == SurfaceType::Enum("FIRMWARE_TYPE".into())) + ); +} + +#[test] +fn subsystem_contexts_exemptions_and_managed_startup_follow_native_evidence() { + let Some(path) = metadata() else { return }; + let mut functions = Vec::new(); + for (namespace, regular, start, stop, subsystem) in [ + ( + "Windows.Win32.Networking.WinSock", + "WSASetLastError", + "WSAStartup", + "WSACleanup", + Subsystem::Winsock, + ), + ( + "Windows.Win32.Graphics.GdiPlus", + "GdipGetImageDecodersSize", + "GdiplusStartup", + "GdiplusShutdown", + Subsystem::GdiPlus, + ), + ( + "Windows.Win32.Media.MediaFoundation", + "MFGetSystemTime", + "MFStartup", + "MFShutdown", + Subsystem::MediaFoundation, + ), + ] { + let mut raw = crate::win32_metadata::parse_apis(&path, namespace, "Apis").unwrap(); + raw.functions + .retain(|f| [regular, start, stop].contains(&f.name.as_str())); + let projected = project_apis(&raw); + let function = projected + .projected + .functions + .iter() + .find(|f| f.metadata_name == regular) + .unwrap(); + assert_eq!(function.subsystem, Some(subsystem)); + for name in [start, stop] { + let omission = projected + .omitted + .iter() + .find(|o| o.identity.ends_with(&format!("::{name}"))) + .unwrap(); + assert!(omission.reason.contains("lifecycle")); + assert!( + !projected + .projected + .functions + .iter() + .any(|f| f.metadata_name == name) + ); + } + functions.push( + raw.functions + .into_iter() + .find(|f| f.name == regular) + .unwrap(), + ); + } + let exempt = metadata_function(&path, "Windows.Win32.Networking.WinSock", "WSAGetLastError"); + assert!(exempt.supports_last_error); + assert!(matches!(&exempt.return_type.base, RawBaseType::Named { + name, kind: RawNamedKind::Enum { underlying: RawScalar::I32, .. }, .. + } if name == "WSA_ERROR")); + let projected = project_one(exempt.clone()); + assert_eq!(projected.subsystem, None); + assert_eq!(projected.runtime.return_abi, Some(AbiType::I32)); + assert_eq!( + projected.return_shape, + ReturnShape::Object { + status: false, + return_may_be_unavailable: false, + return_value: Some((SurfaceType::Enum("WSA_ERROR".into()), Conversion::Number)), + outputs: vec![], + last_error: true, + } + ); + functions.push(exempt); + let (generated, omitted) = generate_apis_files(&apis(functions), "@test/runtime/win32"); + assert!(omitted.is_empty()); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const calls=[] +const runtime={DynWin32:{ + initializeWinsock:()=>({kind:'winsock'}), + initializeGdiPlus:()=>({kind:'gdiplus'}), + initializeMediaFoundation:()=>({kind:'mediaFoundation'}), + i32:value=>value,toNumber:Number,toBigint:BigInt, +},DynWin32Function:{bind(spec){return { + invoke(args){calls.push({spec,args});return {returnValue:7,outputs:[],lastError:19}}, + invokeWithSubsystem(context,kind,args){assert.equal(context.kind,kind);calls.push({spec,args,kind});return {returnValue:7,outputs:[2,32]}} +}}}} +"#, + r#" +projected.wsaSetLastError(projected.initializeWinsock(),123) +assert.equal(calls.at(-1).kind,'winsock') +assert.deepEqual(Array.from(calls.at(-1).args),[123]) +projected.gdipGetImageDecodersSize(projected.initializeGdiPlus()) +assert.equal(calls.at(-1).kind,'gdiplus') +assert.equal(projected.mfGetSystemTime(projected.initializeMediaFoundation()),7n) +assert.equal(calls.at(-1).kind,'mediaFoundation') +const error=projected.wsaGetLastError() +assert.equal(error.result,7) +assert.equal(error.lastError,19) +assert.equal(calls.at(-1).kind,undefined) +"#, + ); +} + +#[test] +fn overlapped_read_write_require_exact_native_roles_and_emit_the_correct_async_helper() { + let Some(path) = metadata() else { return }; + let mut raw = + crate::win32_metadata::parse_apis(&path, "Windows.Win32.Storage.FileSystem", "Apis") + .unwrap(); + raw.functions + .retain(|f| ["ReadFile", "WriteFile"].contains(&f.name.as_str())); + for function in &raw.functions { + assert_eq!(function.calling_convention, RawCallingConvention::System); + assert!(!function.variadic); + assert!(function.supports_last_error); + assert_eq!( + function.return_type.base, + RawBaseType::Scalar(RawScalar::Bool32) + ); + assert_eq!(function.parameters.len(), 5); + let read = function.name == "ReadFile"; + assert_eq!( + function + .parameters + .iter() + .map(|p| p.direction) + .collect::>(), + [ + RawDirection::In, + if read { + RawDirection::Out + } else { + RawDirection::In + }, + RawDirection::In, + RawDirection::Out, + RawDirection::InOut, + ] + ); + assert_eq!( + function.parameters[1].buffer.as_ref().unwrap().size, + RawBufferSize::ByteCountParam(2) + ); + assert_eq!( + function.parameters[2].typ.base, + RawBaseType::Scalar(RawScalar::U32) + ); + assert_eq!(function.parameters[3].typ.pointer_depth, 1); + assert!(function.parameters[4].nullable); + assert!( + matches!(&function.parameters[4].typ.base,RawBaseType::Named { namespace,name,kind:RawNamedKind::NativeStruct { .. } } + if namespace == "Windows.Win32.System.IO" && name == "OVERLAPPED") + ); + let mut changed = function.clone(); + changed.parameters[1].buffer.as_mut().unwrap().size = RawBufferSize::ByteCountParam(3); + let rejected = project_apis(&apis(vec![changed])); + assert!(rejected.projected.functions.is_empty()); + assert!(rejected.projected.async_functions.is_empty()); + assert!(rejected.omitted[0].reason.contains("drift")); + } + let projected = project_apis(&raw); + assert!(projected.omitted.is_empty()); + assert!(projected.projected.functions.is_empty()); + assert_eq!( + projected.projected.async_functions, + vec![ + ProjectedAsyncFunction { + js_name: "readFileAsync".into(), + kind: AsyncIoKind::Read + }, + ProjectedAsyncFunction { + js_name: "writeFileAsync".into(), + kind: AsyncIoKind::Write + }, + ] + ); + let (generated, omitted) = generate_apis_files(&raw, "@test/runtime/win32"); + assert!(omitted.is_empty()); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const calls=[] +const begin=kind=>(file,buffer,offset)=>({ + cancel(){calls.push({kind:'cancel'})}, + start(callback){calls.push({kind,file,buffer,offset});callback(null,4)} +}) +const runtime={DynWin32:{beginReadFile:begin('read'),beginWriteFile:begin('write')},DynWin32Function:{}} +"#, + r#" +;(async()=>{ + const file={} + const buffer=Buffer.alloc(8) + assert.equal(await projected.readFileAsync(file,buffer),4) + assert.equal(calls.at(-1).kind,'read') + assert.equal(calls.at(-1).file,file) + assert.equal(calls.at(-1).buffer,buffer) + assert.equal(calls.at(-1).offset,0n) + assert.equal(await projected.writeFileAsync(file,buffer,12n),4) + assert.equal(calls.at(-1).kind,'write') + assert.equal(calls.at(-1).offset,12n) + const before=calls.length + await assert.rejects(projected.readFileAsync(file,buffer,0n,{}),/AbortSignal/) + await assert.rejects(projected.readFileAsync(file,buffer,0n,{ + aborted:true,addEventListener(){},removeEventListener(){} + }),error=>error.name==='AbortError') + assert.equal(calls.length,before) +})().catch(error=>{console.error(error);process.exitCode=1}) +"#, + ); +} + +#[test] +fn native_builders_encode_size_retention_and_native_owned_result_fields() { + let Some(path) = metadata() else { return }; + let mut raw = + crate::win32_metadata::parse_apis(&path, "Windows.Win32.System.Threading", "Apis").unwrap(); + raw.functions + .retain(|f| ["CreateProcessA", "CreateProcessW"].contains(&f.name.as_str())); + let projection = project_apis(&raw); + assert!(projection.omitted.is_empty(), "{:?}", projection.omitted); + let builders = &projection.projected.native_builders; + let security = builders + .iter() + .find(|b| b.layout_name == "SECURITY_ATTRIBUTES") + .unwrap(); + assert_eq!(security.js_name, "SecurityAttributes"); + assert_eq!(security.size_field.as_deref(), Some("nLength")); + assert_eq!( + security.fields, + vec![ + ProjectedNativeBuilderField { + native_name: "lpSecurityDescriptor".into(), + surface_name: "securityDescriptor".into(), + kind: NativeBuilderFieldKind::DataPointer { nullable: true }, + optional: true + }, + ProjectedNativeBuilderField { + native_name: "bInheritHandle".into(), + surface_name: "inheritHandle".into(), + kind: NativeBuilderFieldKind::Boolean, + optional: true + }, + ] + ); + assert!(security.outputs.is_empty()); + for (native, name) in [ + ("STARTUPINFOA", "StartupInfoA"), + ("STARTUPINFOW", "StartupInfoW"), + ] { + let builder = builders.iter().find(|b| b.layout_name == native).unwrap(); + assert_eq!(builder.js_name, name); + assert_eq!(builder.size_field.as_deref(), Some("cb")); + assert!(builder.fields.is_empty() && builder.outputs.is_empty()); + } + let process = builders + .iter() + .find(|b| b.layout_name == "PROCESS_INFORMATION") + .unwrap(); + assert_eq!(process.size_field, None); + assert!(process.fields.is_empty()); + assert_eq!( + process.outputs, + vec![ + ProjectedNativeOutputField { + native_name: "hProcess".into(), + surface_name: "process".into(), + kind: NativeOutputFieldKind::Resource { + cleanup: Cleanup::CloseHandle + } + }, + ProjectedNativeOutputField { + native_name: "hThread".into(), + surface_name: "thread".into(), + kind: NativeOutputFieldKind::Resource { + cleanup: Cleanup::CloseHandle + } + }, + ProjectedNativeOutputField { + native_name: "dwProcessId".into(), + surface_name: "processId".into(), + kind: NativeOutputFieldKind::U32 + }, + ProjectedNativeOutputField { + native_name: "dwThreadId".into(), + surface_name: "threadId".into(), + kind: NativeOutputFieldKind::U32 + }, + ] + ); + for function in &projection.projected.functions { + assert_eq!(function.runtime.success_rule, SuccessRule::ReturnNonZero); + assert!(function.runtime.capture_last_error); + let original = raw + .functions + .iter() + .find(|f| f.name == function.metadata_name) + .unwrap(); + let native = semantic(original); + assert_eq!(original.parameters[1].direction, RawDirection::InOut); + assert_eq!(native.parameters[1].direction, Direction::In); + assert_eq!(original.parameters[9].direction, RawDirection::Out); + assert_eq!(original.parameters[9].typ.pointer_depth, 1); + let result = &function.runtime.parameters[9]; + assert_eq!(result.abi, AbiType::Pointer); + assert_eq!(result.direction, Direction::In); + assert_eq!(result.cleanup, Cleanup::None); + assert!(result.aggregate.is_none()); + let result_layout = result.pointee_aggregate.as_ref().unwrap(); + assert_eq!(result_layout.name, "PROCESS_INFORMATION"); + assert_eq!( + result_layout.output_fields, + ["hProcess", "hThread", "dwProcessId", "dwThreadId"] + ); + for (layout, size, alignment, offsets) in [ + (&result_layout.x86, 16, 4, [0, 4, 8, 12]), + (&result_layout.x64, 24, 8, [0, 8, 16, 20]), + (&result_layout.arm64, 24, 8, [0, 8, 16, 20]), + ] { + assert_eq!((layout.size, layout.alignment), (size, alignment)); + assert_eq!( + layout + .fields + .iter() + .map(|field| field.offset) + .collect::>(), + offsets + ); + for field in &layout.fields[..2] { + assert_eq!(field.count, 1); + assert_eq!( + field.typ, + NativeFieldType::Handle { + cleanup: Cleanup::CloseHandle + } + ); + } + } + assert!( + function.runtime.parameters[..9] + .iter() + .all(|parameter| parameter.pointee_aggregate.is_none()) + ); + let call_contract = &function.runtime.call_contract; + assert_eq!( + call_contract.version, + dynwinrt_win32_contracts::CURRENT_VERSION + ); + assert_eq!(call_contract.results.len(), 5); + assert!( + call_contract + .result(ResultTarget::Parameter { index: 9 }) + .is_none() + ); + for width in [32, 64] { + let shape = function.runtime.signature_shape(width); + call_contract.validate_signature(&shape).unwrap(); + assert_eq!(shape.parameters[9].result_fields.len(), 4); + for field in 0..4 { + let target = ResultTarget::AggregateField { + parameter: 9, + field, + }; + let policy = call_contract.result(target).unwrap(); + let ownership = if field < 2 { + assert_eq!( + shape.result_type(target).unwrap(), + dynwinrt_win32_contracts::NativeType::Handle + ); + assert_eq!(shape.result_cleanup(target), Cleanup::CloseHandle); + ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle, + } + } else { + assert_eq!( + shape.result_type(target).unwrap(), + dynwinrt_win32_contracts::NativeType::U32 + ); + assert_eq!(shape.result_cleanup(target), Cleanup::None); + ResultOwnership::Value {} + }; + assert_eq!(policy.on_success, ResultPolicy::delivered(ownership)); + assert_eq!(policy.on_failure, ResultPolicy::Undefined {}); + } + } + for (layout_name, x86_size, x64_size) in [ + ("SECURITY_ATTRIBUTES", 12, 24), + ("PROCESS_INFORMATION", 16, 24), + ( + if function.metadata_name.ends_with('W') { + "STARTUPINFOW" + } else { + "STARTUPINFOA" + }, + 68, + 104, + ), + ] { + let native = function + .inputs + .iter() + .find_map(|input| match input { + InputExpression::NativeAggregate { + layout, + by_value: false, + .. + } if layout.name == layout_name => Some(layout), + _ => None, + }) + .unwrap(); + assert_eq!(native.x86.size, x86_size); + assert_eq!(native.x64.size, x64_size); + assert_eq!(native.arm64.size, x64_size); + } + } + let (generated, omitted) = generate_apis_files(&raw, "@test/runtime/win32"); + assert!(omitted.is_empty()); + assert!(!generated.js.contains("prepareNativeStructCall")); + assert!(!generated.js.contains("markNativeStructCallResult")); + assert_eq!( + generated + .js + .matches("pointeeDescriptor: _nativeLayout_PROCESS_INFORMATION") + .count(), + 2 + ); + assert!( + generated + .js + .contains("\"outputFields\":[\"hProcess\",\"hThread\",\"dwProcessId\",\"dwThreadId\"]") + ); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const log=[] +const aggregate={ + createNativeStruct(descriptor){const d=JSON.parse(descriptor);return {length:d.x64.size,fields:{},name:d.name}}, + setNativeStructU32(value,descriptor,field,bits){value.fields[field]=bits}, + setNativeStructBool32(value,descriptor,field,flag){value.fields[field]=flag}, + setNativeStructPointer(value,descriptor,field,pointer){value.fields[field]=pointer}, + getNativeStructU32(value,descriptor,field){return value.fields[field]}, + takeNativeStructResource(value,descriptor,field,cleanup){return {field,cleanup}}, +} +const safe={dataPointer:(value,nullable)=>({value,nullable})} +const runtime={DynWin32:new Proxy(safe,{get(target,key){return key in target?target[key]:aggregate[key]}}),DynWin32Function:{}} +"#, + r#" +const descriptor=Buffer.from([1,2,3]) +const security=projected.createSecurityAttributes({securityDescriptor:descriptor,inheritHandle:true}) +assert.equal(security.fields.nLength,24) +assert.equal(security.fields.lpSecurityDescriptor.value,descriptor) +assert.equal(security.fields.lpSecurityDescriptor.nullable,true) +assert.equal(security.fields.bInheritHandle,true) +for(const create of [projected.createStartupInfoA,projected.createStartupInfoW]) { + const value=create() + assert.deepEqual(Object.keys(value.fields),['cb']) + assert.equal(value.fields.cb,104) +} +const info=projected.createProcessInformation() +info.fields.dwProcessId=31 +info.fields.dwThreadId=47 +assert.equal(projected.getProcessInformationProcessId(info),31) +assert.equal(projected.getProcessInformationThreadId(info),47) +assert.equal(projected.takeProcessInformationProcess(info).field,'hProcess') +assert.equal(projected.takeProcessInformationThread(info).field,'hThread') +assert.equal(projected.takeProcessInformationThread(info).cleanup,'closeHandle') +"#, + ); +} + +#[test] +fn real_enum_files_preserve_values_and_frozen_runtime_objects_not_debug_fingerprints() { + let Some(path) = metadata() else { return }; + let raw = metadata_function(&path, "Windows.Win32.System.Registry", "RegQueryValueExW"); + let projected = project_apis(&apis(vec![raw.clone()])); + assert!(projected.omitted.is_empty()); + let definition = projected + .projected + .enums + .iter() + .find(|e| e.name == "REG_VALUE_TYPE") + .unwrap(); + assert_eq!(definition.namespace, "Windows.Win32.System.Registry"); + assert_eq!(definition.underlying, EnumUnderlying::U32); + for (name, value) in [ + ("REG_NONE", 0), + ("REG_SZ", 1), + ("REG_BINARY", 3), + ("REG_DWORD", 4), + ] { + assert_eq!( + definition + .members + .iter() + .find(|m| m.name == name) + .unwrap() + .value, + value + ); + } + let (generated, omitted) = generate_apis_files(&apis(vec![raw]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + let javascript = &generated + .extra_files + .iter() + .find(|(n, _)| n == "REG_VALUE_TYPE.js") + .unwrap() + .1; + let declarations = &generated + .extra_files + .iter() + .find(|(n, _)| n == "REG_VALUE_TYPE.d.ts") + .unwrap() + .1; + assert!(javascript.starts_with("// Generated by dynwinrt-codegen")); + assert!(declarations.starts_with("// Generated by dynwinrt-codegen")); + run_js( + &GeneratedOutput { + js: javascript.clone(), + dts: String::new(), + extra_files: vec![], + }, + "const assert=require('node:assert/strict'); const runtime={}", + "assert(Object.isFrozen(projected.REG_VALUE_TYPE)); assert.equal(projected.REG_VALUE_TYPE.REG_NONE,0); assert.equal(projected.REG_VALUE_TYPE.REG_DWORD,4);", + ); +} + +#[test] +fn borrowed_module_returns_keep_numeric_handles_and_do_not_acquire_cleanup() { + let Some(path) = metadata() else { return }; + for name in ["GetModuleHandleA", "GetModuleHandleW"] { + let raw = metadata_function(&path, "Windows.Win32.System.LibraryLoader", name); + let native = semantic(&raw); + assert_eq!(native.return_cleanup, Cleanup::None); + let projected = project_one(raw); + assert_eq!(projected.runtime.return_cleanup, Cleanup::None); + assert_eq!(projected.runtime.return_abi, Some(AbiType::Handle)); + assert_eq!(projected.runtime.success_rule, SuccessRule::Always); + assert!(matches!(&projected.return_shape,ReturnShape::Object { + status:false,return_value:Some((SurfaceType::Handle(name),Conversion::BigInt)),outputs,last_error:true,return_may_be_unavailable:false, + } if name == "HMODULE" && outputs.is_empty())); + } +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/mod.rs b/tools/dynwinrt-codegen/src/codegen/win32/mod.rs new file mode 100644 index 00000000..c52173e4 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/mod.rs @@ -0,0 +1,1404 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#[cfg(test)] +mod aggregate_result_tests; +#[cfg(test)] +mod call_contract_tests; +#[cfg(test)] +mod flags_tests; +pub mod ir; +#[cfg(test)] +mod metadata_semantics_tests; +mod model; +#[cfg(test)] +mod naming_tests; +#[cfg(test)] +mod native_call_outcome_tests; +mod project; +#[cfg(test)] +mod projection_semantics_tests; +mod render; +#[cfg(test)] +mod result_policy_tests; +#[cfg(test)] +mod shape_tests; +#[cfg(test)] +pub(crate) mod test_support; + +pub use crate::win32_metadata::FlatFunctionIndex; +use crate::win32_metadata::RawApis; + +pub use ir::{OmittedFunction, ProjectionResult}; +pub use render::GeneratedOutput; + +pub fn generate_apis_files( + raw: &RawApis, + runtime_import: &str, +) -> (GeneratedOutput, Vec) { + let projection = project::project_apis(raw); + let output = render::render(&projection.projected, runtime_import); + (output, projection.omitted) +} + +pub fn project_apis(raw: &RawApis) -> ProjectionResult { + project::project_apis(raw) +} + +pub fn validate_function(function: &crate::win32_metadata::RawFunction) -> Result<(), String> { + model::validate_function(function).map(|_| ()) +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct OmittedExport { + pub name: String, + pub reason: String, +} + +#[derive(Clone, Debug)] +pub struct GeneratedNamespace { + pub namespace: String, + pub js: String, + pub dts: String, + pub extra_files: Vec<(String, String)>, + pub exports: Vec, + pub omissions: Vec, +} + +pub fn has_flat_functions( + winmd_paths: &str, + namespace: &str, + class_name: &str, +) -> Result { + crate::win32_metadata::has_flat_functions(winmd_paths, namespace, class_name) +} + +pub fn generate_namespace( + winmd_paths: &str, + namespace: &str, + runtime_import: &str, +) -> Result { + let raw = crate::win32_metadata::parse_apis(winmd_paths, namespace, "Apis") + .ok_or_else(|| format!("win32.no-complete-exports: no DLL exports in {namespace}"))?; + let projection = project_apis(&raw); + if projection.complete_count() == 0 { + return Err(format!( + "win32.no-complete-exports: {namespace}; {}", + projection + .omitted + .iter() + .map(|o| format!("{}: {}", o.identity, o.reason)) + .collect::>() + .join("; ") + )); + } + let output = render::render(&projection.projected, runtime_import); + Ok(GeneratedNamespace { + namespace: namespace.into(), + js: output.js, + dts: output.dts, + extra_files: output.extra_files, + exports: render::export_names(&projection.projected), + omissions: projection + .omitted + .into_iter() + .map(|o| OmittedExport { + name: o + .identity + .rsplit("::") + .next() + .unwrap_or(&o.identity) + .to_string(), + reason: o.reason, + }) + .collect(), + }) +} + +#[cfg(test)] +mod tests { + use super::ir::{ + AbiType, Conversion, Direction as ProjectedDirection, ReturnShape, SurfaceType, + }; + use super::test_support::{metadata, scalar, synthetic_function}; + use super::*; + use crate::win32_metadata::{ + RawApis, RawArchitectures, RawBaseType, RawBuffer, RawBufferSize, RawCallingConvention, + RawConstness, RawDirection, RawEnumMember, RawLayoutKind, RawNamedKind, RawNativeField, + RawNativeLayout, RawNativeLayoutSet, RawPacking, RawParameter, RawScalar, + RawStatusSemantics, RawType, + }; + + #[test] + fn registry_projection_uses_immutable_plans_and_safe_pointers() { + let Some(winmd) = metadata() else { + return; + }; + let raw = + crate::win32_metadata::parse_apis(&winmd, "Windows.Win32.System.Registry", "Apis") + .unwrap(); + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(output.js.contains("DynWin32Function.bind")); + assert!(!output.js.contains("DynWin32Unsafe")); + assert!(!output.dts.contains("bigint | Buffer")); + assert!(output.js.contains("exports.regOpenKeyExW"), "{omitted:#?}"); + assert!(output.js.contains("exports.regOpenKeyEx"), "{omitted:#?}"); + } + + #[test] + fn fixed_buffer_projection_validates_minimum_storage() { + let mut function = synthetic_function("ReadFourBytes"); + function.parameters.push(RawParameter { + name: "buffer".into(), + typ: RawType { + base: RawBaseType::Scalar(RawScalar::U8), + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::Out, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: Some(RawBuffer { + element: scalar(RawScalar::U8), + size: RawBufferSize::Constant(4), + }), + free_with: None, + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains("must contain at least 4 bytes")); + assert!(output.js.contains("DynWin32.byteLength(buffer)")); + assert!(!output.js.contains("buffer.byteLength")); + assert!(!output.js.contains("value.byteLength")); + } + + #[test] + fn generated_headers_and_already_adjusted_imports_are_preserved() { + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![synthetic_function("Scalar")], + }; + let import = "..\\..\\win32.js"; + let (output, omitted) = generate_apis_files(&raw, import); + assert!(omitted.is_empty()); + assert!(output.js.starts_with("// Generated by dynwinrt-codegen")); + assert!(output.dts.starts_with("// Generated by dynwinrt-codegen")); + assert!(output.js.contains(&format!("require({import:?})"))); + assert!( + output + .js + .contains(&format!("require({:?})", "..\\..\\win32-unsafe.js")) + ); + assert!(output.dts.contains(&format!("from {import:?}"))); + } + + #[test] + fn scalar_pointer_storage_uses_bounded_native_allocation() { + let mut function = synthetic_function("ReadScalar"); + function.parameters.push(RawParameter { + name: "value".into(), + typ: RawType { + base: RawBaseType::Scalar(RawScalar::I32), + pointer_depth: 1, + constness: RawConstness::Const, + }, + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let (output, omitted) = generate_apis_files( + &RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }, + "@microsoft/dynwinrt/win32", + ); + assert!(omitted.is_empty(), "{omitted:?}"); + assert!(output.js.contains("DynWin32.allocateBuffer(4)")); + assert!(!output.js.contains("Buffer.alloc(")); + assert!(!output.js.contains(".subarray(")); + } + + #[test] + fn duplicate_exports_fail_closed_before_rendering() { + let function = synthetic_function("Duplicate"); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function.clone(), function], + }; + let projection = project_apis(&raw); + assert_eq!(projection.complete_count(), 0); + assert_eq!(projection.omitted.len(), 2); + assert!( + projection + .omitted + .iter() + .all(|omission| omission.reason.contains("collision")) + ); + } + + #[test] + fn by_value_inout_handle_remains_a_direct_input() { + let mut function = synthetic_function("FindClose"); + function.parameters.push(RawParameter { + name: "hFindFile".into(), + typ: RawType { + base: RawBaseType::Named { + namespace: "Windows.Win32.Foundation".into(), + name: "HANDLE".into(), + kind: RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + direction: RawDirection::InOut, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains( + r#"type: "handle", direction: "in", nullable: false, cleanup: "none", consumesResource: false, resourceCleanup: "closeHandle", aggregateDescriptor: undefined"# + )); + assert!(!output.dts.contains("readonly hFindFile")); + } + + #[test] + fn bool_failure_rule_precedes_owned_output_adoption() { + let mut function = synthetic_function("OpenToken"); + function.return_type = scalar(RawScalar::Bool32); + function.parameters.push(RawParameter { + name: "token".into(), + typ: RawType { + base: RawBaseType::Named { + namespace: "Windows.Win32.Foundation".into(), + name: "HANDLE".into(), + kind: RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + }, + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::Out, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: Some("CloseHandle".into()), + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains(r#"successRule: "nonzero""#)); + } + + #[test] + fn generic_handle_output_without_function_cleanup_fails_closed() { + let mut function = synthetic_function("LsaConnectUntrusted"); + function.parameters.push(RawParameter { + name: "handle".into(), + typ: RawType { + base: RawBaseType::Named { + namespace: "Windows.Win32.Foundation".into(), + name: "HANDLE".into(), + kind: RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + }, + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::Out, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let projection = project_apis(&raw); + assert_eq!(projection.complete_count(), 0); + assert!( + projection.omitted[0] + .reason + .contains("function-specific ownership") + ); + } + + #[test] + fn owning_inout_handle_fails_closed() { + let mut function = synthetic_function("ReplaceHandle"); + function.parameters.push(RawParameter { + name: "handle".into(), + typ: RawType { + base: RawBaseType::Named { + namespace: "Windows.Win32.Foundation".into(), + name: "HANDLE".into(), + kind: RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + }, + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::InOut, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: Some("CloseHandle".into()), + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let projection = project_apis(&raw); + assert_eq!(projection.complete_count(), 0); + assert!(projection.omitted[0].reason.contains("owning InOut handle")); + } + + #[test] + fn ntstatus_uses_signed_nonnegative_success() { + let mut function = synthetic_function("NtFunction"); + function.return_type = scalar(RawScalar::I32); + function.return_status = RawStatusSemantics::SignedNonNegativeIsSuccess; + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains(r#"successRule: "nonnegative""#)); + } + + #[test] + fn nullable_handle_uses_the_explicit_null_contract() { + let mut function = synthetic_function("OptionalWindow"); + function.parameters.push(RawParameter { + name: "hWnd".into(), + typ: RawType { + base: RawBaseType::Named { + namespace: "Windows.Win32.Foundation".into(), + name: "HWND".into(), + kind: RawNamedKind::Handle { cleanup: None }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + direction: RawDirection::In, + nullable: true, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains("DynWin32.handle(hWnd, true)")); + assert!(output.dts.contains("hWnd: HWND | null")); + } + + #[test] + fn cdecl_is_preserved_and_variadic_functions_fail_closed() { + let mut function = synthetic_function("CdeclScalar"); + function.calling_convention = RawCallingConvention::Cdecl; + function.parameters.push(RawParameter { + name: "value".into(), + typ: scalar(RawScalar::F32), + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + function.return_type = scalar(RawScalar::F32); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function.clone()], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains(r#"callingConvention: "cdecl""#)); + + function.variadic = true; + let projection = project_apis(&RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }); + assert_eq!(projection.complete_count(), 0); + assert!(projection.omitted[0].reason.contains("variadic")); + } + + fn point_layout(bitfield: bool) -> RawNativeLayoutSet { + let fields = ["x", "y"] + .into_iter() + .map(|name| RawNativeField { + name: name.into(), + typ: scalar(RawScalar::I32), + fixed_count: None, + bitfield, + flexible_array: false, + }) + .collect(); + RawNativeLayoutSet { + evidence: None, + recursive: false, + variants: vec![RawNativeLayout { + architectures: RawArchitectures { + x86: true, + x64: true, + arm64: true, + }, + kind: RawLayoutKind::Sequential, + packing: RawPacking::Default, + declared_size: None, + forced_alignment: None, + fields, + }], + } + } + + #[test] + fn native_struct_pointer_projects_typed_aligned_storage() { + let mut function = synthetic_function("OffsetPoint"); + function.parameters.push(RawParameter { + name: "point".into(), + typ: RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "POINT".into(), + kind: RawNamedKind::NativeStruct { + layout: Box::new(point_layout(false)), + }, + }, + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::InOut, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty(), "{omitted:#?}"); + assert!(output.js.contains("_nativeAggregate.createNativeStruct")); + assert!(output.js.contains("_nativeAggregate.nativeStruct(point")); + assert!( + output + .dts + .contains("createPOINT(bytes?: Buffer | Uint8Array): POINT") + ); + } + + #[test] + fn native_bitfield_layout_fails_closed() { + let mut function = synthetic_function("Bitfield"); + function.parameters.push(RawParameter { + name: "value".into(), + typ: RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "BITS".into(), + kind: RawNamedKind::NativeStruct { + layout: Box::new(point_layout(true)), + }, + }, + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let projection = project_apis(&RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }); + assert_eq!(projection.complete_count(), 0); + assert!(projection.omitted[0].reason.contains("bitfield")); + } + + #[test] + fn zero_argument_native_struct_return_declares_its_layout() { + let mut function = synthetic_function("GetPoint"); + function.return_type = RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "POINT".into(), + kind: RawNamedKind::NativeStruct { + layout: Box::new(point_layout(false)), + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }; + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty(), "{omitted:#?}"); + assert!(output.js.contains("const _nativeLayout_POINT")); + assert!( + output + .js + .contains("_nativeAggregate.toNativeStruct(_return, _nativeLayout_POINT)") + ); + } + + #[test] + fn one_byte_metadata_bool_is_not_win32_bool() { + let mut function = synthetic_function("Boolean8"); + function.parameters.push(RawParameter { + name: "value".into(), + typ: scalar(RawScalar::Bool8), + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + function.return_type = scalar(RawScalar::Bool8); + let (output, omitted) = generate_apis_files( + &RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }, + "@microsoft/dynwinrt/win32", + ); + assert!(omitted.is_empty()); + assert!(output.js.contains("type: \"u8\"")); + assert!(output.js.contains("DynWin32.bool8(value)")); + assert!(output.dts.contains("boolean8(value: boolean): boolean")); + } + + #[test] + fn scalar_returns_preserve_exact_abi_widths_and_js_shapes() { + let cases = [ + ("ReturnI8", RawScalar::I8, AbiType::I8, SurfaceType::Number), + ("ReturnU8", RawScalar::U8, AbiType::U8, SurfaceType::Number), + ( + "ReturnU16", + RawScalar::U16, + AbiType::U16, + SurfaceType::Number, + ), + ( + "ReturnI32", + RawScalar::I32, + AbiType::I32, + SurfaceType::Number, + ), + ( + "ReturnU32", + RawScalar::U32, + AbiType::U32, + SurfaceType::Number, + ), + ( + "ReturnChar16", + RawScalar::Char16, + AbiType::U16, + SurfaceType::Number, + ), + ( + "ReturnNativeIsize", + RawScalar::NativeIsize, + AbiType::I64, + SurfaceType::BigInt, + ), + ( + "ReturnNativeUsize", + RawScalar::NativeUsize, + AbiType::U64, + SurfaceType::BigInt, + ), + ( + "ReturnI16", + RawScalar::I16, + AbiType::I16, + SurfaceType::Number, + ), + ( + "ReturnI64", + RawScalar::I64, + AbiType::I64, + SurfaceType::BigInt, + ), + ( + "ReturnU64", + RawScalar::U64, + AbiType::U64, + SurfaceType::BigInt, + ), + ( + "ReturnF32", + RawScalar::F32, + AbiType::F32, + SurfaceType::Number, + ), + ( + "ReturnF64", + RawScalar::F64, + AbiType::F64, + SurfaceType::Number, + ), + ]; + let functions = cases + .iter() + .map(|(name, scalar, _, _)| { + let mut function = synthetic_function(name); + function.return_type = self::scalar(*scalar); + function + }) + .collect(); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions, + }; + + let projection = project_apis(&raw); + assert!(projection.omitted.is_empty()); + for (name, _, abi, surface) in &cases { + let function = projection + .projected + .functions + .iter() + .find(|function| function.metadata_name == *name) + .unwrap(); + assert_eq!(function.runtime.return_abi, Some(*abi)); + assert!(matches!( + &function.return_shape, + ReturnShape::Direct { typ, conversion, may_be_unavailable: false } if typ == surface + && *conversion == if *surface == SurfaceType::BigInt { Conversion::BigInt } else { Conversion::Number } + )); + } + + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + for abi in [ + "i8", "u8", "i16", "u16", "i32", "u32", "i64", "u64", "f32", "f64", + ] { + assert!(output.js.contains(&format!("returnType: \"{abi}\""))); + } + assert!(output.js.contains("return DynWin32.toBigint(_return)")); + assert!(output.dts.contains("returnI8(): number")); + assert!(output.dts.contains("returnI16(): number")); + assert!(output.dts.contains("returnI64(): bigint")); + assert!(output.dts.contains("returnU64(): bigint")); + assert!(output.dts.contains("returnF32(): number")); + assert!(output.dts.contains("returnF64(): number")); + assert!(output.dts.contains("returnNativeIsize(): bigint")); + assert!(output.dts.contains("returnNativeUsize(): bigint")); + } + + #[test] + fn bool32_return_and_output_project_as_booleans() { + let mut direct = synthetic_function("ReturnsBool32"); + direct.return_type = scalar(RawScalar::Bool32); + + let mut output = synthetic_function("GetFlag"); + output.return_type = RawType { + base: RawBaseType::Void, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }; + output.parameters.push(RawParameter { + name: "enabled".into(), + typ: RawType { + base: RawBaseType::Scalar(RawScalar::Bool32), + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::Out, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![direct, output], + }; + let projection = project_apis(&raw); + assert!(projection.omitted.is_empty()); + let get_flag = projection + .projected + .functions + .iter() + .find(|function| function.metadata_name == "GetFlag") + .unwrap(); + assert_eq!( + get_flag.runtime.parameters[0].direction, + ProjectedDirection::Out + ); + assert!(matches!( + &get_flag.return_shape, + ReturnShape::Object { outputs, .. } + if outputs.len() == 1 + && outputs[0].typ == SurfaceType::Boolean + && outputs[0].conversion == Conversion::Boolean + )); + + let (generated, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(generated.js.contains("return DynWin32.toBoolean(_return)")); + assert!( + generated + .js + .contains("enabled: DynWin32.toBoolean(_outputs[0])") + ); + assert!(generated.dts.contains("returnsBool32(): boolean")); + assert!( + generated + .dts + .contains("getFlag(): { readonly enabled: boolean }") + ); + } + + #[test] + fn no_argument_void_returns_omit_result_fields() { + let void_type = RawType { + base: RawBaseType::Void, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }; + let mut no_outputs = synthetic_function("VoidNoOutputs"); + no_outputs.return_type = void_type.clone(); + + let mut with_output = synthetic_function("VoidWithOutput"); + with_output.return_type = void_type; + with_output.parameters.push(RawParameter { + name: "value".into(), + typ: RawType { + base: RawBaseType::Scalar(RawScalar::U32), + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::Out, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![no_outputs, with_output], + }; + + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains("returnType: \"void\"")); + assert!(output.js.contains("return undefined")); + assert!(output.dts.contains("voidNoOutputs(): void")); + assert!( + output + .dts + .contains("voidWithOutput(): { readonly value: number }") + ); + assert!(!output.dts.contains("readonly result")); + } + + #[test] + fn unknown_by_value_type_fails_but_explicit_data_pointer_is_safe() { + let mut unknown = synthetic_function("UnknownValue"); + unknown.parameters.push(RawParameter { + name: "value".into(), + typ: RawType { + base: RawBaseType::Unknown("missing native definition".into()), + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + + let mut pointer = synthetic_function("OpaquePointer"); + pointer.parameters.push(RawParameter { + name: "data".into(), + typ: RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "PVOID".into(), + kind: RawNamedKind::DataPointer, + }, + pointer_depth: 0, + constness: RawConstness::Const, + }, + direction: RawDirection::In, + nullable: true, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![unknown, pointer], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert_eq!(omitted.len(), 1, "{omitted:#?}"); + assert!(omitted[0].reason.contains("native type is unknown")); + assert!(!output.js.contains("unknownValue")); + assert!(output.js.contains("DynWin32.dataPointer(data, true)")); + assert!( + output + .dts + .contains("opaquePointer(data: Buffer | Uint8Array | null): number") + ); + } + + #[test] + fn pointer_returns_require_explicit_lifetime_and_cleanup() { + let pointer_type = RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "PVOID".into(), + kind: RawNamedKind::DataPointer, + }, + pointer_depth: 0, + constness: RawConstness::Mutable, + }; + let mut unowned = synthetic_function("UnownedPointer"); + unowned.return_type = pointer_type.clone(); + + let mut owned = synthetic_function("OwnedPointer"); + owned.return_type = pointer_type; + owned.return_free_with = Some("LocalFree".into()); + + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![unowned, owned], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert_eq!(omitted.len(), 1, "{omitted:#?}"); + assert!( + omitted[0] + .reason + .contains("pointer return lifetime and ownership") + ); + assert!(!output.js.contains("unownedPointer")); + assert!(output.js.contains("returnCleanup: \"localFree\"")); + assert!(output.js.contains( + "return DynWin32.isUnavailable(_return) ? null : (DynWin32.toResource(_return))" + )); + assert!( + output + .dts + .contains("ownedPointer(): DynWin32Resource | null") + ); + } + + #[test] + fn pointer_depth_two_fails_closed_before_rendering() { + let mut function = synthetic_function("DoublePointerOutput"); + function.parameters.push(RawParameter { + name: "values".into(), + typ: RawType { + base: RawBaseType::Scalar(RawScalar::U32), + pointer_depth: 2, + constness: RawConstness::Mutable, + }, + direction: RawDirection::Out, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let projection = project_apis(&RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }); + assert_eq!(projection.complete_count(), 0); + assert_eq!(projection.omitted.len(), 1); + assert!( + projection.omitted[0] + .reason + .contains("unsupported scalar pointer depth 2") + ); + } + + #[test] + fn counted_buffer_hides_and_derives_its_element_count() { + let mut function = synthetic_function("WriteWords"); + function.parameters = vec![ + RawParameter { + name: "values".into(), + typ: RawType { + base: RawBaseType::Scalar(RawScalar::U16), + pointer_depth: 1, + constness: RawConstness::Const, + }, + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: Some(RawBuffer { + element: scalar(RawScalar::U16), + size: RawBufferSize::ElementCountParam(1), + }), + free_with: None, + }, + RawParameter { + name: "count".into(), + typ: scalar(RawScalar::U32), + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }, + ]; + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains("_bufferCount(values, 2)")); + assert!( + output + .dts + .contains("writeWords(values: Buffer | Uint8Array): number") + ); + assert!(!output.dts.contains("count: number")); + } + + fn enum_type(namespace: &str, name: &str, underlying: RawScalar) -> RawType { + RawType { + base: RawBaseType::Named { + namespace: namespace.into(), + name: name.into(), + kind: RawNamedKind::Enum { + underlying, + members: vec![ + RawEnumMember { + name: "NONE".into(), + value: 0, + }, + RawEnumMember { + name: "HIGH_BIT".into(), + value: 0x8000_0000, + }, + ], + is_flags: true, + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + } + } + + #[test] + fn unsigned_enum_high_bit_preserves_u32_abi_and_value() { + let mut function = synthetic_function("SetSecurity"); + function.parameters.push(RawParameter { + name: "securityInformation".into(), + typ: enum_type("Tests.Security", "SECURITY_INFORMATION", RawScalar::U32), + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }; + let projection = project_apis(&raw); + assert!(projection.omitted.is_empty()); + let projected = &projection.projected.functions[0]; + assert_eq!(projected.runtime.parameters[0].abi, AbiType::U32); + assert!(matches!( + projected.inputs[0], + super::ir::InputExpression::Surface { + conversion: Conversion::U32Flags, + .. + } + )); + + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty()); + assert!(output.js.contains("_u32Flags(securityInformation)")); + let enum_js = output + .extra_files + .iter() + .find(|(name, _)| name == "SECURITY_INFORMATION.js") + .map(|(_, content)| content) + .unwrap(); + assert!(enum_js.contains("HIGH_BIT: 2147483648")); + } + + #[test] + fn enum_simple_name_collisions_fail_closed() { + let mut first = synthetic_function("UseFirstMode"); + first.parameters.push(RawParameter { + name: "mode".into(), + typ: enum_type("Tests.First", "MODE", RawScalar::U32), + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let mut second = synthetic_function("UseSecondMode"); + second.parameters.push(RawParameter { + name: "mode".into(), + typ: enum_type("Tests.Second", "MODE", RawScalar::U32), + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + + let projection = project_apis(&RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![first, second], + }); + assert_eq!(projection.complete_count(), 0); + assert_eq!(projection.omitted.len(), 2); + assert!( + projection + .omitted + .iter() + .all(|omission| { omission.reason.contains("enum simple name is ambiguous") }) + ); + } + + #[test] + fn unsupported_enum_underlying_type_fails_closed() { + let mut function = synthetic_function("LargeEnum"); + function.return_type = enum_type("Tests", "LARGE_ENUM", RawScalar::U64); + let projection = project_apis(&RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }); + assert_eq!(projection.complete_count(), 0); + assert!( + projection.omitted[0] + .reason + .contains("enum underlying type is not representable"), + "{:#?}", + projection.omitted + ); + } + + #[test] + fn generation_is_deterministic_without_renderer_snapshots() { + let mut enum_function = synthetic_function("SetSecurity"); + enum_function.parameters.push(RawParameter { + name: "securityInformation".into(), + typ: enum_type("Tests", "SECURITY_INFORMATION", RawScalar::U32), + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![synthetic_function("Zulu"), enum_function], + }; + let first = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + let second = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert_eq!(first, second); + } + + #[test] + fn byte_counted_opaque_buffer_does_not_require_element_layout() { + let mut function = synthetic_function("QueryOpaqueData"); + function.parameters = vec![ + RawParameter { + name: "data".into(), + typ: RawType { + base: RawBaseType::Unknown("variable native record".into()), + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::Out, + nullable: true, + reserved: false, + null_null_terminated: false, + buffer: Some(RawBuffer { + element: RawType { + base: RawBaseType::Unknown("variable native record".into()), + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + size: RawBufferSize::ByteCountParam(1), + }), + free_with: None, + }, + RawParameter { + name: "size".into(), + typ: RawType { + base: RawBaseType::Scalar(RawScalar::U32), + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + direction: RawDirection::InOut, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }, + ]; + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function.clone()], + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert!(omitted.is_empty(), "{omitted:#?}"); + assert!(output.js.contains("_bufferCount(data, 1)")); + assert!( + output + .js + .contains("DynWin32.alignedDataPointer(data, 8, true)") + ); + assert!( + output + .dts + .contains("queryOpaqueData(data: Buffer | Uint8Array | null)") + ); + assert!(output.dts.contains("readonly size: number")); + + function.parameters[0].buffer.as_mut().unwrap().size = RawBufferSize::ElementCountParam(1); + let projection = project_apis(&RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }); + assert_eq!(projection.complete_count(), 0); + assert!( + projection.omitted[0] + .reason + .contains("native buffer element") + ); + + function = synthetic_function("QueryDoublePointer"); + function.parameters = vec![ + RawParameter { + name: "data".into(), + typ: RawType { + base: RawBaseType::Scalar(RawScalar::U8), + pointer_depth: 2, + constness: RawConstness::Mutable, + }, + direction: RawDirection::Out, + nullable: true, + reserved: false, + null_null_terminated: false, + buffer: Some(RawBuffer { + element: scalar(RawScalar::U8), + size: RawBufferSize::ByteCountParam(1), + }), + free_with: None, + }, + RawParameter { + name: "size".into(), + typ: scalar(RawScalar::U32), + direction: RawDirection::In, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + }, + ]; + let projection = project_apis(&RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions: vec![function], + }); + assert_eq!(projection.complete_count(), 0); + assert!( + projection.omitted[0] + .reason + .contains("one data indirection") + ); + } + + fn handle_type(namespace: &str, name: &str, cleanup: &str) -> RawType { + RawType { + base: RawBaseType::Named { + namespace: namespace.into(), + name: name.into(), + kind: RawNamedKind::Handle { + cleanup: Some(cleanup.into()), + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + } + } + + #[test] + fn direct_handle_ownership_uses_exact_function_evidence() { + let cases = [ + ( + "Windows.Win32.System.Memory", + "LocalAlloc", + "HLOCAL", + "LocalFree", + "localFree", + ), + ( + "Windows.Win32.System.Memory", + "GlobalAlloc", + "HGLOBAL", + "GlobalFree", + "globalFree", + ), + ( + "Windows.Win32.System.LibraryLoader", + "LoadLibraryW", + "HMODULE", + "FreeLibrary", + "freeLibrary", + ), + ( + "Windows.Win32.System.Services", + "OpenSCManagerW", + "SC_HANDLE", + "CloseServiceHandle", + "closeServiceHandle", + ), + ]; + let mut functions = Vec::new(); + for (namespace, name, handle, cleanup, _) in cases { + let mut function = synthetic_function(name); + function.namespace = namespace.into(); + function.return_type = handle_type(namespace, handle, cleanup); + functions.push(function); + } + let mut unknown = synthetic_function("MysteryAlloc"); + unknown.namespace = "Windows.Win32.System.Memory".into(); + unknown.return_type = handle_type("Windows.Win32.Foundation", "HGLOBAL", "GlobalFree"); + functions.push(unknown); + let raw = RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions, + }; + let (output, omitted) = generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + assert_eq!(omitted.len(), 5, "{omitted:#?}"); + assert_eq!( + omitted + .iter() + .filter(|o| o.reason == "win32.missing-raw-evidence") + .count(), + 4 + ); + assert!(!output.js.contains("returnCleanup: \"localFree\"")); + let Some(winmd) = metadata() else { + return; + }; + let functions = cases + .iter() + .map(|(namespace, name, _, _, _)| { + crate::win32_metadata::parse_apis(&winmd, namespace, "Apis") + .unwrap() + .functions + .into_iter() + .find(|f| f.name == *name) + .unwrap() + }) + .collect(); + let (output, omitted) = generate_apis_files( + &RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions, + }, + "@microsoft/dynwinrt/win32", + ); + assert!(omitted.is_empty(), "{omitted:#?}"); + for (_, _, _, _, cleanup) in cases { + assert!(output.js.contains(&format!("returnCleanup: \"{cleanup}\""))); + } + assert_eq!(output.js.matches("successRule: \"validHandle\"").count(), 4); + } +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/model.rs b/tools/dynwinrt-codegen/src/codegen/win32/model.rs new file mode 100644 index 00000000..5a4f1658 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/model.rs @@ -0,0 +1,1829 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::collections::{BTreeMap, BTreeSet}; + +use crate::win32_contracts::{AggregateContract, FieldContract, FunctionPolicy, Registry}; +use crate::win32_metadata::{ + RawApis, RawArchitectures, RawBaseType, RawBufferSize, RawCallingConvention, RawDirection, + RawFunction, RawLayoutKind, RawNamedKind, RawNativeLayout, RawNativeLayoutSet, RawPacking, + RawScalar, RawStatusSemantics, RawStringEncoding, RawType, +}; + +use super::ir::{ + AbiType, BufferContract, CallContract, CallingConvention, Cleanup, Condition, Constness, + Direction, EnumDefinition, EnumMember, EnumUnderlying, FunctionContract, InputPredicate, + NativeAggregateKind, NativeArchitectureLayout, NativeField, NativeFieldType, NativeLayout, + NativeScalar, OutputAction, ParameterContract, ResourceEffect, ResultOwnership, ResultPolicy, + ResultTarget, Scalar, StringEncoding, SuccessRule, ValueType, +}; + +pub(super) fn validate_apis(raw: &RawApis) -> (Vec, Vec<(String, String)>) { + let name_counts = + raw.functions + .iter() + .fold(BTreeMap::<&str, usize>::new(), |mut counts, function| { + *counts.entry(&function.name).or_default() += 1; + counts + }); + let mut enum_namespaces = BTreeMap::>::new(); + for function in &raw.functions { + if let Ok(definitions) = enum_definitions(function) { + for definition in definitions { + enum_namespaces + .entry(definition.name) + .or_default() + .insert(definition.namespace); + } + } + } + let ambiguous_enums = enum_namespaces + .into_iter() + .filter_map(|(name, namespaces)| (namespaces.len() > 1).then_some(name)) + .collect::>(); + let mut functions = Vec::new(); + let mut omitted = Vec::new(); + for function in &raw.functions { + if name_counts + .get(function.name.as_str()) + .copied() + .unwrap_or(0) + > 1 + { + omitted.push(( + format!( + "{}.{}::{}", + function.namespace, function.container, function.name + ), + "unresolved metadata overload or architecture collision".into(), + )); + continue; + } + if enum_definitions(function).is_ok_and(|definitions| { + definitions + .iter() + .any(|definition| ambiguous_enums.contains(&definition.name)) + }) { + omitted.push(( + format!( + "{}.{}::{}", + function.namespace, function.container, function.name + ), + "referenced enum simple name is ambiguous across namespaces".into(), + )); + continue; + } + match validate_function(function) { + Ok(function) => functions.push(function), + Err(reason) => omitted.push(( + format!( + "{}.{}::{}", + function.namespace, function.container, function.name + ), + reason, + )), + } + } + (functions, omitted) +} + +pub(super) fn validate_function(raw: &RawFunction) -> Result { + let policy = Registry::builtin()?.function_policy(raw)?; + validate_function_with_policy(raw, &policy) +} + +pub(super) fn validate_function_with_policy( + raw: &RawFunction, + policy: &FunctionPolicy<'_>, +) -> Result { + let expanded = policy.apply_buffers(raw)?; + let raw = &expanded; + let calling_convention = match raw.calling_convention { + RawCallingConvention::System => CallingConvention::System, + RawCallingConvention::Cdecl => CallingConvention::Cdecl, + RawCallingConvention::Unsupported => { + return Err("unsupported native calling convention".into()); + } + }; + if raw.variadic { + return Err("variadic flat Win32 exports are unsupported".into()); + } + if !raw.architectures.x64 || !raw.architectures.arm64 { + return Err("export is not available on both x64 and ARM64".into()); + } + validate_module(&raw.dll)?; + let subsystem = policy.subsystem; + if raw.entry_point.is_empty() || raw.entry_point.as_bytes().contains(&0) { + return Err("entry point is empty or contains NUL".into()); + } + + let (return_type, mut return_abi, return_cleanup) = map_return(raw, &policy)?; + let return_aggregate = match &return_type { + Some(ValueType::NativeStruct { layout }) => { + return_abi = None; + Some(layout.clone()) + } + _ => None, + }; + let mut parameters = raw + .parameters + .iter() + .enumerate() + .map(|(parameter_index, parameter)| { + if parameter.reserved && parameter.direction != RawDirection::In { + return Err(format!( + "reserved parameter `{}` must be input-only", + parameter.name + )); + } + let buffer = parameter + .buffer + .as_ref() + .map(|buffer| -> Result { + let (element_size, element_alignment) = match buffer.size { + RawBufferSize::ByteCountParam(_) + if parameter.typ.pointer_depth == 1 + || (parameter.typ.pointer_depth == 0 + && matches!( + parameter.typ.base, + RawBaseType::Named { + kind: RawNamedKind::DataPointer + | RawNamedKind::StringPointer { .. }, + .. + } + )) => + { + let alignment = map_buffer_element(&buffer.element) + .map(|(_, alignment)| alignment) + .unwrap_or(8); + (1, alignment) + } + RawBufferSize::ByteCountParam(_) => { + return Err( + "byte-sized native buffer does not have one data indirection" + .into(), + ); + } + _ => map_buffer_element(&buffer.element)?, + }; + let (count_parameter, constant_count, count_is_bytes) = match buffer.size { + RawBufferSize::ElementCountParam(index) => (Some(index), None, false), + RawBufferSize::ByteCountParam(index) => (Some(index), None, true), + RawBufferSize::Constant(count) => (None, Some(count), false), + RawBufferSize::Unknown => { + return Err("native buffer has no complete size contract".into()); + } + }; + Ok(BufferContract { + count_parameter, + constant_count, + count_is_bytes, + element_size, + element_alignment, + }) + }) + .transpose()?; + let reserved_pointer = parameter.reserved + && (parameter.typ.pointer_depth > 0 + || matches!( + parameter.typ.base, + RawBaseType::Named { + kind: + RawNamedKind::DataPointer + | RawNamedKind::StringPointer { .. } + | RawNamedKind::FunctionPointer + | RawNamedKind::ComInterface { .. }, + .. + } + )); + let nullable_void = parameter.nullable + && parameter.direction == RawDirection::In + && parameter.typ.pointer_depth == 1 + && matches!(parameter.typ.base, RawBaseType::Void); + let (typ, abi, mut cleanup) = if nullable_void { + (ValueType::NullPointer, AbiType::Pointer, Cleanup::None) + } else if buffer.is_some() || reserved_pointer { + ( + ValueType::DataPointer, + AbiType::Pointer, + if reserved_pointer { + Cleanup::None + } else { + parameter + .free_with + .as_deref() + .map(parse_cleanup) + .transpose()? + .unwrap_or(Cleanup::None) + }, + ) + } else { + map_parameter_type( + ¶meter.typ, + parameter.direction, + parameter.free_with.as_deref(), + )? + }; + if matches!(&typ, ValueType::Handle { .. }) + && parameter.typ.pointer_depth == 1 + && matches!(parameter.direction, RawDirection::Out | RawDirection::InOut) + { + if cleanup == Cleanup::None { + cleanup = policy.output_cleanup(parameter_index).ok_or_else(|| { + format!( + "handle output `{}` has no function-specific ownership and cleanup contract", + parameter.name + ) + })?; + } + if parameter.direction == RawDirection::InOut { + return Err(format!( + "owning InOut handle `{}` is unsupported until replacement ownership is modeled", + parameter.name + )); + } + } + let resource_cleanup = handle_resource_cleanup(¶meter.typ); + if cleanup != Cleanup::None && resource_cleanup != Cleanup::None && cleanup != resource_cleanup { + return Err(format!("ownership evidence conflicts with native cleanup for `{}`",parameter.name)); + } + let consumes_resource = if let Some(expected) = policy.consumed_input(parameter_index) { + if parameter.direction != RawDirection::In || parameter.typ.pointer_depth != 0 + || !matches!(typ,ValueType::Handle { .. }) || expected != resource_cleanup { + return Err(format!("consuming evidence conflicts with native handle `{}`",parameter.name)); + } + true + } else { false }; + let supported_double_null = matches!( + (&typ, parameter.direction), + (ValueType::StringPointer(_), RawDirection::In) + | (ValueType::DataPointer, RawDirection::Out) + ) && (matches!(&typ, ValueType::StringPointer(_)) || buffer.is_some()); + if parameter.null_null_terminated && !supported_double_null { + return Err(format!( + "NullNullTerminated parameter `{}` must be an input string pointer or an explicit output buffer", + parameter.name + )); + } + Ok(ParameterContract { + name: parameter.name.clone(), + native_name: raw_native_name(¶meter.typ), + nullable: (parameter.nullable || reserved_pointer) + && matches!( + &typ, + ValueType::Handle { .. } + | ValueType::DataPointer + | ValueType::StringPointer(_) + | ValueType::FunctionPointer + | ValueType::NativeStructPointer { .. } + | ValueType::NativeUnionPointer { .. } + | ValueType::ScalarPointer { .. } + | ValueType::GuidPointer + | ValueType::NullPointer + | ValueType::ComInterface { .. } + | ValueType::StringPointerPointer(_) + ), + typ, + abi, + pointer_depth: parameter.typ.pointer_depth, + constness: map_constness(parameter.typ.constness), + direction: map_direction(parameter.direction), + reserved: parameter.reserved, + null_null_terminated: parameter.null_null_terminated, + cleanup, + consumes_resource, + resource_cleanup, + buffer, + }) + }) + .collect::, String>>()?; + + for (index, parameter) in parameters.iter_mut().enumerate() { + if policy.mutable_string(index) { + if !matches!(parameter.typ, ValueType::StringPointer(_)) { + return Err("mutable-string evidence requires a native string pointer".into()); + } + parameter.direction = Direction::In; + } + } + validate_buffers(¶meters)?; + if let Some(parameter) = parameters.iter().find(|parameter| { + parameter.pointer_depth == 0 + && parameter.direction == Direction::Out + && parameter.buffer.is_none() + && matches!( + parameter.typ, + ValueType::Scalar(_) | ValueType::Enum { .. } | ValueType::Handle { .. } + ) + }) { + return Err(format!( + "by-value parameter `{}` cannot use an output-only contract", + parameter.name + )); + } + let enums = enum_definitions(raw)?; + let success_rule = match raw.return_status { + RawStatusSemantics::ZeroIsSuccess => SuccessRule::ReturnZero, + RawStatusSemantics::SignedNonNegativeIsSuccess => SuccessRule::SignedNonNegative, + RawStatusSemantics::None + if matches!(&return_type, Some(ValueType::Scalar(Scalar::Bool32))) => + { + SuccessRule::ReturnNonZero + } + RawStatusSemantics::None + if return_cleanup != Cleanup::None + && matches!(&return_type, Some(ValueType::Handle { .. })) => + { + SuccessRule::ReturnValidHandle + } + RawStatusSemantics::None if return_cleanup != Cleanup::None => SuccessRule::ReturnNonNull, + RawStatusSemantics::None => SuccessRule::Always, + }; + + let contract = FunctionContract { + namespace: raw.namespace.clone(), + container: raw.container.clone(), + name: raw.name.clone(), + dll: raw.dll.clone(), + entry_point: raw.entry_point.clone(), + parameters, + return_type, + return_abi, + return_aggregate, + return_native_name: raw_native_name(&raw.return_type), + return_pointer_depth: raw.return_type.pointer_depth, + return_constness: map_constness(raw.return_type.constness), + return_cleanup, + return_is_status: raw.return_status != RawStatusSemantics::None, + success_rule, + capture_last_error: raw.supports_last_error, + calling_convention, + subsystem, + enums, + call_contract: policy.call_contract(), + result_contracts: policy.result_contracts().cloned().collect(), + }; + validate_call_contract(&contract)?; + Ok(contract) +} + +pub(super) fn validate_call_contract(function: &FunctionContract) -> Result<(), String> { + for parameter in &function.parameters { + if let ValueType::NativeStructPointer { layout } + | ValueType::NativeUnionPointer { layout } + | ValueType::NativeStruct { layout } = ¶meter.typ + { + validate_native_result_layout(layout)?; + } + } + let contract = &function.call_contract; + contract + .validate_structure() + .map_err(|error| error.to_string())?; + CallContract::current(function.result_contracts.clone(), Vec::new()) + .validate_structure() + .map_err(|error| error.to_string())?; + for rule in &contract.outputs { + let target = ResultTarget::Parameter { + index: rule.parameter, + }; + validate_result_target(function, target)?; + validate_condition_metadata(function, &rule.when)?; + if let OutputAction::AliasInput { parameter: index } = rule.action { + if native_parameter(function, rule.parameter)?.cleanup == Cleanup::None { + return Err( + "win32.contract-shape-conflict: legacy alias requires an owned handle output" + .into(), + ); + } + validate_result_ownership( + function, + target, + ResultOwnership::AliasInput { parameter: index }, + )?; + } + } + for result in contract.results.iter().chain(&function.result_contracts) { + validate_result_target(function, result.target)?; + for policy in result.policies() { + if let ResultPolicy::Defined { ownership, .. } = policy { + validate_result_ownership(function, result.target, *ownership)?; + } + } + for case in &result.overrides { + validate_condition_metadata(function, &case.when)?; + } + } + for effect in &contract.resource_effects { + let ResourceEffect::AddFileCompletionModes { + handle_parameter, + flags_parameter, + } = *effect; + let handle = native_parameter(function, handle_parameter)?; + let flags = native_parameter(function, flags_parameter)?; + if !matches!(handle.typ, ValueType::Handle { .. }) + || handle.abi != AbiType::Handle + || handle.direction != Direction::In + || handle.pointer_depth != 0 + || handle.buffer.is_some() + || handle.cleanup != Cleanup::None + || handle.consumes_resource + || handle.resource_cleanup != Cleanup::CloseHandle + || flags.abi != AbiType::U8 + || flags.direction != Direction::In + || flags.pointer_depth != 0 + || flags.buffer.is_some() + || !matches!( + flags.typ, + ValueType::Scalar(Scalar::U8) + | ValueType::Enum { + underlying: EnumUnderlying::U8, + .. + } + ) + { + return Err("win32.contract-shape-conflict: file completion state requires a borrowed CloseHandle resource and native U8 input flags".into()); + } + } + Ok(()) +} + +fn native_parameter( + function: &FunctionContract, + index: usize, +) -> Result<&ParameterContract, String> { + function + .parameters + .get(index) + .ok_or_else(|| format!("win32.contract-shape-conflict: missing native parameter {index}")) +} + +fn validate_result_target(function: &FunctionContract, target: ResultTarget) -> Result<(), String> { + match target { + ResultTarget::Return {} if function.return_type.is_none() => { + Err("win32.contract-shape-conflict: void return has no native result".into()) + } + ResultTarget::Return {} => Ok(()), + ResultTarget::Parameter { index } => { + let output = native_parameter(function, index)?; + if output.direction == Direction::In + || output.pointer_depth == 0 + || output.buffer.is_some() + || !matches!( + output.typ, + ValueType::Scalar(_) + | ValueType::Enum { .. } + | ValueType::Handle { .. } + | ValueType::DataPointer + ) + { + return Err( + "win32.contract-shape-conflict: rule requires a native output slot".into(), + ); + } + Ok(()) + } + ResultTarget::AggregateField { parameter, field } => { + native_result_field(function, parameter, field).map(|_| ()) + } + } +} + +fn native_result_field( + function: &FunctionContract, + parameter: usize, + field: usize, +) -> Result<&NativeField, String> { + let parameter = native_parameter(function, parameter)?; + let ValueType::NativeStructPointer { layout } = ¶meter.typ else { + return Err( + "win32.contract-shape-conflict: field result requires a native struct pointer".into(), + ); + }; + if parameter.direction == Direction::In + || parameter.pointer_depth != 1 + || parameter.buffer.is_some() + { + return Err( + "win32.contract-shape-conflict: field result requires an output aggregate pointee" + .into(), + ); + } + layout + .output_fields + .get(field) + .and_then(|name| layout.x64.fields.iter().find(|field| field.name == *name)) + .ok_or_else(|| { + "win32.contract-shape-conflict: missing declared aggregate result field".into() + }) +} + +fn validate_condition_metadata( + function: &FunctionContract, + condition: &Condition, +) -> Result<(), String> { + if let Some(value) = condition.return_value { + let mask = function + .return_abi + .and_then(|abi| abi.native_type().integer_mask(64)) + .ok_or( + "win32.contract-shape-conflict: return condition requires native integer bits", + )?; + if value & !mask != 0 { + return Err( + "win32.contract-shape-conflict: return condition exceeds native width".into(), + ); + } + } + for predicate in &condition.inputs { + let input = native_parameter(function, predicate.parameter())?; + let integer_input = input.buffer.is_none() + && matches!( + (input.direction, input.pointer_depth), + (Direction::In, 0) | (Direction::InOut, 1) + ); + match predicate { + InputPredicate::BitsIn { mask, .. } => { + if !integer_input + || !matches!( + input.typ, + ValueType::Scalar(_) | ValueType::Enum { .. } | ValueType::Handle { .. } + ) + || !input + .abi + .native_type() + .integer_mask(64) + .is_some_and(|width| mask & !width == 0) + { + return Err("win32.contract-shape-conflict: bits predicate requires a width-compatible native integer input".into()); + } + } + InputPredicate::HandleIn { .. } => { + if !integer_input + || input.abi != AbiType::Handle + || !matches!(input.typ, ValueType::Handle { .. }) + { + return Err( + "win32.contract-shape-conflict: handle-in requires a native handle input" + .into(), + ); + } + } + InputPredicate::NullOrEmpty { element_width, .. } => { + let encoding_matches = matches!( + (&input.typ, element_width), + (ValueType::StringPointer(StringEncoding::Ansi), 1) + | (ValueType::StringPointer(StringEncoding::Wide), 2) + ); + if input.direction != Direction::In + || input.pointer_depth != 0 + || input.buffer.is_some() + || input.abi != AbiType::Pointer + || !encoding_matches + { + return Err("win32.contract-shape-conflict: null-or-empty requires a verified native string input and matching encoding width".into()); + } + } + } + } + Ok(()) +} + +fn validate_result_ownership( + function: &FunctionContract, + target: ResultTarget, + ownership: ResultOwnership, +) -> Result<(), String> { + if let ResultTarget::AggregateField { parameter, field } = target { + let field = native_result_field(function, parameter, field)?; + return match (&field.typ, ownership) { + (NativeFieldType::Scalar(_), ResultOwnership::Value {}) => Ok(()), + ( + NativeFieldType::Handle { cleanup }, + ResultOwnership::Owned { cleanup: expected }, + ) if *cleanup != Cleanup::None && *cleanup == expected => Ok(()), + _ => Err("win32.contract-shape-conflict: aggregate field ownership lacks matching native type and cleanup provenance".into()), + }; + } + let (typ, native_name, cleanup) = match target { + ResultTarget::Return {} => ( + function.return_type.as_ref().ok_or("void result")?, + &function.return_native_name, + function.return_cleanup, + ), + ResultTarget::Parameter { index } => { + let output = native_parameter(function, index)?; + (&output.typ, &output.native_name, output.cleanup) + } + ResultTarget::AggregateField { .. } => unreachable!("aggregate field checked above"), + }; + match ownership { + ResultOwnership::Owned { cleanup: expected } => { + if cleanup != expected { + return Err("win32.contract-shape-conflict: result ownership lacks matching native cleanup provenance".into()); + } + } + ResultOwnership::AliasInput { parameter } => { + let input = native_parameter(function, parameter)?; + let target_is_handle = match target { + ResultTarget::Return {} => { + function.return_pointer_depth == 0 + && function.return_abi == Some(AbiType::Handle) + } + ResultTarget::Parameter { index } => { + let output = native_parameter(function, index)?; + output.direction == Direction::Out + && output.pointer_depth == 1 + && output.abi == AbiType::Handle + } + ResultTarget::AggregateField { .. } => { + unreachable!("aggregate field checked above") + } + }; + if !target_is_handle + || !matches!(typ, ValueType::Handle { .. }) + || !matches!(input.typ, ValueType::Handle { .. }) + || input.native_name != *native_name + || input.abi != AbiType::Handle + || input.direction != Direction::In + || input.pointer_depth != 0 + || input.buffer.is_some() + || input.cleanup != Cleanup::None + || input.consumes_resource + || (cleanup != Cleanup::None && input.resource_cleanup != cleanup) + { + return Err("win32.contract-shape-conflict: alias requires matching native handle identity and borrowed input resource".into()); + } + } + ResultOwnership::Value {} | ResultOwnership::Borrowed {} => {} + } + Ok(()) +} + +fn map_return( + function: &RawFunction, + policy: &FunctionPolicy<'_>, +) -> Result<(Option, Option, Cleanup), String> { + let raw = &function.return_type; + if matches!(raw.base, RawBaseType::Void) && raw.pointer_depth == 0 { + return Ok((None, None, Cleanup::None)); + } + if raw.pointer_depth > 0 + && let Some(cleanup) = function.return_free_with.as_deref() + { + return Ok(( + Some(ValueType::DataPointer), + Some(AbiType::Pointer), + parse_cleanup(cleanup)?, + )); + } + if let RawBaseType::Named { + namespace, + name, + kind: RawNamedKind::Handle { cleanup }, + } = &raw.base + && raw.pointer_depth == 0 + { + let cleanup = if let Some(cleanup) = function.return_free_with.as_deref() { + parse_cleanup(cleanup)? + } else if cleanup.is_none() || policy.borrowed_return() { + Cleanup::None + } else if let Some(cleanup) = policy.owned_return() { + if handle_resource_cleanup(raw) != cleanup { + return Err("owned return evidence conflicts with native handle cleanup".into()); + } + cleanup + } else { + return Err(format!( + "direct handle return `{name}` has no verified ownership and success-sentinel contract" + )); + }; + return Ok(( + Some(ValueType::Handle { + namespace: namespace.clone(), + name: name.clone(), + }), + Some(AbiType::Handle), + cleanup, + )); + } + if let RawBaseType::Named { + kind: RawNamedKind::FunctionPointer, + .. + } = &raw.base + && raw.pointer_depth == 0 + { + return Ok(( + Some(ValueType::FunctionPointer), + Some(AbiType::FunctionPointer), + Cleanup::None, + )); + } + let (typ, abi, cleanup) = + map_type(raw, RawDirection::In, function.return_free_with.as_deref())?; + if matches!( + typ, + ValueType::DataPointer + | ValueType::StringPointer(_) + | ValueType::NativeStructPointer { .. } + | ValueType::NativeUnionPointer { .. } + | ValueType::ScalarPointer { .. } + | ValueType::GuidPointer + | ValueType::NullPointer + | ValueType::ComInterface { .. } + | ValueType::StringPointerPointer(_) + ) && cleanup == Cleanup::None + { + return Err("pointer return lifetime and ownership are not modeled".into()); + } + Ok((Some(typ), Some(abi), cleanup)) +} + +fn map_parameter_type( + raw: &RawType, + direction: RawDirection, + free_with: Option<&str>, +) -> Result<(ValueType, AbiType, Cleanup), String> { + let (typ, abi, mut cleanup) = map_type(raw, direction, free_with)?; + if direction == RawDirection::In { + cleanup = Cleanup::None; + } + Ok((typ, abi, cleanup)) +} + +fn map_type( + raw: &RawType, + direction: RawDirection, + free_with: Option<&str>, +) -> Result<(ValueType, AbiType, Cleanup), String> { + match (&raw.base, raw.pointer_depth) { + (RawBaseType::Scalar(scalar), 0) => { + let scalar = map_scalar(*scalar); + Ok((ValueType::Scalar(scalar), scalar_abi(scalar), Cleanup::None)) + } + (RawBaseType::Scalar(scalar), 1) + if matches!(direction, RawDirection::Out | RawDirection::InOut) => + { + let scalar = map_scalar(*scalar); + Ok((ValueType::Scalar(scalar), scalar_abi(scalar), Cleanup::None)) + } + (RawBaseType::Scalar(scalar), 1) if direction == RawDirection::In => { + let scalar = map_scalar(*scalar); + Ok(( + ValueType::ScalarPointer { scalar }, + AbiType::Pointer, + Cleanup::None, + )) + } + ( + RawBaseType::Named { + namespace, + name, + kind: + RawNamedKind::Enum { + underlying, + members, + is_flags, + }, + }, + pointer_depth, + ) if pointer_depth == 0 + || (pointer_depth == 1 + && matches!(direction, RawDirection::Out | RawDirection::InOut)) => + { + let underlying = map_enum_underlying(*underlying)?; + let _ = (members, is_flags); + Ok(( + ValueType::Enum { + namespace: namespace.clone(), + name: name.clone(), + underlying, + }, + enum_abi(underlying), + Cleanup::None, + )) + } + ( + RawBaseType::Named { + namespace, + name, + kind: RawNamedKind::Handle { cleanup: _ }, + }, + pointer_depth, + ) if pointer_depth == 0 + || (pointer_depth == 1 + && matches!(direction, RawDirection::Out | RawDirection::InOut)) => + { + let cleanup = if pointer_depth == 0 || direction == RawDirection::In { + Cleanup::None + } else { + free_with + .map(parse_cleanup) + .transpose()? + .unwrap_or(Cleanup::None) + }; + Ok(( + ValueType::Handle { + namespace: namespace.clone(), + name: name.clone(), + }, + AbiType::Handle, + cleanup, + )) + } + + ( + RawBaseType::Named { + kind: RawNamedKind::DataPointer, + .. + }, + 0, + ) => Ok(( + ValueType::DataPointer, + AbiType::Pointer, + free_with + .map(parse_cleanup) + .transpose()? + .unwrap_or(Cleanup::None), + )), + ( + RawBaseType::Named { + kind: RawNamedKind::StringPointer { encoding }, + .. + }, + 0, + ) => Ok(( + ValueType::StringPointer(match encoding { + RawStringEncoding::Utf16 => StringEncoding::Wide, + RawStringEncoding::Ansi => StringEncoding::Ansi, + }), + AbiType::Pointer, + free_with + .map(parse_cleanup) + .transpose()? + .unwrap_or(Cleanup::None), + )), + ( + RawBaseType::Named { + kind: RawNamedKind::FunctionPointer, + .. + }, + 0, + ) if direction == RawDirection::In => { + Err("managed callback thunks are not implemented".into()) + } + ( + RawBaseType::Named { + kind: RawNamedKind::FunctionPointer, + .. + }, + 0, + ) => Ok(( + ValueType::FunctionPointer, + AbiType::FunctionPointer, + Cleanup::None, + )), + ( + RawBaseType::Named { + namespace, + name, + kind: RawNamedKind::NativeStruct { layout }, + }, + 1, + ) => { + let layout = validate_native_layout(namespace, name, layout)?; + let typ = match layout.kind { + NativeAggregateKind::Struct => ValueType::NativeStructPointer { layout }, + NativeAggregateKind::Union => ValueType::NativeUnionPointer { layout }, + }; + Ok((typ, AbiType::Pointer, Cleanup::None)) + } + ( + RawBaseType::Named { + kind: RawNamedKind::NativeStruct { .. }, + .. + }, + 0, + ) => { + let RawBaseType::Named { + namespace, + name, + kind: RawNamedKind::NativeStruct { layout }, + } = &raw.base + else { + unreachable!() + }; + let layout = validate_native_layout(namespace, name, layout)?; + if layout.kind != NativeAggregateKind::Struct + || !native_layout_supports_by_value(&layout) + { + return Err("by-value native aggregate contains unsupported union fields".into()); + } + Ok(( + ValueType::NativeStruct { layout }, + AbiType::Pointer, + Cleanup::None, + )) + } + ( + RawBaseType::Named { + kind: RawNamedKind::Guid, + .. + }, + 1, + ) => Ok((ValueType::GuidPointer, AbiType::Pointer, Cleanup::None)), + ( + RawBaseType::Named { + name, + kind: RawNamedKind::ComInterface { iid }, + .. + }, + 0, + ) if direction == RawDirection::In => Ok(( + ValueType::ComInterface { + name: name.clone(), + iid: iid.clone(), + }, + AbiType::Pointer, + Cleanup::None, + )), + ( + RawBaseType::Named { + kind: RawNamedKind::StringPointer { encoding }, + .. + }, + 1, + ) if direction == RawDirection::In => Ok(( + ValueType::StringPointerPointer(match encoding { + RawStringEncoding::Utf16 => StringEncoding::Wide, + RawStringEncoding::Ansi => StringEncoding::Ansi, + }), + AbiType::Pointer, + Cleanup::None, + )), + ( + RawBaseType::Named { + namespace, + name, + kind, + }, + _, + ) => Err(format!( + "unsupported {} {namespace}.{name} pointer depth {}", + raw_named_kind_label(kind), + raw.pointer_depth + )), + (RawBaseType::Unknown(reason), _) => Err(format!("native type is unknown: {reason}")), + (RawBaseType::Void, _) => Err("void is not a parameter or pointer value".into()), + (RawBaseType::Scalar(_), _) => Err(format!( + "unsupported scalar pointer depth {}", + raw.pointer_depth + )), + } +} + +fn raw_named_kind_label(kind: &RawNamedKind) -> &'static str { + match kind { + RawNamedKind::Enum { .. } => "enum", + RawNamedKind::Handle { .. } => "handle", + RawNamedKind::StringPointer { .. } => "string pointer", + RawNamedKind::DataPointer => "data pointer", + RawNamedKind::FunctionPointer => "function pointer", + RawNamedKind::Guid => "GUID", + RawNamedKind::ComInterface { .. } => "COM interface", + RawNamedKind::NativeStruct { .. } => "native aggregate", + RawNamedKind::Unknown => "unknown native type", + } +} + +fn native_layout_supports_by_value(layout: &NativeLayout) -> bool { + fn architecture(layout: &NativeArchitectureLayout) -> bool { + layout.fields.iter().all(|field| match &field.typ { + NativeFieldType::Union { .. } => false, + NativeFieldType::Struct { + layout, + by_value_compatible, + .. + } => *by_value_compatible && architecture(layout), + NativeFieldType::Scalar(_) | NativeFieldType::Guid => true, + NativeFieldType::Pointer | NativeFieldType::Handle { .. } => false, + }) + } + layout.by_value_compatible + && architecture(&layout.x86) + && architecture(&layout.x64) + && architecture(&layout.arm64) +} + +#[derive(Debug, Clone, Copy)] +enum LayoutArchitecture { + X86, + X64, + Arm64, +} + +impl LayoutArchitecture { + const fn pointer_size(self) -> usize { + match self { + Self::X86 => 4, + Self::X64 | Self::Arm64 => 8, + } + } + + const fn supports(self, architectures: RawArchitectures) -> bool { + match self { + Self::X86 => architectures.x86, + Self::X64 => architectures.x64, + Self::Arm64 => architectures.arm64, + } + } +} + +fn validate_native_layout( + namespace: &str, + name: &str, + raw: &RawNativeLayoutSet, +) -> Result { + if Registry::builtin()? + .type_entry(namespace, name) + .is_some_and(|entry| entry.aggregate.is_some()) + && raw.evidence.is_none() + { + return Err(format!("win32.missing-type-evidence: {namespace}.{name}")); + } + if raw.recursive { + return Err(format!( + "recursive by-value native layout {namespace}.{name}" + )); + } + let mut visiting = BTreeSet::new(); + let x86 = compute_native_layout(raw, LayoutArchitecture::X86, &mut visiting)?; + let x64 = compute_native_layout(raw, LayoutArchitecture::X64, &mut visiting)?; + let arm64 = compute_native_layout(raw, LayoutArchitecture::Arm64, &mut visiting)?; + let kind = raw + .variants + .first() + .map(|variant| match variant.kind { + RawLayoutKind::Sequential => NativeAggregateKind::Struct, + RawLayoutKind::Union => NativeAggregateKind::Union, + RawLayoutKind::Unknown => NativeAggregateKind::Struct, + }) + .ok_or_else(|| format!("{namespace}.{name} has no native layout variants"))?; + if raw.variants.iter().any(|variant| { + matches!( + (kind, variant.kind), + (NativeAggregateKind::Struct, RawLayoutKind::Union) + | (NativeAggregateKind::Union, RawLayoutKind::Sequential) + ) + }) { + return Err(format!( + "architecture variants disagree on aggregate kind for {namespace}.{name}" + )); + } + let contract = Registry::builtin()?.layout_contract(raw)?; + let output_fields = x64 + .fields + .iter() + .filter(|field| { + contract.is_some_and(|contract| { + contract + .fields + .iter() + .any(|policy| policy.name == field.name && policy.contract.is_output()) + }) + }) + .map(|field| field.name.clone()) + .collect(); + let layout = NativeLayout { + namespace: namespace.into(), + name: name.into(), + kind, + by_value_compatible: raw.variants.iter().all(|variant| { + variant.packing == RawPacking::Default + && variant.forced_alignment.is_none() + && variant.kind == RawLayoutKind::Sequential + }) && [&x86, &x64, &arm64].into_iter().all(|layout| { + layout.fields.iter().all(|field| { + !matches!( + field.typ, + NativeFieldType::Pointer | NativeFieldType::Handle { .. } + ) + }) + }), + output_fields, + x86, + x64, + arm64, + }; + validate_native_result_layout(&layout)?; + Ok(layout) +} + +fn validate_native_result_layout(layout: &NativeLayout) -> Result<(), String> { + fn contains_owned_field(typ: &NativeFieldType) -> bool { + match typ { + NativeFieldType::Handle { cleanup } => *cleanup != Cleanup::None, + NativeFieldType::Struct { layout, .. } | NativeFieldType::Union { layout, .. } => { + layout + .fields + .iter() + .any(|field| contains_owned_field(&field.typ)) + } + NativeFieldType::Scalar(_) | NativeFieldType::Guid | NativeFieldType::Pointer => false, + } + } + let output_names = layout.output_fields.iter().collect::>(); + if output_names.len() != layout.output_fields.len() + || output_names.len() > dynwinrt_win32_contracts::MAX_PARAMETERS + { + return Err("native aggregate result fields must have unique bounded names".into()); + } + if !output_names.is_empty() && layout.kind != NativeAggregateKind::Struct { + return Err("native union result fields require a dedicated active-field contract".into()); + } + let mut expected_types = None; + for (native, architecture) in [ + (&layout.x86, LayoutArchitecture::X86), + (&layout.x64, LayoutArchitecture::X64), + (&layout.arm64, LayoutArchitecture::Arm64), + ] { + let mut names = Vec::new(); + let mut types = Vec::new(); + let mut end = 0; + let mut field_names = BTreeSet::new(); + for field in &native.fields { + if let NativeFieldType::Struct { .. } | NativeFieldType::Union { .. } = &field.typ { + if contains_owned_field(&field.typ) { + return Err( + "nested owned native fields require a dedicated result contract".into(), + ); + } + } else if contains_owned_field(&field.typ) && !output_names.contains(&field.name) { + return Err( + "owned native handle field is missing from aggregate result fields".into(), + ); + } + if output_names.is_empty() { + continue; + } + if !field_names.insert(&field.name) { + return Err("native aggregate result layout has duplicate field names".into()); + } + let element_size = match &field.typ { + NativeFieldType::Scalar(scalar) => { + native_scalar_size_alignment(*scalar, architecture).0 + } + NativeFieldType::Guid => 16, + NativeFieldType::Pointer | NativeFieldType::Handle { .. } => { + architecture.pointer_size() + } + NativeFieldType::Struct { layout, .. } | NativeFieldType::Union { layout, .. } => { + layout.size + } + }; + let size = element_size + .checked_mul(field.count as usize) + .ok_or("native aggregate result field size overflow")?; + end = field + .offset + .checked_add(size) + .filter(|_| field.count > 0 && field.offset >= end) + .ok_or("native aggregate result field layout overlaps or overflows")?; + if end > native.size + || !native.alignment.is_power_of_two() + || native.size % native.alignment != 0 + { + return Err("native aggregate result field is outside its native layout".into()); + } + if !output_names.contains(&field.name) { + continue; + } + if field.count != 1 + || !(matches!(field.typ, NativeFieldType::Scalar(_)) + || matches!(field.typ, NativeFieldType::Handle { cleanup } if cleanup != Cleanup::None)) + { + return Err( + "aggregate result field requires a scalar or independently owned handle".into(), + ); + } + names.push(field.name.clone()); + types.push(field.typ.clone()); + } + if names != layout.output_fields { + return Err("aggregate result fields must follow native declaration order on every architecture".into()); + } + if expected_types + .as_ref() + .is_some_and(|expected| *expected != types) + { + return Err("aggregate result field types differ between native architectures".into()); + } + expected_types = Some(types); + } + Ok(()) +} + +fn compute_native_layout( + raw: &RawNativeLayoutSet, + architecture: LayoutArchitecture, + visiting: &mut BTreeSet, +) -> Result { + let candidates = raw + .variants + .iter() + .filter(|variant| architecture.supports(variant.architectures)) + .collect::>(); + let [variant] = candidates.as_slice() else { + return Err(if candidates.is_empty() { + format!("missing {architecture:?} native layout facts") + } else { + format!("ambiguous {architecture:?} native layout facts") + }); + }; + let contract = Registry::builtin()?.layout_contract(raw)?; + if let Some(contract) = contract { + if contract + .fields + .iter() + .any(|policy| !variant.fields.iter().any(|field| field.name == policy.name)) + { + return Err("aggregate evidence refers to a missing native field".into()); + } + if let Some(size_field) = &contract.size_field + && !variant.fields.iter().any(|field| { + field.name == *size_field + && field.typ.pointer_depth == 0 + && field.typ.base == RawBaseType::Scalar(RawScalar::U32) + }) + { + return Err("aggregate size field is not a native u32".into()); + } + } + compute_native_layout_variant(variant, architecture, visiting, contract) +} + +fn compute_native_layout_variant( + raw: &RawNativeLayout, + architecture: LayoutArchitecture, + visiting: &mut BTreeSet, + contract: Option<&AggregateContract>, +) -> Result { + if raw.kind == RawLayoutKind::Unknown || raw.fields.is_empty() { + return Err("native aggregate has unknown or empty layout".into()); + } + let packing = match raw.packing { + RawPacking::Default => 8usize, + RawPacking::Explicit(value) if value.is_power_of_two() => usize::from(value), + RawPacking::Explicit(value) => { + return Err(format!("invalid native packing {value}")); + } + }; + let mut fields = Vec::with_capacity(raw.fields.len()); + let mut cursor = 0usize; + let mut aggregate_alignment = 1usize; + for raw_field in &raw.fields { + if raw_field.bitfield { + return Err(format!( + "native bitfield `{}` requires dedicated accessors", + raw_field.name + )); + } + if raw_field.flexible_array { + return Err(format!( + "flexible native array `{}` requires a variable-size contract", + raw_field.name + )); + } + if let Some(forced_alignment) = raw.forced_alignment { + if !forced_alignment.is_power_of_two() || forced_alignment > 8 { + return Err(format!( + "unsupported forced native alignment {forced_alignment}" + )); + } + aggregate_alignment = aggregate_alignment.max(forced_alignment); + } + let field_contract = contract + .and_then(|c| c.fields.iter().find(|p| p.name == raw_field.name)) + .map(|p| p.contract); + let (typ, element_size, element_alignment) = + native_field_type(&raw_field.typ, architecture, visiting, field_contract)?; + let count = raw_field.fixed_count.unwrap_or(1); + if field_contract.is_some_and(FieldContract::is_output) + && (raw.kind != RawLayoutKind::Sequential || count != 1) + { + return Err( + "native aggregate result arrays and unions require dedicated field contracts" + .into(), + ); + } + let count_u32 = u32::try_from(count) + .map_err(|_| format!("fixed array `{}` exceeds u32", raw_field.name))?; + if count_u32 == 0 { + return Err(format!("fixed array `{}` has zero length", raw_field.name)); + } + let field_size = element_size + .checked_mul(count) + .ok_or_else(|| format!("field `{}` size overflows", raw_field.name))?; + let effective_alignment = element_alignment.min(packing); + aggregate_alignment = aggregate_alignment.max(effective_alignment); + let offset = if raw.kind == RawLayoutKind::Union { + 0 + } else { + align_up(cursor, effective_alignment)? + }; + cursor = cursor.max( + offset + .checked_add(field_size) + .ok_or_else(|| format!("field `{}` end overflows", raw_field.name))?, + ); + fields.push(NativeField { + name: raw_field.name.clone(), + offset, + count: count_u32, + typ, + }); + } + let natural_size = align_up(cursor, aggregate_alignment)?; + let size = match raw.declared_size { + Some(size) if size < cursor || size % aggregate_alignment != 0 => { + return Err(format!( + "declared aggregate size {size} cannot contain {cursor} bytes at alignment {aggregate_alignment}" + )); + } + Some(size) => size, + None => natural_size, + }; + Ok(NativeArchitectureLayout { + size, + alignment: aggregate_alignment, + fields, + }) +} + +fn native_field_type( + raw: &RawType, + architecture: LayoutArchitecture, + visiting: &mut BTreeSet, + contract: Option, +) -> Result<(NativeFieldType, usize, usize), String> { + if let Some(contract) = contract { + let width = architecture.pointer_size(); + match contract { + FieldContract::RetainedPointer { .. } | FieldContract::NullPointer {} => { + if raw.pointer_depth == 0 + && !matches!( + &raw.base, + RawBaseType::Named { + kind: RawNamedKind::DataPointer | RawNamedKind::StringPointer { .. }, + .. + } + ) + { + return Err("retained field evidence requires a data pointer".into()); + } + return Ok((NativeFieldType::Pointer, width, width)); + } + FieldContract::BorrowedHandle {} | FieldContract::OwnedHandle { .. } => { + if raw.pointer_depth != 0 + || !matches!( + &raw.base, + RawBaseType::Named { + kind: RawNamedKind::Handle { .. }, + .. + } + ) + { + return Err("handle field evidence requires a native handle value".into()); + } + let cleanup = match contract { + FieldContract::OwnedHandle { cleanup } => cleanup, + _ => Cleanup::None, + }; + if cleanup != Cleanup::None && cleanup != handle_resource_cleanup(raw) { + return Err("owned field evidence conflicts with native cleanup".into()); + } + return Ok((NativeFieldType::Handle { cleanup }, width, width)); + } + FieldContract::BooleanInput { .. } + if raw.pointer_depth == 0 + && matches!( + raw.base, + RawBaseType::Scalar(RawScalar::Bool32 | RawScalar::I32) + ) => {} + FieldContract::OutputU32 {} + if raw.pointer_depth == 0 && raw.base == RawBaseType::Scalar(RawScalar::U32) => {} + FieldContract::BooleanInput { .. } | FieldContract::OutputU32 {} => { + return Err("scalar field evidence conflicts with native ABI".into()); + } + } + } + if raw.pointer_depth > 0 + || matches!( + raw.base, + RawBaseType::Named { + kind: RawNamedKind::Handle { .. } + | RawNamedKind::DataPointer + | RawNamedKind::StringPointer { .. } + | RawNamedKind::FunctionPointer + | RawNamedKind::ComInterface { .. }, + .. + } + ) + { + return Err("pointer-bearing native aggregate requires retained pointee ownership".into()); + } + match &raw.base { + RawBaseType::Scalar(scalar) => { + let scalar = native_scalar(*scalar)?; + let (size, alignment) = native_scalar_size_alignment(scalar, architecture); + Ok((NativeFieldType::Scalar(scalar), size, alignment)) + } + RawBaseType::Named { + kind: RawNamedKind::Guid, + .. + } => Ok((NativeFieldType::Guid, 16, 4)), + RawBaseType::Named { + namespace, + name, + kind: RawNamedKind::Enum { underlying, .. }, + } => { + let _ = (namespace, name); + let scalar = native_scalar(*underlying)?; + let (size, alignment) = native_scalar_size_alignment(scalar, architecture); + Ok((NativeFieldType::Scalar(scalar), size, alignment)) + } + RawBaseType::Named { + namespace, + name, + kind: RawNamedKind::NativeStruct { layout }, + } => { + let identity = format!("{namespace}.{name}"); + if Registry::builtin()? + .layout_contract(layout)? + .is_some_and(|contract| { + contract + .fields + .iter() + .any(|field| field.contract.is_output()) + }) + { + return Err( + "nested native aggregate result fields require a dedicated result contract" + .into(), + ); + } + if !visiting.insert(identity.clone()) { + return Err(format!("recursive nested native layout {identity}")); + } + let nested = compute_native_layout(layout, architecture, visiting)?; + visiting.remove(&identity); + let typ = match layout.variants.first().map(|variant| variant.kind) { + Some(RawLayoutKind::Sequential) => NativeFieldType::Struct { + name: identity, + layout: Box::new(nested.clone()), + by_value_compatible: false, + }, + Some(RawLayoutKind::Union) => NativeFieldType::Union { + name: identity, + layout: Box::new(nested.clone()), + by_value_compatible: false, + }, + _ => return Err("nested native aggregate has unknown layout kind".into()), + }; + Ok((typ, nested.size, nested.alignment)) + } + RawBaseType::Void => Err("void native aggregate field".into()), + RawBaseType::Unknown(reason) => Err(format!("unknown aggregate field type: {reason}")), + RawBaseType::Named { + namespace, + name, + kind: RawNamedKind::Unknown, + } => Err(format!( + "unsupported aggregate field type {namespace}.{name}" + )), + RawBaseType::Named { kind, .. } => { + Err(format!("unsupported aggregate field type {kind:?}")) + } + } +} + +fn native_scalar(scalar: RawScalar) -> Result { + Ok(match scalar { + RawScalar::I8 => NativeScalar::I8, + RawScalar::Bool8 | RawScalar::U8 => NativeScalar::U8, + RawScalar::I16 => NativeScalar::I16, + RawScalar::U16 | RawScalar::Char16 => NativeScalar::U16, + RawScalar::I32 | RawScalar::Bool32 => NativeScalar::I32, + RawScalar::U32 => NativeScalar::U32, + RawScalar::I64 => NativeScalar::I64, + RawScalar::U64 => NativeScalar::U64, + RawScalar::F32 => NativeScalar::F32, + RawScalar::F64 => NativeScalar::F64, + RawScalar::NativeIsize => NativeScalar::NativeIsize, + RawScalar::NativeUsize => NativeScalar::NativeUsize, + }) +} + +fn native_scalar_size_alignment( + scalar: NativeScalar, + architecture: LayoutArchitecture, +) -> (usize, usize) { + match scalar { + NativeScalar::I8 | NativeScalar::U8 => (1, 1), + NativeScalar::I16 | NativeScalar::U16 => (2, 2), + NativeScalar::I32 | NativeScalar::U32 | NativeScalar::F32 => (4, 4), + NativeScalar::I64 | NativeScalar::U64 | NativeScalar::F64 => (8, 8), + NativeScalar::NativeIsize | NativeScalar::NativeUsize => { + let width = architecture.pointer_size(); + (width, width) + } + } +} + +fn align_up(value: usize, alignment: usize) -> Result { + value + .checked_add(alignment - 1) + .map(|value| value & !(alignment - 1)) + .ok_or_else(|| "native layout alignment overflow".into()) +} + +fn handle_resource_cleanup(raw: &RawType) -> Cleanup { + let RawBaseType::Named { + kind: RawNamedKind::Handle { cleanup }, + .. + } = &raw.base + else { + return Cleanup::None; + }; + cleanup + .as_deref() + .and_then(|cleanup| parse_cleanup(cleanup).ok()) + .unwrap_or(Cleanup::None) +} + +fn validate_buffers(parameters: &[ParameterContract]) -> Result<(), String> { + for (index, parameter) in parameters.iter().enumerate() { + let Some(buffer) = ¶meter.buffer else { + if matches!( + parameter.typ, + ValueType::DataPointer | ValueType::StringPointer(_) + ) && parameter.direction != Direction::In + { + return Err(format!( + "writable pointer parameter `{}` has no size relationship", + parameter.name + )); + } + continue; + }; + if let Some(count_index) = buffer.count_parameter { + let count = parameters.get(count_index).ok_or_else(|| { + format!( + "buffer `{}` references missing count parameter {count_index}", + parameter.name + ) + })?; + if count_index == index { + return Err(format!("buffer `{}` counts itself", parameter.name)); + } + if !matches!( + count.typ, + ValueType::Scalar( + Scalar::U16 + | Scalar::I16 + | Scalar::U32 + | Scalar::I32 + | Scalar::U64 + | Scalar::I64 + ) + ) { + return Err(format!( + "buffer `{}` count parameter `{}` is not an integer scalar", + parameter.name, count.name + )); + } + } + } + Ok(()) +} + +pub(super) fn enum_definitions(raw: &RawFunction) -> Result, String> { + let mut definitions = BTreeMap::<(String, String), EnumDefinition>::new(); + for parameter in &raw.parameters { + collect_raw_enum(¶meter.typ, &mut definitions)?; + if let Some(buffer) = ¶meter.buffer { + collect_raw_enum(&buffer.element, &mut definitions)?; + } + } + collect_raw_enum(&raw.return_type, &mut definitions)?; + Ok(definitions.into_values().collect()) +} + +fn collect_raw_enum( + raw: &RawType, + definitions: &mut BTreeMap<(String, String), EnumDefinition>, +) -> Result<(), String> { + let RawBaseType::Named { + namespace, + name, + kind: + RawNamedKind::Enum { + underlying, + members, + is_flags, + }, + } = &raw.base + else { + return Ok(()); + }; + let definition = EnumDefinition { + namespace: namespace.clone(), + name: name.clone(), + underlying: map_enum_underlying(*underlying)?, + members: members + .iter() + .map(|member| EnumMember { + name: member.name.clone(), + value: member.value, + }) + .collect(), + is_flags: *is_flags, + }; + if let Some(existing) = + definitions.insert((namespace.clone(), name.clone()), definition.clone()) + && existing != definition + { + return Err(format!("enum metadata disagrees for {namespace}.{name}")); + } + Ok(()) +} + +fn map_direction(direction: RawDirection) -> Direction { + match direction { + RawDirection::In => Direction::In, + RawDirection::Out => Direction::Out, + RawDirection::InOut => Direction::InOut, + } +} + +fn map_constness(constness: crate::win32_metadata::RawConstness) -> Constness { + match constness { + crate::win32_metadata::RawConstness::Const => Constness::Const, + crate::win32_metadata::RawConstness::Mutable => Constness::Mutable, + crate::win32_metadata::RawConstness::Unspecified => Constness::Unspecified, + crate::win32_metadata::RawConstness::Mixed => Constness::Mixed, + } +} + +fn raw_native_name(raw: &RawType) -> Option<(String, String)> { + match &raw.base { + RawBaseType::Named { + namespace, name, .. + } => Some((namespace.clone(), name.clone())), + RawBaseType::Void | RawBaseType::Scalar(_) | RawBaseType::Unknown(_) => None, + } +} + +fn map_scalar(scalar: RawScalar) -> Scalar { + match scalar { + RawScalar::Bool8 => Scalar::Bool8, + RawScalar::Bool32 => Scalar::Bool32, + RawScalar::I8 => Scalar::I8, + RawScalar::U8 => Scalar::U8, + RawScalar::I16 => Scalar::I16, + RawScalar::U16 | RawScalar::Char16 => Scalar::U16, + RawScalar::I32 => Scalar::I32, + RawScalar::U32 => Scalar::U32, + RawScalar::I64 => Scalar::I64, + RawScalar::U64 => Scalar::U64, + RawScalar::F32 => Scalar::F32, + RawScalar::F64 => Scalar::F64, + RawScalar::NativeIsize => Scalar::NativeIsize, + RawScalar::NativeUsize => Scalar::NativeUsize, + } +} + +fn map_enum_underlying(scalar: RawScalar) -> Result { + match scalar { + RawScalar::I8 => Ok(EnumUnderlying::I8), + RawScalar::U8 => Ok(EnumUnderlying::U8), + RawScalar::I16 => Ok(EnumUnderlying::I16), + RawScalar::U16 => Ok(EnumUnderlying::U16), + RawScalar::I32 => Ok(EnumUnderlying::I32), + RawScalar::U32 => Ok(EnumUnderlying::U32), + RawScalar::I64 + | RawScalar::U64 + | RawScalar::NativeIsize + | RawScalar::NativeUsize + | RawScalar::F32 + | RawScalar::F64 + | RawScalar::Char16 + | RawScalar::Bool8 + | RawScalar::Bool32 => { + Err("enum underlying type is not representable as a JS number enum".into()) + } + } +} + +fn scalar_abi(scalar: Scalar) -> AbiType { + match scalar { + Scalar::Bool8 => AbiType::U8, + Scalar::Bool32 => AbiType::Bool32, + Scalar::I8 => AbiType::I8, + Scalar::U8 => AbiType::U8, + Scalar::I16 => AbiType::I16, + Scalar::U16 => AbiType::U16, + Scalar::I32 => AbiType::I32, + Scalar::U32 => AbiType::U32, + Scalar::I64 => AbiType::I64, + Scalar::U64 => AbiType::U64, + Scalar::F32 => AbiType::F32, + Scalar::F64 => AbiType::F64, + Scalar::NativeIsize => AbiType::I64, + Scalar::NativeUsize => AbiType::U64, + } +} + +fn enum_abi(underlying: EnumUnderlying) -> AbiType { + match underlying { + EnumUnderlying::I8 => AbiType::I8, + EnumUnderlying::U8 => AbiType::U8, + EnumUnderlying::I16 => AbiType::I16, + EnumUnderlying::U16 => AbiType::U16, + EnumUnderlying::I32 => AbiType::I32, + EnumUnderlying::U32 => AbiType::U32, + } +} + +fn map_buffer_element(raw: &RawType) -> Result<(usize, usize), String> { + match (&raw.base, raw.pointer_depth) { + (RawBaseType::Scalar(scalar), 0) => { + let size = element_size(*scalar); + Ok((size, size.min(8))) + } + ( + RawBaseType::Named { + namespace, + name, + kind: RawNamedKind::NativeStruct { layout }, + }, + 0, + ) => { + let layout = validate_native_layout(namespace, name, layout)?; + if layout.x64.size != layout.arm64.size + || layout.x64.alignment != layout.arm64.alignment + { + return Err("native buffer element layout differs between x64 and ARM64".into()); + } + Ok((layout.x64.size, layout.x64.alignment)) + } + ( + RawBaseType::Named { + kind: RawNamedKind::Guid, + .. + }, + 0, + ) => Ok((16, 4)), + _ => Err("native buffer element has no validated fixed layout".into()), + } +} + +fn element_size(scalar: RawScalar) -> usize { + match scalar { + RawScalar::Bool8 | RawScalar::I8 | RawScalar::U8 => 1, + RawScalar::I16 | RawScalar::U16 | RawScalar::Char16 => 2, + RawScalar::I32 | RawScalar::U32 | RawScalar::F32 | RawScalar::Bool32 => 4, + RawScalar::I64 + | RawScalar::U64 + | RawScalar::F64 + | RawScalar::NativeIsize + | RawScalar::NativeUsize => 8, + } +} + +fn parse_cleanup(value: &str) -> Result { + match value { + "CloseHandle" => Ok(Cleanup::CloseHandle), + "RegCloseKey" => Ok(Cleanup::RegCloseKey), + "LocalFree" => Ok(Cleanup::LocalFree), + "GlobalFree" => Ok(Cleanup::GlobalFree), + "FreeLibrary" => Ok(Cleanup::FreeLibrary), + "CloseServiceHandle" => Ok(Cleanup::CloseServiceHandle), + "CoTaskMemFree" => Ok(Cleanup::CoTaskMemFree), + "CredFree" => Ok(Cleanup::CredFree), + other => Err(format!("unsupported native cleanup `{other}`")), + } +} + +fn validate_module(module: &str) -> Result<(), String> { + let lower = module.to_ascii_lowercase(); + if module.is_empty() + || !(lower.ends_with(".dll") || lower.ends_with(".drv")) + || module + .chars() + .any(|character| matches!(character, '/' | '\\' | ':')) + { + return Err(format!("module `{module}` is not a bare System32 DLL name")); + } + Ok(()) +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/naming_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/naming_tests.rs new file mode 100644 index 00000000..0dd6d078 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/naming_tests.rs @@ -0,0 +1,274 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::{ir::*, test_support::*, *}; +use crate::win32_metadata::*; +use std::collections::BTreeSet; + +#[test] +fn strict_bindings_and_generated_locals_have_unique_projected_parameter_names() { + let raw_names = [ + "eval", + "arguments", + "eval_", + "arguments_", + "lpValue", + "value", + "_call", + "_return", + "_outputs", + "_subsystem", + "_nativeAggregate", + "_bufferCount", + "_scalarPointer", + "_u32Flags", + "_bindCollisionValuesPlan", + "undefined", + "pClass", + "class", + ]; + let mut function = synthetic_function("CollisionValues"); + function.parameters = raw_names + .iter() + .map(|name| parameter(name, scalar(RawScalar::U32), RawDirection::In)) + .collect(); + let projected = project_one(function.clone()); + assert_eq!(projected.js_name, "collisionValues"); + assert_eq!(projected.parameters.len(), raw_names.len()); + let names = projected + .parameters + .iter() + .map(|p| p.name.as_str()) + .collect::>(); + assert_eq!( + names.iter().copied().collect::>().len(), + names.len() + ); + assert_eq!( + &names[..6], + &[ + "eval_", + "arguments_", + "eval__", + "arguments__", + "value", + "value_" + ] + ); + for original in &raw_names[6..] { + assert!(!names.contains(original), "{original}"); + } + for (index, input) in projected.inputs.iter().enumerate() { + assert_eq!( + *input, + InputExpression::Surface { + parameter_index: index, + conversion: Conversion::U32, + } + ); + } + let (generated, omitted) = generate_apis_files(&apis(vec![function]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + for name in &names { + assert!(generated.dts.contains(&format!("{name}: number"))); + } + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +let received +const runtime={DynWin32:{u32:value=>value,toNumber:Number},DynWin32Function:{bind(){ + return {invoke(args){received=args;return {returnValue:42,outputs:[]}}} +}}} +"#, + &format!( + r#" +const supplied=Array.from({{length:{}}},(_,index)=>index+1) +assert.equal(projected.collisionValues(...supplied),42) +assert.deepEqual(Array.from(received),supplied) +assert.equal(typeof projected.Apis.collisionValues,'function') +"#, + raw_names.len() + ), + ); +} + +#[test] +fn retired_policy_helpers_no_longer_reserve_native_parameter_names() { + let raw_names = [ + "_borrowedHkeyOutput", + "_performanceDataCount0", + "_hkeyBits", + "_isPredefinedHkey", + "_emptyNativeString", + "_bindNoPoliciesPlanBorrowed", + ]; + let mut function = synthetic_function("NoPolicies"); + function.parameters = raw_names + .iter() + .map(|name| parameter(name, scalar(RawScalar::U32), RawDirection::In)) + .collect(); + let projected = project_one(function); + assert_eq!( + projected + .parameters + .iter() + .map(|p| p.name.as_str()) + .collect::>(), + raw_names + ); + assert_eq!( + projected.runtime.call_contract, + CallContract::defaults(&projected.runtime.signature_shape(64)) + ); +} + +#[test] +fn normalized_output_names_do_not_overwrite_other_native_results() { + let mut function = synthetic_function("CollidingOutputs"); + function.parameters = ["lpValue", "value", "lpResult", "result", "value_"] + .into_iter() + .map(|name| { + parameter( + name, + pointer(scalar(RawScalar::U32), 1, RawConstness::Mutable), + RawDirection::Out, + ) + }) + .collect(); + let projected = project_one(function.clone()); + let ReturnShape::Object { outputs, .. } = &projected.return_shape else { + panic!("outputs") + }; + assert_eq!( + outputs.iter().map(|o| o.name.as_str()).collect::>(), + ["value", "value_", "value__", "value___", "value____"] + ); + assert_eq!( + outputs.iter().map(|o| o.output_index).collect::>(), + [0, 1, 2, 3, 4] + ); + let (generated, omitted) = generate_apis_files(&apis(vec![function]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const runtime={DynWin32:{toNumber:Number},DynWin32Function:{bind(){ + return {invoke(){return {returnValue:9,outputs:[1,2,3,4,5]}}} +}}} +"#, + r#" +const result=projected.collidingOutputs() +assert.deepEqual(Object.keys(result),['result','value','value_','value__','value___','value____']) +assert.deepEqual(Object.values(result),[9,1,2,3,4,5]) +"#, + ); +} + +#[test] +fn layout_constants_are_not_shadowed_by_projected_inputs() { + let shape = RawNativeLayoutSet { + recursive: false, + evidence: None, + variants: vec![RawNativeLayout { + architectures: RawArchitectures { + x86: true, + x64: true, + arm64: true, + }, + kind: RawLayoutKind::Sequential, + packing: RawPacking::Default, + declared_size: None, + forced_alignment: None, + fields: vec![RawNativeField { + name: "x".into(), + typ: scalar(RawScalar::I32), + fixed_count: None, + bitfield: false, + flexible_array: false, + }], + }], + }; + let mut function = synthetic_function("LayoutCollision"); + function.parameters = vec![ + parameter( + "_nativeLayout_POINT", + scalar(RawScalar::U32), + RawDirection::In, + ), + parameter( + "point", + RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "POINT".into(), + kind: RawNamedKind::NativeStruct { + layout: Box::new(shape), + }, + }, + pointer_depth: 1, + constness: RawConstness::Const, + }, + RawDirection::In, + ), + ]; + let projected = project_one(function.clone()); + assert_eq!(projected.parameters[0].name, "_nativeLayout_POINT_"); + let (generated, omitted) = generate_apis_files(&apis(vec![function]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +let received +const runtime={DynWin32:{ + u32:value=>value,toNumber:Number, + nativeStruct(value,descriptor){assert.equal(JSON.parse(descriptor).name,'Tests.POINT');return value} +},DynWin32Function:{bind(){ + return {invoke(args){received=args;return {returnValue:0,outputs:[]}}} +}}} +"#, + r#" +const point={} +projected.layoutCollision(123,point) +assert.equal(received[0],123) +assert.equal(received[1],point) +"#, + ); +} + +#[test] +fn real_raise_exception_module_is_strict_mode_safe_without_invoking_native_code() { + let Some(path) = metadata() else { return }; + let raw = metadata_function( + &path, + "Windows.Win32.System.Diagnostics.Debug", + "RaiseException", + ); + let projected = project_one(raw.clone()); + assert_eq!(projected.metadata_name, "RaiseException"); + assert_eq!(projected.js_name, "raiseException"); + assert_eq!( + projected + .parameters + .iter() + .map(|p| p.name.as_str()) + .collect::>(), + ["dwExceptionCode", "dwExceptionFlags", "arguments_"] + ); + let (generated, omitted) = generate_apis_files(&apis(vec![raw]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const runtime={DynWin32:{},DynWin32Function:{bind(){throw Error('native bind during import')}}} +"#, + r#" +assert.equal(typeof projected.raiseException,'function') +assert.equal(projected.Apis.raiseException,projected.raiseException) +assert(Object.isFrozen(projected.Apis)) +"#, + ); +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/native_call_outcome_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/native_call_outcome_tests.rs new file mode 100644 index 00000000..5049b356 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/native_call_outcome_tests.rs @@ -0,0 +1,306 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::*; + +#[test] +fn consuming_module_wrapper_preserves_result_order_and_validates_resource_inputs() { + let Some(path) = test_support::metadata() else { + return; + }; + let raw = test_support::metadata_function(&path, "Windows.Win32.Foundation", "FreeLibrary"); + let (generated, omitted) = + generate_apis_files(&test_support::apis(vec![raw]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + test_support::run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const moduleResource={} +const calls=[] +let succeeded=true +const runtime={DynWin32:{ + resource(value,cleanup) { + assert.equal(cleanup,'freeLibrary') + if(value!==moduleResource) throw new TypeError('managed module resource required') + return value + }, + toBoolean:value=>value!==0 +},DynWin32Function:{bind(spec) { + assert.equal(spec.dll,'KERNEL32.dll') + assert.equal(spec.entryPoint,'FreeLibrary') + assert.equal(spec.returnType,'bool32') + assert.equal(spec.returnCleanup,'none') + assert.equal(spec.successRule,'nonzero') + assert.equal(spec.captureLastError,true) + assert.deepEqual(JSON.parse(spec.callContractDescriptor),{ + version:3, + results:[{ + target:{kind:'return'}, + onSuccess:{kind:'defined',ownership:{kind:'value'},delivery:'deliver'}, + onFailure:{kind:'defined',ownership:{kind:'value'},delivery:'deliver'}, + overrides:[] + }], + resourceEffects:[] + }) + assert.equal(spec.parameters[0].type,'handle') + assert.equal(spec.parameters[0].direction,'in') + assert.equal(spec.parameters[0].consumesResource,true) + assert.equal(spec.parameters[0].resourceCleanup,'freeLibrary') + return {invoke(args) { + calls.push(args) + let reads=0 + return {returnValue:succeeded?1:0,lastError:succeeded?0:5, + get outputs(){assert.equal(++reads,1);return []}} + }} +}}} +"#, + r#" +for(const state of [true,false]) { + succeeded=state + const result=projected.freeLibrary(moduleResource) + assert.deepEqual(Object.keys(result),['result','lastError']) + assert.equal(result.result,state) + assert.equal(result.lastError,state?0:5) + assert.equal(calls.at(-1)[0],moduleResource) +} +const before=calls.length +assert.throws(()=>projected.freeLibrary(123n),/managed module/) +assert.throws(()=>projected.freeLibrary({value:123n}),/managed module/) +assert.equal(calls.length,before) +"#, + ); +} + +#[test] +fn registry_native_outcomes_preserve_counts_aliases_and_owned_results() { + let Some(metadata) = test_support::metadata() else { + return; + }; + let mut raw = + crate::win32_metadata::parse_apis(&metadata, "Windows.Win32.System.Registry", "Apis") + .unwrap(); + raw.functions.retain(|function| { + [ + "RegOpenKeyA", + "RegOpenKeyW", + "RegOpenKeyExA", + "RegOpenKeyExW", + "RegQueryValueExA", + "RegQueryValueExW", + "RegGetValueA", + "RegGetValueW", + ] + .contains(&function.name.as_str()) + }); + let (generated, omitted) = generate_apis_files(&raw, "@test/runtime/win32"); + assert!(omitted.is_empty(), "{omitted:?}"); + assert!( + generated + .dts + .contains("key: DynWin32Resource | bigint | null") + ); + assert!(!generated.js.contains(".value")); + assert!(generated.dts.contains("dataSize: number | null")); + for retired_helper in [ + "_hkeyBits", + "_isPredefinedHkey", + "_emptyNativeString", + "_borrowedHkeyOutput", + "_performanceDataCount", + "PlanBorrowed", + ] { + assert!(!generated.js.contains(retired_helper), "{retired_helper}"); + } + assert!(generated.js.contains("DynWin32.isUnavailable(_outputs[1])")); + assert!( + generated + .js + .contains("DynWin32.toResourceOrHandle(_outputs[0])") + ); + let setup = r#" +const assert = require('node:assert/strict') +const managed = new WeakMap() +const calls = [] +const bindings = new Map() +const unavailable = Symbol('native unavailable output') +const discarded = Symbol('native discarded output') +let status = 0 +let returned = null +let reportedCount = 0 +let aliasConversions = 0 +const extent = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype), 'byteLength').get +const helpers = { + handle(value) { + if (typeof value === 'bigint' || (typeof value === 'number' && Number.isSafeInteger(value)) || managed.has(value)) return { input: value } + throw new TypeError('not a native handle') + }, + isUnavailable: value => value === unavailable || value === discarded, + toNumber(value) { + assert.notEqual(value, unavailable, 'undefined native output must not be converted') + return Number(value) + }, + toResource() { throw new Error('alias-capable outputs must use the native outcome conversion') }, + toResourceOrHandle(value) { aliasConversions++; return value }, + wideString: value => value, + ansiString: value => value, + u32: value => value, + nullPointer: () => null, + dataPointer: value => value, + alignedDataPointer: value => value, + byteLength: value => Reflect.apply(extent, value, []), +} +const predefined = [-2147483648, -2147483647, -2147483646, -2147483645, -2147483644, -2147483643, -2147483642, -2147483568, -2147483552] +const runtime = { + DynWin32: helpers, + DynWin32Function: { + bind(spec) { + bindings.set(spec.entryPoint, (bindings.get(spec.entryPoint) ?? 0) + 1) + assert.equal(typeof spec.callContractDescriptor, 'string') + const contract = JSON.parse(spec.callContractDescriptor) + const query = /^(RegQueryValueEx|RegGetValue)/.test(spec.entryPoint) + const get = spec.entryPoint.startsWith('RegGetValue') + const extended = spec.entryPoint.startsWith('RegOpenKeyEx') + const target = query ? (get ? 6 : 5) : (extended ? 4 : 2) + const width = spec.entryPoint.endsWith('W') ? 2 : 1 + const inputs = query + ? [{kind:'bits-in',parameter:0,mask:0xffffffff,values:[0x80000004]}] + : [...(extended ? [{kind:'handle-in',parameter:0,values:predefined}] : []), + {kind:'null-or-empty',parameter:1,elementWidth:width}] + const valuePolicy = {kind:'defined',ownership:{kind:'value'},delivery:'deliver'} + const valueResult = target => ({target,onSuccess:valuePolicy,onFailure:valuePolicy,overrides:[]}) + const owned = {kind:'owned',cleanup:'reg-close-key'} + const result = query ? valueResult({kind:'parameter',index:target}) : { + target:{kind:'parameter',index:target}, + onSuccess:{kind:'defined',ownership:owned,delivery:'deliver'}, + onFailure:{kind:'undefined'}, + overrides:[] + } + result.overrides = query + ? [{when:{inputs,returnValue:234,succeeded:null},policy:{kind:'undefined'}}] + : [ + {when:{inputs,returnValue:null,succeeded:true},policy:{kind:'defined',ownership:{kind:'alias-input',parameter:0},delivery:'deliver'}}, + {when:{inputs,returnValue:null,succeeded:false},policy:{kind:'undefined'}} + ] + assert.deepEqual(contract, { + version:3, + results: [ + valueResult({kind:'return'}), + ...(query ? [valueResult({kind:'parameter',index:get ? 4 : 3})] : []), + result + ], + resourceEffects:[] + }) + assert.equal(spec.parameters[target].cleanup, query ? 'none' : 'regCloseKey') + return { + invoke(args) { + calls.push({ spec, args }) + if (query) { + const outputs = [1, reportedCount] + const data = args[get ? 4 : 3] + if (status === 0 && data != null) data.fill(0x5a) + return { returnValue: status, outputs, succeeded: status === 0 } + } + return { returnValue: status, outputs: [returned], succeeded: status === 0 } + } + } + } + } +} +"#; + let checks = r#" +for (const name of ['regQueryValueExA', 'regQueryValueExW', 'regGetValueA', 'regGetValueW']) { + const get = name.startsWith('regGetValue') + const invoke = (key, value, data) => get + ? projected[name](key, null, value, 0xffff, data) + : projected[name](key, value, data) + const resource = {} + managed.set(resource, 0xffffffff80000004n) + Object.defineProperty(resource, 'value', { get() { throw Error('resource.value was read') } }) + for (const key of [0x80000004n, -2147483644n, resource]) { + status = 0 + reportedCount = 8 + const data = Buffer.alloc(8) + let result = invoke(key, 'Global', data) + assert.equal(result.status, 0) + assert.equal(result.dataSize, 8) + assert(data.every(byte => byte === 0x5a)) + assert.equal(calls.at(-1).args[get ? 5 : 4], 8) + assert.equal(calls.at(-1).args[0].input, key) + status = 234 + reportedCount = unavailable + result = invoke(key, 'Global', null) + assert.equal(result.status, 234) + assert.equal(result.dataSize, null) + assert.equal(calls.at(-1).args[get ? 5 : 4], 0) + result = invoke(key, 'Global', Buffer.alloc(1)) + assert.equal(result.status, 234) + assert.equal(result.dataSize, null) + assert.equal(calls.at(-1).args[get ? 5 : 4], 1) + } + reportedCount = 4096 + let result = invoke(0x80000002n, 'ProductName', Buffer.alloc(1)) + assert.equal(result.status, 234) + assert.equal(result.dataSize, 4096) + status = 0 + result = invoke(0x80000002n, 'ProductName', null) + assert.equal(result.dataSize, 4096) +} +assert.equal(calls.length, 44) +for (const [name, empty] of [ + ['regOpenKeyA', Buffer.from([0])], + ['regOpenKeyW', Buffer.from([0, 0])], + ['regOpenKeyExA', Buffer.from([0])], + ['regOpenKeyExW', Buffer.from([0, 0])], +]) { + const extended = name.startsWith('regOpenKeyEx') + const invoke = (key, subkey) => extended + ? projected[name](key, subkey, 0, 1 | 2) + : projected[name](key, subkey) + Object.defineProperty(empty, 'length', { value: 0xffffffff }) + Object.defineProperty(empty, 'byteLength', { value: 0xffffffff }) + for (const subkey of [null, '', empty]) { + for (const canonical of [-2147483646n, 0xffffffff80000002n]) { + returned = 0xffffffff80000002n + const conversions = aliasConversions + const result = invoke(canonical, subkey) + assert.equal(result.key, returned) + assert.equal(calls.at(-1).args[0].input, canonical) + assert.equal(calls.at(-1).spec.parameters[extended ? 4 : 2].cleanup, 'regCloseKey') + assert.equal(aliasConversions, conversions + 1) + } + const fresh = {owned: 0x310n} + returned = extended ? fresh : 0x80000002n + assert.equal(invoke(0x80000002n, subkey).key, returned) + } + const owned = { owned: 123n } + returned = owned + assert.equal(invoke(0x80000002n, 'Software').key, owned) + returned = extended ? owned : 42n + assert.equal(invoke(42n, null).key, returned) + const input = {} + managed.set(input, 42n) + Object.defineProperty(input, 'value', { get() { throw Error('managed owner must not be inspected') } }) + returned = extended ? owned : input + assert.equal(invoke(input, '').key, returned) + const predefinedInput = {} + managed.set(predefinedInput, 0xffffffff80000002n) + returned = predefinedInput + assert.equal(invoke(predefinedInput, null).key, predefinedInput) + const zeroExtendedInput = {} + managed.set(zeroExtendedInput, 0x80000002n) + returned = extended ? owned : zeroExtendedInput + assert.equal(invoke(zeroExtendedInput, null).key, returned) + status = 5 + for (const nonDelivered of [null, unavailable, discarded]) { + returned = nonDelivered + assert.equal(invoke(0x80000002n, null).key, null) + assert.equal(invoke(input, '').key, null) + } + status = 0 +} +assert.equal(bindings.size, 8) +assert([...bindings.values()].every(count => count === 1)) +"#; + test_support::run_js(&generated, setup, checks); +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/project.rs b/tools/dynwinrt-codegen/src/codegen/win32/project.rs new file mode 100644 index 00000000..16957f92 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/project.rs @@ -0,0 +1,1088 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::collections::{BTreeMap, BTreeSet}; + +use crate::win32_contracts::{BuilderKind, FieldContract, FunctionEffect, Registry}; +use crate::win32_metadata::{ + RawApis, RawBaseType, RawBufferSize, RawCallingConvention, RawDirection, RawFunction, + RawNamedKind, RawScalar, +}; + +use super::ir::{ + AbiType, AsyncIoKind, Cleanup, Conversion, Delivery, Direction, EnumDefinition, EnumUnderlying, + FunctionContract, InputExpression, NativeBuilderFieldKind, NativeLayout, NativeOutputFieldKind, + OmittedFunction, ProjectedApis, ProjectedAsyncFunction, ProjectedFunction, + ProjectedNativeBuilder, ProjectedNativeBuilderField, ProjectedNativeOutputField, + ProjectedOutput, ProjectionResult, ResultContract, ResultOwnership, ResultPolicy, ResultTarget, + ReturnShape, RuntimeParameter, RuntimePlan, Scalar, StringEncoding, SurfaceParameter, + SurfaceType, ValueType, +}; +use super::model; + +pub(super) fn project_apis(raw: &RawApis) -> ProjectionResult { + let mut async_functions = Vec::new(); + let mut async_names = BTreeSet::new(); + for function in &raw.functions { + let candidates = raw + .functions + .iter() + .filter(|candidate| candidate.name == function.name) + .collect::>(); + if let [function] = candidates.as_slice() + && let Some(projected) = project_async_function(function) + { + async_names.insert(function.name.clone()); + async_functions.push(projected); + } + } + let sync_raw = RawApis { + namespace: raw.namespace.clone(), + class_name: raw.class_name.clone(), + functions: raw + .functions + .iter() + .filter(|function| !async_names.contains(&function.name)) + .cloned() + .collect(), + }; + let (contracts, mut omitted) = model::validate_apis(&sync_raw); + let mut functions = Vec::new(); + let mut enums = BTreeMap::new(); + for contract in contracts { + match project_function(&contract) { + Ok(function) => { + for definition in &contract.enums { + enums.insert( + (definition.namespace.clone(), definition.name.clone()), + definition.clone(), + ); + } + functions.push(function); + } + Err(reason) => omitted.push(( + format!("{}.{}::{}", raw.namespace, raw.class_name, contract.name), + reason, + )), + } + } + functions.sort_by(|left, right| left.js_name.cmp(&right.js_name)); + async_functions.sort_by(|left, right| left.js_name.cmp(&right.js_name)); + assign_unicode_aliases(&mut functions); + let native_builders = project_native_builders(&functions); + ProjectionResult { + projected: ProjectedApis { + namespace: raw.namespace.clone(), + class_name: raw.class_name.clone(), + functions, + enums: enums.into_values().collect(), + native_builders, + async_functions, + }, + omitted: omitted + .into_iter() + .map(|(identity, reason)| OmittedFunction { identity, reason }) + .collect(), + } +} + +fn project_async_function(function: &RawFunction) -> Option { + let registry = Registry::builtin().ok()?; + let entry = registry.function_entry(function)?; + let policy = registry.function_policy(function).ok()?; + let _ = policy; + let (kind, roles) = entry.contracts.iter().find_map(|effect| match effect { + FunctionEffect::OverlappedIo { + operation, + file_parameter, + buffer_parameter, + count_parameter, + transferred_parameter, + overlapped_parameter, + } => Some(( + *operation, + [ + *file_parameter, + *buffer_parameter, + *count_parameter, + *transferred_parameter, + *overlapped_parameter, + ], + )), + _ => None, + })?; + // The runtime primitive implements the five-argument OVERLAPPED ABI; the + // exact import and parameter roles come from pinned evidence. + if roles != [0, 1, 2, 3, 4] { + return None; + } + if function.parameters.len() != 5 + || function.calling_convention != RawCallingConvention::System + || function.variadic + || !function.architectures.x64 + || !function.architectures.arm64 + || !function.supports_last_error + || !matches!( + function.return_type.base, + RawBaseType::Scalar(RawScalar::Bool32) + ) + { + return None; + } + let [file, buffer, count, transferred, overlapped] = function.parameters.as_slice() else { + return None; + }; + let file_ok = file.direction == RawDirection::In + && file.typ.pointer_depth == 0 + && matches!( + &file.typ.base, + RawBaseType::Named { + name, + kind: RawNamedKind::Handle { .. }, + .. + } if name == "HANDLE" + ); + let buffer_ok = buffer.direction + == match kind { + AsyncIoKind::Read => RawDirection::Out, + AsyncIoKind::Write => RawDirection::In, + } + && buffer.typ.pointer_depth > 0 + && matches!( + buffer.buffer.as_ref().map(|buffer| &buffer.size), + Some(RawBufferSize::ByteCountParam(2)) + ); + let count_ok = count.direction == RawDirection::In + && count.typ.pointer_depth == 0 + && matches!(count.typ.base, RawBaseType::Scalar(RawScalar::U32)); + let transferred_ok = transferred.direction == RawDirection::Out + && transferred.typ.pointer_depth == 1 + && matches!(transferred.typ.base, RawBaseType::Scalar(RawScalar::U32)); + let overlapped_ok = overlapped.direction == RawDirection::InOut + && overlapped.nullable + && overlapped.typ.pointer_depth == 1 + && matches!( + &overlapped.typ.base, + RawBaseType::Named { + name, + kind: RawNamedKind::NativeStruct { .. }, + .. + } if name == "OVERLAPPED" + ); + (file_ok && buffer_ok && count_ok && transferred_ok && overlapped_ok).then(|| { + ProjectedAsyncFunction { + js_name: format!("{}Async", camel_case(&function.name)), + kind, + } + }) +} + +fn project_native_builders(functions: &[ProjectedFunction]) -> Vec { + let mut layouts = BTreeMap::<(String, String), &NativeLayout>::new(); + for function in functions { + for input in &function.inputs { + if let InputExpression::NativeAggregate { layout, .. } = input { + layouts + .entry((layout.namespace.clone(), layout.name.clone())) + .or_insert(layout); + } + } + } + layouts + .into_values() + .filter_map(project_native_builder) + .collect() +} + +fn project_native_builder(layout: &NativeLayout) -> Option { + let contract = Registry::builtin() + .ok()? + .type_entry(&layout.namespace, &layout.name)? + .aggregate + .as_ref()?; + let js_name = match contract.builder? { + BuilderKind::SecurityAttributes => "SecurityAttributes", + BuilderKind::StartupInfoAnsi => "StartupInfoA", + BuilderKind::StartupInfoWide => "StartupInfoW", + BuilderKind::ProcessInformation => "ProcessInformation", + }; + let surface_name = |name: &str| { + for prefix in ["lp", "dw", "b", "h"] { + if let Some(rest) = name.strip_prefix(prefix) + && rest.chars().next().is_some_and(|c| c.is_ascii_uppercase()) + { + return lower_first(rest); + } + } + lower_first(name) + }; + let mut fields = Vec::new(); + let mut outputs = Vec::new(); + for field in &contract.fields { + let native_name = field.name.clone(); + let surface_name = surface_name(&field.name); + match field.contract { + FieldContract::RetainedPointer { nullable, optional } => { + fields.push(ProjectedNativeBuilderField { + native_name, + surface_name, + kind: NativeBuilderFieldKind::DataPointer { nullable }, + optional, + }) + } + FieldContract::BooleanInput { optional } => fields.push(ProjectedNativeBuilderField { + native_name, + surface_name, + kind: NativeBuilderFieldKind::Boolean, + optional, + }), + FieldContract::OwnedHandle { cleanup } => outputs.push(ProjectedNativeOutputField { + native_name, + surface_name, + kind: NativeOutputFieldKind::Resource { cleanup }, + }), + FieldContract::OutputU32 {} => outputs.push(ProjectedNativeOutputField { + native_name, + surface_name, + kind: NativeOutputFieldKind::U32, + }), + FieldContract::NullPointer {} | FieldContract::BorrowedHandle {} => {} + } + } + Some(ProjectedNativeBuilder { + layout_name: layout.name.clone(), + js_name: js_name.into(), + size_field: contract.size_field.clone(), + fields, + outputs, + }) +} + +pub(super) fn project_function(contract: &FunctionContract) -> Result { + model::validate_call_contract(contract)?; + let count_buffers = count_buffer_relations(contract)?; + let mut input_names = reserved_input_bindings(contract); + let mut output_names = BTreeSet::from([ + "status".to_string(), + "result".to_string(), + "lastError".to_string(), + ]); + let mut parameters = Vec::::new(); + let mut native_surface = vec![None; contract.parameters.len()]; + let mut inputs = Vec::::new(); + let mut runtime_parameters = Vec::::new(); + + for (index, parameter) in contract.parameters.iter().enumerate() { + let is_buffer_count = count_buffers.contains_key(&index); + if should_surface_input(parameter, is_buffer_count) { + let surface_index = parameters.len(); + let minimum_bytes = parameter + .buffer + .as_ref() + .and_then(|buffer| { + buffer.constant_count.map(|count| { + count.checked_mul(buffer.element_size).ok_or_else(|| { + format!("buffer `{}` fixed size overflows usize", parameter.name) + }) + }) + }) + .transpose()? + .or(matches!(parameter.typ, ValueType::GuidPointer).then_some(16)); + parameters.push(SurfaceParameter { + name: unique_name(input_name(¶meter.name, surface_index), &mut input_names), + typ: if parameter.consumes_resource { + SurfaceType::ManagedResource + } else if parameter.null_null_terminated + && matches!(parameter.typ, ValueType::StringPointer(_)) + { + match parameter.typ { + ValueType::StringPointer(encoding) => SurfaceType::MultiString(encoding), + _ => unreachable!("validated NullNullTerminated string pointer"), + } + } else { + input_surface_type(¶meter.typ) + }, + nullable: parameter.nullable, + minimum_bytes, + alignment: parameter + .buffer + .as_ref() + .map(|buffer| buffer.element_alignment) + .or(matches!(parameter.typ, ValueType::GuidPointer).then_some(4)), + }); + native_surface[index] = Some(surface_index); + } + } + + for (index, parameter) in contract.parameters.iter().enumerate() { + let reserved_pointer = + parameter.reserved && matches!(parameter.typ, ValueType::DataPointer); + let surface_index = native_surface[index]; + + let runtime = if let ValueType::NativeStruct { layout } = ¶meter.typ { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: false, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: Some(layout.clone()), + pointee_aggregate: None, + } + } else if let ValueType::NativeStructPointer { layout } + | ValueType::NativeUnionPointer { layout } = ¶meter.typ + { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: parameter.nullable, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: None, + pointee_aggregate: (parameter.direction != Direction::In + && !layout.output_fields.is_empty()) + .then(|| layout.clone()), + } + } else if matches!(parameter.typ, ValueType::ScalarPointer { .. }) { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: parameter.nullable, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: None, + pointee_aggregate: None, + } + } else if matches!(parameter.typ, ValueType::GuidPointer) { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: parameter.nullable, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: None, + pointee_aggregate: None, + } + } else if matches!(parameter.typ, ValueType::NullPointer) { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: true, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: None, + pointee_aggregate: None, + } + } else if matches!(parameter.typ, ValueType::ComInterface { .. }) { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: parameter.nullable, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: None, + pointee_aggregate: None, + } + } else if matches!(parameter.typ, ValueType::StringPointerPointer(_)) { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: parameter.nullable, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: None, + pointee_aggregate: None, + } + } else if parameter.buffer.is_some() { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: parameter.nullable, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: None, + pointee_aggregate: None, + } + } else if reserved_pointer { + RuntimeParameter { + abi: AbiType::Pointer, + direction: Direction::In, + nullable: true, + cleanup: Cleanup::None, + consumes_resource: false, + resource_cleanup: Cleanup::None, + aggregate: None, + pointee_aggregate: None, + } + } else if parameter.pointer_depth == 0 { + RuntimeParameter { + abi: parameter.abi, + direction: Direction::In, + nullable: parameter.nullable, + cleanup: Cleanup::None, + consumes_resource: parameter.consumes_resource, + resource_cleanup: parameter.resource_cleanup, + aggregate: None, + pointee_aggregate: None, + } + } else { + RuntimeParameter { + abi: parameter.abi, + direction: parameter.direction, + nullable: parameter.nullable, + cleanup: parameter.cleanup, + consumes_resource: parameter.consumes_resource, + resource_cleanup: if matches!(parameter.direction, Direction::In | Direction::InOut) + { + parameter.resource_cleanup + } else { + Cleanup::None + }, + aggregate: None, + pointee_aggregate: None, + } + }; + + if matches!(runtime.direction, Direction::In | Direction::InOut) { + let expression = if parameter.reserved { + if runtime.abi == AbiType::Pointer { + InputExpression::NullPointer + } else { + InputExpression::Zero(runtime.abi) + } + } else if let ValueType::NativeStruct { layout } = ¶meter.typ { + InputExpression::NativeAggregate { + parameter_index: surface_index.ok_or_else(|| { + format!( + "native aggregate parameter `{}` has no projected input", + parameter.name + ) + })?, + layout: layout.clone(), + nullable: false, + by_value: true, + } + } else if let ValueType::NativeStructPointer { layout } + | ValueType::NativeUnionPointer { layout } = ¶meter.typ + { + InputExpression::NativeAggregate { + parameter_index: surface_index.ok_or_else(|| { + format!( + "native aggregate parameter `{}` has no projected input", + parameter.name + ) + })?, + layout: layout.clone(), + nullable: parameter.nullable, + by_value: false, + } + } else if let ValueType::ScalarPointer { scalar } = parameter.typ { + InputExpression::ScalarPointer { + parameter_index: surface_index.ok_or_else(|| { + format!( + "scalar pointer parameter `{}` has no projected input", + parameter.name + ) + })?, + scalar, + nullable: parameter.nullable, + } + } else if let ValueType::ComInterface { iid, .. } = ¶meter.typ { + InputExpression::ComInterface { + parameter_index: surface_index.ok_or_else(|| { + format!( + "COM interface parameter `{}` has no projected input", + parameter.name + ) + })?, + iid: iid.clone(), + } + } else if let ValueType::StringPointerPointer(encoding) = parameter.typ { + InputExpression::StringPointerPointer { + parameter_index: surface_index.ok_or_else(|| { + format!( + "string pointer slot `{}` has no projected input", + parameter.name + ) + })?, + encoding, + nullable: parameter.nullable, + } + } else if matches!(parameter.typ, ValueType::NullPointer) { + InputExpression::NullPointer + } else if let Some(buffer_index) = count_buffers.get(&index).copied() { + let buffer = &contract.parameters[buffer_index]; + let buffer_surface = native_surface[buffer_index] + .ok_or_else(|| format!("buffer `{}` has no projected input", buffer.name))?; + let buffer_contract = buffer.buffer.as_ref().expect("count relation"); + InputExpression::BufferLength { + parameter_index: buffer_surface, + divisor: if buffer_contract.count_is_bytes { + 1 + } else { + buffer_contract.element_size + }, + abi: parameter.abi, + } + } else { + let surface = surface_index.ok_or_else(|| { + format!( + "input parameter `{}` has no projected input", + parameter.name + ) + })?; + InputExpression::Surface { + parameter_index: surface, + conversion: input_conversion(parameter, &contract.enums), + } + }; + inputs.push(expression); + } + + runtime_parameters.push(runtime); + } + + let mut runtime = RuntimePlan { + dll: contract.dll.clone(), + entry_point: contract.entry_point.clone(), + parameters: runtime_parameters, + return_abi: contract.return_abi, + return_aggregate: contract.return_aggregate.clone(), + return_cleanup: contract.return_cleanup, + success_rule: contract.success_rule, + capture_last_error: contract.capture_last_error, + calling_convention: contract.calling_convention, + call_contract: contract.call_contract.clone(), + }; + // Caller-owned aggregates remain physical inputs, but their declared field + // results must survive lowering without inventing native output cells. + let shape = runtime.signature_shape(64); + for (index, parameter) in contract.parameters.iter().enumerate() { + if let ValueType::NativeStructPointer { layout } | ValueType::NativeUnionPointer { layout } = + ¶meter.typ + && parameter.direction != Direction::In + && shape.parameters[index].result_fields.len() != layout.output_fields.len() + { + return Err("win32.contract-shape-conflict: aggregate result fields were lost during physical pointer lowering".into()); + } + } + runtime.call_contract = contract + .call_contract + .upgrade_metadata(&shape) + .map_err(|error| error.to_string())?; + if contract.call_contract.version == dynwinrt_win32_contracts::LEGACY_VERSION { + for result in &mut runtime.call_contract.results { + if matches!(result.target, ResultTarget::AggregateField { .. }) { + result.on_failure = ResultPolicy::Undefined {}; + } + } + } + for evidence in &contract.result_contracts { + let result = runtime.call_contract.results.iter_mut() + .find(|result| result.target == evidence.target) + .ok_or("win32.contract-shape-conflict: result evidence does not target a declared native result")?; + *result = evidence.clone(); + } + runtime + .call_contract + .validate_signature(&shape) + .map_err(|error| error.to_string())?; + + let outputs = contract + .parameters + .iter() + .zip(&runtime.parameters) + .enumerate() + .filter(|(_, (_, parameter))| parameter.direction != Direction::In) + .enumerate() + .map(|(output_index, (index, (parameter, _)))| { + let result = runtime + .call_contract + .result(ResultTarget::Parameter { index }) + .expect("validated native output policy"); + let (typ, conversion) = + project_result(¶meter.typ, output_surface_type(parameter), result); + ProjectedOutput { + name: unique_name(output_name(parameter), &mut output_names), + output_index, + typ, + conversion, + may_be_unavailable: result.may_be_unavailable(), + } + }) + .collect::>(); + let return_policy = runtime.call_contract.result(ResultTarget::Return {}); + let return_may_be_unavailable = return_policy.is_some_and(ResultContract::may_be_unavailable); + let projected_return = contract.return_type.as_ref().map(|typ| { + project_result( + typ, + input_surface_type(typ), + return_policy.expect("validated native return policy"), + ) + }); + let return_shape = if contract.return_is_status { + ReturnShape::Object { + status: true, + return_value: None, + return_may_be_unavailable, + outputs, + last_error: contract.capture_last_error, + } + } else if !outputs.is_empty() || contract.capture_last_error { + ReturnShape::Object { + status: false, + return_value: projected_return, + return_may_be_unavailable, + outputs, + last_error: contract.capture_last_error, + } + } else if let Some((typ, conversion)) = projected_return { + ReturnShape::Direct { + typ, + conversion, + may_be_unavailable: return_may_be_unavailable, + } + } else { + ReturnShape::Void + }; + + Ok(ProjectedFunction { + metadata_name: contract.name.clone(), + js_name: camel_case(&contract.name), + unicode_alias: None, + parameters, + inputs, + runtime, + return_shape, + subsystem: contract.subsystem, + }) +} + +fn count_buffer_relations(contract: &FunctionContract) -> Result, String> { + let mut relations = BTreeMap::new(); + for (buffer_index, parameter) in contract.parameters.iter().enumerate() { + let Some(count_index) = parameter + .buffer + .as_ref() + .and_then(|buffer| buffer.count_parameter) + else { + continue; + }; + if let Some(existing) = relations.insert(count_index, buffer_index) + && existing != buffer_index + { + return Err(format!( + "count parameter {} controls multiple buffers; grouped buffer projection is not implemented", + contract.parameters[count_index].name + )); + } + } + Ok(relations) +} + +fn should_surface_input(parameter: &super::ir::ParameterContract, is_buffer_count: bool) -> bool { + if parameter.reserved || is_buffer_count || matches!(parameter.typ, ValueType::NullPointer) { + return false; + } + parameter.buffer.is_some() + || matches!( + ¶meter.typ, + ValueType::NativeStructPointer { .. } | ValueType::NativeUnionPointer { .. } + ) + || matches!(parameter.typ, ValueType::NativeStruct { .. }) + || matches!(parameter.typ, ValueType::ScalarPointer { .. }) + || matches!(parameter.typ, ValueType::GuidPointer) + || matches!(parameter.direction, Direction::In | Direction::InOut) +} + +fn input_surface_type(typ: &ValueType) -> SurfaceType { + match typ { + ValueType::Scalar(Scalar::Bool8 | Scalar::Bool32) => SurfaceType::Boolean, + ValueType::Scalar( + Scalar::I64 | Scalar::U64 | Scalar::NativeIsize | Scalar::NativeUsize, + ) => SurfaceType::BigInt, + ValueType::Scalar(_) => SurfaceType::Number, + ValueType::Enum { name, .. } => SurfaceType::Enum(name.clone()), + ValueType::Handle { name, .. } => SurfaceType::Handle(name.clone()), + ValueType::DataPointer => SurfaceType::Buffer, + ValueType::StringPointer(encoding) => SurfaceType::String(*encoding), + ValueType::FunctionPointer => SurfaceType::BigInt, + ValueType::NativeStructPointer { layout } => SurfaceType::NativeStruct(layout.name.clone()), + ValueType::NativeUnionPointer { layout } => SurfaceType::NativeUnion(layout.name.clone()), + ValueType::NativeStruct { layout } => SurfaceType::NativeStruct(layout.name.clone()), + ValueType::ScalarPointer { scalar } => scalar_surface_type(*scalar), + ValueType::GuidPointer => SurfaceType::Buffer, + ValueType::NullPointer => unreachable!("null-only pointer is hidden"), + ValueType::ComInterface { name, .. } => SurfaceType::ComInterface(name.clone()), + ValueType::StringPointerPointer(encoding) => SurfaceType::String(*encoding), + } +} + +fn scalar_surface_type(scalar: Scalar) -> SurfaceType { + match scalar { + Scalar::Bool8 | Scalar::Bool32 => SurfaceType::Boolean, + Scalar::I64 | Scalar::U64 | Scalar::NativeIsize | Scalar::NativeUsize => { + SurfaceType::BigInt + } + Scalar::I8 + | Scalar::U8 + | Scalar::I16 + | Scalar::U16 + | Scalar::I32 + | Scalar::U32 + | Scalar::F32 + | Scalar::F64 => SurfaceType::Number, + } +} + +fn output_surface_type(parameter: &super::ir::ParameterContract) -> SurfaceType { + match ¶meter.typ { + ValueType::Scalar(Scalar::Bool8 | Scalar::Bool32) => SurfaceType::Boolean, + ValueType::Scalar( + Scalar::I64 | Scalar::U64 | Scalar::NativeIsize | Scalar::NativeUsize, + ) => SurfaceType::BigInt, + ValueType::Scalar(_) => SurfaceType::Number, + ValueType::Enum { name, .. } => SurfaceType::Enum(name.clone()), + ValueType::Handle { name, .. } => SurfaceType::Handle(name.clone()), + ValueType::DataPointer | ValueType::FunctionPointer => SurfaceType::BigInt, + ValueType::StringPointer(_) => SurfaceType::BigInt, + ValueType::NativeStructPointer { layout } => SurfaceType::NativeStruct(layout.name.clone()), + ValueType::NativeUnionPointer { layout } => SurfaceType::NativeUnion(layout.name.clone()), + ValueType::NativeStruct { layout } => SurfaceType::NativeStruct(layout.name.clone()), + ValueType::ScalarPointer { scalar } => scalar_surface_type(*scalar), + ValueType::GuidPointer => SurfaceType::Buffer, + ValueType::NullPointer => unreachable!("null-only pointer has no output"), + ValueType::ComInterface { name, .. } => SurfaceType::ComInterface(name.clone()), + ValueType::StringPointerPointer(encoding) => SurfaceType::String(*encoding), + } +} + +fn project_result( + typ: &ValueType, + value_surface: SurfaceType, + result: &ResultContract, +) -> (SurfaceType, Conversion) { + let delivered = || { + result.policies().filter_map(|policy| match policy { + ResultPolicy::Defined { + ownership, + delivery: Delivery::Deliver, + } => Some(ownership), + _ => None, + }) + }; + let owns = delivered().any(|ownership| matches!(ownership, ResultOwnership::Owned { .. })); + let borrows = delivered().any(|ownership| matches!(ownership, ResultOwnership::Borrowed {})); + let aliases = + delivered().any(|ownership| matches!(ownership, ResultOwnership::AliasInput { .. })); + if aliases || (owns && borrows) { + (SurfaceType::ResourceOrHandle, Conversion::ResourceOrHandle) + } else if owns { + (SurfaceType::Resource, Conversion::Resource) + } else { + (value_surface, return_conversion(typ)) + } +} + +fn input_conversion( + parameter: &super::ir::ParameterContract, + enums: &[EnumDefinition], +) -> Conversion { + if parameter.consumes_resource { + return Conversion::ResourceInput(parameter.resource_cleanup); + } + if parameter.null_null_terminated && matches!(parameter.typ, ValueType::StringPointer(_)) { + return match parameter.typ { + ValueType::StringPointer(StringEncoding::Wide) => Conversion::WideMultiString, + ValueType::StringPointer(StringEncoding::Ansi) => Conversion::AnsiMultiString, + _ => unreachable!("validated NullNullTerminated string pointer"), + }; + } + if let ValueType::Enum { + namespace, + name, + underlying: EnumUnderlying::U32, + } = ¶meter.typ + && enums.iter().any(|definition| { + definition.namespace == *namespace && definition.name == *name && definition.is_flags + }) + { + return Conversion::U32Flags; + } + match ¶meter.typ { + ValueType::Scalar(Scalar::Bool8) => Conversion::Boolean8, + ValueType::Scalar(Scalar::Bool32) => Conversion::Boolean, + ValueType::Scalar(Scalar::I8) => Conversion::I8, + ValueType::Scalar(Scalar::U8) => Conversion::U8, + ValueType::Scalar(Scalar::I16) => Conversion::I16, + ValueType::Scalar(Scalar::U16) => Conversion::U16, + ValueType::Scalar(Scalar::I32) => Conversion::I32, + ValueType::Scalar(Scalar::U32) => Conversion::U32, + ValueType::Scalar(Scalar::I64) => Conversion::I64, + ValueType::Scalar(Scalar::U64) => Conversion::U64, + ValueType::Scalar(Scalar::F32) => Conversion::F32, + ValueType::Scalar(Scalar::F64) => Conversion::F64, + ValueType::Scalar(Scalar::NativeIsize) => Conversion::I64, + ValueType::Scalar(Scalar::NativeUsize) => Conversion::U64, + ValueType::Enum { underlying, .. } => match underlying { + super::ir::EnumUnderlying::I8 => Conversion::I8, + super::ir::EnumUnderlying::U8 => Conversion::U8, + super::ir::EnumUnderlying::I16 => Conversion::I16, + super::ir::EnumUnderlying::U16 => Conversion::U16, + super::ir::EnumUnderlying::I32 => Conversion::I32, + super::ir::EnumUnderlying::U32 => Conversion::U32, + }, + ValueType::Handle { .. } => Conversion::Handle, + ValueType::DataPointer => Conversion::DataPointer, + ValueType::StringPointer(StringEncoding::Wide) => Conversion::WideString, + ValueType::StringPointer(StringEncoding::Ansi) => Conversion::AnsiString, + ValueType::FunctionPointer => Conversion::BigInt, + ValueType::NativeStructPointer { .. } | ValueType::NativeUnionPointer { .. } => { + unreachable!("native aggregate inputs use a dedicated expression") + } + ValueType::NativeStruct { .. } => { + unreachable!("by-value native aggregate inputs use a dedicated expression") + } + ValueType::ScalarPointer { .. } => { + unreachable!("scalar pointer inputs use a dedicated expression") + } + ValueType::GuidPointer => Conversion::DataPointer, + ValueType::NullPointer => unreachable!("null-only pointer has no surface input"), + ValueType::ComInterface { .. } => { + unreachable!("COM interface inputs use a dedicated expression") + } + ValueType::StringPointerPointer(_) => { + unreachable!("string pointer slots use a dedicated expression") + } + } +} + +fn return_conversion(typ: &ValueType) -> Conversion { + match typ { + ValueType::Scalar(Scalar::Bool8 | Scalar::Bool32) => Conversion::Boolean, + ValueType::Scalar( + Scalar::I64 | Scalar::U64 | Scalar::NativeIsize | Scalar::NativeUsize, + ) => Conversion::BigInt, + ValueType::Scalar(_) | ValueType::Enum { .. } => Conversion::Number, + ValueType::Handle { .. } + | ValueType::DataPointer + | ValueType::StringPointer(_) + | ValueType::FunctionPointer => Conversion::BigInt, + ValueType::NativeStructPointer { .. } | ValueType::NativeUnionPointer { .. } => { + unreachable!("native aggregate pointer results are not projected") + } + ValueType::NativeStruct { .. } => Conversion::NativeAggregate, + ValueType::ScalarPointer { .. } => { + unreachable!("scalar pointer results are not projected") + } + ValueType::GuidPointer => { + unreachable!("GUID pointer results are caller-owned buffers") + } + ValueType::NullPointer => unreachable!("null-only pointer cannot be a return"), + ValueType::ComInterface { .. } => { + unreachable!("COM interface returns require ownership projection") + } + ValueType::StringPointerPointer(_) => { + unreachable!("string pointer slot returns require ownership projection") + } + } +} + +fn input_name(raw: &str, index: usize) -> String { + let stripped = strip_prefix(raw); + safe_identifier(if stripped.is_empty() { + format!("arg{index}") + } else { + lower_first(stripped) + }) +} + +fn reserved_input_bindings(contract: &FunctionContract) -> BTreeSet { + // Parameters must not shadow wrapper locals or the helpers they close over. + let mut names = [ + "_call", + "_return", + "_outputs", + "_subsystem", + "_nativeAggregate", + "_bufferCount", + "_scalarPointer", + "_u32Flags", + "DynWin32", + "DynWin32Function", + "BigInt", + "Number", + "RangeError", + "TypeError", + ] + .into_iter() + .map(str::to_owned) + .collect::>(); + names.insert(format!("_bind{}Plan", contract.name)); + for parameter in &contract.parameters { + match ¶meter.typ { + ValueType::NativeStruct { layout } + | ValueType::NativeStructPointer { layout } + | ValueType::NativeUnionPointer { layout } => { + names.insert(format!("_nativeLayout_{}", layout.name)); + } + _ => {} + } + } + if let Some(layout) = &contract.return_aggregate { + names.insert(format!("_nativeLayout_{}", layout.name)); + } + names +} + +fn unique_name(mut name: String, used: &mut BTreeSet) -> String { + while !used.insert(name.clone()) { + name.push('_'); + } + name +} + +fn output_name(parameter: &super::ir::ParameterContract) -> String { + if let ValueType::Handle { name, .. } = ¶meter.typ + && parameter.name.to_ascii_lowercase().ends_with("result") + { + return lower_first(name.trim_start_matches('H')); + } + let mut name = strip_prefix(¶meter.name).to_string(); + let lower = parameter.name.to_ascii_lowercase(); + if lower.contains("cb") { + name.push_str("Size"); + } else if lower.contains("cch") || lower.contains("ch") { + name.push_str("Length"); + } + if name.eq_ignore_ascii_case("result") { + name = "value".into(); + } + safe_identifier(lower_first(&name)) +} + +fn strip_prefix(value: &str) -> &str { + for prefix in [ + "lpp", "lpcb", "lpch", "lpcch", "lpdw", "lp", "pp", "phk", "ph", "pcb", "pdw", "pcch", + "pch", "p", + ] { + if let Some(rest) = value.strip_prefix(prefix) + && rest + .chars() + .next() + .is_some_and(|character| character.is_ascii_uppercase()) + { + return rest; + } + } + value +} + +fn lower_first(value: &str) -> String { + if value + .chars() + .all(|character| !character.is_ascii_alphabetic() || character.is_ascii_uppercase()) + { + return value.to_ascii_lowercase(); + } + let mut characters = value.chars(); + let Some(first) = characters.next() else { + return String::new(); + }; + first.to_ascii_lowercase().to_string() + characters.as_str() +} + +fn safe_identifier(value: String) -> String { + let value = crate::codegen::winrt::javascript::naming::to_camel_case(&value); + if matches!(value.as_str(), "await" | "status" | "result" | "lastError") { + format!("{value}_") + } else { + value + } +} + +fn camel_case(value: &str) -> String { + let uppercase = value + .chars() + .take_while(|character| character.is_ascii_uppercase()) + .count(); + if uppercase <= 1 { + return lower_first(value); + } + if uppercase == value.len() { + return value.to_ascii_lowercase(); + } + value[..uppercase - 1].to_ascii_lowercase() + &value[uppercase - 1..] +} + +fn assign_unicode_aliases(functions: &mut [ProjectedFunction]) { + let names = functions + .iter() + .map(|function| function.js_name.clone()) + .collect::>(); + let mut aliases = BTreeSet::new(); + for function in functions { + let Some(base) = function.js_name.strip_suffix('W') else { + continue; + }; + if !base.is_empty() && !names.contains(base) && aliases.insert(base.to_string()) { + function.unicode_alias = Some(base.to_string()); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn unicode_name_gets_natural_alias() { + let mut functions = vec![ProjectedFunction { + metadata_name: "RegOpenKeyExW".into(), + js_name: "regOpenKeyExW".into(), + unicode_alias: None, + parameters: vec![], + inputs: vec![], + runtime: RuntimePlan { + dll: "advapi32.dll".into(), + entry_point: "RegOpenKeyExW".into(), + parameters: vec![], + return_abi: Some(AbiType::I32), + return_aggregate: None, + return_cleanup: Cleanup::None, + success_rule: super::super::ir::SuccessRule::ReturnZero, + capture_last_error: false, + calling_convention: super::super::ir::CallingConvention::System, + call_contract: super::super::ir::CallContract::default(), + }, + return_shape: ReturnShape::Object { + status: true, + return_may_be_unavailable: false, + return_value: None, + outputs: vec![], + last_error: false, + }, + subsystem: None, + }]; + assign_unicode_aliases(&mut functions); + assert_eq!(functions[0].unicode_alias.as_deref(), Some("regOpenKeyEx")); + } + + #[test] + fn javascript_reserved_parameter_names_are_escaped() { + assert_eq!(input_name("lpIn", 0), "in_"); + assert_eq!(input_name("class", 0), "class_"); + assert_eq!(input_name("eval", 0), "eval_"); + assert_eq!(input_name("arguments", 0), "arguments_"); + assert_eq!(input_name("lpArguments", 0), "arguments_"); + assert_eq!(input_name("await", 0), "await_"); + } +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/projection_semantics_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/projection_semantics_tests.rs new file mode 100644 index 00000000..c9723c59 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/projection_semantics_tests.rs @@ -0,0 +1,666 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::{ir::*, test_support::*, *}; +use crate::win32_metadata::*; + +fn counted( + name: &str, + size: RawBufferSize, + count_direction: RawDirection, + nullable: bool, +) -> RawFunction { + let mut function = synthetic_function(name); + let mut buffer = parameter( + "data", + pointer(scalar(RawScalar::U16), 1, RawConstness::Mutable), + RawDirection::Out, + ); + buffer.nullable = nullable; + buffer.buffer = Some(RawBuffer { + element: scalar(RawScalar::U16), + size, + }); + let count_type = if count_direction == RawDirection::In { + scalar(RawScalar::U32) + } else { + pointer(scalar(RawScalar::U32), 1, RawConstness::Mutable) + }; + function.parameters = vec![buffer, parameter("count", count_type, count_direction)]; + function +} + +#[test] +fn byte_and_element_capacity_relations_preserve_inout_output_order_and_nullability() { + for (size, divisor) in [ + (RawBufferSize::ElementCountParam(1), 2), + (RawBufferSize::ByteCountParam(1), 1), + ] { + for count_direction in [RawDirection::In, RawDirection::InOut] { + for nullable in [false, true] { + let function = counted("ReadCapacity", size.clone(), count_direction, nullable); + let native = semantic(&function); + let buffer = native.parameters[0].buffer.as_ref().unwrap(); + assert_eq!(buffer.count_parameter, Some(1)); + assert_eq!(buffer.constant_count, None); + assert_eq!(buffer.count_is_bytes, divisor == 1); + assert_eq!(buffer.element_size, divisor); + let projected = project_one(function); + assert_eq!( + projected.parameters, + vec![SurfaceParameter { + name: "data".into(), + typ: SurfaceType::Buffer, + nullable, + minimum_bytes: None, + alignment: Some(2), + }] + ); + assert_eq!( + projected.inputs, + vec![ + InputExpression::Surface { + parameter_index: 0, + conversion: Conversion::DataPointer + }, + InputExpression::BufferLength { + parameter_index: 0, + divisor, + abi: AbiType::U32 + }, + ] + ); + assert_eq!(projected.runtime.parameters[0].abi, AbiType::Pointer); + assert_eq!(projected.runtime.parameters[0].direction, Direction::In); + assert_eq!(projected.runtime.parameters[0].nullable, nullable); + if count_direction == RawDirection::InOut { + assert_eq!(projected.runtime.parameters[1].direction, Direction::InOut); + assert_eq!( + projected.return_shape, + ReturnShape::Object { + return_may_be_unavailable: false, + status: false, + return_value: Some((SurfaceType::Number, Conversion::Number)), + last_error: false, + outputs: vec![ProjectedOutput { + name: "count".into(), + output_index: 0, + typ: SurfaceType::Number, + conversion: Conversion::Number, + may_be_unavailable: false, + }], + } + ); + } else { + assert_eq!(projected.runtime.parameters[1].direction, Direction::In); + assert!(matches!(projected.return_shape, ReturnShape::Direct { .. })); + } + } + } + } +} + +#[test] +fn incomplete_conflicting_or_nonintegral_counts_never_emit_a_callable_export() { + let cases: &[(&str, fn(&mut RawFunction))] = &[ + ("missing count", |f| { + f.parameters[0].buffer.as_mut().unwrap().size = RawBufferSize::ElementCountParam(9) + }), + ("counts itself", |f| { + f.parameters[0].buffer.as_mut().unwrap().size = RawBufferSize::ElementCountParam(0) + }), + ("integer scalar", |f| { + f.parameters[1].typ = scalar(RawScalar::F32) + }), + ("complete size", |f| { + f.parameters[0].buffer.as_mut().unwrap().size = RawBufferSize::Unknown + }), + ("multiple buffers", |f| { + let mut b = f.parameters[0].clone(); + b.name = "second".into(); + f.parameters.push(b); + }), + ("overflows", |f| { + f.parameters[0].buffer.as_mut().unwrap().size = RawBufferSize::Constant(usize::MAX) + }), + ]; + for (reason, mutate) in cases { + let mut function = counted( + "InvalidCount", + RawBufferSize::ElementCountParam(1), + RawDirection::In, + true, + ); + mutate(&mut function); + let raw = apis(vec![function]); + let projection = project_apis(&raw); + assert!(projection.projected.functions.is_empty(), "{reason}"); + assert_eq!(projection.omitted.len(), 1); + assert!( + projection.omitted[0].reason.contains(reason), + "{reason}: {:?}", + projection.omitted + ); + let (generated, _) = generate_apis_files(&raw, "@test/runtime/win32"); + assert!(!generated.js.contains("exports.invalidCount")); + } +} + +#[test] +fn generated_buffer_counts_use_backing_extent_check_divisibility_and_keep_input_positions() { + let element = counted( + "ReadElements", + RawBufferSize::ElementCountParam(1), + RawDirection::InOut, + true, + ); + let bytes = counted( + "ReadBytes", + RawBufferSize::ByteCountParam(1), + RawDirection::InOut, + true, + ); + let mut fixed = synthetic_function("ReadFixed"); + let mut buffer = parameter( + "data", + pointer(scalar(RawScalar::U16), 1, RawConstness::Mutable), + RawDirection::Out, + ); + buffer.buffer = Some(RawBuffer { + element: scalar(RawScalar::U16), + size: RawBufferSize::Constant(3), + }); + fixed.parameters.push(buffer); + let (generated, omitted) = + generate_apis_files(&apis(vec![element, bytes, fixed]), "@test/runtime/win32"); + assert!(omitted.is_empty()); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const calls=[] +const byteLength=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Uint8Array.prototype),'byteLength').get +const native={ + byteLength(value) { return Reflect.apply(byteLength,value,[]) }, + alignedDataPointer(value,alignment,nullable) { + if (value===null && !nullable) throw new TypeError('required pointer') + return { value,alignment,nullable } + }, + u32: value => ({scalar:value}), + toNumber: value => value, +} +const runtime={DynWin32:native,DynWin32Function:{bind(spec) { + return {invoke(args) { + calls.push({spec,args}) + let reads=0 + return {returnValue:7,get outputs() { assert.equal(++reads,1); return [11] }} + }} +}}} +"#, + r#" +const storage=Buffer.alloc(6) +Object.defineProperty(storage,'byteLength',{get(){throw Error('JS length getter was read')}}) +Object.defineProperty(storage,'length',{value:0xffffffff}) +let result=projected.readElements(storage) +assert.equal(result.result,7) +assert.equal(result.count,11) +assert.equal(calls.at(-1).args[0].value,storage) +assert.equal(calls.at(-1).args[0].alignment,2) +assert.equal(calls.at(-1).args[1].scalar,3) +projected.readBytes(storage) +assert.equal(calls.at(-1).args[1].scalar,6) +projected.readElements(null) +assert.equal(calls.at(-1).args[0].value,null) +assert.equal(calls.at(-1).args[1].scalar,0) +const before=calls.length +assert.throws(()=>projected.readElements(Buffer.alloc(5)),/divisible/) +assert.throws(()=>projected.readFixed(Buffer.alloc(5)),/at least 6 bytes/) +assert.throws(()=>projected.readFixed(null),/required/) +assert.equal(calls.length,before) +projected.readFixed(Buffer.alloc(6)) +assert.equal(calls.at(-1).args.length,1) +"#, + ); +} + +#[test] +fn native_return_conventions_last_error_and_outputs_are_typed_independently() { + for (kind, status, capture, success, return_shape) in [ + ( + RawScalar::U32, + RawStatusSemantics::None, + false, + SuccessRule::Always, + ReturnShape::Direct { + typ: SurfaceType::Number, + conversion: Conversion::Number, + may_be_unavailable: false, + }, + ), + ( + RawScalar::U32, + RawStatusSemantics::ZeroIsSuccess, + false, + SuccessRule::ReturnZero, + ReturnShape::Object { + status: true, + return_may_be_unavailable: false, + return_value: None, + outputs: vec![], + last_error: false, + }, + ), + ( + RawScalar::I32, + RawStatusSemantics::SignedNonNegativeIsSuccess, + false, + SuccessRule::SignedNonNegative, + ReturnShape::Object { + status: true, + return_may_be_unavailable: false, + return_value: None, + outputs: vec![], + last_error: false, + }, + ), + ( + RawScalar::Bool32, + RawStatusSemantics::None, + true, + SuccessRule::ReturnNonZero, + ReturnShape::Object { + status: false, + return_may_be_unavailable: false, + return_value: Some((SurfaceType::Boolean, Conversion::Boolean)), + outputs: vec![], + last_error: true, + }, + ), + ] { + let mut function = synthetic_function("NativeReturn"); + function.return_type = scalar(kind); + function.return_status = status; + function.supports_last_error = capture; + let projected = project_one(function); + assert_eq!(projected.runtime.success_rule, success); + assert_eq!(projected.runtime.capture_last_error, capture); + assert_eq!(projected.runtime.return_cleanup, Cleanup::None); + assert_eq!(projected.return_shape, return_shape); + } +} + +#[test] +fn allocator_owned_pointer_returns_use_exact_cleanup_and_nonnull_success() { + for (native_cleanup, cleanup) in [ + ("LocalFree", Cleanup::LocalFree), + ("GlobalFree", Cleanup::GlobalFree), + ("CoTaskMemFree", Cleanup::CoTaskMemFree), + ("CredFree", Cleanup::CredFree), + ] { + let mut function = synthetic_function("AllocateData"); + function.return_type = RawType { + base: RawBaseType::Void, + pointer_depth: 1, + constness: RawConstness::Mutable, + }; + function.return_free_with = Some(native_cleanup.into()); + let projected = project_one(function); + assert_eq!(projected.runtime.return_abi, Some(AbiType::Pointer)); + assert_eq!(projected.runtime.return_cleanup, cleanup); + assert_eq!(projected.runtime.success_rule, SuccessRule::ReturnNonNull); + assert_eq!( + projected.return_shape, + ReturnShape::Direct { + typ: SurfaceType::Resource, + conversion: Conversion::Resource, + may_be_unavailable: true, + } + ); + } + for cleanup in ["UnknownFree", "LocalFreeExtra", "CoTaskMemFreeCallback"] { + let mut function = synthetic_function("UnknownAllocator"); + function.return_type = RawType { + base: RawBaseType::Void, + pointer_depth: 1, + constness: RawConstness::Mutable, + }; + function.return_free_with = Some(cleanup.into()); + let (generated, omitted) = + generate_apis_files(&apis(vec![function]), "@test/runtime/win32"); + assert!(omitted[0].reason.contains("unsupported native cleanup")); + assert!(!generated.js.contains("exports.unknownAllocator")); + } +} + +#[test] +fn mixed_out_inout_and_input_slots_keep_native_and_projected_result_order() { + let mut function = synthetic_function("MixedSlots"); + function.return_type = scalar(RawScalar::Bool32); + function.supports_last_error = true; + function.parameters = vec![ + parameter( + "first", + pointer(scalar(RawScalar::I16), 1, RawConstness::Mutable), + RawDirection::Out, + ), + parameter("input", scalar(RawScalar::U32), RawDirection::In), + parameter( + "cursor", + pointer(scalar(RawScalar::U64), 1, RawConstness::Mutable), + RawDirection::InOut, + ), + parameter( + "enabled", + pointer(scalar(RawScalar::Bool32), 1, RawConstness::Mutable), + RawDirection::Out, + ), + ]; + let projected = project_one(function.clone()); + assert_eq!( + projected + .runtime + .parameters + .iter() + .map(|p| p.direction) + .collect::>(), + [ + Direction::Out, + Direction::In, + Direction::InOut, + Direction::Out + ] + ); + assert_eq!( + projected + .runtime + .parameters + .iter() + .map(|p| p.abi) + .collect::>(), + [AbiType::I16, AbiType::U32, AbiType::U64, AbiType::Bool32] + ); + assert_eq!( + projected.inputs, + vec![ + InputExpression::Surface { + parameter_index: 0, + conversion: Conversion::U32 + }, + InputExpression::Surface { + parameter_index: 1, + conversion: Conversion::U64 + }, + ] + ); + assert_eq!( + projected.return_shape, + ReturnShape::Object { + return_may_be_unavailable: false, + status: false, + return_value: Some((SurfaceType::Boolean, Conversion::Boolean)), + last_error: true, + outputs: vec![ + ProjectedOutput { + name: "first".into(), + output_index: 0, + typ: SurfaceType::Number, + conversion: Conversion::Number, + may_be_unavailable: false, + }, + ProjectedOutput { + name: "cursor".into(), + output_index: 1, + typ: SurfaceType::BigInt, + conversion: Conversion::BigInt, + may_be_unavailable: false, + }, + ProjectedOutput { + name: "enabled".into(), + output_index: 2, + typ: SurfaceType::Boolean, + conversion: Conversion::Boolean, + may_be_unavailable: false, + }, + ], + } + ); + let (generated, _) = generate_apis_files(&apis(vec![function]), "@test/runtime/win32"); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const calls=[] +let result=1 +const runtime={DynWin32:{ + u32:value=>({kind:'u32',value}),u64:value=>({kind:'u64',value}), + toNumber:Number,toBigint:BigInt,toBoolean:Boolean +},DynWin32Function:{bind(spec) {return {invoke(args) { + calls.push({spec,args}) + let reads=0 + return {returnValue:result,lastError:123,get outputs(){assert.equal(++reads,1);return [-7,99n,1]}} +}}}}} +"#, + r#" +for (const returned of [1,0]) { + result=returned + const actual=projected.mixedSlots(4,5n) + assert.deepEqual(Object.keys(actual),['result','first','cursor','enabled','lastError']) + assert.equal(actual.result,!!returned) + assert.equal(actual.first,-7) + assert.equal(actual.cursor,99n) + assert.equal(actual.enabled,true) + assert.equal(actual.lastError,123) + assert.equal(calls.at(-1).args[0].value,4) + assert.equal(calls.at(-1).args[1].value,5n) +} +"#, + ); +} + +fn native_string(encoding: RawStringEncoding) -> RawType { + RawType { + base: RawBaseType::Named { + namespace: "Tests.Strings".into(), + name: "Text".into(), + kind: RawNamedKind::StringPointer { encoding }, + }, + pointer_depth: 0, + constness: RawConstness::Const, + } +} + +#[test] +fn string_encodings_multistrings_and_reserved_values_keep_separate_contracts() { + let mut functions = Vec::new(); + for (name, encoding, projected_encoding, single, multiple) in [ + ( + "WideText", + RawStringEncoding::Utf16, + StringEncoding::Wide, + Conversion::WideString, + Conversion::WideMultiString, + ), + ( + "AnsiText", + RawStringEncoding::Ansi, + StringEncoding::Ansi, + Conversion::AnsiString, + Conversion::AnsiMultiString, + ), + ] { + let mut function = synthetic_function(name); + let mut one = parameter("text", native_string(encoding), RawDirection::In); + one.nullable = true; + let mut many = one.clone(); + many.name = "list".into(); + many.null_null_terminated = true; + function.parameters = vec![one, many]; + let native = semantic(&function); + assert_eq!(native.parameters[0].constness, Constness::Const); + assert!(native.parameters[1].null_null_terminated); + let projected = project_one(function.clone()); + assert_eq!( + projected.parameters[0].typ, + SurfaceType::String(projected_encoding) + ); + assert_eq!( + projected.parameters[1].typ, + SurfaceType::MultiString(projected_encoding) + ); + assert_eq!( + projected.inputs, + vec![ + InputExpression::Surface { + parameter_index: 0, + conversion: single + }, + InputExpression::Surface { + parameter_index: 1, + conversion: multiple + }, + ] + ); + functions.push(function); + } + let mut reserved = synthetic_function("ReservedSlots"); + let mut flag = parameter("reservedBool", scalar(RawScalar::Bool32), RawDirection::In); + flag.reserved = true; + let mut pointer_slot = parameter( + "reservedAddress", + RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "Callback".into(), + kind: RawNamedKind::FunctionPointer, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + RawDirection::In, + ); + pointer_slot.reserved = true; + let mut real = parameter("reservedDouble", scalar(RawScalar::F64), RawDirection::In); + real.reserved = true; + reserved.parameters = vec![ + flag, + parameter("value", scalar(RawScalar::U32), RawDirection::In), + pointer_slot, + real, + ]; + let projected = project_one(reserved.clone()); + assert_eq!(projected.parameters.len(), 1); + assert_eq!(projected.parameters[0].name, "value"); + assert_eq!( + projected.inputs, + vec![ + InputExpression::Zero(AbiType::Bool32), + InputExpression::Surface { + parameter_index: 0, + conversion: Conversion::U32 + }, + InputExpression::NullPointer, + InputExpression::Zero(AbiType::F64), + ] + ); + functions.push(reserved); + let (generated, omitted) = generate_apis_files(&apis(functions), "@test/runtime/win32"); + assert!(omitted.is_empty()); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const calls=[] +const wrap=kind=>(value,nullable)=>({kind,value,nullable}) +const runtime={DynWin32:{ + wideString:wrap('wide'),ansiString:wrap('ansi'),wideMultiString:wrap('wide-list'),ansiMultiString:wrap('ansi-list'), + bool32:wrap('bool32'),u32:wrap('u32'),f64:wrap('f64'),nullPointer:()=>null,toNumber:Number +},DynWin32Function:{bind(spec){return {invoke(args){calls.push({spec,args});return {returnValue:0,outputs:[]}}}}}} +"#, + r#" +for (const [name,kind] of [['wideText','wide'],['ansiText','ansi']]) { + projected[name](null,['one','two']) + const args=calls.at(-1).args + assert.equal(args[0].kind,kind) + assert.equal(args[0].value,null) + assert.equal(args[0].nullable,true) + assert.equal(args[1].kind,kind+'-list') + assert.deepEqual(args[1].value,['one','two']) +} +projected.reservedSlots(9) +const args=calls.at(-1).args +assert.equal(args.length,4) +assert.equal(args[0].value,false) +assert.equal(args[1].value,9) +assert.equal(args[2],null) +assert.equal(args[3].value,0) +"#, + ); +} + +#[test] +fn unsupported_strings_callbacks_com_outputs_and_architectures_fail_before_render() { + let mut invalid = synthetic_function("Unsupported"); + let string = parameter( + "text", + native_string(RawStringEncoding::Utf16), + RawDirection::Out, + ); + let callback = parameter( + "callback", + RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "Callback".into(), + kind: RawNamedKind::FunctionPointer, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + RawDirection::In, + ); + let com = parameter( + "object", + RawType { + base: RawBaseType::Named { + namespace: "Tests".into(), + name: "IObject".into(), + kind: RawNamedKind::ComInterface { + iid: "00000000-0000-0000-c000-000000000046".into(), + }, + }, + pointer_depth: 1, + constness: RawConstness::Mutable, + }, + RawDirection::Out, + ); + for (parameter, reason) in [ + (string, "size relationship"), + (callback, "callback"), + (com, "COM interface"), + ] { + invalid.parameters = vec![parameter]; + let (generated, omitted) = + generate_apis_files(&apis(vec![invalid.clone()]), "@test/runtime/win32"); + assert_eq!(omitted.len(), 1); + assert!( + omitted[0] + .reason + .to_ascii_lowercase() + .contains(&reason.to_ascii_lowercase()), + "{omitted:?}" + ); + assert!(!generated.js.contains("exports.unsupported")); + } + for convention in [RawCallingConvention::Unsupported] { + invalid.parameters.clear(); + invalid.calling_convention = convention; + assert!( + validate_function(&invalid) + .unwrap_err() + .contains("calling convention") + ); + } + invalid.calling_convention = RawCallingConvention::System; + invalid.architectures.arm64 = false; + assert!(validate_function(&invalid).unwrap_err().contains("ARM64")); +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/render.rs b/tools/dynwinrt-codegen/src/codegen/win32/render.rs new file mode 100644 index 00000000..fa9499db --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/render.rs @@ -0,0 +1,1150 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::collections::{BTreeMap, BTreeSet}; + +use super::ir::{ + AbiType, AsyncIoKind, Cleanup, Conversion, Direction, EnumDefinition, InputExpression, + NativeArchitectureLayout, NativeBuilderFieldKind, NativeFieldType, NativeLayout, + NativeOutputFieldKind, NativeScalar, ProjectedApis, ProjectedAsyncFunction, ProjectedFunction, + ProjectedNativeBuilder, ReturnShape, RuntimePlan, StringEncoding, Subsystem, SurfaceType, +}; + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct GeneratedOutput { + pub js: String, + pub dts: String, + pub extra_files: Vec<(String, String)>, +} + +pub(super) fn export_names(apis: &ProjectedApis) -> Vec { + let mut result = BTreeSet::from(["Apis".to_string()]); + for function in &apis.functions { + result.insert(function.js_name.clone()); + if let Some(alias) = &function.unicode_alias { + result.insert(alias.clone()); + } + } + result.extend(apis.async_functions.iter().map(|f| f.js_name.clone())); + result.extend( + collect_subsystems(apis) + .into_iter() + .map(|s| subsystem_initializer(s).to_string()), + ); + for layout in collect_native_layouts(apis).values() { + if let Some(builder) = apis + .native_builders + .iter() + .find(|b| b.layout_name == layout.name) + { + result.insert(format!("create{}", builder.js_name)); + for field in &builder.outputs { + let prefix = match field.kind { + NativeOutputFieldKind::U32 => "get", + NativeOutputFieldKind::Resource { .. } => "take", + }; + result.insert(format!( + "{prefix}{}{}", + builder.js_name, + upper_first(&field.surface_name) + )); + } + } else { + result.insert(format!("create{}", layout.name)); + } + } + result.into_iter().collect() +} + +pub(super) fn render(apis: &ProjectedApis, runtime_import: &str) -> GeneratedOutput { + let js = render_js(apis, runtime_import, &unsafe_runtime_import(runtime_import)); + let dts = render_dts(apis, runtime_import); + let mut extra_files = Vec::new(); + for definition in &apis.enums { + let (js, dts) = render_enum(definition); + extra_files.push((format!("{}.js", definition.name), js)); + extra_files.push((format!("{}.d.ts", definition.name), dts)); + } + extra_files.sort_by(|left, right| left.0.cmp(&right.0)); + GeneratedOutput { + js, + dts, + extra_files, + } +} + +fn render_js(apis: &ProjectedApis, runtime_import: &str, unsafe_runtime_import: &str) -> String { + let mut output = String::new(); + output.push_str("// Generated by dynwinrt-codegen - do not edit\n"); + output.push_str("'use strict'\n"); + output.push_str(&format!( + "const {{ DynWin32 }} = require({runtime_import:?})\n\ + const {{ DynWin32: _nativeAggregate, DynWin32Function }} = require({unsafe_runtime_import:?})\n\n" + )); + let subsystems = collect_subsystems(apis); + for subsystem in &subsystems { + let initializer = subsystem_initializer(*subsystem); + output.push_str(&format!( + "function {initializer}() {{ return DynWin32.{initializer}() }}\nexports.{initializer} = {initializer}\n" + )); + } + if !subsystems.is_empty() { + output.push('\n'); + } + let native_layouts = collect_native_layouts(apis); + for layout in native_layouts.values() { + let builder = apis + .native_builders + .iter() + .find(|builder| builder.layout_name == layout.name); + output.push_str(&format!( + "const _nativeLayout_{} = {}\n", + layout.name, + native_layout_descriptor_js(layout) + )); + if let Some(builder) = builder { + render_native_builder_js(&mut output, layout, builder); + } else { + output.push_str(&format!( + "function create{}(bytes) {{ return _nativeAggregate.createNativeStruct(_nativeLayout_{}, bytes) }}\nexports.create{} = create{}\n\n", + layout.name, layout.name, layout.name, layout.name + )); + } + } + + fn render_native_builder_js( + output: &mut String, + layout: &NativeLayout, + builder: &ProjectedNativeBuilder, + ) { + output.push_str(&format!( + "function create{}(init) {{\n const value = _nativeAggregate.createNativeStruct(_nativeLayout_{})\n init ??= {{}}\n", + builder.js_name, layout.name + )); + if let Some(size_field) = &builder.size_field { + output.push_str(&format!( + " _nativeAggregate.setNativeStructU32(value, _nativeLayout_{}, {:?}, value.length)\n", + layout.name, size_field + )); + } + for field in &builder.fields { + match field.kind { + NativeBuilderFieldKind::Boolean => output.push_str(&format!( + " _nativeAggregate.setNativeStructBool32(value, _nativeLayout_{}, {:?}, Boolean(init.{}))\n", + layout.name, field.native_name, field.surface_name + )), + NativeBuilderFieldKind::DataPointer { nullable } => output.push_str(&format!( + " _nativeAggregate.setNativeStructPointer(value, _nativeLayout_{}, {:?}, DynWin32.dataPointer(init.{} ?? null, {}))\n", + layout.name, field.native_name, field.surface_name, nullable + )), + } + } + output.push_str(&format!( + " return value\n}}\nexports.create{0} = create{0}\n\n", + builder.js_name + )); + for field in &builder.outputs { + let function = match field.kind { + NativeOutputFieldKind::U32 => { + format!("get{}{}", builder.js_name, upper_first(&field.surface_name)) + } + NativeOutputFieldKind::Resource { .. } => { + format!( + "take{}{}", + builder.js_name, + upper_first(&field.surface_name) + ) + } + }; + let expression = match field.kind { + NativeOutputFieldKind::U32 => format!( + "_nativeAggregate.getNativeStructU32(value, _nativeLayout_{}, {:?})", + layout.name, field.native_name + ), + NativeOutputFieldKind::Resource { cleanup } => format!( + "_nativeAggregate.takeNativeStructResource(value, _nativeLayout_{}, {:?}, {:?})", + layout.name, + field.native_name, + cleanup_name(cleanup) + ), + }; + output.push_str(&format!( + "function {function}(value) {{ return {expression} }}\nexports.{function} = {function}\n" + )); + } + if !builder.outputs.is_empty() { + output.push('\n'); + } + } + + if apis.functions.iter().any(|function| { + function + .inputs + .iter() + .any(|input| matches!(input, InputExpression::BufferLength { .. })) + }) { + output.push_str( + "function _bufferCount(value, divisor) {\n\ + \x20 if (value == null) return 0\n\ + \x20 const byteLength = DynWin32.byteLength(value)\n\ + \x20 if (byteLength % divisor !== 0) throw new RangeError('buffer byte length is not divisible by its native element size')\n\ + \x20 const count = byteLength / divisor\n\ + \x20 if (!Number.isSafeInteger(count)) throw new RangeError('native buffer count is not a safe integer')\n\ + \x20 return count\n\ + }\n\n", + ); + } + if apis.functions.iter().any(|function| { + function + .inputs + .iter() + .any(|input| matches!(input, InputExpression::ScalarPointer { .. })) + }) { + output.push_str( + "function _scalarPointer(kind, value) {\n\ + \x20 switch (kind) {\n\ + \x20 case 'bool8': { const b = DynWin32.allocateBuffer(1); b.writeUInt8(value ? 1 : 0); return b }\n\ + \x20 case 'bool32': { const b = DynWin32.allocateBuffer(4); b.writeInt32LE(value ? 1 : 0); return b }\n\ + \x20 case 'i8': { const b = DynWin32.allocateBuffer(1); b.writeInt8(value); return b }\n\ + \x20 case 'u8': { const b = DynWin32.allocateBuffer(1); b.writeUInt8(value); return b }\n\ + \x20 case 'i16': { const b = DynWin32.allocateBuffer(2); b.writeInt16LE(value); return b }\n\ + \x20 case 'u16': { const b = DynWin32.allocateBuffer(2); b.writeUInt16LE(value); return b }\n\ + \x20 case 'i32': { const b = DynWin32.allocateBuffer(4); b.writeInt32LE(value); return b }\n\ + \x20 case 'u32': { const b = DynWin32.allocateBuffer(4); b.writeUInt32LE(value); return b }\n\ + \x20 case 'i64': { const b = DynWin32.allocateBuffer(8); b.writeBigInt64LE(BigInt(value)); return b }\n\ + \x20 case 'u64': { const b = DynWin32.allocateBuffer(8); b.writeBigUInt64LE(BigInt(value)); return b }\n\ + \x20 case 'f32': { const b = DynWin32.allocateBuffer(4); b.writeFloatLE(value); return b }\n\ + \x20 case 'f64': { const b = DynWin32.allocateBuffer(8); b.writeDoubleLE(value); return b }\n\ + \x20 default: throw new TypeError(`unsupported scalar pointer kind ${kind}`)\n\ + \x20 }\n\ + }\n\n", + ); + } + + if apis.functions.iter().any(|function| { + function.inputs.iter().any(|input| { + matches!( + input, + InputExpression::Surface { + conversion: Conversion::U32Flags, + .. + } + ) + }) + }) { + output.push_str( + "function _u32Flags(value) {\n\ + \x20 if (!Number.isInteger(value) || value < -0x80000000 || value > 0xffffffff) throw new RangeError('flags must be a native 32-bit integer or bitwise combination')\n\ + \x20 return DynWin32.u32(value >>> 0)\n\ + }\n\n", + ); + } + for function in &apis.functions { + render_function_js(&mut output, function); + output.push('\n'); + } + for function in &apis.async_functions { + render_async_function_js(&mut output, function); + output.push('\n'); + } + output.push_str("const Apis = Object.freeze({\n"); + for subsystem in &subsystems { + let initializer = subsystem_initializer(*subsystem); + output.push_str(&format!(" {initializer}: {initializer},\n")); + } + for function in &apis.functions { + output.push_str(&format!(" {}: {},\n", function.js_name, function.js_name)); + if let Some(alias) = &function.unicode_alias { + output.push_str(&format!(" {alias}: {alias},\n")); + } + } + for function in &apis.async_functions { + output.push_str(&format!(" {}: {},\n", function.js_name, function.js_name)); + } + + output.push_str("})\nexports.Apis = Apis\n"); + output +} + +fn upper_first(value: &str) -> String { + let mut chars = value.chars(); + chars + .next() + .map(|first| first.to_ascii_uppercase().to_string() + chars.as_str()) + .unwrap_or_default() +} + +fn render_async_function_js(output: &mut String, function: &ProjectedAsyncFunction) { + let runtime_method = match function.kind { + AsyncIoKind::Read => "beginReadFile", + AsyncIoKind::Write => "beginWriteFile", + }; + output.push_str(&format!( + "function {}(file, buffer, offset, signal) {{\n try {{\n if (signal != null && (typeof signal.addEventListener !== 'function' || typeof signal.removeEventListener !== 'function' || typeof signal.aborted !== 'boolean')) return Promise.reject(new TypeError('signal must be an AbortSignal'))\n if (signal?.aborted) {{ const error = new Error('The operation was aborted'); error.name = 'AbortError'; return Promise.reject(error) }}\n }} catch (error) {{ return Promise.reject(error) }}\n let operation\n let aborted = false\n const abort = () => {{ aborted = true; operation?.cancel() }}\n try {{ signal?.addEventListener('abort', abort, {{ once: true }}) }} catch (error) {{ return Promise.reject(error) }}\n try {{ operation = DynWin32.{}(file, buffer, offset ?? 0n) }} catch (error) {{ signal?.removeEventListener('abort', abort); return Promise.reject(error) }}\n if (aborted) operation.cancel()\n const promise = new Promise((resolve, reject) => {{\n try {{ operation.start((error, bytesTransferred) => error ? reject(error) : resolve(bytesTransferred)) }} catch (error) {{ reject(error) }}\n }})\n return promise.catch((cause) => {{\n const message = String(cause?.message ?? '')\n const cancelled = message.includes('Win32 error 995') || message.includes('OVERLAPPED operation was aborted')\n if (!aborted || !cancelled) throw cause\n const error = new Error('The operation was aborted')\n error.name = 'AbortError'\n error.cause = cause\n throw error\n }}).finally(() => signal?.removeEventListener('abort', abort))\n}}\nexports.{0} = {0}\n", + function.js_name, runtime_method + )); +} + +fn unsafe_runtime_import(runtime_import: &str) -> String { + if runtime_import.ends_with("/win32") { + format!("{runtime_import}/unsafe") + } else if let Some(prefix) = runtime_import.strip_suffix("win32.js") { + format!("{prefix}win32-unsafe.js") + } else { + format!("{runtime_import}/unsafe") + } +} + +fn render_runtime_plan( + output: &mut String, + runtime: &RuntimePlan, + plan_name: &str, + bind_name: &str, +) { + output.push_str(&format!( + "let {plan_name}\nfunction {bind_name}() {{\n return {plan_name} ??= DynWin32Function.bind({{\n dll: {:?},\n entryPoint: {:?},\n parameters: [\n", + runtime.dll, runtime.entry_point + )); + for parameter in &runtime.parameters { + let pointee = parameter + .pointee_aggregate + .as_ref() + .map(|layout| format!(", pointeeDescriptor: _nativeLayout_{}", layout.name)) + .unwrap_or_default(); + output.push_str(&format!( + " {{ type: {:?}, direction: {:?}, nullable: {}, cleanup: {:?}, consumesResource: {}, resourceCleanup: {:?}, aggregateDescriptor: {}{pointee} }},\n", + abi_name(parameter.abi), + direction_name(parameter.direction), + parameter.nullable, + cleanup_name(parameter.cleanup), + parameter.consumes_resource, + cleanup_name(parameter.resource_cleanup), + parameter + .aggregate + .as_ref() + .map(native_layout_descriptor_js) + .unwrap_or_else(|| "undefined".into()), + )); + } + output.push_str(&format!( + " ],\n returnType: {:?},\n returnCleanup: {:?},\n successRule: {:?},\n captureLastError: {},\n callingConvention: {:?},\n returnAggregateDescriptor: {},\n", + runtime.return_abi + .map(abi_name) + .unwrap_or("void"), + cleanup_name(runtime.return_cleanup), + success_name(runtime.success_rule), + runtime.capture_last_error, + calling_convention_name(runtime.calling_convention), + runtime.return_aggregate + .as_ref() + .map(native_layout_descriptor_js) + .unwrap_or_else(|| "undefined".into()), + )); + let descriptor = + serde_json::to_string(&runtime.call_contract).expect("validated native call contract"); + output.push_str(&format!( + " callContractDescriptor: {},\n", + serde_json::to_string(&descriptor).expect("native call descriptor string") + )); + output.push_str(" })\n}\n"); +} + +fn render_function_js(output: &mut String, function: &ProjectedFunction) { + let plan_name = format!("_{}Plan", function.js_name); + let bind_name = format!("_bind{}Plan", function.metadata_name); + render_runtime_plan(output, &function.runtime, &plan_name, &bind_name); + let mut surface_parameters = function + .parameters + .iter() + .map(|parameter| parameter.name.as_str()) + .collect::>(); + if function.subsystem.is_some() { + surface_parameters.insert(0, "_subsystem"); + } + output.push_str(&format!( + "function {}({}) {{\n", + function.js_name, + surface_parameters.join(", ") + )); + for parameter in &function.parameters { + if let Some(minimum) = parameter.minimum_bytes { + output.push_str(&format!( + " if ({} != null && DynWin32.byteLength({}) < {}) throw new RangeError({:?})\n", + parameter.name, + parameter.name, + minimum, + format!( + "{} must contain at least {minimum} bytes for its native fixed-size contract", + parameter.name + ), + )); + } + } + let arguments = function + .inputs + .iter() + .map(|input| render_input(input, function)) + .collect::>() + .join(", "); + let plan = format!("{bind_name}()"); + let invocation = function.subsystem.map_or_else( + || format!("{plan}.invoke([{arguments}])"), + |subsystem| { + format!( + "{plan}.invokeWithSubsystem(_subsystem, {:?}, [{arguments}])", + subsystem_name(subsystem) + ) + }, + ); + output.push_str(&format!( + " const _call = {invocation}\n const _return = _call.returnValue\n const _outputs = _call.outputs\n" + )); + match &function.return_shape { + ReturnShape::Void => output.push_str(" return undefined\n"), + ReturnShape::Direct { + typ, + conversion, + may_be_unavailable, + } => { + output.push_str(&format!( + " return {}\n", + render_result_conversion(typ, *conversion, "_return", *may_be_unavailable) + )); + } + ReturnShape::Object { + status, + return_value, + return_may_be_unavailable, + outputs, + last_error, + } => { + output.push_str(" return {\n"); + if *status { + output.push_str(&format!( + " status: {},\n", + render_optional_conversion( + "_return", + "DynWin32.toNumber(_return)".into(), + *return_may_be_unavailable + ) + )); + } else if let Some((typ, conversion)) = return_value { + output.push_str(&format!( + " result: {},\n", + render_result_conversion( + typ, + *conversion, + "_return", + *return_may_be_unavailable + ) + )); + } + for result in outputs { + let value = format!("_outputs[{}]", result.output_index); + let converted = render_result_conversion( + &result.typ, + result.conversion, + &value, + result.may_be_unavailable, + ); + output.push_str(&format!(" {}: {},\n", result.name, converted,)); + } + if *last_error { + output.push_str(" lastError: _call.lastError,\n"); + } + output.push_str(" }\n"); + } + } + output.push_str("}\n"); + output.push_str(&format!("exports.{0} = {0}\n", function.js_name)); + if let Some(alias) = &function.unicode_alias { + output.push_str(&format!( + "const {alias} = {}\nexports.{alias} = {alias}\n", + function.js_name + )); + } +} + +fn render_optional_conversion(value: &str, converted: String, may_be_unavailable: bool) -> String { + if may_be_unavailable { + format!("DynWin32.isUnavailable({value}) ? null : ({converted})") + } else { + converted + } +} + +fn render_result_conversion( + typ: &SurfaceType, + conversion: Conversion, + value: &str, + may_be_unavailable: bool, +) -> String { + let converted = if let SurfaceType::NativeStruct(name) = typ { + format!("_nativeAggregate.toNativeStruct({value}, _nativeLayout_{name})") + } else { + render_output_conversion(conversion, value) + }; + render_optional_conversion(value, converted, may_be_unavailable) +} + +fn render_input(input: &InputExpression, function: &ProjectedFunction) -> String { + match input { + InputExpression::Surface { + parameter_index, + conversion, + } => { + let parameter = &function.parameters[*parameter_index]; + let value = ¶meter.name; + match conversion { + Conversion::Boolean => format!("DynWin32.bool32({value})"), + Conversion::Boolean8 => format!("DynWin32.bool8({value})"), + Conversion::I8 => format!("DynWin32.i8({value})"), + Conversion::U8 => format!("DynWin32.u8({value})"), + Conversion::I16 => format!("DynWin32.i16({value})"), + Conversion::U16 => format!("DynWin32.u16({value})"), + Conversion::I32 => format!("DynWin32.i32({value})"), + Conversion::U32 => format!("DynWin32.u32({value})"), + Conversion::U32Flags => format!("_u32Flags({value})"), + Conversion::I64 => format!("DynWin32.i64({value})"), + Conversion::U64 => format!("DynWin32.u64({value})"), + Conversion::F32 => format!("DynWin32.f32({value})"), + Conversion::F64 => format!("DynWin32.f64({value})"), + Conversion::Handle => { + format!("DynWin32.handle({value}, {})", parameter.nullable) + } + Conversion::DataPointer => { + if parameter.alignment.unwrap_or(1) > 1 { + format!( + "DynWin32.alignedDataPointer({value}, {}, {})", + parameter.alignment.unwrap(), + parameter.nullable + ) + } else { + format!("DynWin32.dataPointer({value}, {})", parameter.nullable) + } + } + Conversion::WideString => { + format!("DynWin32.wideString({value}, {})", parameter.nullable) + } + Conversion::AnsiString => { + format!("DynWin32.ansiString({value}, {})", parameter.nullable) + } + Conversion::WideMultiString => { + format!("DynWin32.wideMultiString({value}, {})", parameter.nullable) + } + Conversion::AnsiMultiString => { + format!("DynWin32.ansiMultiString({value}, {})", parameter.nullable) + } + Conversion::ResourceInput(cleanup) => { + format!("DynWin32.resource({value}, {:?})", cleanup_name(*cleanup)) + } + Conversion::BigInt => format!("DynWin32.handle({value})"), + Conversion::Number + | Conversion::Resource + | Conversion::ResourceOrHandle + | Conversion::NativeAggregate => { + unreachable!("result conversion cannot be an input") + } + } + } + InputExpression::BufferLength { + parameter_index, + divisor, + abi, + } => { + let value = &function.parameters[*parameter_index].name; + format!( + "DynWin32.{}(_bufferCount({}, {}))", + abi_name(*abi), + value, + divisor + ) + } + InputExpression::NullPointer => "DynWin32.nullPointer()".into(), + InputExpression::Zero(abi) => render_zero(*abi), + InputExpression::NativeAggregate { + parameter_index, + layout, + nullable, + by_value, + } => { + let value = &function.parameters[*parameter_index].name; + if *by_value { + format!( + "_nativeAggregate.nativeStructValue({value}, _nativeLayout_{})", + layout.name + ) + } else { + format!( + "_nativeAggregate.nativeStruct({value}, _nativeLayout_{}, {nullable})", + layout.name + ) + } + } + InputExpression::ScalarPointer { + parameter_index, + scalar, + nullable, + } => { + let value = &function.parameters[*parameter_index].name; + let kind = scalar_pointer_kind(*scalar); + let alignment = scalar_pointer_alignment(*scalar); + let converted = format!( + "DynWin32.alignedDataPointer(_scalarPointer({kind:?}, {value}), {alignment}, false)" + ); + if *nullable { + format!("({value} == null ? DynWin32.nullPointer() : {converted})") + } else { + converted + } + } + InputExpression::ComInterface { + parameter_index, + iid, + } => { + let value = &function.parameters[*parameter_index].name; + format!( + "DynWin32.comObject({value}, {iid:?}, {})", + function.parameters[*parameter_index].nullable + ) + } + InputExpression::StringPointerPointer { + parameter_index, + encoding, + nullable, + } => { + let value = &function.parameters[*parameter_index].name; + match encoding { + StringEncoding::Wide => { + format!("DynWin32.wideStringPointerPointer({value}, {nullable})") + } + StringEncoding::Ansi => { + format!("DynWin32.ansiStringPointerPointer({value}, {nullable})") + } + } + } + } +} + +fn render_output_conversion(conversion: Conversion, value: &str) -> String { + match conversion { + Conversion::Boolean => format!("DynWin32.toBoolean({value})"), + Conversion::Number => format!("DynWin32.toNumber({value})"), + Conversion::BigInt => format!("DynWin32.toBigint({value})"), + Conversion::Resource => format!("DynWin32.toResource({value})"), + Conversion::ResourceOrHandle => format!("DynWin32.toResourceOrHandle({value})"), + Conversion::NativeAggregate => { + unreachable!("native aggregate output requires its descriptor") + } + Conversion::I8 + | Conversion::Boolean8 + | Conversion::U8 + | Conversion::I16 + | Conversion::U16 + | Conversion::I32 + | Conversion::U32 + | Conversion::U32Flags + | Conversion::I64 + | Conversion::U64 + | Conversion::F32 + | Conversion::F64 + | Conversion::Handle + | Conversion::DataPointer + | Conversion::WideString + | Conversion::AnsiString + | Conversion::WideMultiString + | Conversion::AnsiMultiString + | Conversion::ResourceInput(_) => unreachable!("input conversion cannot be a result"), + } +} + +fn render_dts(apis: &ProjectedApis, runtime_import: &str) -> String { + let mut output = String::new(); + output.push_str("// Generated by dynwinrt-codegen - do not edit\n"); + output.push_str(&format!( + "import type {{ DynWin32NativeStruct, DynWin32Resource, DynWin32SubsystemContext, DynWinRtValue }} from {runtime_import:?}\n" + )); + for definition in &apis.enums { + output.push_str(&format!( + "import type {{ {} }} from './{}.js'\n", + definition.name, definition.name + )); + } + output.push('\n'); + + let mut handles = BTreeSet::new(); + if !apis.async_functions.is_empty() { + handles.insert("HANDLE".to_string()); + } + for function in &apis.functions { + for parameter in &function.parameters { + collect_handle_alias(¶meter.typ, &mut handles); + } + match &function.return_shape { + ReturnShape::Direct { typ, .. } => collect_handle_alias(typ, &mut handles), + ReturnShape::Object { + return_value, + outputs, + .. + } => { + if let Some((typ, _)) = return_value { + collect_handle_alias(typ, &mut handles); + } + for output in outputs { + collect_handle_alias(&output.typ, &mut handles); + } + } + ReturnShape::Void => {} + } + } + for handle in handles { + output.push_str(&format!( + "export type {handle} = bigint | number | DynWin32Resource\n" + )); + } + for layout in collect_native_layouts(apis).values() { + if let Some(builder) = apis + .native_builders + .iter() + .find(|builder| builder.layout_name == layout.name) + { + output.push_str(&format!("export interface {}Init {{\n", builder.js_name)); + for field in &builder.fields { + let typ = match field.kind { + NativeBuilderFieldKind::Boolean => "boolean", + NativeBuilderFieldKind::DataPointer { nullable: true } => { + "Buffer | Uint8Array | null" + } + NativeBuilderFieldKind::DataPointer { nullable: false } => { + "Buffer | Uint8Array" + } + }; + output.push_str(&format!( + " {}{}: {}\n", + field.surface_name, + if field.optional { "?" } else { "" }, + typ + )); + } + output.push_str(&format!( + "}}\nexport type {0} = DynWin32NativeStruct\nexport declare function create{1}(init?: {1}Init): {0}\n", + layout.name, builder.js_name + )); + for field in &builder.outputs { + let (prefix, typ) = match field.kind { + NativeOutputFieldKind::U32 => ("get", "number"), + NativeOutputFieldKind::Resource { .. } => ("take", "DynWin32Resource | null"), + }; + output.push_str(&format!( + "export declare function {prefix}{}{}(value: {}): {typ}\n", + builder.js_name, + upper_first(&field.surface_name), + layout.name + )); + } + } else { + output.push_str(&format!( + "export type {} = DynWin32NativeStruct\nexport declare function create{}(bytes?: Buffer | Uint8Array): {}\n", + layout.name, layout.name, layout.name + )); + } + } + if !apis.functions.is_empty() { + output.push('\n'); + } + let subsystems = collect_subsystems(apis); + for subsystem in &subsystems { + let initializer = subsystem_initializer(*subsystem); + output.push_str(&format!( + "export declare function {initializer}(): DynWin32SubsystemContext\n" + )); + } + for function in &apis.functions { + let mut parameters = function + .parameters + .iter() + .map(|parameter| { + let mut typ = dts_type(¶meter.typ); + if parameter.nullable { + typ.push_str(" | null"); + } + format!("{}: {typ}", parameter.name) + }) + .collect::>(); + if function.subsystem.is_some() { + parameters.insert(0, "_subsystem: DynWin32SubsystemContext".into()); + } + let parameters = parameters.join(", "); + output.push_str(&format!( + "export declare function {}({parameters}): {}\n", + function.js_name, + dts_return_shape(&function.return_shape) + )); + if let Some(alias) = &function.unicode_alias { + output.push_str(&format!( + "export declare const {alias}: typeof {}\n", + function.js_name + )); + } + } + for function in &apis.async_functions { + output.push_str(&format!( + "export declare function {}(file: DynWin32Resource, buffer: Buffer, offset?: bigint, signal?: AbortSignal): Promise\n", + function.js_name + )); + } + output.push_str("\nexport declare const Apis: Readonly<{\n"); + for subsystem in &subsystems { + let initializer = subsystem_initializer(*subsystem); + output.push_str(&format!(" {initializer}: typeof {initializer}\n")); + } + for function in &apis.functions { + output.push_str(&format!( + " {}: typeof {}\n", + function.js_name, function.js_name + )); + if let Some(alias) = &function.unicode_alias { + output.push_str(&format!(" {alias}: typeof {alias}\n")); + } + } + for function in &apis.async_functions { + output.push_str(&format!( + " {}: typeof {}\n", + function.js_name, function.js_name + )); + } + output.push_str("}>\n"); + output +} + +fn collect_handle_alias(typ: &SurfaceType, handles: &mut BTreeSet) { + if let SurfaceType::Handle(name) = typ { + handles.insert(name.clone()); + } +} + +fn dts_return_shape(shape: &ReturnShape) -> String { + match shape { + ReturnShape::Void => "void".into(), + ReturnShape::Direct { + typ, + may_be_unavailable, + .. + } => dts_result_type(typ, *may_be_unavailable), + ReturnShape::Object { + status, + return_value, + return_may_be_unavailable, + outputs, + last_error, + } => { + let mut fields = Vec::new(); + if *status { + fields.push(format!( + "readonly status: {}", + dts_result_type(&SurfaceType::Number, *return_may_be_unavailable) + )); + } else if let Some((typ, _)) = return_value { + fields.push(format!( + "readonly result: {}", + dts_result_type(typ, *return_may_be_unavailable) + )); + } + fields.extend(outputs.iter().map(|output| { + let typ = dts_result_type(&output.typ, output.may_be_unavailable); + format!("readonly {}: {typ}", output.name) + })); + if *last_error { + fields.push("readonly lastError: number".into()); + } + format!("{{ {} }}", fields.join("; ")) + } + } +} + +fn dts_result_type(typ: &SurfaceType, may_be_unavailable: bool) -> String { + let mut result = dts_type(typ); + if may_be_unavailable && !matches!(typ, SurfaceType::Resource | SurfaceType::ResourceOrHandle) { + result.push_str(" | null"); + } + result +} + +fn dts_type(typ: &SurfaceType) -> String { + match typ { + SurfaceType::Boolean => "boolean".into(), + SurfaceType::Number => "number".into(), + SurfaceType::BigInt => "bigint".into(), + SurfaceType::Enum(name) | SurfaceType::Handle(name) => name.clone(), + SurfaceType::Buffer => "Buffer | Uint8Array".into(), + SurfaceType::String(StringEncoding::Wide | StringEncoding::Ansi) => { + "string | Buffer | Uint8Array".into() + } + SurfaceType::MultiString(StringEncoding::Wide | StringEncoding::Ansi) => { + "string | readonly string[] | Buffer | Uint8Array".into() + } + SurfaceType::ManagedResource => "DynWin32Resource".into(), + SurfaceType::Resource => "DynWin32Resource | null".into(), + SurfaceType::ResourceOrHandle => "DynWin32Resource | bigint | null".into(), + SurfaceType::NativeStruct(name) | SurfaceType::NativeUnion(name) => name.clone(), + SurfaceType::ComInterface(_) => "DynWinRtValue".into(), + } +} + +fn render_zero(abi: AbiType) -> String { + match abi { + AbiType::Bool32 => "DynWin32.bool32(false)".into(), + AbiType::I8 => "DynWin32.i8(0)".into(), + AbiType::U8 => "DynWin32.u8(0)".into(), + AbiType::I16 => "DynWin32.i16(0)".into(), + AbiType::U16 => "DynWin32.u16(0)".into(), + AbiType::I32 => "DynWin32.i32(0)".into(), + AbiType::U32 => "DynWin32.u32(0)".into(), + AbiType::I64 => "DynWin32.i64(0n)".into(), + AbiType::U64 => "DynWin32.u64(0n)".into(), + AbiType::F32 => "DynWin32.f32(0)".into(), + AbiType::F64 => "DynWin32.f64(0)".into(), + AbiType::Pointer => "DynWin32.nullPointer()".into(), + AbiType::FunctionPointer | AbiType::Handle => "DynWin32.handle(0n, true)".into(), + } +} + +fn collect_native_layouts(apis: &ProjectedApis) -> BTreeMap { + let mut layouts = BTreeMap::new(); + for function in &apis.functions { + for input in &function.inputs { + if let InputExpression::NativeAggregate { layout, .. } = input { + layouts + .entry(layout.name.clone()) + .or_insert_with(|| layout.clone()); + } + } + if let Some(layout) = &function.runtime.return_aggregate { + layouts + .entry(layout.name.clone()) + .or_insert_with(|| layout.clone()); + } + } + layouts +} + +fn native_layout_descriptor_js(layout: &NativeLayout) -> String { + let descriptor = format!( + "{{\"name\":\"{}.{}\",\"kind\":\"{}\",\"outputFields\":{},\"x86\":{},\"x64\":{},\"arm64\":{}}}", + layout.namespace, + layout.name, + match layout.kind { + super::ir::NativeAggregateKind::Struct => "struct", + super::ir::NativeAggregateKind::Union => "union", + }, + serde_json::to_string(&layout.output_fields).expect("validated native result field names"), + native_architecture_json(&layout.x86), + native_architecture_json(&layout.x64), + native_architecture_json(&layout.arm64), + ); + format!( + "'{}'", + descriptor.replace('\\', "\\\\").replace('\'', "\\'") + ) +} + +fn native_architecture_json(layout: &NativeArchitectureLayout) -> String { + let fields = layout + .fields + .iter() + .map(|field| { + format!( + "{{\"name\":\"{}\",\"offset\":{},\"count\":{},\"type\":{}}}", + field.name, + field.offset, + field.count, + native_field_type_json(&field.typ) + ) + }) + .collect::>() + .join(","); + format!( + "{{\"size\":{},\"alignment\":{},\"fields\":[{}]}}", + layout.size, layout.alignment, fields + ) +} + +fn native_field_type_json(typ: &NativeFieldType) -> String { + match typ { + NativeFieldType::Scalar(scalar) => { + format!("{{\"kind\":\"{}\"}}", native_scalar_name(*scalar)) + } + NativeFieldType::Guid => "{\"kind\":\"guid\"}".into(), + NativeFieldType::Pointer => "{\"kind\":\"pointer\"}".into(), + NativeFieldType::Handle { cleanup } => format!( + "{{\"kind\":\"handle\",\"cleanup\":\"{}\"}}", + cleanup_name(*cleanup) + ), + NativeFieldType::Struct { name, layout, .. } => format!( + "{{\"kind\":\"struct\",\"name\":\"{name}\",\"layout\":{}}}", + native_architecture_json(layout) + ), + NativeFieldType::Union { name, layout, .. } => format!( + "{{\"kind\":\"union\",\"name\":\"{name}\",\"layout\":{}}}", + native_architecture_json(layout) + ), + } +} + +fn native_scalar_name(scalar: NativeScalar) -> &'static str { + match scalar { + NativeScalar::I8 => "i8", + NativeScalar::U8 => "u8", + NativeScalar::I16 => "i16", + NativeScalar::U16 => "u16", + NativeScalar::I32 => "i32", + NativeScalar::U32 => "u32", + NativeScalar::I64 => "i64", + NativeScalar::U64 => "u64", + NativeScalar::F32 => "f32", + NativeScalar::F64 => "f64", + NativeScalar::NativeIsize => "isize", + NativeScalar::NativeUsize => "usize", + } +} + +fn scalar_pointer_kind(scalar: super::ir::Scalar) -> &'static str { + match scalar { + super::ir::Scalar::Bool8 => "bool8", + super::ir::Scalar::Bool32 => "bool32", + super::ir::Scalar::I8 => "i8", + super::ir::Scalar::U8 => "u8", + super::ir::Scalar::I16 => "i16", + super::ir::Scalar::U16 => "u16", + super::ir::Scalar::I32 => "i32", + super::ir::Scalar::U32 => "u32", + super::ir::Scalar::I64 | super::ir::Scalar::NativeIsize => "i64", + super::ir::Scalar::U64 | super::ir::Scalar::NativeUsize => "u64", + super::ir::Scalar::F32 => "f32", + super::ir::Scalar::F64 => "f64", + } +} + +fn scalar_pointer_alignment(scalar: super::ir::Scalar) -> usize { + match scalar { + super::ir::Scalar::Bool32 + | super::ir::Scalar::I32 + | super::ir::Scalar::U32 + | super::ir::Scalar::F32 => 4, + super::ir::Scalar::Bool8 | super::ir::Scalar::I8 | super::ir::Scalar::U8 => 1, + super::ir::Scalar::I16 | super::ir::Scalar::U16 => 2, + super::ir::Scalar::I64 + | super::ir::Scalar::U64 + | super::ir::Scalar::F64 + | super::ir::Scalar::NativeIsize + | super::ir::Scalar::NativeUsize => 8, + } +} + +fn render_enum(definition: &EnumDefinition) -> (String, String) { + let mut js = String::from("// Generated by dynwinrt-codegen - do not edit\n'use strict'\n"); + js.push_str(&format!("const {} = Object.freeze({{\n", definition.name)); + for member in &definition.members { + js.push_str(&format!(" {}: {},\n", member.name, member.value)); + } + js.push_str(&format!("}})\nexports.{0} = {0}\n", definition.name)); + + let mut dts = String::from("// Generated by dynwinrt-codegen - do not edit\n"); + if definition.is_flags { + dts.push_str(&format!("export type {} = number\n", definition.name)); + } else { + dts.push_str(&format!( + "export type {0} = (typeof {0})[keyof typeof {0}]\n", + definition.name + )); + } + dts.push_str(&format!("export declare const {}: {{\n", definition.name)); + for member in &definition.members { + dts.push_str(&format!(" readonly {}: {}\n", member.name, member.value)); + } + dts.push_str("}\n"); + (js, dts) +} + +fn collect_subsystems(apis: &ProjectedApis) -> BTreeSet { + apis.functions + .iter() + .filter_map(|function| function.subsystem) + .collect() +} + +fn subsystem_name(subsystem: Subsystem) -> &'static str { + match subsystem { + Subsystem::Winsock => "winsock", + Subsystem::GdiPlus => "gdiplus", + Subsystem::MediaFoundation => "mediaFoundation", + } +} + +fn subsystem_initializer(subsystem: Subsystem) -> &'static str { + match subsystem { + Subsystem::Winsock => "initializeWinsock", + Subsystem::GdiPlus => "initializeGdiPlus", + Subsystem::MediaFoundation => "initializeMediaFoundation", + } +} + +fn abi_name(typ: AbiType) -> &'static str { + match typ { + AbiType::Bool32 => "bool32", + AbiType::I8 => "i8", + AbiType::U8 => "u8", + AbiType::I16 => "i16", + AbiType::U16 => "u16", + AbiType::I32 => "i32", + AbiType::U32 => "u32", + AbiType::I64 => "i64", + AbiType::U64 => "u64", + AbiType::F32 => "f32", + AbiType::F64 => "f64", + AbiType::Pointer => "pointer", + AbiType::FunctionPointer => "functionPointer", + AbiType::Handle => "handle", + } +} + +fn direction_name(direction: Direction) -> &'static str { + match direction { + Direction::In => "in", + Direction::Out => "out", + Direction::InOut => "inout", + } +} + +fn cleanup_name(cleanup: Cleanup) -> &'static str { + match cleanup { + Cleanup::None => "none", + Cleanup::CloseHandle => "closeHandle", + Cleanup::RegCloseKey => "regCloseKey", + Cleanup::LocalFree => "localFree", + Cleanup::GlobalFree => "globalFree", + Cleanup::FreeLibrary => "freeLibrary", + Cleanup::CloseServiceHandle => "closeServiceHandle", + Cleanup::CoTaskMemFree => "coTaskMemFree", + Cleanup::CredFree => "credFree", + } +} + +fn success_name(success: super::ir::SuccessRule) -> &'static str { + match success { + super::ir::SuccessRule::Always => "always", + super::ir::SuccessRule::ReturnZero => "zero", + super::ir::SuccessRule::ReturnNonZero => "nonzero", + super::ir::SuccessRule::ReturnNonNull => "nonnull", + super::ir::SuccessRule::HResultSucceeded => "hresult", + super::ir::SuccessRule::SignedNonNegative => "nonnegative", + super::ir::SuccessRule::ReturnValidHandle => "validHandle", + } +} + +fn calling_convention_name(convention: super::ir::CallingConvention) -> &'static str { + match convention { + super::ir::CallingConvention::System => "system", + super::ir::CallingConvention::Cdecl => "cdecl", + } +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/result_policy_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/result_policy_tests.rs new file mode 100644 index 00000000..7868976d --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/result_policy_tests.rs @@ -0,0 +1,600 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::{ir::*, test_support::*, *}; +use crate::win32_metadata::*; + +fn handle_result(output: bool, capture_last_error: bool) -> (FunctionContract, ResultTarget) { + let handle = RawType { + base: RawBaseType::Named { + namespace: "Tests.Resources".into(), + name: "NATIVE_HANDLE".into(), + kind: RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + }; + let mut raw = synthetic_function("NativeResult"); + raw.parameters = vec![ + parameter("source", handle.clone(), RawDirection::In), + parameter("flags", scalar(RawScalar::U8), RawDirection::In), + ]; + raw.supports_last_error = capture_last_error; + if output { + let mut slot = parameter( + "pHandle", + pointer(handle, 1, RawConstness::Mutable), + RawDirection::Out, + ); + slot.free_with = Some("CloseHandle".into()); + raw.parameters.push(slot); + raw.return_status = RawStatusSemantics::ZeroIsSuccess; + } + let mut native = semantic(&raw); + let target = if output { + ResultTarget::Parameter { index: 2 } + } else { + native.return_type = Some(native.parameters[0].typ.clone()); + native.return_abi = Some(AbiType::Handle); + native.return_native_name = native.parameters[0].native_name.clone(); + native.return_cleanup = Cleanup::CloseHandle; + native.success_rule = SuccessRule::ReturnValidHandle; + ResultTarget::Return {} + }; + (native, target) +} + +fn result_projection( + function: &ProjectedFunction, + target: ResultTarget, +) -> (&SurfaceType, Conversion, bool) { + match (&function.return_shape, target) { + ( + ReturnShape::Direct { + typ, + conversion, + may_be_unavailable, + }, + ResultTarget::Return {}, + ) => (typ, *conversion, *may_be_unavailable), + ( + ReturnShape::Object { + return_value: Some((typ, conversion)), + return_may_be_unavailable, + .. + }, + ResultTarget::Return {}, + ) => (typ, *conversion, *return_may_be_unavailable), + (ReturnShape::Object { outputs, .. }, ResultTarget::Parameter { .. }) => ( + &outputs[0].typ, + outputs[0].conversion, + outputs[0].may_be_unavailable, + ), + _ => panic!("expected projected native result"), + } +} + +#[test] +fn result_matrix_separates_success_failure_ownership_delivery_and_projection() { + let owned = ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle, + }; + let borrowed = ResultOwnership::Borrowed {}; + let alias = ResultOwnership::AliasInput { parameter: 0 }; + let cases = [ + ( + "undefined", + ResultPolicy::delivered(owned), + ResultPolicy::Undefined {}, + SurfaceType::Resource, + Conversion::Resource, + true, + ), + ( + "owned-discarded", + ResultPolicy::delivered(owned), + ResultPolicy::discarded(owned), + SurfaceType::Resource, + Conversion::Resource, + true, + ), + ( + "owned-delivered", + ResultPolicy::delivered(owned), + ResultPolicy::delivered(owned), + SurfaceType::Resource, + Conversion::Resource, + false, + ), + ( + "borrowed-delivered", + ResultPolicy::delivered(owned), + ResultPolicy::delivered(borrowed), + SurfaceType::ResourceOrHandle, + Conversion::ResourceOrHandle, + false, + ), + ( + "alias-delivered", + ResultPolicy::delivered(owned), + ResultPolicy::delivered(alias), + SurfaceType::ResourceOrHandle, + Conversion::ResourceOrHandle, + false, + ), + ( + "alias-discarded", + ResultPolicy::delivered(owned), + ResultPolicy::discarded(alias), + SurfaceType::Resource, + Conversion::Resource, + true, + ), + ( + "borrowed-discarded", + ResultPolicy::delivered(owned), + ResultPolicy::discarded(borrowed), + SurfaceType::Resource, + Conversion::Resource, + true, + ), + ( + "only-cleanup-owned", + ResultPolicy::delivered(borrowed), + ResultPolicy::discarded(owned), + SurfaceType::Handle("NATIVE_HANDLE".into()), + Conversion::BigInt, + true, + ), + ( + "never-delivered", + ResultPolicy::Undefined {}, + ResultPolicy::discarded(owned), + SurfaceType::Handle("NATIVE_HANDLE".into()), + Conversion::BigInt, + true, + ), + ]; + for output in [false, true] { + for capture in [false, true] { + for (name, on_success, on_failure, typ, conversion, unavailable) in &cases { + let (mut native, target) = handle_result(output, capture); + let evidence = ResultContract { + target, + on_success: *on_success, + on_failure: *on_failure, + overrides: Vec::new(), + }; + native.result_contracts = vec![evidence.clone()]; + let projected = project::project_function(&native) + .unwrap_or_else(|error| panic!("{name}: {error}")); + assert_eq!( + projected.runtime.call_contract.version, + dynwinrt_win32_contracts::CURRENT_VERSION + ); + assert!(projected.runtime.call_contract.outputs.is_empty()); + assert_eq!( + projected.runtime.call_contract.result(target), + Some(&evidence) + ); + assert_eq!( + result_projection(&projected, target), + (typ, *conversion, *unavailable), + "{name}, output={output}, capture={capture}" + ); + for width in [32, 64] { + projected + .runtime + .call_contract + .validate_signature(&projected.runtime.signature_shape(width)) + .unwrap(); + } + } + } + } +} + +#[test] +fn legacy_owned_output_cleanup_is_not_promoted_to_new_metadata_failure_guarantees() { + let (mut native, target) = handle_result(true, false); + let legacy = CallContract::decode("{}").unwrap(); + assert_eq!(legacy.version, dynwinrt_win32_contracts::LEGACY_VERSION); + native.call_contract = legacy.clone(); + let projected = project::project_function(&native).unwrap(); + let shape = projected.runtime.signature_shape(64); + let compatibility = legacy.upgrade(&shape).unwrap(); + let historical = compatibility.result(target).unwrap(); + let fresh = projected.runtime.call_contract.result(target).unwrap(); + assert_eq!( + historical.on_failure, + ResultPolicy::discarded(ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle + }) + ); + assert_eq!(fresh.on_success, historical.on_success); + assert_eq!(fresh.on_failure, ResultPolicy::Undefined {}); + assert_eq!( + projected + .runtime + .call_contract + .result(ResultTarget::Return {}), + compatibility.result(ResultTarget::Return {}), + "scalar/status failure results remain defined" + ); + + for version in [ + dynwinrt_win32_contracts::SLOT_VERSION, + dynwinrt_win32_contracts::CURRENT_VERSION, + ] { + let mut explicit = compatibility.clone(); + explicit.version = version; + native.call_contract = + CallContract::decode(&serde_json::to_string(&explicit).unwrap()).unwrap(); + assert_eq!( + project::project_function(&native) + .unwrap() + .runtime + .call_contract, + compatibility, + "an explicit complete v{version} contract retains its failure guarantee" + ); + } + + native.call_contract = legacy; + native.result_contracts = vec![historical.clone()]; + let evidenced = project::project_function(&native).unwrap(); + assert_eq!( + evidenced.runtime.call_contract.result(target), + Some(historical), + "reviewed per-result evidence may explicitly define failure storage and cleanup" + ); +} + +#[test] +fn resolved_override_policies_determine_return_and_output_resource_unions() { + for output in [false, true] { + let (mut native, target) = handle_result(output, false); + let owned = ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle, + }; + native.result_contracts = vec![ResultContract { + target, + on_success: ResultPolicy::delivered(owned), + on_failure: ResultPolicy::Undefined {}, + overrides: vec![ + ResultOverride { + when: Condition { + succeeded: Some(true), + ..Condition::default() + }, + policy: ResultPolicy::delivered(ResultOwnership::AliasInput { parameter: 0 }), + }, + ResultOverride { + when: Condition { + succeeded: Some(false), + ..Condition::default() + }, + policy: ResultPolicy::discarded(owned), + }, + ], + }]; + let projected = project::project_function(&native).unwrap(); + assert_eq!( + result_projection(&projected, target), + ( + &SurfaceType::ResourceOrHandle, + Conversion::ResourceOrHandle, + true + ) + ); + let roundtrip = + CallContract::decode(&serde_json::to_string(&projected.runtime.call_contract).unwrap()) + .unwrap(); + assert_eq!(roundtrip, projected.runtime.call_contract); + assert!(roundtrip.result(target).unwrap().may_alias()); + } +} + +#[test] +fn ambiguous_and_forbidden_result_contracts_fail_before_rendering() { + let (base, target) = handle_result(false, false); + let evidence = ResultContract { + target, + on_success: ResultPolicy::delivered(ResultOwnership::Owned { + cleanup: Cleanup::CloseHandle, + }), + on_failure: ResultPolicy::Undefined {}, + overrides: Vec::new(), + }; + for ownership in [ + ResultOwnership::Value {}, + ResultOwnership::Owned { + cleanup: Cleanup::None, + }, + ResultOwnership::Owned { + cleanup: Cleanup::RegCloseKey, + }, + ResultOwnership::AliasInput { parameter: 1 }, + ResultOwnership::AliasInput { parameter: 99 }, + ] { + let mut native = base.clone(); + let mut result = evidence.clone(); + result.on_failure = ResultPolicy::delivered(ownership); + native.result_contracts = vec![result]; + assert!(project::project_function(&native).is_err(), "{ownership:?}"); + } + for conditions in [ + vec![Condition::default(), Condition::default()], + vec![ + Condition { + succeeded: Some(true), + ..Condition::default() + }, + Condition { + return_value: Some(7), + ..Condition::default() + }, + ], + vec![ + Condition { + inputs: vec![InputPredicate::BitsIn { + parameter: 1, + mask: 3, + values: vec![1], + }], + ..Condition::default() + }, + Condition { + inputs: vec![InputPredicate::BitsIn { + parameter: 1, + mask: 1, + values: vec![1], + }], + ..Condition::default() + }, + ], + vec![Condition { + inputs: vec![ + InputPredicate::BitsIn { + parameter: 1, + mask: 3, + values: vec![1], + }, + InputPredicate::BitsIn { + parameter: 1, + mask: 3, + values: vec![2], + }, + ], + ..Condition::default() + }], + vec![Condition { + succeeded: Some(true), + return_value: Some(0), + ..Condition::default() + }], + ] { + let mut native = base.clone(); + let mut result = evidence.clone(); + result.overrides = conditions + .into_iter() + .map(|when| ResultOverride { + when, + policy: ResultPolicy::Undefined {}, + }) + .collect(); + native.result_contracts = vec![result]; + assert!(project::project_function(&native).is_err()); + } + let mut native = base.clone(); + native.call_contract = CallContract::current(Vec::new(), Vec::new()); + assert!( + project::project_function(&native).is_err(), + "v2 cannot omit a native result" + ); + for target in [ + ResultTarget::Parameter { index: 0 }, + ResultTarget::Parameter { index: 99 }, + ] { + let mut native = base.clone(); + let mut result = evidence.clone(); + result.target = target; + native.result_contracts = vec![result]; + assert!(project::project_function(&native).is_err(), "{target:?}"); + } + for change in [ + |native: &mut FunctionContract| { + native.parameters[0].consumes_resource = true; + }, + |native: &mut FunctionContract| { + native.parameters[0].native_name.as_mut().unwrap().1 = "UNRELATED_HANDLE".into(); + }, + |native: &mut FunctionContract| { + native.parameters[0].pointer_depth = 1; + }, + ] { + let mut native = base.clone(); + change(&mut native); + native.result_contracts = vec![ResultContract { + on_success: ResultPolicy::delivered(ResultOwnership::AliasInput { parameter: 0 }), + ..evidence.clone() + }]; + assert!(project::project_function(&native).is_err()); + } +} + +#[test] +fn scalar_and_resource_non_delivery_is_guarded_for_direct_status_and_output_slots() { + let mut functions = Vec::new(); + for (name, output, status) in [ + ("ScalarDirect", false, false), + ("ScalarResults", true, false), + ("ScalarStatus", true, true), + ] { + let mut raw = synthetic_function(name); + raw.return_status = if status { + RawStatusSemantics::ZeroIsSuccess + } else { + RawStatusSemantics::None + }; + if output { + raw.parameters.push(parameter( + "pValue", + pointer(scalar(RawScalar::U32), 1, RawConstness::Mutable), + RawDirection::Out, + )); + } + let mut native = semantic(&raw); + native.result_contracts.push(ResultContract { + target: ResultTarget::Return {}, + on_success: ResultPolicy::delivered(ResultOwnership::Value {}), + on_failure: ResultPolicy::discarded(ResultOwnership::Value {}), + overrides: Vec::new(), + }); + if output { + native.result_contracts.push(ResultContract { + target: ResultTarget::Parameter { index: 0 }, + on_success: ResultPolicy::delivered(ResultOwnership::Value {}), + on_failure: ResultPolicy::Undefined {}, + overrides: Vec::new(), + }); + } + functions.push(project::project_function(&native).unwrap()); + } + for (output, name) in [(false, "OwnedDirect"), (true, "OwnedOutput")] { + let (mut native, _) = handle_result(output, false); + native.name = name.into(); + native.entry_point = name.into(); + functions.push(project::project_function(&native).unwrap()); + } + let generated = render::render( + &ProjectedApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions, + enums: Vec::new(), + native_builders: Vec::new(), + async_functions: Vec::new(), + }, + "@test/runtime/win32", + ); + assert!(generated.dts.contains("scalarDirect(): number | null")); + assert!(generated.dts.contains("readonly status: number | null")); + assert!(generated.dts.contains("readonly result: number | null")); + assert!(generated.dts.contains("readonly value: number | null")); + run_js( + &generated, + r#" +const assert=require('node:assert/strict') +const unavailable=Symbol('undefined native result') +const discarded=Symbol('defined native result discarded after cleanup') +let value=0 +let binds=0 +let conversions=0 +const runtime={DynWin32:{ + isUnavailable:value=>value===unavailable||value===discarded, + handle:value=>value,u8:value=>value, + toNumber(value){assert.notEqual(value,unavailable);assert.notEqual(value,discarded);return Number(value)}, + toResource(value){assert.notEqual(value,unavailable);assert.notEqual(value,discarded);conversions++;return value} +},DynWin32Function:{bind(spec){ + binds++ + assert.equal(JSON.parse(spec.callContractDescriptor).version,3) + return {invoke(){return {returnValue:spec.entryPoint==='OwnedOutput'?0:value,outputs:[value]}}} +}}} +"#, + r#" +assert.equal(binds,0,'module import must not bind or dispatch native functions') +for(value of [unavailable,discarded,42]){ + const expected=typeof value==='symbol'?null:42 + assert.equal(projected.scalarDirect(),expected) + const results=projected.scalarResults() + assert.equal(results.result,expected) + assert.equal(results.value,expected) + const status=projected.scalarStatus() + assert.equal(status.status,expected) + assert.equal(status.value,expected) +} +const owner={} +for(value of [unavailable,discarded,owner]){ + const expected=typeof value==='symbol'?null:owner + assert.equal(projected.ownedDirect(1n,0),expected) + assert.equal(projected.ownedOutput(1n,0).handle,expected) +} +assert.equal(conversions,2,'non-delivered resources must not reach converters') +assert.equal(binds,5,'native plans remain lazy and cached') +"#, + ); +} + +#[test] +fn actual_metadata_resolves_physical_buffers_aggregate_returns_and_evidenced_direct_returns() { + let Some(path) = metadata() else { return }; + for (namespace, name) in [ + ("Windows.Win32.System.Registry", "RegQueryValueExW"), + ("Windows.Win32.System.SystemInformation", "GetSystemTime"), + ( + "Windows.Win32.System.Console", + "GetLargestConsoleWindowSize", + ), + ("Windows.Win32.Storage.FileSystem", "CreateFileA"), + ("Windows.Win32.Storage.FileSystem", "CreateFileW"), + ] { + let raw = metadata_function(&path, namespace, name); + let native = semantic(&raw); + let projected = project_one(raw); + let shape = projected.runtime.signature_shape(64); + projected + .runtime + .call_contract + .validate_signature(&shape) + .unwrap(); + assert_eq!( + projected + .runtime + .call_contract + .results + .iter() + .map(|result| result.target) + .collect::>(), + shape.result_targets().collect::>() + ); + for (index, parameter) in projected.runtime.parameters.iter().enumerate() { + if parameter.direction == Direction::In { + assert!( + projected + .runtime + .call_contract + .result(ResultTarget::Parameter { index }) + .is_none() + ); + } + } + if name == "GetLargestConsoleWindowSize" { + assert_eq!( + shape.return_type, + Some(dynwinrt_win32_contracts::NativeType::Aggregate) + ); + assert_eq!( + projected + .runtime + .call_contract + .result(ResultTarget::Return {}) + .unwrap() + .on_success, + ResultPolicy::delivered(ResultOwnership::Value {}) + ); + } + if name.starts_with("CreateFile") { + assert_eq!(native.result_contracts.len(), 1); + assert_eq!( + projected + .runtime + .call_contract + .result(ResultTarget::Return {}), + Some(&native.result_contracts[0]) + ); + } + } +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/shape_tests.rs b/tools/dynwinrt-codegen/src/codegen/win32/shape_tests.rs new file mode 100644 index 00000000..11c8586c --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/shape_tests.rs @@ -0,0 +1,398 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use super::{ir::*, test_support::*, *}; +use crate::win32_metadata::*; + +fn field(name: &str, typ: RawType, count: Option) -> RawNativeField { + RawNativeField { + name: name.into(), + typ, + fixed_count: count, + bitfield: false, + flexible_array: false, + } +} + +fn layout(kind: RawLayoutKind, fields: Vec) -> RawNativeLayoutSet { + RawNativeLayoutSet { + recursive: false, + evidence: None, + variants: vec![RawNativeLayout { + architectures: RawArchitectures { + x86: true, + x64: true, + arm64: true, + }, + kind, + packing: RawPacking::Default, + declared_size: None, + forced_alignment: None, + fields, + }], + } +} + +fn record(name: &str, layout: RawNativeLayoutSet, depth: u8) -> RawType { + RawType { + base: RawBaseType::Named { + namespace: "Tests.Layouts".into(), + name: name.into(), + kind: RawNamedKind::NativeStruct { + layout: Box::new(layout), + }, + }, + pointer_depth: depth, + constness: RawConstness::Mutable, + } +} + +fn argument( + name: &str, + layout: RawNativeLayoutSet, + depth: u8, + direction: RawDirection, +) -> RawFunction { + let mut function = synthetic_function(name); + function.parameters.push(parameter( + "record", + record("RECORD", layout, depth), + direction, + )); + function +} + +fn projected_layout(function: &ProjectedFunction) -> &NativeLayout { + let InputExpression::NativeAggregate { layout, .. } = &function.inputs[0] else { + panic!("native aggregate input") + }; + layout +} + +#[test] +fn native_layout_padding_arrays_and_pointer_sized_scalars_match_each_architecture() { + let fixed = layout( + RawLayoutKind::Sequential, + vec![ + field("tag", scalar(RawScalar::U8), None), + field("wide", scalar(RawScalar::U64), None), + field("samples", scalar(RawScalar::U16), Some(3)), + ], + ); + let projected = project_one(argument("FixedArrayRecord", fixed, 1, RawDirection::In)); + let native = projected_layout(&projected); + for architecture in [&native.x86, &native.x64, &native.arm64] { + assert_eq!((architecture.size, architecture.alignment), (24, 8)); + assert_eq!( + architecture.fields, + vec![ + NativeField { + name: "tag".into(), + offset: 0, + count: 1, + typ: NativeFieldType::Scalar(NativeScalar::U8) + }, + NativeField { + name: "wide".into(), + offset: 8, + count: 1, + typ: NativeFieldType::Scalar(NativeScalar::U64) + }, + NativeField { + name: "samples".into(), + offset: 16, + count: 3, + typ: NativeFieldType::Scalar(NativeScalar::U16) + }, + ] + ); + } + let sized = layout( + RawLayoutKind::Sequential, + vec![ + field("tag", scalar(RawScalar::U8), None), + field("word", scalar(RawScalar::NativeUsize), None), + field("tail", scalar(RawScalar::U16), None), + ], + ); + let projected = project_one(argument("NativeWidthRecord", sized, 0, RawDirection::In)); + let native = projected_layout(&projected); + assert!(native.by_value_compatible); + for (architecture, size, alignment, offsets) in [ + (&native.x86, 12, 4, [0, 4, 8]), + (&native.x64, 24, 8, [0, 8, 16]), + (&native.arm64, 24, 8, [0, 8, 16]), + ] { + assert_eq!( + (architecture.size, architecture.alignment), + (size, alignment) + ); + assert_eq!( + architecture + .fields + .iter() + .map(|f| f.offset) + .collect::>(), + offsets + ); + } + assert_eq!( + projected.runtime.parameters[0].aggregate.as_ref(), + Some(native) + ); + assert!(matches!( + projected.inputs[0], + InputExpression::NativeAggregate { by_value: true, .. } + )); +} + +#[test] +fn union_members_overlap_but_union_values_cannot_be_passed_by_value() { + let union = layout( + RawLayoutKind::Union, + vec![ + field("small", scalar(RawScalar::U32), None), + field("large", scalar(RawScalar::U64), None), + ], + ); + let nested = layout( + RawLayoutKind::Sequential, + vec![ + field("tag", scalar(RawScalar::U8), None), + field("payload", record("PAYLOAD", union.clone(), 0), Some(2)), + ], + ); + for direction in [RawDirection::In, RawDirection::Out, RawDirection::InOut] { + let projected = project_one(argument("UnionPointer", union.clone(), 1, direction)); + let native = projected_layout(&projected); + assert_eq!(native.kind, NativeAggregateKind::Union); + assert_eq!((native.x64.size, native.x64.alignment), (8, 8)); + assert_eq!( + native + .x64 + .fields + .iter() + .map(|f| f.offset) + .collect::>(), + [0, 0] + ); + assert_eq!( + projected.parameters[0].typ, + SurfaceType::NativeUnion("RECORD".into()) + ); + assert_eq!(projected.runtime.parameters[0].direction, Direction::In); + assert_eq!( + projected.return_shape, + ReturnShape::Direct { + typ: SurfaceType::Number, + conversion: Conversion::Number, + may_be_unavailable: false, + } + ); + } + let projected = project_one(argument( + "NestedUnionPointer", + nested.clone(), + 1, + RawDirection::In, + )); + let native = projected_layout(&projected); + assert_eq!((native.x64.size, native.x64.alignment), (24, 8)); + assert_eq!(native.x64.fields[1].offset, 8); + assert_eq!(native.x64.fields[1].count, 2); + assert!( + matches!(&native.x64.fields[1].typ,NativeFieldType::Union { layout, .. } + if layout.size == 8 && layout.fields.iter().all(|f|f.offset == 0)) + ); + for shape in [union, nested] { + let function = argument("UnsupportedUnionValue", shape, 0, RawDirection::In); + let (generated, omitted) = + generate_apis_files(&apis(vec![function]), "@test/runtime/win32"); + assert_eq!(omitted.len(), 1); + assert!(omitted[0].reason.contains("union")); + assert!(!generated.js.contains("exports.unsupportedUnionValue")); + } +} + +#[test] +fn packing_forced_alignment_and_declared_tail_padding_are_not_guessed() { + for (packing, forced, declared, size, alignment, second_offset, by_value) in [ + (RawPacking::Default, None, None, 8, 4, 4, true), + (RawPacking::Explicit(1), None, None, 5, 1, 1, false), + (RawPacking::Explicit(2), None, None, 6, 2, 2, false), + (RawPacking::Default, Some(8), None, 8, 8, 4, false), + (RawPacking::Default, None, Some(12), 12, 4, 4, true), + ] { + let mut shape = layout( + RawLayoutKind::Sequential, + vec![ + field("first", scalar(RawScalar::U8), None), + field("second", scalar(RawScalar::U32), None), + ], + ); + shape.variants[0].packing = packing; + shape.variants[0].forced_alignment = forced; + shape.variants[0].declared_size = declared; + let projected = project_one(argument( + "PackedPointer", + shape.clone(), + 1, + RawDirection::In, + )); + let native = projected_layout(&projected); + assert_eq!((native.x64.size, native.x64.alignment), (size, alignment)); + assert_eq!(native.x64.fields[1].offset, second_offset); + let projection = project_apis(&apis(vec![argument( + "PackedValue", + shape, + 0, + RawDirection::In, + )])); + assert_eq!( + projection.omitted.is_empty(), + by_value, + "{packing:?} / {forced:?}" + ); + } +} + +#[test] +fn invalid_layout_facts_fail_before_emitting_a_native_wrapper() { + let base = layout( + RawLayoutKind::Sequential, + vec![field("value", scalar(RawScalar::U64), None)], + ); + let cases: &[(&str, fn(&mut RawNativeLayoutSet))] = &[ + ("recursive", |l| l.recursive = true), + ("unknown", |l| l.variants[0].kind = RawLayoutKind::Unknown), + ("empty", |l| l.variants[0].fields.clear()), + ("packing", |l| { + l.variants[0].packing = RawPacking::Explicit(3) + }), + ("alignment", |l| l.variants[0].forced_alignment = Some(16)), + ("alignment", |l| l.variants[0].forced_alignment = Some(3)), + ("declared", |l| l.variants[0].declared_size = Some(4)), + ("declared", |l| l.variants[0].declared_size = Some(9)), + ("zero", |l| l.variants[0].fields[0].fixed_count = Some(0)), + ("exceeds u32", |l| { + l.variants[0].fields[0].fixed_count = Some(usize::MAX) + }), + ("flexible", |l| { + l.variants[0].fields[0].flexible_array = true + }), + ("ambiguous", |l| l.variants.push(l.variants[0].clone())), + ("missing", |l| l.variants[0].architectures.arm64 = false), + ]; + for (reason, mutate) in cases { + let mut shape = base.clone(); + mutate(&mut shape); + let (generated, omitted) = generate_apis_files( + &apis(vec![argument("InvalidLayout", shape, 1, RawDirection::In)]), + "@test/runtime/win32", + ); + assert_eq!(omitted.len(), 1, "{reason}"); + assert!( + omitted[0].reason.contains(reason), + "{reason}: {:?}", + omitted[0] + ); + assert!(!generated.js.contains("exports.invalidLayout")); + } +} + +#[test] +fn scalar_and_guid_pointer_contracts_preserve_constness_width_and_storage_direction() { + for (kind, expected_abi, expected_surface) in [ + (RawScalar::I16, AbiType::I16, SurfaceType::Number), + (RawScalar::U64, AbiType::U64, SurfaceType::BigInt), + (RawScalar::Bool32, AbiType::Bool32, SurfaceType::Boolean), + ] { + for direction in [RawDirection::In, RawDirection::Out, RawDirection::InOut] { + let mut function = synthetic_function("PointerValue"); + let constness = if direction == RawDirection::In { + RawConstness::Const + } else { + RawConstness::Mutable + }; + function.parameters.push(parameter( + "value", + pointer(scalar(kind), 1, constness), + direction, + )); + let native = semantic(&function); + assert_eq!(native.parameters[0].pointer_depth, 1); + assert_eq!( + native.parameters[0].constness, + if direction == RawDirection::In { + Constness::Const + } else { + Constness::Mutable + } + ); + let projected = project_one(function); + if direction == RawDirection::In { + assert_eq!(projected.parameters[0].typ, expected_surface); + assert!(matches!( + projected.inputs[0], + InputExpression::ScalarPointer { + parameter_index: 0, + nullable: false, + .. + } + )); + assert_eq!(projected.runtime.parameters[0].abi, AbiType::Pointer); + assert_eq!(projected.runtime.parameters[0].direction, Direction::In); + } else { + assert_eq!(projected.runtime.parameters[0].abi, expected_abi); + assert_eq!( + projected.runtime.parameters[0].direction, + if direction == RawDirection::Out { + Direction::Out + } else { + Direction::InOut + } + ); + let ReturnShape::Object { outputs, .. } = &projected.return_shape else { + panic!("output cell") + }; + assert_eq!(outputs[0].output_index, 0); + assert_eq!(outputs[0].typ, expected_surface); + } + } + } + for direction in [RawDirection::In, RawDirection::Out, RawDirection::InOut] { + let guid = RawType { + base: RawBaseType::Named { + namespace: "System".into(), + name: "Guid".into(), + kind: RawNamedKind::Guid, + }, + pointer_depth: 1, + constness: RawConstness::Const, + }; + let mut function = synthetic_function("GuidPointer"); + let mut guid = parameter("guid", guid, direction); + guid.nullable = true; + function.parameters.push(guid); + let projected = project_one(function); + assert_eq!( + projected.parameters[0], + SurfaceParameter { + name: "guid".into(), + typ: SurfaceType::Buffer, + nullable: true, + minimum_bytes: Some(16), + alignment: Some(4), + } + ); + assert_eq!(projected.runtime.parameters[0].direction, Direction::In); + assert_eq!(projected.runtime.parameters[0].abi, AbiType::Pointer); + assert_eq!( + projected.inputs, + vec![InputExpression::Surface { + parameter_index: 0, + conversion: Conversion::DataPointer + }] + ); + } +} diff --git a/tools/dynwinrt-codegen/src/codegen/win32/test_support.rs b/tools/dynwinrt-codegen/src/codegen/win32/test_support.rs new file mode 100644 index 00000000..9a8db151 --- /dev/null +++ b/tools/dynwinrt-codegen/src/codegen/win32/test_support.rs @@ -0,0 +1,178 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::{ + io::Write, + path::Path, + process::{Command, Stdio}, +}; + +use super::{GeneratedOutput, ir::ProjectedFunction, project_apis}; +use crate::win32_metadata::{ + RawApis, RawArchitectures, RawBaseType, RawCallingConvention, RawConstness, RawDirection, + RawFunction, RawParameter, RawScalar, RawStatusSemantics, RawType, +}; + +fn resolve_metadata( + path: Option, + required: bool, + is_file: impl FnOnce(&str) -> bool, +) -> Result, String> { + match path.filter(|path| !path.trim().is_empty()) { + Some(path) if is_file(&path) => Ok(Some(path)), + Some(path) => Err(format!( + "DYNWINRT_WIN32_WINMD is not a readable metadata file: {path}" + )), + None if required => { + Err("DYNWINRT_REQUIRE_WIN32_METADATA=1 requires DYNWINRT_WIN32_WINMD".into()) + } + None => Ok(None), + } +} + +pub(crate) fn metadata() -> Option { + resolve_metadata( + std::env::var("DYNWINRT_WIN32_WINMD").ok(), + std::env::var("DYNWINRT_REQUIRE_WIN32_METADATA").as_deref() == Ok("1"), + |path| Path::new(path).is_file(), + ) + .unwrap_or_else(|reason| panic!("{reason}")) +} + +pub(crate) fn metadata_function(path: &str, namespace: &str, name: &str) -> RawFunction { + crate::win32_metadata::parse_apis(path, namespace, "Apis") + .unwrap_or_else(|| panic!("missing metadata container {namespace}.Apis")) + .functions + .into_iter() + .find(|function| function.name == name) + .unwrap_or_else(|| panic!("missing metadata function {namespace}.Apis::{name}")) +} + +pub(crate) fn scalar(kind: RawScalar) -> RawType { + RawType { + base: RawBaseType::Scalar(kind), + pointer_depth: 0, + constness: RawConstness::Unspecified, + } +} + +pub(crate) fn pointer(mut typ: RawType, depth: u8, constness: RawConstness) -> RawType { + typ.pointer_depth = depth; + typ.constness = constness; + typ +} + +pub(crate) fn parameter(name: &str, typ: RawType, direction: RawDirection) -> RawParameter { + RawParameter { + name: name.into(), + typ, + direction, + nullable: false, + reserved: false, + null_null_terminated: false, + buffer: None, + free_with: None, + } +} + +pub(crate) fn synthetic_function(name: &str) -> RawFunction { + RawFunction { + namespace: "Tests".into(), + container: "Apis".into(), + name: name.into(), + dll: "kernel32.dll".into(), + entry_point: name.into(), + return_type: scalar(RawScalar::U32), + parameters: Vec::new(), + return_status: RawStatusSemantics::None, + return_free_with: None, + supports_last_error: false, + calling_convention: RawCallingConvention::System, + architectures: RawArchitectures { + x86: true, + x64: true, + arm64: true, + }, + variadic: false, + evidence: None, + } +} + +pub(crate) fn apis(functions: Vec) -> RawApis { + RawApis { + namespace: "Tests".into(), + class_name: "Apis".into(), + functions, + } +} + +pub(crate) fn project_one(function: RawFunction) -> ProjectedFunction { + let projection = project_apis(&apis(vec![function])); + assert!(projection.omitted.is_empty(), "{:?}", projection.omitted); + assert_eq!(projection.projected.functions.len(), 1); + projection.projected.functions.into_iter().next().unwrap() +} + +pub(crate) fn semantic(function: &RawFunction) -> super::ir::FunctionContract { + super::model::validate_function(function) + .unwrap_or_else(|reason| panic!("{}: {reason}", function.name)) +} + +pub(crate) fn project_with_policy( + function: &RawFunction, + policy: &crate::win32_contracts::FunctionPolicy<'_>, +) -> Result { + let native = super::model::validate_function_with_policy(function, policy)?; + super::project::project_function(&native) +} + +pub(crate) fn run_js(generated: &GeneratedOutput, setup: &str, checks: &str) { + let script = format!( + "{setup}\nconst projected = {{}}\nrequire('node:vm').runInNewContext({}, \ + {{ exports: projected, require: () => runtime, Buffer, BigInt }})\n{checks}", + serde_json::to_string(&generated.js).unwrap(), + ); + let mut child = Command::new("node") + .arg("-") + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .expect("Node.js is required to exercise generated Win32 JavaScript"); + child + .stdin + .take() + .unwrap() + .write_all(script.as_bytes()) + .unwrap(); + let output = child.wait_with_output().unwrap(); + assert!( + output.status.success(), + "{}", + String::from_utf8_lossy(&output.stderr) + ); +} + +#[test] +fn required_metadata_configuration_never_silently_skips() { + for (path, required, present, expected) in [ + (None, false, false, Ok(None)), + (None, true, false, Err(())), + (Some(""), true, false, Err(())), + (Some("missing.winmd"), false, false, Err(())), + (Some("missing.winmd"), true, false, Err(())), + ( + Some("official.winmd"), + true, + true, + Ok(Some("official.winmd".to_owned())), + ), + ] { + let result = resolve_metadata(path.map(str::to_owned), required, |_| present); + assert_eq!( + result.map_err(|_| ()), + expected, + "{path:?}, required={required}" + ); + } +} diff --git a/tools/dynwinrt-codegen/src/lib.rs b/tools/dynwinrt-codegen/src/lib.rs index 0c59386c..ef0c3b86 100644 --- a/tools/dynwinrt-codegen/src/lib.rs +++ b/tools/dynwinrt-codegen/src/lib.rs @@ -7,4 +7,6 @@ pub mod com_metadata; mod contract_registry; pub mod meta; pub mod types; +mod win32_contracts; +pub mod win32_metadata; pub mod xml_doc; diff --git a/tools/dynwinrt-codegen/src/main.rs b/tools/dynwinrt-codegen/src/main.rs index 2fd43e93..894a8ac7 100644 --- a/tools/dynwinrt-codegen/src/main.rs +++ b/tools/dynwinrt-codegen/src/main.rs @@ -1,6 +1,9 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. +mod win32_census; +mod win32_output; + use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; use std::fs; use std::hash::{BuildHasher, Hash, Hasher}; @@ -16,6 +19,7 @@ use dynwinrt_codegen::codegen::javascript; use dynwinrt_codegen::codegen::package; use dynwinrt_codegen::codegen::python; use dynwinrt_codegen::codegen::typescript; +use dynwinrt_codegen::codegen::win32; use dynwinrt_codegen::codegen::winrt::extensions::winui; use dynwinrt_codegen::codegen::{project, render_dts, render_js}; use dynwinrt_codegen::com_metadata; @@ -30,7 +34,8 @@ use dynwinrt_codegen::xml_doc::DocTable; long_about = "dynwinrt-codegen reads .winmd metadata and generates typed bindings\n\ for dynamic Windows API invocation. JavaScript and TypeScript output uses\n\ @microsoft/dynwinrt; Python output uses dynwinrt. Supported Classic COM APIs\n\ - from Windows.Win32 metadata are available for JavaScript and TypeScript.\n\n\ + from Windows.Win32 metadata are available for JavaScript and TypeScript.\n\ + An initial contract-audited flat Win32 slice emits isolated JavaScript bindings.\n\n\ It auto-detects Windows SDK metadata and discovers sibling .winmd files\n\ in the same directory, so you typically only need to point at one file." )] @@ -78,6 +83,15 @@ enum Commands { json: bool, }, + /// Measure complete flat Win32 generation from native metadata and contracts. + Win32Census { + #[arg(long, value_name = "PATH")] + winmd: String, + + #[arg(long)] + json: bool, + }, + /// Generate exact per-target Classic COM raw/type capability reports. ComCapabilityCensus { /// Path to Microsoft Windows.Win32.winmd 71.0.14-preview. @@ -339,6 +353,9 @@ fn run() -> Result<(), String> { Commands::ComCensus { winmd, json } => { run_com_census(&winmd, json)?; } + Commands::Win32Census { winmd, json } => { + win32_census::run(&winmd, json)?; + } Commands::ComCapabilityCensus { winmd, output_dir, @@ -470,6 +487,7 @@ fn run() -> Result<(), String> { // Auto-discover sibling .winmd files in the same directories let winmd = meta::expand_winmd_paths(&winmd_joined); + let mut win32_type_index = win32::FlatFunctionIndex::new(&winmd); // Build XML doc table from sibling .xml files of each winmd. let expanded_parts: Vec = winmd @@ -520,13 +538,25 @@ fn run() -> Result<(), String> { if let Some(ref cls_arg) = class_name { let class_requests = parse_class_requests(cls_arg, namespace.as_deref())?; - // First: partition into WinRT classes and classic-COM interfaces. + // Partition the native domains before language projection. let mut classes = Vec::new(); + let mut win32_namespaces = BTreeSet::new(); let mut requested_winrt_interfaces = Vec::new(); let mut com_interfaces: Vec = Vec::new(); let mut com_coclasses: Vec = Vec::new(); let mut native_audio_completion = false; for (ns, cls) in &class_requests { + if ns.starts_with("Windows.Win32.") + && win32_type_index.has_flat_functions(ns, cls)? + { + if cls != "Apis" { + return Err(format!( + "Flat Win32 generation currently supports Apis containers, not {ns}.{cls}" + )); + } + win32_namespaces.insert(ns.clone()); + continue; + } if ns == com_metadata::completion::AUDIO_NAMESPACE && cls == com_metadata::completion::AUDIO_EXPORT { @@ -585,6 +615,31 @@ fn run() -> Result<(), String> { } } } + if !win32_namespaces.is_empty() { + if lang != "js" { + return Err(format!( + "--lang {lang} is not supported for flat Win32 DLL exports; use --lang js" + )); + } + win32_output::generate( + output_dir, + &winmd, + &win32_namespaces, + &import_name, + dry_run, + )?; + if classes.is_empty() + && requested_winrt_interfaces.is_empty() + && com_interfaces.is_empty() + && com_coclasses.is_empty() + && !native_audio_completion + { + if let Some(transaction) = output_transaction.take() { + transaction.commit()?; + } + return Ok(()); + } + } // Fail loud: classic-COM codegen only emits `.js` + `.d.ts` // today. If the user asked for a different language // (e.g. `--lang py`) but any of the requested `--class-name` @@ -992,6 +1047,29 @@ fn run() -> Result<(), String> { } } } else { + if let Some(ns) = namespace + .as_deref() + .filter(|ns| ns.starts_with("Windows.Win32.")) + && com_metadata::first_classic_com_interface_in_namespace(&winmd, ns).is_none() + && win32_type_index.has_flat_functions(ns, "Apis")? + { + if lang != "js" { + return Err(format!( + "--lang {lang} is not supported for flat Win32 DLL exports; use --lang js" + )); + } + win32_output::generate( + output_dir, + &winmd, + &BTreeSet::from([ns.to_string()]), + &import_name, + dry_run, + )?; + if let Some(transaction) = output_transaction.take() { + transaction.commit()?; + } + return Ok(()); + } if lang == "py" && !dry_run { clean_python_generated_output(output_dir)?; } @@ -1650,7 +1728,11 @@ fn check_javascript_layout_inventory(output_dir: &Path) -> Result<(), String> { continue; } if metadata.is_dir() { - if current == root && path.file_name().is_some_and(|name| name == "com") { + if current == root + && path + .file_name() + .is_some_and(|name| name == "com" || name == "win32") + { continue; } if contains_generated_implementation(root, &path) { @@ -1990,7 +2072,15 @@ fn validate_javascript_inventory_files( for entry in entries.flatten() { let path = entry.path(); if path.is_dir() { - if path == root.join("com") && !expected_namespace_roots.contains("com") { + if current == root + && path + .file_name() + .and_then(|name| name.to_str()) + .is_some_and(|name| { + matches!(name, "com" | "win32") + && !expected_namespace_roots.contains(name) + }) + { continue; } if shared_output @@ -3675,11 +3765,15 @@ fn write_bindings_manifest_with_plan( BTreeSet::new() }; let has_com_output = has_com_output(&output_dir.join("com"))?; - let content = package::render_bindings_package_json(&package::BindingsPackageManifestInput { - has_winrt_root, - has_com_output, - winrt_subpath_names: &winrt_subpath_names, - }); + let win32_namespaces = win32_output::namespace_paths(output_dir)?; + let content = package::render_bindings_package_json_with_win32( + &package::BindingsPackageManifestInput { + has_winrt_root, + has_com_output, + winrt_subpath_names: &winrt_subpath_names, + }, + &win32_namespaces, + ); let path = output_dir.join("package.json"); ensure_safe_generated_destination(output_dir, &path)?; fs::write(&path, content) diff --git a/tools/dynwinrt-codegen/src/win32_census.rs b/tools/dynwinrt-codegen/src/win32_census.rs new file mode 100644 index 00000000..79cb7f42 --- /dev/null +++ b/tools/dynwinrt-codegen/src/win32_census.rs @@ -0,0 +1,107 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::collections::BTreeMap; + +use dynwinrt_codegen::{codegen::win32, win32_metadata}; +use serde::Serialize; + +#[derive(Serialize)] +struct Census { + metadata: String, + eligible_functions: usize, + complete_functions: usize, + omitted_functions: usize, + coverage_percent: f64, + omission_reasons: BTreeMap, +} + +pub(super) fn run(winmd: &str, json: bool) -> Result<(), String> { + let functions = win32_metadata::parse_all_functions(winmd) + .ok_or_else(|| format!("Failed to load flat Win32 metadata from {winmd}"))?; + let eligible = functions.len(); + let mut containers = BTreeMap::new(); + for function in functions { + containers + .entry((function.namespace.clone(), function.container.clone())) + .or_insert_with(Vec::new) + .push(function); + } + let mut complete = 0; + let mut reasons = BTreeMap::new(); + for ((namespace, class_name), functions) in containers { + let projection = win32::project_apis(&win32_metadata::RawApis { + namespace, + class_name, + functions, + }); + complete += projection.complete_count(); + for omission in projection.omitted { + *reasons + .entry(reason_code(&omission.reason).to_string()) + .or_insert(0) += 1; + } + } + let result = Census { + metadata: winmd.into(), + eligible_functions: eligible, + complete_functions: complete, + omitted_functions: eligible + .checked_sub(complete) + .ok_or("Flat Win32 projection counted more exports than metadata contains")?, + coverage_percent: if eligible == 0 { + 0.0 + } else { + complete as f64 * 100.0 / eligible as f64 + }, + omission_reasons: reasons, + }; + if json { + println!( + "{}", + serde_json::to_string(&result) + .map_err(|error| format!("Failed to serialize Win32 census: {error}"))? + ); + } else { + println!( + "Flat Win32 complete functions: {}/{} ({:.6}%)", + result.complete_functions, result.eligible_functions, result.coverage_percent + ); + for (reason, count) in result.omission_reasons { + println!(" {count:>5} {reason}"); + } + } + Ok(()) +} + +fn reason_code(reason: &str) -> &'static str { + if reason.contains("calling convention") { + "calling-convention" + } else if reason.contains("variadic") { + "variadic" + } else if reason.contains("both x64 and ARM64") { + "architecture" + } else if reason.contains("System32 DLL") { + "module-policy" + } else if reason.contains("callback thunk") { + "callback" + } else if reason.contains("cleanup") { + "cleanup" + } else if reason.contains("pointer return lifetime") { + "return-ownership" + } else if reason.contains("native buffer") || reason.contains("count parameter") { + "buffer-contract" + } else if reason.contains("writable pointer") { + "writable-pointer" + } else if reason.contains("NativeStruct") { + "native-layout" + } else if reason.contains("pointer depth") || reason.contains("void is not") { + "pointer-contract" + } else if reason.contains("enum underlying") { + "enum-abi" + } else if reason.contains("unknown") || reason.contains("Unknown") { + "unknown-native-type" + } else { + "other" + } +} diff --git a/tools/dynwinrt-codegen/src/win32_contracts.rs b/tools/dynwinrt-codegen/src/win32_contracts.rs new file mode 100644 index 00000000..afa50fc8 --- /dev/null +++ b/tools/dynwinrt-codegen/src/win32_contracts.rs @@ -0,0 +1,1234 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Independently pinned Win32 semantic evidence. Generic ABI facts do not +//! require function allowlisting; exact contracts only supply missing semantics. + +use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; +use std::{ + collections::{BTreeMap, BTreeSet}, + sync::OnceLock, +}; +use windows_metadata::{AsRow, HasAttributes, reader}; + +use crate::codegen::win32::ir::{ + AsyncIoKind, CallContract, Cleanup, ResultContract, ResultOwnership, ResultPolicy, + ResultTarget, Subsystem, +}; +use crate::win32_metadata::{RawFunction, RawScalar}; + +pub(crate) const METADATA_SHA256: &str = + "B64EE4818A7ED9F9D135038D58C51BD08369184D4D5ED428F20E9DE55DF8121D"; + +pub(crate) fn sha256(bytes: &[u8]) -> String { + format!("{:X}", Sha256::digest(bytes)) +} + +fn text_sha256(text: &str) -> String { + sha256(text.replace("\r\n", "\n").as_bytes()) +} + +fn string_enum<'de, D, T>(deserializer: D) -> Result +where + D: serde::Deserializer<'de>, + T: Deserialize<'de>, +{ + let text = String::deserialize(deserializer)?; + T::deserialize(serde::de::value::StringDeserializer::::new(text)) +} + +fn optional_string_enum<'de, D, T>(deserializer: D) -> Result, D::Error> +where + D: serde::Deserializer<'de>, + T: Deserialize<'de>, +{ + Option::::deserialize(deserializer)? + .map(|text| T::deserialize(serde::de::value::StringDeserializer::::new(text))) + .transpose() +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub(crate) struct FunctionSelector { + pub namespace: String, + pub container: String, + pub name: String, + pub dll: String, + pub entry_point: String, + pub calling_convention: String, + pub architectures: u8, + pub source_fingerprint: String, +} + +#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub(crate) struct TypeSelector { + pub namespace: String, + pub name: String, + pub source_fingerprint: String, +} + +fn bytes(mut blob: reader::Blob<'_>) -> Vec { + let mut result = Vec::new(); + while !blob.is_empty() { + result.push(blob.read_u8()); + } + result +} + +fn attributes<'a>(item: &impl HasAttributes<'a>) -> Vec<(String, Vec)> { + let mut result = item + .attributes() + .map(|attribute| { + let constructor = attribute.ctor(); + let parent = constructor.parent(); + ( + format!("{}.{}", parent.namespace(), parent.name()), + bytes(attribute.blob(2)), + ) + }) + .collect::>(); + result.sort(); + result +} + +pub(crate) fn method_fingerprint( + namespace: &str, + container: &str, + method: &reader::MethodDef, +) -> String { + let import = method + .impl_map() + .expect("only flat imports have Win32 evidence"); + let parameters = method + .params() + .map(|p| { + ( + p.sequence(), + p.name().to_owned(), + format!("{:?}", p.flags()), + attributes(&p), + ) + }) + .collect::>(); + sha256( + &serde_json::to_vec(&( + namespace, + container, + method.name(), + import.import_scope().name(), + import.import_name(), + format!("{:?}", import.flags()), + format!("{:?}", method.flags()), + format!("{:?}", method.impl_flags()), + bytes(method.blob(4)), + attributes(method), + parameters, + )) + .expect("raw metadata facts serialize"), + ) +} + +pub(crate) fn type_fingerprint(index: &reader::Index, namespace: &str, name: &str) -> String { + let definitions = index + .get(namespace, name) + .map(|definition| { + let fields = definition + .fields() + .map(|field| { + ( + field.name().to_owned(), + format!("{:?}", field.flags()), + bytes(field.blob(2)), + field.constant().map(|value| format!("{:?}", value.value())), + attributes(&field), + ) + }) + .collect::>(); + ( + definition.namespace().to_owned(), + definition.name().to_owned(), + format!("{:?}", definition.flags()), + definition + .extends() + .map(|base| (base.namespace().to_string(), base.name().to_string())), + definition + .class_layout() + .map(|layout| (layout.packing_size(), layout.class_size())), + attributes(&definition), + fields, + ) + }) + .collect::>(); + sha256(&serde_json::to_vec(&definitions).expect("raw type metadata serializes")) +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde( + tag = "kind", + rename_all = "kebab-case", + rename_all_fields = "camelCase", + deny_unknown_fields +)] +pub(crate) enum FunctionEffect { + CountedBuffer { + parameter: usize, + count_parameter: usize, + nullable: bool, + }, + UnsupportedCountUnit { + parameter: usize, + }, + OwnedReturn { + #[serde(deserialize_with = "string_enum")] + cleanup: Cleanup, + }, + BorrowedReturn {}, + OwnedOutput { + parameter: usize, + #[serde(deserialize_with = "string_enum")] + cleanup: Cleanup, + }, + ConsumedInput { + parameter: usize, + #[serde(deserialize_with = "string_enum")] + cleanup: Cleanup, + }, + MutableString { + parameter: usize, + }, + CallContract { + contract: CallContract, + }, + ResultContract { + contract: ResultContract, + }, + OverlappedIo { + #[serde(deserialize_with = "string_enum")] + operation: AsyncIoKind, + file_parameter: usize, + buffer_parameter: usize, + count_parameter: usize, + transferred_parameter: usize, + overlapped_parameter: usize, + }, + Subsystem { + #[serde(deserialize_with = "string_enum")] + subsystem: Subsystem, + }, + SubsystemExempt {}, + ManagedLifecycle { + #[serde(deserialize_with = "string_enum")] + subsystem: Subsystem, + }, +} + +impl FunctionEffect { + fn key(&self) -> String { + match self { + Self::CountedBuffer { parameter, .. } | Self::UnsupportedCountUnit { parameter } => { + format!("buffer:{parameter}") + } + Self::OwnedReturn { .. } | Self::BorrowedReturn {} => "return".into(), + Self::OwnedOutput { parameter, .. } | Self::ConsumedInput { parameter, .. } => { + format!("ownership:{parameter}") + } + Self::MutableString { parameter } => format!("mutable-string:{parameter}"), + Self::CallContract { .. } => "call-contract".into(), + Self::ResultContract { contract } => match contract.target { + ResultTarget::Return {} => "result:return".into(), + ResultTarget::Parameter { index } => format!("result:parameter:{index}"), + ResultTarget::AggregateField { parameter, field } => { + format!("result:aggregate-field:{parameter}:{field}") + } + }, + Self::OverlappedIo { .. } => "async".into(), + Self::Subsystem { .. } | Self::SubsystemExempt {} | Self::ManagedLifecycle { .. } => { + "subsystem".into() + } + } + } +} + +#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq, Eq)] +#[serde(rename_all = "kebab-case")] +pub(crate) enum Encoding { + Utf16, + Ansi, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde( + tag = "kind", + rename_all = "kebab-case", + rename_all_fields = "camelCase", + deny_unknown_fields +)] +pub(crate) enum TypeMeaning { + Scalar { + #[serde(deserialize_with = "string_enum")] + scalar: RawScalar, + }, + Handle {}, + DataPointer {}, + StringPointer { + #[serde(deserialize_with = "string_enum")] + encoding: Encoding, + is_const: bool, + }, + FunctionPointer {}, + Unsupported {}, +} + +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] +pub(crate) enum StatusMeaning { + Zero, + SignedNonnegative, +} + +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] +pub(crate) enum BuilderKind { + SecurityAttributes, + StartupInfoAnsi, + StartupInfoWide, + ProcessInformation, +} + +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)] +pub(crate) enum FieldContract { + RetainedPointer { + nullable: bool, + optional: bool, + }, + NullPointer {}, + BorrowedHandle {}, + OwnedHandle { + #[serde(deserialize_with = "string_enum")] + cleanup: Cleanup, + }, + BooleanInput { + optional: bool, + }, + OutputU32 {}, +} + +impl FieldContract { + pub fn is_output(self) -> bool { + matches!(self, Self::OwnedHandle { .. } | Self::OutputU32 {}) + } +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub(crate) struct FieldPolicy { + pub name: String, + pub contract: FieldContract, +} + +#[derive(Clone, Copy, Debug, Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] +pub(crate) enum RecordKind { + Struct, + Union, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)] +pub(crate) enum RecipeType { + Scalar { + #[serde(deserialize_with = "string_enum")] + scalar: RawScalar, + }, + Named { + namespace: String, + name: String, + }, + Record { + layout: Box, + }, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub(crate) struct RecipeField { + pub name: String, + pub typ: RecipeType, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub(crate) struct LayoutRecipe { + pub name: String, + #[serde(deserialize_with = "string_enum")] + pub kind: RecordKind, + pub fields: Vec, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +pub(crate) struct AggregateContract { + #[serde(deserialize_with = "optional_string_enum")] + pub builder: Option, + pub size_field: Option, + pub fields: Vec, + pub anonymous_layouts: Vec, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)] +enum Citation { + MicrosoftLearn { url: String }, + SdkHeader { file: String }, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub(crate) struct FunctionEntry { + pub id: String, + pub selector: FunctionSelector, + pub contracts: Vec, + evidence: Vec, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +pub(crate) struct TypeEntry { + pub id: String, + pub selector: TypeSelector, + pub meaning: Option, + #[serde(deserialize_with = "optional_string_enum")] + pub status: Option, + pub aggregate: Option, + evidence: Vec, +} + +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(tag = "kind", rename_all = "kebab-case", deny_unknown_fields)] +pub(crate) enum DomainPolicy { + Subsystem { + namespace: String, + #[serde(deserialize_with = "string_enum")] + subsystem: Subsystem, + }, + ProviderLifecycle { + dll: String, + }, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +struct Group { + schema_version: u32, + entries: Vec, +} + +#[derive(Deserialize)] +#[serde(deny_unknown_fields)] +struct FilePin { + file: String, + sha256: String, +} + +#[derive(Deserialize)] +#[serde(deny_unknown_fields)] +struct MetadataPin { + package: String, + version: String, + sha256: String, +} + +#[derive(Deserialize)] +#[serde(rename_all = "camelCase", deny_unknown_fields)] +struct Manifest { + schema_version: u32, + metadata: MetadataPin, + schema: FilePin, + files: Vec, +} + +const MANIFEST: &str = include_str!("../contracts/win32/manifest.json"); +const SCHEMA: &str = include_str!("../contracts/win32/schema.json"); +const CALL_CONTRACT_SCHEMA: &str = include_str!("../contracts/win32/call-contract.schema.json"); +const FILES: &[(&str, &str)] = &[ + ("call-contract.schema.json", CALL_CONTRACT_SCHEMA), + ( + "function-contracts.json", + include_str!("../contracts/win32/function-contracts.json"), + ), + ( + "subsystem-policies.json", + include_str!("../contracts/win32/subsystem-policies.json"), + ), + ( + "native-types.json", + include_str!("../contracts/win32/native-types.json"), + ), + ( + "aggregate-layouts.json", + include_str!("../contracts/win32/aggregate-layouts.json"), + ), + ( + "policy-domains.json", + include_str!("../contracts/win32/policy-domains.json"), + ), +]; + +pub(crate) struct Registry { + functions: BTreeMap<(String, String, String), FunctionEntry>, + types: BTreeMap<(String, String), TypeEntry>, + domains: Vec, +} + +pub(crate) struct FunctionPolicy<'a> { + pub entry: Option<&'a FunctionEntry>, + pub subsystem: Option, +} + +impl FunctionPolicy<'_> { + pub fn effects(&self) -> impl Iterator { + self.entry + .into_iter() + .flat_map(|entry| entry.contracts.iter()) + } + + pub fn owned_return(&self) -> Option { + self.effects() + .find_map(|effect| match effect { + FunctionEffect::OwnedReturn { cleanup } => Some(*cleanup), + _ => None, + }) + .or_else(|| self.result_cleanup(ResultTarget::Return {})) + } + + pub fn borrowed_return(&self) -> bool { + self.effects() + .any(|effect| matches!(effect, FunctionEffect::BorrowedReturn {})) + || self + .result_contract(ResultTarget::Return {}) + .is_some_and(|result| { + result.policies().any(|policy| { + matches!( + policy, + ResultPolicy::Defined { + ownership: ResultOwnership::Borrowed {} + | ResultOwnership::AliasInput { .. }, + .. + } + ) + }) && self.result_cleanup(ResultTarget::Return {}).is_none() + }) + } + + pub fn output_cleanup(&self, index: usize) -> Option { + self.effects() + .find_map(|effect| match effect { + FunctionEffect::OwnedOutput { parameter, cleanup } if *parameter == index => { + Some(*cleanup) + } + _ => None, + }) + .or_else(|| self.result_cleanup(ResultTarget::Parameter { index })) + } + + pub fn consumed_input(&self, index: usize) -> Option { + self.effects().find_map(|effect| match effect { + FunctionEffect::ConsumedInput { parameter, cleanup } if *parameter == index => { + Some(*cleanup) + } + _ => None, + }) + } + + pub fn mutable_string(&self, index: usize) -> bool { + self.effects().any(|effect|matches!(effect,FunctionEffect::MutableString { parameter } if *parameter == index)) + } + + pub fn call_contract(&self) -> CallContract { + self.effects() + .find_map(|effect| match effect { + FunctionEffect::CallContract { contract } => Some(contract.clone()), + _ => None, + }) + .unwrap_or_default() + } + + pub fn result_contracts(&self) -> impl Iterator { + self.effects().filter_map(|effect| match effect { + FunctionEffect::ResultContract { contract } => Some(contract), + _ => None, + }) + } + + fn result_contract(&self, target: ResultTarget) -> Option<&ResultContract> { + self.result_contracts() + .find(|contract| contract.target == target) + .or_else(|| { + self.effects().find_map(|effect| match effect { + FunctionEffect::CallContract { contract } => contract.result(target), + _ => None, + }) + }) + } + + fn result_cleanup(&self, target: ResultTarget) -> Option { + self.result_contract(target)? + .policies() + .find_map(|policy| match policy { + ResultPolicy::Defined { + ownership: ResultOwnership::Owned { cleanup }, + .. + } => Some(*cleanup), + _ => None, + }) + } + + pub fn apply_buffers(&self, raw: &RawFunction) -> Result { + use crate::win32_metadata::{RawBuffer, RawBufferSize, RawDirection, buffer_element}; + let mut result = raw.clone(); + for effect in self.effects() { + match effect { + FunctionEffect::CountedBuffer { + parameter, + count_parameter, + nullable, + } => { + if parameter == count_parameter || *count_parameter >= result.parameters.len() { + return Err("win32.contract-conflict: invalid count parameter".into()); + } + let buffer = result + .parameters + .get_mut(*parameter) + .ok_or("win32.contract-conflict: missing buffer parameter")?; + if buffer.direction != RawDirection::Out { + return Err( + "win32.contract-conflict: counted output is not writable".into() + ); + } + if let Some(existing) = &buffer.buffer + && existing.size != RawBufferSize::ElementCountParam(*count_parameter) + { + return Err( + "win32.contract-conflict: metadata and evidence counts disagree".into(), + ); + } + buffer.buffer = Some(RawBuffer { + element: buffer_element(&buffer.typ), + size: RawBufferSize::ElementCountParam(*count_parameter), + }); + buffer.nullable = *nullable; + } + FunctionEffect::UnsupportedCountUnit { .. } => { + return Err( + "flag-dependent native buffer count units require a dedicated contract" + .into(), + ); + } + FunctionEffect::OwnedReturn { .. } + | FunctionEffect::BorrowedReturn {} + | FunctionEffect::OwnedOutput { .. } + | FunctionEffect::ConsumedInput { .. } + | FunctionEffect::MutableString { .. } + | FunctionEffect::CallContract { .. } + | FunctionEffect::ResultContract { .. } + | FunctionEffect::OverlappedIo { .. } + | FunctionEffect::Subsystem { .. } + | FunctionEffect::SubsystemExempt {} + | FunctionEffect::ManagedLifecycle { .. } => {} + } + } + Ok(result) + } +} + +fn group(text: &str) -> Result, String> { + let group: Group = + serde_json::from_str(text).map_err(|e| format!("win32.contract-json: {e}"))?; + if group.schema_version != 2 { + return Err("win32.contract-schema-version".into()); + } + Ok(group.entries) +} + +fn valid_hash(hash: &str) -> bool { + hash.len() == 64 + && hash + .bytes() + .all(|c| c.is_ascii_digit() || (b'A'..=b'F').contains(&c)) +} + +fn native_identifier(name: &str) -> bool { + !name.is_empty() + && name + .bytes() + .enumerate() + .all(|(i, c)| c.is_ascii_alphabetic() || c == b'_' || (i > 0 && c.is_ascii_digit())) +} + +fn native_namespace(name: &str) -> bool { + name.starts_with("Windows.Win32.") && name.split('.').all(native_identifier) +} + +fn identifier(id: &str) -> bool { + !id.is_empty() + && id + .bytes() + .all(|c| c.is_ascii_lowercase() || c.is_ascii_digit() || b"_.-".contains(&c)) +} + +fn dll_name(dll: &str) -> bool { + let lower = dll.to_ascii_lowercase(); + (lower.ends_with(".dll") || lower.ends_with(".drv")) + && !dll.contains("..") + && dll + .bytes() + .all(|c| c.is_ascii_alphanumeric() || b"_.-".contains(&c)) +} + +fn raw_result_target(registry: &Registry, raw: &RawFunction, target: ResultTarget) -> bool { + use crate::win32_metadata::{RawBaseType, RawDirection, RawNamedKind}; + match target { + ResultTarget::Return {} => { + raw.return_type.pointer_depth != 0 || !matches!(raw.return_type.base, RawBaseType::Void) + } + ResultTarget::Parameter { index } => raw.parameters.get(index).is_some_and(|parameter| { + parameter.direction != RawDirection::In + && parameter.typ.pointer_depth > 0 + && parameter.buffer.is_none() + }), + ResultTarget::AggregateField { parameter, field } => { + raw.parameters.get(parameter).is_some_and(|parameter| { + let RawBaseType::Named { + kind: RawNamedKind::NativeStruct { layout }, + .. + } = ¶meter.typ.base + else { + return false; + }; + parameter.direction != RawDirection::In + && parameter.typ.pointer_depth == 1 + && parameter.buffer.is_none() + && registry.layout_contract(layout).is_ok_and(|contract| { + contract.is_some_and(|contract| { + contract + .fields + .iter() + .filter(|field| field.contract.is_output()) + .count() + > field + }) + }) + }) + } + } +} + +fn validate_recipe(recipe: &LayoutRecipe, depth: usize) -> Result<(), String> { + if depth > 16 + || !native_identifier(&recipe.name) + || recipe.fields.is_empty() + || recipe.fields.len() > 256 + { + return Err("win32.contract-evidence: invalid anonymous layout recipe".into()); + } + let mut names = BTreeSet::new(); + for field in &recipe.fields { + if !native_identifier(&field.name) || !names.insert(&field.name) { + return Err("win32.contract-conflict: anonymous layout field".into()); + } + match &field.typ { + RecipeType::Record { layout } => validate_recipe(layout, depth + 1)?, + RecipeType::Named { namespace, name } + if !native_namespace(namespace) || !native_identifier(name) => + { + return Err("win32.contract-evidence: invalid native type reference".into()); + } + RecipeType::Scalar { .. } | RecipeType::Named { .. } => {} + } + } + Ok(()) +} + +fn citations(values: &[Citation]) -> bool { + values.iter().any(|citation| matches!(citation, Citation::MicrosoftLearn { url } + if url.starts_with("https://learn.microsoft.com/") && !url.bytes().any(|b|b.is_ascii_whitespace()))) + && values.iter().all(|citation| match citation { + Citation::MicrosoftLearn { url } => url.starts_with("https://learn.microsoft.com/"), + Citation::SdkHeader { file } => file.ends_with(".h") && !file.contains(['/', '\\', ':']), + }) +} + +impl Registry { + pub fn builtin() -> Result<&'static Self, String> { + static REGISTRY: OnceLock> = OnceLock::new(); + REGISTRY + .get_or_init(|| Self::load(MANIFEST, SCHEMA, FILES)) + .as_ref() + .map_err(Clone::clone) + } + + fn load(manifest: &str, schema: &str, files: &[(&str, &str)]) -> Result { + let manifest: Manifest = + serde_json::from_str(manifest).map_err(|e| format!("win32.manifest: {e}"))?; + if manifest.schema_version != 2 + || manifest.metadata.package != "Microsoft.Windows.SDK.Win32Metadata" + || manifest.metadata.version != "71.0.14-preview" + || manifest.metadata.sha256 != METADATA_SHA256 + || manifest.schema.file != "schema.json" + || manifest.schema.sha256 != text_sha256(schema) + || manifest.files.len() != FILES.len() + || files.len() != FILES.len() + { + return Err("win32.contract-integrity: schema or metadata pin mismatch".into()); + } + let mut seen = BTreeSet::new(); + for file in &manifest.files { + if !seen.insert(file.file.as_str()) || !valid_hash(&file.sha256) { + return Err("win32.contract-integrity: duplicate file or invalid digest".into()); + } + let Some((_, bytes)) = files.iter().find(|(name, _)| *name == file.file) else { + return Err("win32.contract-integrity: unknown data file".into()); + }; + if text_sha256(bytes) != file.sha256 { + return Err(format!("win32.contract-integrity: {}", file.file)); + } + } + let data = |name: &str| { + files + .iter() + .find(|(n, _)| *n == name) + .map(|(_, v)| *v) + .ok_or_else(|| format!("win32.contract-integrity: missing {name}")) + }; + let mut function_entries: Vec = group(data("function-contracts.json")?)?; + function_entries.extend(group::(data("subsystem-policies.json")?)?); + let mut type_entries: Vec = group(data("native-types.json")?)?; + type_entries.extend(group::(data("aggregate-layouts.json")?)?); + Self::validate( + function_entries, + type_entries, + group(data("policy-domains.json")?)?, + ) + } + + fn validate( + function_entries: Vec, + type_entries: Vec, + domains: Vec, + ) -> Result { + let mut ids = BTreeSet::new(); + let mut functions = BTreeMap::new(); + let mut types = BTreeMap::new(); + for entry in function_entries { + let selector = &entry.selector; + if !identifier(&entry.id) + || !ids.insert(entry.id.clone()) + || !citations(&entry.evidence) + || entry.contracts.is_empty() + || !native_namespace(&selector.namespace) + || !dll_name(&selector.dll) + || selector.entry_point.is_empty() + || selector.entry_point.contains('\0') + || !native_identifier(&selector.name) + || !native_identifier(&selector.container) + || !valid_hash(&selector.source_fingerprint) + || selector.architectures & !7 != 0 + || !matches!( + selector.calling_convention.as_str(), + "system" | "cdecl" | "unsupported" + ) + { + return Err(format!( + "win32.contract-evidence: invalid function {}", + entry.id + )); + } + let mut effects = BTreeSet::new(); + for effect in &entry.contracts { + if !effects.insert(effect.key()) { + return Err(format!("win32.contract-conflict: {}", entry.id)); + } + if let FunctionEffect::CallContract { contract } = effect { + contract + .validate_structure() + .map_err(|error| error.to_string())?; + } + if let FunctionEffect::ResultContract { contract } = effect { + CallContract::current(vec![contract.clone()], Vec::new()) + .validate_structure() + .map_err(|error| error.to_string())?; + } + if matches!( + effect, + FunctionEffect::CallContract { .. } | FunctionEffect::ResultContract { .. } + ) { + if entry + .contracts + .iter() + .any(|effect| matches!(effect, FunctionEffect::OverlappedIo { .. })) + { + return Err(format!( + "win32.contract-conflict: asynchronous adapter call rules {}", + entry.id + )); + } + } + let positions: Vec = match effect { + FunctionEffect::CountedBuffer { + parameter, + count_parameter, + .. + } => vec![*parameter, *count_parameter], + FunctionEffect::UnsupportedCountUnit { parameter } + | FunctionEffect::OwnedOutput { parameter, .. } + | FunctionEffect::ConsumedInput { parameter, .. } + | FunctionEffect::MutableString { parameter } => vec![*parameter], + FunctionEffect::OverlappedIo { + file_parameter, + buffer_parameter, + count_parameter, + transferred_parameter, + overlapped_parameter, + .. + } => vec![ + *file_parameter, + *buffer_parameter, + *count_parameter, + *transferred_parameter, + *overlapped_parameter, + ], + _ => Vec::new(), + }; + if positions.iter().any(|p| *p > 1023) + || positions.iter().copied().collect::>().len() != positions.len() + { + return Err(format!( + "win32.contract-conflict: parameter roles {}", + entry.id + )); + } + if matches!( + effect, + FunctionEffect::OwnedReturn { + cleanup: Cleanup::None + } | FunctionEffect::OwnedOutput { + cleanup: Cleanup::None, + .. + } | FunctionEffect::ConsumedInput { + cleanup: Cleanup::None, + .. + } + ) { + return Err(format!( + "win32.contract-evidence: missing cleanup {}", + entry.id + )); + } + } + let key = ( + selector.namespace.clone(), + selector.container.clone(), + selector.name.clone(), + ); + if functions.insert(key, entry).is_some() { + return Err("win32.contract-conflict: duplicate function selector".into()); + } + } + for entry in type_entries { + if !identifier(&entry.id) + || !ids.insert(entry.id.clone()) + || !citations(&entry.evidence) + || !native_namespace(&entry.selector.namespace) + || !valid_hash(&entry.selector.source_fingerprint) + || (!native_identifier(&entry.selector.name)) + || (entry.meaning.is_none() && entry.status.is_none() && entry.aggregate.is_none()) + { + return Err(format!( + "win32.contract-evidence: invalid type {}", + entry.id + )); + } + if let Some(aggregate) = &entry.aggregate { + if entry.meaning.is_some() + || entry.status.is_some() + || aggregate + .size_field + .as_deref() + .is_some_and(|s| !native_identifier(s)) + { + return Err(format!( + "win32.contract-conflict: aggregate meaning {}", + entry.id + )); + } + let mut fields = BTreeSet::new(); + for field in &aggregate.fields { + if !native_identifier(&field.name) + || !fields.insert(&field.name) + || matches!( + field.contract, + FieldContract::OwnedHandle { + cleanup: Cleanup::None + } + ) + { + return Err(format!( + "win32.contract-conflict: aggregate fields {}", + entry.id + )); + } + } + let mut names = BTreeSet::new(); + for recipe in &aggregate.anonymous_layouts { + validate_recipe(recipe, 0)?; + if !names.insert(&recipe.name) { + return Err(format!( + "win32.contract-conflict: duplicate layout {}", + entry.id + )); + } + } + } + if types + .insert( + ( + entry.selector.namespace.clone(), + entry.selector.name.clone(), + ), + entry, + ) + .is_some() + { + return Err("win32.contract-conflict: duplicate type selector".into()); + } + } + let mut seen = BTreeSet::new(); + for domain in &domains { + let key = match domain { + DomainPolicy::Subsystem { namespace, .. } if native_namespace(namespace) => { + format!("namespace:{namespace}") + } + DomainPolicy::ProviderLifecycle { dll } if dll_name(dll) => { + format!("dll:{}", dll.to_ascii_lowercase()) + } + _ => return Err("win32.contract-evidence: invalid policy domain".into()), + }; + if !seen.insert(key) { + return Err("win32.contract-conflict: duplicate policy domain".into()); + } + } + Ok(Self { + functions, + types, + domains, + }) + } + + pub fn type_entry(&self, namespace: &str, name: &str) -> Option<&TypeEntry> { + self.types.get(&(namespace.to_string(), name.to_string())) + } + + pub fn function_entry(&self, raw: &RawFunction) -> Option<&FunctionEntry> { + self.functions.get(&( + raw.namespace.clone(), + raw.container.clone(), + raw.name.clone(), + )) + } + + pub fn function_policy(&self, raw: &RawFunction) -> Result, String> { + if let Some(evidence) = &raw.evidence + && evidence.shape_fingerprint != crate::win32_metadata::function_shape_fingerprint(raw) + { + return Err("win32.signature-drift: raw facts changed after parsing".into()); + } + let entry = self.function_entry(raw); + if let Some(entry) = entry { + let proof = raw.evidence.as_ref().ok_or("win32.missing-raw-evidence")?; + if proof.metadata_sha256 != METADATA_SHA256 { + return Err("win32.metadata-hash-mismatch".into()); + } + if proof.selector != entry.selector { + return Err(format!("win32.signature-drift: {}", entry.id)); + } + use crate::win32_metadata::{RawBaseType, RawDirection, RawNamedKind}; + for effect in &entry.contracts { + let valid = match effect { + FunctionEffect::OwnedReturn { .. } | FunctionEffect::BorrowedReturn {} => { + raw.return_type.pointer_depth == 0 + && matches!( + raw.return_type.base, + RawBaseType::Named { + kind: RawNamedKind::Handle { .. }, + .. + } + ) + } + FunctionEffect::OwnedOutput { parameter, .. } => { + raw.parameters.get(*parameter).is_some_and(|p| { + p.direction == RawDirection::Out + && p.typ.pointer_depth == 1 + && matches!( + p.typ.base, + RawBaseType::Named { + kind: RawNamedKind::Handle { .. }, + .. + } + ) + }) + } + FunctionEffect::ConsumedInput { parameter, .. } => { + raw.parameters.get(*parameter).is_some_and(|p| { + p.direction == RawDirection::In + && p.typ.pointer_depth == 0 + && matches!( + p.typ.base, + RawBaseType::Named { + kind: RawNamedKind::Handle { .. }, + .. + } + ) + }) + } + FunctionEffect::MutableString { parameter } => { + raw.parameters.get(*parameter).is_some_and(|p| { + p.direction != RawDirection::Out + && p.typ.pointer_depth == 0 + && matches!( + p.typ.base, + RawBaseType::Named { + kind: RawNamedKind::StringPointer { .. }, + .. + } + ) + }) + } + FunctionEffect::CountedBuffer { + parameter, + count_parameter, + .. + } => { + *parameter < raw.parameters.len() && *count_parameter < raw.parameters.len() + } + FunctionEffect::UnsupportedCountUnit { parameter } => { + *parameter < raw.parameters.len() + } + FunctionEffect::CallContract { contract } => { + contract + .validate_structure() + .map_err(|error| error.to_string())?; + contract.outputs.iter().all(|rule| { + raw.parameters.get(rule.parameter).is_some_and(|parameter| { + parameter.direction != RawDirection::In + && parameter.typ.pointer_depth > 0 + && parameter.buffer.is_none() + }) + }) && contract + .results + .iter() + .all(|result| raw_result_target(self, raw, result.target)) + } + FunctionEffect::ResultContract { contract } => { + raw_result_target(self, raw, contract.target) + } + FunctionEffect::OverlappedIo { + file_parameter, + buffer_parameter, + count_parameter, + transferred_parameter, + overlapped_parameter, + .. + } => [ + file_parameter, + buffer_parameter, + count_parameter, + transferred_parameter, + overlapped_parameter, + ] + .into_iter() + .all(|p| *p < raw.parameters.len()), + FunctionEffect::Subsystem { .. } + | FunctionEffect::SubsystemExempt {} + | FunctionEffect::ManagedLifecycle { .. } => true, + }; + if !valid { + return Err(format!("win32.contract-shape-conflict: {}", entry.id)); + } + } + } else if self.functions.values().any(|entry| { + entry.selector.dll.eq_ignore_ascii_case(&raw.dll) + && entry.selector.entry_point == raw.entry_point + }) { + return Err( + "win32.signature-drift: known export has a different metadata identity".into(), + ); + } + + let mut subsystem = None; + for effect in entry.into_iter().flat_map(|entry| entry.contracts.iter()) { + match effect { + FunctionEffect::Subsystem { subsystem: value } => subsystem = Some(*value), + FunctionEffect::ManagedLifecycle { subsystem } => { + return Err(format!( + "{subsystem:?} lifecycle is managed by the generated initialization adapter" + )); + } + _ => {} + } + } + for domain in &self.domains { + match domain { + DomainPolicy::Subsystem { + namespace, + subsystem: required, + } if *namespace == raw.namespace => { + let exempt = entry.is_some_and(|entry| { + entry + .contracts + .iter() + .any(|e| matches!(e, FunctionEffect::SubsystemExempt {})) + }); + if !exempt && subsystem != Some(*required) { + return Err("win32.missing-subsystem-evidence".into()); + } + } + DomainPolicy::ProviderLifecycle { dll } if dll.eq_ignore_ascii_case(&raw.dll) => { + return Err( + "MAPI exports require a separately classified provider lifecycle contract" + .into(), + ); + } + DomainPolicy::Subsystem { .. } | DomainPolicy::ProviderLifecycle { .. } => {} + } + } + Ok(FunctionPolicy { entry, subsystem }) + } + + pub fn layout_contract<'a>( + &'a self, + raw: &crate::win32_metadata::RawNativeLayoutSet, + ) -> Result, String> { + let Some(proof) = &raw.evidence else { + return Ok(None); + }; + if proof.metadata_sha256 != METADATA_SHA256 + || proof.shape_fingerprint != crate::win32_metadata::layout_shape_fingerprint(raw) + { + return Err("win32.type-signature-drift: native layout facts changed".into()); + } + let entry = self + .type_entry(&proof.selector.namespace, &proof.selector.name) + .ok_or("win32.missing-type-evidence")?; + if entry.selector != proof.selector { + return Err("win32.type-signature-drift".into()); + } + Ok(entry.aggregate.as_ref()) + } +} + +#[cfg(test)] +#[path = "codegen/win32/contract_tests.rs"] +mod tests; diff --git a/tools/dynwinrt-codegen/src/win32_metadata.rs b/tools/dynwinrt-codegen/src/win32_metadata.rs new file mode 100644 index 00000000..6e04a6de --- /dev/null +++ b/tools/dynwinrt-codegen/src/win32_metadata.rs @@ -0,0 +1,1722 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +//! Raw metadata facts for flat Win32 `[DllImport]` exports. +//! +//! This module preserves native facts only. Language projection and ABI +//! support decisions belong to `codegen::win32`. + +use std::{ + cell::RefCell, + collections::{HashMap, HashSet}, + ops::Deref, + sync::Arc, +}; + +use serde::{Deserialize, Serialize}; +use windows_metadata::{AsRow, HasAttributes, reader}; + +use crate::win32_contracts::{ + self, Encoding, FunctionSelector, RecipeType, RecordKind, Registry, StatusMeaning, TypeEntry, + TypeMeaning, TypeSelector, +}; + +struct MetadataContext { + index: reader::Index, + hashes: Vec, + type_hashes: RefCell>, +} + +fn load_metadata_index( + paths: &str, + mut inspect_bytes: impl FnMut(&[u8]), +) -> Result { + let mut files = Vec::new(); + for path in paths.split(';').filter(|path| !path.is_empty()) { + let bytes = + std::fs::read(path).map_err(|error| format!("win32.metadata: {path}: {error}"))?; + inspect_bytes(&bytes); + files.push( + reader::File::new(bytes) + .ok_or_else(|| format!("win32.metadata: invalid file {path}"))?, + ); + } + if files.is_empty() { + return Err("win32.metadata: no files supplied".into()); + } + Ok(reader::Index::new(files)) +} + +/// A lazy, command-scoped index for native-domain routing. Presence queries do +/// not require provenance hashes or semantic contract projection. +pub struct FlatFunctionIndex<'a> { + paths: &'a str, + index: Option, +} + +impl<'a> FlatFunctionIndex<'a> { + pub fn new(paths: &'a str) -> Self { + Self { paths, index: None } + } + + pub fn has_flat_functions( + &mut self, + namespace: &str, + class_name: &str, + ) -> Result { + if self.index.is_none() { + self.index = Some(load_metadata_index(self.paths, |_| {})?); + } + Ok(self + .index + .as_ref() + .expect("loaded routing index") + .get(namespace, class_name) + .any(|definition| { + definition + .methods() + .any(|method| method.impl_map().is_some()) + })) + } +} + +impl Deref for MetadataContext { + type Target = reader::Index; + fn deref(&self) -> &Self::Target { + &self.index + } +} + +impl MetadataContext { + fn load(paths: &str) -> Result { + let mut hashes = Vec::new(); + let index = load_metadata_index(paths, |bytes| { + hashes.push(win32_contracts::sha256(bytes)); + })?; + Ok(Self { + index, + hashes, + type_hashes: RefCell::new(HashMap::new()), + }) + } + + fn type_entry( + &self, + namespace: &str, + name: &str, + ) -> Result, String> { + let Some(entry) = Registry::builtin()?.type_entry(namespace, name) else { + return Ok(None); + }; + let definitions = self.index.get(namespace, name).collect::>(); + if definitions.is_empty() + || definitions + .iter() + .any(|d| self.hashes[d.to_row().file] != win32_contracts::METADATA_SHA256) + { + return Err(format!("win32.metadata-hash-mismatch: {namespace}.{name}")); + } + let key = (namespace.to_string(), name.to_string()); + let cached = self.type_hashes.borrow().get(&key).cloned(); + let fingerprint = cached.unwrap_or_else(|| { + let value = win32_contracts::type_fingerprint(&self.index, namespace, name); + self.type_hashes.borrow_mut().insert(key, value.clone()); + value + }); + if fingerprint != entry.selector.source_fingerprint { + return Err(format!("win32.type-signature-drift: {namespace}.{name}")); + } + Ok(Some(entry)) + } +} + +/// Native provenance is produced by the parser, not application contract JSON. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawFunctionEvidence { + pub(crate) selector: FunctionSelector, + pub(crate) metadata_sha256: String, + pub(crate) shape_fingerprint: String, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawLayoutEvidence { + pub(crate) selector: TypeSelector, + pub(crate) metadata_sha256: String, + pub(crate) shape_fingerprint: String, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)] +#[serde(rename_all = "kebab-case")] +pub enum RawScalar { + Bool8, + I8, + U8, + I16, + U16, + I32, + U32, + I64, + U64, + F32, + F64, + Char16, + Bool32, + NativeIsize, + NativeUsize, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RawConstness { + Const, + Mutable, + Unspecified, + Mixed, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RawDirection { + In, + Out, + InOut, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RawStringEncoding { + Utf16, + Ansi, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RawCallingConvention { + System, + Cdecl, + Unsupported, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RawStatusSemantics { + None, + ZeroIsSuccess, + SignedNonNegativeIsSuccess, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub struct RawArchitectures { + pub x86: bool, + pub x64: bool, + pub arm64: bool, +} + +impl RawArchitectures { + fn all() -> Self { + Self { + x86: true, + x64: true, + arm64: true, + } + } +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawEnumMember { + pub name: String, + pub value: i128, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum RawNamedKind { + Enum { + underlying: RawScalar, + members: Vec, + is_flags: bool, + }, + Handle { + cleanup: Option, + }, + StringPointer { + encoding: RawStringEncoding, + }, + DataPointer, + FunctionPointer, + Guid, + ComInterface { + iid: String, + }, + NativeStruct { + layout: Box, + }, + Unknown, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RawLayoutKind { + Sequential, + Union, + Unknown, +} + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RawPacking { + Default, + Explicit(u16), +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawNativeField { + pub name: String, + pub typ: RawType, + pub fixed_count: Option, + pub bitfield: bool, + pub flexible_array: bool, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawNativeLayout { + pub architectures: RawArchitectures, + pub kind: RawLayoutKind, + pub packing: RawPacking, + pub declared_size: Option, + pub forced_alignment: Option, + pub fields: Vec, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawNativeLayoutSet { + pub recursive: bool, + pub variants: Vec, + pub evidence: Option>, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum RawBaseType { + Void, + Scalar(RawScalar), + Named { + namespace: String, + name: String, + kind: RawNamedKind, + }, + Unknown(String), +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawType { + pub base: RawBaseType, + pub pointer_depth: u8, + pub constness: RawConstness, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum RawBufferSize { + ElementCountParam(usize), + ByteCountParam(usize), + Constant(usize), + Unknown, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawBuffer { + pub element: RawType, + pub size: RawBufferSize, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawParameter { + pub name: String, + pub typ: RawType, + pub direction: RawDirection, + pub nullable: bool, + pub reserved: bool, + pub null_null_terminated: bool, + pub buffer: Option, + pub free_with: Option, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawFunction { + pub namespace: String, + pub container: String, + pub name: String, + pub dll: String, + pub entry_point: String, + pub return_type: RawType, + pub parameters: Vec, + pub return_status: RawStatusSemantics, + pub return_free_with: Option, + pub supports_last_error: bool, + pub calling_convention: RawCallingConvention, + pub architectures: RawArchitectures, + pub variadic: bool, + pub evidence: Option>, +} + +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct RawApis { + pub namespace: String, + pub class_name: String, + pub functions: Vec, +} + +pub fn has_flat_functions( + winmd_paths: &str, + namespace: &str, + class_name: &str, +) -> Result { + FlatFunctionIndex::new(winmd_paths).has_flat_functions(namespace, class_name) +} + +pub fn parse_apis(winmd_paths: &str, namespace: &str, class_name: &str) -> Option { + let index = MetadataContext::load(winmd_paths).ok()?; + let definition = index.get(namespace, class_name).next()?; + let functions = definition + .methods() + .filter_map(|method| parse_function(&index, namespace, class_name, &method)) + .collect::>(); + (!functions.is_empty()).then(|| RawApis { + namespace: namespace.to_string(), + class_name: class_name.to_string(), + functions, + }) +} + +pub fn parse_all_functions(winmd_paths: &str) -> Option> { + let index = MetadataContext::load(winmd_paths).ok()?; + let mut functions = Vec::new(); + for definition in index.all() { + let namespace = definition.namespace().to_string(); + let container = definition.name().to_string(); + functions.extend( + definition + .methods() + .filter_map(|method| parse_function(&index, &namespace, &container, &method)), + ); + } + Some(functions) +} + +fn parse_function( + index: &MetadataContext, + namespace: &str, + container: &str, + method: &reader::MethodDef, +) -> Option { + let import = method.impl_map()?; + if matches!(method.name(), ".ctor" | ".cctor") { + return None; + } + // ECMA-335 MethodDef.Flags is column 2; Static is 0x0010. + if method.usize(2) & 0x0010 == 0 { + return Some(invalid_function( + namespace, + container, + method.name(), + import.import_scope().name(), + import.import_name(), + "instance DLL imports have no flat-call ABI", + )); + } + let signature = method.signature(&[]); + let (return_definition, definitions) = match params_by_sequence(method, signature.types.len()) { + Ok(definitions) => definitions, + Err(reason) => { + return Some(invalid_function( + namespace, + container, + method.name(), + import.import_scope().name(), + import.import_name(), + &reason, + )); + } + }; + + let return_type = map_type(index, &signature.return_type); + let mut parameters = Vec::with_capacity(definitions.len()); + for (position, (definition, typ)) in definitions.iter().zip(&signature.types).enumerate() { + let mut mapped = map_type(index, typ); + if definition + .as_ref() + .is_some_and(|d| d.has_attribute("ConstAttribute")) + { + mapped.constness = RawConstness::Const; + } + let (name, direction, nullable, reserved, null_null_terminated, buffer, free_with) = + match definition { + Some(definition) => { + let flags = definition.flags(); + ( + definition.name().to_string(), + param_direction(flags), + flags.contains(windows_metadata::ParamAttributes::Optional) + || definition.has_attribute("OptionalAttribute"), + definition.has_attribute("ReservedAttribute"), + definition.has_attribute("NullNullTerminatedAttribute"), + buffer_size(definition).map(|size| RawBuffer { + element: buffer_element(&mapped), + size, + }), + free_with(definition), + ) + } + None => ( + format!("arg{position}"), + RawDirection::In, + false, + false, + false, + None, + None, + ), + }; + parameters.push(RawParameter { + name, + typ: mapped, + direction, + nullable, + reserved, + null_null_terminated, + buffer, + free_with, + }); + } + let flags = import.flags(); + let mut function = RawFunction { + namespace: namespace.to_string(), + container: container.to_string(), + name: method.name().to_string(), + dll: import.import_scope().name().to_string(), + entry_point: import.import_name().to_string(), + return_status: status_semantics(index, &signature.return_type), + return_free_with: return_definition.as_ref().and_then(free_with), + return_type, + parameters, + supports_last_error: flags.contains(windows_metadata::PInvokeAttributes::SupportsLastError), + calling_convention: calling_convention(method), + architectures: architectures(method), + variadic: signature + .flags + .contains(windows_metadata::MethodCallAttributes::VARARG), + evidence: None, + }; + let a = function.architectures; + function.evidence = Some(Arc::new(RawFunctionEvidence { + selector: FunctionSelector { + namespace: namespace.into(), + container: container.into(), + name: function.name.clone(), + dll: function.dll.clone(), + entry_point: function.entry_point.clone(), + calling_convention: format!("{:?}", function.calling_convention).to_ascii_lowercase(), + architectures: u8::from(a.x86) | (u8::from(a.x64) << 1) | (u8::from(a.arm64) << 2), + source_fingerprint: win32_contracts::method_fingerprint(namespace, container, method), + }, + metadata_sha256: index.hashes[method.to_row().file].clone(), + shape_fingerprint: function_shape_fingerprint(&function), + })); + Some(function) +} + +pub(crate) fn function_shape_fingerprint(function: &RawFunction) -> String { + let mut raw = function.clone(); + raw.evidence = None; + win32_contracts::sha256(format!("{raw:?}").as_bytes()) +} + +pub(crate) fn layout_shape_fingerprint(layout: &RawNativeLayoutSet) -> String { + win32_contracts::sha256(format!("{:?}", (layout.recursive, &layout.variants)).as_bytes()) +} + +fn invalid_function( + namespace: &str, + container: &str, + name: &str, + dll: &str, + entry_point: &str, + reason: &str, +) -> RawFunction { + RawFunction { + namespace: namespace.to_string(), + container: container.to_string(), + name: name.to_string(), + dll: dll.to_string(), + entry_point: entry_point.to_string(), + return_type: RawType { + base: RawBaseType::Unknown(reason.to_string()), + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + parameters: Vec::new(), + return_status: RawStatusSemantics::None, + return_free_with: None, + supports_last_error: false, + calling_convention: RawCallingConvention::Unsupported, + architectures: RawArchitectures { + x86: false, + x64: false, + arm64: false, + }, + variadic: false, + evidence: None, + } +} + +fn params_by_sequence<'a>( + method: &'a reader::MethodDef<'a>, + parameter_count: usize, +) -> Result< + ( + Option>, + Vec>>, + ), + String, +> { + let mut parameters = vec![None; parameter_count]; + let mut return_parameter = None; + for parameter in method.params() { + let sequence = parameter.sequence(); + if sequence == 0 { + if return_parameter.replace(parameter).is_some() { + return Err("duplicate return parameter sequence 0".into()); + } + continue; + } + let position = sequence as usize - 1; + let Some(slot) = parameters.get_mut(position) else { + return Err(format!( + "parameter sequence {sequence} exceeds signature arity {parameter_count}" + )); + }; + if slot.replace(parameter).is_some() { + return Err(format!("duplicate parameter sequence {sequence}")); + } + } + Ok((return_parameter, parameters)) +} + +fn param_direction(flags: windows_metadata::ParamAttributes) -> RawDirection { + match ( + flags.contains(windows_metadata::ParamAttributes::In), + flags.contains(windows_metadata::ParamAttributes::Out), + ) { + (true, true) => RawDirection::InOut, + (_, true) => RawDirection::Out, + _ => RawDirection::In, + } +} + +fn map_type(index: &MetadataContext, typ: &windows_metadata::Type) -> RawType { + use windows_metadata::Type; + + match typ { + Type::Void => raw_base(RawBaseType::Void), + Type::Bool => raw_scalar(RawScalar::Bool8), + Type::Char => raw_scalar(RawScalar::Char16), + Type::I8 => raw_scalar(RawScalar::I8), + Type::U8 => raw_scalar(RawScalar::U8), + Type::I16 => raw_scalar(RawScalar::I16), + Type::U16 => raw_scalar(RawScalar::U16), + Type::I32 => raw_scalar(RawScalar::I32), + Type::U32 => raw_scalar(RawScalar::U32), + Type::I64 => raw_scalar(RawScalar::I64), + Type::U64 => raw_scalar(RawScalar::U64), + Type::F32 => raw_scalar(RawScalar::F32), + Type::F64 => raw_scalar(RawScalar::F64), + Type::ISize => raw_scalar(RawScalar::NativeIsize), + Type::USize => raw_scalar(RawScalar::NativeUsize), + Type::PtrMut(inner, depth) => map_pointer(index, inner, *depth, RawConstness::Mutable), + Type::PtrConst(inner, depth) => map_pointer(index, inner, *depth, RawConstness::Const), + Type::Name(name) => map_named(index, &name.namespace, &name.name, &mut Vec::new()), + other => RawType { + base: RawBaseType::Unknown(format!("{other:?}")), + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + } +} + +fn raw_base(base: RawBaseType) -> RawType { + RawType { + base, + pointer_depth: 0, + constness: RawConstness::Unspecified, + } +} + +fn raw_scalar(scalar: RawScalar) -> RawType { + raw_base(RawBaseType::Scalar(scalar)) +} + +fn map_pointer( + index: &MetadataContext, + inner: &windows_metadata::Type, + depth: usize, + outer_constness: RawConstness, +) -> RawType { + let mut mapped = map_type(index, inner); + let Ok(depth) = u8::try_from(depth) else { + mapped.base = RawBaseType::Unknown("pointer depth exceeds u8".into()); + return mapped; + }; + mapped.pointer_depth = match mapped.pointer_depth.checked_add(depth) { + Some(depth) => depth, + None => { + mapped.base = RawBaseType::Unknown("pointer depth overflow".into()); + return mapped; + } + }; + mapped.constness = match (mapped.constness, outer_constness) { + (RawConstness::Unspecified, value) => value, + (value, RawConstness::Unspecified) => value, + (left, right) if left == right => left, + _ => RawConstness::Mixed, + }; + mapped +} + +fn map_named( + index: &MetadataContext, + namespace: &str, + name: &str, + layout_stack: &mut Vec<(String, String)>, +) -> RawType { + if (namespace == "System" && name == "Guid") + || (namespace == "Windows.Win32.Foundation" && name == "GUID") + { + return named(namespace, name, RawNamedKind::Guid); + } + let entry = match index.type_entry(namespace, name) { + Ok(entry) => entry, + Err(reason) => return raw_base(RawBaseType::Unknown(reason)), + }; + if let Some(meaning) = entry.and_then(|entry| entry.meaning.as_ref()) { + let value = index.get(namespace, name).next().and_then(|d| { + d.fields() + .find(|field| field.name() == "Value") + .map(|field| field.ty()) + }); + match meaning { + TypeMeaning::Scalar { scalar } => { + let Some(value) = value else { + return raw_base(RawBaseType::Unknown( + "scalar contract requires an underlying Value field".into(), + )); + }; + let underlying = map_type(index, &value); + let expected = if *scalar == RawScalar::Bool32 { + RawScalar::I32 + } else { + *scalar + }; + if underlying.pointer_depth != 0 || underlying.base != RawBaseType::Scalar(expected) + { + return raw_base(RawBaseType::Unknown( + "scalar contract conflicts with native underlying ABI".into(), + )); + } + return raw_scalar(*scalar); + } + TypeMeaning::Handle {} => { + return named( + namespace, + name, + RawNamedKind::Handle { + cleanup: handle_cleanup(index, namespace, name), + }, + ); + } + TypeMeaning::DataPointer {} => { + return named(namespace, name, RawNamedKind::DataPointer); + } + TypeMeaning::StringPointer { encoding, is_const } => { + let expected = match encoding { + Encoding::Utf16 => windows_metadata::Type::Char, + Encoding::Ansi => windows_metadata::Type::U8, + }; + if !matches!(&value, Some(windows_metadata::Type::PtrMut(inner,1)) if **inner == expected) + { + return raw_base(RawBaseType::Unknown( + "string contract conflicts with native underlying ABI".into(), + )); + } + return named_string( + namespace, + name, + match encoding { + Encoding::Utf16 => RawStringEncoding::Utf16, + Encoding::Ansi => RawStringEncoding::Ansi, + }, + *is_const, + ); + } + TypeMeaning::FunctionPointer {} => { + return named(namespace, name, RawNamedKind::FunctionPointer); + } + TypeMeaning::Unsupported {} => return named(namespace, name, RawNamedKind::Unknown), + } + } + + let Some(definition) = index.get(namespace, name).next() else { + return named(namespace, name, RawNamedKind::Unknown); + }; + let iid = crate::meta::extract_iid(&definition); + if definition.extends().is_none() && !iid.is_empty() { + return named(namespace, name, RawNamedKind::ComInterface { iid }); + } + let Some(extends) = definition.extends() else { + return named(namespace, name, RawNamedKind::Unknown); + }; + if extends.namespace() == "System" && extends.name() == "Enum" { + let (underlying, members) = parse_enum(&definition); + return named( + namespace, + name, + RawNamedKind::Enum { + underlying, + members, + is_flags: definition.has_attribute("FlagsAttribute"), + }, + ); + } + if extends.namespace() == "System" && matches!(extends.name(), "Delegate" | "MulticastDelegate") + { + return named(namespace, name, RawNamedKind::FunctionPointer); + } + if extends.namespace() == "System" && extends.name() == "ValueType" { + if definition.has_attribute("NativeTypedefAttribute") { + let fields = definition.fields().collect::>(); + if fields.len() == 1 && fields[0].name() == "Value" { + return map_transparent_typedef(index, namespace, name, &fields[0].ty()); + } + } + return named( + namespace, + name, + RawNamedKind::NativeStruct { + layout: Box::new(parse_native_layouts(index, namespace, name, layout_stack)), + }, + ); + } + + fn parse_native_layouts( + index: &MetadataContext, + namespace: &str, + name: &str, + layout_stack: &mut Vec<(String, String)>, + ) -> RawNativeLayoutSet { + let key = (namespace.to_string(), name.to_string()); + if layout_stack.contains(&key) { + return RawNativeLayoutSet { + recursive: true, + variants: Vec::new(), + evidence: None, + }; + } + layout_stack.push(key); + let variants = index + .get(namespace, name) + .filter(|definition| { + definition + .extends() + .is_some_and(|base| base.namespace() == "System" && base.name() == "ValueType") + }) + .map(|definition| { + let flags = definition.flags(); + let kind = if flags.contains(windows_metadata::TypeAttributes::SequentialLayout) { + RawLayoutKind::Sequential + } else if flags.contains(windows_metadata::TypeAttributes::ExplicitLayout) { + RawLayoutKind::Union + } else { + RawLayoutKind::Unknown + }; + let (packing, declared_size) = + definition + .class_layout() + .map_or((RawPacking::Default, None), |layout| { + ( + if layout.packing_size() == 0 { + RawPacking::Default + } else { + RawPacking::Explicit(layout.packing_size()) + }, + (layout.class_size() != 0).then_some(layout.class_size() as usize), + ) + }); + let fields = definition + .fields() + .filter(|field| field.name() != "value__" && field.constant().is_none()) + .map(|field| { + let field_type = field.ty(); + let (typ, fixed_count) = match field_type { + windows_metadata::Type::ArrayFixed(ref element, count) => ( + map_layout_field_type( + index, + element, + Some(definition), + layout_stack, + ), + Some(count), + ), + _ => ( + map_layout_field_type( + index, + &field_type, + Some(definition), + layout_stack, + ), + None, + ), + }; + RawNativeField { + name: field.name().to_string(), + typ, + fixed_count, + bitfield: field.has_attribute("NativeBitfieldAttribute"), + flexible_array: field.has_attribute("FlexibleArrayAttribute"), + } + }) + .collect(); + RawNativeLayout { + architectures: architectures(&definition), + kind, + packing, + declared_size, + forced_alignment: definition.find_attribute("AlignmentAttribute").and_then( + |attribute| match attribute.value().first() { + Some((_, windows_metadata::Value::I32(value))) if *value > 0 => { + Some(*value as usize) + } + _ => None, + }, + ), + fields, + } + }) + .collect(); + layout_stack.pop(); + let mut result = RawNativeLayoutSet { + recursive: false, + variants, + evidence: None, + }; + if let Ok(Some(entry)) = index.type_entry(namespace, name) + && entry.aggregate.is_some() + { + result.evidence = Some(Arc::new(RawLayoutEvidence { + selector: entry.selector.clone(), + metadata_sha256: win32_contracts::METADATA_SHA256.into(), + shape_fingerprint: layout_shape_fingerprint(&result), + })); + } + result + } + + fn map_layout_field_type<'a>( + index: &'a MetadataContext, + typ: &windows_metadata::Type, + enclosing: Option>, + layout_stack: &mut Vec<(String, String)>, + ) -> RawType { + match typ { + windows_metadata::Type::Name(name) => { + if let Some(enclosing) = enclosing + && let Some(nested) = index + .nested(enclosing) + .find(|nested| nested.name() == name.name) + { + return map_nested_layout(index, enclosing, nested, layout_stack); + } + if let Some(enclosing) = enclosing + && let Some(known) = + contract_anonymous_layout(index, enclosing, &name.name, layout_stack) + { + return known; + } + map_named(index, &name.namespace, &name.name, layout_stack) + } + windows_metadata::Type::PtrMut(inner, depth) => { + let mut mapped = map_layout_field_type(index, inner, enclosing, layout_stack); + mapped.pointer_depth = mapped + .pointer_depth + .saturating_add(u8::try_from(*depth).unwrap_or(u8::MAX)); + mapped.constness = RawConstness::Mutable; + mapped + } + windows_metadata::Type::PtrConst(inner, depth) => { + let mut mapped = map_layout_field_type(index, inner, enclosing, layout_stack); + mapped.pointer_depth = mapped + .pointer_depth + .saturating_add(u8::try_from(*depth).unwrap_or(u8::MAX)); + mapped.constness = RawConstness::Const; + mapped + } + windows_metadata::Type::Void => raw_base(RawBaseType::Void), + windows_metadata::Type::Bool => raw_scalar(RawScalar::Bool8), + windows_metadata::Type::Char => raw_scalar(RawScalar::Char16), + windows_metadata::Type::I8 => raw_scalar(RawScalar::I8), + windows_metadata::Type::U8 => raw_scalar(RawScalar::U8), + windows_metadata::Type::I16 => raw_scalar(RawScalar::I16), + windows_metadata::Type::U16 => raw_scalar(RawScalar::U16), + windows_metadata::Type::I32 => raw_scalar(RawScalar::I32), + windows_metadata::Type::U32 => raw_scalar(RawScalar::U32), + windows_metadata::Type::I64 => raw_scalar(RawScalar::I64), + windows_metadata::Type::U64 => raw_scalar(RawScalar::U64), + windows_metadata::Type::F32 => raw_scalar(RawScalar::F32), + windows_metadata::Type::F64 => raw_scalar(RawScalar::F64), + windows_metadata::Type::ISize => raw_scalar(RawScalar::NativeIsize), + windows_metadata::Type::USize => raw_scalar(RawScalar::NativeUsize), + other => RawType { + base: RawBaseType::Unknown(format!("{other:?}")), + pointer_depth: 0, + constness: RawConstness::Unspecified, + }, + } + } + + fn contract_anonymous_layout( + index: &MetadataContext, + enclosing: reader::TypeDef, + name: &str, + layout_stack: &mut Vec<(String, String)>, + ) -> Option { + let namespace = enclosing.namespace(); + let entry = index + .type_entry(namespace, enclosing.name()) + .ok() + .flatten()?; + let recipe = entry + .aggregate + .as_ref()? + .anonymous_layouts + .iter() + .find(|r| r.name == name)?; + Some(map_recipe( + index, + namespace, + enclosing.name(), + architectures(&enclosing), + recipe, + layout_stack, + )) + } + + fn map_recipe( + index: &MetadataContext, + namespace: &str, + owner: &str, + architectures: RawArchitectures, + recipe: &win32_contracts::LayoutRecipe, + layout_stack: &mut Vec<(String, String)>, + ) -> RawType { + let identity = format!("{owner}+{}", recipe.name); + let fields = recipe + .fields + .iter() + .map(|field| RawNativeField { + name: field.name.clone(), + typ: match &field.typ { + RecipeType::Scalar { scalar } => raw_scalar(*scalar), + RecipeType::Named { namespace, name } => { + map_named(index, namespace, name, layout_stack) + } + RecipeType::Record { layout } => map_recipe( + index, + namespace, + &identity, + architectures, + layout, + layout_stack, + ), + }, + fixed_count: None, + bitfield: false, + flexible_array: false, + }) + .collect(); + named( + namespace, + &identity, + RawNamedKind::NativeStruct { + layout: Box::new(RawNativeLayoutSet { + recursive: false, + evidence: None, + variants: vec![RawNativeLayout { + architectures, + kind: match recipe.kind { + RecordKind::Struct => RawLayoutKind::Sequential, + RecordKind::Union => RawLayoutKind::Union, + }, + packing: RawPacking::Default, + declared_size: None, + forced_alignment: None, + fields, + }], + }), + }, + ) + } + + fn map_nested_layout<'a>( + index: &'a MetadataContext, + enclosing: reader::TypeDef<'a>, + nested: reader::TypeDef<'a>, + layout_stack: &mut Vec<(String, String)>, + ) -> RawType { + let namespace = enclosing.namespace(); + let identity = format!("{}+{}", enclosing.name(), nested.name()); + let key = (namespace.to_string(), identity.clone()); + if layout_stack.contains(&key) { + return named( + namespace, + &identity, + RawNamedKind::NativeStruct { + layout: Box::new(RawNativeLayoutSet { + recursive: true, + variants: Vec::new(), + evidence: None, + }), + }, + ); + } + layout_stack.push(key); + let flags = nested.flags(); + let kind = if flags.contains(windows_metadata::TypeAttributes::SequentialLayout) { + RawLayoutKind::Sequential + } else if flags.contains(windows_metadata::TypeAttributes::ExplicitLayout) { + RawLayoutKind::Union + } else { + RawLayoutKind::Unknown + }; + let (packing, declared_size) = + nested + .class_layout() + .map_or((RawPacking::Default, None), |layout| { + ( + if layout.packing_size() == 0 { + RawPacking::Default + } else { + RawPacking::Explicit(layout.packing_size()) + }, + (layout.class_size() != 0).then_some(layout.class_size() as usize), + ) + }); + let fields = nested + .fields() + .filter(|field| field.name() != "value__" && field.constant().is_none()) + .map(|field| { + let field_type = field.ty(); + let (typ, fixed_count) = match field_type { + windows_metadata::Type::ArrayFixed(ref element, count) => ( + map_layout_field_type(index, element, Some(nested), layout_stack), + Some(count), + ), + _ => ( + map_layout_field_type(index, &field_type, Some(nested), layout_stack), + None, + ), + }; + RawNativeField { + name: field.name().to_string(), + typ, + fixed_count, + bitfield: field.has_attribute("NativeBitfieldAttribute"), + flexible_array: field.has_attribute("FlexibleArrayAttribute"), + } + }) + .collect(); + let layout = RawNativeLayout { + architectures: architectures(&nested), + kind, + packing, + declared_size, + forced_alignment: nested + .find_attribute("AlignmentAttribute") + .and_then(|attribute| match attribute.value().first() { + Some((_, windows_metadata::Value::I32(value))) if *value > 0 => { + Some(*value as usize) + } + _ => None, + }), + fields, + }; + layout_stack.pop(); + named( + namespace, + &identity, + RawNamedKind::NativeStruct { + layout: Box::new(RawNativeLayoutSet { + recursive: false, + variants: vec![layout], + evidence: None, + }), + }, + ) + } + named(namespace, name, RawNamedKind::Unknown) +} + +fn map_transparent_typedef( + index: &MetadataContext, + namespace: &str, + name: &str, + typ: &windows_metadata::Type, +) -> RawType { + let mapped = map_type(index, typ); + match mapped.base { + RawBaseType::Scalar(scalar) if mapped.pointer_depth == 0 => raw_scalar(scalar), + RawBaseType::Named { + kind: RawNamedKind::StringPointer { encoding }, + .. + } => { + let mut value = named(namespace, name, RawNamedKind::StringPointer { encoding }); + value.constness = mapped.constness; + value + } + _ => named(namespace, name, RawNamedKind::Unknown), + } +} + +fn named(namespace: &str, name: &str, kind: RawNamedKind) -> RawType { + RawType { + base: RawBaseType::Named { + namespace: namespace.to_string(), + name: name.to_string(), + kind, + }, + pointer_depth: 0, + constness: RawConstness::Unspecified, + } +} + +fn named_string( + namespace: &str, + name: &str, + encoding: RawStringEncoding, + is_const: bool, +) -> RawType { + let mut value = named(namespace, name, RawNamedKind::StringPointer { encoding }); + value.constness = if is_const { + RawConstness::Const + } else { + RawConstness::Mutable + }; + value +} + +fn parse_enum(definition: &reader::TypeDef) -> (RawScalar, Vec) { + let mut underlying = RawScalar::I32; + let mut members = Vec::new(); + for field in definition.fields() { + if field.name() == "value__" { + underlying = match field.ty() { + windows_metadata::Type::I8 => RawScalar::I8, + windows_metadata::Type::U8 => RawScalar::U8, + windows_metadata::Type::I16 => RawScalar::I16, + windows_metadata::Type::U16 => RawScalar::U16, + windows_metadata::Type::I32 => RawScalar::I32, + windows_metadata::Type::U32 => RawScalar::U32, + windows_metadata::Type::I64 => RawScalar::I64, + windows_metadata::Type::U64 => RawScalar::U64, + _ => RawScalar::I32, + }; + continue; + } + let Some(constant) = field.constant() else { + continue; + }; + let value = match constant.value() { + windows_metadata::Value::I8(value) => value as i128, + windows_metadata::Value::U8(value) => value as i128, + windows_metadata::Value::I16(value) => value as i128, + windows_metadata::Value::U16(value) => value as i128, + windows_metadata::Value::I32(value) => value as i128, + windows_metadata::Value::U32(value) => value as i128, + windows_metadata::Value::I64(value) => value as i128, + windows_metadata::Value::U64(value) => value as i128, + _ => continue, + }; + members.push(RawEnumMember { + name: field.name().to_string(), + value, + }); + } + (underlying, members) +} + +pub(crate) fn buffer_element(typ: &RawType) -> RawType { + let mut element = typ.clone(); + if element.pointer_depth > 0 { + element.pointer_depth -= 1; + } else if matches!( + element.base, + RawBaseType::Named { + kind: RawNamedKind::DataPointer | RawNamedKind::StringPointer { .. }, + .. + } + ) { + element.base = match &element.base { + RawBaseType::Named { + kind: + RawNamedKind::StringPointer { + encoding: RawStringEncoding::Utf16, + }, + .. + } => RawBaseType::Scalar(RawScalar::Char16), + _ => RawBaseType::Scalar(RawScalar::U8), + }; + } + element +} + +fn buffer_size(parameter: &reader::MethodParam) -> Option { + if let Some(attribute) = parameter.find_attribute("NativeArrayInfoAttribute") { + let values = attribute.value(); + if let Some(index) = attribute_usize(&values, "CountParamIndex") { + return Some(RawBufferSize::ElementCountParam(index)); + } + if let Some(count) = attribute_usize(&values, "CountConst") { + return Some(RawBufferSize::Constant(count)); + } + return Some(RawBufferSize::Unknown); + } + if let Some(attribute) = parameter.find_attribute("MemorySizeAttribute") { + return Some( + attribute_usize(&attribute.value(), "BytesParamIndex") + .map(RawBufferSize::ByteCountParam) + .unwrap_or(RawBufferSize::Unknown), + ); + } + None +} + +fn attribute_usize(values: &[(String, windows_metadata::Value)], name: &str) -> Option { + values + .iter() + .find(|(candidate, _)| candidate == name) + .and_then(|(_, value)| match value { + windows_metadata::Value::I16(value) if *value >= 0 => Some(*value as usize), + windows_metadata::Value::U16(value) => Some(*value as usize), + windows_metadata::Value::I32(value) if *value >= 0 => Some(*value as usize), + windows_metadata::Value::U32(value) => usize::try_from(*value).ok(), + _ => None, + }) +} + +fn free_with(parameter: &reader::MethodParam) -> Option { + parameter + .find_attribute("FreeWithAttribute") + .and_then(|attribute| first_attribute_string(&attribute.value())) +} + +fn handle_cleanup(index: &MetadataContext, namespace: &str, name: &str) -> Option { + index + .get(namespace, name) + .next() + .and_then(|definition| definition.find_attribute("RAIIFreeAttribute")) + .and_then(|attribute| first_attribute_string(&attribute.value())) +} + +fn first_attribute_string(values: &[(String, windows_metadata::Value)]) -> Option { + values.iter().find_map(|(_, value)| match value { + windows_metadata::Value::Utf8(value) | windows_metadata::Value::Utf16(value) => { + Some(value.to_string()) + } + _ => None, + }) +} + +fn architectures<'a, T: HasAttributes<'a>>(item: &T) -> RawArchitectures { + let Some(attribute) = item.find_attribute("SupportedArchitectureAttribute") else { + return RawArchitectures::all(); + }; + let Some(bits) = attribute + .value() + .first() + .and_then(|(_, value)| match value { + windows_metadata::Value::I32(value) => Some(*value as u32), + windows_metadata::Value::U32(value) => Some(*value), + windows_metadata::Value::AttributeEnum(_, value) => Some(*value as u32), + _ => None, + }) + else { + return RawArchitectures { + x86: false, + x64: false, + arm64: false, + }; + }; + RawArchitectures { + x86: bits == 0 || bits & 0x1 != 0, + x64: bits == 0 || bits & 0x2 != 0, + arm64: bits == 0 || bits & 0x4 != 0, + } +} + +fn calling_convention(method: &reader::MethodDef) -> RawCallingConvention { + let Some(flags) = method.impl_map().map(|mapping| mapping.flags()) else { + return RawCallingConvention::Unsupported; + }; + let Some(bits) = parse_pinvoke_attribute_bits(&format!("{flags:?}")) else { + return RawCallingConvention::Unsupported; + }; + calling_convention_bits(bits) +} + +fn parse_pinvoke_attribute_bits(value: &str) -> Option { + value + .strip_prefix("PInvokeAttributes(")? + .strip_suffix(')')? + .parse() + .ok() +} + +fn calling_convention_bits(bits: u16) -> RawCallingConvention { + match bits & 0x0700 { + 0x0100 => RawCallingConvention::System, + 0x0200 => RawCallingConvention::Cdecl, + _ => RawCallingConvention::Unsupported, + } +} + +fn status_semantics(index: &MetadataContext, raw: &windows_metadata::Type) -> RawStatusSemantics { + if let windows_metadata::Type::Name(name) = raw { + if let Ok(Some(entry)) = index.type_entry(&name.namespace, &name.name) { + return match entry.status { + Some(StatusMeaning::Zero) => RawStatusSemantics::ZeroIsSuccess, + Some(StatusMeaning::SignedNonnegative) => { + RawStatusSemantics::SignedNonNegativeIsSuccess + } + None => RawStatusSemantics::None, + }; + } + } + RawStatusSemantics::None +} + +pub fn distinct_containers(functions: &[RawFunction]) -> usize { + functions + .iter() + .map(|function| (&function.namespace, &function.container)) + .collect::>() + .len() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + #[ignore = "Writes a local review artifact from the independently pinned official metadata"] + fn export_contract_review_facts() { + use crate::win32_contracts::{ + FunctionSelector, METADATA_SHA256, TypeSelector, method_fingerprint, sha256, + type_fingerprint, + }; + let path = std::env::var("DYNWINRT_WIN32_WINMD").unwrap(); + let bytes = std::fs::read(path).unwrap(); + assert_eq!(sha256(&bytes), METADATA_SHA256); + let index = reader::Index::new(vec![reader::File::new(bytes).unwrap()]); + let docs = |definition: &reader::TypeDef| { + definition + .find_attribute("DocumentationAttribute") + .and_then(|attribute| first_attribute_string(&attribute.value())) + }; + let mut functions = Vec::new(); + let mut types = Vec::new(); + let mut seen = HashSet::new(); + for definition in index.all() { + for method in definition.methods() { + let Some(import) = method.impl_map() else { + continue; + }; + let architecture = architectures(&method); + let signature = method.signature(&[]); + functions.push(serde_json::json!({ + "selector": FunctionSelector { + namespace: definition.namespace().into(), container: definition.name().into(), + name: method.name().into(), dll: import.import_scope().name().into(), entry_point: import.import_name().into(), + calling_convention: format!("{:?}", calling_convention(&method)).to_ascii_lowercase(), + architectures: u8::from(architecture.x86) | (u8::from(architecture.x64) << 1) | (u8::from(architecture.arm64) << 2), + source_fingerprint: method_fingerprint(definition.namespace(), definition.name(), &method), + }, + "parameters": method.params().filter(|p| p.sequence() != 0) + .map(|p| serde_json::json!({"name":p.name(), "index":p.sequence()-1, "flags":format!("{:?}",p.flags())})) + .collect::>(), + "types": signature.types.iter().map(|t|format!("{t:?}")).collect::>(), + "returnType": format!("{:?}",signature.return_type), + "docs": method.find_attribute("DocumentationAttribute").and_then(|a|first_attribute_string(&a.value())), + })); + } + if seen.insert(( + definition.namespace().to_string(), + definition.name().to_string(), + )) { + types.push(serde_json::json!({ + "selector": TypeSelector { namespace:definition.namespace().into(), name:definition.name().into(), + source_fingerprint:type_fingerprint(&index,definition.namespace(),definition.name()) }, + "extends": definition.extends().map(|base|format!("{}.{}",base.namespace(),base.name())), + "nativeTypedef": definition.has_attribute("NativeTypedefAttribute"), + "cleanup": definition.find_attribute("RAIIFreeAttribute").and_then(|a|first_attribute_string(&a.value())), + "fields": definition.fields().filter(|f|f.constant().is_none()) + .map(|f|serde_json::json!({"name":f.name(), "type":format!("{:?}",f.ty())})).collect::>(), + "docs": docs(&definition), + })); + } + } + functions.sort_by_key(|f| f["selector"].to_string()); + types.sort_by_key(|t| t["selector"].to_string()); + let output = std::path::Path::new(env!("CARGO_MANIFEST_DIR")) + .join("..\\..\\.win32-contract-inputs.json"); + std::fs::write( + &output, + serde_json::to_vec_pretty(&serde_json::json!({ + "metadataSha256":METADATA_SHA256, "functions":functions, "types":types, + })) + .unwrap(), + ) + .unwrap(); + println!("Review facts: {}", output.display()); + } + + fn configured_winmd() -> Option { + crate::codegen::win32::test_support::metadata() + } + + #[test] + fn named_type_evidence_preserves_scalar_handle_string_and_opaque_categories() { + let Some(path) = configured_winmd() else { + return; + }; + let index = MetadataContext::load(&path).unwrap(); + let scalar = map_named(&index, "Windows.Win32.Foundation", "BOOL", &mut Vec::new()); + assert_eq!(scalar.base, RawBaseType::Scalar(RawScalar::Bool32)); + assert_eq!(scalar.pointer_depth, 0); + for (namespace, name, expected) in [ + ( + "Windows.Win32.Foundation", + "HANDLE", + RawNamedKind::Handle { + cleanup: Some("CloseHandle".into()), + }, + ), + ( + "Windows.Win32.System.Registry", + "HKEY", + RawNamedKind::Handle { + cleanup: Some("RegCloseKey".into()), + }, + ), + ("Windows.Win32.Security", "PSID", RawNamedKind::DataPointer), + ( + "Windows.Win32.Foundation", + "FARPROC", + RawNamedKind::FunctionPointer, + ), + ("Windows.Win32.Foundation", "BSTR", RawNamedKind::Unknown), + ] { + let actual = map_named(&index, namespace, name, &mut Vec::new()); + assert_eq!(actual.pointer_depth, 0); + assert_eq!( + actual.base, + RawBaseType::Named { + namespace: namespace.into(), + name: name.into(), + kind: expected, + } + ); + } + for (name, encoding, expected_element) in [ + ("PWSTR", RawStringEncoding::Utf16, RawScalar::Char16), + ("PSTR", RawStringEncoding::Ansi, RawScalar::U8), + ] { + let actual = map_named(&index, "Windows.Win32.Foundation", name, &mut Vec::new()); + assert!( + matches!(actual.base, RawBaseType::Named { kind:RawNamedKind::StringPointer { encoding:found }, .. } if found == encoding) + ); + assert_eq!(actual.constness, RawConstness::Mutable); + let element = buffer_element(&actual); + assert_eq!(element.base, RawBaseType::Scalar(expected_element)); + assert_eq!(element.pointer_depth, 0); + } + let unknown = map_named( + &index, + "Windows.Win32.Foundation", + "NoSuchNativeTypeForTesting", + &mut Vec::new(), + ); + assert!(matches!( + unknown.base, + RawBaseType::Named { + kind: RawNamedKind::Unknown, + .. + } + )); + } + + #[test] + fn pinvoke_convention_mask_is_decoded_exactly() { + assert_eq!( + calling_convention_bits(0x0100), + RawCallingConvention::System + ); + assert_eq!(calling_convention_bits(0x0200), RawCallingConvention::Cdecl); + for bits in [0x0000, 0x0300, 0x0400, 0x0500] { + assert_eq!( + calling_convention_bits(bits), + RawCallingConvention::Unsupported + ); + } + assert_eq!( + parse_pinvoke_attribute_bits("PInvokeAttributes(768)"), + Some(0x0300) + ); + assert_eq!(parse_pinvoke_attribute_bits("changed-format"), None); + } + + #[test] + fn registry_metadata_preserves_handle_cleanup_and_buffer_relation() { + let Some(winmd) = configured_winmd() else { + return; + }; + let apis = parse_apis(&winmd, "Windows.Win32.System.Registry", "Apis").unwrap(); + let open = apis + .functions + .iter() + .find(|function| function.name == "RegOpenKeyExW") + .unwrap(); + let output = open.parameters.last().unwrap(); + assert_eq!(output.direction, RawDirection::Out); + assert!(matches!( + &output.typ.base, + RawBaseType::Named { + kind: RawNamedKind::Handle { cleanup: Some(cleanup) }, + .. + } if cleanup == "RegCloseKey" + )); + assert_eq!(output.typ.pointer_depth, 1); + + let query = apis + .functions + .iter() + .find(|function| function.name == "RegQueryValueExW") + .unwrap(); + assert!(matches!( + query.parameters[4] + .buffer + .as_ref() + .map(|buffer| &buffer.size), + Some(RawBufferSize::ByteCountParam(5)) + )); + } + + #[test] + fn string_buffer_evidence_does_not_rewrite_raw_metadata() { + let Some(winmd) = configured_winmd() else { + return; + }; + let apis = parse_apis(&winmd, "Windows.Win32.Globalization", "Apis").unwrap(); + let function = apis + .functions + .iter() + .find(|function| function.name == "LCMapStringA") + .unwrap(); + let buffer = &function.parameters[4]; + assert_eq!(buffer.name, "lpDestStr"); + assert!(buffer.nullable); + assert!(buffer.buffer.is_none()); + let policy = Registry::builtin() + .unwrap() + .function_policy(function) + .unwrap(); + let expanded = policy.apply_buffers(function).unwrap(); + assert_eq!( + expanded.parameters[4].buffer.as_ref().unwrap().size, + RawBufferSize::ElementCountParam(5) + ); + assert!(function.parameters[4].buffer.is_none()); + for name in ["LCMapStringW", "LCMapStringEx"] { + let function = apis + .functions + .iter() + .find(|function| function.name == name) + .unwrap(); + assert!( + Registry::builtin() + .unwrap() + .function_policy(function) + .unwrap() + .apply_buffers(function) + .is_err() + ); + } + } + + #[test] + fn nested_anonymous_layouts_are_resolved_from_their_enclosing_type() { + let Some(winmd) = configured_winmd() else { + return; + }; + let apis = parse_apis(&winmd, "Windows.Win32.System.SystemInformation", "Apis").unwrap(); + let system_info = apis + .functions + .iter() + .find(|function| function.name == "GetSystemInfo") + .expect("GetSystemInfo metadata"); + let system_info = &system_info.parameters[0].typ; + let RawBaseType::Named { + kind: RawNamedKind::NativeStruct { layout }, + .. + } = &system_info.base + else { + panic!("SYSTEM_INFO must retain native layout"); + }; + let variant = layout.variants.first().expect("SYSTEM_INFO layout"); + assert!( + variant.fields.iter().any(|field| { + matches!( + &field.typ.base, + RawBaseType::Named { + name, + kind: RawNamedKind::NativeStruct { layout }, + .. + } if name.contains("_Anonymous_e__Union") + && layout.variants.first().is_some_and(|nested| nested.kind == RawLayoutKind::Union) + ) + }), + "{:#?}", + variant.fields + ); + } + + #[test] + fn hfile_preserves_its_signed_i32_abi() { + let Some(winmd) = configured_winmd() else { + return; + }; + let functions = parse_all_functions(&winmd).unwrap(); + let function = functions + .iter() + .find(|function| function.name == "_lopen") + .expect("configured metadata contains _lopen"); + assert!(matches!( + function.return_type, + RawType { + base: RawBaseType::Scalar(RawScalar::I32), + pointer_depth: 0, + .. + } + )); + + let config = functions + .iter() + .find(|function| function.name == "CM_Disable_DevNode") + .expect("configured metadata contains CM_Disable_DevNode"); + assert_eq!(config.return_status, RawStatusSemantics::ZeroIsSuccess); + + let ldap = functions + .iter() + .find(|function| function.name == "LdapGetLastError") + .expect("configured metadata contains LdapGetLastError"); + assert_eq!(ldap.calling_convention, RawCallingConvention::Cdecl); + assert!(!ldap.variadic); + } +} diff --git a/tools/dynwinrt-codegen/src/win32_output.rs b/tools/dynwinrt-codegen/src/win32_output.rs new file mode 100644 index 00000000..3da7f05f --- /dev/null +++ b/tools/dynwinrt-codegen/src/win32_output.rs @@ -0,0 +1,611 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::collections::{BTreeMap, BTreeSet}; +use std::fs; +use std::path::Path; + +use dynwinrt_codegen::codegen::{com, win32}; +use serde::{Deserialize, Serialize}; +use sha2::{Digest, Sha256}; + +const MANIFEST: &str = ".dynwinrt-win32-manifest.json"; +const VERSION: u32 = 2; +const HEADER: &str = "// Generated by dynwinrt-codegen (flat Win32)\n"; + +#[derive(Default, Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +struct Manifest { + version: u32, + namespaces: BTreeMap, +} + +#[derive(Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +struct Namespace { + exports: BTreeSet, + javascript_sha256: String, + declarations_sha256: String, + #[serde(default)] + extra_files: BTreeMap, +} + +#[derive(Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +struct ExtraFile { + sha256: String, + exports: BTreeSet, +} + +fn extra_file_name(name: &str) -> bool { + let stem = name + .strip_suffix(".d.ts") + .or_else(|| name.strip_suffix(".js")); + stem.is_some_and(|stem| identifier(stem) && !matches!(stem, "Apis" | "index")) +} + +fn valid_hash(hash: &str) -> bool { + hash.len() == 64 && hash.bytes().all(|byte| byte.is_ascii_hexdigit()) +} + +fn namespace_directory(namespace: &str) -> Result { + if !namespace.starts_with("Windows.Win32.") + || namespace.split('.').any(|part| !identifier(part)) + { + return Err(format!("Invalid flat Win32 namespace `{namespace}`")); + } + // Use the existing namespace naming and Windows filename validation. + let module = com::canonical_module_path(namespace, "Apis")?; + module + .strip_suffix("/Apis") + .map(str::to_string) + .ok_or_else(|| format!("Invalid flat Win32 module path `{module}`")) +} + +fn identifier(value: &str) -> bool { + let mut chars = value.chars(); + chars + .next() + .is_some_and(|first| first.is_ascii_alphabetic() || first == '_') + && chars.all(|character| character.is_ascii_alphanumeric() || character == '_') +} + +fn digest(bytes: &[u8]) -> String { + format!("{:x}", Sha256::digest(bytes)) +} + +fn validate(manifest: &Manifest) -> Result<(), String> { + if !matches!(manifest.version, 1 | VERSION) { + return Err(format!( + "Unsupported Win32 generation manifest version {}", + manifest.version + )); + } + let mut paths = BTreeSet::new(); + let mut aliases = BTreeSet::new(); + for (namespace, record) in &manifest.namespaces { + let path = namespace_directory(namespace)?; + if !paths.insert(com::windows_relative_path_key(&path)?) + || !aliases.insert(namespace.replace('.', "_")) + { + return Err(format!("Conflicting flat Win32 namespace `{namespace}`")); + } + if record.exports.is_empty() + || record.exports.iter().any(|name| !identifier(name)) + || [&record.javascript_sha256, &record.declarations_sha256] + .iter() + .any(|hash| !valid_hash(hash)) + { + return Err(format!("Invalid Win32 generation record for `{namespace}`")); + } + let mut files = BTreeSet::new(); + let mut names = record.exports.clone(); + for (file, extra) in &record.extra_files { + if manifest.version == 1 + || !extra_file_name(file) + || !files.insert(com::windows_relative_path_key(file)?) + || !valid_hash(&extra.sha256) + || extra.exports.iter().any(|name| !identifier(name)) + { + return Err(format!("Invalid Win32 extra file `{namespace}/{file}`")); + } + let companion = if let Some(stem) = file.strip_suffix(".d.ts") { + if !extra.exports.is_empty() { + return Err(format!( + "Declaration file `{file}` cannot carry runtime exports" + )); + } + format!("{stem}.js") + } else { + format!( + "{}.d.ts", + file.strip_suffix(".js").expect("validated JavaScript file") + ) + }; + if !record.extra_files.contains_key(&companion) { + return Err(format!( + "Win32 extra file `{file}` has no paired module/declaration" + )); + } + for name in &extra.exports { + if !names.insert(name.clone()) { + return Err(format!( + "Conflicting Win32 namespace export `{namespace}.{name}`" + )); + } + } + } + } + Ok(()) +} + +fn read_file(root: &Path, relative: &Path) -> Result>, String> { + let mut path = root.to_path_buf(); + for component in relative.components() { + let std::path::Component::Normal(segment) = component else { + return Err(format!("Unsafe Win32 output path {}", relative.display())); + }; + path.push(segment); + match fs::symlink_metadata(&path) { + Ok(metadata) if super::is_link_or_reparse_point(&metadata) => { + return Err(format!("Refusing linked Win32 output {}", path.display())); + } + Ok(_) => {} + Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(None), + Err(error) => return Err(format!("Failed to inspect {}: {error}", path.display())), + } + } + fs::read(&path) + .map(Some) + .map_err(|error| format!("Failed to read {}: {error}", path.display())) +} + +fn read_manifest(output: &Path) -> Result, String> { + let Some(bytes) = read_file(output, &Path::new("win32").join(MANIFEST))? else { + return Ok(None); + }; + let manifest: Manifest = serde_json::from_slice(&bytes) + .map_err(|error| format!("Invalid Win32 generation manifest: {error}"))?; + validate(&manifest)?; + for (namespace, record) in &manifest.namespaces { + let directory = Path::new("win32").join(namespace_directory(namespace)?); + for (file, expected) in [ + ("Apis.js", &record.javascript_sha256), + ("Apis.d.ts", &record.declarations_sha256), + ] + .into_iter() + .chain( + record + .extra_files + .iter() + .map(|(file, extra)| (file.as_str(), &extra.sha256)), + ) { + let path = directory.join(file); + let bytes = read_file(output, &path)? + .ok_or_else(|| format!("Win32 manifest references missing {}", path.display()))?; + if digest(&bytes) != *expected { + return Err(format!( + "Win32 generated file {} does not match its manifest", + path.display() + )); + } + } + } + Ok(Some(manifest)) +} + +pub(super) fn namespace_paths(output: &Path) -> Result, String> { + let Some(manifest) = read_manifest(output)? else { + return Ok(BTreeSet::new()); + }; + manifest + .namespaces + .keys() + .map(|namespace| namespace_directory(namespace)) + .collect() +} + +fn runtime_import(import_name: &str, directory: &str) -> String { + if import_name == "@microsoft/dynwinrt" { + "@microsoft/dynwinrt/win32".into() + } else if ["./", "../", r".\", r"..\"] + .iter() + .any(|prefix| import_name.starts_with(prefix)) + { + format!( + "{}{}", + "../".repeat(directory.split('/').count() + 1), + import_name.replace('\\', "/") + ) + } else { + import_name.to_string() + } +} + +fn write_javascript(output: &Path, relative: &Path, content: &str) -> Result<(), String> { + super::write_generated_javascript_file(output, &output.join(relative), content) +} + +pub(super) fn generate( + output: &Path, + winmd: &str, + namespaces: &BTreeSet, + import_name: &str, + dry_run: bool, +) -> Result<(), String> { + let existing = read_manifest(output)?; + let root = output.join("win32"); + if existing.is_none() + && root.exists() + && fs::read_dir(&root) + .map_err(|error| format!("Failed to inspect {}: {error}", root.display()))? + .next() + .transpose() + .map_err(|error| format!("Failed to inspect {}: {error}", root.display()))? + .is_some() + { + return Err( + "Existing win32 output has no generation manifest; use a fresh output directory".into(), + ); + } + let mut manifest = existing.unwrap_or_else(|| Manifest { + version: VERSION, + namespaces: BTreeMap::new(), + }); + manifest.version = VERSION; + let mut generated = Vec::new(); + let mut stale_files = Vec::new(); + for namespace in namespaces { + let directory = namespace_directory(namespace)?; + let generated_namespace = + win32::generate_namespace(winmd, namespace, &runtime_import(import_name, &directory))?; + if generated_namespace.namespace != *namespace { + return Err(format!("Win32 projection changed namespace `{namespace}`")); + } + let exports = generated_namespace + .exports + .iter() + .cloned() + .collect::>(); + if exports.len() != generated_namespace.exports.len() { + return Err(format!("Duplicate Win32 exports in `{namespace}`")); + } + for omitted in &generated_namespace.omissions { + eprintln!( + "warning: omitting flat Win32 export `{namespace}::{}`: {}", + omitted.name, omitted.reason + ); + } + let mut extra_files = BTreeMap::new(); + for (name, content) in &generated_namespace.extra_files { + if !extra_file_name(name) { + return Err(format!("Invalid projected Win32 file `{namespace}/{name}`")); + } + let exports = if name.ends_with(".js") { + super::collect_com_cjs_exports(content) + } else { + BTreeSet::new() + }; + if extra_files + .insert( + name.clone(), + ExtraFile { + sha256: digest(content.as_bytes()), + exports, + }, + ) + .is_some() + { + return Err(format!( + "Duplicate projected Win32 file `{namespace}/{name}`" + )); + } + } + if let Some(previous) = manifest.namespaces.get(namespace) { + for file in previous + .extra_files + .keys() + .filter(|file| !extra_files.contains_key(*file)) + { + stale_files.push(Path::new("win32").join(&directory).join(file)); + } + } + manifest.namespaces.insert( + namespace.clone(), + Namespace { + exports, + javascript_sha256: digest(generated_namespace.js.as_bytes()), + declarations_sha256: digest(generated_namespace.dts.as_bytes()), + extra_files, + }, + ); + generated.push((directory, generated_namespace)); + } + validate(&manifest)?; + if dry_run { + for (_, generated) in generated { + println!( + "Would generate flat Win32 {}.Apis ({} exports, {} omitted)", + generated.namespace, + generated.exports.len(), + generated.omissions.len() + ); + } + return Ok(()); + } + for (directory, generated) in generated { + let relative = Path::new("win32").join(&directory); + write_javascript(output, &relative.join("Apis.js"), &generated.js)?; + write_javascript(output, &relative.join("Apis.d.ts"), &generated.dts)?; + for (file, content) in generated.extra_files { + write_javascript(output, &relative.join(file), &content)?; + } + println!( + "Generated flat Win32 {}.Apis ({} exports, {} omitted)", + generated.namespace, + generated.exports.len(), + generated.omissions.len() + ); + } + for relative in stale_files { + let path = output.join(relative); + super::ensure_safe_generated_destination(output, &path)?; + fs::remove_file(&path).map_err(|error| { + format!( + "Failed to remove stale Win32 output {}: {error}", + path.display() + ) + })?; + } + write_indexes(output, &manifest)?; + let path = root.join(MANIFEST); + super::ensure_safe_generated_destination(output, &path)?; + let content = serde_json::to_string_pretty(&manifest) + .map_err(|error| format!("Failed to serialize Win32 generation manifest: {error}"))?; + fs::write(&path, format!("{content}\n")) + .map_err(|error| format!("Failed to write {}: {error}", path.display()))?; + super::write_bindings_manifest(output) +} + +fn write_indexes(output: &Path, manifest: &Manifest) -> Result<(), String> { + let mut root_js = HEADER.to_string(); + let mut root_mjs = HEADER.to_string(); + let mut root_dts = HEADER.to_string(); + for (namespace, record) in &manifest.namespaces { + let directory = namespace_directory(namespace)?; + let relative = Path::new("win32").join(&directory); + let mut js = HEADER.to_string(); + let mut mjs = HEADER.to_string(); + let mut dts = HEADER.to_string(); + let modules = std::iter::once(("Apis.js", &record.exports)).chain( + record + .extra_files + .iter() + .filter(|(name, _)| name.ends_with(".js")) + .map(|(name, extra)| (name.as_str(), &extra.exports)), + ); + for (index, (module, exports)) in modules.enumerate() { + js.push_str(&format!("const _module{index} = require('./{module}');\n")); + for name in exports { + js.push_str(&format!( + "Object.defineProperty(exports, '{name}', {{ enumerable: true, get: () => _module{index}.{name} }});\n" + )); + } + if !exports.is_empty() { + mjs.push_str(&format!( + "export {{ {} }} from './{module}';\n", + exports.iter().cloned().collect::>().join(", ") + )); + } + dts.push_str(&format!("export * from './{module}';\n")); + } + for (file, content) in [("index.js", js), ("index.mjs", mjs), ("index.d.ts", dts)] { + write_javascript(output, &relative.join(file), &content)?; + } + let alias = namespace.replace('.', "_"); + root_js.push_str(&format!( + "Object.defineProperty(exports, '{alias}', {{ enumerable: true, get: () => require('./{directory}/index.js') }});\n" + )); + root_mjs.push_str(&format!( + "export * as {alias} from './{directory}/index.mjs';\n" + )); + root_dts.push_str(&format!( + "export * as {alias} from './{directory}/index.js';\n" + )); + } + for (file, content) in [ + ("index.js", root_js), + ("index.mjs", root_mjs), + ("index.d.ts", root_dts), + ] { + write_javascript(output, &Path::new("win32").join(file), &content)?; + } + Ok(()) +} + +#[cfg(test)] +mod tests { + use super::*; + + fn record() -> Namespace { + Namespace { + exports: BTreeSet::from(["regCloseKey".into()]), + javascript_sha256: digest(b"js"), + declarations_sha256: digest(b"dts"), + extra_files: BTreeMap::new(), + } + } + + #[test] + fn win32_paths_use_main_namespace_layout() { + assert_eq!( + namespace_directory("Windows.Win32.System.SystemInformation").unwrap(), + "windows/win32/system/system-information" + ); + assert!(namespace_directory("Windows.Win32...escape").is_err()); + assert!(namespace_directory("Windows.Win32.System/escape").is_err()); + assert_eq!( + runtime_import("./runtime.js", "windows/win32/system/registry"), + "../../../../.././runtime.js" + ); + assert_eq!( + runtime_import( + r".\runtime helpers\win32.js", + "windows/win32/system/registry" + ), + "../../../../.././runtime helpers/win32.js" + ); + assert_eq!( + runtime_import( + r"..\runtime helpers\win32.js", + "windows/win32/system/registry" + ), + "../../../../../../runtime helpers/win32.js" + ); + } + + #[test] + fn win32_output_manifest_rejects_invalid_and_colliding_records() { + let mut manifest = Manifest { + version: VERSION, + namespaces: BTreeMap::from([("Windows.Win32.System.Registry".into(), record())]), + }; + validate(&manifest).unwrap(); + manifest + .namespaces + .insert("Windows.Win32.System.REGISTRY".into(), record()); + assert!(validate(&manifest).is_err()); + manifest.namespaces.remove("Windows.Win32.System.REGISTRY"); + manifest.namespaces.values_mut().next().unwrap().exports = BTreeSet::from(["bad);".into()]); + assert!(validate(&manifest).is_err()); + assert!( + serde_json::from_str::(r#"{"version":1,"namespaces":{},"unexpected":true}"#) + .is_err() + ); + } + + fn manifest_with_enum() -> Manifest { + let mut record = record(); + record.extra_files.insert( + "FLAGS.js".into(), + ExtraFile { + sha256: digest(b"enum"), + exports: BTreeSet::from(["FLAGS".into()]), + }, + ); + record.extra_files.insert( + "FLAGS.d.ts".into(), + ExtraFile { + sha256: digest(b"declaration"), + exports: BTreeSet::new(), + }, + ); + Manifest { + version: VERSION, + namespaces: BTreeMap::from([("Windows.Win32.System.Registry".into(), record)]), + } + } + + #[test] + fn win32_manifest_rejects_incomplete_ambiguous_and_unsafe_module_records() { + type Mutation = fn(&mut serde_json::Value); + let mutations: &[(&str, Mutation)] = &[ + ("unknown version", |value| value["version"] = 99.into()), + ("root property", |value| value["unexpected"] = true.into()), + ("namespace property", |value| { + value["namespaces"]["Windows.Win32.System.Registry"]["unexpected"] = true.into(); + }), + ("empty exports", |value| { + value["namespaces"]["Windows.Win32.System.Registry"]["exports"] = + serde_json::json!([]); + }), + ("malformed checksum", |value| { + value["namespaces"]["Windows.Win32.System.Registry"]["javascript_sha256"] = + "bad".into(); + }), + ("missing declaration", |value| { + value["namespaces"]["Windows.Win32.System.Registry"]["extra_files"] + .as_object_mut() + .unwrap() + .remove("FLAGS.d.ts"); + }), + ("declaration runtime export", |value| { + value["namespaces"]["Windows.Win32.System.Registry"]["extra_files"]["FLAGS.d.ts"] + ["exports"] = serde_json::json!(["FLAGS"]); + }), + ("duplicate namespace export", |value| { + value["namespaces"]["Windows.Win32.System.Registry"]["extra_files"]["FLAGS.js"]["exports"] = + serde_json::json!(["regCloseKey"]); + }), + ("extra file property", |value| { + value["namespaces"]["Windows.Win32.System.Registry"]["extra_files"]["FLAGS.js"]["unexpected"] = + true.into(); + }), + ("injected name", |value| { + value["namespaces"]["Windows.Win32.System.Registry"]["extra_files"]["FLAGS.js"]["exports"] = + serde_json::json!(["bad');"]); + }), + ]; + for (name, mutate) in mutations { + let mut value = serde_json::to_value(manifest_with_enum()).unwrap(); + mutate(&mut value); + let result = serde_json::from_value::(value) + .map_err(|error| error.to_string()) + .and_then(|manifest| validate(&manifest)); + assert!(result.is_err(), "{name}"); + } + for invalid in [ + "../escape.js", + r"..\escape.js", + "nested/file.js", + r"nested\file.js", + "C:escape.js", + "Apis.js", + "index.d.ts", + "FLAGS.js:stream", + "FLAGS.txt", + "CON.js", + ] { + let mut manifest = manifest_with_enum(); + let files = &mut manifest.namespaces.values_mut().next().unwrap().extra_files; + let entry = files.remove("FLAGS.js").unwrap(); + files.insert(invalid.into(), entry); + assert!(validate(&manifest).is_err(), "{invalid}"); + } + let mut manifest = manifest_with_enum(); + let files = &mut manifest.namespaces.values_mut().next().unwrap().extra_files; + files.insert( + "flags.js".into(), + ExtraFile { + sha256: digest(b"other"), + exports: BTreeSet::from(["Other".into()]), + }, + ); + files.insert( + "flags.d.ts".into(), + ExtraFile { + sha256: digest(b"other types"), + exports: BTreeSet::new(), + }, + ); + assert!( + validate(&manifest).is_err(), + "Windows filename collisions must fail" + ); + } + + #[test] + fn win32_manifest_accepts_known_versions_without_weakening_module_pairing() { + let mut old = Manifest { + version: 1, + namespaces: BTreeMap::from([("Windows.Win32.System.Registry".into(), record())]), + }; + validate(&old).unwrap(); + old.version = VERSION; + validate(&old).unwrap(); + let mut with_enum = manifest_with_enum(); + validate(&with_enum).unwrap(); + with_enum.version = 1; + assert!(validate(&with_enum).is_err()); + } +} diff --git a/tools/dynwinrt-codegen/tests/win32_cli_test.rs b/tools/dynwinrt-codegen/tests/win32_cli_test.rs new file mode 100644 index 00000000..d04262a5 --- /dev/null +++ b/tools/dynwinrt-codegen/tests/win32_cli_test.rs @@ -0,0 +1,591 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use sha2::{Digest, Sha256}; +use std::collections::BTreeMap; +use std::fs; +use std::path::{Path, PathBuf}; +use std::process::{Command, Output}; +use std::sync::atomic::{AtomicU64, Ordering}; + +const REGISTRY: &str = "Windows.Win32.System.Registry"; +const SYSTEM: &str = "Windows.Win32.System.SystemInformation"; +const SDK: &str = + r"C:\Program Files (x86)\Windows Kits\10\UnionMetadata\10.0.26100.0\Windows.winmd"; +static NEXT: AtomicU64 = AtomicU64::new(0); + +struct Scratch(PathBuf); + +impl Scratch { + fn new() -> Self { + let path = std::env::temp_dir().join(format!( + "dynwinrt-win32-cli-{}-{}", + std::process::id(), + NEXT.fetch_add(1, Ordering::Relaxed) + )); + fs::create_dir(&path).unwrap(); + Self(path) + } + + fn output(&self) -> PathBuf { + self.0.join("generated") + } +} + +impl Drop for Scratch { + fn drop(&mut self) { + fs::remove_dir_all(&self.0).expect("remove this test's private output"); + } +} + +fn metadata() -> Option { + let path = std::env::var("DYNWINRT_WIN32_WINMD") + .ok() + .filter(|path| Path::new(path).is_file()); + if path.is_none() { + assert_ne!( + std::env::var("DYNWINRT_REQUIRE_WIN32_METADATA").as_deref(), + Ok("1"), + "Win32 CLI tests require DYNWINRT_WIN32_WINMD" + ); + eprintln!("Skipping Win32 CLI test: DYNWINRT_WIN32_WINMD is not configured"); + } + path +} + +fn generate(winmd: &str, output: &Path, args: &[&str]) -> Output { + command(winmd, output, args) + .output() + .expect("execute generator") +} + +fn command(winmd: &str, output: &Path, args: &[&str]) -> Command { + let mut command = Command::new(env!("CARGO_BIN_EXE_dynwinrt-codegen")); + command + .args(["generate", "--winmd", winmd, "--output"]) + .arg(output) + .args(args); + command +} + +fn success(output: Output) { + assert!( + output.status.success(), + "{}\n{}", + String::from_utf8_lossy(&output.stdout), + String::from_utf8_lossy(&output.stderr) + ); +} + +fn files(root: &Path) -> BTreeMap> { + fn visit(root: &Path, current: &Path, result: &mut BTreeMap>) { + for entry in fs::read_dir(current).unwrap() { + let path = entry.unwrap().path(); + if path.is_dir() { + visit(root, &path, result); + } else { + result.insert( + path.strip_prefix(root).unwrap().to_path_buf(), + fs::read(path).unwrap(), + ); + } + } + } + let mut result = BTreeMap::new(); + visit(root, root, &mut result); + result +} + +#[test] +fn win32_namespace_and_class_modes_are_identical_and_incremental() { + let Some(winmd) = metadata() else { return }; + let first = Scratch::new(); + let second = Scratch::new(); + let output = first.output(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + success(generate( + &winmd, + &second.output(), + &["--class-name", "Windows.Win32.System.Registry.Apis"], + )); + assert_eq!(files(&output), files(&second.output())); + + let registry = output.join(r"win32\windows\win32\system\registry\Apis.js"); + let original = fs::read(®istry).unwrap(); + success(generate(&winmd, &output, &["--namespace", SYSTEM])); + assert_eq!(fs::read(®istry).unwrap(), original); + assert!( + output + .join(r"win32\windows\win32\system\system-information\Apis.js") + .is_file() + ); + assert!(!output.join("Apis.js").exists()); + assert!(!output.join("index.js").exists()); + let package: serde_json::Value = + serde_json::from_slice(&fs::read(output.join("package.json")).unwrap()).unwrap(); + assert!(package["exports"].get(".").is_none()); + assert_eq!( + package["exports"]["./win32/windows/win32/system/registry"]["require"], + "./win32/windows/win32/system/registry/index.js" + ); + assert!(package["exports"].get("./win32").is_some()); + assert!( + String::from_utf8(original) + .unwrap() + .contains("@microsoft/dynwinrt/win32") + ); +} + +#[test] +fn win32_dry_run_and_python_rejection_do_not_publish_output() { + let Some(winmd) = metadata() else { return }; + let scratch = Scratch::new(); + let output = scratch.output(); + let dry_run = generate(&winmd, &output, &["--namespace", REGISTRY, "--dry-run"]); + assert!(String::from_utf8_lossy(&dry_run.stdout).contains("Would generate flat Win32")); + success(dry_run); + assert!(!output.exists()); + + fs::create_dir(&output).unwrap(); + fs::write(output.join("sentinel.txt"), b"keep").unwrap(); + for args in [ + vec!["--namespace", REGISTRY, "--lang", "py"], + vec![ + "--class-name", + "Windows.Win32.System.Registry.Apis", + "--lang", + "py", + ], + ] { + let result = generate(&winmd, &output, &args); + assert!(!result.status.success()); + assert!(String::from_utf8_lossy(&result.stderr).contains("not supported for flat Win32")); + assert_eq!(fs::read(output.join("sentinel.txt")).unwrap(), b"keep"); + assert!(!output.join("win32").exists()); + } +} + +#[test] +fn win32_unsupported_export_container_fails_without_partial_output() { + let Some(winmd) = metadata() else { return }; + let scratch = Scratch::new(); + let output = scratch.output(); + let result = generate( + &winmd, + &output, + &[ + "--class-name", + "Windows.Win32.System.Registry.Apis,Windows.Win32.System.Mapi.Apis", + ], + ); + assert!(!result.status.success()); + assert!(!output.exists()); +} + +#[test] +fn win32_manifest_and_generated_file_drift_fail_closed() { + let Some(winmd) = metadata() else { return }; + let scratch = Scratch::new(); + let output = scratch.output(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + let path = output.join(r"win32\windows\win32\system\registry\Apis.js"); + fs::write(&path, "// edited").unwrap(); + let before = files(&output); + let result = generate(&winmd, &output, &["--namespace", SYSTEM]); + assert!(!result.status.success()); + assert!(String::from_utf8_lossy(&result.stderr).contains("does not match its manifest")); + assert_eq!(files(&output), before); +} + +#[test] +fn win32_enum_artifacts_are_exported_hashed_and_cleaned_incrementally() { + let Some(winmd) = metadata() else { return }; + let scratch = Scratch::new(); + let output = scratch.output(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + let manifest_path = output.join(r"win32\.dynwinrt-win32-manifest.json"); + let mut manifest: serde_json::Value = + serde_json::from_slice(&fs::read(&manifest_path).unwrap()).unwrap(); + let directory = output.join(r"win32\windows\win32\system\registry"); + let extras = manifest["namespaces"][REGISTRY]["extra_files"] + .as_object_mut() + .unwrap(); + assert!( + !extras.is_empty(), + "full Registry declarations require enum modules" + ); + let index = fs::read_to_string(directory.join("index.mjs")).unwrap(); + for name in extras.keys() { + assert!(directory.join(name).is_file(), "{name}"); + if name.ends_with(".js") { + assert!(index.contains(&format!("from './{name}'")), "{name}"); + } + } + for (name, text, exports) in [ + ( + "StaleEnum.js", + "// Generated by dynwinrt-codegen\nexports.StaleEnum = {};\n", + vec!["StaleEnum"], + ), + ( + "StaleEnum.d.ts", + "// Generated by dynwinrt-codegen\nexport declare const StaleEnum: {};\n", + vec![], + ), + ] { + fs::write(directory.join(name), text).unwrap(); + extras.insert( + name.into(), + serde_json::json!({ + "sha256": format!("{:x}", Sha256::digest(text.as_bytes())), + "exports": exports, + }), + ); + } + fs::write( + &manifest_path, + serde_json::to_vec_pretty(&manifest).unwrap(), + ) + .unwrap(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + assert!(!directory.join("StaleEnum.js").exists()); + assert!(!directory.join("StaleEnum.d.ts").exists()); + + let manifest: serde_json::Value = + serde_json::from_slice(&fs::read(&manifest_path).unwrap()).unwrap(); + let enum_file = manifest["namespaces"][REGISTRY]["extra_files"] + .as_object() + .unwrap() + .keys() + .find(|name| name.ends_with(".js")) + .unwrap(); + fs::write(directory.join(enum_file), "// edited enum").unwrap(); + let before = files(&output); + let result = generate(&winmd, &output, &["--namespace", SYSTEM]); + assert!(!result.status.success()); + assert!(String::from_utf8_lossy(&result.stderr).contains("does not match its manifest")); + assert_eq!(files(&output), before); +} + +#[test] +fn win32_mixed_generation_preserves_winrt_modules_and_root_exports() { + let Some(winmd) = metadata() else { return }; + assert!( + Path::new(SDK).is_file(), + "mixed WinRT test requires the Windows SDK" + ); + let scratch = Scratch::new(); + let output = scratch.output(); + success(generate( + SDK, + &output, + &["--namespace", "Windows.Foundation", "--class-name", "Uri"], + )); + let baseline = files(&output); + let package: serde_json::Value = + serde_json::from_slice(&baseline[Path::new("package.json")]).unwrap(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + for (path, bytes) in &baseline { + if path != Path::new("package.json") { + assert_eq!( + &fs::read(output.join(path)).unwrap(), + bytes, + "{}", + path.display() + ); + } + } + let mixed: serde_json::Value = + serde_json::from_slice(&fs::read(output.join("package.json")).unwrap()).unwrap(); + for (key, value) in package["exports"].as_object().unwrap() { + assert_eq!(&mixed["exports"][key], value); + } + + success(generate( + SDK, + &output, + &["--namespace", "Windows.Foundation", "--class-name", "Uri"], + )); + assert!( + output + .join(r"win32\windows\win32\system\registry\Apis.js") + .exists() + ); + let package: serde_json::Value = + serde_json::from_slice(&fs::read(output.join("package.json")).unwrap()).unwrap(); + assert!(package["exports"].get("./win32").is_some()); + + let reverse = Scratch::new(); + success(generate( + &winmd, + &reverse.output(), + &["--namespace", REGISTRY], + )); + success(generate( + SDK, + &reverse.output(), + &["--namespace", "Windows.Foundation", "--class-name", "Uri"], + )); + assert_eq!(files(&output), files(&reverse.output())); +} + +#[test] +fn win32_dry_run_does_not_mutate_an_existing_mixed_package() { + let Some(winmd) = metadata() else { return }; + let scratch = Scratch::new(); + let output = scratch.output(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + fs::write(output.join("keep.txt"), "handwritten user note").unwrap(); + let before = files(&output); + success(generate( + &winmd, + &output, + &["--namespace", SYSTEM, "--dry-run"], + )); + assert_eq!(files(&output), before); + let result = generate( + &winmd, + &output, + &[ + "--class-name", + "Windows.Win32.System.Mapi.Apis", + "--dry-run", + ], + ); + assert!(!result.status.success()); + assert_eq!(files(&output), before); +} + +#[test] +fn win32_failed_publish_rolls_back_and_a_retry_commits_all_files() { + let Some(winmd) = metadata() else { return }; + for point in ["before_publish", "after_backup_rename"] { + let scratch = Scratch::new(); + let output = scratch.output(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + fs::write(output.join("keep.txt"), b"preserve existing data").unwrap(); + let before = files(&output); + let failed = command(&winmd, &output, &["--namespace", SYSTEM]) + .env("DYNWINRT_CODEGEN_TEST_FAIL_OUTPUT_COMMIT", point) + .output() + .unwrap(); + assert!(!failed.status.success(), "{point}"); + assert!( + String::from_utf8_lossy(&failed.stderr).contains("Injected output transaction failure"), + "{}", + String::from_utf8_lossy(&failed.stderr) + ); + assert_eq!(files(&output), before, "{point}"); + success(generate(&winmd, &output, &["--namespace", SYSTEM])); + assert!( + output + .join(r"win32\windows\win32\system\system-information\Apis.js") + .is_file() + ); + assert_eq!( + fs::read(output.join("keep.txt")).unwrap(), + b"preserve existing data" + ); + assert_eq!( + fs::read(output.join(r"win32\windows\win32\system\registry\Apis.js")).unwrap(), + before[Path::new(r"win32\windows\win32\system\registry\Apis.js")] + ); + } +} + +#[test] +fn win32_missing_modules_and_malformed_manifests_fail_without_publication() { + let Some(winmd) = metadata() else { return }; + let scratch = Scratch::new(); + let output = scratch.output(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + let module = output.join(r"win32\windows\win32\system\registry\Apis.d.ts"); + let bytes = fs::read(&module).unwrap(); + fs::remove_file(&module).unwrap(); + let before = files(&output); + let missing = generate(&winmd, &output, &["--namespace", SYSTEM]); + assert!(!missing.status.success()); + assert!(String::from_utf8_lossy(&missing.stderr).contains("missing")); + assert_eq!(files(&output), before); + fs::write(module, bytes).unwrap(); + + let manifest = output.join(r"win32\.dynwinrt-win32-manifest.json"); + let original: serde_json::Value = + serde_json::from_slice(&fs::read(&manifest).unwrap()).unwrap(); + for field in ["version", "unexpected"] { + let mut malformed = original.clone(); + malformed[field] = 123.into(); + fs::write(&manifest, serde_json::to_vec(&malformed).unwrap()).unwrap(); + let before = files(&output); + let result = generate(&winmd, &output, &["--namespace", SYSTEM]); + assert!(!result.status.success()); + assert_eq!(files(&output), before); + } +} + +#[test] +fn win32_output_rejects_unmanaged_files_and_traversal_manifest_paths() { + let Some(winmd) = metadata() else { return }; + let scratch = Scratch::new(); + let output = scratch.output(); + fs::create_dir_all(output.join("win32")).unwrap(); + let sentinel = output.join(r"win32\custom.js"); + fs::write(&sentinel, "module.exports = 'mine'").unwrap(); + let before = files(&output); + let failed = generate(&winmd, &output, &["--namespace", REGISTRY]); + assert!(!failed.status.success()); + assert!(String::from_utf8_lossy(&failed.stderr).contains("no generation manifest")); + assert_eq!(files(&output), before); + fs::remove_file(sentinel).unwrap(); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + let manifest = output.join(r"win32\.dynwinrt-win32-manifest.json"); + let mut value: serde_json::Value = + serde_json::from_slice(&fs::read(&manifest).unwrap()).unwrap(); + value["namespaces"][REGISTRY]["extra_files"]["../outside.js"] = serde_json::json!({ + "sha256": "0".repeat(64), "exports": ["outside"] + }); + fs::write(&manifest, serde_json::to_vec(&value).unwrap()).unwrap(); + fs::write(scratch.0.join("outside.js"), b"outside unchanged").unwrap(); + let before = files(&output); + let failed = generate(&winmd, &output, &["--namespace", SYSTEM]); + assert!(!failed.status.success()); + assert_eq!(files(&output), before); + assert_eq!( + fs::read(scratch.0.join("outside.js")).unwrap(), + b"outside unchanged" + ); +} + +#[test] +fn win32_com_and_winrt_share_one_atomic_batch_without_export_collisions() { + let Some(winmd) = metadata() else { return }; + let scratch = Scratch::new(); + let output = scratch.output(); + let combined_metadata = format!("{winmd};{SDK}"); + success(generate( + &combined_metadata, + &output, + &[ + "--class-name", + "Windows.Foundation.Uri,Windows.Win32.System.Com.IPersistFile", + ], + )); + let baseline = files(&output); + success(generate(&winmd, &output, &["--namespace", REGISTRY])); + for (path, content) in baseline { + if path != Path::new("package.json") { + assert_eq!( + fs::read(output.join(&path)).unwrap(), + content, + "{}", + path.display() + ); + } + } + let package: serde_json::Value = + serde_json::from_slice(&fs::read(output.join("package.json")).unwrap()).unwrap(); + for entry in [".", "./com", "./win32"] { + assert!(package["exports"].get(entry).is_some(), "{entry}"); + } + let root = fs::read_to_string(output.join("index.d.ts")).unwrap(); + assert!(!root.contains("regOpenKeyEx")); + assert!(!root.contains("IPersistFile")); + + let batch = Scratch::new(); + success(generate( + &combined_metadata, + &batch.output(), + &[ + "--class-name", + "Windows.Win32.System.Registry.Apis,Windows.Foundation.Uri,Windows.Win32.System.Com.IPersistFile", + ], + )); + assert_eq!(files(&output), files(&batch.output())); + let before = files(&output); + let failed = generate( + &combined_metadata, + &output, + &[ + "--class-name", + "Windows.Win32.System.SystemInformation.Apis,Windows.Foundation.ClassThatDoesNotExist", + ], + ); + assert!(!failed.status.success()); + assert_eq!(files(&output), before); +} + +#[test] +fn win32_relative_runtime_imports_load_cjs_esm_and_enum_subpaths() { + let Some(winmd) = metadata() else { return }; + for import in ["./runtime helpers/win32.js", r".\runtime helpers\win32.js"] { + let scratch = Scratch::new(); + let output = scratch.0.join("generated bindings"); + success(generate( + &winmd, + &output, + &[ + "--class-name", + "Windows.Win32.System.Registry.Apis,Windows.Win32.System.SystemInformation.Apis", + "--import-name", + import, + ], + )); + let runtime = output.join("runtime helpers"); + fs::create_dir(&runtime).unwrap(); + let stub = r#" +globalThis.win32RuntimeLoads = (globalThis.win32RuntimeLoads ?? 0) + 1; +module.exports = { + DynWin32: {}, + DynWin32Function: { bind() { throw new Error('import must not dispatch a native function'); } }, +}; +"#; + fs::write(runtime.join("win32.js"), stub).unwrap(); + fs::write(runtime.join("win32-unsafe.js"), stub).unwrap(); + let script = r#" +const assert = require('node:assert/strict'); +const { createRequire } = require('node:module'); +const { join } = require('node:path'); +const { pathToFileURL } = require('node:url'); +const fs = require('node:fs'); +(async () => { + const root = process.argv[1]; + const req = createRequire(join(root, 'package.json')); + assert.throws(() => req('@winapp/bindings'), { code: 'ERR_PACKAGE_PATH_NOT_EXPORTED' }); + assert.equal(globalThis.win32RuntimeLoads, undefined); + const ns = '@winapp/bindings/win32/windows/win32/system/registry'; + const registry = req(ns); + const module = req(`${ns}/Apis`); + assert.equal(registry.regOpenKeyEx, module.regOpenKeyExW); + assert.equal(registry.regQueryValueEx, module.regQueryValueExW); + assert.equal(typeof registry.regCloseKey, 'function'); + const esm = await import(pathToFileURL(join(root, 'win32/windows/win32/system/registry/index.mjs')).href); + assert.equal(esm.regOpenKeyExW, registry.regOpenKeyExW); + const manifest = JSON.parse(fs.readFileSync(join(root, 'win32/.dynwinrt-win32-manifest.json'))); + const files = manifest.namespaces['Windows.Win32.System.Registry'].extra_files; + let enums = 0; + for (const [file, entry] of Object.entries(files)) { + if (!file.endsWith('.js')) continue; + const values = req(`${ns}/${file.slice(0, -3)}`); + for (const name of entry.exports) { + assert.equal(registry[name], values[name]); + assert.equal(esm[name], values[name]); + assert(Object.isFrozen(values[name])); + ++enums; + } + } + assert(enums > 0); + const barrel = req('@winapp/bindings/win32'); + assert.equal(barrel.Windows_Win32_System_Registry, registry); + assert.equal(typeof barrel.Windows_Win32_System_SystemInformation.getTickCount64, 'function'); + assert.equal(globalThis.win32RuntimeLoads, 2); + console.log('module-contracts-ok'); +})().catch(error => { console.error(error); process.exitCode = 1; }); +"#; + let node = Command::new("node") + .args(["--eval", script]) + .arg(&output) + .output() + .expect("Node is required for generated module tests"); + success(node); + } +} diff --git a/tools/dynwinrt-codegen/tests/win32_contract_schema_test.rs b/tools/dynwinrt-codegen/tests/win32_contract_schema_test.rs new file mode 100644 index 00000000..d16c7c79 --- /dev/null +++ b/tools/dynwinrt-codegen/tests/win32_contract_schema_test.rs @@ -0,0 +1,73 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::{fs, path::Path}; + +use serde_json::Value; +use sha2::{Digest, Sha256}; + +fn lf_hash(text: &str) -> String { + format!( + "{:X}", + Sha256::digest(text.replace("\r\n", "\n").as_bytes()) + ) +} + +#[test] +fn win32_call_contract_schema_matches_shared_protocol() { + let directory = Path::new(env!("CARGO_MANIFEST_DIR")).join(r"contracts\win32"); + let generated = format!( + "{}\n", + serde_json::to_string_pretty(&dynwinrt_win32_contracts::schema()).unwrap() + ); + let manifest_path = directory.join("manifest.json"); + let mut manifest: Value = + serde_json::from_str(&fs::read_to_string(&manifest_path).unwrap()).unwrap(); + if std::env::var_os("DYNWINRT_UPDATE_WIN32_SCHEMA").is_some() { + fs::write(directory.join("call-contract.schema.json"), &generated).unwrap(); + manifest["schema"]["sha256"] = + lf_hash(&fs::read_to_string(directory.join("schema.json")).unwrap()).into(); + for pin in manifest["files"].as_array_mut().unwrap() { + let text = fs::read_to_string(directory.join(pin["file"].as_str().unwrap())).unwrap(); + pin["sha256"] = lf_hash(&text).into(); + } + fs::write( + &manifest_path, + format!("{}\n", serde_json::to_string_pretty(&manifest).unwrap()), + ) + .unwrap(); + } + assert_eq!( + fs::read_to_string(directory.join("call-contract.schema.json")) + .unwrap() + .replace("\r\n", "\n"), + generated, + "Set DYNWINRT_UPDATE_WIN32_SCHEMA=1 and rerun this test to update the shared schema and LF manifest hashes" + ); + let production: Value = + serde_json::from_str(&fs::read_to_string(directory.join("schema.json")).unwrap()).unwrap(); + assert_eq!( + production["$defs"]["callContract"]["$ref"], + "call-contract.schema.json" + ); + assert_eq!( + production["$defs"]["resultContract"]["$ref"], + "call-contract.schema.json#/$defs/ResultContract" + ); + for duplicate in [ + "outputRule", + "condition", + "inputPredicate", + "outputAction", + "resourceEffect", + ] { + assert!( + production["$defs"].get(duplicate).is_none(), + "handwritten protocol definition: {duplicate}" + ); + } + for pin in std::iter::once(&manifest["schema"]).chain(manifest["files"].as_array().unwrap()) { + let text = fs::read_to_string(directory.join(pin["file"].as_str().unwrap())).unwrap(); + assert_eq!(pin["sha256"], lf_hash(&text), "{}", pin["file"]); + } +} diff --git a/tools/dynwinrt-codegen/tests/win32_generated_modules_test.rs b/tools/dynwinrt-codegen/tests/win32_generated_modules_test.rs new file mode 100644 index 00000000..047b50c6 --- /dev/null +++ b/tools/dynwinrt-codegen/tests/win32_generated_modules_test.rs @@ -0,0 +1,326 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::{ + collections::{BTreeMap, BTreeSet}, + fs, + path::{Path, PathBuf}, + process::Command, +}; + +use dynwinrt_codegen::{ + codegen::{com, win32}, + win32_metadata, +}; + +struct Scratch(PathBuf); + +impl Drop for Scratch { + fn drop(&mut self) { + fs::remove_dir_all(&self.0).expect("remove this test's generated module directory"); + } +} + +#[test] +fn all_supported_win32_modules_load_and_have_valid_declarations() { + let required = std::env::var("DYNWINRT_REQUIRE_WIN32_METADATA").as_deref() == Ok("1"); + let metadata = std::env::var("DYNWINRT_WIN32_WINMD").ok(); + let Some(metadata) = metadata else { + assert!( + !required, + "DYNWINRT_REQUIRE_WIN32_METADATA=1 requires a metadata path" + ); + eprintln!("Skipping generated Win32 module test: metadata is not configured"); + return; + }; + assert!( + Path::new(&metadata).is_file(), + "configured Win32 metadata does not exist" + ); + let tsc = std::env::var_os("DYNWINRT_TSC") + .map(PathBuf::from) + .unwrap_or_else(|| { + Path::new(env!("CARGO_MANIFEST_DIR")) + .join(r"..\..\bindings\js\node_modules\typescript\bin\tsc") + }); + let require_tsc = std::env::var("DYNWINRT_REQUIRE_TSC").as_deref() == Ok("1"); + assert!( + !require_tsc || tsc.is_file(), + "DYNWINRT_REQUIRE_TSC=1 requires a TypeScript compiler" + ); + let directory = Path::new(env!("CARGO_MANIFEST_DIR")) + .join("target") + .join(format!("win32-generated-modules-{}", std::process::id())); + fs::create_dir_all(directory.parent().unwrap()).unwrap(); + fs::create_dir(&directory).unwrap(); + let scratch = Scratch(directory); + let functions = win32_metadata::parse_all_functions(&metadata).expect("parse native exports"); + let eligible_functions = functions.len(); + let mut containers = BTreeMap::new(); + for function in functions { + containers + .entry((function.namespace.clone(), function.container.clone())) + .or_insert_with(Vec::new) + .push(function); + } + let mut modules = Vec::new(); + let mut namespace_count = 0; + let mut complete_functions = 0; + for ((namespace, class_name), functions) in containers { + let raw = win32_metadata::RawApis { + namespace, + class_name, + functions, + }; + let projection = win32::project_apis(&raw); + complete_functions += projection.complete_count(); + if projection.complete_count() == 0 { + continue; + } + namespace_count += 1; + let (generated, _) = win32::generate_apis_files(&raw, "@microsoft/dynwinrt/win32"); + let module = com::canonical_module_path(&raw.namespace, &raw.class_name).unwrap(); + let target = scratch.0.join(&module); + let parent = target.parent().unwrap(); + fs::create_dir_all(parent).unwrap(); + let mut outputs = BTreeMap::from([ + (format!("{}.js", raw.class_name), generated.js), + (format!("{}.d.ts", raw.class_name), generated.dts), + ]); + let mut names = BTreeSet::new(); + for (file, content) in generated.extra_files { + assert!( + names.insert(com::windows_relative_path_key(&file).unwrap()), + "{namespace}", + namespace = raw.namespace + ); + assert!( + outputs.insert(file, content).is_none(), + "duplicate generated file" + ); + } + for (file, content) in &outputs { + assert!( + content.starts_with("// Generated by dynwinrt-codegen"), + "{file}" + ); + let pair = if let Some(stem) = file.strip_suffix(".d.ts") { + format!("{stem}.js") + } else { + format!( + "{}.d.ts", + file.strip_suffix(".js").expect("known output extension") + ) + }; + assert!( + outputs.contains_key(&pair), + "{file} has no implementation/declaration pair" + ); + let path = parent.join(file); + fs::write(&path, content).unwrap(); + if file.ends_with(".js") { + modules.push(path); + } + } + } + assert!( + namespace_count > 0, + "metadata must exercise actual generated modules" + ); + assert_eq!( + (complete_functions, eligible_functions, namespace_count), + (8_936, 18_321, 182), + "the pinned Win32Metadata complete-export census must not regress" + ); + eprintln!( + "Validated {complete_functions}/{eligible_functions} exports across {namespace_count} namespaces" + ); + let runtime = scratch.0.join(r"node_modules\@microsoft\dynwinrt"); + fs::create_dir_all(&runtime).unwrap(); + fs::write( + runtime.join("package.json"), + r#"{ + "name":"@microsoft/dynwinrt", + "exports":{ + "./win32":{"types":"./win32.d.ts","default":"./win32.js"}, + "./win32/unsafe":{"types":"./win32.d.ts","default":"./win32.js"} + } + }"#, + ) + .unwrap(); + fs::write( + runtime.join("win32.js"), + r#" +const forbidCall = new Proxy({}, { + get(_, name) { throw new Error(`Native operation ${String(name)} ran during import`); } +}); +module.exports = { DynWin32: forbidCall, DynWin32Function: forbidCall }; +"#, + ) + .unwrap(); + fs::write( + runtime.join("win32.d.ts"), + r#" +export declare class DynWin32NativeStruct { + private constructor(); + private readonly nativeStructBrand: never; + readonly length: number; +} +export declare class DynWin32Resource { + private constructor(); + private readonly resourceBrand: never; + readonly value: bigint; + close(): boolean; +} +export declare class DynWin32SubsystemContext { + private constructor(); + private readonly subsystemBrand: never; +} +export declare class DynWinRtValue { + private constructor(); + private readonly comValueBrand: never; +} +"#, + ) + .unwrap(); + fs::write( + scratch.0.join("globals.d.ts"), + "declare class Buffer extends Uint8Array {}\n", + ) + .unwrap(); + fs::write(scratch.0.join("package.json"), r#"{"type":"commonjs"}"#).unwrap(); + let modules_file = scratch.0.join("modules.json"); + fs::write(&modules_file, serde_json::to_vec(&modules).unwrap()).unwrap(); + let node_script = r#" +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const { basename } = require('node:path'); +const { pathToFileURL } = require('node:url'); +(async () => { + const modules = JSON.parse(fs.readFileSync(process.argv[1], 'utf8')); + const failures = []; + let namespaceExports = 0; + for (const file of modules) { + try { + const cjs = require(file); + const esm = await import(pathToFileURL(file).href); + if (basename(file) === 'Apis.js') namespaceExports += Object.keys(cjs).length; + for (const name of Object.keys(cjs)) { + assert.notEqual(cjs[name], undefined, `${file}: undefined export ${name}`); + assert.equal(esm[name], cjs[name], `${file}: missing ESM named export ${name}`); + } + } catch (error) { + failures.push(`${file}: ${error.stack}`); + } + } + assert.equal(failures.length, 0, failures.join('\n')); + assert.equal(namespaceExports, 10680, 'the pinned public namespace export census must not regress'); + console.log(`Loaded ${modules.length} generated modules with ${namespaceExports} public namespace exports without native calls`); +})().catch(error => { console.error(error); process.exitCode = 1; }); +"#; + let node = Command::new("node") + .args(["--eval", node_script]) + .arg(&modules_file) + .output() + .expect("Node is required for module loading tests"); + eprintln!("{}", String::from_utf8_lossy(&node.stdout).trim()); + if !tsc.is_file() { + assert!( + node.status.success(), + "{}\n{}", + String::from_utf8_lossy(&node.stdout), + String::from_utf8_lossy(&node.stderr) + ); + eprintln!("Skipping declaration compilation only: TypeScript is not installed"); + return; + } + let module = |namespace, name| { + format!( + "./{}.js", + com::canonical_module_path(namespace, name) + .unwrap() + .replace('\\', "/") + ) + }; + fs::write( + scratch.0.join("consumer.ts"), + format!( + r#" +import type {{ DynWin32Resource }} from '@microsoft/dynwinrt/win32' +import {{ Apis as Registry, regOpenKey, regOpenKeyEx, regGetValue, regQueryValueEx }} from {registry:?} +import {{ REG_SAM_FLAGS }} from {access:?} +import {{ REG_ROUTINE_FLAGS }} from {routine:?} +import {{ REG_VALUE_TYPE }} from {value_type:?} +import {{ FILE_FLAGS_AND_ATTRIBUTES }} from {file_flags:?} +import {{ setFileAttributes }} from {files:?} +import {{ createProcessInformation, takeProcessInformationProcess, takeProcessInformationThread, getProcessInformationProcessId, getProcessInformationThreadId }} from {threading:?} + +const access: REG_SAM_FLAGS = REG_SAM_FLAGS.KEY_QUERY_VALUE | REG_SAM_FLAGS.KEY_SET_VALUE +const flags: REG_ROUTINE_FLAGS = REG_ROUTINE_FLAGS.RRF_RT_REG_DWORD | REG_ROUTINE_FLAGS.RRF_ZEROONFAILURE +const fileFlags: FILE_FLAGS_AND_ATTRIBUTES = FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_WRITE_THROUGH | FILE_FLAGS_AND_ATTRIBUTES.FILE_FLAG_OVERLAPPED +setFileAttributes('fixture', fileFlags) +regOpenKeyEx(0x80000001n, 'Software', 0, access) +Registry.regOpenKeyEx(0x80000001n, 'Software', 0, REG_SAM_FLAGS.KEY_QUERY_VALUE | REG_SAM_FLAGS.KEY_NOTIFY) +const get = regGetValue(0x80000004n, null, 'Global', flags, null) +const query = regQueryValueEx(0x80000004n, 'Global', null) +const getCount: number | null = get.dataSize +const queryCount: number | null = query.dataSize +const borrowed: ReturnType['key'] = 0x80000001n +declare const managed: DynWin32Resource +const alias: DynWin32Resource | bigint | null = regOpenKey(managed, '').key +if (alias !== null && typeof alias !== 'bigint') alias.close() +const ordinary: REG_VALUE_TYPE = REG_VALUE_TYPE.REG_DWORD +const exactOrdinaryMember: 4 = REG_VALUE_TYPE.REG_DWORD +const processInformation = createProcessInformation() +const processOwner: DynWin32Resource | null = takeProcessInformationProcess(processInformation) +const threadOwner: DynWin32Resource | null = takeProcessInformationThread(processInformation) +const processId: number = getProcessInformationProcessId(processInformation) +const threadId: number = getProcessInformationThreadId(processInformation) + +// @ts-expect-error native unavailable output remains nullable +const invalidGetCount: number = get.dataSize +// @ts-expect-error taking an absent native field resource remains nullable +const invalidProcessOwner: DynWin32Resource = takeProcessInformationProcess(processInformation) +// @ts-expect-error native unavailable output remains nullable +const invalidQueryCount: number = query.dataSize +// @ts-expect-error ordinary enums retain their closed member union +const invalidOrdinary: REG_VALUE_TYPE = 2147483647 +// @ts-expect-error flags permit numbers, not arbitrary values +const invalidFlags: REG_SAM_FLAGS = 'read' +"#, + registry = module("Windows.Win32.System.Registry", "Apis"), + access = module("Windows.Win32.System.Registry", "REG_SAM_FLAGS"), + routine = module("Windows.Win32.System.Registry", "REG_ROUTINE_FLAGS"), + value_type = module("Windows.Win32.System.Registry", "REG_VALUE_TYPE"), + file_flags = module("Windows.Win32.Storage.FileSystem", "FILE_FLAGS_AND_ATTRIBUTES"), + files = module("Windows.Win32.Storage.FileSystem", "Apis"), + threading = module("Windows.Win32.System.Threading", "Apis"), + ), + ) + .unwrap(); + fs::write( + scratch.0.join("tsconfig.json"), + r#"{ + "compilerOptions":{ + "noEmit":true,"strict":true,"skipLibCheck":false, + "target":"ES2022","module":"NodeNext","moduleResolution":"NodeNext","types":[] + }, + "include":["**/*.ts"] + }"#, + ) + .unwrap(); + let result = Command::new("node") + .arg(tsc) + .args(["--project"]) + .arg(scratch.0.join("tsconfig.json")) + .output() + .expect("run TypeScript declaration compiler"); + assert!( + node.status.success() && result.status.success(), + "Module loading:\n{}\n{}\nDeclaration compilation:\n{}\n{}", + String::from_utf8_lossy(&node.stdout), + String::from_utf8_lossy(&node.stderr), + String::from_utf8_lossy(&result.stdout), + String::from_utf8_lossy(&result.stderr) + ); +} diff --git a/tools/dynwinrt-codegen/tests/win32_lookup_test.rs b/tools/dynwinrt-codegen/tests/win32_lookup_test.rs new file mode 100644 index 00000000..35d06b9b --- /dev/null +++ b/tools/dynwinrt-codegen/tests/win32_lookup_test.rs @@ -0,0 +1,144 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +use std::{ + fs, + path::{Path, PathBuf}, + sync::atomic::{AtomicU64, Ordering}, +}; + +use dynwinrt_codegen::win32_metadata::{FlatFunctionIndex, has_flat_functions}; +use windows_metadata::{ + MethodAttributes, MethodCallAttributes, MethodImplAttributes, PInvokeAttributes, Signature, + Type, TypeAttributes, writer, +}; + +const NAMESPACE: &str = "Windows.Win32.Routing"; +static NEXT: AtomicU64 = AtomicU64::new(0); + +struct Scratch(PathBuf); + +impl Scratch { + fn new() -> Self { + let path = std::env::temp_dir().join(format!( + "dynwinrt-routing-{}-{}", + std::process::id(), + NEXT.fetch_add(1, Ordering::Relaxed) + )); + fs::create_dir(&path).unwrap(); + Self(path) + } +} + +impl Drop for Scratch { + fn drop(&mut self) { + fs::remove_dir_all(&self.0).unwrap(); + } +} + +fn metadata(path: &Path, imported: bool) { + let mut file = writer::File::new("Routing"); + file.TypeDef( + NAMESPACE, + "Apis", + writer::TypeDefOrRef::default(), + TypeAttributes::Public | TypeAttributes::Sealed, + ); + let method = file.MethodDef( + "GetTickCount", + &Signature { + flags: MethodCallAttributes::default(), + return_type: Type::U32, + types: Vec::new(), + }, + MethodAttributes::Public, + MethodImplAttributes::default(), + ); + if imported { + file.ImplMap( + method, + PInvokeAttributes::CallConvPlatformapi, + "GetTickCount", + "kernel32.dll", + ); + } + file.TypeDef( + NAMESPACE, + "IExample", + writer::TypeDefOrRef::default(), + TypeAttributes::Public | TypeAttributes::Interface | TypeAttributes::Abstract, + ); + file.MethodDef( + "Read", + &Signature { + flags: MethodCallAttributes::HASTHIS, + return_type: Type::I32, + types: Vec::new(), + }, + MethodAttributes::Public | MethodAttributes::Virtual | MethodAttributes::Abstract, + MethodImplAttributes::default(), + ); + fs::write(path, file.into_stream()).unwrap(); +} + +#[test] +fn routing_is_lazy_and_reuses_one_snapshot_without_reopening_files() { + let scratch = Scratch::new(); + let path = scratch.0.join("input.winmd"); + let paths = path.to_str().unwrap(); + let mut index = FlatFunctionIndex::new(paths); + metadata(&path, true); + assert!(index.has_flat_functions(NAMESPACE, "Apis").unwrap()); + fs::remove_file(&path).unwrap(); + for _ in 0..50 { + assert!(!index.has_flat_functions(NAMESPACE, "IExample").unwrap()); + assert!(!index.has_flat_functions(NAMESPACE, "Missing").unwrap()); + assert!(index.has_flat_functions(NAMESPACE, "Apis").unwrap()); + } + assert!( + FlatFunctionIndex::new(paths) + .has_flat_functions(NAMESPACE, "Apis") + .is_err() + ); + metadata(&path, false); + assert!( + !FlatFunctionIndex::new(paths) + .has_flat_functions(NAMESPACE, "Apis") + .unwrap() + ); + assert!(index.has_flat_functions(NAMESPACE, "Apis").unwrap()); +} + +#[test] +fn routing_checks_all_definitions_in_the_loaded_metadata_set() { + let scratch = Scratch::new(); + let first = scratch.0.join("first.winmd"); + let second = scratch.0.join("second.winmd"); + metadata(&first, false); + metadata(&second, true); + let paths = format!("{};{}", first.display(), second.display()); + let mut index = FlatFunctionIndex::new(&paths); + assert!(index.has_flat_functions(NAMESPACE, "Apis").unwrap()); + assert!(!index.has_flat_functions(NAMESPACE, "IExample").unwrap()); + assert!(has_flat_functions(&paths, NAMESPACE, "Apis").unwrap()); +} + +#[test] +fn incomplete_metadata_sets_fail_closed_without_caching_partial_indexes() { + let scratch = Scratch::new(); + let first = scratch.0.join("first.winmd"); + let second = scratch.0.join("second.winmd"); + metadata(&first, true); + fs::write(&second, b"not metadata").unwrap(); + let paths = format!("{};{}", first.display(), second.display()); + let mut index = FlatFunctionIndex::new(&paths); + let error = index.has_flat_functions(NAMESPACE, "Apis").unwrap_err(); + assert!(error.contains("win32.metadata: invalid file")); + metadata(&second, false); + assert!(index.has_flat_functions(NAMESPACE, "Apis").unwrap()); + assert!( + FlatFunctionIndex::new(";") + .has_flat_functions(NAMESPACE, "Apis") + .is_err() + ); +}