Class: Net::SSH::Authentication::Pageant::Socket19
- Defined in:
- lib/net/ssh/authentication/pageant.rb
Overview
Socket changes for Ruby 1.9 Functionality is the same as Ruby 1.8 but it includes the new calls to the DL module as well as other pointer transformations
Instance Method Summary collapse
-
#send_query(query) ⇒ Object
Packages the given query string and sends it to the pageant process via the Windows messaging subsystem.
Methods inherited from Socket
#close, #closed?, #initialize, open, #read, #send
Constructor Details
This class inherits a constructor from Net::SSH::Authentication::Pageant::Socket
Instance Method Details
#send_query(query) ⇒ Object
Packages the given query string and sends it to the pageant process via the Windows messaging subsystem. The result is cached, to be returned piece-wise when #read is called.
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/net/ssh/authentication/pageant.rb', line 204 def send_query(query) res = nil filemap = 0 ptr = nil id = DL.malloc(DL::SIZEOF_LONG) mapname = "PageantRequest%08x\000" % Win.GetCurrentThreadId() filemap = Win.CreateFileMapping(Win::INVALID_HANDLE_VALUE, Win::NULL, Win::PAGE_READWRITE, 0, AGENT_MAX_MSGLEN, mapname) if filemap == 0 || filemap == Win::INVALID_HANDLE_VALUE raise Net::SSH::Exception, "Creation of file mapping failed" end ptr = Win.MapViewOfFile(filemap, Win::FILE_MAP_WRITE, 0, 0, 0) if ptr.nil? || ptr.null? raise Net::SSH::Exception, "Mapping of file failed" end DL::CPtr.new(ptr)[0,query.size]=query cds = DL::CPtr.to_ptr [AGENT_COPYDATA_ID, mapname.size + 1, mapname]. pack("LLp") succ = Win.SendMessageTimeout(@win, Win::WM_COPYDATA, Win::NULL, cds, Win::SMTO_NORMAL, 5000, id) if succ > 0 retlen = 4 + ptr.to_s(4).unpack("N")[0] res = ptr.to_s(retlen) end return res ensure Win.UnmapViewOfFile(ptr) unless ptr.nil? || ptr.null? Win.CloseHandle(filemap) if filemap != 0 end |