#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"
#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>
% process.
%
*/
-MagickExport int Exit(int status)
+MagickPrivate int Exit(int status)
{
if (IsWindows95())
TerminateProcess(GetCurrentProcess(),(unsigned 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)
% int IsWindows95()
%
*/
-MagickExport int IsWindows95()
+MagickPrivate int IsWindows95()
{
OSVERSIONINFO
version_info;
% o argv: the wide-character command line arguments.
%
*/
-MagickExport char **NTArgvToUTF8(const int argc,wchar_t **argv)
+MagickPrivate char **NTArgvToUTF8(const int argc,wchar_t **argv)
{
char
**utf8;
% 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);
% 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));
return(FALSE);
}
-MagickExport int NTControlHandler(void)
+MagickPrivate int NTControlHandler(void)
{
return(SetConsoleCtrlHandler((PHANDLER_ROUTINE) ControlHandler,TRUE));
}
% double NTElapsedTime(void)
%
*/
-MagickExport double NTElapsedTime(void)
+MagickPrivate double NTElapsedTime(void)
{
union
{
% 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
% int NTExitLibrary(void)
%
*/
-MagickExport int NTExitLibrary(void)
+MagickPrivate int NTExitLibrary(void)
{
return(0);
}
% 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)
% 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);
% const char *NTGetLibraryError(void)
%
*/
-MagickExport const char *NTGetLibraryError(void)
+MagickPrivate const char *NTGetLibraryError(void)
{
static char
last_error[MaxTextExtent];
% 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];
%
*/
-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
/*
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;
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
(void) FormatLocaleString(key,MaxTextExtent,"SOFTWARE\\%s",products[i]);
root=HKEY_LOCAL_MACHINE;
- mode=KEY_READ;
+ mode=KEY_READ | flags;
if (RegOpenKeyExA(root,key,0,mode,&hkey) == ERROR_SUCCESS)
{
DWORD
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
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;
/*
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",
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);
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);
}
% const GhostInfo *NTGhostscriptDLLVectors(void)
%
*/
-MagickExport const GhostInfo *NTGhostscriptDLLVectors(void)
+MagickPrivate const GhostInfo *NTGhostscriptDLLVectors(void)
{
if (NTGhostscriptLoadDLL() == FALSE)
return((GhostInfo *) NULL);
% o length: length of buffer.
%
*/
-MagickExport int NTGhostscriptEXE(char *path,int length)
+MagickPrivate int NTGhostscriptEXE(char *path,int length)
{
register char
*p;
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);
% o length: length of the path buffer.
%
*/
-MagickExport int NTGhostscriptFonts(char *path,int length)
+MagickPrivate int NTGhostscriptFonts(char *path,int length)
{
char
buffer[MaxTextExtent],
*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))
{
% int NTGhostscriptLoadDLL(void)
%
*/
-MagickExport int NTGhostscriptLoadDLL(void)
+MagickPrivate int NTGhostscriptLoadDLL(void)
{
char
path[MaxTextExtent];
% int NTGhostscriptUnLoadDLL(void)
%
*/
-MagickExport int NTGhostscriptUnLoadDLL(void)
+MagickPrivate int NTGhostscriptUnLoadDLL(void)
{
int
status;
% int NTInitializeLibrary(void)
%
*/
-MagickExport int NTInitializeLibrary(void)
+MagickPrivate int NTInitializeLibrary(void)
{
return(0);
}
%
% 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
% 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];
#endif
}
-MagickExport void *NTOpenLibrary(const char *filename)
+MagickPrivate void *NTOpenLibrary(const char *filename)
{
#define MaxPathElements 31
% o entry: Specifies a pointer to a DIR structure.
%
*/
-MagickExport struct dirent *NTReadDirectory(DIR *entry)
+MagickPrivate struct dirent *NTReadDirectory(DIR *entry)
{
int
status;
% "LibPath", "CoderModulesPath", "FilterModulesPath", "SharePath".
%
*/
-MagickExport unsigned char *NTRegistryKeyLookup(const char *subkey)
+MagickPrivate unsigned char *NTRegistryKeyLookup(const char *subkey)
{
char
package_key[MaxTextExtent];
% 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
% 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];
% stream.
%
*/
-MagickExport void NTSeekDirectory(DIR *entry,ssize_t position)
+MagickPrivate void NTSeekDirectory(DIR *entry,ssize_t position)
{
(void) position;
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
% 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);
% 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)
% 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];
(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)
% o name: _SC_PAGE_SIZE or _SC_PHYS_PAGES.
%
*/
-MagickExport ssize_t NTSystemConfiguration(int name)
+MagickPrivate ssize_t NTSystemConfiguration(int name)
{
switch (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);
% o length: the file length.
%
*/
-MagickExport int NTTruncateFile(int file,off_t length)
+MagickPrivate int NTTruncateFile(int file,off_t length)
{
DWORD
file_pointer;
% 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)
% double NTUserTime(void)
%
*/
-MagickExport double NTUserTime(void)
+MagickPrivate double NTUserTime(void)
{
DWORD
status;
% 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