windows-pr 1.1.2 → 1.1.3
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.
- data/CHANGES +408 -404
- data/MANIFEST +65 -65
- data/README +149 -149
- data/Rakefile +52 -52
- data/doc/conversion_guide.txt +37 -37
- data/lib/windows/clipboard.rb +59 -59
- data/lib/windows/com.rb +190 -189
- data/lib/windows/com/automation.rb +147 -147
- data/lib/windows/com/variant.rb +22 -22
- data/lib/windows/console.rb +112 -112
- data/lib/windows/debug.rb +33 -33
- data/lib/windows/device_io.rb +246 -246
- data/lib/windows/directory.rb +25 -25
- data/lib/windows/error.rb +482 -482
- data/lib/windows/eventlog.rb +78 -78
- data/lib/windows/file.rb +262 -262
- data/lib/windows/file_mapping.rb +23 -23
- data/lib/windows/filesystem.rb +13 -13
- data/lib/windows/gdi/bitmap.rb +63 -63
- data/lib/windows/gdi/device_context.rb +44 -44
- data/lib/windows/gdi/metafile.rb +38 -38
- data/lib/windows/gdi/painting_drawing.rb +113 -113
- data/lib/windows/handle.rb +21 -21
- data/lib/windows/library.rb +42 -42
- data/lib/windows/limits.rb +31 -31
- data/lib/windows/mailslot.rb +22 -22
- data/lib/windows/memory.rb +126 -126
- data/lib/windows/msvcrt/buffer.rb +73 -73
- data/lib/windows/msvcrt/directory.rb +29 -29
- data/lib/windows/msvcrt/file.rb +45 -45
- data/lib/windows/msvcrt/io.rb +71 -71
- data/lib/windows/msvcrt/time.rb +167 -167
- data/lib/windows/national.rb +578 -578
- data/lib/windows/network/management.rb +523 -523
- data/lib/windows/network/snmp.rb +90 -90
- data/lib/windows/network/winsock.rb +126 -126
- data/lib/windows/nio.rb +48 -47
- data/lib/windows/ntfs/winternl.rb +96 -96
- data/lib/windows/path.rb +141 -141
- data/lib/windows/pipe.rb +40 -40
- data/lib/windows/process.rb +174 -174
- data/lib/windows/registry.rb +126 -126
- data/lib/windows/security.rb +477 -477
- data/lib/windows/security/authentication.rb +30 -30
- data/lib/windows/service.rb +140 -140
- data/lib/windows/shell.rb +169 -169
- data/lib/windows/sound.rb +37 -37
- data/lib/windows/synchronize.rb +131 -131
- data/lib/windows/system_info.rb +227 -222
- data/lib/windows/thread.rb +62 -62
- data/lib/windows/time.rb +46 -46
- data/lib/windows/tool_helper.rb +34 -34
- data/lib/windows/volume.rb +59 -59
- data/lib/windows/window.rb +79 -79
- data/lib/windows/window/classes.rb +57 -57
- data/lib/windows/window/dialog.rb +89 -89
- data/lib/windows/window/menu.rb +100 -100
- data/lib/windows/window/message.rb +295 -295
- data/lib/windows/window/properties.rb +18 -18
- data/lib/windows/window/timer.rb +17 -17
- data/test/tc_clipboard.rb +41 -41
- data/test/tc_com.rb +32 -32
- data/test/tc_com_automation.rb +15 -15
- data/test/tc_console.rb +108 -108
- data/test/tc_debug.rb +48 -48
- data/test/tc_device_io.rb +29 -29
- data/test/tc_directory.rb +25 -25
- data/test/tc_error.rb +49 -49
- data/test/tc_eventlog.rb +58 -58
- data/test/tc_file.rb +67 -67
- data/test/tc_file_mapping.rb +38 -38
- data/test/tc_filesystem.rb +27 -27
- data/test/tc_gdi_bitmap.rb +25 -25
- data/test/tc_gdi_metafile.rb +23 -23
- data/test/tc_handle.rb +36 -36
- data/test/tc_library.rb +37 -37
- data/test/tc_limits.rb +34 -34
- data/test/tc_mailslot.rb +22 -22
- data/test/tc_memory.rb +44 -44
- data/test/tc_msvcrt_buffer.rb +68 -68
- data/test/tc_msvcrt_directory.rb +98 -98
- data/test/tc_msvcrt_file.rb +80 -80
- data/test/tc_msvcrt_io.rb +48 -48
- data/test/tc_msvcrt_string.rb +93 -93
- data/test/tc_msvcrt_time.rb +29 -29
- data/test/tc_national.rb +38 -38
- data/test/tc_network_management.rb +32 -32
- data/test/tc_network_snmp.rb +31 -31
- data/test/tc_network_winsock.rb +34 -34
- data/test/tc_nio.rb +32 -32
- data/test/tc_ntfs_winternl.rb +29 -29
- data/test/tc_path.rb +90 -90
- data/test/tc_pipe.rb +53 -53
- data/test/tc_process.rb +24 -24
- data/test/tc_registry.rb +29 -29
- data/test/tc_security.rb +104 -104
- data/test/tc_security_authentication.rb +34 -34
- data/test/tc_service.rb +57 -57
- data/test/tc_shell.rb +34 -34
- data/test/tc_sound.rb +37 -37
- data/test/tc_synchronize.rb +75 -75
- data/test/tc_system_info.rb +43 -43
- data/test/tc_thread.rb +29 -29
- data/test/tc_time.rb +32 -32
- data/test/tc_tool_helper.rb +29 -29
- data/test/tc_volume.rb +47 -47
- data/test/tc_window.rb +45 -45
- data/test/tc_window_classes.rb +33 -33
- data/test/tc_window_dialog.rb +33 -33
- data/test/tc_window_menu.rb +29 -29
- data/test/tc_window_message.rb +33 -33
- data/test/tc_window_properties.rb +29 -29
- data/test/tc_window_timer.rb +29 -29
- data/windows-pr.gemspec +34 -34
- metadata +4 -4
data/lib/windows/sound.rb
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
require 'windows/api'
|
2
|
-
|
3
|
-
module Windows
|
4
|
-
module Sound
|
5
|
-
API.auto_namespace = 'Windows::Sound'
|
6
|
-
API.auto_constant = true
|
7
|
-
API.auto_method = true
|
8
|
-
API.auto_unicode = false
|
9
|
-
|
10
|
-
SND_SYNC = 0x0000 # play synchronously (default)
|
11
|
-
SND_ASYNC = 0x0001 # play asynchronously
|
12
|
-
SND_NODEFAULT = 0x0002 # silence (!default) if sound not found
|
13
|
-
SND_MEMORY = 0x0004 # pszSound points to a memory file
|
14
|
-
SND_LOOP = 0x0008 # loop the sound until next sndPlaySound
|
15
|
-
SND_NOSTOP = 0x0010 # don't stop any currently playing sound
|
16
|
-
|
17
|
-
SND_NOWAIT = 8192 # don't wait if the driver is busy
|
18
|
-
SND_ALIAS = 65536 # name is a registry alias
|
19
|
-
SND_ALIAS_ID = 1114112 # alias is a predefined ID
|
20
|
-
SND_FILENAME = 131072 # name is file name
|
21
|
-
SND_RESOURCE = 262148 # name is resource name or atom
|
22
|
-
|
23
|
-
SND_PURGE = 0x0040 # purge non-static events for task
|
24
|
-
SND_APPLICATION = 0x0080 # look for application specific association
|
25
|
-
|
26
|
-
API.new('Beep', 'LL', 'B')
|
27
|
-
API.new('PlaySound', 'PPL', 'B', 'winmm')
|
28
|
-
API.new('waveOutSetVolume', 'PL', 'I', 'winmm')
|
29
|
-
API.new('waveOutGetVolume', 'LP', 'I', 'winmm')
|
30
|
-
API.new('waveOutGetNumDevs', 'V', 'I', 'winmm')
|
31
|
-
API.new('waveInGetNumDevs', 'V', 'I', 'winmm')
|
32
|
-
API.new('midiOutGetNumDevs', 'V', 'I', 'winmm')
|
33
|
-
API.new('midiInGetNumDevs', 'V', 'I', 'winmm')
|
34
|
-
API.new('auxGetNumDevs', 'V', 'I', 'winmm')
|
35
|
-
API.new('mixerGetNumDevs', 'V', 'I', 'winmm')
|
36
|
-
end
|
37
|
-
end
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Sound
|
5
|
+
API.auto_namespace = 'Windows::Sound'
|
6
|
+
API.auto_constant = true
|
7
|
+
API.auto_method = true
|
8
|
+
API.auto_unicode = false
|
9
|
+
|
10
|
+
SND_SYNC = 0x0000 # play synchronously (default)
|
11
|
+
SND_ASYNC = 0x0001 # play asynchronously
|
12
|
+
SND_NODEFAULT = 0x0002 # silence (!default) if sound not found
|
13
|
+
SND_MEMORY = 0x0004 # pszSound points to a memory file
|
14
|
+
SND_LOOP = 0x0008 # loop the sound until next sndPlaySound
|
15
|
+
SND_NOSTOP = 0x0010 # don't stop any currently playing sound
|
16
|
+
|
17
|
+
SND_NOWAIT = 8192 # don't wait if the driver is busy
|
18
|
+
SND_ALIAS = 65536 # name is a registry alias
|
19
|
+
SND_ALIAS_ID = 1114112 # alias is a predefined ID
|
20
|
+
SND_FILENAME = 131072 # name is file name
|
21
|
+
SND_RESOURCE = 262148 # name is resource name or atom
|
22
|
+
|
23
|
+
SND_PURGE = 0x0040 # purge non-static events for task
|
24
|
+
SND_APPLICATION = 0x0080 # look for application specific association
|
25
|
+
|
26
|
+
API.new('Beep', 'LL', 'B')
|
27
|
+
API.new('PlaySound', 'PPL', 'B', 'winmm')
|
28
|
+
API.new('waveOutSetVolume', 'PL', 'I', 'winmm')
|
29
|
+
API.new('waveOutGetVolume', 'LP', 'I', 'winmm')
|
30
|
+
API.new('waveOutGetNumDevs', 'V', 'I', 'winmm')
|
31
|
+
API.new('waveInGetNumDevs', 'V', 'I', 'winmm')
|
32
|
+
API.new('midiOutGetNumDevs', 'V', 'I', 'winmm')
|
33
|
+
API.new('midiInGetNumDevs', 'V', 'I', 'winmm')
|
34
|
+
API.new('auxGetNumDevs', 'V', 'I', 'winmm')
|
35
|
+
API.new('mixerGetNumDevs', 'V', 'I', 'winmm')
|
36
|
+
end
|
37
|
+
end
|
data/lib/windows/synchronize.rb
CHANGED
@@ -1,131 +1,131 @@
|
|
1
|
-
require 'windows/api'
|
2
|
-
|
3
|
-
module Windows
|
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
|
-
|
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
|
24
|
-
|
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)
|
107
|
-
end
|
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
|
131
|
-
end
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
module Windows
|
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
|
+
|
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
|
24
|
+
|
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)
|
107
|
+
end
|
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
|
131
|
+
end
|
data/lib/windows/system_info.rb
CHANGED
@@ -1,222 +1,227 @@
|
|
1
|
-
require 'windows/api'
|
2
|
-
|
3
|
-
module Windows
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module SystemInfo
|
5
|
+
API.auto_namespace = 'Windows::SystemInfo'
|
6
|
+
API.auto_constant = true
|
7
|
+
API.auto_method = true
|
8
|
+
API.auto_unicode = true
|
9
|
+
|
10
|
+
# Obsolete processor info constants
|
11
|
+
|
12
|
+
PROCESSOR_INTEL_386 = 386
|
13
|
+
PROCESSOR_INTEL_486 = 486
|
14
|
+
PROCESSOR_INTEL_PENTIUM = 586
|
15
|
+
PROCESSOR_INTEL_IA64 = 2200
|
16
|
+
PROCESSOR_AMD_X8664 = 8664
|
17
|
+
|
18
|
+
# Suite mask constants
|
19
|
+
|
20
|
+
VER_SERVER_NT = 0x80000000
|
21
|
+
VER_WORKSTATION_NT = 0x40000000
|
22
|
+
VER_SUITE_SMALLBUSINESS = 0x00000001
|
23
|
+
VER_SUITE_ENTERPRISE = 0x00000002
|
24
|
+
VER_SUITE_BACKOFFICE = 0x00000004
|
25
|
+
VER_SUITE_COMMUNICATIONS = 0x00000008
|
26
|
+
VER_SUITE_TERMINAL = 0x00000010
|
27
|
+
VER_SUITE_SMALLBUSINESS_RESTRICTED = 0x00000020
|
28
|
+
VER_SUITE_EMBEDDEDNT = 0x00000040
|
29
|
+
VER_SUITE_DATACENTER = 0x00000080
|
30
|
+
VER_SUITE_SINGLEUSERTS = 0x00000100
|
31
|
+
VER_SUITE_PERSONAL = 0x00000200
|
32
|
+
VER_SUITE_BLADE = 0x00000400
|
33
|
+
VER_SUITE_EMBEDDED_RESTRICTED = 0x00000800
|
34
|
+
VER_SUITE_SECURITY_APPLIANCE = 0x00001000
|
35
|
+
VER_SUITE_STORAGE_SERVER = 0x00002000
|
36
|
+
VER_SUITE_COMPUTE_SERVER = 0x00004000
|
37
|
+
|
38
|
+
# Product mask constants
|
39
|
+
|
40
|
+
VER_NT_WORKSTATION = 0x0000001
|
41
|
+
VER_NT_DOMAIN_CONTROLLER = 0x0000002
|
42
|
+
VER_NT_SERVER = 0x0000003
|
43
|
+
|
44
|
+
# Platform definitions
|
45
|
+
|
46
|
+
VER_PLATFORM_WIN32s = 0
|
47
|
+
VER_PLATFORM_WIN32_WINDOWS = 1
|
48
|
+
VER_PLATFORM_WIN32_NT = 2
|
49
|
+
|
50
|
+
# Version info type constants
|
51
|
+
|
52
|
+
VER_MINORVERSION = 0x0000001
|
53
|
+
VER_MAJORVERSION = 0x0000002
|
54
|
+
VER_BUILDNUMBER = 0x0000004
|
55
|
+
VER_PLATFORMID = 0x0000008
|
56
|
+
VER_SERVICEPACKMINOR = 0x0000010
|
57
|
+
VER_SERVICEPACKMAJOR = 0x0000020
|
58
|
+
VER_SUITENAME = 0x0000040
|
59
|
+
VER_PRODUCT_TYPE = 0x0000080
|
60
|
+
|
61
|
+
# Enum COMPUTER_NAME_FORMAT
|
62
|
+
|
63
|
+
ComputerNameNetBIOS = 0
|
64
|
+
ComputerNameDnsHostname = 1
|
65
|
+
ComputerNameDnsDomain = 2
|
66
|
+
ComputerNameDnsFullyQualified = 3
|
67
|
+
ComputerNamePhysicalNetBIOS = 4
|
68
|
+
ComputerNamePhysicalDnsHostname = 5
|
69
|
+
ComputerNamePhysicalDnsDomain = 6
|
70
|
+
ComputerNamePhysicalDnsFullyQualified = 7
|
71
|
+
ComputerNameMax = 8
|
72
|
+
|
73
|
+
API.new('ExpandEnvironmentStrings', 'PPL', 'L')
|
74
|
+
API.new('GetComputerName', 'PP', 'B')
|
75
|
+
API.new('GetComputerNameEx', 'PPP', 'B')
|
76
|
+
API.new('GetSystemInfo', 'P', 'V')
|
77
|
+
API.new('GetUserName', 'PP', 'B', 'advapi32')
|
78
|
+
API.new('GetUserNameEx', 'LPP', 'B', 'secur32')
|
79
|
+
API.new('GetVersion', 'V', 'L')
|
80
|
+
API.new('GetVersionEx', 'P', 'B')
|
81
|
+
API.new('GetWindowsDirectory', 'PI', 'I')
|
82
|
+
|
83
|
+
begin
|
84
|
+
API.new('GetSystemWow64Directory', 'PI', 'I')
|
85
|
+
rescue Win32::API::LoadLibraryError
|
86
|
+
# XP or later
|
87
|
+
end
|
88
|
+
|
89
|
+
# These macros are from windef.h, but I've put them here for now
|
90
|
+
# since they can be used in conjunction with some of the functions
|
91
|
+
# declared in this module.
|
92
|
+
|
93
|
+
def MAKEWORD(a, b)
|
94
|
+
((a & 0xff) | (b & 0xff)) << 8
|
95
|
+
end
|
96
|
+
|
97
|
+
def MAKELONG(a, b)
|
98
|
+
((a & 0xffff) | (b & 0xffff)) << 16
|
99
|
+
end
|
100
|
+
|
101
|
+
def LOWORD(l)
|
102
|
+
l & 0xffff
|
103
|
+
end
|
104
|
+
|
105
|
+
def HIWORD(l)
|
106
|
+
l >> 16
|
107
|
+
end
|
108
|
+
|
109
|
+
def LOBYTE(w)
|
110
|
+
w & 0xff
|
111
|
+
end
|
112
|
+
|
113
|
+
def HIBYTE(w)
|
114
|
+
w >> 8
|
115
|
+
end
|
116
|
+
|
117
|
+
# Returns a float indicating the major and minor version of Windows,
|
118
|
+
# e.g. 5.1, 6.0, etc.
|
119
|
+
#
|
120
|
+
def windows_version
|
121
|
+
version = GetVersion()
|
122
|
+
major = LOBYTE(LOWORD(version))
|
123
|
+
minor = HIBYTE(LOWORD(version))
|
124
|
+
eval("Float(#{major}.#{minor})")
|
125
|
+
end
|
126
|
+
|
127
|
+
# Custom methods that may come in handy
|
128
|
+
|
129
|
+
# Returns true if the current platform is Vista (any variant) or Windows
|
130
|
+
# Server 2008, i.e. major version 6, minor version 0.
|
131
|
+
#
|
132
|
+
def windows_2000?
|
133
|
+
version = GetVersion()
|
134
|
+
LOBYTE(LOWORD(version)) == 5 && HIBYTE(LOWORD(version)) == 0
|
135
|
+
end
|
136
|
+
|
137
|
+
# Returns true if the current platform is Windows XP or Windows XP
|
138
|
+
# Pro, i.e. major version 5, minor version 1 (or 2 in the case of a
|
139
|
+
# 64-bit Windows XP Pro).
|
140
|
+
#--
|
141
|
+
# Because of the exception for a 64-bit Windows XP Pro, we have to
|
142
|
+
# do things the hard way. For version 2 we look for any of the suite
|
143
|
+
# masks that might be associated with Windows 2003. If we don't find
|
144
|
+
# any of them, assume it's Windows XP.
|
145
|
+
#
|
146
|
+
def windows_xp?
|
147
|
+
bool = false
|
148
|
+
|
149
|
+
buf = 0.chr * 156
|
150
|
+
buf[0,4] = [buf.size].pack("L") # Set dwOSVersionInfoSize
|
151
|
+
|
152
|
+
GetVersionEx(buf)
|
153
|
+
|
154
|
+
major = buf[4,4].unpack("L")[0]
|
155
|
+
minor = buf[8,4].unpack("L")[0]
|
156
|
+
suite = buf[152,2].unpack("S")[0]
|
157
|
+
|
158
|
+
# Make sure we detect a 64-bit Windows XP Pro
|
159
|
+
if major == 5
|
160
|
+
if minor == 1
|
161
|
+
bool = true
|
162
|
+
elsif minor == 2
|
163
|
+
if (suite & VER_SUITE_BLADE == 0) &&
|
164
|
+
(suite & VER_SUITE_COMPUTE_SERVER == 0) &&
|
165
|
+
(suite & VER_SUITE_DATACENTER == 0) &&
|
166
|
+
(suite & VER_SUITE_ENTERPRISE == 0) &&
|
167
|
+
(suite & VER_SUITE_STORAGE_SERVER == 0)
|
168
|
+
then
|
169
|
+
bool = true
|
170
|
+
end
|
171
|
+
else
|
172
|
+
# Do nothing - already false
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
bool
|
177
|
+
end
|
178
|
+
|
179
|
+
# Returns true if the current platform is Windows 2003 (any version).
|
180
|
+
# i.e. major version 5, minor version 2.
|
181
|
+
#--
|
182
|
+
# Because of the exception for a 64-bit Windows XP Pro, we have to
|
183
|
+
# do things the hard way. For version 2 we look for any of the suite
|
184
|
+
# masks that might be associated with Windows 2003. If we find any
|
185
|
+
# of them, assume it's Windows 2003.
|
186
|
+
#
|
187
|
+
def windows_2003?
|
188
|
+
bool = false
|
189
|
+
|
190
|
+
buf = 0.chr * 156
|
191
|
+
buf[0,4] = [buf.size].pack("L") # Set dwOSVersionInfoSize
|
192
|
+
|
193
|
+
GetVersionEx(buf)
|
194
|
+
|
195
|
+
major = buf[4,4].unpack("L")[0]
|
196
|
+
minor = buf[8,4].unpack("L")[0]
|
197
|
+
suite = buf[152,2].unpack("S")[0]
|
198
|
+
|
199
|
+
# Make sure we exclude a 64-bit Windows XP Pro
|
200
|
+
if major == 5 && minor == 2
|
201
|
+
if (suite & VER_SUITE_BLADE > 0) ||
|
202
|
+
(suite & VER_SUITE_COMPUTE_SERVER > 0) ||
|
203
|
+
(suite & VER_SUITE_DATACENTER > 0) ||
|
204
|
+
(suite & VER_SUITE_ENTERPRISE > 0) ||
|
205
|
+
(suite & VER_SUITE_STORAGE_SERVER > 0)
|
206
|
+
then
|
207
|
+
bool = true
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
bool
|
212
|
+
end
|
213
|
+
|
214
|
+
# Returns true if the current platform is Windows Vista (any variant)
|
215
|
+
# or Windows Server 2008, i.e. major version 6, minor version 0.
|
216
|
+
#
|
217
|
+
def windows_vista?
|
218
|
+
version = GetVersion()
|
219
|
+
LOBYTE(LOWORD(version)) == 6 && HIBYTE(LOWORD(version)) == 0
|
220
|
+
end
|
221
|
+
|
222
|
+
def windows_7?
|
223
|
+
version = GetVersion()
|
224
|
+
LOBYTE(LOWORD(version)) == 6 && HIBYTE(LOWORD(version)) == 1
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|