-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect usage of PHANDLE type. #61
Comments
Hi, Thanks for the report. While I agree that the type is technically incorrect, as in In case you're passing it to other Win32 functions it should be fine as well as it's an opaque value. We don't pretend to know anything about it in the Haskell world. Whenever #51 gets done I'll make sure to correct this. Unless you want to submit a PR for it to get it done sooner? |
It hasn't been done yet, it's not a correctness issue so it's not particularly high on my to-do list atm I must admit. The handle is being treated as a completely opaque value in Haskell side so we assume nothing about it. |
I posted this issue two years ago, I can recall a bit why I need to represent BOOL WINAPI CreatePipe(
_Out_ PHANDLE hReadPipe,
_Out_ PHANDLE hWritePipe,
_In_opt_ LPSECURITY_ATTRIBUTES lpPipeAttributes,
_In_ DWORD nSize
); In haskell, it should be createPipe :: PHANDLE -> PHANDLE -> LPSECURITY_ATTRIBUTES -> DWORD -> IO Bool This is roughly how we invoke this function: let lpattr = ...
size = ...
(in, out) <- alloca $ \pin ->
alloca $ \pout ->
createPipe pin pout lpattr size
(,) <$> (peek pin) <*> (peek pout) If we represent As what is stated in the description of this issue, I think we might should obey the relation, and difference of types of Win32 API as what they are in their C/C++version, even although they are opaque. |
Move away from Chan to STM
In convension of win32 API,
PHANDLE
means "A pointer to a HANDLE"[1]. However in System/Win32/DebugApi.hscPHANDLE
was wrongly used to represent "process handle". Maybe some more precise tokens such asProcHANDLE
andThreadHandle
can be used to distinguish process handle, thread handle and ordinay handles.I think the type synonym
PHANDLE
should be defined astype PHANDLE = Ptr HANDLE
in System/Win32/Types.hs and should be available after we import the moduleSystem.Win32.Types
and then it can be used directly with some win32 functions likeCreatePipe
.1: https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
The text was updated successfully, but these errors were encountered: