]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/nt-base.c
(no commit message)
[imagemagick] / MagickCore / nt-base.c
index 38a00aa4f2d6e30900fb928888aca3d45d798af5..d9414bd7664979043df5921f2b98df012e03d8c2 100644 (file)
@@ -17,7 +17,7 @@
 %                                December 1996                                %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
 #include "MagickCore/studio.h"
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
 #include "MagickCore/client.h"
+#include "MagickCore/exception-private.h"
 #include "MagickCore/locale_.h"
 #include "MagickCore/log.h"
 #include "MagickCore/magick.h"
 #include "MagickCore/memory_.h"
+#include "MagickCore/nt-base.h"
+#include "MagickCore/nt-base-private.h"
 #include "MagickCore/resource_.h"
+#include "MagickCore/resource-private.h"
 #include "MagickCore/timer.h"
 #include "MagickCore/string_.h"
 #include "MagickCore/utility.h"
@@ -53,7 +57,7 @@
 #if defined(MAGICKCORE_LTDL_DELEGATE)
 #  include "ltdl.h"
 #endif
-#include "MagickCore/nt-base.h"
+#include "MagickCore/nt-base-private.h"
 #if defined(MAGICKCORE_CIPHER_SUPPORT)
 #include <ntsecapi.h>
 #include <wincrypt.h>
@@ -229,7 +233,7 @@ BOOL WINAPI DllMain(HINSTANCE handle,DWORD reason,LPVOID lpvReserved)
 %      process.
 %
 */
-MagickExport int Exit(int status)
+MagickPrivate int Exit(int status)
 {
   if (IsWindows95())
     TerminateProcess(GetCurrentProcess(),(unsigned int) status);
@@ -262,7 +266,7 @@ MagickExport int Exit(int status)
 %    o time_zone: the time zone.
 %
 */
-MagickExport int gettimeofday (struct timeval *time_value,
+MagickPrivate int gettimeofday (struct timeval *time_value,
   struct timezone *time_zone)
 {
 #define EpochFiletime  MagickLLConstant(116444736000000000)
@@ -322,7 +326,7 @@ MagickExport int gettimeofday (struct timeval *time_value,
 %      int IsWindows95()
 %
 */
-MagickExport int IsWindows95()
+MagickPrivate int IsWindows95()
 {
   OSVERSIONINFO
     version_info;
@@ -339,6 +343,65 @@ MagickExport int IsWindows95()
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   N T A r g v T o U T F 8                                                   %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  NTArgvToUTF8() converts the wide command line arguments to UTF-8 to ensure
+%  compatibility with Linux.
+%
+%  The format of the NTArgvToUTF8 method is:
+%
+%      char **NTArgvToUTF8(const int argc,wchar_t **argv)
+%
+%  A description of each parameter follows:
+%
+%    o argc: the number of command line arguments.
+%
+%    o argv:  the  wide-character command line arguments.
+%
+*/
+MagickPrivate char **NTArgvToUTF8(const int argc,wchar_t **argv)
+{
+  char
+    **utf8;
+
+  ssize_t
+    i;
+
+  utf8=(char **) AcquireQuantumMemory(argc,sizeof(*utf8));
+  if (utf8 == (char **) NULL)
+    ThrowFatalException(ResourceLimitFatalError,"UnableToConvertStringToARGV");
+  for (i=0; i < (ssize_t) argc; i++)
+  {
+    ssize_t
+      count;
+
+    count=WideCharToMultiByte(CP_UTF8,0,argv[i],-1,NULL,0,NULL,NULL);
+    if (count < 0)
+      count=0;
+    utf8[i]=(char *) AcquireQuantumMemory(count+1,sizeof(**utf8));
+    if (utf8[i] == (char *) NULL)
+      {
+        for (i--; i >= 0; i--)
+          utf8[i]=DestroyString(utf8[i]);
+        utf8=(char **) RelinquishMagickMemory(utf8);
+        ThrowFatalException(ResourceLimitFatalError,
+          "UnableToConvertStringToARGV");
+      }
+    count=WideCharToMultiByte(CP_UTF8,0,argv[i],-1,utf8[i],count,NULL,NULL);
+    utf8[i][count]=0;
+  }
+  return(utf8);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   N T C l o s e D i r e c t o r y                                           %
 %                                                                             %
 %                                                                             %
@@ -357,7 +420,7 @@ MagickExport int IsWindows95()
 %    o entry: Specifies a pointer to a DIR structure.
 %
 */
-MagickExport int NTCloseDirectory(DIR *entry)
+MagickPrivate int NTCloseDirectory(DIR *entry)
 {
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
   assert(entry != (DIR *) NULL);
@@ -388,7 +451,7 @@ MagickExport int NTCloseDirectory(DIR *entry)
 %    o handle: Specifies a handle to a previously loaded dynamic module.
 %
 */
-MagickExport int NTCloseLibrary(void *handle)
+MagickPrivate int NTCloseLibrary(void *handle)
 {
   if (IsWindows95())
     return(FreeLibrary((HINSTANCE) handle));
@@ -422,7 +485,7 @@ static BOOL ControlHandler(DWORD type)
   return(FALSE);
 }
 
-MagickExport int NTControlHandler(void)
+MagickPrivate int NTControlHandler(void)
 {
   return(SetConsoleCtrlHandler((PHANDLER_ROUTINE) ControlHandler,TRUE));
 }
@@ -446,7 +509,7 @@ MagickExport int NTControlHandler(void)
 %      double NTElapsedTime(void)
 %
 */
-MagickExport double NTElapsedTime(void)
+MagickPrivate double NTElapsedTime(void)
 {
   union
   {
@@ -493,7 +556,7 @@ MagickExport double NTElapsedTime(void)
 %    o description: Specifies any description to the reason.
 %
 */
-MagickExport void NTErrorHandler(const ExceptionType severity,
+MagickPrivate void NTErrorHandler(const ExceptionType severity,
   const char *reason,const char *description)
 {
   char
@@ -546,7 +609,7 @@ MagickExport void NTErrorHandler(const ExceptionType severity,
 %      int NTExitLibrary(void)
 %
 */
-MagickExport int NTExitLibrary(void)
+MagickPrivate int NTExitLibrary(void)
 {
   return(0);
 }
@@ -576,7 +639,7 @@ MagickExport int NTExitLibrary(void)
 %    random: the random data is returned here.
 %
 */
-MagickExport MagickBooleanType NTGatherRandomData(const size_t length,
+MagickPrivate MagickBooleanType NTGatherRandomData(const size_t length,
   unsigned char *random)
 {
 #if defined(MAGICKCORE_CIPHER_SUPPORT) && defined(_MSC_VER) && (_MSC_VER > 1200)
@@ -634,7 +697,7 @@ MagickExport MagickBooleanType NTGatherRandomData(const size_t length,
 %    o extent: the maximum extent of the path.
 %
 */
-MagickExport MagickBooleanType NTGetExecutionPath(char *path,
+MagickPrivate MagickBooleanType NTGetExecutionPath(char *path,
   const size_t extent)
 {
   GetModuleFileName(0,path,(DWORD) extent);
@@ -703,7 +766,7 @@ char *NTGetLastError(void)
 %      const char *NTGetLibraryError(void)
 %
 */
-MagickExport const char *NTGetLibraryError(void)
+MagickPrivate const char *NTGetLibraryError(void)
 {
   static char
     last_error[MaxTextExtent];
@@ -779,7 +842,7 @@ void *NTGetLibrarySymbol(void *handle,const char *name)
 %    path: the module path is returned here.
 %
 */
-MagickExport MagickBooleanType NTGetModulePath(const char *module,char *path)
+MagickPrivate MagickBooleanType NTGetModulePath(const char *module,char *path)
 {
   char
     module_path[MaxTextExtent];
@@ -826,7 +889,7 @@ MagickExport MagickBooleanType NTGetModulePath(const char *module,char *path)
 %
 */
 
-static int NTGetRegistryValue(HKEY root,const char *key,const char *name,
+static int NTGetRegistryValue(HKEY root,const char *key,DWORD flags,const char *name,
   char *value,int *length)
 {
   BYTE
@@ -846,7 +909,7 @@ static int NTGetRegistryValue(HKEY root,const char *key,const char *name,
   /*
     Get a registry value: key = root\\key, named value = name.
   */
-  if (RegOpenKeyExA(root,key,0,KEY_READ,&hkey) != ERROR_SUCCESS)
+  if (RegOpenKeyExA(root,key,0,KEY_READ | flags,&hkey) != ERROR_SUCCESS)
     return(1);  /* no match */
   p=(BYTE *) value;
   type=REG_SZ;
@@ -868,7 +931,7 @@ static int NTGetRegistryValue(HKEY root,const char *key,const char *name,
   return(1);  /* not found */
 }
 
-static int NTLocateGhostscript(const char **product_family,int *major_version,
+static int NTLocateGhostscript(DWORD flags,const char **product_family,int *major_version,
   int *minor_version)
 {
   int
@@ -907,10 +970,7 @@ static int NTLocateGhostscript(const char **product_family,int *major_version,
 
     (void) FormatLocaleString(key,MaxTextExtent,"SOFTWARE\\%s",products[i]);
     root=HKEY_LOCAL_MACHINE;
-    mode=KEY_READ;
-#if defined(KEY_WOW64_32KEY)
-    mode|=KEY_WOW64_32KEY;
-#endif
+    mode=KEY_READ | flags;
     if (RegOpenKeyExA(root,key,0,mode,&hkey) == ERROR_SUCCESS)
       {
         DWORD
@@ -955,7 +1015,17 @@ static int NTLocateGhostscript(const char **product_family,int *major_version,
   return(status);
 }
 
-static int NTGhostscriptGetString(const char *name,char *value,
+static BOOL NTIs64BitPlatform()
+{
+#if defined(_WIN64) || !defined(KEY_WOW64_32KEY)
+  return(TRUE);
+#else
+  BOOL is64=FALSE;
+  return(IsWow64Process(GetCurrentProcess(), &is64) && is64);
+#endif
+}
+
+static int NTGhostscriptGetString(const char *name,BOOL *is_64_bit,char *value,
   const size_t length)
 {
   char
@@ -968,7 +1038,11 @@ static int NTGhostscriptGetString(const char *name,char *value,
   static const char
     *product_family = (const char *) NULL;
 
+  static BOOL
+    is_64_bit_version = FALSE;
+
   static int
+    flags=0,
     major_version=0,
     minor_version=0;
 
@@ -989,9 +1063,37 @@ static int NTGhostscriptGetString(const char *name,char *value,
   /*
     Get a string from the installed Ghostscript.
   */
+  if (is_64_bit!=NULL)
+    *is_64_bit=FALSE;
   *value='\0';
   if (product_family == NULL)
-    (void) NTLocateGhostscript(&product_family,&major_version,&minor_version);
+  {
+    flags=0;
+#if defined(KEY_WOW64_32KEY)
+    flags=NTIs64BitPlatform() ? KEY_WOW64_64KEY : 0;
+#endif
+    (void) NTLocateGhostscript(flags,&product_family,&major_version,
+      &minor_version);
+    if (product_family == NULL)
+    {
+      if (flags!=0)
+      {
+        /*
+          We are running on a 64 bit platform - check for a 32 bit Ghostscript.
+        */
+        flags=0;
+#if defined(KEY_WOW64_32KEY)
+        flags=KEY_WOW64_32KEY;
+#endif
+        (void) NTLocateGhostscript(flags,&product_family,&major_version,
+          &minor_version);
+         }
+    }
+    else
+      is_64_bit_version=NTIs64BitPlatform();
+  }
+  if (is_64_bit!=NULL)
+    *is_64_bit=is_64_bit_version;
   if (product_family == NULL)
     return(FALSE);
   (void) FormatLocaleString(key,MaxTextExtent,"SOFTWARE\\%s\\%d.%02d",
@@ -999,7 +1101,7 @@ static int NTGhostscriptGetString(const char *name,char *value,
   for (i=0; i < (ssize_t) (sizeof(hkeys)/sizeof(hkeys[0])); i++)
   {
     extent=(int) length;
-    if (NTGetRegistryValue(hkeys[i].hkey,key,name,value,&extent) == 0)
+    if (NTGetRegistryValue(hkeys[i].hkey,key,flags,name,value,&extent) == 0)
       {
         (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
           "registry: \"%s\\%s\\%s\"=\"%s\"",hkeys[i].name,key,name,value);
@@ -1011,15 +1113,26 @@ static int NTGhostscriptGetString(const char *name,char *value,
   return(FALSE);
 }
 
-MagickExport int NTGhostscriptDLL(char *path,int length)
+MagickPrivate int NTGhostscriptDLL(char *path,int length)
 {
   static char
     dll[MaxTextExtent] = { "" };
 
+  static BOOL
+    is_64_bit_version;
+
   *path='\0';
   if ((*dll == '\0') &&
-      (NTGhostscriptGetString("GS_DLL",dll,sizeof(dll)) == FALSE))
+      (NTGhostscriptGetString("GS_DLL",&is_64_bit_version,dll,sizeof(dll)) == FALSE))
     return(FALSE);
+
+#if defined(_WIN64)
+  if (!is_64_bit_version)
+    return(FALSE);
+#else
+  if (is_64_bit_version)
+    return(FALSE);
+#endif
   (void) CopyMagickString(path,dll,length);
   return(TRUE);
 }
@@ -1045,7 +1158,7 @@ MagickExport int NTGhostscriptDLL(char *path,int length)
 %      const GhostInfo *NTGhostscriptDLLVectors(void)
 %
 */
-MagickExport const GhostInfo *NTGhostscriptDLLVectors(void)
+MagickPrivate const GhostInfo *NTGhostscriptDLLVectors(void)
 {
   if (NTGhostscriptLoadDLL() == FALSE)
     return((GhostInfo *) NULL);
@@ -1078,7 +1191,7 @@ MagickExport const GhostInfo *NTGhostscriptDLLVectors(void)
 %    o length: length of buffer.
 %
 */
-MagickExport int NTGhostscriptEXE(char *path,int length)
+MagickPrivate int NTGhostscriptEXE(char *path,int length)
 {
   register char
     *p;
@@ -1086,16 +1199,19 @@ MagickExport int NTGhostscriptEXE(char *path,int length)
   static char
     program[MaxTextExtent] = { "" };
 
+  static BOOL
+    is_64_bit_version = FALSE;
+
   (void) CopyMagickString(path,"gswin32c.exe",length);
   if ((*program == '\0') &&
-      (NTGhostscriptGetString("GS_DLL",program,sizeof(program)) == FALSE))
+      (NTGhostscriptGetString("GS_DLL",&is_64_bit_version,program,sizeof(program)) == FALSE))
     return(FALSE);
   p=strrchr(program,'\\');
   if (p != (char *) NULL)
     {
       p++;
       *p='\0';
-      (void) ConcatenateMagickString(program,"gswin32c.exe",sizeof(program));
+      (void) ConcatenateMagickString(program,is_64_bit_version ? "gswin64c.exe" : "gswin32c.exe",sizeof(program));
     }
   (void) CopyMagickString(path,program,length);
   return(TRUE);
@@ -1126,7 +1242,7 @@ MagickExport int NTGhostscriptEXE(char *path,int length)
 %    o length: length of the path buffer.
 %
 */
-MagickExport int NTGhostscriptFonts(char *path,int length)
+MagickPrivate int NTGhostscriptFonts(char *path,int length)
 {
   char
     buffer[MaxTextExtent],
@@ -1137,7 +1253,7 @@ MagickExport int NTGhostscriptFonts(char *path,int length)
     *q;
 
   *path='\0';
-  if (NTGhostscriptGetString("GS_LIB",buffer,MaxTextExtent) == FALSE)
+  if (NTGhostscriptGetString("GS_LIB",NULL,buffer,MaxTextExtent) == FALSE)
     return(FALSE);
   for (p=buffer-1; p != (char *) NULL; p=strchr(p+1,DirectoryListSeparator))
   {
@@ -1172,7 +1288,7 @@ MagickExport int NTGhostscriptFonts(char *path,int length)
 %      int NTGhostscriptLoadDLL(void)
 %
 */
-MagickExport int NTGhostscriptLoadDLL(void)
+MagickPrivate int NTGhostscriptLoadDLL(void)
 {
   char
     path[MaxTextExtent];
@@ -1221,7 +1337,7 @@ MagickExport int NTGhostscriptLoadDLL(void)
 %      int NTGhostscriptUnLoadDLL(void)
 %
 */
-MagickExport int NTGhostscriptUnLoadDLL(void)
+MagickPrivate int NTGhostscriptUnLoadDLL(void)
 {
   int
     status;
@@ -1252,7 +1368,7 @@ MagickExport int NTGhostscriptUnLoadDLL(void)
 %      int NTInitializeLibrary(void)
 %
 */
-MagickExport int NTInitializeLibrary(void)
+MagickPrivate int NTInitializeLibrary(void)
 {
   return(0);
 }
@@ -1272,11 +1388,11 @@ MagickExport int NTInitializeLibrary(void)
 %
 %  The format of the NTMapMemory method is:
 %
-%    MagickExport void *NTMapMemory(char *address,size_t length,int protection,
+%    MagickPrivate void *NTMapMemory(char *address,size_t length,int protection,
 %      int access,int file,MagickOffsetType offset)
 %
 */
-MagickExport void *NTMapMemory(char *address,size_t length,int protection,
+MagickPrivate void *NTMapMemory(char *address,size_t length,int protection,
   int flags,int file,MagickOffsetType offset)
 {
   DWORD
@@ -1361,7 +1477,7 @@ MagickExport void *NTMapMemory(char *address,size_t length,int protection,
 %    o entry: Specifies a pointer to a DIR structure.
 %
 */
-MagickExport DIR *NTOpenDirectory(const char *path)
+MagickPrivate DIR *NTOpenDirectory(const char *path)
 {
   char
     file_specification[MaxTextExtent];
@@ -1438,7 +1554,7 @@ static const char *GetSearchPath( void )
 #endif
 }
 
-MagickExport void *NTOpenLibrary(const char *filename)
+MagickPrivate void *NTOpenLibrary(const char *filename)
 {
 #define MaxPathElements  31
 
@@ -1519,7 +1635,7 @@ MagickExport void *NTOpenLibrary(const char *filename)
 %    o entry: Specifies a pointer to a DIR structure.
 %
 */
-MagickExport struct dirent *NTReadDirectory(DIR *entry)
+MagickPrivate struct dirent *NTReadDirectory(DIR *entry)
 {
   int
     status;
@@ -1561,7 +1677,8 @@ MagickExport struct dirent *NTReadDirectory(DIR *entry)
 %  may coexist.
 %
 %  Values are stored in the registry under a base path path similar to
-%  "HKEY_LOCAL_MACHINE/SOFTWARE\ImageMagick\5.5.7\Q:16". The provided subkey
+%  "HKEY_LOCAL_MACHINE/SOFTWARE\ImageMagick\6.7.4\Q:16" or
+%  "HKEY_CURRENT_USER/SOFTWARE\ImageMagick\6.7.4\Q:16". The provided subkey
 %  is appended to this base path to form the full key.
 %
 %  The format of the NTRegistryKeyLookup method is:
@@ -1575,7 +1692,7 @@ MagickExport struct dirent *NTReadDirectory(DIR *entry)
 %      "LibPath", "CoderModulesPath", "FilterModulesPath", "SharePath".
 %
 */
-MagickExport unsigned char *NTRegistryKeyLookup(const char *subkey)
+MagickPrivate unsigned char *NTRegistryKeyLookup(const char *subkey)
 {
   char
     package_key[MaxTextExtent];
@@ -1601,6 +1718,9 @@ MagickExport unsigned char *NTRegistryKeyLookup(const char *subkey)
   (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),"%s",package_key);
   registry_key=(HKEY) INVALID_HANDLE_VALUE;
   status=RegOpenKeyExA(HKEY_LOCAL_MACHINE,package_key,0,KEY_READ,&registry_key);
+  if (status != ERROR_SUCCESS)
+    status=RegOpenKeyExA(HKEY_CURRENT_USER,package_key,0,KEY_READ,
+      &registry_key);
   if (status != ERROR_SUCCESS)
     {
       registry_key=(HKEY) INVALID_HANDLE_VALUE;
@@ -1659,7 +1779,7 @@ MagickExport unsigned char *NTRegistryKeyLookup(const char *subkey)
 %    o error: MagickTrue the event is an error.
 %
 */
-MagickExport MagickBooleanType NTReportEvent(const char *event,
+MagickPrivate MagickBooleanType NTReportEvent(const char *event,
   const MagickBooleanType error)
 {
   const char
@@ -1706,7 +1826,7 @@ MagickExport MagickBooleanType NTReportEvent(const char *event,
 %    o id: Specifies a string that identifies the resource.
 %
 */
-MagickExport unsigned char *NTResourceToBlob(const char *id)
+MagickPrivate unsigned char *NTResourceToBlob(const char *id)
 {
   char
     path[MaxTextExtent];
@@ -1788,7 +1908,7 @@ MagickExport unsigned char *NTResourceToBlob(const char *id)
 %      stream.
 %
 */
-MagickExport void NTSeekDirectory(DIR *entry,ssize_t position)
+MagickPrivate void NTSeekDirectory(DIR *entry,ssize_t position)
 {
   (void) position;
   (void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
@@ -1819,7 +1939,7 @@ MagickExport void NTSeekDirectory(DIR *entry,ssize_t position)
 %      for DLL's that can be dynamically loaded.
 %
 */
-MagickExport int NTSetSearchPath(const char *path)
+MagickPrivate int NTSetSearchPath(const char *path)
 {
 #if defined(MAGICKCORE_LTDL_DELEGATE)
   lt_dlsetsearchpath(path);
@@ -1858,7 +1978,7 @@ MagickExport int NTSetSearchPath(const char *path)
 %    o flags: Option flags (ignored for Windows).
 %
 */
-MagickExport int NTSyncMemory(void *address,size_t length,int flags)
+MagickPrivate int NTSyncMemory(void *address,size_t length,int flags)
 {
   (void) flags;
   if (FlushViewOfFile(address,length) == MagickFalse)
@@ -1889,7 +2009,7 @@ MagickExport int NTSyncMemory(void *address,size_t length,int flags)
 %    o command: This string is the command to execute.
 %
 */
-MagickExport int NTSystemCommand(const char *command)
+MagickPrivate int NTSystemCommand(const char *command)
 {
   char
     local_command[MaxTextExtent];
@@ -1917,19 +2037,19 @@ MagickExport int NTSystemCommand(const char *command)
   (void) CopyMagickString(local_command,command,MaxTextExtent);
   background_process=command[strlen(command)-1] == '&' ? MagickTrue :
     MagickFalse;
-  if (background_process)
+  if (background_process != MagickFalse)
     local_command[strlen(command)-1]='\0';
   if (command[strlen(command)-1] == '|')
      local_command[strlen(command)-1]='\0';
    else
      startup_info.wShowWindow=SW_SHOWDEFAULT;
-  status=CreateProcess((LPCTSTR) NULL,local_command,
-    (LPSECURITY_ATTRIBUTES) NULL,(LPSECURITY_ATTRIBUTES) NULL,(BOOL) FALSE,
-    (DWORD) NORMAL_PRIORITY_CLASS,(LPVOID) NULL,(LPCSTR) NULL,&startup_info,
+  status=CreateProcess((LPCTSTR) NULL,local_command,(LPSECURITY_ATTRIBUTES)
+    NULL,(LPSECURITY_ATTRIBUTES) NULL,(BOOL) FALSE,(DWORD)
+    NORMAL_PRIORITY_CLASS,(LPVOID) NULL,(LPCSTR) NULL,&startup_info,
     &process_info);
   if (status == 0)
     return(-1);
-  if (background_process)
+  if (background_process != MagickFalse)
     return(status == 0);
   status=WaitForSingleObject(process_info.hProcess,INFINITE);
   if (status != WAIT_OBJECT_0)
@@ -1965,7 +2085,7 @@ MagickExport int NTSystemCommand(const char *command)
 %    o name: _SC_PAGE_SIZE or _SC_PHYS_PAGES.
 %
 */
-MagickExport ssize_t NTSystemConfiguration(int name)
+MagickPrivate ssize_t NTSystemConfiguration(int name)
 {
   switch (name)
   {
@@ -2040,7 +2160,7 @@ MagickExport ssize_t NTSystemConfiguration(int name)
 %    o entry: Specifies a pointer to a DIR structure.
 %
 */
-MagickExport ssize_t NTTellDirectory(DIR *entry)
+MagickPrivate ssize_t NTTellDirectory(DIR *entry)
 {
   assert(entry != (DIR *) NULL);
   return(0);
@@ -2070,7 +2190,7 @@ MagickExport ssize_t NTTellDirectory(DIR *entry)
 %    o length: the file length.
 %
 */
-MagickExport int NTTruncateFile(int file,off_t length)
+MagickPrivate int NTTruncateFile(int file,off_t length)
 {
   DWORD
     file_pointer;
@@ -2117,7 +2237,7 @@ MagickExport int NTTruncateFile(int file,off_t length)
 %    o length: the length of the binary large object.
 %
 */
-MagickExport int NTUnmapMemory(void *map,size_t length)
+MagickPrivate int NTUnmapMemory(void *map,size_t length)
 {
   (void) length;
   if (UnmapViewOfFile(map) == 0)
@@ -2144,7 +2264,7 @@ MagickExport int NTUnmapMemory(void *map,size_t length)
 %      double NTUserTime(void)
 %
 */
-MagickExport double NTUserTime(void)
+MagickPrivate double NTUserTime(void)
 {
   DWORD
     status;
@@ -2213,7 +2333,7 @@ MagickExport double NTUserTime(void)
 %    o description: Specifies any description to the reason.
 %
 */
-MagickExport void NTWarningHandler(const ExceptionType severity,
+MagickPrivate void NTWarningHandler(const ExceptionType severity,
   const char *reason,const char *description)
 {
   char