Open
Description
Is your feature request related to a problem? Please describe.
I changed GetMagickModulePath to support a registry path that is decided when users install my program which loads ImageMagick dll files at runtime that are built by myself. But I have to change this function everytime I upgrade to a new version of ImageMagick.
Describe the solution you'd like
Could this functionality be added and for example be enabled by a define?
static MagickBooleanType GetMagickModulePath(const char *filename,
MagickModuleType module_type,char *path,ExceptionInfo *exception)
{
const char
*registery_key;
unsigned char
*key_value;
DWORD success = 1;
char package_key[MagickPathExtent];
DWORD size, type;
HKEY registry_key;
LONG status;
unsigned char *value;
(void)module_type; // Mark the parameter as intentionally unused
assert(filename != (const char *)NULL);
(void)LogMagickEvent(TraceEvent, GetMagickModule(), "%s", filename);
assert(path != (char *)NULL);
assert(exception != (ExceptionInfo *)NULL);
if (strchr(filename, '/') != (char *)NULL)
return(MagickFalse);
(void)CopyMagickString(path, filename, MagickPathExtent);
/*
Locate path via registry key.
*/
registery_key = "ImageMagickPath";
/*
Look-up base key.
*/
(void)CopyMagickString(package_key, "SOFTWARE\\DMM Solutions\\DMM\\3.1", MagickPathExtent);
(void)LogMagickEvent(ConfigureEvent, GetMagickModule(), "%s", package_key);
registry_key = (HKEY)INVALID_HANDLE_VALUE;
status = RegOpenKeyExA(HKEY_LOCAL_MACHINE, package_key, 0, KEY_READ, ®istry_key);
key_value = ((unsigned char*)NULL);
if (status != ERROR_SUCCESS)
{
registry_key = (HKEY)INVALID_HANDLE_VALUE;
success = 0;
}
if (success != 0)
{
/*
Look-up sub key.
*/
size = 32;
value = (unsigned char *)AcquireQuantumMemory(size, sizeof(*value));
if (value == (unsigned char *)NULL)
{
RegCloseKey(registry_key);
success = 0;
}
if (success != 0)
{
(void)LogMagickEvent(ConfigureEvent, GetMagickModule(), "%s", registery_key);
status = RegQueryValueExA(registry_key, registery_key, 0, &type, value, &size);
if ((status == ERROR_MORE_DATA) && (type == REG_SZ))
{
value = (unsigned char *)ResizeQuantumMemory(value, size, sizeof(*value));
if (value == (BYTE *)NULL)
{
RegCloseKey(registry_key);
success = 0;
}
status = RegQueryValueExA(registry_key, registery_key, 0, &type, value, &size);
}
if (success != 0)
{
RegCloseKey(registry_key);
if ((type != REG_SZ) || (status != ERROR_SUCCESS))
value = (unsigned char *)RelinquishMagickMemory(value);
key_value = ((unsigned char *)value);
}
}
}
if (key_value == (unsigned char *)NULL)
{
ThrowMagickException(exception, GetMagickModule(), ConfigureError, "RegistryKeyLookupFailed", "`%s'", registery_key);
return(MagickFalse);
}
(void)FormatLocaleString(path, MagickPathExtent, "%s%s%s", (char *)key_value, DirectorySeparator, filename);
key_value = (unsigned char *)RelinquishMagickMemory(key_value);
if (IsPathAccessible(path) == MagickFalse)
{
ThrowFileException(exception, ConfigureWarning, "UnableToOpenModuleFile", path);
return(MagickFalse);
}
return(MagickTrue);
}
Describe alternatives you've considered
No response
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels