packages feed

Win32 2.1 → 2.1.0.0

raw patch · 20 files changed

+450/−15 lines, 20 filesdep +bytestringsetup-changed

Dependencies added: bytestring

Files

Graphics/Win32/GDI.hs view
@@ -14,6 +14,13 @@ -- ----------------------------------------------------------------------------- +{-# OPTIONS_GHC -w #-}+-- The above warning supression flag is a temporary kludge.+-- While working on this module you are encouraged to remove it and fix+-- any warnings in the module. See+--     http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings+-- for details+ module Graphics.Win32.GDI ( 	module Graphics.Win32.GDI.Bitmap, 	module Graphics.Win32.GDI.Brush,
Graphics/Win32/GDI/Graphics2D.hs view
@@ -86,11 +86,11 @@ foreign import stdcall unsafe "windows.h ArcTo"   c_ArcTo :: HDC -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> Int32 -> IO Bool -angleArc :: HDC -> Int32 -> Int32 -> WORD -> Double -> Double -> IO ()+angleArc :: HDC -> Int32 -> Int32 -> WORD -> Float -> Float -> IO () angleArc dc x y r start sweep =   failIfFalse_ "AngleArc" $ c_AngleArc dc x y r start sweep foreign import stdcall unsafe "windows.h AngleArc"-  c_AngleArc :: HDC -> Int32 -> Int32 -> WORD -> Double -> Double -> IO Bool+  c_AngleArc :: HDC -> Int32 -> Int32 -> WORD -> Float -> Float -> IO Bool  ---------------------------------------------------------------- -- Filled Shapes
Setup.hs view
@@ -1,2 +1,6 @@+module Main (main) where+ import Distribution.Simple-main = defaultMain++main :: IO ()+main = defaultMainWithHooks defaultUserHooks
System/Win32.hs view
@@ -23,6 +23,7 @@ 	, module System.Win32.Registry 	, module System.Win32.Time 	, module System.Win32.Console+	, module System.Win32.Security 	, module System.Win32.Types 	) where @@ -40,6 +41,7 @@ import System.Win32.Time import System.Win32.Console import System.Win32.Types+import System.Win32.Security  ---------------------------------------------------------------- -- End
System/Win32/FileMapping.hsc view
@@ -20,10 +20,11 @@ import System.Win32.File import System.Win32.Info -import Control.Exception    ( block, bracket )-import Data.ByteString.Base ( ByteString(..) )-import Foreign              ( Ptr, nullPtr, plusPtr, maybeWith, FunPtr-                            , ForeignPtr, newForeignPtr )+import Control.Exception        ( block, bracket )+import Data.ByteString          ( ByteString )+import Data.ByteString.Internal ( fromForeignPtr )+import Foreign                  ( Ptr, nullPtr, plusPtr, maybeWith, FunPtr+                                , ForeignPtr, newForeignPtr )  #include "windows.h" @@ -52,7 +53,7 @@ mapFileBs :: FilePath -> IO ByteString mapFileBs p = do     (fp,i) <- mapFile p-    return $ PS fp 0 i+    return $ fromForeignPtr fp 0 i  data MappedObject = MappedObject HANDLE HANDLE FileMapAccess 
System/Win32/Info.hsc view
@@ -104,10 +104,10 @@ 	Left n    -> try loc f n    	Right str -> return str -foreign import ccall unsafe "GetWindowsDirectoryW"+foreign import stdcall unsafe "GetWindowsDirectoryW"   c_getWindowsDirectory :: LPTSTR -> UINT -> IO UINT -foreign import ccall unsafe "GetSystemDirectoryW"+foreign import stdcall unsafe "GetSystemDirectoryW"   c_getSystemDirectory :: LPTSTR -> UINT -> IO UINT  ----------------------------------------------------------------
+ System/Win32/Security.hsc view
@@ -0,0 +1,232 @@+-----------------------------------------------------------------------------+-- |+-- Module      :  System.Win32.Security+-- Copyright   :  (c) Simon Marlow 2007+-- License     :  BSD-style (see the file LICENSE)+--+-- Maintainer  :  Simon Marlow+-- Stability   :  provisional+-- Portability :  portable+--+-- FFI-bindings to interact with Win32 Security+--+-----------------------------------------------------------------------------++{-# OPTIONS_GHC -w #-}+-- The above warning supression flag is a temporary kludge.+-- While working on this module you are encouraged to remove it and fix+-- any warnings in the module. See+--     http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings+-- for details++module System.Win32.Security ( +        -- * Types+        SID, PSID,+        ACL, PACL,+        SECURITY_DESCRIPTOR,++        SECURITY_DESCRIPTOR_CONTROL,+        se_OWNER_DEFAULTED,+        se_GROUP_DEFAULTED,+        se_DACL_PRESENT,+        se_DACL_DEFAULTED,+        se_SACL_PRESENT,+        se_SACL_DEFAULTED,+        se_DACL_AUTO_INHERIT_REQ,+        se_SACL_AUTO_INHERIT_REQ,+        se_DACL_AUTO_INHERITED,+        se_SACL_AUTO_INHERITED,+        se_DACL_PROTECTED,+        se_SACL_PROTECTED,+        se_SELF_RELATIVE,++        SECURITY_INFORMATION,+        oWNER_SECURITY_INFORMATION,+        gROUP_SECURITY_INFORMATION,+        dACL_SECURITY_INFORMATION,+        sACL_SECURITY_INFORMATION,++        -- * Functions+        getFileSecurity,+  ) where++import Foreign+-- import Foreign.C+import System.Win32.Types++#include <windows.h>++-- --------------------------------------------------------------------------+-- Security Descriptors++newtype SECURITY_DESCRIPTOR = SECURITY_DESCRIPTOR SECURITY_DESCRIPTOR+type PSECURITY_DESCRIPTOR = Ptr SECURITY_DESCRIPTOR+newtype SecurityDescriptor = SecurityDescriptor (ForeignPtr SECURITY_DESCRIPTOR)++type SECURITY_DESCRIPTOR_CONTROL = WORD+#{enum SECURITY_DESCRIPTOR_CONTROL,+ , se_OWNER_DEFAULTED       = SE_OWNER_DEFAULTED+ , se_GROUP_DEFAULTED       = SE_GROUP_DEFAULTED+ , se_DACL_PRESENT          = SE_DACL_PRESENT+ , se_DACL_DEFAULTED        = SE_DACL_DEFAULTED+ , se_SACL_PRESENT          = SE_SACL_PRESENT+ , se_SACL_DEFAULTED        = SE_SACL_DEFAULTED+ , se_DACL_AUTO_INHERIT_REQ = SE_DACL_AUTO_INHERIT_REQ+ , se_SACL_AUTO_INHERIT_REQ = SE_SACL_AUTO_INHERIT_REQ+ , se_DACL_AUTO_INHERITED   = SE_DACL_AUTO_INHERITED+ , se_SACL_AUTO_INHERITED   = SE_SACL_AUTO_INHERITED+ , se_DACL_PROTECTED        = SE_DACL_PROTECTED+ , se_SACL_PROTECTED        = SE_SACL_PROTECTED+ , se_SELF_RELATIVE         = SE_SELF_RELATIVE+ }++newtype ACL = ACL ACL   -- abstract+type PACL = Ptr ACL++newtype SID = SID SID+type PSID = Ptr SID++foreign import stdcall unsafe "windows.h GetSecurityDescriptorControl"+  c_getSecurityDescriptorControl+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> Ptr SECURITY_DESCRIPTOR_CONTROL -- pControl+    -> LPDWORD -- lpdwRevision+    -> IO BOOL ++foreign import stdcall unsafe "windows.h GetSecurityDescriptorDacl"+  c_getSecurityDescriptorDacl +    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> LPBOOL -- lpbDaclPresent+    -> Ptr PACL -- pDacl+    -> LPBOOL -- lpbDaclDefaulted+    -> IO BOOL ++foreign import stdcall unsafe "windows.h GetSecurityDescriptorGroup"+  c_getSecurityDescriptorGroup+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> Ptr PSID -- pGroup+    -> LPBOOL -- lpbGroupDefaulted+    -> IO BOOL ++foreign import stdcall unsafe "windows.h GetSecurityDescriptorLength"+  c_getSecurityDescriptorLength+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> IO DWORD ++foreign import stdcall unsafe "windows.h GetSecurityDescriptorOwner"+  c_getSecurityDescriptorOwner+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> Ptr PSID -- pOwner+    -> LPBOOL -- lpbOwnerDefaulted+    -> IO BOOL ++foreign import stdcall unsafe "windows.h GetSecurityDescriptorSacl"+  c_getSecurityDescriptorSacl+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> LPBOOL -- lpbSaclPresent+    -> Ptr PACL -- pSacl+    -> LPBOOL -- lpbSaclDefaulted+    -> IO BOOL ++foreign import stdcall unsafe "windows.h InitializeSecurityDescriptor"+  c_initializeSecurityDescriptor+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> DWORD -- dwRevision+    -> IO BOOL ++foreign import stdcall unsafe "windows.h IsValidSecurityDescriptor"+  c_isValidSecurityDescriptor+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> IO BOOL ++foreign import stdcall unsafe "windows.h SetSecurityDescriptorDacl"+  c_setSecurityDescriptorDacl+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> BOOL -- bDaclPresent+    -> PACL -- pDacl+    -> BOOL -- bDaclDefaulted+    -> IO BOOL ++foreign import stdcall unsafe "windows.h SetSecurityDescriptorGroup"+  c_setSecurityDescriptorGroup+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> PSID -- pGroup+    -> BOOL -- bGroupDefaulted+    -> IO BOOL ++foreign import stdcall unsafe "windows.h SetSecurityDescriptorOwner"+  c_setSecurityDescriptorOwner+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> PSID -- pOwner+    -> BOOL -- bOwnerDefaulted+    -> IO BOOL ++foreign import stdcall unsafe "windows.h SetSecurityDescriptorSacl"+  c_setSecurityDescriptorSacl+    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> BOOL -- bSaclPresent+    -> PACL -- pSacl+    -> BOOL -- bSaclDefaulted+    -> IO BOOL ++-- ---------------------------------------------------------------------------++-- PGENERIC_MAPPING+-- PPRIVILEGE_SET++type SECURITY_INFORMATION = DWORD++#{enum SECURITY_INFORMATION,+ , oWNER_SECURITY_INFORMATION = OWNER_SECURITY_INFORMATION+ , gROUP_SECURITY_INFORMATION = GROUP_SECURITY_INFORMATION+ , dACL_SECURITY_INFORMATION = DACL_SECURITY_INFORMATION+ , sACL_SECURITY_INFORMATION = SACL_SECURITY_INFORMATION+ }+-- , pROTECTED_DACL_SECURITY_INFORMATION = PROTECTED_DACL_SECURITY_INFORMATION+-- , pROTECTED_SACL_SECURITY_INFORMATION = PROTECTED_SACL_SECURITY_INFORMATION+-- , uNPROTECTED_DACL_SECURITY_INFORMATION = UNPROTECTED_DACL_SECURITY_INFORMATION+-- , uNPROTECTED_SACL_SECURITY_INFORMATION = UNPROTECTED_SACL_SECURITY_INFORMATION ++getFileSecurity+    :: String+    -> SECURITY_INFORMATION+    -> IO SecurityDescriptor+getFileSecurity filename si =+  withTString filename $ \lpFileName ->+  with 0 $ \lpnLengthNeeded -> do+  c_GetFileSecurity lpFileName si nullPtr 0 lpnLengthNeeded+  needed <- peek lpnLengthNeeded+  fpSd <- mallocForeignPtrBytes (fromIntegral needed)+  withForeignPtr fpSd $ \pSd -> do+  failIfFalse_ "getFileSecurity" $ +    c_GetFileSecurity lpFileName si pSd needed lpnLengthNeeded+  return (SecurityDescriptor fpSd)++foreign import stdcall unsafe "windows.h GetFileSecurityW"+  c_GetFileSecurity+    :: LPCWSTR -- lpFileName+    -> SECURITY_INFORMATION -- RequestedInformation+    -> PSECURITY_DESCRIPTOR -- pSecurityDescriptor+    -> DWORD -- nLength+    -> LPDWORD -- lpnLengthNeeded+    -> IO BOOL ++--foreign import stdcall unsafe "windows.h AccessCheck"+--  c_AccessCheck+--    :: PSECURITY_DESCRIPTOR -- pSecurityDescriptor+--    -> HANDLE -- ClientToken+--    -> DWORD -- DesiredAccess+--    -> PGENERIC_MAPPING -- GenericMapping+--    -> PPRIVILEGE_SET -- PrivilegeSet+--    -> LPDWORD -- PrivilegeSetLength+--    -> LPDWORD -- GrantedAccess+--    -> LPBOOL -- AccessStatus+--    -> IO BOOL++-- foreign import stdcall unsafe "windows.h OpenThreadToken"+--    OpenThreadToken+--      :: HANDLE -- ThreadHandle+--      -> DWORD -- DesiredAccess+--      -> BOOL -- OpenAsSelf+--      -> PHANDLE -- TokenHandle+--      -> IO BOOL
System/Win32/Types.hs view
@@ -32,6 +32,7 @@  type BOOL          = Bool type BYTE          = Word8+type UCHAR         = CUChar type USHORT        = Word16 type UINT          = Word32 type INT           = Int32@@ -64,7 +65,10 @@ type Addr          = Ptr ()  type LPVOID        = Ptr ()+type LPBOOL        = Ptr BOOL type LPBYTE        = Ptr BYTE+type PUCHAR        = Ptr UCHAR+type LPDWORD       = Ptr DWORD type LPSTR         = Ptr CChar type LPCSTR        = LPSTR type LPWSTR        = Ptr CWchar@@ -126,7 +130,7 @@ type   ForeignHANDLE = ForeignPtr ()  newForeignHANDLE :: HANDLE -> IO ForeignHANDLE-newForeignHANDLE = newForeignPtr deleteObject_p+newForeignHANDLE = newForeignPtr deleteObjectFinaliser  handleToWord :: HANDLE -> UINT handleToWord = castPtrToUINT@@ -216,8 +220,9 @@ -- Primitives ---------------------------------------------------------------- -foreign import stdcall unsafe "windows.h &DeleteObject"-  deleteObject_p :: FunPtr (HANDLE -> IO ())+{-# CFILES cbits/HsWin32.c #-}+foreign import ccall "HsWin32.h &DeleteObjectFinaliser"+  deleteObjectFinaliser :: FunPtr (Ptr a -> IO ())  foreign import stdcall unsafe "windows.h LocalFree"   localFree :: Ptr a -> IO (Ptr a)
Win32.cabal view
@@ -1,5 +1,5 @@ name:		Win32-version:	2.1+version:	2.1.0.0 license:	BSD3 license-file:	LICENSE author:		Alastair Reid@@ -7,7 +7,11 @@ maintainer:	Esa Ilari Vuokko <ei@vuokko.info> category:	System, Graphics synopsis:	A binding to part of the Win32 library-build-depends:	base+build-type: Configure+extra-source-files:+	include/diatemp.h include/dumpBMP.h include/ellipse.h include/errors.h+	include/gettime.h include/Win32Aux.h include/win32debug.h+build-depends:	base, bytestring ghc-options:    -O -fvia-C -Wall -fno-warn-name-shadowing exposed-modules: 	Graphics.Win32.GDI,@@ -45,12 +49,14 @@ 	System.Win32.SimpleMAPI, 	System.Win32.Time, 	System.Win32.Console,+	System.Win32.Security, 	System.Win32.Types extensions: ForeignFunctionInterface extra-libraries: 	"user32", "gdi32", "winmm", "kernel32", "advapi32" include-dirs: 	include includes:	"HsWin32.h", "HsGDI.h", "WndProc.h"+install-includes:	"HsWin32.h", "HsGDI.h", "WndProc.h" c-sources: 	cbits/HsGDI.c, 	cbits/HsWin32.c,
cbits/HsWin32.c view
@@ -13,3 +13,7 @@ void FreeLibraryFinaliser(HMODULE m) {     FreeLibrary(m); }++void DeleteObjectFinaliser(HGDIOBJ h) {+    DeleteObject(h);+}
+ include/HsGDI.h view
@@ -0,0 +1,42 @@+#ifndef __HSGDI_H+#define __HSGDI_H++#include <windows.h>++#ifndef INLINE+# if defined(_MSC_VER)+#  define INLINE extern __inline+# else+#  define INLINE extern inline+# endif+#endif++INLINE COLORREF rgb(BYTE r, BYTE g, BYTE b) { return RGB(r, g, b); }+INLINE BYTE getRValue(COLORREF color) { return GetRValue(color); }+INLINE BYTE getGValue(COLORREF color) { return GetGValue(color); }+INLINE BYTE getBValue(COLORREF color) { return GetBValue(color); }++INLINE COLORREF pALETTERGB(BYTE r, BYTE g, BYTE b) {+  return PALETTERGB(r, g, b);+}+INLINE COLORREF pALETTEINDEX(WORD w) {+  return PALETTEINDEX(w);+}++#ifdef __WINE_WINDOWS_H+INLINE UINT mAKEROP4(UINT op1, UINT op2) { return 0; }+#else+INLINE UINT mAKEROP4(UINT op1, UINT op2) { return MAKEROP4(op1, op2); }+#endif++INLINE UINT prim_MenuItemFromPoint(HWND wnd, HMENU menu, LPPOINT p_pt) {+  return MenuItemFromPoint(wnd, menu, *p_pt);+}+INLINE HWND prim_ChildWindowFromPoint(HWND parent, LPPOINT p_pt) {+  return ChildWindowFromPoint(parent, *p_pt);+}+INLINE HWND prim_ChildWindowFromPointEx(HWND parent, LPPOINT p_pt, UINT flags) {+  return ChildWindowFromPointEx(parent, *p_pt, flags);+}++#endif /* __HSGDI_H */
+ include/HsWin32.h view
@@ -0,0 +1,47 @@+#ifndef __HSWIN32_H+#define __HSWIN32_H++#include <windows.h>++#ifndef INLINE+# if defined(_MSC_VER)+#  define INLINE extern __inline+# else+#  define INLINE extern inline+# endif+#endif++INLINE UINT castPtrToUINT(void *p) { return (UINT)p; }+INLINE void *castUINTToPtr(UINT n) { return (void *)n; }+INLINE LONG castFunPtrToLONG(void *p) { return (LONG)p; }+INLINE WORD hIWORD(DWORD w) { return HIWORD(w); }+INLINE WORD lOWORD(DWORD w) { return LOWORD(w); }++INLINE LANGID prim_LANGIDFROMLCID(LCID id) {+  return LANGIDFROMLCID(id);+}+INLINE LANGID prim_MAKELANGID(LANGID primary, LANGID sub) {+  return MAKELANGID(primary, sub);+}+INLINE LCID prim_MAKELCID(LANGID id, WORD sort) {+  return MAKELCID(id, sort);+}+INLINE LANGID prim_PRIMARYLANGID(LANGID id) {+  return PRIMARYLANGID(id);+}+INLINE LANGID prim_SUBLANGID(LCID id) {+  return SUBLANGID(id);+}+INLINE WORD prim_SORTIDFROMLCID(LCID id) {+  return SORTIDFROMLCID(id);+}++void UnmapViewOfFileFinaliser(void *);++void CloseHandleFinaliser(HANDLE);++void FreeLibraryFinaliser(HMODULE);++void DeleteObjectFinaliser(HGDIOBJ);++#endif /* __HSWIN32_H */
+ include/Win32Aux.h view
@@ -0,0 +1,3 @@+/* We define OEMRESOURCE so that we can get the OBM_ constants */++#define OEMRESOURCE
+ include/WndProc.h view
@@ -0,0 +1,8 @@+#ifndef __WNDPROC_H+#define __WNDPROC_H++#include <windows.h>++extern LRESULT CALLBACK genericWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);++#endif /* __WNDPROC_H */
+ include/diatemp.h view
@@ -0,0 +1,30 @@+#ifndef _DIATEMP_H_+#define _DIATEMP_H_++#include <windows.h>++typedef struct {+  LPDLGTEMPLATE dtemplate;+  unsigned int bytes_left; /* bytes left in the chunk that 'dtemplate' points to. */+  unsigned int bytes_alloced;+  LPDLGITEMTEMPLATE next_dia_item;+} DIA_TEMPLATE;++extern LPDLGTEMPLATE getFinalDialog(DIA_TEMPLATE* dt);++extern DIA_TEMPLATE* mkDiaTemplate+      ( UINT size, int x, int y, int cx, int cy+      , DWORD style, DWORD exstyle+      , LPCWSTR menu, LPCWSTR class+      , LPCWSTR caption, LPCWSTR font+      , int height+      );+extern DIA_TEMPLATE* addDiaControl+         ( DIA_TEMPLATE* dia+	 , LPCWSTR text, short id+	 , LPCWSTR classname, DWORD style+	 , int x, int y, int cx, int cy+	 , DWORD exstyle+	 );++#endif
+ include/dumpBMP.h view
@@ -0,0 +1,6 @@+#include <windows.h>++/* There's currently no #define that indicate whether we're+   compiling a .hc file. */++extern void CreateBMPFile(LPCSTR pszFileName, HBITMAP hBmp, HDC hDC);
+ include/ellipse.h view
@@ -0,0 +1,8 @@+#ifndef __ELLIPSE_H+#define __ELLIPSE_H++#include <windows.h>++extern int transformedEllipse(HDC, LONG, LONG, LONG, LONG, LONG, LONG);++#endif /* __ELLIPSE_H */
+ include/errors.h view
@@ -0,0 +1,16 @@+#ifndef _MY_ERRORS_H+#define _MY_ERRORS_H++#include <windows.h>++/* There's two ways we can generate error messages - with different tradeoffs:+ * If we do a function call, we have to use a static buffer.+ * If we use a macro and ANSI C's string splicing, we have to use constant+ * strings - and accept a certain amount of overhead from inserting the+ * boilerplate text.+ */++/* result should be freed using LocalFree */+extern LPTSTR getErrorMessage(DWORD err);++#endif /* _MY_ERRORS_H */
+ include/gettime.h view
@@ -0,0 +1,5 @@+#include <windows.h>++/* Prototype missing from Cygwin B20.1 */++extern DWORD WINAPI timeGetTime();
+ include/win32debug.h view
@@ -0,0 +1,9 @@+#ifndef __WIN32_LIB_DEBUG_H+/* prefix WIN32_LIB to give it a better chance of being unique */+#define __WIN32_LIB_DEBUG_H++#if  defined(TARGET_GHC) && defined(WIN32_LIB_DEBUG)+extern char* __current_fun__;+#endif++#endif /* __WIN32_LIB_DEBUG_H */