<div>For background, I'm trying to port paramiko to IronPython.  With the IronPyCrypto, we seem to have everything working apart from Pageant support.</div><div><br></div><div>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.</div>
<div><br></div><div>Cheers,</div><div><br></div><div>Michael</div><div><br></div>import ctypes, ctypes.wintypes, array, mmap<div><br></div><div>_WM_COPYDATA = 74</div><div>_PAGEANT_MAGIC = 0x804e50ba</div><div>_MAX_MSG_LEN = 8192</div>
<div><br><div>class COPYDATASTRUCT(ctypes.Structure):</div><div>  _fields_ = [</div><div>        ('num_data', ctypes.c_uint32),</div><div>        ('data_size', ctypes.wintypes.DWORD),</div><div>        ('data_loc', ctypes.c_void_p),</div>
<div>        ]</div><div><br></div><div>hWnd = ctypes.windll.user32.FindWindowA(b'Pageant', b'Pageant') #This works on IronPython</div><div><br></div><div>tagname = "PageantRequest5"</div><div>pymap = mmap.mmap(-1,_MAX_MSG_LEN,tagname=tagname, access=mmap.ACCESS_WRITE)</div>
<div>pymap[0:5] = '\0\0\0\x01\x0b' #A request of length one asking for keys from pageant</div><div><br></div><div>cbuf = array.array('c', bytes(tagname + '\0'))</div><div>_addr, _size = cbuf.buffer_info()</div>
<div>cds = COPYDATASTRUCT(_PAGEANT_MAGIC, _size, _addr)</div><div>response = ctypes.windll.user32.SendMessageA(hWnd, _WM_COPYDATA, ctypes.sizeof(cds), ctypes.byref(cds))</div><div>print response #On CPython 2.7, 1; on Ironpython, 0.</div>
<div>#On CPython, at this stage we can read out the response just by manipulating the mmap object.</div><div><br></div></div>