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.
- data/CHANGES +15 -0
- data/MANIFEST +65 -65
- data/README +149 -149
- data/Rakefile +37 -52
- data/doc/conversion_guide.txt +37 -37
- data/lib/windows/clipboard.rb +2 -0
- data/lib/windows/com.rb +2 -0
- data/lib/windows/com/accessibility.rb +12 -10
- data/lib/windows/com/automation.rb +149 -147
- data/lib/windows/com/variant.rb +24 -22
- data/lib/windows/console.rb +114 -112
- data/lib/windows/debug.rb +35 -33
- data/lib/windows/device_io.rb +248 -246
- data/lib/windows/directory.rb +2 -0
- data/lib/windows/error.rb +2 -0
- data/lib/windows/eventlog.rb +2 -0
- data/lib/windows/file.rb +264 -262
- data/lib/windows/file_mapping.rb +25 -23
- data/lib/windows/filesystem.rb +2 -0
- data/lib/windows/gdi/bitmap.rb +65 -63
- data/lib/windows/gdi/device_context.rb +46 -44
- data/lib/windows/gdi/metafile.rb +40 -38
- data/lib/windows/gdi/painting_drawing.rb +115 -113
- data/lib/windows/handle.rb +2 -0
- data/lib/windows/library.rb +2 -0
- data/lib/windows/limits.rb +34 -31
- data/lib/windows/mailslot.rb +2 -0
- data/lib/windows/memory.rb +2 -0
- data/lib/windows/msvcrt/buffer.rb +75 -73
- data/lib/windows/msvcrt/directory.rb +31 -29
- data/lib/windows/msvcrt/file.rb +47 -45
- data/lib/windows/msvcrt/io.rb +62 -60
- data/lib/windows/msvcrt/string.rb +2 -0
- data/lib/windows/msvcrt/time.rb +169 -167
- data/lib/windows/national.rb +580 -578
- data/lib/windows/network/management.rb +525 -523
- data/lib/windows/network/snmp.rb +92 -90
- data/lib/windows/network/winsock.rb +128 -126
- data/lib/windows/nio.rb +2 -0
- data/lib/windows/ntfs/winternl.rb +96 -82
- data/lib/windows/path.rb +143 -141
- data/lib/windows/pipe.rb +42 -40
- data/lib/windows/process.rb +2 -0
- data/lib/windows/registry.rb +171 -126
- data/lib/windows/security.rb +479 -477
- data/lib/windows/security/authentication.rb +32 -30
- data/lib/windows/service.rb +142 -140
- data/lib/windows/shell.rb +171 -169
- data/lib/windows/socket.rb +86 -0
- data/lib/windows/sound.rb +39 -37
- data/lib/windows/synchronize.rb +133 -131
- data/lib/windows/system_info.rb +4 -2
- data/lib/windows/thread.rb +2 -0
- data/lib/windows/time.rb +48 -46
- data/lib/windows/tool_helper.rb +36 -34
- data/lib/windows/unicode.rb +2 -0
- data/lib/windows/volume.rb +61 -59
- data/lib/windows/window.rb +81 -79
- data/lib/windows/window/classes.rb +59 -57
- data/lib/windows/window/dialog.rb +91 -89
- data/lib/windows/window/menu.rb +102 -100
- data/lib/windows/window/message.rb +297 -295
- data/lib/windows/window/properties.rb +20 -18
- data/lib/windows/window/timer.rb +19 -17
- data/lib/windows/wsa.rb +102 -0
- 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 +38 -50
- 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 +59 -68
- data/test/tc_msvcrt_directory.rb +96 -98
- data/test/tc_msvcrt_file.rb +80 -80
- data/test/tc_msvcrt_io.rb +48 -48
- data/test/tc_msvcrt_string.rb +94 -93
- data/test/tc_msvcrt_time.rb +19 -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 +33 -18
- 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_socket.rb +20 -0
- data/test/tc_sound.rb +37 -37
- data/test/tc_synchronize.rb +75 -75
- data/test/tc_system_info.rb +33 -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_unicode.rb +62 -62
- 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/test/tc_wsa.rb +19 -0
- data/windows-pr.gemspec +1 -1
- metadata +13 -7
data/lib/windows/network/snmp.rb
CHANGED
@@ -1,90 +1,92 @@
|
|
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
|
-
end
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Network
|
5
|
+
module SNMP
|
6
|
+
API.auto_namespace = 'Windows::Network::SNMP'
|
7
|
+
API.auto_constant = true
|
8
|
+
API.auto_method = true
|
9
|
+
API.auto_unicode = false
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
SNMPAPI_FAILURE = 0
|
14
|
+
SNMPAPI_SUCCESS = 1
|
15
|
+
SNMPAPI_ALLOC_ERROR = 2
|
16
|
+
SNMPAPI_CONTEXT_INVALID = 3
|
17
|
+
SNMPAPI_CONTEXT_UNKNOWN = 4
|
18
|
+
SNMPAPI_ENTITY_INVALID = 5
|
19
|
+
SNMPAPI_ENTITY_UNKNOWN = 6
|
20
|
+
SNMPAPI_INDEX_INVALID = 7
|
21
|
+
SNMPAPI_NOOP = 8
|
22
|
+
SNMPAPI_OID_INVALID = 9
|
23
|
+
SNMPAPI_OPERATION_INVALID = 10
|
24
|
+
SNMPAPI_OUTPUT_TRUNCATED = 11
|
25
|
+
SNMPAPI_PDU_INVALID = 12
|
26
|
+
SNMPAPI_SESSION_INVALID = 13
|
27
|
+
SNMPAPI_SYNTAX_INVALID = 14
|
28
|
+
SNMPAPI_VBL_INVALID = 15
|
29
|
+
SNMPAPI_MODE_INVALID = 16
|
30
|
+
SNMPAPI_SIZE_INVALID = 17
|
31
|
+
SNMPAPI_NOT_INITIALIZED = 18
|
32
|
+
SNMPAPI_MESSAGE_INVALID = 19
|
33
|
+
SNMPAPI_HWND_INVALID = 20
|
34
|
+
SNMPAPI_OTHER_ERROR = 99
|
35
|
+
SNMPAPI_TL_NOT_INITIALIZED = 100
|
36
|
+
SNMPAPI_TL_NOT_SUPPORTED = 101
|
37
|
+
SNMPAPI_TL_NOT_AVAILABLE = 102
|
38
|
+
SNMPAPI_TL_RESOURCE_ERROR = 103
|
39
|
+
SNMPAPI_TL_UNDELIVERABLE = 104
|
40
|
+
SNMPAPI_TL_SRC_INVALID = 105
|
41
|
+
SNMPAPI_TL_INVALID_PARAM = 106
|
42
|
+
SNMPAPI_TL_IN_USE = 107
|
43
|
+
SNMPAPI_TL_TIMEOUT = 108
|
44
|
+
SNMPAPI_TL_PDU_TOO_BIG = 109
|
45
|
+
SNMPAPI_TL_OTHER = 199
|
46
|
+
|
47
|
+
SNMPAPI_TRANSLATED = 0
|
48
|
+
SNMPAPI_UNTRANSLATED_V1 = 1
|
49
|
+
SNMPAPI_UNTRANSLATED_V2 = 2
|
50
|
+
SNMPAPI_NO_SUPPORT = 0
|
51
|
+
SNMPAPI_V1_SUPPORT = 1
|
52
|
+
SNMPAPI_V2_SUPPORT = 2
|
53
|
+
SNMPAPI_M2M_SUPPORT = 3
|
54
|
+
SNMPAPI_OFF = 0
|
55
|
+
SNMPAPI_ON = 1
|
56
|
+
|
57
|
+
API.new('SnmpCancelMsg', 'LI', 'I', 'wsnmp32')
|
58
|
+
API.new('SnmpCleanup', 'V', 'I', 'wsnmp32')
|
59
|
+
API.new('SnmpClose', 'L', 'I', 'wsnmp32')
|
60
|
+
API.new('SnmpContextToStr', 'LP', 'I', 'wsnmp32')
|
61
|
+
API.new('SnmpDecodeMsg', 'LPPPPP', 'I', 'wsnmp32')
|
62
|
+
API.new('SnmpEncodeMsg', 'LLLLLP', 'I', 'wsnmp32')
|
63
|
+
API.new('SnmpEntityToStr', 'LLP', 'I', 'wsnmp32')
|
64
|
+
API.new('SnmpFreeContext', 'L', 'I', 'wsnmp32')
|
65
|
+
API.new('SnmpFreeDescriptor', 'LP', 'I', 'wsnmp32')
|
66
|
+
API.new('SnmpFreeEntity', 'L', 'I', 'wsnmp32')
|
67
|
+
API.new('SnmpGetLastError', 'L', 'I', 'wsnmp32')
|
68
|
+
API.new('SnmpListen', 'LL', 'I', 'wsnmp32')
|
69
|
+
API.new('SnmpOidCompare', 'PPLP', 'I', 'wsnmp32')
|
70
|
+
API.new('SnmpOidCopy', 'PP', 'I', 'wsnmp32')
|
71
|
+
API.new('SnmpOidToStr', 'PLP', 'I', 'wsnmp32')
|
72
|
+
API.new('SnmpOpen', 'LL', 'L', 'wsnmp32')
|
73
|
+
API.new('SnmpRecvMsg', 'LPPPP', 'I', 'wsnmp32')
|
74
|
+
API.new('SnmpRegister', 'LLLLPL', 'I', 'wsnmp32')
|
75
|
+
API.new('SnmpSendMsg', 'LLLLL', 'I', 'wsnmp32')
|
76
|
+
API.new('SnmpSetPort', 'LL', 'I', 'wsnmp32')
|
77
|
+
API.new('SnmpStartup', 'PPPPP', 'I', 'wsnmp32')
|
78
|
+
API.new('SnmpStrToContext', 'LP', 'I', 'wsnmp32')
|
79
|
+
API.new('SnmpStrToEntity', 'LP', 'I', 'wsnmp32')
|
80
|
+
API.new('SnmpStrToOid', 'PP', 'I', 'wsnmp32')
|
81
|
+
|
82
|
+
# Windows 2003 Server or later and/or WinSNMP 2.0 or later
|
83
|
+
begin
|
84
|
+
API.new('SnmpCreateSession', 'LLKP', 'L', 'wsnmp32')
|
85
|
+
API.new('SnmpCleanupEx', 'V', 'I', 'wsnmp32')
|
86
|
+
API.new('SnmpStartupEx', 'PPPPP', 'L', 'wsnmp32')
|
87
|
+
rescue Win32::API::LoadLibraryError
|
88
|
+
# Do nothing. It's up to you to check for their existence.
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -1,126 +1,128 @@
|
|
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
|
-
end
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Network
|
5
|
+
module Winsock
|
6
|
+
API.auto_namespace = 'Windows::Network::Winsock'
|
7
|
+
API.auto_constant = true
|
8
|
+
API.auto_method = true
|
9
|
+
API.auto_unicode = true
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
# Namespace constants
|
14
|
+
NS_DEFAULT = 0
|
15
|
+
NS_SAP = 1
|
16
|
+
NS_NDS = 2
|
17
|
+
NS_PEER_BROWSE = 3
|
18
|
+
NS_TCPIP_LOCAL = 10
|
19
|
+
NS_TCPIP_HOSTS = 11
|
20
|
+
NS_DNS = 12
|
21
|
+
NS_NETBT = 13
|
22
|
+
NS_WINS = 14
|
23
|
+
NS_NBP = 20
|
24
|
+
NS_MS = 30
|
25
|
+
NS_STDA = 31
|
26
|
+
NS_NTDS = 32
|
27
|
+
NS_X500 = 40
|
28
|
+
NS_NIS = 41
|
29
|
+
NS_VNS = 50
|
30
|
+
|
31
|
+
# Resolution flags
|
32
|
+
RES_SOFT_SEARCH = 0x00000001
|
33
|
+
RES_FIND_MULTIPLE = 0x00000002
|
34
|
+
RES_SERVICE = 0x00000004
|
35
|
+
|
36
|
+
API.new('accept', 'LPP', 'L', 'ws2_32')
|
37
|
+
API.new('AcceptEx', 'LLPLLLPP', 'B', 'mswsock')
|
38
|
+
API.new('bind', 'LPL', 'I', 'ws2_32')
|
39
|
+
API.new('closesocket', 'L', 'I', 'ws2_32')
|
40
|
+
API.new('connect', 'LPI', 'I', 'ws2_32')
|
41
|
+
API.new('EnumProtocols', 'PPP', 'I', 'mswsock')
|
42
|
+
API.new('GetAcceptExSockaddrs', 'PLLLPPPP', 'V', 'mswsock')
|
43
|
+
API.new('GetAddressByName', 'LPPPLPPPPP', 'V', 'mswsock')
|
44
|
+
API.new('gethostbyaddr', 'PII', 'L', 'ws2_32')
|
45
|
+
API.new('gethostbyname', 'P', 'L', 'ws2_32')
|
46
|
+
API.new('gethostname', 'PI', 'I', 'ws2_32')
|
47
|
+
API.new('GetNameByType', 'PPL', 'I', 'mswsock')
|
48
|
+
API.new('getpeername', 'LPP', 'I', 'ws2_32')
|
49
|
+
API.new('getprotobyname', 'P', 'L', 'ws2_32')
|
50
|
+
API.new('getprotobynumber', 'L', 'L', 'ws2_32')
|
51
|
+
API.new('getservbyname', 'PP', 'L', 'ws2_32')
|
52
|
+
API.new('getservbyport', 'IP', 'L', 'ws2_32')
|
53
|
+
API.new('GetService', 'LPPLPPP', 'I', 'mswsock')
|
54
|
+
API.new('getsockname', 'LPP', 'I', 'ws2_32')
|
55
|
+
API.new('getsockopt', 'LIIPP', 'I', 'ws2_32')
|
56
|
+
API.new('GetTypeByName', 'PP', 'I', 'mswsock')
|
57
|
+
API.new('htonl', 'L', 'L', 'ws2_32')
|
58
|
+
API.new('htons', 'I', 'I', 'ws2_32')
|
59
|
+
API.new('inet_addr', 'P', 'L', 'ws2_32')
|
60
|
+
API.new('inet_ntoa', 'P', 'P', 'ws2_32')
|
61
|
+
API.new('ioctlsocket', 'LLP', 'I', 'ws2_32')
|
62
|
+
API.new('listen', 'LI', 'I', 'ws2_32')
|
63
|
+
API.new('ntohl', 'L', 'L', 'ws2_32')
|
64
|
+
API.new('ntohs', 'I', 'I', 'ws2_32')
|
65
|
+
API.new('recv', 'LPII', 'I', 'ws2_32')
|
66
|
+
API.new('recvfrom', 'LPIIPP', 'I', 'ws2_32')
|
67
|
+
API.new('select', 'IPPPP', 'I', 'ws2_32')
|
68
|
+
API.new('send', 'LPII', 'I', 'ws2_32')
|
69
|
+
API.new('sendto', 'LPIIPI', 'I', 'ws2_32')
|
70
|
+
API.new('SetService', 'LLLPPP', 'I', 'mswsock')
|
71
|
+
API.new('setsockopt', 'LIIPI', 'I', 'ws2_32')
|
72
|
+
API.new('shutdown', 'LI', 'I', 'ws2_32')
|
73
|
+
API.new('socket', 'III', 'L', 'ws2_32')
|
74
|
+
API.new('TransmitFile', 'LLLLPPL', 'B', 'mswsock')
|
75
|
+
|
76
|
+
API.new('WSAAccept', 'PPPKL', 'I', 'ws2_32')
|
77
|
+
API.new('WSAAddressToString', 'PLPPP', 'I', 'ws2_32')
|
78
|
+
API.new('WSAAsyncGetHostByAddr', 'LIPIIPI', 'L', 'ws2_32')
|
79
|
+
API.new('WSAAsyncGetHostByName', 'LIPPI', 'L', 'ws2_32')
|
80
|
+
API.new('WSAAsyncGetProtoByName', 'LIPPI', 'L', 'ws2_32')
|
81
|
+
API.new('WSAAsyncGetServByName', 'LIPPPL', 'L', 'ws2_32')
|
82
|
+
API.new('WSAAsyncGetServByPort', 'LIIPPI', 'L', 'ws2_32')
|
83
|
+
API.new('WSAAsyncSelect', 'PLIL', 'I', 'ws2_32')
|
84
|
+
API.new('WSACleanup', 'V', 'I', 'ws2_32')
|
85
|
+
API.new('WSACloseEvent', 'L', 'B', 'ws2_32')
|
86
|
+
API.new('WSAConnect', 'LPIPPPP', 'I', 'ws2_32')
|
87
|
+
API.new('WSACreateEvent', 'V', 'L', 'ws2_32')
|
88
|
+
API.new('WSADuplicateSocket', 'LLP', 'I', 'ws2_32')
|
89
|
+
API.new('WSAEnumNameSpaceProviders', 'PP', 'I', 'ws2_32')
|
90
|
+
API.new('WSAEnumNetworkEvents', 'LLP', 'I', 'ws2_32')
|
91
|
+
API.new('WSAEnumProtocols', 'PPP', 'I', 'ws2_32')
|
92
|
+
API.new('WSAEventSelect', 'LLL', 'I', 'ws2_32')
|
93
|
+
API.new('WSAGetLastError', 'V', 'I', 'ws2_32')
|
94
|
+
API.new('WSAIoctl', 'LLPLPLPPP', 'I', 'ws2_32')
|
95
|
+
API.new('WSARecv', 'LPLPPPP', 'I', 'ws2_32')
|
96
|
+
API.new('WSASocket', 'IIIPIL', 'L', 'ws2_32')
|
97
|
+
API.new('WSAStartup', 'IP', 'I', 'ws2_32')
|
98
|
+
API.new('WSAStringToAddress', 'PIPPP', 'I', 'ws2_32')
|
99
|
+
API.new('WSAWaitForMultipleEvents', 'LPBLB', 'L', 'ws2_32')
|
100
|
+
|
101
|
+
# XP or later
|
102
|
+
begin
|
103
|
+
API.new('ConnectEx', 'LPIPLPP', 'B', 'mswsock')
|
104
|
+
API.new('DisconnectEx', 'LPLL', 'B', 'mswsock')
|
105
|
+
API.new('freeaddrinfo', 'P', 'V', 'ws2_32')
|
106
|
+
API.new('FreeAddrInfoW', 'P', 'V', 'ws2_32')
|
107
|
+
API.new('getaddrinfo', 'PPPP', 'I', 'ws2_32')
|
108
|
+
API.new('GetAddrInfoW', 'PPPP', 'I', 'mswsock')
|
109
|
+
API.new('getnameinfo', 'PLPLPLI', 'I', 'ws2_32')
|
110
|
+
API.new('GetNameInfoW', 'PLPLPLI', 'I', 'ws2_32')
|
111
|
+
rescue Win32::API::LoadLibraryError
|
112
|
+
# Do nothing, not supported on your platform.
|
113
|
+
end
|
114
|
+
|
115
|
+
# Vista or later
|
116
|
+
begin
|
117
|
+
API.new('FreeAddrInfoEx', 'P', 'V', 'ws2_32')
|
118
|
+
API.new('GetAddrInfoEx', 'PPLPPPPPPP', 'I', 'ws2_32')
|
119
|
+
API.new('WSAConnectByList', 'LPPPPPPP', 'B', 'ws2_32')
|
120
|
+
API.new('WSAConnectByName', 'LPPPPPPP', 'B', 'ws2_32')
|
121
|
+
API.new('WSADeleteSocketPeerTargetName', 'LPPPP', 'I', 'ws2_32')
|
122
|
+
API.new('WSAPoll', 'PLI', 'I', 'ws2_32')
|
123
|
+
rescue Win32::API::LoadLibraryError
|
124
|
+
# Do nothing, not supported on your platform.
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
data/lib/windows/nio.rb
CHANGED
@@ -4,93 +4,107 @@ require 'windows/api'
|
|
4
4
|
# The name is derived from winternl.h which contains only function prototypes.
|
5
5
|
|
6
6
|
module Windows
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
module NTFS
|
8
|
+
module Winternl
|
9
|
+
API.auto_namespace = 'Windows::NTFS::Winternl'
|
10
|
+
API.auto_constant = true
|
11
|
+
API.auto_method = true
|
12
|
+
API.auto_unicode = false
|
13
13
|
|
14
|
-
|
15
|
-
FileAlignmentInformation = 17
|
16
|
-
FileAllInformation = 18
|
17
|
-
FileAllocationInformation = 19
|
18
|
-
FileAlternateNameInformation = 21
|
19
|
-
FileAttributeTagInformation = 35
|
20
|
-
FileBasicInformation = 4
|
21
|
-
FileBothDirectoryInformation = 3
|
22
|
-
FileCompletionInformation = 30
|
23
|
-
FileCompressionInformation = 28
|
24
|
-
FileDirectoryInformation = 1
|
25
|
-
FileDispositionInformation = 13
|
26
|
-
FileEaInformation = 7
|
27
|
-
FileEndOfFileInformation = 20
|
28
|
-
FileFullDirectoryInformation = 2
|
29
|
-
FileFullEaInformation = 15
|
30
|
-
FileHardLinkInformation = 46
|
31
|
-
FileIdBothDirectoryInformation = 37
|
32
|
-
FileIdFullDirectoryInformation = 38
|
33
|
-
FileInternalInformation = 6
|
34
|
-
FileLinkInformation = 11
|
35
|
-
FileMailslotQueryInformation = 26
|
36
|
-
FileMailslotSetInformation = 27
|
37
|
-
FileModeInformation = 16
|
38
|
-
FileMoveClusterInformation = 31
|
39
|
-
FileNameInformation = 9
|
40
|
-
FileNamesInformation = 12
|
41
|
-
FileNetworkOpenInformation = 34
|
42
|
-
FileObjectIdInformation = 29
|
43
|
-
FilePipeInformation = 23
|
44
|
-
FilePipeLocalInformation = 24
|
45
|
-
FilePipeRemoteInformation = 25
|
46
|
-
FilePositionInformation = 14
|
47
|
-
FileQuotaInformation = 32
|
48
|
-
FileRenameInformation = 10
|
49
|
-
FileReparsePointInformation = 33
|
50
|
-
FileShortNameInformation = 40
|
51
|
-
FileStandardInformation = 5
|
52
|
-
FileStreamInformation = 22
|
53
|
-
FileTrackingInformation = 36
|
54
|
-
FileValidDataLengthInformation = 39
|
14
|
+
private
|
55
15
|
|
56
|
-
|
16
|
+
FileAccessInformation = 8
|
17
|
+
FileAlignmentInformation = 17
|
18
|
+
FileAllInformation = 18
|
19
|
+
FileAllocationInformation = 19
|
20
|
+
FileAlternateNameInformation = 21
|
21
|
+
FileAttributeTagInformation = 35
|
22
|
+
FileBasicInformation = 4
|
23
|
+
FileBothDirectoryInformation = 3
|
24
|
+
FileCompletionInformation = 30
|
25
|
+
FileCompressionInformation = 28
|
26
|
+
FileDirectoryInformation = 1
|
27
|
+
FileDispositionInformation = 13
|
28
|
+
FileEaInformation = 7
|
29
|
+
FileEndOfFileInformation = 20
|
30
|
+
FileFullDirectoryInformation = 2
|
31
|
+
FileFullEaInformation = 15
|
32
|
+
FileHardLinkInformation = 46
|
33
|
+
FileIdBothDirectoryInformation = 37
|
34
|
+
FileIdFullDirectoryInformation = 38
|
35
|
+
FileInternalInformation = 6
|
36
|
+
FileLinkInformation = 11
|
37
|
+
FileMailslotQueryInformation = 26
|
38
|
+
FileMailslotSetInformation = 27
|
39
|
+
FileModeInformation = 16
|
40
|
+
FileMoveClusterInformation = 31
|
41
|
+
FileNameInformation = 9
|
42
|
+
FileNamesInformation = 12
|
43
|
+
FileNetworkOpenInformation = 34
|
44
|
+
FileObjectIdInformation = 29
|
45
|
+
FilePipeInformation = 23
|
46
|
+
FilePipeLocalInformation = 24
|
47
|
+
FilePipeRemoteInformation = 25
|
48
|
+
FilePositionInformation = 14
|
49
|
+
FileQuotaInformation = 32
|
50
|
+
FileRenameInformation = 10
|
51
|
+
FileReparsePointInformation = 33
|
52
|
+
FileShortNameInformation = 40
|
53
|
+
FileStandardInformation = 5
|
54
|
+
FileStreamInformation = 22
|
55
|
+
FileTrackingInformation = 36
|
56
|
+
FileValidDataLengthInformation = 39
|
57
57
|
|
58
|
-
|
58
|
+
ObjectNameInformation = 1
|
59
59
|
|
60
|
-
|
61
|
-
API.new('NtQueryObject', 'LLPLP', 'L', 'ntdll')
|
62
|
-
API.new('NtQuerySystemInformation', 'LPLP', 'L', 'ntdll')
|
63
|
-
API.new('RtlAdjustPrivilege', 'LIIP', 'L', 'ntdll')
|
64
|
-
API.new('RtlSetProcessIsCritical', 'IPI', 'L', 'ntdll')
|
65
|
-
|
66
|
-
# Should work for Windows XP/2000
|
67
|
-
unless defined? GetFinalPathNameByHandle
|
68
|
-
require 'windows/handle'
|
69
|
-
require 'windows/error'
|
70
|
-
require 'windows/unicode'
|
71
|
-
|
72
|
-
def GetFinalPathNameByHandle(file)
|
73
|
-
begin
|
74
|
-
max_path = 256
|
75
|
-
fh = File.open(file, 'r')
|
76
|
-
handle = get_osfhandle(fh.fileno)
|
77
|
-
object_name_information = 0.chr * (8 + (max_path*2))
|
60
|
+
STATUS_SUCCESS = 0
|
78
61
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
object_name_information.size,
|
84
|
-
0
|
85
|
-
)
|
62
|
+
API.new('NtQueryInformationFile', 'LPPLL', 'L', 'ntdll')
|
63
|
+
API.new('NtQueryObject', 'LLPLP', 'L', 'ntdll')
|
64
|
+
API.new('NtQuerySystemInformation', 'LPLP', 'L', 'ntdll')
|
65
|
+
API.new('RtlAdjustPrivilege', 'LIIP', 'L', 'ntdll')
|
86
66
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
name
|
92
|
-
end
|
93
|
-
end
|
67
|
+
begin
|
68
|
+
API.new('RtlSetProcessIsCritical', 'IPI', 'L', 'ntdll')
|
69
|
+
rescue Win32::API::LoadLibraryError
|
70
|
+
# XP or later
|
94
71
|
end
|
95
|
-
|
72
|
+
|
73
|
+
# Should work for Windows XP/2000
|
74
|
+
unless defined? GetFinalPathNameByHandle
|
75
|
+
require 'windows/handle'
|
76
|
+
require 'windows/unicode'
|
77
|
+
require 'windows/volume'
|
78
|
+
|
79
|
+
include Windows::Handle
|
80
|
+
include Windows::Unicode
|
81
|
+
include Windows::Volume
|
82
|
+
|
83
|
+
# Simulates the GetFinalPathNameByHandle method. Note that the +size+
|
84
|
+
# and +flags+ arguments are ignored, but are required for interface
|
85
|
+
# compatibility. The buffer is an in/out parameter.
|
86
|
+
#
|
87
|
+
# The +size+ argument simply isn't used internally and the +flags+
|
88
|
+
# argument is currently assumed to always be VOLUME_NAME_NT.
|
89
|
+
#
|
90
|
+
def GetFinalPathNameByHandle(handle, buffer, size, flags)
|
91
|
+
mpath = 1024
|
92
|
+
hfile = get_osfhandle(handle.fileno)
|
93
|
+
|
94
|
+
object_name_information = 0.chr * (8 + (mpath * 2))
|
95
|
+
|
96
|
+
status = NtQueryObject(
|
97
|
+
hfile,
|
98
|
+
ObjectNameInformation,
|
99
|
+
object_name_information,
|
100
|
+
object_name_information.size,
|
101
|
+
0
|
102
|
+
)
|
103
|
+
|
104
|
+
buffer.replace(wide_to_multi(object_name_information[8..-1]))
|
105
|
+
buffer.size
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
96
110
|
end
|