def get(self): inputHookFunc = c_void_p.from_address(self.inputHookPtr).value Cevent = INPUT_RECORD() count = DWORD(0) while 1: if inputHookFunc: call_function(inputHookFunc, ()) status = self.ReadConsoleInputW(self.hin, byref(Cevent), 1, byref(count)) if status and count.value == 1: e = event(self, Cevent) return e
def get(self): '''Get next event from queue.''' inputHookFunc = c_int.from_address(self.inputHookPtr).value Cevent = INPUT_RECORD() count = c_int(0) while 1: if inputHookFunc: call_function(inputHookFunc, ()) status = self.ReadConsoleInputA(self.hin, byref(Cevent), 1, byref(count)) if status and count.value == 1: e = event(self, Cevent) return e
def get(self): u"""Get next event from queue.""" inputHookFunc = c_void_p.from_address(self.inputHookPtr).value Cevent = INPUT_RECORD() count = DWORD(0) while 1: if inputHookFunc: call_function(inputHookFunc, ()) status = self.ReadConsoleInputW(self.hin, byref(Cevent), 1, byref(count)) if status and count.value == 1: e = event(self, Cevent) return e
def get(self): '''Get next event from queue.''' inputHookFunc = c_int.from_address(self.inputHookPtr).value Cevent = INPUT_RECORD() count = c_int(0) while 1: if inputHookFunc: call_function(inputHookFunc, ()) status = self.ReadConsoleInputW(self.hin, byref(Cevent), 1, byref(count)) if status and count.value == 1: e = event(self, Cevent) log_sock(ensure_unicode(e.keyinfo),"keypress") return e
def test(self): from _ctypes import call_function hdll = windll.kernel32.LoadLibraryA("kernel32") funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA") self.failUnlessEqual(call_function(funcaddr, (None, )), windll.kernel32.GetModuleHandleA(None))
def test(self): from _ctypes import call_function hdll = windll.kernel32.LoadLibraryA("kernel32") funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA") self.failUnlessEqual(call_function(funcaddr, (None,)), windll.kernel32.GetModuleHandleA(None))
def test(self): from _ctypes import call_function windll.kernel32.LoadLibraryA.restype = c_void_p windll.kernel32.GetProcAddress.argtypes = (c_void_p, c_char_p) windll.kernel32.GetProcAddress.restype = c_void_p hdll = windll.kernel32.LoadLibraryA('kernel32') funcaddr = windll.kernel32.GetProcAddress(hdll, 'GetModuleHandleA') self.assertEqual(call_function(funcaddr, (None,)), windll.kernel32.GetModuleHandleA(None)) return
def test_1703286_B(self): from _ctypes import call_function advapi32 = windll.advapi32 self.assertEqual(0, advapi32.CloseEventLog(None)) windll.kernel32.GetProcAddress.argtypes = (c_void_p, c_char_p) windll.kernel32.GetProcAddress.restype = c_void_p proc = windll.kernel32.GetProcAddress(advapi32._handle, 'CloseEventLog') self.assertTrue(proc) self.assertEqual(0, call_function(proc, (None,))) return
def test(self): from _ctypes import call_function windll.kernel32.LoadLibraryA.restype = c_void_p windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p windll.kernel32.GetProcAddress.restype = c_void_p hdll = windll.kernel32.LoadLibraryA(b"kernel32") funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA") self.failUnlessEqual(call_function(funcaddr, (None, )), windll.kernel32.GetModuleHandleA(None))
def test(self): from _ctypes import call_function windll.kernel32.LoadLibraryA.restype = c_void_p windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p windll.kernel32.GetProcAddress.restype = c_void_p hdll = windll.kernel32.LoadLibraryA(b"kernel32") funcaddr = windll.kernel32.GetProcAddress(hdll, "GetModuleHandleA") self.failUnlessEqual(call_function(funcaddr, (None,)), windll.kernel32.GetModuleHandleA(None))
def test_1703286_B(self): # Since on winXP 64-bit advapi32 loads like described # above, the (arbitrarily selected) CloseEventLog function # also has a high address. 'call_function' should accept # addresses so large. from _ctypes import call_function advapi32 = windll.advapi32 # Calling CloseEventLog with a NULL argument should fail, # but the call should not segfault or so. self.failUnlessEqual(0, advapi32.CloseEventLog(None)) windll.kernel32.GetProcAddress.argtypes = c_void_p, c_char_p windll.kernel32.GetProcAddress.restype = c_void_p proc = windll.kernel32.GetProcAddress(advapi32._handle, "CloseEventLog") self.failUnless(proc) # This is the real test: call the function via 'call_function' self.failUnlessEqual(0, call_function(proc, (None,)))