module Undll32
Undll32
replacement of Windows' rundll32.exe
Constants
- VERSION
Public Class Methods
exe(argv=ARGV)
click to toggle source
# File lib/undll32.rb, line 267 def self.exe(argv=ARGV) return help if ARGV.include? '-h' or ARGV.include? '--help' dllfunc, *args = argv return help if dllfunc.nil? dll, func = dllfunc.split(',') return help if func.nil? dll += '.dll' unless dll.end_with? '.dll' realpath = File.expand_path dll dll = realpath if File.exist? realpath args.map! do |e| e = e.dup if e.start_with?('+') e.slice!(0) next e if e.start_with?('+') Buffer.from(e) else n = Integer(e) rescue nil next n if n e end end ret = run(dll, func, *args) args.each { |e| pp e.unpack if Buffer === e } ret end
help()
click to toggle source
# File lib/undll32.rb, line 293 def self.help puts <<-USAGE undll32 dll,func [...args] EXAMPLE undll32 user32,MessageBox 0 hello world 0 undll32 user32,GetCursorPos +[LL] undll32 user32,GetCursorPos +x,y undll32 user32,GetCursorPos +:8 # will be converted to string ARGUMENTS 0 => (Integer) 0 str => 'str' +0 => '0' ++0 => '+0' +[CSLQ] => Buffer.new([:C, :S, :L, :Q]) +{x:L,y:L} => Buffer.new({:x => :L, :y => :L}) +:256 => Buffer.new(256) VERSION #{VERSION} USAGE end
run(dll, func, *args)
click to toggle source
Undll32.run
'user32', 'MessageBox', 0, 'hello', 'world', 0 Undll32.run
'user32', 'GetCursorPos', Buffer.new
({:x => :L, :y => :L}) Undll32.run
'user32', 'GetCursorPos', Buffer.from
('x,y')
# File lib/undll32.rb, line 261 def self.run(dll, func, *args) types = args.map { |e| Integer === e ? 'L' : 'p' } input = args.map { |e| Buffer === e ? e.buffer : e } Win32API.new(dll, func, types, 'i').call(*input) end