[Ironpython-users] ctypes/struct: Why does this not work?
Michael van der Kolff
mvanderkolff at gmail.com
Sat Dec 15 03:35:18 CET 2012
For background, I'm trying to port paramiko to IronPython. With the
IronPyCrypto, we seem to have everything working apart from Pageant support.
The question is, why does this not work? This is a simplified version of
what Paramiko does - but the point is, run it on CPython and we have
different behaviour.
Cheers,
Michael
import ctypes, ctypes.wintypes, array, mmap
_WM_COPYDATA = 74
_PAGEANT_MAGIC = 0x804e50ba
_MAX_MSG_LEN = 8192
class COPYDATASTRUCT(ctypes.Structure):
_fields_ = [
('num_data', ctypes.c_uint32),
('data_size', ctypes.wintypes.DWORD),
('data_loc', ctypes.c_void_p),
]
hWnd = ctypes.windll.user32.FindWindowA(b'Pageant', b'Pageant') #This works
on IronPython
tagname = "PageantRequest5"
pymap = mmap.mmap(-1,_MAX_MSG_LEN,tagname=tagname, access=mmap.ACCESS_WRITE)
pymap[0:5] = '\0\0\0\x01\x0b' #A request of length one asking for keys from
pageant
cbuf = array.array('c', bytes(tagname + '\0'))
_addr, _size = cbuf.buffer_info()
cds = COPYDATASTRUCT(_PAGEANT_MAGIC, _size, _addr)
response = ctypes.windll.user32.SendMessageA(hWnd, _WM_COPYDATA,
ctypes.sizeof(cds), ctypes.byref(cds))
print response #On CPython 2.7, 1; on Ironpython, 0.
#On CPython, at this stage we can read out the response just by
manipulating the mmap object.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20121215/46c65dce/attachment.html>
More information about the Ironpython-users
mailing list