diff --git a/Graphics/Win32/Control.hsc b/Graphics/Win32/Control.hsc
--- a/Graphics/Win32/Control.hsc
+++ b/Graphics/Win32/Control.hsc
@@ -22,7 +22,7 @@
 import System.Win32.Types
 import Graphics.Win32.Message
 
-import Foreign hiding (unsafePerformIO)
+import Foreign
 import System.IO.Unsafe
 
 ##include "windows_cconv.h"
diff --git a/Graphics/Win32/GDI/HDC.hs b/Graphics/Win32/GDI/HDC.hs
--- a/Graphics/Win32/GDI/HDC.hs
+++ b/Graphics/Win32/GDI/HDC.hs
@@ -26,8 +26,21 @@
 
 #include "windows_cconv.h"
 
-----------------------------------------------------------------
+{- Note [Overflow checking and fromIntegral]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+Some windows APIs use the value 0x80000000 to represent failure return
+codes. However, when GHC builds libraries with -XNegativeLiterals
+enabled, it will fail in contexts where the type would suffer from
+signed overflow - such as Int32. (minBound :: Int32 == 0x80000000)
+
+Technically, the frontend is correct that the literal overflows in the
+context it is used in. So instead, we use fromIntegral to convert the
+literal from a Word32 to the necessary type. This isn't any less
+efficient (fromIntegral is optimized away,) and conveys the idea we
+simply want the same representational value.
+-}
+
 setArcDirection :: HDC -> ArcDirection -> IO ArcDirection
 setArcDirection dc dir =
   failIfZero "SetArcDirection" $ c_SetArcDirection dc dir
@@ -142,14 +155,16 @@
 
 setTextCharacterExtra :: HDC -> Int -> IO Int
 setTextCharacterExtra dc extra =
-  failIf (== 0x80000000) "SetTextCharacterExtra" $
+  -- See Note [Overflow checking and fromIntegral]
+  failIf (== fromIntegral (0x80000000 :: Word32)) "SetTextCharacterExtra" $
     c_SetTextCharacterExtra dc extra
 foreign import WINDOWS_CCONV unsafe "windows.h SetTextCharacterExtra"
   c_SetTextCharacterExtra :: HDC ->  Int  -> IO  Int
 
 getTextCharacterExtra :: HDC -> IO Int
 getTextCharacterExtra dc =
-  failIf (== 0x80000000) "GetTextCharacterExtra" $ c_GetTextCharacterExtra dc
+  -- See Note [Overflow checking and fromIntegral]
+  failIf (== fromIntegral (0x80000000 :: Word32)) "GetTextCharacterExtra" $ c_GetTextCharacterExtra dc
 foreign import WINDOWS_CCONV unsafe "windows.h GetTextCharacterExtra"
   c_GetTextCharacterExtra :: HDC -> IO  Int
 
diff --git a/Graphics/Win32/Window.hsc b/Graphics/Win32/Window.hsc
--- a/Graphics/Win32/Window.hsc
+++ b/Graphics/Win32/Window.hsc
@@ -24,7 +24,7 @@
 
 import Control.Monad
 import Data.Maybe
-import Foreign hiding (unsafePerformIO)
+import Foreign
 import System.IO.Unsafe
 
 ##include "windows_cconv.h"
@@ -171,8 +171,10 @@
  , wS_EX_PALETTEWINDOW  = WS_EX_PALETTEWINDOW
  }
 
+
 cW_USEDEFAULT :: Pos
-cW_USEDEFAULT = #{const CW_USEDEFAULT}
+-- See Note [Overflow checking and fromIntegral] in Graphics/Win32/GDI/HDC.hs
+cW_USEDEFAULT = fromIntegral (#{const CW_USEDEFAULT} :: Word32)
 
 type Pos = Int
 
diff --git a/System/Win32/Registry.hsc b/System/Win32/Registry.hsc
--- a/System/Win32/Registry.hsc
+++ b/System/Win32/Registry.hsc
@@ -65,7 +65,7 @@
 import System.Win32.File
 
 import System.IO.Unsafe
-import Foreign hiding (unsafePerformIO)
+import Foreign
 
 ##include "windows_cconv.h"
 
@@ -497,7 +497,7 @@
 regSetStringValue :: HKEY -> String -> String -> IO ()
 regSetStringValue hk key val =
   withTString val $ \ v ->
-  regSetValueEx hk key rEG_SZ v (length val * sizeOf (undefined::TCHAR))
+  regSetValueEx hk key rEG_SZ v ((1+length val) * sizeOf (undefined::TCHAR))
 
 regSetValueEx :: HKEY -> String -> RegValueType -> LPTSTR -> Int -> IO ()
 regSetValueEx key subkey ty value value_len =
diff --git a/System/Win32/Types.hs b/System/Win32/Types.hs
--- a/System/Win32/Types.hs
+++ b/System/Win32/Types.hs
@@ -21,7 +21,7 @@
 	) where
 
 import Data.Maybe
-import Foreign hiding (unsafePerformIO)
+import Foreign
 import Foreign.C
 import Control.Exception
 import System.IO.Error
@@ -238,11 +238,11 @@
 
 ddwordToDwords :: DDWORD -> (DWORD,DWORD)
 ddwordToDwords n =
-        (fromIntegral (n `shiftR` bitSize (undefined::DWORD))
+        (fromIntegral (n `shiftR` finiteBitSize (undefined :: DWORD))
         ,fromIntegral (n .&. fromIntegral (maxBound :: DWORD)))
 
 dwordsToDdword:: (DWORD,DWORD) -> DDWORD
-dwordsToDdword (hi,low) = (fromIntegral low) .|. (fromIntegral hi `shiftL`bitSize hi)
+dwordsToDdword (hi,low) = (fromIntegral low) .|. (fromIntegral hi `shiftL` finiteBitSize hi)
 
 ----------------------------------------------------------------
 -- Primitives
diff --git a/Win32.cabal b/Win32.cabal
--- a/Win32.cabal
+++ b/Win32.cabal
@@ -1,5 +1,5 @@
 name:		Win32
-version:	2.3.0.0
+version:	2.3.0.1
 license:	BSD3
 license-file:	LICENSE
 author:		Alastair Reid
@@ -17,7 +17,7 @@
 	include/Win32Aux.h include/win32debug.h include/windows_cconv.h
 
 Library
-    build-depends:	base >= 3 && < 5, bytestring
+    build-depends:	base >= 4.7 && < 5, bytestring
     ghc-options:    -Wall -fno-warn-name-shadowing
     cc-options:     -fno-strict-aliasing
     exposed-modules:
