def _query_pageant(msg):
hwnd = _get_pageant_window_object()<EOL>if not hwnd:<EOL><INDENT>return None<EOL><DEDENT>map_name = "<STR_LIT>" % thread.get_ident()<EOL>pymap = _winapi.MemoryMap(<EOL>map_name, _AGENT_MAX_MSGLEN, _winapi.get_security_attributes_for_user()<EOL>)<EOL>with pymap:<EOL><INDENT>pymap.write(msg)<EOL>char_buffer = array.array("<STR_LIT:b>", b(map_name) + zero_byte)  <EOL>char_buffer_address, char_buffer_size = char_buffer.buffer_info()<EOL>cds = COPYDATASTRUCT(<EOL>_AGENT_COPYDATA_ID, char_buffer_size, char_buffer_address<EOL>)<EOL>response = ctypes.windll.user32.SendMessageA(<EOL>hwnd, win32con_WM_COPYDATA, ctypes.sizeof(cds), ctypes.byref(cds)<EOL>)<EOL>if response > <NUM_LIT:0>:<EOL><INDENT>pymap.seek(<NUM_LIT:0>)<EOL>datalen = pymap.read(<NUM_LIT:4>)<EOL>retlen = struct.unpack("<STR_LIT>", datalen)[<NUM_LIT:0>]<EOL>return datalen + pymap.read(retlen)<EOL><DEDENT>return None<EOL><DEDENT>
Communication with the Pageant process is done through a shared
memory-mapped file.