41#include "MagickCore/studio.h"
42#if defined(MAGICKCORE_WINDOWS_SUPPORT)
43#include "MagickCore/client.h"
44#include "MagickCore/distribute-cache-private.h"
45#include "MagickCore/exception-private.h"
46#include "MagickCore/image-private.h"
47#include "MagickCore/locale_.h"
48#include "MagickCore/log.h"
49#include "MagickCore/magick.h"
50#include "MagickCore/memory_.h"
51#include "MagickCore/memory-private.h"
52#include "MagickCore/nt-base.h"
53#include "MagickCore/nt-base-private.h"
54#include "MagickCore/resource_.h"
55#include "MagickCore/resource-private.h"
56#include "MagickCore/timer.h"
57#include "MagickCore/string_.h"
58#include "MagickCore/string-private.h"
59#include "MagickCore/utility.h"
60#include "MagickCore/utility-private.h"
61#include "MagickCore/version.h"
62#if defined(MAGICKCORE_LTDL_DELEGATE)
65#if defined(MAGICKCORE_CIPHER_SUPPORT)
73#if !defined(MAP_FAILED)
74#define MAP_FAILED ((void *)(LONG_PTR)-1)
76#define MaxWideByteExtent 100
90typedef struct _NTGhostInfo
93 (MagickDLLCall *delete_instance)(gs_main_instance *);
96 (MagickDLLCall *new_instance)(gs_main_instance **,
void *);
112 *ghost_handle = (
void *) NULL;
125const registry_roots[2] =
127 { HKEY_CURRENT_USER,
"HKEY_CURRENT_USER" },
128 { HKEY_LOCAL_MACHINE,
"HKEY_LOCAL_MACHINE" }
134static void MagickDLLCall NTGhostscriptDeleteInstance(
135 gs_main_instance *instance)
137 LockSemaphoreInfo(ghost_semaphore);
138 nt_ghost_info.delete_instance(instance);
139 nt_ghost_info.has_instance=MagickFalse;
140 UnlockSemaphoreInfo(ghost_semaphore);
143static int MagickDLLCall NTGhostscriptNewInstance(gs_main_instance **pinstance,
149 LockSemaphoreInfo(ghost_semaphore);
151 if (nt_ghost_info.has_instance == MagickFalse)
153 status=nt_ghost_info.new_instance(pinstance,caller_handle);
155 nt_ghost_info.has_instance=MagickTrue;
157 UnlockSemaphoreInfo(ghost_semaphore);
161static inline char *create_utf8_string(
const wchar_t *wide)
169 count=WideCharToMultiByte(CP_UTF8,0,wide,-1,NULL,0,NULL,NULL);
171 return((
char *) NULL);
172 utf8=(
char *) NTAcquireQuantumMemory(count+1,
sizeof(*utf8));
173 if (utf8 == (
char *) NULL)
174 return((
char *) NULL);
175 count=WideCharToMultiByte(CP_UTF8,0,wide,-1,utf8,count,NULL,NULL);
178 utf8=(
char *) RelinquishMagickMemory(utf8);
179 return((
char *) NULL);
185static unsigned char *NTGetRegistryValue(HKEY root,
const char *key,DWORD flags,
202 wide_name[MaxWideByteExtent];
204 value=(
unsigned char *) NULL;
205 status=RegOpenKeyExA(root,key,0,(KEY_READ | flags),®istry_key);
206 if (status != ERROR_SUCCESS)
208 if (MultiByteToWideChar(CP_UTF8,0,name,-1,wide_name,MaxWideByteExtent) == 0)
210 RegCloseKey(registry_key);
213 status=RegQueryValueExW(registry_key,wide_name,0,&type,0,&size);
214 if ((status == ERROR_SUCCESS) && (type == REG_SZ))
219 wide=(LPBYTE) NTAcquireQuantumMemory((
const size_t) size,
sizeof(*wide));
220 if (wide != (LPBYTE) NULL)
222 status=RegQueryValueExW(registry_key,wide_name,0,&type,wide,&size);
223 if ((status == ERROR_SUCCESS) && (type == REG_SZ))
224 value=(
unsigned char *) create_utf8_string((
const wchar_t *) wide);
225 wide=(LPBYTE) RelinquishMagickMemory(wide);
228 RegCloseKey(registry_key);
275#if defined(_DLL) && defined(ProvideDllMain)
276BOOL WINAPI DllMain(HINSTANCE handle,DWORD reason,LPVOID lpvReserved)
280 case DLL_PROCESS_ATTACH:
291 MagickCoreGenesis((
const char *) NULL,MagickFalse);
292 wide_path=(
wchar_t *) NTAcquireQuantumMemory(MagickPathExtent,
294 if (wide_path == (
wchar_t *) NULL)
296 count=(ssize_t) GetModuleFileNameW(handle,wide_path,MagickPathExtent);
302 module_path=create_utf8_string(wide_path);
303 for ( ; count > 0; count--)
304 if (module_path[count] ==
'\\')
306 module_path[count+1]=
'\0';
309 path=(
char *) NTAcquireQuantumMemory(MagickPathExtent,
311 if (path == (
char *) NULL)
313 module_path=DestroyString(module_path);
314 wide_path=(
wchar_t *) RelinquishMagickMemory(wide_path);
317 count=(ssize_t) GetEnvironmentVariable(
"PATH",path,16*
319 if ((count != 0) && (strstr(path,module_path) == (
char *) NULL))
321 if ((strlen(module_path)+count+1) < (16*MagickPathExtent-1))
326 variable=(
char *) NTAcquireQuantumMemory(MagickPathExtent,
327 16*
sizeof(*variable));
328 if (variable == (
char *) NULL)
330 path=DestroyString(path);
331 module_path=DestroyString(module_path);
332 wide_path=(
wchar_t *) RelinquishMagickMemory(wide_path);
335 (void) FormatLocaleString(variable,16*MagickPathExtent,
336 "%s;%s",module_path,path);
337 SetEnvironmentVariable(
"PATH",variable);
338 variable=DestroyString(variable);
341 path=DestroyString(path);
342 module_path=DestroyString(module_path);
344 wide_path=(
wchar_t *) RelinquishMagickMemory(wide_path);
347 case DLL_PROCESS_DETACH:
349 MagickCoreTerminus();
359#if !defined(__MINGW32__)
384MagickPrivate
int gettimeofday (
struct timeval *time_value,
385 struct timezone *time_zone)
387#define EpochFiletime MagickLLConstant(116444736000000000)
392 if (time_value != (
struct timeval *) NULL)
403 GetSystemTimeAsFileTime(&file_time);
404 date_time.LowPart=file_time.dwLowDateTime;
405 date_time.HighPart=file_time.dwHighDateTime;
406 time=date_time.QuadPart;
409 time_value->tv_sec=(long) (time / 1000000);
410 time_value->tv_usec=(long) (time % 1000000);
412 if (time_zone != (
struct timezone *) NULL)
425 _get_timezone(&timezone);
426 time_zone->tz_minuteswest=timezone/60;
427 _get_daylight(&daylight);
428 time_zone->tz_dsttime=daylight;
458MagickExport
int NTAccessWide(
const char *path,
int mode)
466 path_wide=NTCreateWidePath(path);
467 if (path_wide == (
wchar_t *) NULL)
469 status=_waccess(path_wide,mode);
470 path_wide=(
wchar_t *) RelinquishMagickMemory(path_wide);
499MagickPrivate
char **NTArgvToUTF8(
const int argc,
wchar_t **argv)
507 utf8=(
char **) NTAcquireQuantumMemory(argc,
sizeof(*utf8));
508 if (utf8 == (
char **) NULL)
509 ThrowFatalException(ResourceLimitFatalError,
"UnableToConvertStringToARGV");
510 for (i=0; i < (ssize_t) argc; i++)
512 utf8[i]=create_utf8_string(argv[i]);
513 if (utf8[i] == (
char *) NULL)
515 for (i--; i >= 0; i--)
516 utf8[i]=DestroyString(utf8[i]);
517 ThrowFatalException(ResourceLimitFatalError,
518 "UnableToConvertStringToARGV");
547MagickPrivate
int NTCloseDirectory(DIR *entry)
549 assert(entry != (DIR *) NULL);
550 if (IsEventLogging() != MagickFalse)
551 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"...");
552 FindClose(entry->hSearch);
553 entry=(DIR *) RelinquishMagickMemory(entry);
578MagickPrivate
int NTCloseLibrary(
void *handle)
580 return(FreeLibrary((HINSTANCE) handle) ? 0 : 1);
606MagickExport
wchar_t* NTCreateWidePath(
const char *utf8)
614 count=MultiByteToWideChar(CP_UTF8,0,utf8,-1,NULL,0);
615 if ((count > MAX_PATH) && (strncmp(utf8,
"\\\\?\\",4) != 0) &&
616 (NTLongPathsEnabled() == MagickFalse))
619 buffer[MagickPathExtent];
628 (void) FormatLocaleString(buffer,MagickPathExtent,
"\\\\?\\%s",utf8);
630 longPath=(
wchar_t *) NTAcquireQuantumMemory((
size_t) count,
632 if (longPath == (
wchar_t *) NULL)
633 return((
wchar_t *) NULL);
634 count=MultiByteToWideChar(CP_UTF8,0,buffer,-1,longPath,count);
636 count=(int) GetShortPathNameW(longPath,shortPath,MAX_PATH);
637 longPath=(
wchar_t *) RelinquishMagickMemory(longPath);
638 if ((count < 5) || (count >= MAX_PATH))
639 return((
wchar_t *) NULL);
640 length=(size_t) count-3;
641 wide=(
wchar_t *) NTAcquireQuantumMemory(length,
sizeof(*wide));
642 wcscpy_s(wide,length,shortPath+4);
645 wide=(
wchar_t *) NTAcquireQuantumMemory((
size_t) count,
sizeof(*wide));
646 if ((wide != (
wchar_t *) NULL) &&
647 (MultiByteToWideChar(CP_UTF8,0,utf8,-1,wide,count) == 0))
648 wide=(
wchar_t *) RelinquishMagickMemory(wide);
671MagickPrivate
double NTElapsedTime(
void)
691 if (frequency.QuadPart == 0)
693 if (QueryPerformanceFrequency(&frequency) == 0)
694 frequency.QuadPart=1;
696 if (frequency.QuadPart > 1)
698 QueryPerformanceCounter(&performance_count);
699 return((
double) performance_count.QuadPart/frequency.QuadPart);
701 GetSystemTime(&system_time);
702 SystemTimeToFileTime(&system_time,&elapsed_time.filetime);
703 return((
double) 1.0e-7*elapsed_time.filetime64);
728MagickPrivate
double NTErf(
double x)
752 y=1.0-(((((a5*t+a4)*t)+a3)*t+a2)*t+a1)*t*exp(-x*x);
784MagickPrivate
void NTErrorHandler(
const ExceptionType severity,
785 const char *reason,
const char *description)
788 buffer[3*MagickPathExtent],
792 if (reason == (
char *) NULL)
794 MagickCoreTerminus();
797 message=GetExceptionMessage(errno);
798 if ((description != (
char *) NULL) && errno)
799 (void) FormatLocaleString(buffer,MagickPathExtent,
"%s: %s (%s) [%s].\n",
800 GetClientName(),reason,description,message);
802 if (description != (
char *) NULL)
803 (void) FormatLocaleString(buffer,MagickPathExtent,
"%s: %s (%s).\n",
804 GetClientName(),reason,description);
807 (void) FormatLocaleString(buffer,MagickPathExtent,
"%s: %s [%s].\n",
808 GetClientName(),reason,message);
810 (
void) FormatLocaleString(buffer,MagickPathExtent,
"%s: %s.\n",
811 GetClientName(),reason);
812 message=DestroyString(message);
813 (void) MessageBox(NULL,buffer,
"ImageMagick Exception",MB_OK | MB_TASKMODAL |
814 MB_SETFOREGROUND | MB_ICONEXCLAMATION);
815 MagickCoreTerminus();
844MagickPrivate MagickBooleanType NTGatherRandomData(
const size_t length,
845 unsigned char *random)
847#if defined(MAGICKCORE_CIPHER_SUPPORT) && defined(_MSC_VER)
854 handle=(HCRYPTPROV) NULL;
855 status=CryptAcquireContext(&handle,NULL,MS_DEF_PROV,PROV_RSA_FULL,
856 (CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET));
858 status=CryptAcquireContext(&handle,NULL,MS_DEF_PROV,PROV_RSA_FULL,
859 (CRYPT_VERIFYCONTEXT | CRYPT_MACHINE_KEYSET | CRYPT_NEWKEYSET));
862 status=CryptGenRandom(handle,(DWORD) length,random);
865 status=CryptReleaseContext(handle,0);
868 status=CryptReleaseContext(handle,0);
901extern MagickPrivate
char *NTGetEnvironmentValue(
const char *name)
904 *environment = (
char *) NULL;
913 wide_name[MaxWideByteExtent];
915 if (MultiByteToWideChar(CP_UTF8,0,name,-1,wide_name,MaxWideByteExtent) == 0)
917 size=GetEnvironmentVariableW(wide_name,(LPWSTR) NULL,0);
920 wide=(LPWSTR) NTAcquireQuantumMemory((
const size_t) size,
sizeof(*wide));
921 if (wide == (LPWSTR) NULL)
923 if (GetEnvironmentVariableW(wide_name,wide,size) != 0)
924 environment=create_utf8_string(wide);
925 wide=(LPWSTR) RelinquishMagickMemory(wide);
953MagickPrivate MagickBooleanType NTGetExecutionPath(
char *path,
957 wide_path[MagickPathExtent];
959 (void) GetModuleFileNameW((HMODULE) NULL,wide_path,(DWORD) extent);
960 (void) WideCharToMultiByte(CP_UTF8,0,wide_path,-1,path,(
int) extent,NULL,
987static char *NTGetLastErrorMessage(DWORD last_error)
996 buffer = (LPVOID) NULL;
998 status=FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
999 FORMAT_MESSAGE_FROM_SYSTEM,NULL,last_error,
1000 MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT),(LPTSTR) &buffer,0,NULL);
1002 reason=AcquireString(
"An unknown error occurred");
1005 reason=AcquireString((
const char *) buffer);
1031MagickPrivate
const char *NTGetLibraryError(
void)
1034 last_error[MagickPathExtent];
1040 error=NTGetLastErrorMessage(GetLastError());
1042 (void) CopyMagickString(last_error,error,MagickPathExtent);
1043 error=DestroyString(error);
1072void *NTGetLibrarySymbol(
void *handle,
const char *name)
1077 proc_address=GetProcAddress((HMODULE) handle,(LPCSTR) name);
1078 if (proc_address == (FARPROC) NULL)
1079 return((
void *) NULL);
1080 return((
void *) proc_address);
1107MagickPrivate MagickBooleanType NTGetModulePath(
const char *module,
char *path)
1110 module_path[MagickPathExtent];
1119 handle=GetModuleHandle(module);
1120 if (handle == (HMODULE) NULL)
1121 return(MagickFalse);
1122 length=GetModuleFileName(handle,module_path,MagickPathExtent);
1124 GetPathComponent(module_path,HeadPath,path);
1149static int NTLocateGhostscript(DWORD flags,
int *root_index,
1150 const char **product_family,
int *major_version,
int *minor_version,
1162 "Artifex Ghostscript",
1171 *product_family=NULL;
1174 for (i=0; i < (ssize_t) (
sizeof(products)/
sizeof(products[0])); i++)
1177 key[MagickPathExtent];
1188 (void) FormatLocaleString(key,MagickPathExtent,
"SOFTWARE\\%s",products[i]);
1189 for (j=0; j < (ssize_t) (
sizeof(registry_roots)/
sizeof(registry_roots[0]));
1192 mode=KEY_READ | flags;
1193 if (RegOpenKeyExA(registry_roots[j].hkey,key,0,mode,&hkey) ==
1205 extent=
sizeof(key)/
sizeof(
char);
1206 for (k=0; RegEnumKeyA(hkey,k,key,extent) == ERROR_SUCCESS; k++)
1216 if (MagickSscanf(key,
"%d.%d.%d",&major,&minor,&patch) != 3)
1217 if (MagickSscanf(key,
"%d.%d",&major,&minor) != 2)
1219 if ((major > *major_version) ||
1220 ((major == *major_version) && (minor > *minor_version)) ||
1221 ((minor == *minor_version) && (patch > *patch_version)))
1224 *product_family=products[i];
1225 *major_version=major;
1226 *minor_version=minor;
1227 *patch_version=patch;
1231 (void) RegCloseKey(hkey);
1235 if (status == MagickFalse)
1241 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
"Ghostscript (%s) "
1242 "version %d.%d.%d",*product_family,*major_version,*minor_version,*patch_version);
1246static MagickBooleanType NTGhostscriptGetString(
const char *name,
1247 BOOL *is_64_bit,
char *value,
const size_t length)
1250 buffer[MagickPathExtent],
1254 *product_family = (
const char *) NULL;
1257 is_64_bit_version = FALSE;
1273 directory=(
char *) NULL;
1274 if (LocaleCompare(name,
"GS_DLL") == 0)
1276 directory=GetEnvironmentValue(
"MAGICK_GHOSTSCRIPT_PATH");
1277 if (directory != (
char *) NULL)
1279 (void) FormatLocaleString(buffer,MagickPathExtent,
"%s%sgsdll64.dll",
1280 directory,DirectorySeparator);
1281 if (IsPathAccessible(buffer) != MagickFalse)
1283 directory=DestroyString(directory);
1284 (void) CopyMagickString(value,buffer,length);
1285 if (is_64_bit != NULL)
1289 (void) FormatLocaleString(buffer,MagickPathExtent,
"%s%sgsdll32.dll",
1290 directory,DirectorySeparator);
1291 if (IsPathAccessible(buffer) != MagickFalse)
1293 directory=DestroyString(directory);
1294 (void) CopyMagickString(value,buffer,length);
1295 if (is_64_bit != NULL)
1299 return(MagickFalse);
1302 if (product_family == (
const char *) NULL)
1305#if defined(KEY_WOW64_32KEY)
1307 flags=KEY_WOW64_64KEY;
1309 flags=KEY_WOW64_32KEY;
1311 (void) NTLocateGhostscript(flags,&root_index,&product_family,
1312 &major_version,&minor_version,&patch_version);
1313 if (product_family == (
const char *) NULL)
1315 flags=KEY_WOW64_32KEY;
1317 is_64_bit_version=TRUE;
1319 flags=KEY_WOW64_64KEY;
1323 if (product_family == (
const char *) NULL)
1325 (void) NTLocateGhostscript(flags,&root_index,&product_family,
1326 &major_version,&minor_version,&patch_version);
1328 is_64_bit_version=TRUE;
1331 if (product_family == (
const char *) NULL)
1332 return(MagickFalse);
1333 if (is_64_bit != NULL)
1334 *is_64_bit=is_64_bit_version;
1335 (void) FormatLocaleString(buffer,MagickPathExtent,
"SOFTWARE\\%s\\%d.%.2d.%d",
1336 product_family,major_version,minor_version,patch_version);
1337 registry_value=NTGetRegistryValue(registry_roots[root_index].hkey,buffer,
1339 if (registry_value == (
unsigned char *) NULL)
1341 (void) FormatLocaleString(buffer,MagickPathExtent,
"SOFTWARE\\%s\\%d.%02d",
1342 product_family,major_version,minor_version);
1343 registry_value=NTGetRegistryValue(registry_roots[root_index].hkey,buffer,
1346 if (registry_value == (
unsigned char *) NULL)
1347 return(MagickFalse);
1348 (void) CopyMagickString(value,(
const char *) registry_value,length);
1349 registry_value=(
unsigned char *) RelinquishMagickMemory(registry_value);
1350 (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
1351 "registry: \"%s\\%s\\%s\"=\"%s\"",registry_roots[root_index].name,
1356static MagickBooleanType NTGhostscriptDLL(
char *path,
int length)
1359 dll[MagickPathExtent] = {
"" };
1365 if ((*dll ==
'\0') &&
1366 (NTGhostscriptGetString(
"GS_DLL",&is_64_bit,dll,
sizeof(dll)) != MagickTrue))
1367 return(MagickFalse);
1370 return(MagickFalse);
1373 return(MagickFalse);
1375 (void) CopyMagickString(path,dll,length);
1379static inline MagickBooleanType NTGhostscriptHasValidHandle()
1381 if ((nt_ghost_info.delete_instance == NULL) || (ghost_info.exit == NULL) ||
1382 (nt_ghost_info.new_instance == NULL) || (ghost_info.set_stdio == NULL) ||
1383 (ghost_info.init_with_args == NULL) || (ghost_info.revision == NULL))
1384 return(MagickFalse);
1388MagickPrivate
const GhostInfo *NTGhostscriptDLLVectors(
void)
1391 path[MagickPathExtent];
1394 ActivateSemaphoreInfo(&ghost_semaphore);
1395 LockSemaphoreInfo(ghost_semaphore);
1396 if (ghost_handle != (
void *) NULL)
1398 UnlockSemaphoreInfo(ghost_semaphore);
1399 if (NTGhostscriptHasValidHandle() == MagickTrue)
1400 return(&ghost_info);
1401 return((GhostInfo *) NULL);
1403 if (NTGhostscriptDLL(path,
sizeof(path)) != MagickTrue)
1405 UnlockSemaphoreInfo(ghost_semaphore);
1406 return((GhostInfo *) NULL);
1408 ghost_handle=lt_dlopen(path);
1409 if (ghost_handle == (
void *) NULL)
1411 UnlockSemaphoreInfo(ghost_semaphore);
1412 return((GhostInfo *) NULL);
1414 (void) memset((
void *) &nt_ghost_info,0,
sizeof(NTGhostInfo));
1415 nt_ghost_info.delete_instance=(void (MagickDLLCall *)(gs_main_instance *)) (
1416 lt_dlsym(ghost_handle,
"gsapi_delete_instance"));
1417 nt_ghost_info.new_instance=(int (MagickDLLCall *)(gs_main_instance **,
1418 void *)) (lt_dlsym(ghost_handle,
"gsapi_new_instance"));
1419 nt_ghost_info.has_instance=MagickFalse;
1420 (void) memset((
void *) &ghost_info,0,
sizeof(GhostInfo));
1421 ghost_info.delete_instance=NTGhostscriptDeleteInstance;
1422 ghost_info.exit=(int (MagickDLLCall *)(gs_main_instance*))
1423 lt_dlsym(ghost_handle,
"gsapi_exit");
1424 ghost_info.init_with_args=(int (MagickDLLCall *)(gs_main_instance *,int,
1425 char **)) (lt_dlsym(ghost_handle,
"gsapi_init_with_args"));
1426 ghost_info.new_instance=NTGhostscriptNewInstance;
1427 ghost_info.run_string=(int (MagickDLLCall *)(gs_main_instance *,
const char *,
1428 int,
int *)) (lt_dlsym(ghost_handle,
"gsapi_run_string"));
1429 ghost_info.set_arg_encoding=(int (MagickDLLCall*)(gs_main_instance*, int)) (
1430 lt_dlsym(ghost_handle,
"gsapi_set_arg_encoding"));
1431 ghost_info.set_stdio=(int (MagickDLLCall *)(gs_main_instance *,int(
1432 MagickDLLCall *)(
void *,
char *,int),
int(MagickDLLCall *)(
void *,
1433 const char *,int),
int(MagickDLLCall *)(
void *,
const char *,int)))
1434 (lt_dlsym(ghost_handle,
"gsapi_set_stdio"));
1435 ghost_info.revision=(int (MagickDLLCall *)(gsapi_revision_t *,int)) (
1436 lt_dlsym(ghost_handle,
"gsapi_revision"));
1437 UnlockSemaphoreInfo(ghost_semaphore);
1438 if (NTGhostscriptHasValidHandle() == MagickTrue)
1439 return(&ghost_info);
1440 return((GhostInfo *) NULL);
1469MagickPrivate
void NTGhostscriptEXE(
char *path,
int length)
1475 program[MagickPathExtent] = {
"" };
1478 is_64_bit_version = FALSE;
1480 if (*program ==
'\0')
1483 ActivateSemaphoreInfo(&ghost_semaphore);
1484 LockSemaphoreInfo(ghost_semaphore);
1485 if (*program ==
'\0')
1487 if (NTGhostscriptGetString(
"GS_DLL",&is_64_bit_version,program,
1488 sizeof(program)) == MagickFalse)
1490 UnlockSemaphoreInfo(ghost_semaphore);
1492 (void) CopyMagickString(program,
"gswin64c.exe",
sizeof(program));
1494 (void) CopyMagickString(program,
"gswin32c.exe",
sizeof(program));
1496 (void) CopyMagickString(path,program,length);
1499 p=strrchr(program,
'\\');
1500 if (p != (
char *) NULL)
1504 (void) ConcatenateMagickString(program,is_64_bit_version ?
1505 "gswin64c.exe" :
"gswin32c.exe",
sizeof(program));
1508 UnlockSemaphoreInfo(ghost_semaphore);
1510 (void) CopyMagickString(path,program,length);
1538MagickPrivate MagickBooleanType NTGhostscriptFonts(
char *path,
int length)
1541 buffer[MagickPathExtent],
1543 filename[MagickPathExtent];
1550 directory=GetEnvironmentValue(
"MAGICK_GHOSTSCRIPT_FONT_PATH");
1551 if (directory != (
char *) NULL)
1553 (void) CopyMagickString(buffer,directory,MagickPathExtent);
1554 directory=DestroyString(directory);
1558 if (NTGhostscriptGetString(
"GS_LIB",NULL,buffer,
1559 MagickPathExtent) == MagickFalse)
1560 return(MagickFalse);
1562 for (p=buffer-1; p != (
char *) NULL; p=strchr(p+1,DirectoryListSeparator))
1564 (void) CopyMagickString(path,p+1,length+1);
1565 q=strchr(path,DirectoryListSeparator);
1566 if (q != (
char *) NULL)
1568 (void) FormatLocaleString(filename,MagickPathExtent,
"%s%sfonts.dir",path,
1569 DirectorySeparator);
1570 if (IsPathAccessible(filename) != MagickFalse)
1572 (void) FormatLocaleString(filename,MagickPathExtent,
"%s%sn019003l.pfb",path,
1573 DirectorySeparator);
1574 if (IsPathAccessible(filename) != MagickFalse)
1578 return(MagickFalse);
1600MagickPrivate
void NTGhostscriptUnLoadDLL(
void)
1603 ActivateSemaphoreInfo(&ghost_semaphore);
1604 LockSemaphoreInfo(ghost_semaphore);
1605 if (ghost_handle != (
void *) NULL)
1607 (void) lt_dlclose(ghost_handle);
1608 ghost_handle=(
void *) NULL;
1609 (void) memset((
void *) &ghost_info,0,
sizeof(GhostInfo));
1611 UnlockSemaphoreInfo(ghost_semaphore);
1612 RelinquishSemaphoreInfo(&ghost_semaphore);
1634MagickExport MagickBooleanType NTLongPathsEnabled()
1637 long_paths_enabled = 2;
1639 if (long_paths_enabled == 2)
1652 registry_key=(HKEY) INVALID_HANDLE_VALUE;
1653 status=RegOpenKeyExA(HKEY_LOCAL_MACHINE,
1654 "SYSTEM\\CurrentControlSet\\Control\\FileSystem",0,KEY_READ,
1656 if (status != ERROR_SUCCESS)
1658 RegCloseKey(registry_key);
1659 long_paths_enabled=0;
1660 return(MagickFalse);
1663 status=RegQueryValueExA(registry_key,
"LongPathsEnabled",0,&type,NULL,
1665 if ((status != ERROR_SUCCESS) || (type != REG_DWORD))
1667 RegCloseKey(registry_key);
1668 long_paths_enabled=0;
1669 return(MagickFalse);
1672 status=RegQueryValueExA(registry_key,
"LongPathsEnabled",0,&type,
1673 (LPBYTE) &value,&size);
1674 RegCloseKey(registry_key);
1675 if (status != ERROR_SUCCESS)
1677 long_paths_enabled=0;
1678 return(MagickFalse);
1680 long_paths_enabled=(size_t) value;
1682 return(long_paths_enabled == 1 ? MagickTrue : MagickFalse);
1704MagickPrivate
void *NTMapMemory(
char *address,
size_t length,
int protection,
1705 int flags,
int file,MagickOffsetType offset)
1724 file_handle=INVALID_HANDLE_VALUE;
1725 low_length=(DWORD) (length & 0xFFFFFFFFUL);
1726 high_length=(DWORD) ((((MagickOffsetType) length) >> 32) & 0xFFFFFFFFUL);
1727 map_handle=INVALID_HANDLE_VALUE;
1729 low_offset=(DWORD) (offset & 0xFFFFFFFFUL);
1730 high_offset=(DWORD) ((offset >> 32) & 0xFFFFFFFFUL);
1732 if (protection & PROT_WRITE)
1734 access_mode=FILE_MAP_WRITE;
1735 if (!(flags & MAP_PRIVATE))
1736 protection_mode=PAGE_READWRITE;
1739 access_mode=FILE_MAP_COPY;
1740 protection_mode=PAGE_WRITECOPY;
1744 if (protection & PROT_READ)
1746 access_mode=FILE_MAP_READ;
1747 protection_mode=PAGE_READONLY;
1749 if ((file == -1) && (flags & MAP_ANONYMOUS))
1750 file_handle=INVALID_HANDLE_VALUE;
1752 file_handle=(HANDLE) _get_osfhandle(file);
1753 map_handle=CreateFileMapping(file_handle,0,protection_mode,high_length,
1757 map=(
void *) MapViewOfFile(map_handle,access_mode,high_offset,low_offset,
1759 CloseHandle(map_handle);
1761 if (map == (
void *) NULL)
1762 return((
void *) ((
char *) MAP_FAILED));
1763 return((
void *) ((
char *) map));
1789MagickPrivate DIR *NTOpenDirectory(
const char *path)
1798 file_specification[MagickPathExtent];
1800 assert(path != (
const char *) NULL);
1801 length=MultiByteToWideChar(CP_UTF8,0,path,-1,file_specification,
1804 return((DIR *) NULL);
1805 if (wcsncat_s(file_specification,MagickPathExtent,L
"\\*.*",MagickPathExtent-
1806 wcslen(file_specification)-1) != 0)
1807 return((DIR *) NULL);
1808 entry=(DIR *) AcquireCriticalMemory(
sizeof(DIR));
1809 entry->firsttime=TRUE;
1810 entry->hSearch=FindFirstFileW(file_specification,&entry->Win32FindData);
1811 if (entry->hSearch == INVALID_HANDLE_VALUE)
1813 entry=(DIR *) RelinquishMagickMemory(entry);
1814 return((DIR *) NULL);
1843static UINT ChangeErrorMode(
void)
1846 (CALLBACK *GETERRORMODE)(void);
1857 mode=SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
1859 handle=GetModuleHandle(
"kernel32.dll");
1860 if (handle == (HMODULE) NULL)
1861 return SetErrorMode(mode);
1863 getErrorMode=(GETERRORMODE) NTGetLibrarySymbol(handle,
"GetErrorMode");
1864 if (getErrorMode != (GETERRORMODE) NULL)
1865 mode=getErrorMode() | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX;
1867 return SetErrorMode(mode);
1870static inline void *NTLoadLibrary(
const char *filename)
1878 library=(
void *) NULL;
1879 path=NTCreateWidePath(filename);
1880 if (path != (
wchar_t *) NULL)
1882 library=LoadLibraryExW(path,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
1883 path=(
wchar_t *) RelinquishMagickMemory(path);
1888MagickPrivate
void *NTOpenLibrary(
const char *filename)
1896 mode=ChangeErrorMode();
1897 handle=NTLoadLibrary(filename);
1898#if defined(MAGICKCORE_LTDL_DELEGATE)
1899 if (handle == (
void *) NULL)
1902 path[MagickPathExtent];
1908 p=lt_dlgetsearchpath();
1909 while (p != (
const char*) NULL)
1911 q=strchr(p,DirectoryListSeparator);
1912 if (q != (
const char*) NULL)
1913 (void) CopyMagickString(path,p,q-p+1);
1915 (
void) CopyMagickString(path,p,MagickPathExtent);
1916 (void) ConcatenateMagickString(path,DirectorySeparator,MagickPathExtent);
1917 (void) ConcatenateMagickString(path,filename,MagickPathExtent);
1918 handle=NTLoadLibrary(path);
1919 if (handle != (
void *) NULL || q == (
const char*) NULL)
1953static inline wchar_t *create_wchar_mode(
const char *mode)
1961 count=MultiByteToWideChar(CP_UTF8,0,mode,-1,NULL,0);
1962 wide=(
wchar_t *) AcquireQuantumMemory((
size_t) count+1,
1964 if (wide == (
wchar_t *) NULL)
1965 return((
wchar_t *) NULL);
1966 if (MultiByteToWideChar(CP_UTF8,0,mode,-1,wide,count) == 0)
1968 wide=(
wchar_t *) RelinquishMagickMemory(wide);
1969 return((
wchar_t *) NULL);
1972 wide[count] = L
'\0';
1973 wide[count-1] = L
'N';
1977MagickExport FILE *NTOpenFileWide(
const char* path,
const char* mode)
1986 path_wide=NTCreateWidePath(path);
1987 if (path_wide == (
wchar_t *) NULL)
1988 return((FILE *) NULL);
1989 mode_wide=create_wchar_mode(mode);
1990 if (mode_wide == (
wchar_t *) NULL)
1992 path_wide=(
wchar_t *) RelinquishMagickMemory(path_wide);
1993 return((FILE *) NULL);
1995 if (_wfopen_s(&file,path_wide,mode_wide) != 0)
1997 mode_wide=(
wchar_t *) RelinquishMagickMemory(mode_wide);
1998 path_wide=(
wchar_t *) RelinquishMagickMemory(path_wide);
2026MagickExport FILE *NTOpenPipeWide(
const char *command,
const char *type)
2039 length=MultiByteToWideChar(CP_UTF8,0,type,-1,type_wide,5);
2042 length=MultiByteToWideChar(CP_UTF8,0,command,-1,NULL,0);
2045 command_wide=(
wchar_t *) AcquireQuantumMemory((
size_t) length,
2046 sizeof(*command_wide));
2047 if (command_wide == (
wchar_t *) NULL)
2049 length=MultiByteToWideChar(CP_UTF8,0,command,-1,command_wide,length);
2051 file=_wpopen(command_wide,type_wide);
2052 command_wide=(
wchar_t *) RelinquishMagickMemory(command_wide);
2082MagickExport
int NTOpenWide(
const char* path,
int flags,mode_t mode)
2091 path_wide=NTCreateWidePath(path);
2092 if (path_wide == (
wchar_t *) NULL)
2095 status=_wsopen_s(&file_handle,path_wide,flags | O_NOINHERIT,_SH_DENYNO,mode);
2096 path_wide=(
wchar_t *) RelinquishMagickMemory(path_wide);
2097 return(status == 0 ? file_handle : -1);
2124MagickPrivate
struct dirent *NTReadDirectory(DIR *entry)
2132 if (entry == (DIR *) NULL)
2133 return((
struct dirent *) NULL);
2134 if (!entry->firsttime)
2136 status=FindNextFileW(entry->hSearch,&entry->Win32FindData);
2138 return((
struct dirent *) NULL);
2140 length=WideCharToMultiByte(CP_UTF8,0,entry->Win32FindData.cFileName,-1,
2141 entry->file_info.d_name,
sizeof(entry->file_info.d_name),NULL,NULL);
2143 return((
struct dirent *) NULL);
2144 entry->firsttime=FALSE;
2145 entry->file_info.d_namlen=(int) strlen(entry->file_info.d_name);
2146 return(&entry->file_info);
2171static inline wchar_t* resolve_symlink(
const wchar_t* path)
2182 file_handle=CreateFileW(path,GENERIC_READ,FILE_SHARE_READ |FILE_SHARE_WRITE |
2183 FILE_SHARE_DELETE,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS,NULL);
2184 if (file_handle == INVALID_HANDLE_VALUE)
2185 return((
wchar_t *) NULL);
2186 link_length=GetFinalPathNameByHandleW(file_handle,NULL,0,
2187 FILE_NAME_NORMALIZED);
2188 link=(
wchar_t *) AcquireQuantumMemory(link_length,
sizeof(
wchar_t));
2189 if (link == (
wchar_t *) NULL)
2191 CloseHandle(file_handle);
2192 return((
wchar_t *) NULL);
2194 GetFinalPathNameByHandleW(file_handle,link,link_length,FILE_NAME_NORMALIZED);
2195 CloseHandle(file_handle);
2199MagickExport
char *NTRealPathWide(
const char *path)
2208 wide_path=NTCreateWidePath(path);
2209 wide_real_path=resolve_symlink(wide_path);
2210 if (wide_real_path == (
wchar_t*) NULL)
2215 full_path_length=GetFullPathNameW(wide_path,0,NULL,NULL);
2216 wide_real_path=(
wchar_t *) AcquireQuantumMemory(full_path_length,
2218 if (wide_real_path == (
wchar_t*) NULL)
2220 wide_path=(
wchar_t *) RelinquishMagickMemory(wide_path);
2221 return((
char*) NULL);
2223 GetFullPathNameW(wide_path,full_path_length,wide_real_path,NULL);
2225 wide_path=(
wchar_t *) RelinquishMagickMemory(wide_path);
2229 if (wcsncmp(wide_real_path,L
"\\\\?\\",4) == 0)
2230 real_path=create_utf8_string(wide_real_path+4);
2232 real_path=create_utf8_string(wide_real_path);
2233 wide_real_path=(
wchar_t *) RelinquishMagickMemory(wide_real_path);
2269MagickPrivate
unsigned char *NTRegistryKeyLookup(
const char *subkey)
2272 package_key[MagickPathExtent] =
"";
2277 (void) FormatLocaleString(package_key,MagickPathExtent,
2278 "SOFTWARE\\%s\\%s\\Q:%d",MagickPackageName,MagickLibVersionText,
2279 MAGICKCORE_QUANTUM_DEPTH);
2280 value=NTGetRegistryValue(HKEY_LOCAL_MACHINE,package_key,0,subkey);
2281 if (value == (
unsigned char *) NULL)
2282 value=NTGetRegistryValue(HKEY_CURRENT_USER,package_key,0,subkey);
2308MagickExport
int NTRemoveWide(
const char *path)
2316 path_wide=NTCreateWidePath(path);
2317 if (path_wide == (
wchar_t *) NULL)
2319 status=_wremove(path_wide);
2320 path_wide=(
wchar_t *) RelinquishMagickMemory(path_wide);
2348MagickExport
int NTRenameWide(
const char* source,
const char* destination)
2357 source_wide=NTCreateWidePath(source);
2358 if (source_wide == (
wchar_t *) NULL)
2360 destination_wide=NTCreateWidePath(destination);
2361 if (destination_wide == (
wchar_t *) NULL)
2363 source_wide=(
wchar_t *) RelinquishMagickMemory(source_wide);
2366 status=_wrename(source_wide,destination_wide);
2367 destination_wide=(
wchar_t *) RelinquishMagickMemory(destination_wide);
2368 source_wide=(
wchar_t *) RelinquishMagickMemory(source_wide);
2397MagickPrivate MagickBooleanType NTReportEvent(
const char *event,
2398 const MagickBooleanType error)
2409 handle=RegisterEventSource(NULL,MAGICKCORE_PACKAGE_NAME);
2411 return(MagickFalse);
2413 type=error ? EVENTLOG_ERROR_TYPE : EVENTLOG_WARNING_TYPE;
2414 ReportEvent(handle,type,0,0,NULL,1,0,events,NULL);
2415 DeregisterEventSource(handle);
2444MagickPrivate
unsigned char *NTResourceToBlob(
const char *
id)
2446#ifndef MAGICKCORE_LIBRARY_NAME
2448 path[MagickPathExtent];
2467 assert(
id != (
const char *) NULL);
2468 if (IsEventLogging() != MagickFalse)
2469 (void) LogMagickEvent(TraceEvent,GetMagickModule(),
"%s",
id);
2470#ifdef MAGICKCORE_LIBRARY_NAME
2471 handle=GetModuleHandle(MAGICKCORE_LIBRARY_NAME);
2473 (void) FormatLocaleString(path,MagickPathExtent,
"%s%s%s",GetClientPath(),
2474 DirectorySeparator,GetClientName());
2475 if (IsPathAccessible(path) != MagickFalse)
2476 handle=GetModuleHandle(path);
2478 handle=GetModuleHandle(0);
2481 return((
unsigned char *) NULL);
2482 resource=FindResource(handle,
id,
"IMAGEMAGICK");
2484 return((
unsigned char *) NULL);
2485 global=LoadResource(handle,resource);
2487 return((
unsigned char *) NULL);
2488 length=SizeofResource(handle,resource);
2489 value=(
unsigned char *) LockResource(global);
2492 FreeResource(global);
2493 return((
unsigned char *) NULL);
2495 blob=(
unsigned char *) AcquireQuantumMemory(length+MagickPathExtent,
2497 if (blob != (
unsigned char *) NULL)
2499 (void) memcpy(blob,value,length);
2502 UnlockResource(global);
2503 FreeResource(global);
2531MagickExport
int NTSetFileTimestamp(
const char *path,
struct stat *attributes)
2543 path_wide=NTCreateWidePath(path);
2544 if (path_wide == (WCHAR *) NULL)
2546 handle=CreateFileW(path_wide,FILE_WRITE_ATTRIBUTES,FILE_SHARE_WRITE |
2547 FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL);
2548 if (handle != (HANDLE) NULL)
2558 date_time.QuadPart=(ULONGLONG) (attributes->st_ctime*10000000LL)+
2559 116444736000000000LL;
2560 creation_time.dwLowDateTime=date_time.LowPart;
2561 creation_time.dwHighDateTime=date_time.HighPart;
2562 date_time.QuadPart=(ULONGLONG) (attributes->st_atime*10000000LL)+
2563 116444736000000000LL;
2564 last_access_time.dwLowDateTime=date_time.LowPart;
2565 last_access_time.dwHighDateTime=date_time.HighPart;
2566 date_time.QuadPart=(ULONGLONG) (attributes->st_mtime*10000000LL)+
2567 116444736000000000LL;
2568 last_write_time.dwLowDateTime=date_time.LowPart;
2569 last_write_time.dwHighDateTime=date_time.HighPart;
2570 status=SetFileTime(handle,&creation_time,&last_access_time,&last_write_time);
2571 CloseHandle(handle);
2574 path_wide=(WCHAR *) RelinquishMagickMemory(path_wide);
2602MagickExport
int NTStatWide(
const char *path,
struct stat *attributes)
2610 path_wide=NTCreateWidePath(path);
2611 if (path_wide == (WCHAR *) NULL)
2613 status=wstat(path_wide,attributes);
2614 path_wide=(WCHAR *) RelinquishMagickMemory(path_wide);
2643MagickPrivate
int NTSystemCommand(
const char *command,
char *output)
2645#define CleanupOutputHandles \
2646 if (read_output != (HANDLE) NULL) \
2648 CloseHandle(read_output); \
2649 read_output=(HANDLE) NULL; \
2650 CloseHandle(write_output); \
2651 write_output=(HANDLE) NULL; \
2654#define CopyLastError \
2655 last_error=GetLastError(); \
2656 if (output != (char *) NULL) \
2658 error=NTGetLastErrorMessage(last_error); \
2659 if (error != (char *) NULL) \
2661 (void) CopyMagickString(output,error,MagickPathExtent); \
2662 error=DestroyString(error); \
2668 local_command[MagickPathExtent];
2693 if (command == (
char *) NULL)
2695 read_output=(HANDLE) NULL;
2696 write_output=(HANDLE) NULL;
2697 GetStartupInfo(&startup_info);
2698 startup_info.dwFlags=STARTF_USESHOWWINDOW;
2699 startup_info.wShowWindow=SW_SHOWMINNOACTIVE;
2700 (void) CopyMagickString(local_command,command,MagickPathExtent);
2701 asynchronous=command[strlen(command)-1] ==
'&' ? MagickTrue : MagickFalse;
2702 if (asynchronous != MagickFalse)
2704 local_command[strlen(command)-1]=
'\0';
2705 startup_info.wShowWindow=SW_SHOWDEFAULT;
2709 if (command[strlen(command)-1] ==
'|')
2710 local_command[strlen(command)-1]=
'\0';
2712 startup_info.wShowWindow=SW_HIDE;
2713 read_output=(HANDLE) NULL;
2714 if (output != (
char *) NULL)
2716 if (CreatePipe(&read_output,&write_output,NULL,0))
2718 if (SetHandleInformation(write_output,HANDLE_FLAG_INHERIT,
2719 HANDLE_FLAG_INHERIT))
2721 startup_info.dwFlags|=STARTF_USESTDHANDLES;
2722 startup_info.hStdOutput=write_output;
2723 startup_info.hStdError=write_output;
2726 CleanupOutputHandles;
2729 read_output=(HANDLE) NULL;
2732 status=CreateProcess((LPCTSTR) NULL,local_command,(LPSECURITY_ATTRIBUTES)
2733 NULL,(LPSECURITY_ATTRIBUTES) NULL,(BOOL) TRUE,(DWORD)
2734 NORMAL_PRIORITY_CLASS,(LPVOID) NULL,(LPCSTR) NULL,&startup_info,
2739 CleanupOutputHandles;
2740 return(last_error == ERROR_FILE_NOT_FOUND ? 127 : -1);
2742 if (output != (
char *) NULL)
2744 if (asynchronous != MagickFalse)
2745 return(status == 0);
2747 status=STATUS_TIMEOUT;
2748 while (status == STATUS_TIMEOUT)
2753 status=WaitForSingleObject(process_info.hProcess,1000);
2755 if (read_output != (HANDLE) NULL)
2756 if (!PeekNamedPipe(read_output,NULL,0,NULL,&size,NULL))
2761 buffer[MagickPathExtent];
2766 if (ReadFile(read_output,buffer,MagickPathExtent-1,&bytes_read,NULL))
2771 count=MagickMin(MagickPathExtent-output_offset,
2772 (
size_t) bytes_read+1);
2775 (void) CopyMagickString(output+output_offset,buffer,count);
2776 output_offset+=count-1;
2779 if (!PeekNamedPipe(read_output,NULL,0,NULL,&size,NULL))
2783 if (status != WAIT_OBJECT_0)
2786 CleanupOutputHandles;
2789 status=GetExitCodeProcess(process_info.hProcess,&child_status);
2793 CleanupOutputHandles;
2796 CloseHandle(process_info.hProcess);
2797 CloseHandle(process_info.hThread);
2798 CleanupOutputHandles;
2799 return((
int) child_status);
2825MagickPrivate ssize_t NTSystemConfiguration(
int name)
2834 GetSystemInfo(&system_info);
2835 return(system_info.dwPageSize);
2837 case _SC_PHYS_PAGES:
2845 status.dwLength=
sizeof(status);
2846 if (GlobalMemoryStatusEx(&status) == 0)
2848 GetSystemInfo(&system_info);
2849 return((ssize_t) status.ullTotalPhys/system_info.dwPageSize);
2883MagickPrivate
int NTTruncateFile(
int file,off_t length)
2895 file_handle=(HANDLE) _get_osfhandle(file);
2896 if (file_handle == INVALID_HANDLE_VALUE)
2898 low=(long) (length & 0xffffffffUL);
2899 high=(long) ((((MagickOffsetType) length) >> 32) & 0xffffffffUL);
2900 file_pointer=SetFilePointer(file_handle,low,&high,FILE_BEGIN);
2901 if ((file_pointer == 0xFFFFFFFF) && (GetLastError() != NO_ERROR))
2903 if (SetEndOfFile(file_handle) == 0)
2932MagickPrivate
int NTUnmapMemory(
void *map,
size_t length)
2935 if (UnmapViewOfFile(map) == 0)
2968MagickPrivate
void NTWarningHandler(
const ExceptionType severity,
2969 const char *reason,
const char *description)
2972 buffer[2*MagickPathExtent];
2975 if (reason == (
char *) NULL)
2977 if (description == (
char *) NULL)
2978 (void) FormatLocaleString(buffer,MagickPathExtent,
"%s: %s.\n",GetClientName(),
2981 (
void) FormatLocaleString(buffer,MagickPathExtent,
"%s: %s (%s).\n",
2982 GetClientName(),reason,description);
2983 (void) MessageBox(NULL,buffer,
"ImageMagick Warning",MB_OK | MB_TASKMODAL |
2984 MB_SETFOREGROUND | MB_ICONINFORMATION);
3005MagickPrivate
void NTWindowsGenesis(
void)
3010 mode=GetEnvironmentValue(
"MAGICK_ERRORMODE");
3011 if (mode != (
char *) NULL)
3013 (void) SetErrorMode(StringToInteger(mode));
3014 mode=DestroyString(mode);
3016#if defined(_DEBUG) && !defined(__MINGW32__)
3017 if (IsEventLogging() != MagickFalse)
3022 debug=_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);
3024 debug |= _CRTDBG_DELAY_FREE_MEM_DF;
3025 debug |= _CRTDBG_LEAK_CHECK_DF;
3026 (void) _CrtSetDbgFlag(debug);
3033#if defined(MAGICKCORE_INSTALLED_SUPPORT)
3038 path=NTRegistryKeyLookup(
"LibPath");
3039 if (path != (
unsigned char *) NULL)
3044 lib_path=NTCreateWidePath((
const char *) path);
3045 if (lib_path != (
wchar_t *) NULL)
3047 SetDllDirectoryW(lib_path);
3048 lib_path=(
wchar_t *) RelinquishMagickMemory(lib_path);
3050 path=(
unsigned char *) RelinquishMagickMemory(path);
3074MagickPrivate
void NTWindowsTerminus(
void)
3076 NTGhostscriptUnLoadDLL();
3077 DistributeCacheTerminus();