zoukankan      html  css  js  c++  java
  • 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);
    }
  • 相关阅读:
    (2/24) 快速上手一个webpack的demo
    (1/24) 认识webpack
    module.exports 、exports、export、export default的区别
    Git同时提交到多个远程仓库
    @codeforces
    @loj
    @bzoj
    @loj
    @bzoj
    @bzoj
  • 原文地址:https://www.cnblogs.com/personnel/p/12321634.html
Copyright © 2011-2022 走看看