windows-pr 1.1.3 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. data/CHANGES +15 -0
  2. data/MANIFEST +65 -65
  3. data/README +149 -149
  4. data/Rakefile +37 -52
  5. data/doc/conversion_guide.txt +37 -37
  6. data/lib/windows/clipboard.rb +2 -0
  7. data/lib/windows/com.rb +2 -0
  8. data/lib/windows/com/accessibility.rb +12 -10
  9. data/lib/windows/com/automation.rb +149 -147
  10. data/lib/windows/com/variant.rb +24 -22
  11. data/lib/windows/console.rb +114 -112
  12. data/lib/windows/debug.rb +35 -33
  13. data/lib/windows/device_io.rb +248 -246
  14. data/lib/windows/directory.rb +2 -0
  15. data/lib/windows/error.rb +2 -0
  16. data/lib/windows/eventlog.rb +2 -0
  17. data/lib/windows/file.rb +264 -262
  18. data/lib/windows/file_mapping.rb +25 -23
  19. data/lib/windows/filesystem.rb +2 -0
  20. data/lib/windows/gdi/bitmap.rb +65 -63
  21. data/lib/windows/gdi/device_context.rb +46 -44
  22. data/lib/windows/gdi/metafile.rb +40 -38
  23. data/lib/windows/gdi/painting_drawing.rb +115 -113
  24. data/lib/windows/handle.rb +2 -0
  25. data/lib/windows/library.rb +2 -0
  26. data/lib/windows/limits.rb +34 -31
  27. data/lib/windows/mailslot.rb +2 -0
  28. data/lib/windows/memory.rb +2 -0
  29. data/lib/windows/msvcrt/buffer.rb +75 -73
  30. data/lib/windows/msvcrt/directory.rb +31 -29
  31. data/lib/windows/msvcrt/file.rb +47 -45
  32. data/lib/windows/msvcrt/io.rb +62 -60
  33. data/lib/windows/msvcrt/string.rb +2 -0
  34. data/lib/windows/msvcrt/time.rb +169 -167
  35. data/lib/windows/national.rb +580 -578
  36. data/lib/windows/network/management.rb +525 -523
  37. data/lib/windows/network/snmp.rb +92 -90
  38. data/lib/windows/network/winsock.rb +128 -126
  39. data/lib/windows/nio.rb +2 -0
  40. data/lib/windows/ntfs/winternl.rb +96 -82
  41. data/lib/windows/path.rb +143 -141
  42. data/lib/windows/pipe.rb +42 -40
  43. data/lib/windows/process.rb +2 -0
  44. data/lib/windows/registry.rb +171 -126
  45. data/lib/windows/security.rb +479 -477
  46. data/lib/windows/security/authentication.rb +32 -30
  47. data/lib/windows/service.rb +142 -140
  48. data/lib/windows/shell.rb +171 -169
  49. data/lib/windows/socket.rb +86 -0
  50. data/lib/windows/sound.rb +39 -37
  51. data/lib/windows/synchronize.rb +133 -131
  52. data/lib/windows/system_info.rb +4 -2
  53. data/lib/windows/thread.rb +2 -0
  54. data/lib/windows/time.rb +48 -46
  55. data/lib/windows/tool_helper.rb +36 -34
  56. data/lib/windows/unicode.rb +2 -0
  57. data/lib/windows/volume.rb +61 -59
  58. data/lib/windows/window.rb +81 -79
  59. data/lib/windows/window/classes.rb +59 -57
  60. data/lib/windows/window/dialog.rb +91 -89
  61. data/lib/windows/window/menu.rb +102 -100
  62. data/lib/windows/window/message.rb +297 -295
  63. data/lib/windows/window/properties.rb +20 -18
  64. data/lib/windows/window/timer.rb +19 -17
  65. data/lib/windows/wsa.rb +102 -0
  66. data/test/tc_clipboard.rb +41 -41
  67. data/test/tc_com.rb +32 -32
  68. data/test/tc_com_automation.rb +15 -15
  69. data/test/tc_console.rb +108 -108
  70. data/test/tc_debug.rb +48 -48
  71. data/test/tc_device_io.rb +29 -29
  72. data/test/tc_directory.rb +25 -25
  73. data/test/tc_error.rb +38 -50
  74. data/test/tc_eventlog.rb +58 -58
  75. data/test/tc_file.rb +67 -67
  76. data/test/tc_file_mapping.rb +38 -38
  77. data/test/tc_filesystem.rb +27 -27
  78. data/test/tc_gdi_bitmap.rb +25 -25
  79. data/test/tc_gdi_metafile.rb +23 -23
  80. data/test/tc_handle.rb +36 -36
  81. data/test/tc_library.rb +37 -37
  82. data/test/tc_limits.rb +34 -34
  83. data/test/tc_mailslot.rb +22 -22
  84. data/test/tc_memory.rb +44 -44
  85. data/test/tc_msvcrt_buffer.rb +59 -68
  86. data/test/tc_msvcrt_directory.rb +96 -98
  87. data/test/tc_msvcrt_file.rb +80 -80
  88. data/test/tc_msvcrt_io.rb +48 -48
  89. data/test/tc_msvcrt_string.rb +94 -93
  90. data/test/tc_msvcrt_time.rb +19 -29
  91. data/test/tc_national.rb +38 -38
  92. data/test/tc_network_management.rb +32 -32
  93. data/test/tc_network_snmp.rb +31 -31
  94. data/test/tc_network_winsock.rb +34 -34
  95. data/test/tc_nio.rb +32 -32
  96. data/test/tc_ntfs_winternl.rb +33 -18
  97. data/test/tc_path.rb +90 -90
  98. data/test/tc_pipe.rb +53 -53
  99. data/test/tc_process.rb +24 -24
  100. data/test/tc_registry.rb +29 -29
  101. data/test/tc_security.rb +104 -104
  102. data/test/tc_security_authentication.rb +34 -34
  103. data/test/tc_service.rb +57 -57
  104. data/test/tc_shell.rb +34 -34
  105. data/test/tc_socket.rb +20 -0
  106. data/test/tc_sound.rb +37 -37
  107. data/test/tc_synchronize.rb +75 -75
  108. data/test/tc_system_info.rb +33 -43
  109. data/test/tc_thread.rb +29 -29
  110. data/test/tc_time.rb +32 -32
  111. data/test/tc_tool_helper.rb +29 -29
  112. data/test/tc_unicode.rb +62 -62
  113. data/test/tc_volume.rb +47 -47
  114. data/test/tc_window.rb +45 -45
  115. data/test/tc_window_classes.rb +33 -33
  116. data/test/tc_window_dialog.rb +33 -33
  117. data/test/tc_window_menu.rb +29 -29
  118. data/test/tc_window_message.rb +33 -33
  119. data/test/tc_window_properties.rb +29 -29
  120. data/test/tc_window_timer.rb +29 -29
  121. data/test/tc_wsa.rb +19 -0
  122. data/windows-pr.gemspec +1 -1
  123. metadata +13 -7
@@ -0,0 +1,86 @@
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module Socket
5
+ API.auto_namespace = 'Windows::Socket'
6
+ API.auto_constant = true
7
+ API.auto_method = true
8
+ API.auto_unicode = true
9
+
10
+ private
11
+
12
+ # Constants
13
+
14
+ IPPROTO_IP = 0 # dummy for IP
15
+ IPPROTO_ICMP = 1 # control message protocol
16
+ IPPROTO_IGMP = 2 # group management protocol
17
+ IPPROTO_GGP = 3 # gateway^2 (deprecated)
18
+ IPPROTO_TCP = 6 # tcp
19
+ IPPROTO_PUP = 12 # pup
20
+ IPPROTO_UDP = 17 # user datagram protocol
21
+ IPPROTO_IDP = 22 # xns idp
22
+ IPPROTO_ND = 77 # UNOFFICIAL net disk proto
23
+ IPPROTO_RAW = 255 # raw IP packet
24
+ IPPROTO_MAX = 256
25
+
26
+ NSPROTO_IPX = 1000
27
+ NSPROTO_SPX = 1256
28
+ NSPROTO_SPXII = 1257
29
+
30
+ # Functions
31
+
32
+ API.new('accept', 'LPP', 'L', 'ws2_32')
33
+ API.new('AcceptEx', 'LLPLLLPP', 'B', 'mswsock')
34
+ API.new('bind', 'LPI', 'I', 'ws2_32')
35
+ API.new('closesocket', 'L', 'I', 'ws2_32')
36
+ API.new('connect', 'LPI', 'I', 'ws2_32')
37
+ API.new('EnumProtocols', 'PPP', 'I', 'mswsock')
38
+ API.new('GetAcceptExSockaddrs', 'PLLLPPPP', 'V', 'mswsock')
39
+ API.new('GetAddressByName', 'LPPPLPPPPP', 'I', 'mswsock')
40
+ API.new('gethostbyaddr', 'SII', 'P', 'ws2_32')
41
+ API.new('gethostbyname', 'S', 'P', 'ws2_32')
42
+ API.new('gethostname', 'PI', 'I', 'ws2_32')
43
+ API.new('GetNameByType', 'PPL', 'I', 'mswsock')
44
+ API.new('getpeername', 'LPP', 'I', 'ws2_32')
45
+ API.new('getprotobyname', 'S', 'P', 'ws2_32')
46
+ API.new('getprotobynumber', 'I', 'P', 'ws2_32')
47
+ API.new('getservbyport', 'IS', 'P', 'ws2_32')
48
+ API.new('GetService', 'LPSLPPP', 'I', 'mswsock')
49
+ API.new('getsockname', 'LPP', 'I', 'ws2_32')
50
+ API.new('getsockopt', 'LIIPP', 'I', 'ws2_32')
51
+ API.new('GetTypeByName', 'LIIPP', 'I', 'mswsock')
52
+ API.new('htonl', 'L', 'L', 'ws2_32')
53
+ API.new('htons', 'S', 'S', 'ws2_32')
54
+ API.new('inet_addr', 'S', 'L', 'ws2_32')
55
+ API.new('inet_ntoa', 'P', 'S', 'ws2_32')
56
+ API.new('ioctlsocket', 'LLP', 'I', 'ws2_32')
57
+ API.new('listen', 'LI', 'I', 'ws2_32')
58
+ API.new('ntohl', 'L', 'L', 'ws2_32')
59
+ API.new('ntohs', 'S', 'S', 'ws2_32')
60
+ API.new('recv', 'LPII', 'I', 'ws2_32')
61
+ API.new('recvfrom', 'LPIIPP', 'I', 'ws2_32')
62
+ API.new('send', 'LSII', 'I', 'ws2_32')
63
+ API.new('sendto', 'LSIIPI', 'I', 'ws2_32')
64
+ API.new('SetService', 'LLLPPP', 'I', 'mswsock')
65
+ API.new('setsockopt', 'LIISI', 'I', 'ws2_32')
66
+ API.new('shutdown', 'LI', 'I', 'ws2_32')
67
+ API.new('socket', 'III', 'L', 'ws2_32')
68
+ API.new('TransmitFile', 'LLLLPPL', 'B', 'mswsock')
69
+
70
+ begin
71
+ API.new('freeaddrinfo', 'P', 'V', 'ws2_32')
72
+ API.new('FreeAddrInfoEx', 'P', 'V', 'ws2_32')
73
+ API.new('FreeAddrInfoW', 'P', 'V', 'ws2_32')
74
+ API.new('getaddrinfo', 'PPPP', 'I', 'ws2_32')
75
+ API.new('GetAddrInfoEx', 'PPLPPPPPPP', 'I', 'ws2_32')
76
+ API.new('GetAddrInfoW', 'PPPP', 'I', 'ws2_32')
77
+ API.new('getnameinfo', 'PLPLPLI', 'I', 'ws2_32')
78
+ API.new('GetNameInfoW', 'PLPLPLI', 'I', 'ws2_32')
79
+ API.new('InetNtop', 'IPPL', 'P', 'ws2_32')
80
+ API.new('inet_pton', 'IPP', 'I', 'ws2_32')
81
+ API.new('SetAddrInfoEx', 'SSPLPLLPPPPP', 'I', 'ws2_32')
82
+ rescue Win32::API::LoadLibraryError
83
+ # XP or later
84
+ end
85
+ end
86
+ end
data/lib/windows/sound.rb CHANGED
@@ -1,37 +1,39 @@
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
+ private
11
+
12
+ SND_SYNC = 0x0000 # play synchronously (default)
13
+ SND_ASYNC = 0x0001 # play asynchronously
14
+ SND_NODEFAULT = 0x0002 # silence (!default) if sound not found
15
+ SND_MEMORY = 0x0004 # pszSound points to a memory file
16
+ SND_LOOP = 0x0008 # loop the sound until next sndPlaySound
17
+ SND_NOSTOP = 0x0010 # don't stop any currently playing sound
18
+
19
+ SND_NOWAIT = 8192 # don't wait if the driver is busy
20
+ SND_ALIAS = 65536 # name is a registry alias
21
+ SND_ALIAS_ID = 1114112 # alias is a predefined ID
22
+ SND_FILENAME = 131072 # name is file name
23
+ SND_RESOURCE = 262148 # name is resource name or atom
24
+
25
+ SND_PURGE = 0x0040 # purge non-static events for task
26
+ SND_APPLICATION = 0x0080 # look for application specific association
27
+
28
+ API.new('Beep', 'LL', 'B')
29
+ API.new('PlaySound', 'PPL', 'B', 'winmm')
30
+ API.new('waveOutSetVolume', 'PL', 'I', 'winmm')
31
+ API.new('waveOutGetVolume', 'LP', 'I', 'winmm')
32
+ API.new('waveOutGetNumDevs', 'V', 'I', 'winmm')
33
+ API.new('waveInGetNumDevs', 'V', 'I', 'winmm')
34
+ API.new('midiOutGetNumDevs', 'V', 'I', 'winmm')
35
+ API.new('midiInGetNumDevs', 'V', 'I', 'winmm')
36
+ API.new('auxGetNumDevs', 'V', 'I', 'winmm')
37
+ API.new('mixerGetNumDevs', 'V', 'I', 'winmm')
38
+ end
39
+ end
@@ -1,131 +1,133 @@
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
+ private
11
+
12
+ INFINITE = 0xFFFFFFFF
13
+ WAIT_OBJECT_0 = 0
14
+ WAIT_TIMEOUT = 0x102
15
+ WAIT_ABANDONED = 128
16
+ WAIT_ABANDONED_0 = WAIT_ABANDONED
17
+ WAIT_FAILED = 0xFFFFFFFF
18
+
19
+ STATUS_WAIT_0 = 0
20
+ STATUS_ABANDONED_WAIT_0 = 128
21
+ STATUS_USER_APC = 192
22
+ STATUS_TIMEOUT = 258
23
+ STATUS_PENDING = 259
24
+
25
+ # Wake mask constants
26
+
27
+ QS_ALLEVENTS = 0x04BF
28
+ QS_ALLINPUT = 0x04FF
29
+ QS_ALLPOSTMESSAGE = 0x0100
30
+ QS_HOTKEY = 0x0080
31
+ QS_INPUT = 0x407
32
+ QS_KEY = 0x0001
33
+ QS_MOUSE = 0x0006
34
+ QS_MOUSEBUTTON = 0x0004
35
+ QS_MOUSEMOVE = 0x0002
36
+ QS_PAINT = 0x0020
37
+ QS_POSTMESSAGE = 0x0008
38
+ QS_RAWINPUT = 0x0400
39
+ QS_SENDMESSAGE = 0x0040
40
+ QS_TIMER = 0x0010
41
+
42
+ # Wait type constants
43
+
44
+ MWMO_ALERTABLE = 0x0002
45
+ MWMO_INPUTAVAILABLE = 0x0004
46
+ MWMO_WAITALL = 0x0001
47
+
48
+ # Access rights
49
+
50
+ EVENT_ALL_ACCESS = 0x1F0003
51
+ EVENT_MODIFY_STATE = 0x0002
52
+ MUTEX_ALL_ACCESS = 0x1F0001
53
+ MUTEX_MODIFY_STATE = 0x0001
54
+ SEMAPHORE_ALL_ACCESS = 0x1F0003
55
+ SEMAPHORE_MODIFY_STATE = 0x0002
56
+
57
+ # Namespace flags
58
+
59
+ PRIVATE_NAMESPACE_FLAG_DESTROY = 0x00000001
60
+
61
+ # Functions
62
+
63
+ API.new('CancelWaitableTimer', 'L', 'B')
64
+ API.new('CreateEvent', 'PIIP', 'L')
65
+ API.new('CreateMutex', 'PIP', 'L')
66
+ API.new('CreateSemaphore', 'PLLP', 'L')
67
+ API.new('CreateWaitableTimer', 'PIP', 'L')
68
+ API.new('DeleteCriticalSection', 'P', 'V')
69
+ API.new('EnterCriticalSection', 'P', 'V')
70
+ API.new('GetOverlappedResult', 'LPPI', 'I')
71
+ API.new('InitializeCriticalSection', 'P', 'V')
72
+ API.new('InitializeCriticalSectionAndSpinCount', 'PL', 'B')
73
+ API.new('LeaveCriticalSection', 'P', 'V')
74
+ API.new('MsgWaitForMultipleObjects', 'LPILL', 'L', 'user32')
75
+ API.new('MsgWaitForMultipleObjectsEx', 'LPLLL', 'L', 'user32')
76
+ API.new('OpenEvent', 'LIP', 'L')
77
+ API.new('OpenMutex', 'LIP', 'L')
78
+ API.new('OpenSemaphore', 'LIP', 'L')
79
+ API.new('OpenWaitableTimer', 'LIP', 'L')
80
+ API.new('ReleaseMutex', 'L', 'B')
81
+ API.new('ReleaseSemaphore', 'LLP', 'B')
82
+ API.new('ResetEvent', 'L', 'B')
83
+ API.new('SetCriticalSectionSpinCount', 'PL', 'V')
84
+ API.new('SetWaitableTimer', 'LPLKPI', 'B')
85
+ API.new('SetEvent', 'L', 'B')
86
+ API.new('TryEnterCriticalSection', 'P', 'B')
87
+ API.new('WaitForMultipleObjects', 'LPIL', 'L')
88
+ API.new('WaitForMultipleObjectsEx', 'LPILI', 'L')
89
+ API.new('WaitForSingleObject', 'LL', 'L')
90
+ API.new('WaitForSingleObjectEx', 'LLI', 'L')
91
+
92
+ # Macros
93
+
94
+ def HasOverlappedIoCompleted(overlapped)
95
+ overlapped[0,4].unpack('L')[0] != STATUS_PENDING
96
+ end
97
+
98
+ # This simulates the RUBY_CRITICAL macro from rubysig.h, although I've
99
+ # added the begin/ensure wrapper to boot.
100
+ #
101
+ def RUBY_CRITICAL(&block)
102
+ critical_section = [0].pack('L')
103
+ begin
104
+ InitializeCriticalSection(critical_section)
105
+ EnterCriticalSection(critical_section)
106
+ block.call
107
+ ensure
108
+ LeaveCriticalSection(critical_section)
109
+ end
110
+ end
111
+
112
+ # Vista or later
113
+
114
+ begin
115
+ API.new('AddSIDToBoundaryDescriptor', 'PP', 'B')
116
+ API.new('ClosePrivateNamespace', 'LL', 'B')
117
+ API.new('CreateBoundaryDescriptor', 'SL', 'L')
118
+ API.new('DeleteBoundaryDescriptor', 'L', 'V')
119
+ API.new('CreatePrivateNamespace', 'PLS', 'L')
120
+ API.new('OpenPrivateNamespace', 'PS', 'L')
121
+ rescue Win32::API::LoadLibraryError
122
+ # Windows Vista or later
123
+ end
124
+
125
+ # Windows 7 or later
126
+
127
+ begin
128
+ API.new('AddIntegrityLabelToBoundaryDescriptor', 'PP', 'B')
129
+ rescue Win32::API::LoadLibraryError
130
+ # Windows 7 or later
131
+ end
132
+ end
133
+ end
@@ -7,6 +7,8 @@ module Windows
7
7
  API.auto_method = true
8
8
  API.auto_unicode = true
9
9
 
10
+ private
11
+
10
12
  # Obsolete processor info constants
11
13
 
12
14
  PROCESSOR_INTEL_386 = 386
@@ -91,11 +93,11 @@ module Windows
91
93
  # declared in this module.
92
94
 
93
95
  def MAKEWORD(a, b)
94
- ((a & 0xff) | (b & 0xff)) << 8
96
+ ((a & 0xff) | ((b & 0xff) << 8))
95
97
  end
96
98
 
97
99
  def MAKELONG(a, b)
98
- ((a & 0xffff) | (b & 0xffff)) << 16
100
+ ((a & 0xffff) | ((b & 0xffff) << 16))
99
101
  end
100
102
 
101
103
  def LOWORD(l)