208: def send_query(query)
209: res = nil
210: filemap = 0
211: ptr = nil
212: id = DL.malloc(DL::SIZEOF_LONG)
213:
214: mapname = "PageantRequest%08x\000" % Win.GetCurrentThreadId()
215:
216: filemap = Win.CreateFileMapping(Win::INVALID_HANDLE_VALUE,
217: Win::NULL,
218: Win::PAGE_READWRITE, 0,
219: AGENT_MAX_MSGLEN, mapname)
220:
221: if filemap == 0 || filemap == Win::INVALID_HANDLE_VALUE
222: raise Net::SSH::Exception,
223: "Creation of file mapping failed"
224: end
225:
226: ptr = Win.MapViewOfFile(filemap, Win::FILE_MAP_WRITE, 0, 0,
227: 0)
228:
229: if ptr.nil? || ptr.null?
230: raise Net::SSH::Exception, "Mapping of file failed"
231: end
232:
233: DL::CPtr.new(ptr)[0,query.size]=query
234:
235: cds = DL::CPtr.to_ptr [AGENT_COPYDATA_ID, mapname.size + 1, mapname].
236: pack("LLp")
237: succ = Win.SendMessageTimeout(@win, Win::WM_COPYDATA, Win::NULL,
238: cds, Win::SMTO_NORMAL, 5000, id)
239:
240: if succ > 0
241: retlen = 4 + ptr.to_s(4).unpack("N")[0]
242: res = ptr.to_s(retlen)
243: end
244:
245: return res
246: ensure
247: Win.UnmapViewOfFile(ptr) unless ptr.nil? || ptr.null?
248: Win.CloseHandle(filemap) if filemap != 0
249: end