windows-pr 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +4 -0
- data/Rakefile +6 -0
- data/lib/windows/process.rb +9 -0
- data/lib/windows/synchronize.rb +124 -93
- data/test/tc_synchronize.rb +62 -66
- data/windows-pr.gemspec +1 -1
- metadata +4 -5
data/CHANGES
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
= 1.1.1 - 6-Nov-2010
|
2
|
+
* Added some security flags for Job objects to the Windows::Process module.
|
3
|
+
* Added namespace functions to the Windows::Synchronize module.
|
4
|
+
|
1
5
|
= 1.1.0 - 5-Nov-2010
|
2
6
|
* Added the get_volume_type method to the Windows::Volume module.
|
3
7
|
* Added more tests for the Windows::Volume module.
|
data/Rakefile
CHANGED
@@ -30,6 +30,12 @@ namespace 'test' do
|
|
30
30
|
t.test_files = FileList['test/tc_clipboard.rb']
|
31
31
|
end
|
32
32
|
|
33
|
+
Rake::TestTask.new('synchronize') do |t|
|
34
|
+
t.warning = true
|
35
|
+
t.verbose = true
|
36
|
+
t.test_files = FileList['test/tc_synchronize.rb']
|
37
|
+
end
|
38
|
+
|
33
39
|
Rake::TestTask.new('unicode') do |t|
|
34
40
|
t.warning = true
|
35
41
|
t.verbose = true
|
data/lib/windows/process.rb
CHANGED
@@ -96,6 +96,15 @@ module Windows
|
|
96
96
|
JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK = 0x00001000
|
97
97
|
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = 0x00002000
|
98
98
|
|
99
|
+
# Job Access Rights
|
100
|
+
|
101
|
+
JOB_OBJECT_ASSIGN_PROCESS = 0x0001
|
102
|
+
JOB_OBJECT_SET_ATTRIBUTES = 0x0002
|
103
|
+
JOB_OBJECT_OBJECT_QUERY = 0x0004
|
104
|
+
JOB_OBJECT_TERMINATE = 0x0008
|
105
|
+
JOB_OBJECT_SET_SECURITY_ATTRIBUTES = 0x0010
|
106
|
+
JOB_OBJECT_ALL_ACCESS = 0x1F001F
|
107
|
+
|
99
108
|
# Functions
|
100
109
|
|
101
110
|
API.new('AssignProcessToJobObject', 'LL', 'B')
|
data/lib/windows/synchronize.rb
CHANGED
@@ -1,100 +1,131 @@
|
|
1
1
|
require 'windows/api'
|
2
2
|
|
3
3
|
module Windows
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
module Synchronize
|
5
|
+
API.auto_namespace = 'Windows::Synchronize'
|
6
|
+
API.auto_constant = true
|
7
|
+
API.auto_method = true
|
8
|
+
API.auto_unicode = true
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
QS_ALLEVENTS = 0x04BF
|
25
|
-
QS_ALLINPUT = 0x04FF
|
26
|
-
QS_ALLPOSTMESSAGE = 0x0100
|
27
|
-
QS_HOTKEY = 0x0080
|
28
|
-
QS_INPUT = 0x407
|
29
|
-
QS_KEY = 0x0001
|
30
|
-
QS_MOUSE = 0x0006
|
31
|
-
QS_MOUSEBUTTON = 0x0004
|
32
|
-
QS_MOUSEMOVE = 0x0002
|
33
|
-
QS_PAINT = 0x0020
|
34
|
-
QS_POSTMESSAGE = 0x0008
|
35
|
-
QS_RAWINPUT = 0x0400
|
36
|
-
QS_SENDMESSAGE = 0x0040
|
37
|
-
QS_TIMER = 0x0010
|
38
|
-
|
39
|
-
# Wait type constants
|
40
|
-
MWMO_ALERTABLE = 0x0002
|
41
|
-
MWMO_INPUTAVAILABLE = 0x0004
|
42
|
-
MWMO_WAITALL = 0x0001
|
43
|
-
|
44
|
-
# Access rights
|
45
|
-
EVENT_ALL_ACCESS = 0x1F0003
|
46
|
-
EVENT_MODIFY_STATE = 0x0002
|
47
|
-
MUTEX_ALL_ACCESS = 0x1F0001
|
48
|
-
MUTEX_MODIFY_STATE = 0x0001
|
49
|
-
SEMAPHORE_ALL_ACCESS = 0x1F0003
|
50
|
-
SEMAPHORE_MODIFY_STATE = 0x0002
|
10
|
+
INFINITE = 0xFFFFFFFF
|
11
|
+
WAIT_OBJECT_0 = 0
|
12
|
+
WAIT_TIMEOUT = 0x102
|
13
|
+
WAIT_ABANDONED = 128
|
14
|
+
WAIT_ABANDONED_0 = WAIT_ABANDONED
|
15
|
+
WAIT_FAILED = 0xFFFFFFFF
|
16
|
+
|
17
|
+
STATUS_WAIT_0 = 0
|
18
|
+
STATUS_ABANDONED_WAIT_0 = 128
|
19
|
+
STATUS_USER_APC = 192
|
20
|
+
STATUS_TIMEOUT = 258
|
21
|
+
STATUS_PENDING = 259
|
22
|
+
|
23
|
+
# Wake mask constants
|
51
24
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
25
|
+
QS_ALLEVENTS = 0x04BF
|
26
|
+
QS_ALLINPUT = 0x04FF
|
27
|
+
QS_ALLPOSTMESSAGE = 0x0100
|
28
|
+
QS_HOTKEY = 0x0080
|
29
|
+
QS_INPUT = 0x407
|
30
|
+
QS_KEY = 0x0001
|
31
|
+
QS_MOUSE = 0x0006
|
32
|
+
QS_MOUSEBUTTON = 0x0004
|
33
|
+
QS_MOUSEMOVE = 0x0002
|
34
|
+
QS_PAINT = 0x0020
|
35
|
+
QS_POSTMESSAGE = 0x0008
|
36
|
+
QS_RAWINPUT = 0x0400
|
37
|
+
QS_SENDMESSAGE = 0x0040
|
38
|
+
QS_TIMER = 0x0010
|
39
|
+
|
40
|
+
# Wait type constants
|
41
|
+
|
42
|
+
MWMO_ALERTABLE = 0x0002
|
43
|
+
MWMO_INPUTAVAILABLE = 0x0004
|
44
|
+
MWMO_WAITALL = 0x0001
|
45
|
+
|
46
|
+
# Access rights
|
47
|
+
|
48
|
+
EVENT_ALL_ACCESS = 0x1F0003
|
49
|
+
EVENT_MODIFY_STATE = 0x0002
|
50
|
+
MUTEX_ALL_ACCESS = 0x1F0001
|
51
|
+
MUTEX_MODIFY_STATE = 0x0001
|
52
|
+
SEMAPHORE_ALL_ACCESS = 0x1F0003
|
53
|
+
SEMAPHORE_MODIFY_STATE = 0x0002
|
54
|
+
|
55
|
+
# Namespace flags
|
56
|
+
|
57
|
+
PRIVATE_NAMESPACE_FLAG_DESTROY = 0x00000001
|
58
|
+
|
59
|
+
# Functions
|
60
|
+
|
61
|
+
API.new('CancelWaitableTimer', 'L', 'B')
|
62
|
+
API.new('CreateEvent', 'PIIP', 'L')
|
63
|
+
API.new('CreateMutex', 'PIP', 'L')
|
64
|
+
API.new('CreateSemaphore', 'PLLP', 'L')
|
65
|
+
API.new('CreateWaitableTimer', 'PIP', 'L')
|
66
|
+
API.new('DeleteCriticalSection', 'P', 'V')
|
67
|
+
API.new('EnterCriticalSection', 'P', 'V')
|
68
|
+
API.new('GetOverlappedResult', 'LPPI', 'I')
|
69
|
+
API.new('InitializeCriticalSection', 'P', 'V')
|
70
|
+
API.new('InitializeCriticalSectionAndSpinCount', 'PL', 'B')
|
71
|
+
API.new('LeaveCriticalSection', 'P', 'V')
|
72
|
+
API.new('MsgWaitForMultipleObjects', 'LPILL', 'L', 'user32')
|
73
|
+
API.new('MsgWaitForMultipleObjectsEx', 'LPLLL', 'L', 'user32')
|
74
|
+
API.new('OpenEvent', 'LIP', 'L')
|
75
|
+
API.new('OpenMutex', 'LIP', 'L')
|
76
|
+
API.new('OpenSemaphore', 'LIP', 'L')
|
77
|
+
API.new('OpenWaitableTimer', 'LIP', 'L')
|
78
|
+
API.new('ReleaseMutex', 'L', 'B')
|
79
|
+
API.new('ReleaseSemaphore', 'LLP', 'B')
|
80
|
+
API.new('ResetEvent', 'L', 'B')
|
81
|
+
API.new('SetCriticalSectionSpinCount', 'PL', 'V')
|
82
|
+
API.new('SetWaitableTimer', 'LPLKPI', 'B')
|
83
|
+
API.new('SetEvent', 'L', 'B')
|
84
|
+
API.new('TryEnterCriticalSection', 'P', 'B')
|
85
|
+
API.new('WaitForMultipleObjects', 'LPIL', 'L')
|
86
|
+
API.new('WaitForMultipleObjectsEx', 'LPILI', 'L')
|
87
|
+
API.new('WaitForSingleObject', 'LL', 'L')
|
88
|
+
API.new('WaitForSingleObjectEx', 'LLI', 'L')
|
89
|
+
|
90
|
+
# Macros
|
91
|
+
|
92
|
+
def HasOverlappedIoCompleted(overlapped)
|
93
|
+
overlapped[0,4].unpack('L')[0] != STATUS_PENDING
|
94
|
+
end
|
95
|
+
|
96
|
+
# This simulates the RUBY_CRITICAL macro from rubysig.h, although I've
|
97
|
+
# added the begin/ensure wrapper to boot.
|
98
|
+
#
|
99
|
+
def RUBY_CRITICAL(&block)
|
100
|
+
critical_section = [0].pack('L')
|
101
|
+
begin
|
102
|
+
InitializeCriticalSection(critical_section)
|
103
|
+
EnterCriticalSection(critical_section)
|
104
|
+
block.call
|
105
|
+
ensure
|
106
|
+
LeaveCriticalSection(critical_section)
|
85
107
|
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
108
|
+
end
|
109
|
+
|
110
|
+
# Vista or later
|
111
|
+
|
112
|
+
begin
|
113
|
+
API.new('AddSIDToBoundaryDescriptor', 'PP', 'B')
|
114
|
+
API.new('ClosePrivateNamespace', 'LL', 'B')
|
115
|
+
API.new('CreateBoundaryDescriptor', 'SL', 'L')
|
116
|
+
API.new('DeleteBoundaryDescriptor', 'L', 'V')
|
117
|
+
API.new('CreatePrivateNamespace', 'PLS', 'L')
|
118
|
+
API.new('OpenPrivateNamespace', 'PS', 'L')
|
119
|
+
rescue Win32::API::LoadLibraryError
|
120
|
+
# Windows Vista or later
|
121
|
+
end
|
122
|
+
|
123
|
+
# Windows 7 or later
|
124
|
+
|
125
|
+
begin
|
126
|
+
API.new('AddIntegrityLabelToBoundaryDescriptor', 'PP', 'B')
|
127
|
+
rescue Win32::API::LoadLibraryError
|
128
|
+
# Windows 7 or later
|
129
|
+
end
|
130
|
+
end
|
100
131
|
end
|
data/test/tc_synchronize.rb
CHANGED
@@ -6,74 +6,70 @@
|
|
6
6
|
require "windows/synchronize"
|
7
7
|
require "test/unit"
|
8
8
|
|
9
|
-
class SynchFoo
|
10
|
-
include Windows::Synchronize
|
11
|
-
end
|
12
|
-
|
13
9
|
class TC_Windows_Synchronize < Test::Unit::TestCase
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
include Windows::Synchronize
|
11
|
+
|
12
|
+
def setup
|
13
|
+
@handle = (0.chr * 16).unpack('LLLL')
|
14
|
+
end
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
16
|
+
def test_numeric_constants
|
17
|
+
assert_not_nil(INFINITE)
|
18
|
+
assert_not_nil(WAIT_OBJECT_0)
|
19
|
+
assert_not_nil(WAIT_TIMEOUT)
|
20
|
+
assert_not_nil(WAIT_ABANDONED)
|
21
|
+
assert_not_nil(WAIT_FAILED)
|
22
|
+
assert_not_nil(QS_ALLEVENTS)
|
23
|
+
assert_not_nil(QS_ALLINPUT)
|
24
|
+
assert_not_nil(QS_ALLPOSTMESSAGE)
|
25
|
+
assert_not_nil(QS_HOTKEY)
|
26
|
+
assert_not_nil(QS_INPUT)
|
27
|
+
assert_not_nil(QS_KEY)
|
28
|
+
assert_not_nil(QS_MOUSE)
|
29
|
+
assert_not_nil(QS_MOUSEBUTTON)
|
30
|
+
assert_not_nil(QS_MOUSEMOVE)
|
31
|
+
assert_not_nil(QS_PAINT)
|
32
|
+
assert_not_nil(QS_POSTMESSAGE)
|
33
|
+
assert_not_nil(QS_RAWINPUT)
|
34
|
+
assert_not_nil(QS_SENDMESSAGE)
|
35
|
+
assert_not_nil(QS_TIMER)
|
36
|
+
assert_not_nil(MWMO_ALERTABLE)
|
37
|
+
assert_not_nil(MWMO_INPUTAVAILABLE)
|
38
|
+
assert_not_nil(MWMO_WAITALL)
|
39
|
+
assert_not_nil(EVENT_ALL_ACCESS)
|
40
|
+
assert_not_nil(EVENT_MODIFY_STATE)
|
41
|
+
assert_not_nil(MUTEX_ALL_ACCESS)
|
42
|
+
assert_not_nil(MUTEX_MODIFY_STATE)
|
43
|
+
assert_not_nil(SEMAPHORE_ALL_ACCESS)
|
44
|
+
assert_not_nil(SEMAPHORE_MODIFY_STATE)
|
45
|
+
end
|
49
46
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
47
|
+
def test_method_constants
|
48
|
+
assert_not_nil(CreateEvent)
|
49
|
+
assert_not_nil(CreateMutex)
|
50
|
+
assert_not_nil(CreateSemaphore)
|
51
|
+
assert_not_nil(DeleteCriticalSection)
|
52
|
+
assert_not_nil(EnterCriticalSection)
|
53
|
+
assert_not_nil(GetOverlappedResult)
|
54
|
+
assert_not_nil(InitializeCriticalSection)
|
55
|
+
assert_not_nil(InitializeCriticalSectionAndSpinCount)
|
56
|
+
assert_not_nil(LeaveCriticalSection)
|
57
|
+
assert_not_nil(MsgWaitForMultipleObjects)
|
58
|
+
assert_not_nil(MsgWaitForMultipleObjectsEx)
|
59
|
+
assert_not_nil(OpenEvent)
|
60
|
+
assert_not_nil(OpenMutex)
|
61
|
+
assert_not_nil(OpenSemaphore)
|
62
|
+
assert_not_nil(ReleaseMutex)
|
63
|
+
assert_not_nil(ReleaseSemaphore)
|
64
|
+
assert_not_nil(ResetEvent)
|
65
|
+
assert_not_nil(SetEvent)
|
66
|
+
assert_not_nil(WaitForMultipleObjects)
|
67
|
+
assert_not_nil(WaitForMultipleObjectsEx)
|
68
|
+
assert_not_nil(WaitForSingleObject)
|
69
|
+
assert_not_nil(WaitForSingleObjectEx)
|
70
|
+
end
|
74
71
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
72
|
+
def teardown
|
73
|
+
@handle = nil
|
74
|
+
end
|
79
75
|
end
|
data/windows-pr.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: windows-pr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 1.1.
|
9
|
+
- 1
|
10
|
+
version: 1.1.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Daniel J. Berger
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-11-
|
19
|
+
date: 2010-11-06 00:00:00 -06:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -180,7 +180,6 @@ files:
|
|
180
180
|
- test/tc_window_message.rb
|
181
181
|
- test/tc_window_properties.rb
|
182
182
|
- test/tc_window_timer.rb
|
183
|
-
- windows-pr-1.1.0.gem
|
184
183
|
- windows-pr.gemspec
|
185
184
|
has_rdoc: true
|
186
185
|
homepage: http://www.rubyforge.org/projects/win32utils
|