maerwald: you can inline a simplified version, the one from handleResultsWinIO, findTempNamePosix is legacy but I hadn't removed it yet as we'll remove it all when winio becomes the only one. but difference is only in what they do with the filePath after it's returned. For that you can call your new CreateFile with AFPP support and then call Win32's hANDLEToHandle again
https://gitlab.haskell.org/ghc/ghc/-/blob/67072c31d8b6ce4f0de79fa52bc3e5cdd5a495c6/libraries/base/System/IO.hs#L501-591