Repository navigation
Conversation
win64 getapi() runs on the libffi backend (lffi.pas), where a 'p' argument is a raw pointer value. `var h` therefore passed h's value (0) as phAlgorithm, so BCryptOpenAlgorithmProvider returned STATUS_INVALID_PARAMETER (0xC000000D) and every SHA384/512 hash failed. Pass the address of an 8-byte buffer instead and read the handle back with a pointer-width little-endian helper (the same _zr idiom as lib-ado-unx.fun). Also: - gate CNG on host.bits >= 64; 32-bit Windows keeps the CryptoAPI path, whose winapi.pas 'p' means "address of this value"; - use the real signatures 'pppi:i' / 'pi:i' / 'ppipipi:i' and pass the UTF-16 name by address; - terminate the UTF-16 name with two NUL bytes; - pass a non-NULL pointer for an empty message, which CNG rejects. Verified on Linux with a fake bcrypt: `var h` returned -1073741811 while the buffer form opened, hashed and closed with a full 64-bit handle.
win32's winapi.pas has always passed the address of the value for a 'p' argument, so `var x` is the natural way to receive an OUT handle. lffi (Unix and win64) sent the numeric value instead, silently handing the callee 0/NULL; the auth SHA384/512 path hit this as an unknown NTSTATUS. For a CRef argument with a 'p' parameter, allocate a pointer-width scratch cell, pass its address, and copy the result back into the referenced variable after the call. String and object targets keep their existing handling, and the explicit raw-address idiom (buf.toNum(-1)) is unchanged. Cover it with setout/addout in the FFI helper and a ffi-var-ref.fun snapshot that runs on Linux/macOS and the win64 runner.
The win64 job restored a cached libffitest.dll built before setout/addout existed, so ffi-var-ref.fun failed with 'symbol not found'. Include the C source hash in the cache key so adding an export rebuilds the DLL, and list the new symbols in the build diagnostic.
funlang
approved these changes
Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.