Methods

Class Index [+]

Quicksearch

Net::SSH::Authentication::Pageant::Socket19

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

Public Instance Methods

send_query(query) click to toggle source

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 # is called.

     # File lib/net/ssh/authentication/pageant.rb, line 208
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\0000" % 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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.