python类dllhandle()的实例源码

regutil.py 文件源码 项目:purelove 作者: hucmosin 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def RegisterCoreDLL(coredllName = None):
    """Registers the core DLL in the registry.

        If no params are passed, the name of the Python DLL used in 
        the current process is used and registered.
    """
    if coredllName is None:
        coredllName = win32api.GetModuleFileName(sys.dllhandle)
        # must exist!
    else:
        try:
            os.stat(coredllName)
        except os.error:
            print "Warning: Registering non-existant core DLL %s" % coredllName

    hKey = win32api.RegCreateKey(GetRootKey() , BuildDefaultPythonKey())
    try:
        win32api.RegSetValue(hKey, "Dll", win32con.REG_SZ, coredllName)
    finally:
        win32api.RegCloseKey(hKey)
    # Lastly, setup the current version to point to me.
    win32api.RegSetValue(GetRootKey(), "Software\\Python\\PythonCore\\CurrentVersion", win32con.REG_SZ, sys.winver)
console.py 文件源码 项目:PyMal 作者: cysinfo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def install_readline(hook):
    '''Set up things for the interpreter to call our function like GNU readline.'''
    global readline_hook, readline_ref
    # save the hook so the wrapper can call it
    readline_hook = hook
    # get the address of PyOS_ReadlineFunctionPointer so we can update it
    PyOS_RFP = c_int.from_address(Console.GetProcAddress(sys.dllhandle,
                                                 "PyOS_ReadlineFunctionPointer"))
    # save a reference to the generated C-callable so it doesn't go away
    if sys.version < '2.3':
        readline_ref = HOOKFUNC22(hook_wrapper)
    else:
        readline_ref = HOOKFUNC23(hook_wrapper_23)
    # get the address of the function
    func_start = c_int.from_address(addressof(readline_ref)).value
    # write the function address into PyOS_ReadlineFunctionPointer
    PyOS_RFP.value = func_start
console.py 文件源码 项目:isf 作者: w3h 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def install_readline(hook):
    '''Set up things for the interpreter to call 
    our function like GNU readline.'''
    global readline_hook, readline_ref
    # save the hook so the wrapper can call it
    readline_hook = hook
    # get the address of PyOS_ReadlineFunctionPointer so we can update it
    PyOS_RFP = c_void_p.from_address(Console.GetProcAddress(sys.dllhandle,
                           "PyOS_ReadlineFunctionPointer".encode('ascii')))
    # save a reference to the generated C-callable so it doesn't go away
    if sys.version < '2.3':
        readline_ref = HOOKFUNC22(hook_wrapper)
    else:
        readline_ref = HOOKFUNC23(hook_wrapper_23)
    # get the address of the function
    func_start = c_void_p.from_address(addressof(readline_ref)).value
    # write the function address into PyOS_ReadlineFunctionPointer
    PyOS_RFP.value = func_start
regutil.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def RegisterCoreDLL(coredllName = None):
    """Registers the core DLL in the registry.

        If no params are passed, the name of the Python DLL used in 
        the current process is used and registered.
    """
    if coredllName is None:
        coredllName = win32api.GetModuleFileName(sys.dllhandle)
        # must exist!
    else:
        try:
            os.stat(coredllName)
        except os.error:
            print "Warning: Registering non-existant core DLL %s" % coredllName

    hKey = win32api.RegCreateKey(GetRootKey() , BuildDefaultPythonKey())
    try:
        win32api.RegSetValue(hKey, "Dll", win32con.REG_SZ, coredllName)
    finally:
        win32api.RegCloseKey(hKey)
    # Lastly, setup the current version to point to me.
    win32api.RegSetValue(GetRootKey(), "Software\\Python\\PythonCore\\CurrentVersion", win32con.REG_SZ, sys.winver)
regutil.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 60 收藏 0 点赞 0 评论 0
def RegisterCoreDLL(coredllName = None):
    """Registers the core DLL in the registry.

        If no params are passed, the name of the Python DLL used in 
        the current process is used and registered.
    """
    if coredllName is None:
        coredllName = win32api.GetModuleFileName(sys.dllhandle)
        # must exist!
    else:
        try:
            os.stat(coredllName)
        except os.error:
            print("Warning: Registering non-existant core DLL %s" % coredllName)

    hKey = win32api.RegCreateKey(GetRootKey() , BuildDefaultPythonKey())
    try:
        win32api.RegSetValue(hKey, "Dll", win32con.REG_SZ, coredllName)
    finally:
        win32api.RegCloseKey(hKey)
    # Lastly, setup the current version to point to me.
    win32api.RegSetValue(GetRootKey(), "Software\\Python\\PythonCore\\CurrentVersion", win32con.REG_SZ, sys.winver)
console.py 文件源码 项目:shadowbroker-auto 作者: wrfly 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def install_readline(hook):
    '''Set up things for the interpreter to call our function like GNU readline.'''
    global readline_hook, readline_ref
    # save the hook so the wrapper can call it
    readline_hook = hook
    # get the address of PyOS_ReadlineFunctionPointer so we can update it
    PyOS_RFP = c_int.from_address(Console.GetProcAddress(sys.dllhandle,
                                                 "PyOS_ReadlineFunctionPointer"))
    # save a reference to the generated C-callable so it doesn't go away
    if sys.version < '2.3':
        readline_ref = HOOKFUNC22(hook_wrapper)
    else:
        readline_ref = HOOKFUNC23(hook_wrapper_23)
    # get the address of the function
    func_start = c_int.from_address(addressof(readline_ref)).value
    # write the function address into PyOS_ReadlineFunctionPointer
    PyOS_RFP.value = func_start
console.py 文件源码 项目:themole 作者: tiankonguse 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def install_readline(hook):
    '''Set up things for the interpreter to call 
    our function like GNU readline.'''
    global readline_hook, readline_ref
    # save the hook so the wrapper can call it
    readline_hook = hook
    # get the address of PyOS_ReadlineFunctionPointer so we can update it
    PyOS_RFP = c_void_p.from_address(Console.GetProcAddress(sys.dllhandle,
                           "PyOS_ReadlineFunctionPointer".encode('ascii')))
    # save a reference to the generated C-callable so it doesn't go away
    if sys.version < '2.3':
        readline_ref = HOOKFUNC22(hook_wrapper)
    else:
        readline_ref = HOOKFUNC23(hook_wrapper_23)
    # get the address of the function
    func_start = c_void_p.from_address(addressof(readline_ref)).value
    # write the function address into PyOS_ReadlineFunctionPointer
    PyOS_RFP.value = func_start
handles.py 文件源码 项目:remoteControlPPT 作者: htwenning 项目源码 文件源码 阅读 37 收藏 0 点赞 0 评论 0
def testOtherHandle(self):
        h=pywintypes.HANDLE(1)
        h2=pywintypes.HANDLE(h)
        self.failUnlessEqual(h, h2)
        # but the above doesn't really test everything - we want a way to
        # pass the handle directly into PyWinLong_AsVoidPtr.  One way to
        # to that is to abuse win32api.GetProcAddress() - the 2nd param
        # is passed to PyWinLong_AsVoidPtr() if its not a string.
        # passing a handle value of '1' should work - there is something
        # at that ordinal
        win32api.GetProcAddress(sys.dllhandle, h)
handles.py 文件源码 项目:CodeReader 作者: jasonrbr 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def testOtherHandle(self):
        h=pywintypes.HANDLE(1)
        h2=pywintypes.HANDLE(h)
        self.failUnlessEqual(h, h2)
        # but the above doesn't really test everything - we want a way to
        # pass the handle directly into PyWinLong_AsVoidPtr.  One way to
        # to that is to abuse win32api.GetProcAddress() - the 2nd param
        # is passed to PyWinLong_AsVoidPtr() if its not a string.
        # passing a handle value of '1' should work - there is something
        # at that ordinal
        win32api.GetProcAddress(sys.dllhandle, h)
console.py 文件源码 项目:OWASP-ZSC-API 作者: viraintel 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def install_readline(hook):
    '''Set up things for the interpreter to call 
    our function like GNU readline.'''
    global readline_hook, readline_ref
    # save the hook so the wrapper can call it
    readline_hook = hook
    # get the address of PyOS_ReadlineFunctionPointer so we can update it
    PyOS_RFP = c_void_p.from_address(Console.GetProcAddress(
        sys.dllhandle, "PyOS_ReadlineFunctionPointer".encode('ascii')))
    # save a reference to the generated C-callable so it doesn't go away
    readline_ref = HOOKFUNC23(hook_wrapper_23)
    # get the address of the function
    func_start = c_void_p.from_address(addressof(readline_ref)).value
    # write the function address into PyOS_ReadlineFunctionPointer
    PyOS_RFP.value = func_start


问题


面经


文章

微信
公众号

扫码关注公众号