Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6611897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:01:50+00:00 2026-05-25T20:01:50+00:00

I’m trying to access some functions in a dll ( nss3.dll ) that ships

  • 0

I’m trying to access some functions in a dll (nss3.dll) that ships with Firefox web browser. To handle this task I have used ctypes in Python. The problem is that it fails at the initial point which is when loading the dll in to the memory.

This is the code snippet that I have to do so.

>>> from ctypes import *
>>> windll.LoadLibrary("E:\\nss3.dll")

The exception I’m getting is

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    windll.LoadLibrary("E:\\nss3.dll")
  File "C:\Python26\lib\ctypes\__init__.py", line 431, in LoadLibrary
    return self._dlltype(name)
  File "C:\Python26\lib\ctypes\__init__.py", line 353, in __init__
    self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

I also tried loading it from the Firefox installation path assuming that there maybe dependencies.

>>> windll.LoadLibrary("F:\\Softwares\\Mozilla Firefox\\nss3.dll")

But I’m getting the same exception as mentioned above.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:01:51+00:00Added an answer on May 25, 2026 at 8:01 pm

    nss3.dll is linked to the following DLLs, which are all located in the Firefox directory: nssutil3.dll, plc4.dll, plds4.dll, nspr4.dll, and mozcrt19.dll. The system library loader looks for these files in the DLL search path of the process, which includes the application directory, system directories, the current directory, and each of the directories listed in the PATH environment variable.

    The simplest solution is to change the current directory to the DLL Firefox directory. However, that’s not thread safe, so I wouldn’t rely on it in general. Another option is to append the Firefox directory to the PATH environment variable, which is what I suggested in my original version of this answer. However, that’s not much better than modifying the current directory.

    Newer versions of Windows (NT 6.0+ with update KB2533623) allow the DLL search path to be updated in a thread-safe manner via SetDefaultDllDirectories, AddDllDirectory, and RemoveDllDirectory. But that approach would be over the top here.

    In this case, for the sake of both simplicity and compatibility with older versions of Windows, it suffices to call LoadLibraryEx with the flag LOAD_WITH_ALTERED_SEARCH_PATH. You need to load the DLL using an absolute path, else the behavior is undefined. For convenience we can subclass ctypes.CDLL and ctypes.WinDLL to call LoadLibraryEx instead of LoadLibrary.

    import os
    import ctypes
    
    if os.name == 'nt':
        from ctypes import wintypes
    
        kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
    
        def check_bool(result, func, args):
            if not result:
                raise ctypes.WinError(ctypes.get_last_error())
            return args
    
        kernel32.LoadLibraryExW.errcheck = check_bool
        kernel32.LoadLibraryExW.restype = wintypes.HMODULE
        kernel32.LoadLibraryExW.argtypes = (wintypes.LPCWSTR,
                                            wintypes.HANDLE,
                                            wintypes.DWORD)
    
    class CDLLEx(ctypes.CDLL):
        def __init__(self, name, mode=0, handle=None, 
                     use_errno=True, use_last_error=False):
            if os.name == 'nt' and handle is None:
                handle = kernel32.LoadLibraryExW(name, None, mode)
            super(CDLLEx, self).__init__(name, mode, handle,
                                         use_errno, use_last_error)
    
    class WinDLLEx(ctypes.WinDLL):
        def __init__(self, name, mode=0, handle=None, 
                     use_errno=False, use_last_error=True):
            if os.name == 'nt' and handle is None:
                handle = kernel32.LoadLibraryExW(name, None, mode)
            super(WinDLLEx, self).__init__(name, mode, handle,
                                           use_errno, use_last_error)
    

    Here are all of the available LoadLibraryEx flags:

    DONT_RESOLVE_DLL_REFERENCES         = 0x00000001
    LOAD_LIBRARY_AS_DATAFILE            = 0x00000002
    LOAD_WITH_ALTERED_SEARCH_PATH       = 0x00000008
    LOAD_IGNORE_CODE_AUTHZ_LEVEL        = 0x00000010  # NT 6.1
    LOAD_LIBRARY_AS_IMAGE_RESOURCE      = 0x00000020  # NT 6.0
    LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE  = 0x00000040  # NT 6.0
    
    # These cannot be combined with LOAD_WITH_ALTERED_SEARCH_PATH.
    # Install update KB2533623 for NT 6.0 & 6.1.
    LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR    = 0x00000100
    LOAD_LIBRARY_SEARCH_APPLICATION_DIR = 0x00000200
    LOAD_LIBRARY_SEARCH_USER_DIRS       = 0x00000400
    LOAD_LIBRARY_SEARCH_SYSTEM32        = 0x00000800
    LOAD_LIBRARY_SEARCH_DEFAULT_DIRS    = 0x00001000
    

    For example:

    firefox_path = r'F:\Softwares\Mozilla Firefox'
    nss3 = CDLLEx(os.path.join(firefox_path, 'nss3.dll'), 
                  LOAD_WITH_ALTERED_SEARCH_PATH)
    
    nss3.NSS_GetVersion.restype = c_char_p
    
    >>> nss3.NSS_GetVersion()                 
    '3.13.5.0 Basic ECC'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm trying to create an if statement in PHP that prevents a single post
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.