windows-pr 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +444 -438
  3. data/MANIFEST +68 -65
  4. data/README +154 -153
  5. data/Rakefile +42 -37
  6. data/doc/conversion_guide.txt +37 -37
  7. data/lib/windows/clipboard.rb +61 -61
  8. data/lib/windows/com.rb +192 -192
  9. data/lib/windows/com/accessibility.rb +16 -16
  10. data/lib/windows/com/automation.rb +149 -149
  11. data/lib/windows/com/variant.rb +24 -24
  12. data/lib/windows/console.rb +114 -114
  13. data/lib/windows/debug.rb +35 -35
  14. data/lib/windows/device_io.rb +248 -248
  15. data/lib/windows/directory.rb +27 -27
  16. data/lib/windows/error.rb +504 -498
  17. data/lib/windows/eventlog.rb +80 -80
  18. data/lib/windows/file.rb +264 -264
  19. data/lib/windows/file_mapping.rb +25 -25
  20. data/lib/windows/filesystem.rb +15 -15
  21. data/lib/windows/gdi/bitmap.rb +65 -65
  22. data/lib/windows/gdi/device_context.rb +46 -46
  23. data/lib/windows/gdi/metafile.rb +40 -40
  24. data/lib/windows/gdi/painting_drawing.rb +115 -115
  25. data/lib/windows/handle.rb +23 -23
  26. data/lib/windows/library.rb +44 -44
  27. data/lib/windows/limits.rb +34 -34
  28. data/lib/windows/mailslot.rb +24 -24
  29. data/lib/windows/memory.rb +128 -128
  30. data/lib/windows/msvcrt/buffer.rb +75 -75
  31. data/lib/windows/msvcrt/directory.rb +31 -31
  32. data/lib/windows/msvcrt/file.rb +47 -47
  33. data/lib/windows/msvcrt/io.rb +73 -73
  34. data/lib/windows/msvcrt/string.rb +182 -182
  35. data/lib/windows/msvcrt/time.rb +169 -169
  36. data/lib/windows/national.rb +580 -580
  37. data/lib/windows/network/management.rb +525 -525
  38. data/lib/windows/network/snmp.rb +92 -92
  39. data/lib/windows/network/winsock.rb +128 -128
  40. data/lib/windows/nio.rb +50 -50
  41. data/lib/windows/ntfs/winternl.rb +117 -117
  42. data/lib/windows/path.rb +143 -143
  43. data/lib/windows/pipe.rb +42 -42
  44. data/lib/windows/process.rb +176 -176
  45. data/lib/windows/registry.rb +171 -171
  46. data/lib/windows/security.rb +479 -479
  47. data/lib/windows/security/authentication.rb +32 -32
  48. data/lib/windows/security/sspi.rb +153 -0
  49. data/lib/windows/service.rb +142 -142
  50. data/lib/windows/shell.rb +171 -171
  51. data/lib/windows/socket.rb +86 -86
  52. data/lib/windows/sound.rb +39 -39
  53. data/lib/windows/synchronize.rb +133 -133
  54. data/lib/windows/system_info.rb +229 -229
  55. data/lib/windows/thread.rb +64 -64
  56. data/lib/windows/time.rb +48 -48
  57. data/lib/windows/tool_helper.rb +36 -36
  58. data/lib/windows/unicode.rb +155 -155
  59. data/lib/windows/volume.rb +61 -61
  60. data/lib/windows/window.rb +81 -81
  61. data/lib/windows/window/classes.rb +59 -59
  62. data/lib/windows/window/dialog.rb +91 -91
  63. data/lib/windows/window/menu.rb +102 -102
  64. data/lib/windows/window/message.rb +297 -297
  65. data/lib/windows/window/properties.rb +20 -20
  66. data/lib/windows/window/timer.rb +19 -19
  67. data/lib/windows/wsa.rb +102 -102
  68. data/test/tc_clipboard.rb +41 -41
  69. data/test/tc_com.rb +32 -32
  70. data/test/tc_com_automation.rb +15 -15
  71. data/test/tc_console.rb +108 -108
  72. data/test/tc_debug.rb +48 -48
  73. data/test/tc_device_io.rb +29 -29
  74. data/test/tc_directory.rb +25 -25
  75. data/test/tc_error.rb +38 -38
  76. data/test/tc_eventlog.rb +58 -58
  77. data/test/tc_file.rb +67 -67
  78. data/test/tc_file_mapping.rb +38 -38
  79. data/test/tc_filesystem.rb +27 -27
  80. data/test/tc_gdi_bitmap.rb +25 -25
  81. data/test/tc_gdi_metafile.rb +23 -23
  82. data/test/tc_handle.rb +36 -36
  83. data/test/tc_library.rb +37 -37
  84. data/test/tc_limits.rb +34 -34
  85. data/test/tc_mailslot.rb +22 -22
  86. data/test/tc_memory.rb +44 -44
  87. data/test/tc_msvcrt_buffer.rb +63 -63
  88. data/test/tc_msvcrt_directory.rb +96 -96
  89. data/test/tc_msvcrt_file.rb +80 -80
  90. data/test/tc_msvcrt_io.rb +48 -48
  91. data/test/tc_msvcrt_string.rb +94 -94
  92. data/test/tc_msvcrt_time.rb +19 -19
  93. data/test/tc_national.rb +38 -38
  94. data/test/tc_network_management.rb +32 -32
  95. data/test/tc_network_snmp.rb +31 -31
  96. data/test/tc_network_winsock.rb +34 -34
  97. data/test/tc_nio.rb +32 -32
  98. data/test/tc_ntfs_winternl.rb +48 -48
  99. data/test/tc_path.rb +90 -90
  100. data/test/tc_pipe.rb +53 -53
  101. data/test/tc_process.rb +24 -24
  102. data/test/tc_registry.rb +29 -29
  103. data/test/tc_security.rb +104 -104
  104. data/test/tc_security_authentication.rb +34 -34
  105. data/test/tc_security_sspi.rb +23 -0
  106. data/test/tc_service.rb +57 -57
  107. data/test/tc_shell.rb +34 -34
  108. data/test/tc_socket.rb +20 -20
  109. data/test/tc_sound.rb +37 -37
  110. data/test/tc_synchronize.rb +75 -75
  111. data/test/tc_system_info.rb +33 -33
  112. data/test/tc_thread.rb +29 -29
  113. data/test/tc_time.rb +32 -32
  114. data/test/tc_tool_helper.rb +29 -29
  115. data/test/tc_unicode.rb +83 -83
  116. data/test/tc_volume.rb +47 -47
  117. data/test/tc_window.rb +45 -45
  118. data/test/tc_window_classes.rb +33 -33
  119. data/test/tc_window_dialog.rb +33 -33
  120. data/test/tc_window_menu.rb +29 -29
  121. data/test/tc_window_message.rb +33 -33
  122. data/test/tc_window_properties.rb +29 -29
  123. data/test/tc_window_timer.rb +29 -29
  124. data/test/tc_wsa.rb +19 -19
  125. data/windows-pr.gemspec +33 -34
  126. metadata +31 -32
@@ -1,80 +1,80 @@
1
- require 'windows/api'
2
-
3
- module Windows
4
- module EventLog
5
- API.auto_namespace = 'Windows::EventLog'
6
- API.auto_constant = true
7
- API.auto_method = true
8
- API.auto_unicode = true
9
-
10
- private
11
-
12
- EVENTLOG_SEQUENTIAL_READ = 0x0001
13
- EVENTLOG_SEEK_READ = 0x0002
14
- EVENTLOG_FORWARDS_READ = 0x0004
15
- EVENTLOG_BACKWARDS_READ = 0x0008
16
-
17
- EVENTLOG_SUCCESS = 0x0000
18
- EVENTLOG_ERROR_TYPE = 0x0001
19
- EVENTLOG_WARNING_TYPE = 0x0002
20
- EVENTLOG_INFORMATION_TYPE = 0x0004
21
- EVENTLOG_AUDIT_SUCCESS = 0x0008
22
- EVENTLOG_AUDIT_FAILURE = 0x0010
23
-
24
- EVENTLOG_FULL_INFO = 0
25
-
26
- API.new('BackupEventLog', 'LS', 'B', 'advapi32')
27
- API.new('ClearEventLog', 'LS', 'B', 'advapi32')
28
- API.new('CloseEventLog', 'L', 'B', 'advapi32')
29
- API.new('DeregisterEventSource', 'L', 'B', 'advapi32')
30
- API.new('GetEventLogInformation', 'LLPLP', 'B', 'advapi32')
31
- API.new('GetNumberOfEventLogRecords', 'LP', 'B', 'advapi32')
32
- API.new('GetOldestEventLogRecord', 'LP', 'B', 'advapi32')
33
- API.new('NotifyChangeEventLog', 'LL', 'B', 'advapi32')
34
- API.new('OpenBackupEventLog', 'SS', 'L', 'advapi32')
35
- API.new('OpenEventLog', 'SS', 'L', 'advapi32')
36
- API.new('ReadEventLog', 'LLLPLPP', 'B', 'advapi32')
37
- API.new('RegisterEventSource', 'SS', 'L', 'advapi32')
38
- API.new('ReportEvent', 'LIILPILPP', 'B', 'advapi32')
39
-
40
- begin
41
- API.new('EvtArchiveExportedLog', 'LPLL', 'B', 'wevtapi')
42
- API.new('EvtCancel', 'L', 'B', 'wevtapi')
43
- API.new('EvtClearLog', 'LPPL', 'B', 'wevtapi')
44
- API.new('EvtClose', 'L', 'B', 'wevtapi')
45
- API.new('EvtCreateBookmark', 'L', 'L', 'wevtapi')
46
- API.new('EvtCreateRenderContext', 'LPL', 'L', 'wevtapi')
47
- API.new('EvtExportLog', 'LPPPL', 'B', 'wevtapi')
48
- API.new('EvtFormatMessage', 'LLLLPLLPP', 'B', 'wevtapi')
49
- API.new('EvtGetChannelConfigProperty', 'LLLLPP', 'B', 'wevtapi')
50
- API.new('EvtGetEventInfo', 'LLLPP', 'B', 'wevtapi')
51
- API.new('EvtGetEventMetadataProperty', 'LLLLPP', 'B', 'wevtapi')
52
- API.new('EvtGetExtendedStatus', 'LPP', 'B', 'wevtapi')
53
- API.new('EvtGetLogInfo', 'LLLPP', 'B', 'wevtapi')
54
- API.new('EvtGetObjectArrayProperty', 'LLLLLPP', 'B', 'wevtapi')
55
- API.new('EvtGetObjectArraySize', 'LP', 'B', 'wevtapi')
56
- API.new('EvtGetPublisherMetadataProperty', 'LLLLPP', 'B', 'wevtapi')
57
- API.new('EvtGetQueryInfo', 'LLLPP', 'B', 'wevtapi')
58
- API.new('EvtNext', 'LLPLLP', 'B', 'wevtapi')
59
- API.new('EvtNextChannelPath', 'LLPP', 'B', 'wevtapi')
60
- API.new('EvtNextEventMetadata', 'LL', 'L', 'wevtapi')
61
- API.new('EvtNextPublisherId', 'LLPP', 'B', 'wevtapi')
62
- API.new('EvtOpenChannelConfig', 'LPL', 'L', 'wevtapi')
63
- API.new('EvtOpenChannelEnum', 'LL', 'L', 'wevtapi')
64
- API.new('EvtOpenEventMetadataEnum', 'LL', 'L', 'wevtapi')
65
- API.new('EvtOpenLog', 'LPL', 'L', 'wevtapi')
66
- API.new('EvtOpenPublisherEnum', 'LL', 'L', 'wevtapi')
67
- API.new('EvtOpenPublisherMetadata', 'LPPLL', 'L', 'wevtapi')
68
- API.new('EvtOpenSession', 'LLLL', 'L', 'wevtapi')
69
- API.new('EvtQuery', 'LPPL', 'L', 'wevtapi')
70
- API.new('EvtRender', 'LLLLPPP', 'B', 'wevtapi')
71
- API.new('EvtSaveChannelConfig', 'LL', 'B', 'wevtapi')
72
- API.new('EvtSeek', 'LLLLL', 'B', 'wevtapi')
73
- API.new('EvtSetChannelConfigProperty', 'LLLP', 'B', 'wevtapi')
74
- API.new('EvtSubscribe', 'LLPPLPKL', 'L', 'wevtapi')
75
- API.new('EvtUpdateBookmark', 'LL', 'B', 'wevtapi')
76
- rescue Win32::API::LoadLibraryError
77
- # Windows Vista or later
78
- end
79
- end
80
- end
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module EventLog
5
+ API.auto_namespace = 'Windows::EventLog'
6
+ API.auto_constant = true
7
+ API.auto_method = true
8
+ API.auto_unicode = true
9
+
10
+ private
11
+
12
+ EVENTLOG_SEQUENTIAL_READ = 0x0001
13
+ EVENTLOG_SEEK_READ = 0x0002
14
+ EVENTLOG_FORWARDS_READ = 0x0004
15
+ EVENTLOG_BACKWARDS_READ = 0x0008
16
+
17
+ EVENTLOG_SUCCESS = 0x0000
18
+ EVENTLOG_ERROR_TYPE = 0x0001
19
+ EVENTLOG_WARNING_TYPE = 0x0002
20
+ EVENTLOG_INFORMATION_TYPE = 0x0004
21
+ EVENTLOG_AUDIT_SUCCESS = 0x0008
22
+ EVENTLOG_AUDIT_FAILURE = 0x0010
23
+
24
+ EVENTLOG_FULL_INFO = 0
25
+
26
+ API.new('BackupEventLog', 'LS', 'B', 'advapi32')
27
+ API.new('ClearEventLog', 'LS', 'B', 'advapi32')
28
+ API.new('CloseEventLog', 'L', 'B', 'advapi32')
29
+ API.new('DeregisterEventSource', 'L', 'B', 'advapi32')
30
+ API.new('GetEventLogInformation', 'LLPLP', 'B', 'advapi32')
31
+ API.new('GetNumberOfEventLogRecords', 'LP', 'B', 'advapi32')
32
+ API.new('GetOldestEventLogRecord', 'LP', 'B', 'advapi32')
33
+ API.new('NotifyChangeEventLog', 'LL', 'B', 'advapi32')
34
+ API.new('OpenBackupEventLog', 'SS', 'L', 'advapi32')
35
+ API.new('OpenEventLog', 'SS', 'L', 'advapi32')
36
+ API.new('ReadEventLog', 'LLLPLPP', 'B', 'advapi32')
37
+ API.new('RegisterEventSource', 'SS', 'L', 'advapi32')
38
+ API.new('ReportEvent', 'LIILPILPP', 'B', 'advapi32')
39
+
40
+ begin
41
+ API.new('EvtArchiveExportedLog', 'LPLL', 'B', 'wevtapi')
42
+ API.new('EvtCancel', 'L', 'B', 'wevtapi')
43
+ API.new('EvtClearLog', 'LPPL', 'B', 'wevtapi')
44
+ API.new('EvtClose', 'L', 'B', 'wevtapi')
45
+ API.new('EvtCreateBookmark', 'L', 'L', 'wevtapi')
46
+ API.new('EvtCreateRenderContext', 'LPL', 'L', 'wevtapi')
47
+ API.new('EvtExportLog', 'LPPPL', 'B', 'wevtapi')
48
+ API.new('EvtFormatMessage', 'LLLLPLLPP', 'B', 'wevtapi')
49
+ API.new('EvtGetChannelConfigProperty', 'LLLLPP', 'B', 'wevtapi')
50
+ API.new('EvtGetEventInfo', 'LLLPP', 'B', 'wevtapi')
51
+ API.new('EvtGetEventMetadataProperty', 'LLLLPP', 'B', 'wevtapi')
52
+ API.new('EvtGetExtendedStatus', 'LPP', 'B', 'wevtapi')
53
+ API.new('EvtGetLogInfo', 'LLLPP', 'B', 'wevtapi')
54
+ API.new('EvtGetObjectArrayProperty', 'LLLLLPP', 'B', 'wevtapi')
55
+ API.new('EvtGetObjectArraySize', 'LP', 'B', 'wevtapi')
56
+ API.new('EvtGetPublisherMetadataProperty', 'LLLLPP', 'B', 'wevtapi')
57
+ API.new('EvtGetQueryInfo', 'LLLPP', 'B', 'wevtapi')
58
+ API.new('EvtNext', 'LLPLLP', 'B', 'wevtapi')
59
+ API.new('EvtNextChannelPath', 'LLPP', 'B', 'wevtapi')
60
+ API.new('EvtNextEventMetadata', 'LL', 'L', 'wevtapi')
61
+ API.new('EvtNextPublisherId', 'LLPP', 'B', 'wevtapi')
62
+ API.new('EvtOpenChannelConfig', 'LPL', 'L', 'wevtapi')
63
+ API.new('EvtOpenChannelEnum', 'LL', 'L', 'wevtapi')
64
+ API.new('EvtOpenEventMetadataEnum', 'LL', 'L', 'wevtapi')
65
+ API.new('EvtOpenLog', 'LPL', 'L', 'wevtapi')
66
+ API.new('EvtOpenPublisherEnum', 'LL', 'L', 'wevtapi')
67
+ API.new('EvtOpenPublisherMetadata', 'LPPLL', 'L', 'wevtapi')
68
+ API.new('EvtOpenSession', 'LLLL', 'L', 'wevtapi')
69
+ API.new('EvtQuery', 'LPPL', 'L', 'wevtapi')
70
+ API.new('EvtRender', 'LLLLPPP', 'B', 'wevtapi')
71
+ API.new('EvtSaveChannelConfig', 'LL', 'B', 'wevtapi')
72
+ API.new('EvtSeek', 'LLLLL', 'B', 'wevtapi')
73
+ API.new('EvtSetChannelConfigProperty', 'LLLP', 'B', 'wevtapi')
74
+ API.new('EvtSubscribe', 'LLPPLPKL', 'L', 'wevtapi')
75
+ API.new('EvtUpdateBookmark', 'LL', 'B', 'wevtapi')
76
+ rescue Win32::API::LoadLibraryError
77
+ # Windows Vista or later
78
+ end
79
+ end
80
+ end
@@ -1,264 +1,264 @@
1
- require 'windows/unicode'
2
- require 'windows/security'
3
-
4
- module Windows
5
- module File
6
- include Windows::Unicode
7
- include Windows::Security
8
-
9
- API.auto_namespace = 'Windows::File'
10
- API.auto_constant = true
11
- API.auto_method = true
12
- API.auto_unicode = true
13
-
14
- private
15
-
16
- FILE_BEGIN = 0
17
- FILE_CURRENT = 1
18
- FILE_END = 2
19
-
20
- # File Attributes
21
-
22
- FILE_ATTRIBUTE_READONLY = 0x00000001
23
- FILE_ATTRIBUTE_HIDDEN = 0x00000002
24
- FILE_ATTRIBUTE_SYSTEM = 0x00000004
25
- FILE_ATTRIBUTE_DIRECTORY = 0x00000010
26
- FILE_ATTRIBUTE_ARCHIVE = 0x00000020
27
- FILE_ATTRIBUTE_ENCRYPTED = 0x00000040
28
- FILE_ATTRIBUTE_NORMAL = 0x00000080
29
- FILE_ATTRIBUTE_TEMPORARY = 0x00000100
30
- FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200
31
- FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
32
- FILE_ATTRIBUTE_COMPRESSED = 0x00000800
33
- FILE_ATTRIBUTE_OFFLINE = 0x00001000
34
- FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
35
-
36
- # File types
37
-
38
- FILE_TYPE_UNKNOWN = 0x0000
39
- FILE_TYPE_DISK = 0x0001
40
- FILE_TYPE_CHAR = 0x0002
41
- FILE_TYPE_PIPE = 0x0003
42
- FILE_TYPE_REMOTE = 0x8000
43
-
44
- # File compression constants
45
-
46
- COMPRESSION_FORMAT_NONE = 0
47
- COMPRESSION_FORMAT_DEFAULT = 1
48
- COMPRESSION_FORMAT_LZNT1 = 2
49
- COMPRESSION_ENGINE_STANDARD = 0
50
- COMPRESSION_ENGINE_MAXIMUM = 256
51
- ANYSIZE_ARRAY = 1
52
-
53
- # File security and access rights
54
-
55
- FILE_READ_DATA = 1
56
- FILE_LIST_DIRECTORY = 1
57
- FILE_WRITE_DATA = 2
58
- FILE_ADD_FILE = 2
59
- FILE_APPEND_DATA = 4
60
- FILE_ADD_SUBDIRECTORY = 4
61
- FILE_CREATE_PIPE_INSTANCE = 4
62
- FILE_READ_EA = 8
63
- FILE_READ_PROPERTIES = 8
64
- FILE_WRITE_EA = 16
65
- FILE_WRITE_PROPERTIES = 16
66
- FILE_EXECUTE = 32
67
- FILE_TRAVERSE = 32
68
- FILE_DELETE_CHILD = 64
69
- FILE_READ_ATTRIBUTES = 128
70
- FILE_WRITE_ATTRIBUTES = 256
71
-
72
- FILE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF
73
-
74
- FILE_GENERIC_READ =
75
- STANDARD_RIGHTS_READ |
76
- FILE_READ_DATA |
77
- FILE_READ_ATTRIBUTES |
78
- FILE_READ_EA |
79
- SYNCHRONIZE
80
-
81
- FILE_GENERIC_WRITE =
82
- STANDARD_RIGHTS_WRITE |
83
- FILE_WRITE_DATA |
84
- FILE_WRITE_ATTRIBUTES |
85
- FILE_WRITE_EA |
86
- FILE_APPEND_DATA |
87
- SYNCHRONIZE
88
-
89
- FILE_GENERIC_EXECUTE =
90
- STANDARD_RIGHTS_EXECUTE |
91
- FILE_READ_ATTRIBUTES |
92
- FILE_EXECUTE |
93
- SYNCHRONIZE
94
-
95
- FILE_SHARE_READ = 1
96
- FILE_SHARE_WRITE = 2
97
- FILE_SHARE_DELETE = 4
98
- FILE_NOTIFY_CHANGE_FILE_NAME = 1
99
- FILE_NOTIFY_CHANGE_DIR_NAME = 2
100
- FILE_NOTIFY_CHANGE_ATTRIBUTES = 4
101
- FILE_NOTIFY_CHANGE_SIZE = 8
102
- FILE_NOTIFY_CHANGE_LAST_WRITE = 16
103
- FILE_NOTIFY_CHANGE_LAST_ACCESS = 32
104
- FILE_NOTIFY_CHANGE_CREATION = 64
105
- FILE_NOTIFY_CHANGE_SECURITY = 256
106
- FILE_CASE_SENSITIVE_SEARCH = 1
107
- FILE_CASE_PRESERVED_NAMES = 2
108
- FILE_UNICODE_ON_DISK = 4
109
- FILE_PERSISTENT_ACLS = 8
110
- FILE_FILE_COMPRESSION = 16
111
- FILE_VOLUME_QUOTAS = 32
112
- FILE_SUPPORTS_SPARSE_FILES = 64
113
- FILE_SUPPORTS_REPARSE_POINTS = 128
114
- FILE_SUPPORTS_REMOTE_STORAGE = 256
115
- FILE_VOLUME_IS_COMPRESSED = 0x8000
116
- FILE_SUPPORTS_OBJECT_IDS = 0x10000
117
- FILE_SUPPORTS_ENCRYPTION = 0x20000
118
-
119
- # File flags
120
-
121
- FILE_FLAG_WRITE_THROUGH = 0x80000000
122
- FILE_FLAG_OVERLAPPED = 0x40000000
123
- FILE_FLAG_NO_BUFFERING = 0x20000000
124
- FILE_FLAG_RANDOM_ACCESS = 0x10000000
125
- FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000
126
- FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
127
- FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
128
- FILE_FLAG_POSIX_SEMANTICS = 0x01000000
129
- FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
130
- FILE_FLAG_OPEN_NO_RECALL = 0x00100000
131
- FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000
132
-
133
- # File creation disposition
134
-
135
- CREATE_NEW = 1
136
- CREATE_ALWAYS = 2
137
- OPEN_EXISTING = 3
138
- OPEN_ALWAYS = 4
139
- TRUNCATE_EXISTING = 5
140
-
141
- SECTION_QUERY = 0x0001
142
- SECTION_MAP_WRITE = 0x0002
143
- SECTION_MAP_READ = 0x0004
144
- SECTION_MAP_EXECUTE = 0x0008
145
- SECTION_EXTEND_SIZE = 0x0010
146
-
147
- SECTION_ALL_ACCESS =
148
- STANDARD_RIGHTS_REQUIRED |
149
- SECTION_QUERY |
150
- SECTION_MAP_WRITE |
151
- SECTION_MAP_READ |
152
- SECTION_MAP_EXECUTE |
153
- SECTION_EXTEND_SIZE
154
-
155
- # Errors
156
-
157
- INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF
158
- INVALID_SET_FILE_POINTER = 0xFFFFFFFF
159
- INVALID_FILE_SIZE = 0xFFFFFFFF
160
-
161
- # Defined in Windows::Handle as well. Here for convenience.
162
-
163
- INVALID_HANDLE_VALUE = 0xFFFFFFFF unless defined? INVALID_HANDLE_VALUE
164
-
165
- # Misc
166
-
167
- LOCKFILE_EXCLUSIVE_LOCK = 0x00000001
168
- LOCKFILE_FAIL_IMMEDIATELY = 0x00000002
169
- MOVEFILE_REPLACE_EXISTING = 0x00000001
170
- MOVEFILE_COPY_ALLOWED = 0x00000002
171
- MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
172
- MOVEFILE_WRITE_THROUGH = 0x00000008
173
- MOVEFILE_CREATE_HARDLINK = 0x00000010
174
- MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x00000020
175
- SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
176
-
177
- # FILE_INFO_BY_HANDLE_CLASS enum
178
-
179
- FileBasicInfo = 0
180
- FileStandardInfo = 1
181
- FileNameInfo = 2
182
- FileRenameInfo = 3
183
- FileDispositionInfo = 4
184
- FileAllocationInfo = 5
185
- FileEndOfFileInfo = 6
186
- FileStreamInfo = 7
187
- FileCompressionInfo = 8
188
- FileAttributeTagInfo = 9
189
- FileIdBothDirectoryInfo = 10
190
- FileIdBothDirectoryRestartInfo = 11
191
- FileIoPriorityHintInfo = 12
192
- MaximumFileInfoByHandleClass = 13
193
-
194
- # Reparse point tags
195
-
196
- IO_REPARSE_TAG_DFS = 0x8000000A
197
- IO_REPARSE_TAG_DFSR = 0x80000012
198
- IO_REPARSE_TAG_HSM = 0xC0000004
199
- IO_REPARSE_TAG_HSM2 = 0x80000006
200
- IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
201
- IO_REPARSE_TAG_SIS = 0x80000007
202
- IO_REPARSE_TAG_SYMLINK = 0xA000000C
203
-
204
- API.new('CopyFile', 'SSI', 'B')
205
- API.new('CopyFileEx', 'SSKPPL', 'B')
206
- API.new('CreateFile', 'SLLPLLL', 'L')
207
- API.new('CreateHardLink', 'SSP', 'B')
208
- API.new('DecryptFile', 'SL', 'B', 'advapi32')
209
- API.new('DeleteFile', 'S', 'B')
210
- API.new('EncryptFile', 'S', 'B', 'advapi32')
211
- API.new('FindClose', 'L', 'B')
212
- API.new('FindFirstFile', 'SP', 'L')
213
- API.new('FindFirstFileEx', 'SIPIII', 'L')
214
- API.new('FindNextFile', 'LP', 'B')
215
- API.new('FlushFileBuffers', 'L', 'B')
216
- API.new('GetBinaryType', 'SP', 'B')
217
- API.new('GetFileAttributes', 'S', 'L')
218
- API.new('GetFileAttributesEx', 'SPP', 'I')
219
- API.new('GetFileInformationByHandle', 'LP', 'B')
220
- API.new('GetFileSize', 'LP', 'L')
221
- API.new('GetFileSizeEx', 'LP', 'B')
222
- API.new('GetFileType', 'L', 'L')
223
- API.new('GetFullPathName', 'SLPP', 'L')
224
- API.new('GetLongPathName', 'SPL', 'L')
225
- API.new('GetShortPathName', 'SPL', 'L')
226
- API.new('LockFile', 'LLLLL', 'B')
227
- API.new('LockFileEx', 'LLLLLL', 'B')
228
- API.new('MoveFile', 'SS', 'B')
229
- API.new('MoveFileEx', 'SSL', 'B')
230
- API.new('ReadFile', 'LPLPP', 'B')
231
- API.new('ReadFileEx', 'LPLPK', 'B')
232
- API.new('SetEndOfFile', 'L', 'B')
233
- API.new('SetFileAttributes', 'SL', 'B')
234
- API.new('UnlockFile', 'LLLLL', 'B')
235
- API.new('UnlockFileEx', 'LLLLL', 'B')
236
- API.new('WriteFile', 'LPLPP', 'B')
237
- API.new('WriteFileEx', 'LPLPK', 'B')
238
-
239
- begin
240
- API.new('SetFileShortName', 'LP', 'B')
241
- API.new('SetFileValidData', 'LL', 'B')
242
- rescue Win32::API::LoadLibraryError
243
- # Windows XP or later
244
- end
245
-
246
- begin
247
- API.new('Wow64DisableWow64FsRedirection', 'P', 'B')
248
- API.new('Wow64EnableWow64FsRedirection', 'I', 'I')
249
- API.new('Wow64RevertWow64FsRedirection', 'L', 'B')
250
- rescue Win32::API::LoadLibraryError
251
- # Windows XP 64-bit and later
252
- end
253
-
254
- begin
255
- API.new('CreateSymbolicLink', 'SSL', 'B')
256
- API.new('CreateSymbolicLinkTransacted', 'SSLL', 'B')
257
- API.new('GetFileInformationByHandleEx', 'LLPL', 'B')
258
- API.new('GetFinalPathNameByHandle', 'LPLL', 'L')
259
- API.new('SetFileInformationByHandle', 'LLPL', 'B')
260
- rescue Win32::API::LoadLibraryError
261
- # Windows Vista
262
- end
263
- end
264
- end
1
+ require 'windows/unicode'
2
+ require 'windows/security'
3
+
4
+ module Windows
5
+ module File
6
+ include Windows::Unicode
7
+ include Windows::Security
8
+
9
+ API.auto_namespace = 'Windows::File'
10
+ API.auto_constant = true
11
+ API.auto_method = true
12
+ API.auto_unicode = true
13
+
14
+ private
15
+
16
+ FILE_BEGIN = 0
17
+ FILE_CURRENT = 1
18
+ FILE_END = 2
19
+
20
+ # File Attributes
21
+
22
+ FILE_ATTRIBUTE_READONLY = 0x00000001
23
+ FILE_ATTRIBUTE_HIDDEN = 0x00000002
24
+ FILE_ATTRIBUTE_SYSTEM = 0x00000004
25
+ FILE_ATTRIBUTE_DIRECTORY = 0x00000010
26
+ FILE_ATTRIBUTE_ARCHIVE = 0x00000020
27
+ FILE_ATTRIBUTE_ENCRYPTED = 0x00000040
28
+ FILE_ATTRIBUTE_NORMAL = 0x00000080
29
+ FILE_ATTRIBUTE_TEMPORARY = 0x00000100
30
+ FILE_ATTRIBUTE_SPARSE_FILE = 0x00000200
31
+ FILE_ATTRIBUTE_REPARSE_POINT = 0x00000400
32
+ FILE_ATTRIBUTE_COMPRESSED = 0x00000800
33
+ FILE_ATTRIBUTE_OFFLINE = 0x00001000
34
+ FILE_ATTRIBUTE_NOT_CONTENT_INDEXED = 0x00002000
35
+
36
+ # File types
37
+
38
+ FILE_TYPE_UNKNOWN = 0x0000
39
+ FILE_TYPE_DISK = 0x0001
40
+ FILE_TYPE_CHAR = 0x0002
41
+ FILE_TYPE_PIPE = 0x0003
42
+ FILE_TYPE_REMOTE = 0x8000
43
+
44
+ # File compression constants
45
+
46
+ COMPRESSION_FORMAT_NONE = 0
47
+ COMPRESSION_FORMAT_DEFAULT = 1
48
+ COMPRESSION_FORMAT_LZNT1 = 2
49
+ COMPRESSION_ENGINE_STANDARD = 0
50
+ COMPRESSION_ENGINE_MAXIMUM = 256
51
+ ANYSIZE_ARRAY = 1
52
+
53
+ # File security and access rights
54
+
55
+ FILE_READ_DATA = 1
56
+ FILE_LIST_DIRECTORY = 1
57
+ FILE_WRITE_DATA = 2
58
+ FILE_ADD_FILE = 2
59
+ FILE_APPEND_DATA = 4
60
+ FILE_ADD_SUBDIRECTORY = 4
61
+ FILE_CREATE_PIPE_INSTANCE = 4
62
+ FILE_READ_EA = 8
63
+ FILE_READ_PROPERTIES = 8
64
+ FILE_WRITE_EA = 16
65
+ FILE_WRITE_PROPERTIES = 16
66
+ FILE_EXECUTE = 32
67
+ FILE_TRAVERSE = 32
68
+ FILE_DELETE_CHILD = 64
69
+ FILE_READ_ATTRIBUTES = 128
70
+ FILE_WRITE_ATTRIBUTES = 256
71
+
72
+ FILE_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x1FF
73
+
74
+ FILE_GENERIC_READ =
75
+ STANDARD_RIGHTS_READ |
76
+ FILE_READ_DATA |
77
+ FILE_READ_ATTRIBUTES |
78
+ FILE_READ_EA |
79
+ SYNCHRONIZE
80
+
81
+ FILE_GENERIC_WRITE =
82
+ STANDARD_RIGHTS_WRITE |
83
+ FILE_WRITE_DATA |
84
+ FILE_WRITE_ATTRIBUTES |
85
+ FILE_WRITE_EA |
86
+ FILE_APPEND_DATA |
87
+ SYNCHRONIZE
88
+
89
+ FILE_GENERIC_EXECUTE =
90
+ STANDARD_RIGHTS_EXECUTE |
91
+ FILE_READ_ATTRIBUTES |
92
+ FILE_EXECUTE |
93
+ SYNCHRONIZE
94
+
95
+ FILE_SHARE_READ = 1
96
+ FILE_SHARE_WRITE = 2
97
+ FILE_SHARE_DELETE = 4
98
+ FILE_NOTIFY_CHANGE_FILE_NAME = 1
99
+ FILE_NOTIFY_CHANGE_DIR_NAME = 2
100
+ FILE_NOTIFY_CHANGE_ATTRIBUTES = 4
101
+ FILE_NOTIFY_CHANGE_SIZE = 8
102
+ FILE_NOTIFY_CHANGE_LAST_WRITE = 16
103
+ FILE_NOTIFY_CHANGE_LAST_ACCESS = 32
104
+ FILE_NOTIFY_CHANGE_CREATION = 64
105
+ FILE_NOTIFY_CHANGE_SECURITY = 256
106
+ FILE_CASE_SENSITIVE_SEARCH = 1
107
+ FILE_CASE_PRESERVED_NAMES = 2
108
+ FILE_UNICODE_ON_DISK = 4
109
+ FILE_PERSISTENT_ACLS = 8
110
+ FILE_FILE_COMPRESSION = 16
111
+ FILE_VOLUME_QUOTAS = 32
112
+ FILE_SUPPORTS_SPARSE_FILES = 64
113
+ FILE_SUPPORTS_REPARSE_POINTS = 128
114
+ FILE_SUPPORTS_REMOTE_STORAGE = 256
115
+ FILE_VOLUME_IS_COMPRESSED = 0x8000
116
+ FILE_SUPPORTS_OBJECT_IDS = 0x10000
117
+ FILE_SUPPORTS_ENCRYPTION = 0x20000
118
+
119
+ # File flags
120
+
121
+ FILE_FLAG_WRITE_THROUGH = 0x80000000
122
+ FILE_FLAG_OVERLAPPED = 0x40000000
123
+ FILE_FLAG_NO_BUFFERING = 0x20000000
124
+ FILE_FLAG_RANDOM_ACCESS = 0x10000000
125
+ FILE_FLAG_SEQUENTIAL_SCAN = 0x08000000
126
+ FILE_FLAG_DELETE_ON_CLOSE = 0x04000000
127
+ FILE_FLAG_BACKUP_SEMANTICS = 0x02000000
128
+ FILE_FLAG_POSIX_SEMANTICS = 0x01000000
129
+ FILE_FLAG_OPEN_REPARSE_POINT = 0x00200000
130
+ FILE_FLAG_OPEN_NO_RECALL = 0x00100000
131
+ FILE_FLAG_FIRST_PIPE_INSTANCE = 0x00080000
132
+
133
+ # File creation disposition
134
+
135
+ CREATE_NEW = 1
136
+ CREATE_ALWAYS = 2
137
+ OPEN_EXISTING = 3
138
+ OPEN_ALWAYS = 4
139
+ TRUNCATE_EXISTING = 5
140
+
141
+ SECTION_QUERY = 0x0001
142
+ SECTION_MAP_WRITE = 0x0002
143
+ SECTION_MAP_READ = 0x0004
144
+ SECTION_MAP_EXECUTE = 0x0008
145
+ SECTION_EXTEND_SIZE = 0x0010
146
+
147
+ SECTION_ALL_ACCESS =
148
+ STANDARD_RIGHTS_REQUIRED |
149
+ SECTION_QUERY |
150
+ SECTION_MAP_WRITE |
151
+ SECTION_MAP_READ |
152
+ SECTION_MAP_EXECUTE |
153
+ SECTION_EXTEND_SIZE
154
+
155
+ # Errors
156
+
157
+ INVALID_FILE_ATTRIBUTES = 0xFFFFFFFF
158
+ INVALID_SET_FILE_POINTER = 0xFFFFFFFF
159
+ INVALID_FILE_SIZE = 0xFFFFFFFF
160
+
161
+ # Defined in Windows::Handle as well. Here for convenience.
162
+
163
+ INVALID_HANDLE_VALUE = 0xFFFFFFFF unless defined? INVALID_HANDLE_VALUE
164
+
165
+ # Misc
166
+
167
+ LOCKFILE_EXCLUSIVE_LOCK = 0x00000001
168
+ LOCKFILE_FAIL_IMMEDIATELY = 0x00000002
169
+ MOVEFILE_REPLACE_EXISTING = 0x00000001
170
+ MOVEFILE_COPY_ALLOWED = 0x00000002
171
+ MOVEFILE_DELAY_UNTIL_REBOOT = 0x00000004
172
+ MOVEFILE_WRITE_THROUGH = 0x00000008
173
+ MOVEFILE_CREATE_HARDLINK = 0x00000010
174
+ MOVEFILE_FAIL_IF_NOT_TRACKABLE = 0x00000020
175
+ SYMBOLIC_LINK_FLAG_DIRECTORY = 0x1
176
+
177
+ # FILE_INFO_BY_HANDLE_CLASS enum
178
+
179
+ FileBasicInfo = 0
180
+ FileStandardInfo = 1
181
+ FileNameInfo = 2
182
+ FileRenameInfo = 3
183
+ FileDispositionInfo = 4
184
+ FileAllocationInfo = 5
185
+ FileEndOfFileInfo = 6
186
+ FileStreamInfo = 7
187
+ FileCompressionInfo = 8
188
+ FileAttributeTagInfo = 9
189
+ FileIdBothDirectoryInfo = 10
190
+ FileIdBothDirectoryRestartInfo = 11
191
+ FileIoPriorityHintInfo = 12
192
+ MaximumFileInfoByHandleClass = 13
193
+
194
+ # Reparse point tags
195
+
196
+ IO_REPARSE_TAG_DFS = 0x8000000A
197
+ IO_REPARSE_TAG_DFSR = 0x80000012
198
+ IO_REPARSE_TAG_HSM = 0xC0000004
199
+ IO_REPARSE_TAG_HSM2 = 0x80000006
200
+ IO_REPARSE_TAG_MOUNT_POINT = 0xA0000003
201
+ IO_REPARSE_TAG_SIS = 0x80000007
202
+ IO_REPARSE_TAG_SYMLINK = 0xA000000C
203
+
204
+ API.new('CopyFile', 'SSI', 'B')
205
+ API.new('CopyFileEx', 'SSKPPL', 'B')
206
+ API.new('CreateFile', 'SLLPLLL', 'L')
207
+ API.new('CreateHardLink', 'SSP', 'B')
208
+ API.new('DecryptFile', 'SL', 'B', 'advapi32')
209
+ API.new('DeleteFile', 'S', 'B')
210
+ API.new('EncryptFile', 'S', 'B', 'advapi32')
211
+ API.new('FindClose', 'L', 'B')
212
+ API.new('FindFirstFile', 'SP', 'L')
213
+ API.new('FindFirstFileEx', 'SIPIII', 'L')
214
+ API.new('FindNextFile', 'LP', 'B')
215
+ API.new('FlushFileBuffers', 'L', 'B')
216
+ API.new('GetBinaryType', 'SP', 'B')
217
+ API.new('GetFileAttributes', 'S', 'L')
218
+ API.new('GetFileAttributesEx', 'SPP', 'I')
219
+ API.new('GetFileInformationByHandle', 'LP', 'B')
220
+ API.new('GetFileSize', 'LP', 'L')
221
+ API.new('GetFileSizeEx', 'LP', 'B')
222
+ API.new('GetFileType', 'L', 'L')
223
+ API.new('GetFullPathName', 'SLPP', 'L')
224
+ API.new('GetLongPathName', 'SPL', 'L')
225
+ API.new('GetShortPathName', 'SPL', 'L')
226
+ API.new('LockFile', 'LLLLL', 'B')
227
+ API.new('LockFileEx', 'LLLLLL', 'B')
228
+ API.new('MoveFile', 'SS', 'B')
229
+ API.new('MoveFileEx', 'SSL', 'B')
230
+ API.new('ReadFile', 'LPLPP', 'B')
231
+ API.new('ReadFileEx', 'LPLPK', 'B')
232
+ API.new('SetEndOfFile', 'L', 'B')
233
+ API.new('SetFileAttributes', 'SL', 'B')
234
+ API.new('UnlockFile', 'LLLLL', 'B')
235
+ API.new('UnlockFileEx', 'LLLLL', 'B')
236
+ API.new('WriteFile', 'LPLPP', 'B')
237
+ API.new('WriteFileEx', 'LPLPK', 'B')
238
+
239
+ begin
240
+ API.new('SetFileShortName', 'LP', 'B')
241
+ API.new('SetFileValidData', 'LL', 'B')
242
+ rescue Win32::API::LoadLibraryError
243
+ # Windows XP or later
244
+ end
245
+
246
+ begin
247
+ API.new('Wow64DisableWow64FsRedirection', 'P', 'B')
248
+ API.new('Wow64EnableWow64FsRedirection', 'I', 'I')
249
+ API.new('Wow64RevertWow64FsRedirection', 'L', 'B')
250
+ rescue Win32::API::LoadLibraryError
251
+ # Windows XP 64-bit and later
252
+ end
253
+
254
+ begin
255
+ API.new('CreateSymbolicLink', 'SSL', 'B')
256
+ API.new('CreateSymbolicLinkTransacted', 'SSLL', 'B')
257
+ API.new('GetFileInformationByHandleEx', 'LLPL', 'B')
258
+ API.new('GetFinalPathNameByHandle', 'LPLL', 'L')
259
+ API.new('SetFileInformationByHandle', 'LLPL', 'B')
260
+ rescue Win32::API::LoadLibraryError
261
+ # Windows Vista
262
+ end
263
+ end
264
+ end