Python win32api.FreeLibrary() Examples

The following are 26 code examples of win32api.FreeLibrary(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module win32api , or try the search function .
Example #1
Source File: gyptest-link-generate-manifest.py    From kawalpemilu2014 with GNU Affero General Public License v3.0 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #2
Source File: util.py    From code with MIT License 5 votes vote down vote up
def load_string_resource(pointer):
    """Resolve a @dllname,ordinal string resource pointer"""

    if pointer[0] != "@":
        return pointer

    resfile, resid = pointer[1:].split(",")
    resid = int(resid)

    hRes = Api.LoadLibraryEx(resfile, 0, Con.LOAD_LIBRARY_AS_DATAFILE)
    val = Api.LoadString(hRes, -resid, 1024)
    Api.FreeLibrary(hRes)

    return val.split('\x00', 1)[0] 
Example #3
Source File: gyptest-link-enable-uac.py    From android-xmrig-miner with GNU General Public License v3.0 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #4
Source File: gyptest-link-embed-manifest.py    From android-xmrig-miner with GNU General Public License v3.0 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #5
Source File: gyptest-link-update-manifest.py    From android-xmrig-miner with GNU General Public License v3.0 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #6
Source File: gyptest-link-generate-manifest.py    From android-xmrig-miner with GNU General Public License v3.0 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #7
Source File: hook-pythoncom.py    From ConTroll_Remote_Access_Trojan with Apache License 2.0 5 votes vote down vote up
def hook(mod):
    import sys
    newname = 'pythoncom%d%d' % sys.version_info[:2]
    if mod.typ == 'EXTENSION':
        mod.__name__ = newname
    else:
        import win32api
        h = win32api.LoadLibrary(newname + '.dll')
        pth = win32api.GetModuleFileName(h)
        #win32api.FreeLibrary(h)
        mod = PyInstaller.depend.modules.ExtensionModule(newname, pth)
    return mod 
Example #8
Source File: hook-pywintypes.py    From ConTroll_Remote_Access_Trojan with Apache License 2.0 5 votes vote down vote up
def hook(mod):
    import sys
    newname = 'pywintypes%d%d' % sys.version_info[:2]
    if mod.typ == 'EXTENSION':
        mod.__name__ = newname
    else:
        import win32api
        h = win32api.LoadLibrary(newname + '.dll')
        pth = win32api.GetModuleFileName(h)
        #win32api.FreeLibrary(h)
        mod = PyInstaller.depend.modules.ExtensionModule(newname, pth)
    return mod 
Example #9
Source File: versioninfo.py    From ConTroll_Remote_Access_Trojan with Apache License 2.0 5 votes vote down vote up
def decode(pathnm):
    h = win32api.LoadLibraryEx(pathnm, 0, LOAD_LIBRARY_AS_DATAFILE)
    nm = win32api.EnumResourceNames(h, RT_VERSION)[0]
    data = win32api.LoadResource(h, RT_VERSION, nm)
    vs = VSVersionInfo()
    j = vs.fromRaw(data)
    if TEST:
        print vs
        if data[:j] != vs.toRaw():
            print "AAAAAGGHHHH"
        glbls = {
            'VSVersionInfo': VSVersionInfo,
            'FixedFileInfo': FixedFileInfo,
            'StringFileInfo': StringFileInfo,
            'StringTable': StringTable,
            'StringStruct': StringStruct,
            'VarFileInfo': VarFileInfo,
            'VarStruct': VarStruct,
            }
        vs2 = eval(repr(vs), glbls)
        if vs.toRaw() != vs2.toRaw():
            print
            print 'reconstruction not the same!'
            print vs2
    win32api.FreeLibrary(h)
    return vs 
Example #10
Source File: winresource.py    From ConTroll_Remote_Access_Trojan with Apache License 2.0 5 votes vote down vote up
def GetResources(filename, types=None, names=None, languages=None):
    """
    Get resources from dll/exe file.
    
    types = a list of resource types to search for (None = all)
    names = a list of resource names to search for (None = all)
    languages = a list of resource languages to search for (None = all)
    Return a dict of the form {type_: {name: {language: data}}} which 
    might also be empty if no matching resources were found.
    
    """
    hsrc = win32api.LoadLibraryEx(filename, 0, LOAD_LIBRARY_AS_DATAFILE)
    res = _GetResources(hsrc, types, names, languages)
    win32api.FreeLibrary(hsrc)
    return res 
Example #11
Source File: gyptest-link-enable-uac.py    From kawalpemilu2014 with GNU Affero General Public License v3.0 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #12
Source File: gyptest-link-embed-manifest.py    From kawalpemilu2014 with GNU Affero General Public License v3.0 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #13
Source File: gyptest-link-update-manifest.py    From kawalpemilu2014 with GNU Affero General Public License v3.0 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #14
Source File: win32evtlogutil.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def FormatMessage( eventLogRecord, logType="Application" ):
    """Given a tuple from ReadEventLog, and optionally where the event
    record came from, load the message, and process message inserts.

    Note that this function may raise win32api.error.  See also the
    function SafeFormatMessage which will return None if the message can
    not be processed.
    """

    # From the event log source name, we know the name of the registry
    # key to look under for the name of the message DLL that contains
    # the messages we need to extract with FormatMessage. So first get
    # the event log source name...
    keyName = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s" % (logType, eventLogRecord.SourceName)

    # Now open this key and get the EventMessageFile value, which is
    # the name of the message DLL.
    handle = win32api.RegOpenKey(win32con.HKEY_LOCAL_MACHINE, keyName)
    try:
        dllNames = win32api.RegQueryValueEx(handle, "EventMessageFile")[0].split(";")
        # Win2k etc appear to allow multiple DLL names
        data = None
        for dllName in dllNames:
            try:
                # Expand environment variable strings in the message DLL path name,
                # in case any are there.
                dllName = win32api.ExpandEnvironmentStrings(dllName)

                dllHandle = win32api.LoadLibraryEx(dllName, 0, win32con.LOAD_LIBRARY_AS_DATAFILE)
                try:
                    data = win32api.FormatMessageW(win32con.FORMAT_MESSAGE_FROM_HMODULE,
                                    dllHandle, eventLogRecord.EventID, langid, eventLogRecord.StringInserts)
                finally:
                    win32api.FreeLibrary(dllHandle)
            except win32api.error:
                pass # Not in this DLL - try the next
            if data is not None:
                break
    finally:
        win32api.RegCloseKey(handle)
    return data or u'' # Don't want "None" ever being returned. 
Example #15
Source File: gyptest-link-enable-uac.py    From gyp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #16
Source File: gyptest-link-embed-manifest.py    From gyp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #17
Source File: gyptest-link-update-manifest.py    From gyp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #18
Source File: gyptest-link-generate-manifest.py    From gyp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #19
Source File: gyptest-link-enable-uac.py    From gyp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #20
Source File: gyptest-link-embed-manifest.py    From gyp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #21
Source File: gyptest-link-update-manifest.py    From gyp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #22
Source File: gyptest-link-generate-manifest.py    From gyp with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
      win32api.FreeLibrary(self._handle) 
Example #23
Source File: gyptest-link-enable-uac.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
    win32api.FreeLibrary(self._handle) 
Example #24
Source File: gyptest-link-embed-manifest.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
    win32api.FreeLibrary(self._handle) 
Example #25
Source File: gyptest-link-update-manifest.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
    win32api.FreeLibrary(self._handle) 
Example #26
Source File: gyptest-link-generate-manifest.py    From GYP3 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def __exit__(self, type, value, traceback):
    win32api.FreeLibrary(self._handle)