I am getting the following error from my code:
Traceback (most recent call last):
File "<pyshell#309>" , line 1, in <module>
get_handles('Py thon26')
File "C:\Python26\e_ _handle.py", line 19, in get_handles
ctypes.windll.u ser32.EnumWindo ws(ctypes.c_lon g(function),cty pes.byref(ctype s.c_char_p(arg) ))
WindowsError: exception: access violation writing 0x0064BCF6
From some searching online I think it's because I'm not able to properly pass the function's address pointer.
So the jist of the code is that I have defined EnumWindowsProc further down. I import the function so now it should be associated with an memory location. I use id(EnumWindowsP roc) to get the address, but when I try to make it a pointer the pointer ends up referencing the location of the integer and not the function. Please let me know if this isn't clear.
I changed the one line to
ctypes.windll.u ser32.EnumWindo ws(ctypes.POINT ER(function),ct ypes.byref(ctyp es.c_char_p(arg )))
and got a different error of:
Traceback (most recent call last):
File "<pyshell#311>" , line 1, in <module>
get_handles('Py thon26')
File "C:\Python26\e_ _handle.py", line 17, in get_handles
ctypes.windll.u ser32.EnumWindo ws(ctypes.POINT ER(function),ct ypes.byref(ctyp es.c_char_p(arg )))
TypeError: must be a ctypes type
Any ideas?
Traceback (most recent call last):
File "<pyshell#309>" , line 1, in <module>
get_handles('Py thon26')
File "C:\Python26\e_ _handle.py", line 19, in get_handles
ctypes.windll.u ser32.EnumWindo ws(ctypes.c_lon g(function),cty pes.byref(ctype s.c_char_p(arg) ))
WindowsError: exception: access violation writing 0x0064BCF6
From some searching online I think it's because I'm not able to properly pass the function's address pointer.
Code:
from e__handle import EnumWindowsProc, EnumChildWindowsProc
import ctypes
global listed
global parents
listed=[]
arg=str(parent_search_text)+'|'+str(parent_case_sensitive)+'|'+str(document)+'|'+str(child_search_text)+'|'+str(child_case_sensitive)+'|'+str(get_children)+'|'+str(id(EnumChildWindowsProc))
function=id(EnumWindowsProc)
ctypes.windll.user32.EnumWindows(ctypes.c_long(function),ctypes.byref(ctypes.c_char_p(arg)))
if document==True:
return listed
else:
listed=[]
I changed the one line to
ctypes.windll.u ser32.EnumWindo ws(ctypes.POINT ER(function),ct ypes.byref(ctyp es.c_char_p(arg )))
and got a different error of:
Traceback (most recent call last):
File "<pyshell#311>" , line 1, in <module>
get_handles('Py thon26')
File "C:\Python26\e_ _handle.py", line 17, in get_handles
ctypes.windll.u ser32.EnumWindo ws(ctypes.POINT ER(function),ct ypes.byref(ctyp es.c_char_p(arg )))
TypeError: must be a ctypes type
Any ideas?
Comment