win32-pdh 0.1.1 → 0.1.4
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/win32/pdh/counter.rb +8 -1
- data/lib/win32/pdh.rb +24 -9
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e46f18c5fb8a3022b81c9e861ae65aeb1a9a86478935efb3868c51b635f851de
|
|
4
|
+
data.tar.gz: 4f8f6c8800700eda846aff5e96ad83760ed6c5996e94cea9cb49c01e7bbf8dbf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 000ff8756967f84acc1bd96d0408f426bab086bf81a2357923652aacf123d8a6e7a6409f14e32d78a7538d7e35f30bbe04d825b5a7f023f2bf15d0a2f73e4d0c
|
|
7
|
+
data.tar.gz: af0cfc18ec75c26400e1ee089f253a99e86c7c836124ff867ae3a49fe742b4b88d8265a73504e8c626316bcb53a1404522aeaa7f587ca4714b303290831b1157
|
data/lib/win32/pdh/counter.rb
CHANGED
data/lib/win32/pdh.rb
CHANGED
|
@@ -20,23 +20,38 @@ module Win32
|
|
|
20
20
|
raise PdhError, status unless status == Constants::ERROR_SUCCESS
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
+
##
|
|
24
|
+
# Gets the length of a cwstr (null-terminated UTF-16 string) in characters
|
|
25
|
+
# (16-bit units).
|
|
26
|
+
#
|
|
27
|
+
# Returns nil if the pointer is null
|
|
28
|
+
def self.strlen_cwstr(pointer)
|
|
29
|
+
return nil if pointer.null?
|
|
30
|
+
|
|
31
|
+
# Clone pointer, so we don't modify the original.
|
|
32
|
+
pointer = FFI::Pointer.new(pointer)
|
|
33
|
+
length = 0
|
|
34
|
+
until pointer.get_uint16(0) == 0
|
|
35
|
+
length += 1
|
|
36
|
+
# Need to proceed 2 bytes at a time; Ruby ffi gives no special pointer
|
|
37
|
+
# arithmetic by type.
|
|
38
|
+
pointer += 2
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
length
|
|
42
|
+
end
|
|
43
|
+
|
|
23
44
|
##
|
|
24
45
|
# Takes a pointer to null-terminated utf-16 data and reads it into a utf-8 encoded string.
|
|
25
46
|
#
|
|
26
47
|
# If pointer is null, return nil instead of a string.
|
|
27
48
|
def self.read_cwstr(pointer)
|
|
28
49
|
return nil if pointer.null?
|
|
29
|
-
array = []
|
|
30
|
-
loop do
|
|
31
|
-
char = pointer.read_uint16
|
|
32
|
-
break if char == 0
|
|
33
50
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
pointer += 2
|
|
37
|
-
end
|
|
51
|
+
# length in wchars
|
|
52
|
+
length = strlen_cwstr(pointer)
|
|
38
53
|
|
|
39
|
-
|
|
54
|
+
pointer.read_bytes(length * 2).force_encoding('UTF-16LE').encode('UTF-8')
|
|
40
55
|
end
|
|
41
56
|
|
|
42
57
|
##
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: win32-pdh
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Taylor C. Richberger
|
|
@@ -14,16 +14,16 @@ dependencies:
|
|
|
14
14
|
name: ffi
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '1.9'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '1.9'
|
|
27
27
|
description: Ruby FFI interface for Windows PDH
|
|
28
28
|
email: tcr@absolute-performance.com
|
|
29
29
|
executables: []
|