windows-pr 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +5 -0
- data/lib/windows/error.rb +3 -3
- data/lib/windows/memory.rb +26 -0
- data/test/tc_tool_helper.rb +29 -0
- data/windows-pr.gemspec +1 -1
- metadata +4 -2
data/CHANGES
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
= 0.8.7 - 23-Jun-2008
|
2
|
+
* Wide character fix for the get_last_error helper function. Thanks go to
|
3
|
+
Dave Whitley for the spot.
|
4
|
+
* Added local memory functions and constants to the Windows::Memory module.
|
5
|
+
|
1
6
|
= 0.8.6 - 14-Jun-2008
|
2
7
|
* Added the Windows::Network::Winsock module.
|
3
8
|
* Added the Windows::ToolHelper module.
|
data/lib/windows/error.rb
CHANGED
@@ -413,10 +413,10 @@ module Windows
|
|
413
413
|
# returns a human readable string.
|
414
414
|
#
|
415
415
|
def get_last_error(err_num = GetLastError.call)
|
416
|
-
buf = 0.chr * 260
|
417
|
-
flags = FORMAT_MESSAGE_FROM_SYSTEM
|
416
|
+
buf = $KCODE == 'UTF8' ? 0.chr * 520 : 0.chr * 260
|
417
|
+
flags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY
|
418
418
|
FormatMessage.call(flags, 0, err_num, 0, buf, buf.size, 0)
|
419
|
-
buf.split(0.chr).
|
419
|
+
buf.split(0.chr).join[ /^[^\0\r\n]*/ ] rescue 'Unknown error'
|
420
420
|
end
|
421
421
|
|
422
422
|
# Macros from WinError.h
|
data/lib/windows/memory.rb
CHANGED
@@ -53,6 +53,18 @@ module Windows
|
|
53
53
|
SEC_COMMIT = 0x8000000
|
54
54
|
SEC_NOCACHE = 0x10000000
|
55
55
|
|
56
|
+
LMEM_FIXED = 0x0000
|
57
|
+
LMEM_MOVEABLE = 0x0002
|
58
|
+
LMEM_NOCOMPACT = 0x0010
|
59
|
+
LMEM_NODISCARD = 0x0020
|
60
|
+
LMEM_ZEROINIT = 0x0040
|
61
|
+
LMEM_MODIFY = 0x0080
|
62
|
+
LMEM_DISCARDABLE = 0x0F00
|
63
|
+
LMEM_VALID_FLAGS = 0x0F72
|
64
|
+
LMEM_INVALID_HANDLE = 0x8000
|
65
|
+
LMEM_DISCARDED = 0x4000
|
66
|
+
LMEM_LOCKCOUNT = 0x00FF
|
67
|
+
|
56
68
|
API.new('GlobalAlloc', 'II', 'I')
|
57
69
|
API.new('GlobalFlags', 'I', 'I')
|
58
70
|
API.new('GlobalFree', 'I', 'I')
|
@@ -78,6 +90,15 @@ module Windows
|
|
78
90
|
API.new('HeapValidate', 'LLL', 'B')
|
79
91
|
API.new('HeapWalk', 'LP', 'B')
|
80
92
|
|
93
|
+
API.new('LocalAlloc', 'IL', 'L')
|
94
|
+
API.new('LocalFlags', 'L', 'I')
|
95
|
+
API.new('LocalFree', 'L', 'L')
|
96
|
+
API.new('LocalHandle', 'L', 'L')
|
97
|
+
API.new('LocalLock', 'L', 'L')
|
98
|
+
API.new('LocalReAlloc', 'LLI', 'L')
|
99
|
+
API.new('LocalSize', 'L', 'I')
|
100
|
+
API.new('LocalUnlock', 'L', 'B')
|
101
|
+
|
81
102
|
API.new('VirtualAlloc', 'LLLL', 'L')
|
82
103
|
API.new('VirtualAllocEx', 'LLLLL', 'L')
|
83
104
|
API.new('VirtualFree', 'LLL', 'B')
|
@@ -90,6 +111,11 @@ module Windows
|
|
90
111
|
API.new('VirtualUnlock', 'LL', 'B')
|
91
112
|
API.new('RtlZeroMemory', 'PL', 'L')
|
92
113
|
|
114
|
+
# The LocalDiscard macro from winbase.h
|
115
|
+
def LocalDiscard(mem_loc)
|
116
|
+
LocalReAlloc(mem_loc, 0, LMEM_MOVEABLE)
|
117
|
+
end
|
118
|
+
|
93
119
|
# Windows XP or later
|
94
120
|
begin
|
95
121
|
API.new('HeapQueryInformation', 'LIPLL', 'B')
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#####################################################################
|
2
|
+
# tc_tool_helper.rb
|
3
|
+
#
|
4
|
+
# Test case for the Windows::ToolHelper module.
|
5
|
+
#####################################################################
|
6
|
+
require 'windows/tool_helper'
|
7
|
+
require 'test/unit'
|
8
|
+
|
9
|
+
class ToolHelperFoo
|
10
|
+
include Windows::ToolHelper
|
11
|
+
end
|
12
|
+
|
13
|
+
class TC_Windows_ToolHelper < Test::Unit::TestCase
|
14
|
+
def setup
|
15
|
+
@foo = ToolHelperFoo.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_numeric_constants
|
19
|
+
assert_equal(0x00000001, ToolHelperFoo::TH32CS_SNAPHEAPLIST)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_method_constants
|
23
|
+
assert_not_nil(ToolHelperFoo::Process32First)
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
@foo = nil
|
28
|
+
end
|
29
|
+
end
|
data/windows-pr.gemspec
CHANGED
@@ -2,7 +2,7 @@ require "rubygems"
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |gem|
|
4
4
|
gem.name = "windows-pr"
|
5
|
-
gem.version = "0.8.
|
5
|
+
gem.version = "0.8.7"
|
6
6
|
gem.author = "Daniel J. Berger"
|
7
7
|
gem.email = "djberg96@gmail.com"
|
8
8
|
gem.homepage = "http://www.rubyforge.org/projects/win32utils"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: windows-pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel J. Berger
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-06-
|
12
|
+
date: 2008-06-23 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- test/tc_system_info.rb
|
104
104
|
- test/tc_thread.rb
|
105
105
|
- test/tc_time.rb
|
106
|
+
- test/tc_tool_helper.rb
|
106
107
|
- test/tc_unicode.rb
|
107
108
|
- test/tc_volume.rb
|
108
109
|
- test/tc_window.rb
|
@@ -189,6 +190,7 @@ test_files:
|
|
189
190
|
- test/tc_system_info.rb
|
190
191
|
- test/tc_thread.rb
|
191
192
|
- test/tc_time.rb
|
193
|
+
- test/tc_tool_helper.rb
|
192
194
|
- test/tc_unicode.rb
|
193
195
|
- test/tc_volume.rb
|
194
196
|
- test/tc_window.rb
|