undll32 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/undll32.rb +47 -2
- data/lib/undll32/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e80e26fa2eb8bbc0c7d23333434118a2125395fc70fb92881a0289196afa814
|
4
|
+
data.tar.gz: 9b8dbdbb88c81a9d735f1cf56f3ab8b5e72698b557a5528fe4e465954b95321f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1840b9abede2282463c2d5b433fa522f1b9a98fde80eb1038b10939a264ca58fc85ce282f291599e4b8ea6b163fbe73498bd22ff9ae1d322fde0ca09ee895bec
|
7
|
+
data.tar.gz: 3fcdeb2f46f87013b0ddff0ac3370acb127325665b4796a01824a6a886911aeccc4b4ba6d3b256432526c5bd463190e079ac1445f886a2f0c59ab031dffee742
|
data/lib/undll32.rb
CHANGED
@@ -1,13 +1,58 @@
|
|
1
1
|
require "undll32/version"
|
2
|
-
require '
|
2
|
+
require 'fiddle/import'
|
3
3
|
|
4
4
|
##
|
5
5
|
# Undll32
|
6
6
|
# replacement of Windows' rundll32.exe
|
7
7
|
module Undll32
|
8
8
|
|
9
|
+
class Win32API
|
10
|
+
DLL = {}
|
11
|
+
TYPEMAP = {
|
12
|
+
'0' => Fiddle::TYPE_VOID,
|
13
|
+
'S' => Fiddle::TYPE_VOIDP,
|
14
|
+
'I' => Fiddle::TYPE_LONG,
|
15
|
+
}
|
16
|
+
POINTER_TYPE =
|
17
|
+
Fiddle::SIZEOF_VOIDP == Fiddle::SIZEOF_LONG_LONG ? 'q*' : 'l!*'
|
18
|
+
WIN32_TYPES = 'VPpNnLlIi'
|
19
|
+
DL_TYPES = '0SSI'
|
20
|
+
|
21
|
+
def initialize(dllname, func, import, export = '0', calltype = :stdcall)
|
22
|
+
@proto = [import].join.tr(WIN32_TYPES, DL_TYPES).sub(/^(.)0*$/, '\1')
|
23
|
+
import = @proto.chars.map { |e| TYPEMAP[e.tr(WIN32_TYPES, DL_TYPES)] }
|
24
|
+
export = TYPEMAP[export.tr(WIN32_TYPES, DL_TYPES)]
|
25
|
+
calltype = Fiddle::Importer.const_get(:CALL_TYPE_TO_ABI)[calltype]
|
26
|
+
handle = DLL[dllname] ||=
|
27
|
+
begin
|
28
|
+
Fiddle.dlopen(dllname)
|
29
|
+
rescue Fiddle::DLError
|
30
|
+
raise unless File.extname(dllname).empty?
|
31
|
+
Fiddle.dlopen("#{dllname}.dll")
|
32
|
+
end
|
33
|
+
@func = Fiddle::Function.new(handle[func], import, export, calltype)
|
34
|
+
rescue Fiddle::DLError => e
|
35
|
+
raise LoadError, e.message, e.backtrace
|
36
|
+
end
|
37
|
+
|
38
|
+
def call(*args)
|
39
|
+
import = @proto.split('')
|
40
|
+
args.each_with_index do |x, i|
|
41
|
+
if import[i] == 'S'
|
42
|
+
args[i] = [x == 0 ? nil : x].pack('p').unpack(POINTER_TYPE)
|
43
|
+
end
|
44
|
+
args[i], = [x].pack('I').unpack('i') if import[i] == 'I'
|
45
|
+
end
|
46
|
+
ret, = @func.call(*args)
|
47
|
+
ret || 0
|
48
|
+
end
|
49
|
+
|
50
|
+
alias Call call
|
51
|
+
end
|
52
|
+
|
9
53
|
##
|
10
|
-
# represents a string/struct
|
54
|
+
# represents a string/struct.
|
55
|
+
# a thinner version can be found at hyrious/rgstl/blob/master/scripts/api.rb
|
11
56
|
# Buffer.new({ :x => :L, :y => 4 })
|
12
57
|
# Buffer.new([ :L, 4 ])
|
13
58
|
# Buffer.new(:L)
|
data/lib/undll32/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: undll32
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hyrious
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,8 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
requirements: []
|
80
|
-
|
81
|
-
rubygems_version: 2.7.6
|
80
|
+
rubygems_version: 3.0.1
|
82
81
|
signing_key:
|
83
82
|
specification_version: 4
|
84
83
|
summary: Windows rundll32 replacement.
|