ImageMagick 加载 dll 相关的源代码

根据 NTLoadLibrary() 的源代码,可以看出,  ImageMagick 内部使用的是 utf-8 编码,并且 NTLoadLibrary() 在加载 dll 的时候,先将 dll 的路径 转换成 wchar_t, 然后使用 LoadLibraryExW() 加载 dll

 

static inline void *NTLoadLibrary(const char *filename)
{
  int
    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;

  UINT
    mode;

  void
    *handle;

  mode=ChangeErrorMode();
  handle=NTLoadLibrary(filename);
  if (handle == (void *) NULL)
    {
      p=GetSearchPath();
      while (p != (const char*) NULL)
      {
        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;
      }
    }
  SetErrorMode(mode);
  return(handle);
}

 

posted @ 2020-02-17 14:25  personnel  阅读(308)  评论(0编辑  收藏  举报
友情链接:图片批量处理工具 gif动态图制作工具 制作电子相册 图片排版工具 制作淘宝主图视频 MKScript 鼠标键盘自动化脚本语言