Module: FFI::Library

Included in:
ExecutableMemoryPointer::C
Defined in:
lib/ffi/extra.rb

Instance Method Summary collapse

Instance Method Details

#attach_function!(*args, &block) ⇒ Object



65
66
67
68
69
70
71
# File 'lib/ffi/extra.rb', line 65

def attach_function! (*args, &block)
	begin
		attach_function(*args, &block)
	rescue Exception => e
		false
	end
end

#ffi_lib_add(*names) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
# File 'lib/ffi/extra.rb', line 41

def ffi_lib_add (*names)
	ffi_lib *((begin
		ffi_libraries
	rescue Exception
		[]
	end).map {|lib|
		lib.name
	} + names).compact.uniq.reject {|lib|
		lib == '[current process]'
	}
end

#has_function?(sym, libraries = nil) ⇒ Boolean

Returns:

  • (Boolean)


53
54
55
56
57
58
59
60
61
62
63
# File 'lib/ffi/extra.rb', line 53

def has_function? (sym, libraries=nil)
	libraries ||= ffi_libraries

	libraries.any? {|lib|
		if lib.is_a?(DynamicLibrary)
			lib
		else
			DynamicLibrary.new(lib, 0)
		end.find_function(sym.to_s) rescue nil
	}
end