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
@@ -1,90 +1,92 @@
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
- SNMPAPI_FAILURE = 0
12
- SNMPAPI_SUCCESS = 1
13
- SNMPAPI_ALLOC_ERROR = 2
14
- SNMPAPI_CONTEXT_INVALID = 3
15
- SNMPAPI_CONTEXT_UNKNOWN = 4
16
- SNMPAPI_ENTITY_INVALID = 5
17
- SNMPAPI_ENTITY_UNKNOWN = 6
18
- SNMPAPI_INDEX_INVALID = 7
19
- SNMPAPI_NOOP = 8
20
- SNMPAPI_OID_INVALID = 9
21
- SNMPAPI_OPERATION_INVALID = 10
22
- SNMPAPI_OUTPUT_TRUNCATED = 11
23
- SNMPAPI_PDU_INVALID = 12
24
- SNMPAPI_SESSION_INVALID = 13
25
- SNMPAPI_SYNTAX_INVALID = 14
26
- SNMPAPI_VBL_INVALID = 15
27
- SNMPAPI_MODE_INVALID = 16
28
- SNMPAPI_SIZE_INVALID = 17
29
- SNMPAPI_NOT_INITIALIZED = 18
30
- SNMPAPI_MESSAGE_INVALID = 19
31
- SNMPAPI_HWND_INVALID = 20
32
- SNMPAPI_OTHER_ERROR = 99
33
- SNMPAPI_TL_NOT_INITIALIZED = 100
34
- SNMPAPI_TL_NOT_SUPPORTED = 101
35
- SNMPAPI_TL_NOT_AVAILABLE = 102
36
- SNMPAPI_TL_RESOURCE_ERROR = 103
37
- SNMPAPI_TL_UNDELIVERABLE = 104
38
- SNMPAPI_TL_SRC_INVALID = 105
39
- SNMPAPI_TL_INVALID_PARAM = 106
40
- SNMPAPI_TL_IN_USE = 107
41
- SNMPAPI_TL_TIMEOUT = 108
42
- SNMPAPI_TL_PDU_TOO_BIG = 109
43
- SNMPAPI_TL_OTHER = 199
44
-
45
- SNMPAPI_TRANSLATED = 0
46
- SNMPAPI_UNTRANSLATED_V1 = 1
47
- SNMPAPI_UNTRANSLATED_V2 = 2
48
- SNMPAPI_NO_SUPPORT = 0
49
- SNMPAPI_V1_SUPPORT = 1
50
- SNMPAPI_V2_SUPPORT = 2
51
- SNMPAPI_M2M_SUPPORT = 3
52
- SNMPAPI_OFF = 0
53
- SNMPAPI_ON = 1
54
-
55
- API.new('SnmpCancelMsg', 'LI', 'I', 'wsnmp32')
56
- API.new('SnmpCleanup', 'V', 'I', 'wsnmp32')
57
- API.new('SnmpClose', 'L', 'I', 'wsnmp32')
58
- API.new('SnmpContextToStr', 'LP', 'I', 'wsnmp32')
59
- API.new('SnmpDecodeMsg', 'LPPPPP', 'I', 'wsnmp32')
60
- API.new('SnmpEncodeMsg', 'LLLLLP', 'I', 'wsnmp32')
61
- API.new('SnmpEntityToStr', 'LLP', 'I', 'wsnmp32')
62
- API.new('SnmpFreeContext', 'L', 'I', 'wsnmp32')
63
- API.new('SnmpFreeDescriptor', 'LP', 'I', 'wsnmp32')
64
- API.new('SnmpFreeEntity', 'L', 'I', 'wsnmp32')
65
- API.new('SnmpGetLastError', 'L', 'I', 'wsnmp32')
66
- API.new('SnmpListen', 'LL', 'I', 'wsnmp32')
67
- API.new('SnmpOidCompare', 'PPLP', 'I', 'wsnmp32')
68
- API.new('SnmpOidCopy', 'PP', 'I', 'wsnmp32')
69
- API.new('SnmpOidToStr', 'PLP', 'I', 'wsnmp32')
70
- API.new('SnmpOpen', 'LL', 'L', 'wsnmp32')
71
- API.new('SnmpRecvMsg', 'LPPPP', 'I', 'wsnmp32')
72
- API.new('SnmpRegister', 'LLLLPL', 'I', 'wsnmp32')
73
- API.new('SnmpSendMsg', 'LLLLL', 'I', 'wsnmp32')
74
- API.new('SnmpSetPort', 'LL', 'I', 'wsnmp32')
75
- API.new('SnmpStartup', 'PPPPP', 'I', 'wsnmp32')
76
- API.new('SnmpStrToContext', 'LP', 'I', 'wsnmp32')
77
- API.new('SnmpStrToEntity', 'LP', 'I', 'wsnmp32')
78
- API.new('SnmpStrToOid', 'PP', 'I', 'wsnmp32')
79
-
80
- # Windows 2003 Server or later and/or WinSNMP 2.0 or later
81
- begin
82
- API.new('SnmpCreateSession', 'LLKP', 'L', 'wsnmp32')
83
- API.new('SnmpCleanupEx', 'V', 'I', 'wsnmp32')
84
- API.new('SnmpStartupEx', 'PPPPP', 'L', 'wsnmp32')
85
- rescue Win32::API::LoadLibraryError
86
- # Do nothing. It's up to you to check for their existence.
87
- end
88
- end
89
- end
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
- 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
- # Namespace constants
12
- NS_DEFAULT = 0
13
- NS_SAP = 1
14
- NS_NDS = 2
15
- NS_PEER_BROWSE = 3
16
- NS_TCPIP_LOCAL = 10
17
- NS_TCPIP_HOSTS = 11
18
- NS_DNS = 12
19
- NS_NETBT = 13
20
- NS_WINS = 14
21
- NS_NBP = 20
22
- NS_MS = 30
23
- NS_STDA = 31
24
- NS_NTDS = 32
25
- NS_X500 = 40
26
- NS_NIS = 41
27
- NS_VNS = 50
28
-
29
- # Resolution flags
30
- RES_SOFT_SEARCH = 0x00000001
31
- RES_FIND_MULTIPLE = 0x00000002
32
- RES_SERVICE = 0x00000004
33
-
34
- API.new('accept', 'LPP', 'L', 'ws2_32')
35
- API.new('AcceptEx', 'LLPLLLPP', 'B', 'mswsock')
36
- API.new('bind', 'LPL', 'I', 'ws2_32')
37
- API.new('closesocket', 'L', 'I', 'ws2_32')
38
- API.new('connect', 'LPI', 'I', 'ws2_32')
39
- API.new('EnumProtocols', 'PPP', 'I', 'mswsock')
40
- API.new('GetAcceptExSockaddrs', 'PLLLPPPP', 'V', 'mswsock')
41
- API.new('GetAddressByName', 'LPPPLPPPPP', 'V', 'mswsock')
42
- API.new('gethostbyaddr', 'PII', 'L', 'ws2_32')
43
- API.new('gethostbyname', 'P', 'L', 'ws2_32')
44
- API.new('gethostname', 'PI', 'I', 'ws2_32')
45
- API.new('GetNameByType', 'PPL', 'I', 'mswsock')
46
- API.new('getpeername', 'LPP', 'I', 'ws2_32')
47
- API.new('getprotobyname', 'P', 'L', 'ws2_32')
48
- API.new('getprotobynumber', 'L', 'L', 'ws2_32')
49
- API.new('getservbyname', 'PP', 'L', 'ws2_32')
50
- API.new('getservbyport', 'IP', 'L', 'ws2_32')
51
- API.new('GetService', 'LPPLPPP', 'I', 'mswsock')
52
- API.new('getsockname', 'LPP', 'I', 'ws2_32')
53
- API.new('getsockopt', 'LIIPP', 'I', 'ws2_32')
54
- API.new('GetTypeByName', 'PP', 'I', 'mswsock')
55
- API.new('htonl', 'L', 'L', 'ws2_32')
56
- API.new('htons', 'I', 'I', 'ws2_32')
57
- API.new('inet_addr', 'P', 'L', 'ws2_32')
58
- API.new('inet_ntoa', 'P', 'P', 'ws2_32')
59
- API.new('ioctlsocket', 'LLP', 'I', 'ws2_32')
60
- API.new('listen', 'LI', 'I', 'ws2_32')
61
- API.new('ntohl', 'L', 'L', 'ws2_32')
62
- API.new('ntohs', 'I', 'I', 'ws2_32')
63
- API.new('recv', 'LPII', 'I', 'ws2_32')
64
- API.new('recvfrom', 'LPIIPP', 'I', 'ws2_32')
65
- API.new('select', 'IPPPP', 'I', 'ws2_32')
66
- API.new('send', 'LPII', 'I', 'ws2_32')
67
- API.new('sendto', 'LPIIPI', 'I', 'ws2_32')
68
- API.new('SetService', 'LLLPPP', 'I', 'mswsock')
69
- API.new('setsockopt', 'LIIPI', 'I', 'ws2_32')
70
- API.new('shutdown', 'LI', 'I', 'ws2_32')
71
- API.new('socket', 'III', 'L', 'ws2_32')
72
- API.new('TransmitFile', 'LLLLPPL', 'B', 'mswsock')
73
-
74
- API.new('WSAAccept', 'PPPKL', 'I', 'ws2_32')
75
- API.new('WSAAddressToString', 'PLPPP', 'I', 'ws2_32')
76
- API.new('WSAAsyncGetHostByAddr', 'LIPIIPI', 'L', 'ws2_32')
77
- API.new('WSAAsyncGetHostByName', 'LIPPI', 'L', 'ws2_32')
78
- API.new('WSAAsyncGetProtoByName', 'LIPPI', 'L', 'ws2_32')
79
- API.new('WSAAsyncGetServByName', 'LIPPPL', 'L', 'ws2_32')
80
- API.new('WSAAsyncGetServByPort', 'LIIPPI', 'L', 'ws2_32')
81
- API.new('WSAAsyncSelect', 'PLIL', 'I', 'ws2_32')
82
- API.new('WSACleanup', 'V', 'I', 'ws2_32')
83
- API.new('WSACloseEvent', 'L', 'B', 'ws2_32')
84
- API.new('WSAConnect', 'LPIPPPP', 'I', 'ws2_32')
85
- API.new('WSACreateEvent', 'V', 'L', 'ws2_32')
86
- API.new('WSADuplicateSocket', 'LLP', 'I', 'ws2_32')
87
- API.new('WSAEnumNameSpaceProviders', 'PP', 'I', 'ws2_32')
88
- API.new('WSAEnumNetworkEvents', 'LLP', 'I', 'ws2_32')
89
- API.new('WSAEnumProtocols', 'PPP', 'I', 'ws2_32')
90
- API.new('WSAEventSelect', 'LLL', 'I', 'ws2_32')
91
- API.new('WSAGetLastError', 'V', 'I', 'ws2_32')
92
- API.new('WSAIoctl', 'LLPLPLPPP', 'I', 'ws2_32')
93
- API.new('WSARecv', 'LPLPPPP', 'I', 'ws2_32')
94
- API.new('WSASocket', 'IIIPIL', 'L', 'ws2_32')
95
- API.new('WSAStartup', 'IP', 'I', 'ws2_32')
96
- API.new('WSAStringToAddress', 'PIPPP', 'I', 'ws2_32')
97
- API.new('WSAWaitForMultipleEvents', 'LPBLB', 'L', 'ws2_32')
98
-
99
- # XP or later
100
- begin
101
- API.new('ConnectEx', 'LPIPLPP', 'B', 'mswsock')
102
- API.new('DisconnectEx', 'LPLL', 'B', 'mswsock')
103
- API.new('freeaddrinfo', 'P', 'V', 'ws2_32')
104
- API.new('FreeAddrInfoW', 'P', 'V', 'ws2_32')
105
- API.new('getaddrinfo', 'PPPP', 'I', 'ws2_32')
106
- API.new('GetAddrInfoW', 'PPPP', 'I', 'mswsock')
107
- API.new('getnameinfo', 'PLPLPLI', 'I', 'ws2_32')
108
- API.new('GetNameInfoW', 'PLPLPLI', 'I', 'ws2_32')
109
- rescue Win32::API::LoadLibraryError
110
- # Do nothing, not supported on your platform.
111
- end
112
-
113
- # Vista or later
114
- begin
115
- API.new('FreeAddrInfoEx', 'P', 'V', 'ws2_32')
116
- API.new('GetAddrInfoEx', 'PPLPPPPPPP', 'I', 'ws2_32')
117
- API.new('WSAConnectByList', 'LPPPPPPP', 'B', 'ws2_32')
118
- API.new('WSAConnectByName', 'LPPPPPPP', 'B', 'ws2_32')
119
- API.new('WSADeleteSocketPeerTargetName', 'LPPPP', 'I', 'ws2_32')
120
- API.new('WSAPoll', 'PLI', 'I', 'ws2_32')
121
- rescue Win32::API::LoadLibraryError
122
- # Do nothing, not supported on your platform.
123
- end
124
- end
125
- end
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
@@ -7,6 +7,8 @@ module Windows
7
7
  API.auto_method = true
8
8
  API.auto_unicode = false
9
9
 
10
+ private
11
+
10
12
  # OpenFile() constants
11
13
 
12
14
  OF_READ = 0x00000000
@@ -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
- 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
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
- FileAccessInformation = 8
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
- ObjectNameInformation = 1
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
- STATUS_SUCCESS = 0
58
+ ObjectNameInformation = 1
59
59
 
60
- API.new('NtQueryInformationFile', 'LPPLL', 'L', 'ntdll')
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
- status = NtQueryObject(
80
- handle,
81
- ObjectNameInformation,
82
- object_name_information,
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
- name = wide_to_multi(object_name_information[8..-1])
88
- ensure
89
- fh.close
90
- end
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
- end
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