% Windows NT Utility Methods for MagickCore %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% December 1996 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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/resource-private.h"
#include "MagickCore/timer.h"
#include "MagickCore/string_.h"
+#include "MagickCore/string-private.h"
#include "MagickCore/utility.h"
+#include "MagickCore/utility-private.h"
#include "MagickCore/version.h"
#if defined(MAGICKCORE_LTDL_DELEGATE)
# include "ltdl.h"
#endif
-#include "MagickCore/nt-base-private.h"
#if defined(MAGICKCORE_CIPHER_SUPPORT)
#include <ntsecapi.h>
#include <wincrypt.h>
static void
*ghost_handle = (void *) NULL;
\f
+struct
+{
+ const HKEY
+ hkey;
+
+ const char
+ *name;
+}
+const registry_roots[2] =
+{
+ { HKEY_CURRENT_USER, "HKEY_CURRENT_USER" },
+ { HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE" }
+};
+
/*
External declarations.
*/
extern "C" BOOL WINAPI
DllMain(HINSTANCE handle,DWORD reason,LPVOID lpvReserved);
#endif
+
+static inline char *create_utf8_string(const wchar_t *wideChar)
+{
+ char
+ *utf8;
+
+ int
+ count;
+
+ count=WideCharToMultiByte(CP_UTF8,0,wideChar,-1,NULL,0,NULL,NULL);
+ if (count < 0)
+ return((char *) NULL);
+ utf8=(char *) AcquireQuantumMemory(count+1,sizeof(*utf8));
+ if (utf8 == (char *) NULL)
+ return((char *) NULL);
+ count=WideCharToMultiByte(CP_UTF8,0,wideChar,-1,utf8,count,NULL,NULL);
+ if (count == 0)
+ {
+ utf8=DestroyString(utf8);
+ return((char *) NULL);
+ }
+ utf8[count]=0;
+ return(utf8);
+}
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ssize_t
count;
- module_path=(char *) AcquireQuantumMemory(MaxTextExtent,
- sizeof(*module_path));
- if (module_path == (char *) NULL)
+ wchar_t
+ *wide_path;
+
+ wide_path=(wchar_t *) AcquireQuantumMemory(MaxTextExtent,
+ sizeof(*wide_path));
+ if (wide_path == (wchar_t *) NULL)
return(FALSE);
- count=(ssize_t) GetModuleFileName(handle,module_path,MaxTextExtent);
+ count=(ssize_t) GetModuleFileNameW(handle,wide_path,MaxTextExtent);
if (count != 0)
{
char
*path;
+ module_path=create_utf8_string(wide_path);
for ( ; count > 0; count--)
if (module_path[count] == '\\')
{
if (path == (char *) NULL)
{
module_path=DestroyString(module_path);
+ wide_path=(wchar_t *) RelinquishMagickMemory(wide_path);
return(FALSE);
}
count=(ssize_t) GetEnvironmentVariable("PATH",path,16*MaxTextExtent);
{
path=DestroyString(path);
module_path=DestroyString(module_path);
+ wide_path=(wchar_t *) RelinquishMagickMemory(wide_path);
return(FALSE);
}
(void) FormatLocaleString(variable,16*MaxTextExtent,
}
}
path=DestroyString(path);
+ module_path=DestroyString(module_path);
}
- module_path=DestroyString(module_path);
+ wide_path=(wchar_t *) RelinquishMagickMemory(wide_path);
break;
}
case DLL_PROCESS_DETACH:
MagickPrivate int Exit(int status)
{
if (IsWindows95())
- TerminateProcess(GetCurrentProcess(),(unsigned int) status);
+ {
+ TerminateProcess(GetCurrentProcess(),(unsigned int) status);
+ return(0);
+ }
exit(status);
- return(0);
}
\f
-#if !defined(__MINGW32__)
+#if !defined(__MINGW32__) && !defined(__MINGW64__)
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
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));
+ utf8[i]=create_utf8_string(argv[i]);
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);
}
MagickPrivate MagickBooleanType NTGetExecutionPath(char *path,
const size_t extent)
{
- GetModuleFileName(0,path,(DWORD) extent);
+ wchar_t
+ wide_path[MaxTextExtent];
+
+ (void) GetModuleFileNameW(0,wide_path,(DWORD) extent);
+ (void) WideCharToMultiByte(CP_UTF8,0,wide_path,-1,path,(int) extent,NULL,
+ NULL);
return(MagickTrue);
}
\f
return(1); /* not found */
}
-static int NTLocateGhostscript(DWORD flags,const char **product_family,int *major_version,
- int *minor_version)
+static int NTLocateGhostscript(DWORD flags,int *root_index,
+ const char **product_family,int *major_version,int *minor_version)
{
int
i;
/*
Find the most recent version of Ghostscript.
*/
- status=FALSE;
+ status=MagickFalse;
+ *root_index=0;
*product_family=NULL;
*major_version=5;
*minor_version=49; /* min version of Ghostscript is 5.50 */
key[MaxTextExtent];
HKEY
- hkey,
- root;
+ hkey;
+
+ int
+ j;
REGSAM
mode;
(void) FormatLocaleString(key,MaxTextExtent,"SOFTWARE\\%s",products[i]);
- root=HKEY_LOCAL_MACHINE;
- mode=KEY_READ | flags;
- if (RegOpenKeyExA(root,key,0,mode,&hkey) == ERROR_SUCCESS)
- {
- DWORD
- extent;
-
- int
- j;
-
- /*
- Now enumerate the keys.
- */
- extent=sizeof(key)/sizeof(char);
- for (j=0; RegEnumKeyA(hkey,j,key,extent) == ERROR_SUCCESS; j++)
+ for (j=0; j < (ssize_t) (sizeof(registry_roots)/sizeof(registry_roots[0]));
+ j++)
+ {
+ mode=KEY_READ | flags;
+ if (RegOpenKeyExA(registry_roots[j].hkey,key,0,mode,&hkey) ==
+ ERROR_SUCCESS)
{
+ DWORD
+ extent;
+
int
- major,
- minor;
-
- major=0;
- minor=0;
- if (sscanf(key,"%d.%d",&major,&minor) != 2)
- continue;
- if ((major > *major_version) || ((major == *major_version) &&
- (minor > *minor_version)))
- {
- *product_family=products[i];
- *major_version=major;
- *minor_version=minor;
- status=TRUE;
- }
+ k;
+
+ /*
+ Now enumerate the keys.
+ */
+ extent=sizeof(key)/sizeof(char);
+ for (k=0; RegEnumKeyA(hkey,k,key,extent) == ERROR_SUCCESS; k++)
+ {
+ int
+ major,
+ minor;
+
+ major=0;
+ minor=0;
+ if (sscanf(key,"%d.%d",&major,&minor) != 2)
+ continue;
+ if ((major > *major_version) || ((major == *major_version) &&
+ (minor > *minor_version)))
+ {
+ *root_index=j;
+ *product_family=products[i];
+ *major_version=major;
+ *minor_version=minor;
+ status=MagickTrue;
+ }
+ }
+ (void) RegCloseKey(hkey);
}
- (void) RegCloseKey(hkey);
- }
+ }
}
- if (status == FALSE)
+ if (status == MagickFalse)
{
*major_version=0;
*minor_version=0;
return(status);
}
-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)
+static int NTGhostscriptGetString(const char *name,BOOL *is_64_bit,
+ char *value,const size_t length)
{
char
- key[MaxTextExtent];
+ buffer[MaxTextExtent],
+ *directory;
int
- i,
extent;
static const char
- *product_family = (const char *) NULL;
+ *product_family=(const char *) NULL;
static BOOL
- is_64_bit_version = FALSE;
+ is_64_bit_version=FALSE;
static int
flags=0,
major_version=0,
- minor_version=0;
-
- struct
- {
- const HKEY
- hkey;
-
- const char
- *name;
- }
- hkeys[2] =
- {
- { HKEY_CURRENT_USER, "HKEY_CURRENT_USER" },
- { HKEY_LOCAL_MACHINE, "HKEY_LOCAL_MACHINE" }
- };
+ minor_version=0,
+ root_index=0;
/*
Get a string from the installed Ghostscript.
*/
- if (is_64_bit!=NULL)
- *is_64_bit=FALSE;
*value='\0';
+ directory=(char *) NULL;
+ if (LocaleCompare(name, "GS_DLL") == 0)
+ {
+ directory=GetEnvironmentValue("MAGICK_GHOSTSCRIPT_PATH");
+ if (directory != (char *) NULL)
+ {
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%s%sgsdll32.dll",
+ directory,DirectorySeparator);
+ if (IsPathAccessible(buffer) != MagickFalse)
+ {
+ (void) CopyMagickString(value,buffer,length);
+ if (is_64_bit != NULL)
+ *is_64_bit=FALSE;
+ return(TRUE);
+ }
+ (void) FormatLocaleString(buffer,MaxTextExtent,"%s%sgsdll64.dll",
+ directory,DirectorySeparator);
+ if (IsPathAccessible(buffer) != MagickFalse)
+ {
+ (void) CopyMagickString(value,buffer,length);
+ if (is_64_bit != NULL)
+ *is_64_bit=TRUE;
+ return(TRUE);
+ }
+ return(FALSE);
+ }
+ }
if (product_family == NULL)
- {
- 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;
+ flags=0;
#if defined(KEY_WOW64_32KEY)
+#if defined(_WIN64)
+ flags=KEY_WOW64_64KEY;
+#else
+ flags=KEY_WOW64_32KEY;
+#endif
+ (void) NTLocateGhostscript(flags,&root_index,&product_family,
+ &major_version,&minor_version);
+ if (product_family == NULL)
+#if defined(_WIN64)
flags=KEY_WOW64_32KEY;
+ else
+ is_64_bit_version=TRUE;
+#else
+ flags=KEY_WOW64_64KEY;
+#endif
+#endif
+ }
+ if (product_family == NULL)
+ {
+ (void) NTLocateGhostscript(flags,&root_index,&product_family,
+ &major_version,&minor_version);
+#if !defined(_WIN64)
+ is_64_bit_version=TRUE;
#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",
+ if (is_64_bit != NULL)
+ *is_64_bit=is_64_bit_version;
+ (void) FormatLocaleString(buffer,MaxTextExtent,"SOFTWARE\\%s\\%d.%02d",
product_family,major_version,minor_version);
- for (i=0; i < (ssize_t) (sizeof(hkeys)/sizeof(hkeys[0])); i++)
- {
- extent=(int) length;
- 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(TRUE);
- }
- (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
- "registry: \"%s\\%s\\%s\" (failed)",hkeys[i].name,key,name);
- }
+ extent=(int) length;
+ if (NTGetRegistryValue(registry_roots[root_index].hkey,buffer,flags,name,
+ value,&extent) == 0)
+ {
+ (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
+ "registry: \"%s\\%s\\%s\"=\"%s\"",registry_roots[root_index].name,
+ buffer,name,value);
+ return(TRUE);
+ }
return(FALSE);
}
{
p++;
*p='\0';
- (void) ConcatenateMagickString(program,is_64_bit_version ? "gswin64c.exe" : "gswin32c.exe",sizeof(program));
+ (void) ConcatenateMagickString(program,is_64_bit_version ?
+ "gswin64c.exe" : "gswin32c.exe",sizeof(program));
}
(void) CopyMagickString(path,program,length);
return(TRUE);
{
char
buffer[MaxTextExtent],
+ *directory,
filename[MaxTextExtent];
register char
*q;
*path='\0';
- if (NTGhostscriptGetString("GS_LIB",NULL,buffer,MaxTextExtent) == FALSE)
- return(FALSE);
+ directory=GetEnvironmentValue("MAGICK_GHOSTSCRIPT_FONT_PATH");
+ if (directory != (char *) NULL)
+ {
+ (void) CopyMagickString(buffer,directory,MaxTextExtent);
+ directory=DestroyString(directory);
+ }
+ else
+ {
+ if (NTGhostscriptGetString("GS_LIB",NULL,buffer,MaxTextExtent) == FALSE)
+ return(FALSE);
+ }
for (p=buffer-1; p != (char *) NULL; p=strchr(p+1,DirectoryListSeparator))
{
(void) CopyMagickString(path,p+1,length+1);
if (IsPathAccessible(filename) != MagickFalse)
return(TRUE);
}
+ *path='\0';
return(FALSE);
}
\f
CloseHandle(map_handle);
}
if (map == (void *) NULL)
- return((void *) MAP_FAILED);
+ return((void *) ((char *) MAP_FAILED));
return((void *) ((char *) map));
}
\f
*/
MagickPrivate DIR *NTOpenDirectory(const char *path)
{
- char
- file_specification[MaxTextExtent];
-
DIR
*entry;
size_t
length;
+ wchar_t
+ file_specification[MaxTextExtent];
+
assert(path != (const char *) NULL);
- length=CopyMagickString(file_specification,path,MaxTextExtent);
- if (length >= (MaxTextExtent-1))
- return((DIR *) NULL);
- length=ConcatenateMagickString(file_specification,DirectorySeparator,
+ length=MultiByteToWideChar(CP_UTF8,0,path,-1,file_specification,
MaxTextExtent);
- if (length >= (MaxTextExtent-1))
+ if (length == 0)
+ return((DIR *) NULL);
+ if(wcsncat(file_specification,(const wchar_t*) DirectorySeparator,
+ MaxTextExtent-wcslen(file_specification)-1) == (wchar_t*)NULL)
return((DIR *) NULL);
entry=(DIR *) AcquireMagickMemory(sizeof(DIR));
if (entry != (DIR *) NULL)
{
entry->firsttime=TRUE;
- entry->hSearch=FindFirstFile(file_specification,&entry->Win32FindData);
+ entry->hSearch=FindFirstFileW(file_specification,&entry->Win32FindData);
}
if (entry->hSearch == INVALID_HANDLE_VALUE)
{
- length=ConcatenateMagickString(file_specification,"\\*.*",MaxTextExtent);
- if (length >= (MaxTextExtent-1))
+ if(wcsncat(file_specification,L"*.*",
+ MaxTextExtent-wcslen(file_specification)-1) == (wchar_t*)NULL)
{
entry=(DIR *) RelinquishMagickMemory(entry);
return((DIR *) NULL);
}
- entry->hSearch=FindFirstFile(file_specification,&entry->Win32FindData);
+ entry->hSearch=FindFirstFileW(file_specification,&entry->Win32FindData);
if (entry->hSearch == INVALID_HANDLE_VALUE)
{
entry=(DIR *) RelinquishMagickMemory(entry);
%
*/
-static const char *GetSearchPath( void )
+static inline const char *GetSearchPath(void)
{
#if defined(MAGICKCORE_LTDL_DELEGATE)
return(lt_dlgetsearchpath());
#endif
}
-MagickPrivate void *NTOpenLibrary(const char *filename)
+static UINT ChangeErrorMode(void)
{
-#define MaxPathElements 31
+ typedef UINT
+ (CALLBACK *GETERRORMODE)(void);
- char
- buffer[MaxTextExtent];
+ GETERRORMODE
+ getErrorMode;
+
+ HMODULE
+ handle;
+
+ UINT
+ mode;
+
+ mode=SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
+
+ handle=GetModuleHandle("kernel32.dll");
+ if (handle == (HMODULE) NULL)
+ return SetErrorMode(mode);
+
+ getErrorMode=(GETERRORMODE) NTGetLibrarySymbol(handle,"GetErrorMode");
+ if (getErrorMode != (GETERRORMODE) NULL)
+ mode=getErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
+ return SetErrorMode(mode);
+}
+
+static inline void *NTLoadLibrary(const char *filename)
+{
int
- index;
+ length;
+
+ wchar_t
+ path[MaxTextExtent];
+
+ length=MultiByteToWideChar(CP_UTF8,0,filename,-1,path,MaxTextExtent);
+ if (length == 0)
+ return((void *) NULL);
+ return (void *) LoadLibraryExW(path,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
+}
+
+MagickPrivate void *NTOpenLibrary(const char *filename)
+{
+ char
+ path[MaxTextExtent];
register const char
*p,
*q;
- register int
- i;
-
UINT
mode;
void
*handle;
- mode=SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX);
- handle=(void *) LoadLibraryEx(filename,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
- if ((handle != (void *) NULL) || (GetSearchPath() == (char *) NULL))
+ mode=ChangeErrorMode();
+ handle=NTLoadLibrary(filename);
+ if (handle == (void *) NULL)
{
- SetErrorMode(mode);
- return(handle);
- }
- p=(char *) GetSearchPath();
- index=0;
- while (index < MaxPathElements)
- {
- q=strchr(p,DirectoryListSeparator);
- if (q == (char *) NULL)
+ p=GetSearchPath();
+ while (p != (const char*) NULL)
{
- (void) CopyMagickString(buffer,p,MaxTextExtent);
- (void) ConcatenateMagickString(buffer,"\\",MaxTextExtent);
- (void) ConcatenateMagickString(buffer,filename,MaxTextExtent);
- handle=(void *) LoadLibraryEx(buffer,NULL,
- LOAD_WITH_ALTERED_SEARCH_PATH);
- break;
+ q=strchr(p,DirectoryListSeparator);
+ if (q != (const char*) NULL)
+ (void) CopyMagickString(path,p,q-p+1);
+ else
+ (void) CopyMagickString(path,p,MaxTextExtent);
+ (void) ConcatenateMagickString(path,DirectorySeparator,MaxTextExtent);
+ (void) ConcatenateMagickString(path,filename,MaxTextExtent);
+ handle=NTLoadLibrary(path);
+ if (handle != (void *) NULL || q == (const char*) NULL)
+ break;
+ p=q+1;
}
- i=q-p;
- (void) CopyMagickString(buffer,p,i+1);
- (void) ConcatenateMagickString(buffer,"\\",MaxTextExtent);
- (void) ConcatenateMagickString(buffer,filename,MaxTextExtent);
- handle=(void *) LoadLibraryEx(buffer,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
- if (handle != (void *) NULL)
- break;
- p=q+1;
- }
+ }
SetErrorMode(mode);
return(handle);
}
return((struct dirent *) NULL);
if (!entry->firsttime)
{
- status=FindNextFile(entry->hSearch,&entry->Win32FindData);
+ status=FindNextFileW(entry->hSearch,&entry->Win32FindData);
if (status == 0)
return((struct dirent *) NULL);
}
- length=CopyMagickString(entry->file_info.d_name,
- entry->Win32FindData.cFileName,sizeof(entry->file_info.d_name));
- if (length >= sizeof(entry->file_info.d_name))
+ length=WideCharToMultiByte(CP_UTF8,0,entry->Win32FindData.cFileName,-1,
+ entry->file_info.d_name,sizeof(entry->file_info.d_name),NULL,NULL);
+ if (length == 0)
return((struct dirent *) NULL);
entry->firsttime=FALSE;
entry->file_info.d_namlen=(int) strlen(entry->file_info.d_name);
*/
MagickPrivate unsigned char *NTResourceToBlob(const char *id)
{
+
+#ifndef MAGICKCORE_LIBRARY_NAME
char
path[MaxTextExtent];
+#endif
DWORD
length;
assert(id != (const char *) NULL);
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",id);
+#ifdef MAGICKCORE_LIBRARY_NAME
+ handle=GetModuleHandle(MAGICKCORE_LIBRARY_NAME);
+#else
(void) FormatLocaleString(path,MaxTextExtent,"%s%s%s",GetClientPath(),
DirectorySeparator,GetClientName());
if (IsPathAccessible(path) != MagickFalse)
handle=GetModuleHandle(path);
else
handle=GetModuleHandle(0);
+#endif
if (!handle)
return((unsigned char *) NULL);
resource=FindResource(handle,id,"IMAGEMAGICK");
status;
MagickBooleanType
- background_process;
+ asynchronous;
PROCESS_INFORMATION
process_info;
startup_info.dwFlags=STARTF_USESHOWWINDOW;
startup_info.wShowWindow=SW_SHOWMINNOACTIVE;
(void) CopyMagickString(local_command,command,MaxTextExtent);
- background_process=command[strlen(command)-1] == '&' ? MagickTrue :
- MagickFalse;
- 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;
+ asynchronous=command[strlen(command)-1] == '&' ? MagickTrue : MagickFalse;
+ if (asynchronous != MagickFalse)
+ {
+ local_command[strlen(command)-1]='\0';
+ startup_info.wShowWindow=SW_SHOWDEFAULT;
+ }
+ else
+ if (command[strlen(command)-1] == '|')
+ local_command[strlen(command)-1]='\0';
+ else
+ startup_info.wShowWindow=SW_HIDE;
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 != MagickFalse)
+ if (asynchronous != MagickFalse)
return(status == 0);
status=WaitForSingleObject(process_info.hProcess,INFINITE);
if (status != WAIT_OBJECT_0)
status;
GlobalMemoryStatus(&status);
- return((ssize_t) status.dwTotalPhys/system_info.dwPageSize);
+ return((ssize_t) status.dwTotalPhys/system_info.dwPageSize/4);
}
status.dwLength=sizeof(status);
if (module(&status) == 0)
return(0L);
- return((ssize_t) status.ullTotalPhys/system_info.dwPageSize);
+ return((ssize_t) status.ullTotalPhys/system_info.dwPageSize/4);
}
case _SC_OPEN_MAX:
return(2048);
DWORD
file_pointer;
+ HANDLE
+ file_handle;
+
long
- file_handle,
high,
low;
- file_handle=_get_osfhandle(file);
- if (file_handle == -1L)
+ file_handle=(HANDLE) _get_osfhandle(file);
+ if (file_handle == (HANDLE) -1L)
return(-1);
low=(long) (length & 0xffffffffUL);
high=(long) ((((MagickOffsetType) length) >> 32) & 0xffffffffUL);
- file_pointer=SetFilePointer((HANDLE) file_handle,low,&high,FILE_BEGIN);
+ file_pointer=SetFilePointer(file_handle,low,&high,FILE_BEGIN);
if ((file_pointer == 0xFFFFFFFF) && (GetLastError() != NO_ERROR))
return(-1);
- if (SetEndOfFile((HANDLE) file_handle) == 0)
+ if (SetEndOfFile(file_handle) == 0)
return(-1);
return(0);
}
(void) MessageBox(NULL,buffer,"ImageMagick Warning",MB_OK | MB_TASKMODAL |
MB_SETFOREGROUND | MB_ICONINFORMATION);
}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% N T W i n d o w s G e n e s i s %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% NTWindowsGenesis() initializes the MagickCore Windows environment.
+%
+% The format of the NTWindowsGenesis method is:
+%
+% void NTWindowsGenesis(void)
+%
+*/
+MagickPrivate void NTWindowsGenesis(void)
+{
+ char
+ *mode;
+
+ mode=GetEnvironmentValue("MAGICK_ERRORMODE");
+ if (mode != (char *) NULL)
+ {
+ (void) SetErrorMode(StringToInteger(mode));
+ mode=DestroyString(mode);
+ }
+#if defined(_DEBUG) && !defined(__BORLANDC__) && !defined(__MINGW32__) && !defined(__MINGW64__)
+ if (IsEventLogging() != MagickFalse)
+ {
+ int
+ debug;
+
+ debug=_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
+ debug|=_CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_LEAK_CHECK_DF;
+ (void) _CrtSetDbgFlag(debug);
+ _ASSERTE(_CrtCheckMemory());
+ }
+#endif
+}
#endif