windows-pr 0.5.1-mswin32 → 0.5.2-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,15 @@
1
+ = 0.5.2 - 29-Jul-2006
2
+ * Prototype fixes/changes for CreateProcess, GlobalLock, GlobalMemoryStatusEx,
3
+ and CreateFileMapping.
4
+ * Finer grained method wrapping/checking for the Windows::Process module (only
5
+ two methods might not be defined).
6
+ * Added method wrappers for the Handle constants.
7
+ * Added mmap related methods and constants.
8
+ * Added more test cases.
9
+ * Added wide character methods to the Windows::Directory class.
10
+ * Added wide character helper methods.
11
+ * Added a few more methods to MSVCRT::String.
12
+
1
13
  = 0.5.1 - 26-May-2006
2
14
  * Minor updates and fixes for the Unicode and DeviceIO modules.
3
15
  * Added some wide character support, based on $KCODE values (which should
data/README CHANGED
@@ -45,15 +45,16 @@
45
45
  file contains clipboard related functions, such as CloseClipboard(), as
46
46
  well as constants such as CF_TEXT, CF_BITMAP, etc.
47
47
 
48
- == Wide character functions - DO NOT USE
49
- Because there's no way to "#define UNICODE" from outside of C, I have
50
- instead taken the approach of defining the wide character functions and
51
- automatically using those if $KCODE is set to anything other than "NONE".
52
-
53
- However, support for this is very incomplete at the moment. In addition,
54
- unpredictable segfaults occur with Ruby's string processing in some cases,
55
- the cause of which is unknown at this time. The upshot of this is that you
56
- should not use these modules with $KCODE set to anything other than "NONE".
48
+ == Wide character functions
49
+ I decided that the $KCODE handling was a bad idea, so most of the $KCODE
50
+ handling has been removed. The only methods that change their behavior
51
+ based on $KCODE are the multi_to_wide and wide_to_multi helper methods
52
+ in the Windows::Unicode module. If $KCODE is set to UTF8, then the code
53
+ point used is CP_UTF8. Otherwise, CP_ACP is used.
54
+
55
+ In the future I'll add the wide character functions explicitly. I haven't
56
+ added many yet (as of 29-Jul-2006) but I plan on adding as many as I can
57
+ as time permits.
57
58
 
58
59
  == Where are the tests, dude?
59
60
  While I've made some effort to test these functions, there are simply too
@@ -5,10 +5,12 @@ module Windows
5
5
  CreateDirectory = Win32API.new('kernel32', 'CreateDirectory', 'PP', 'I')
6
6
  CreateDirectoryW = Win32API.new('kernel32', 'CreateDirectoryW', 'PP', 'I')
7
7
  CreateDirectoryEx = Win32API.new('kernel32', 'CreateDirectoryEx', 'PPP', 'I')
8
+ CreateDirectoryExW = Win32API.new('kernel32', 'CreateDirectoryExW', 'PPP', 'I')
8
9
  FindCloseChangeNotification = Win32API.new('kernel32', 'FindCloseChangeNotification', 'L', 'I')
9
10
  FindFirstChangeNotification = Win32API.new('kernel32', 'FindFirstChangeNotification', 'PIL', 'L')
10
11
  FindNextChangeNotification = Win32API.new('kernel32', 'FindFirstChangeNotification', 'PIL', 'I')
11
12
  GetCurrentDirectory = Win32API.new('kernel32', 'GetCurrentDirectory', 'LP', 'L')
13
+ GetCurrentDirectoryW = Win32API.new('kernel32', 'GetCurrentDirectoryW', 'LP', 'L')
12
14
  ReadDirectoryChangesW = Win32API.new('kernel32', 'ReadDirectoryChangesW', 'LPLILPPP', 'I')
13
15
  RemoveDirectory = Win32API.new('kernel32', 'RemoveDirectory', 'P', 'I')
14
16
  RemoveDirectoryW = Win32API.new('kernel32', 'RemoveDirectoryW', 'P', 'I')
@@ -16,15 +18,21 @@ module Windows
16
18
  SetCurrentDirectoryW = Win32API.new('kernel32', 'SetCurrentDirectoryW', 'P', 'I')
17
19
 
18
20
  def CreateDirectory(path, attributes = 0)
19
- if $KCODE != 'NONE'
20
- CreateDirectoryW.call(path, attributes) != 0
21
- else
22
- CreateDirectory.call(path, attributes) != 0
23
- end
21
+ CreateDirectory.call(path, attributes) != 0
22
+ end
23
+
24
+ def CreateDirectoryW(path, attributes)
25
+ path = multi_to_wide(path) unless IsTextUnicode(path)
26
+ CreateDirectoryW.call(path, attributes) != 0
24
27
  end
25
28
 
26
- def CreateDirectoryEx(template, new, attributes)
27
- CreateDirectoryEx.call(template, new, attributes) != 0
29
+ def CreateDirectoryEx(template, new_dir, attributes)
30
+ CreateDirectoryEx.call(template, new_dir, attributes) != 0
31
+ end
32
+
33
+ def CreateDirectoryExW(template, new_dir, attributes)
34
+ new_dir = multi_to_wide(new_dir) unless IsTextUnicode(new_dir)
35
+ CreateDirectoryExW.call(template, new_dir, attributes) != 0
28
36
  end
29
37
 
30
38
  def FindCloseChangeNotification(handle)
@@ -42,25 +50,31 @@ module Windows
42
50
  def GetCurrentDirectory(buf_len, buf)
43
51
  GetCurrentDirectory.call(buf_len, buf)
44
52
  end
53
+
54
+ def GetCurrentDirectoryW(buf_len, buf)
55
+ GetCurrentDirectoryW.call(buf_len, buf)
56
+ end
45
57
 
46
58
  def ReadDirectoryChangesW(handle, buf, buf_len, subtree, filter, bytes, overlapped, routine)
47
59
  ReadDirectoryChangesW.call(handle, buf, buf_len, subtree, filter, bytes, overlapped, routine) != 0
48
60
  end
49
61
 
50
62
  def RemoveDirectory(path)
51
- if $KCODE != 'NONE'
52
- RemoveDirectoryW.call(path) != 0
53
- else
54
- RemoveDirectory.call(path) != 0
55
- end
63
+ RemoveDirectory.call(path) != 0
64
+ end
65
+
66
+ def RemoveDirectoryW(path)
67
+ path = multi_to_wide(path) unless IsTextUnicode(path)
68
+ RemoveDirectoryW.call(path) != 0
56
69
  end
57
70
 
58
71
  def SetCurrentDirectory(path)
59
- if $KCODE != 'NONE'
60
- SetCurrentDirectoryW.call(path) != 0
61
- else
62
- SetCurrentDirectory.call(path) != 0
63
- end
72
+ SetCurrentDirectory.call(path) != 0
73
+ end
74
+
75
+ def SetCurrentDirectoryW(path)
76
+ path = multi_to_wide(path) unless IsTextUnicode(path)
77
+ SetCurrentDirectoryW.call(path) != 0
64
78
  end
65
79
  end
66
80
  end
@@ -196,6 +196,7 @@ module Windows
196
196
  ERROR_BAD_DYNALINK = 213 #@@ PTM 5760
197
197
  ERROR_TOO_MANY_MODULES = 214
198
198
  ERROR_NESTING_NOT_ALLOWED = 215
199
+ ERROR_MORE_DATA = 234
199
200
 
200
201
  ERROR_USER_DEFINED_BASE = 0xF000
201
202
 
@@ -295,18 +296,17 @@ module Windows
295
296
  FormatMessage.call(flags, src, msg_id, lang_id, buf, size, args)
296
297
  end
297
298
 
299
+ def FormatMessageW(flags, src, msg_id, lang_id, buf, size, args)
300
+ FormatMessageW.call(flags, src, msg_id, lang_id, buf, size, args)
301
+ end
302
+
298
303
  # Convenience method that wraps FormatMessage with some sane defaults and
299
304
  # returns a human readable string.
300
305
  #
301
306
  def get_last_error(err_num = GetLastError.call)
302
307
  buf = 0.chr * 260
303
- flags = FORMAT_MESSAGE_FROM_SYSTEM + FORMAT_MESSAGE_ARGUMENT_ARRAY
304
-
305
- if $KCODE != 'NONE'
306
- FormatMessageW.call(flags, 0, err_num, 0, buf, buf.length, 0)
307
- else
308
- FormatMessage.call(flags, 0, err_num, 0, buf, buf.length, 0)
309
- end
308
+ flags = FORMAT_MESSAGE_FROM_SYSTEM + FORMAT_MESSAGE_ARGUMENT_ARRAY
309
+ FormatMessage.call(flags, 0, err_num, 0, buf, buf.size, 0)
310
310
  buf.split(0.chr).first.chomp
311
311
  end
312
312
  end
@@ -137,6 +137,40 @@ module Windows
137
137
  OPEN_EXISTING = 3
138
138
  OPEN_ALWAYS = 4
139
139
  TRUNCATE_EXISTING = 5
140
+
141
+ # Page file access
142
+ PAGE_NOACCESS = 0x01
143
+ PAGE_READONLY = 0x02
144
+ PAGE_READWRITE = 0x04
145
+ PAGE_WRITECOPY = 0x08
146
+ PAGE_EXECUTE = 0x10
147
+ PAGE_EXECUTE_READ = 0x20
148
+ PAGE_EXECUTE_READWRITE = 0x40
149
+ PAGE_EXECUTE_WRITECOPY = 0x80
150
+ PAGE_GUARD = 0x100
151
+ PAGE_NOCACHE = 0x200
152
+ PAGE_WRITECOMBINE = 0x400
153
+ SEC_FILE = 0x800000
154
+ SEC_IMAGE = 0x1000000
155
+ SEC_VLM = 0x2000000
156
+ SEC_RESERVE = 0x4000000
157
+ SEC_COMMIT = 0x8000000
158
+ SEC_NOCACHE = 0x10000000
159
+
160
+ SECTION_QUERY = 0x0001
161
+ SECTION_MAP_WRITE = 0x0002
162
+ SECTION_MAP_READ = 0x0004
163
+ SECTION_MAP_EXECUTE = 0x0008
164
+ SECTION_EXTEND_SIZE = 0x0010
165
+
166
+ SECTION_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED | SECTION_QUERY |
167
+ SECTION_MAP_WRITE | SECTION_MAP_READ | SECTION_MAP_EXECUTE |
168
+ SECTION_EXTEND_SIZE
169
+
170
+ FILE_MAP_COPY = SECTION_QUERY
171
+ FILE_MAP_WRITE = SECTION_MAP_WRITE
172
+ FILE_MAP_READ = SECTION_MAP_READ
173
+ FILE_MAP_ALL_ACCESS = SECTION_ALL_ACCESS
140
174
 
141
175
  # Errors
142
176
  INVALID_FILE_ATTRIBUTES = -1
@@ -147,10 +181,15 @@ module Windows
147
181
  CopyFileEx = Win32API.new('kernel32', 'CopyFileEx', 'PPPPPL', 'I')
148
182
  CreateFile = Win32API.new('kernel32', 'CreateFile', 'PLLPLLL', 'L')
149
183
  CreateFileW = Win32API.new('kernel32', 'CreateFileW', 'PLLPLLL', 'L')
184
+
185
+ CreateFileMapping = Win32API.new('kernel32', 'CreateFileMapping', 'LPLLLP', 'L')
186
+
150
187
  CreateHardLink = Win32API.new('kernel32', 'CreateHardLink', 'PPP', 'I')
151
188
  DecryptFile = Win32API.new('advapi32', 'DecryptFile', 'PL', 'I')
152
189
  DeleteFile = Win32API.new('kernel32', 'DeleteFile', 'P', 'I')
153
190
  EncryptFile = Win32API.new('advapi32', 'EncryptFile', 'P', 'I')
191
+
192
+ FlushViewOfFile = Win32API.new('kernel32', 'FlushViewOfFile', 'PL', 'I')
154
193
 
155
194
  GetBinaryType = Win32API.new('kernel32', 'GetBinaryType', 'PP', 'I')
156
195
  GetFileAttributes = Win32API.new('kernel32', 'GetFileAttributes', 'P', 'L')
@@ -165,6 +204,11 @@ module Windows
165
204
 
166
205
  LockFile = Win32API.new('kernel32', 'LockFile', 'LLLLL', 'I')
167
206
  LockFileEx = Win32API.new('kernel32', 'LockFileEx', 'LLLLLL', 'I')
207
+
208
+ MapViewOfFile = Win32API.new('kernel32', 'MapViewOfFile', 'LLLLL', 'L')
209
+ MapViewOfFileEx = Win32API.new('kernel32', 'MapViewOfFileEx', 'LLLLLP', 'L')
210
+ OpenFileMapping = Win32API.new('kernel32', 'OpenFileMapping', 'LIP', 'L')
211
+
168
212
  ReadFile = Win32API.new('kernel32', 'ReadFile', 'LPLPP', 'I')
169
213
  ReadFileEx = Win32API.new('kernel32', 'ReadFileEx', 'LPLPP', 'I')
170
214
 
@@ -172,6 +216,9 @@ module Windows
172
216
 
173
217
  UnlockFile = Win32API.new('kernel32', 'UnlockFile', 'LLLLL', 'I')
174
218
  UnlockFileEx = Win32API.new('kernel32', 'UnlockFileEx', 'LLLLL', 'I')
219
+
220
+ UnmapViewOfFile = Win32API.new('kernel32', 'UnmapViewOfFile', 'P', 'I')
221
+
175
222
  WriteFile = Win32API.new('kernel32', 'WriteFile', 'LPLPP', 'I')
176
223
  WriteFileEx = Win32API.new('kernel32', 'WriteFileEx', 'LPLPP', 'I')
177
224
 
@@ -184,11 +231,11 @@ module Windows
184
231
  end
185
232
 
186
233
  def CreateFile(file, access, share, sec, disp, flags, template)
187
- if $KCODE != 'NONE'
188
- CreateFileW.call(file, access, share, sec, disp, flags, template)
189
- else
190
- CreateFile.call(file, access, share, sec, disp, flags, template)
191
- end
234
+ CreateFile.call(file, access, share, sec, disp, flags, template)
235
+ end
236
+
237
+ def CreateFileMapping(handle, security, protect, high, low, name)
238
+ CreateFileMapping.call(handle, security, protect, high, low, name)
192
239
  end
193
240
 
194
241
  def CreateHardLink(new_file, old_file, attributes)
@@ -206,6 +253,10 @@ module Windows
206
253
  def EncryptFile(file)
207
254
  EncryptFile.call(file) > 0
208
255
  end
256
+
257
+ def FlushViewOfFile(address, bytes)
258
+ FlushViewOfFile.call(address, bytes) != 0
259
+ end
209
260
 
210
261
  def GetBinaryType(file, type)
211
262
  GetBinaryType.call(file, type) > 0
@@ -232,11 +283,7 @@ module Windows
232
283
  end
233
284
 
234
285
  def GetFullPathName(file, buf, buf_size, part)
235
- if $KCODE != 'NONE'
236
- GetFullPathNameW.call(file, buf, buf_size, part)
237
- else
238
- GetFullPathName.call(file, buf, buf_size, part)
239
- end
286
+ GetFullPathName.call(file, buf, buf_size, part)
240
287
  end
241
288
 
242
289
  def GetLongPathName(short, buf, buf_size)
@@ -255,6 +302,18 @@ module Windows
255
302
  LockFileEx.call(handle, flags, res, low, high, overlapped) > 0
256
303
  end
257
304
 
305
+ def MapViewOfFile(handle, access, high, low, bytes)
306
+ MapViewOfFile.call(handle, access, high, low, bytes)
307
+ end
308
+
309
+ def MapViewOfFileEx(handle, access, high, low, bytes, address)
310
+ MapViewOfFile.call(handle, access, high, low, bytes, address)
311
+ end
312
+
313
+ def OpenFileMapping(access, inherit, name)
314
+ OpenFileMapping.call(access, inherit, name)
315
+ end
316
+
258
317
  def ReadFile(file, buf, bytes, bytes_read, overlapped)
259
318
  ReadFile.call(file, buf, bytes, bytes_read, overlapped) > 0
260
319
  end
@@ -275,6 +334,10 @@ module Windows
275
334
  UnlockFileEx.call(handle, res, low, high, overlapped) > 0
276
335
  end
277
336
 
337
+ def UnmapViewOfFile(address)
338
+ UnmapViewOfFile.call(address) != 0
339
+ end
340
+
278
341
  def WriteFile(handle, buf, bytes, overlapped)
279
342
  WriteFileEx.call(handle, buf, bytes, overlapped) > 0
280
343
  end
@@ -1,19 +1,3 @@
1
- #####################################################################
2
- # handle.rb
3
- #
4
- # Defines the following functions:
5
- #
6
- # CloseHandle()
7
- # DuplicateHandle()
8
- # GetHandleInformation()
9
- # SetHandleInformation()
10
- #
11
- # Defines the following constants
12
- #
13
- # INVALID_HANDLE_VALUE
14
- # HANDLE_FLAG_INHERIT
15
- # HANDLE_FLAG_PROTECT_FROM_CLOSE
16
- ######################################################################
17
1
  require 'Win32API'
18
2
 
19
3
  module Windows
@@ -14,10 +14,21 @@ module Windows
14
14
  GlobalHandle = Win32API.new('kernel32', 'GlobalHandle', 'P', 'I')
15
15
  GlobalLock = Win32API.new('kernel32', 'GlobalLock', 'L', 'L')
16
16
  GlobalMemoryStatus = Win32API.new('kernel32', 'GlobalMemoryStatus', 'P', 'V')
17
- GlobalMemoryStatusEx = Win32API.new('kernel32', 'GlobalMemoryStatus', 'P', 'V')
17
+ GlobalMemoryStatusEx = Win32API.new('kernel32', 'GlobalMemoryStatusEx', 'P', 'V')
18
18
  GlobalReAlloc = Win32API.new('kernel32', 'GlobalReAlloc', 'III', 'I')
19
19
  GlobalSize = Win32API.new('kernel32', 'GlobalSize', 'I', 'I')
20
20
  GlobalUnlock = Win32API.new('kernel32', 'GlobalUnlock', 'I', 'I')
21
+ VirtualAlloc = Win32API.new('kernel32', 'VirtualAlloc', 'PLLL', 'P')
22
+ VirtualAllocEx = Win32API.new('kernel32', 'VirtualAllocEx', 'LPLLL', 'P')
23
+ VirtualFree = Win32API.new('kernel32', 'VirtualFree', 'PLL', 'I')
24
+ VirtualFreeEx = Win32API.new('kernel32', 'VirtualFreeEx', 'LPLL', 'I')
25
+ VirtualLock = Win32API.new('kernel32', 'VirtualLock', 'PL', 'I')
26
+ VirtualProtect = Win32API.new('kernel32', 'VirtualProtect', 'PLLP', 'I')
27
+ VirtualProtectEx = Win32API.new('kernel32', 'VirtualProtectEx', 'LPLLP', 'I')
28
+ VirtualQuery = Win32API.new('kernel32', 'VirtualQuery', 'PPL', 'L')
29
+ VirtualQueryEx = Win32API.new('kernel32', 'VirtualQueryEx', 'LPPL', 'L')
30
+ VirtualUnlock = Win32API.new('kernel32', 'VirtualUnlock', 'PL', 'I')
31
+ ZeroMemory = Win32API.new('kernel32', 'RtlZeroMemory', 'PL', 'I')
21
32
 
22
33
  def GlobalAlloc(flags, bytes)
23
34
  GlobalAlloc.call(flags, bytes)
@@ -36,7 +47,7 @@ module Windows
36
47
  end
37
48
 
38
49
  def GlobalLock(handle)
39
- GlobalHandle.call(handle)
50
+ GlobalLock.call(handle)
40
51
  end
41
52
 
42
53
  def GlobalMemoryStatus(buf)
@@ -58,5 +69,49 @@ module Windows
58
69
  def GlobalUnlock(handle)
59
70
  GlobalUnlock.call(handle)
60
71
  end
72
+
73
+ def VirtualAlloc(address, size, alloc_type, protect)
74
+ VirtualAlloc.call(address, size, alloc_type, protect)
75
+ end
76
+
77
+ def VirtualAllocEx(handle, address, size, alloc_type, protect)
78
+ VirtualAllocEx.call(handle, address, size, alloc_type, protect)
79
+ end
80
+
81
+ def VirtualFree(address, size, free_type)
82
+ VirtualFree.call(address, size, free_type) != 0
83
+ end
84
+
85
+ def VirtualFreeEx(handle, address, size, free_type)
86
+ VirtualFreeEx.call(handle, address, size, free_type) != 0
87
+ end
88
+
89
+ def VirtualLock(address, size)
90
+ VirtualLock.call(address, size) != 0
91
+ end
92
+
93
+ def VirtualProtect(address, size, new_protect, old_protect)
94
+ VirtualProtect.call(address, size, new_protect, old_protect) != 0
95
+ end
96
+
97
+ def VirtualProtectEx(handle, address, size, new_protect, old_protect)
98
+ VirtualProtect.call(handle, address, size, new_protect, old_protect) != 0
99
+ end
100
+
101
+ def VirtualQuery(address, buffer, length)
102
+ VirtualQuery.call(address, buffer, length)
103
+ end
104
+
105
+ def VirtualQueryEx(handle, address, buffer, length)
106
+ VirtualQueryEx.call(handle, address, buffer, length)
107
+ end
108
+
109
+ def VirtualUnlock(address, size)
110
+ VirtualUnlock.call(address, size) != 0
111
+ end
112
+
113
+ def ZeroMemory(dest, length)
114
+ ZeroMemory.call(dest, length)
115
+ end
61
116
  end
62
117
  end
@@ -0,0 +1,46 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module MSVCRT
5
+ module String
6
+ Strcpy = Win32API.new('msvcrt', 'strcpy', 'PL', 'l')
7
+ Strrev = Win32API.new('msvcrt', '_strrev', 'P', 'P')
8
+
9
+ Mbscpy = Win32API.new('msvcrt', '_mbscpy', 'PL', 'L')
10
+ Mbsrev = Win32API.new('msvcrt', '_mbsrev', 'P', 'P')
11
+
12
+ Wcscpy = Win32API.new('msvcrt', 'wcscpy', 'PL', 'l')
13
+ Wcsrev = Win32API.new('msvcrt', '_wcsrev', 'P', 'P')
14
+
15
+ def strcpy(dest, src)
16
+ return nil if src == 0
17
+ Strcpy.call(dest, src)
18
+ end
19
+
20
+ def strrev(str)
21
+ return nil if str == 0
22
+ Strrev.call(str)
23
+ end
24
+
25
+ def mbscpy(dest, src)
26
+ return nil if src == 0
27
+ Mbscpy.call(dest, src)
28
+ end
29
+
30
+ def mbsrev(str)
31
+ return nil if str == 0
32
+ Mbsrev.call(str)
33
+ end
34
+
35
+ def wcscpy(dest, src)
36
+ return nil if src == 0
37
+ Wcscpy.call(dest, src)
38
+ end
39
+
40
+ def wcsrev(str)
41
+ return nil if str == 0
42
+ Wcsrev.call(str)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -519,10 +519,10 @@ module Windows
519
519
  SORT_GEORGIAN_TRADITIONAL = 0x0 # Georgian Traditional order
520
520
  SORT_GEORGIAN_MODERN = 0x1 # Georgian Modern order
521
521
 
522
- LANG_SYSTEM_DEFAULT = 2
523
- LANG_USER_DEFAULT = 1
524
- LOCALE_SYSTEM_DEFAULT = 131072
525
- LOCALE_USER_DEFAULT = 65536
522
+ LANG_SYSTEM_DEFAULT = 2048
523
+ LANG_USER_DEFAULT = 1024
524
+ LOCALE_SYSTEM_DEFAULT = 2048
525
+ LOCALE_USER_DEFAULT = 1024
526
526
 
527
527
  GetACP = Win32API.new('kernel32', 'GetACP', 'V', 'I')
528
528
  GetDateFormat = Win32API.new('kernel32', 'GetDateFormat', 'LLPPPI', 'I')
@@ -0,0 +1,77 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module Pipe
5
+ NMPWAIT_NOWAIT = 0x00000001
6
+ NMPWAIT_WAIT_FOREVER = 0xffffffff
7
+ NMPWAIT_USE_DEFAULT_WAIT = 0x00000000
8
+
9
+ PIPE_WAIT = 0x00000000
10
+ PIPE_NOWAIT = 0x00000001
11
+ PIPE_ACCESS_INBOUND = 0x00000001
12
+ PIPE_ACCESS_OUTBOUND = 0x00000002
13
+ PIPE_ACCESS_DUPLEX = 0x00000003
14
+ PIPE_TYPE_BYTE = 0x00000000
15
+ PIPE_TYPE_MESSAGE = 0x00000004
16
+ PIPE_READMODE_BYTE = 0x00000000
17
+ PIPE_READMODE_MESSAGE = 0x00000002
18
+ PIPE_CLIENT_END = 0x00000000
19
+ PIPE_SERVER_END = 0x00000001
20
+
21
+ CallNamedPipe = Win32API.new('kernel32', 'CallNamedPipe', 'PPLPLPL', 'I')
22
+ ConnectNamedPipe = Win32API.new('kernel32', 'ConnectNamedPipe', 'LP', 'I')
23
+ CreateNamedPipe = Win32API.new('kernel32', 'CreateNamedPipe', 'PLLLLLLL', 'L')
24
+ CreatePipe = Win32API.new('kernel32', 'CreatePipe', 'PPPL', 'I')
25
+ DisconnectNamedPipe = Win32API.new('kernel32', 'DisconnectNamedPipe', 'L', 'I')
26
+ GetNamedPipeHandleState = Win32API.new('kernel32', 'GetNamedPipeHandleState', 'LPPPPPL', 'I')
27
+ GetNamedPipeInfo = Win32API.new('kernel32', 'GetNamedPipeInfo', 'LPPPP', 'I')
28
+ PeekNamedPipe = Win32API.new('kernel32', 'PeekNamedPipe', 'LPLPPP', 'I')
29
+ SetNamedPipeHandleState = Win32API.new('kernel32', 'SetNamedPipeHandleState', 'LPPP', 'I')
30
+ TransactNamedPipe = Win32API.new('kernel32', 'TransactNamedPipe', 'LPLPLPP', 'I')
31
+ WaitNamedPipe = Win32API.new('kernel32', 'WaitNamedPipe', 'PL', 'I')
32
+
33
+ def CallNamedPipe(name, buf, buf_size, out, out_size, read, timeout)
34
+ CallNamedPipe.call(name, buf, buf_size, out, out_size, read, timeout) != 0
35
+ end
36
+
37
+ def ConnectNamedPipe(pipe, overlapped = 0)
38
+ ConnectNamedPipe.call(pipe, overlapped) != 0
39
+ end
40
+
41
+ def CreateNamedPipe(name, open_mode, pipe_mode, max, out_size, in_size, timeout, sec_attr)
42
+ CreateNamedPipe.call(name, open_mode, pipe_mode, max, out_size, in_size, timeout, sec_attr)
43
+ end
44
+
45
+ def CreatePipe(read_pipe, write_pipe, pipe_attr, size)
46
+ CreatePipe.call(read_pipe, write_pipe, pipe_attr, size) != 0
47
+ end
48
+
49
+ def DisconnectNamedPipe(name)
50
+ DisconnectNamedPipe.call(name) != 0
51
+ end
52
+
53
+ def GetNamedPipeHandleState(name, state, instances, count, timeout, user, size)
54
+ GetNamedPipeHandleState.call(name, state, instances, count, timeout, user, size) != 0
55
+ end
56
+
57
+ def GetNamedPipeInfo(name, flags, out_size, in_size, max)
58
+ GetNamedPipeInfo.call(name, flags, out_size, in_size, max) != 0
59
+ end
60
+
61
+ def PeekNamedPipe(name, buf, buf_size, bytes_read, bytes_avail, bytes_left)
62
+ PeekNamedPipe.call(name, buf, buf_size, bytes_read, bytes_avail, bytes_left) != 0
63
+ end
64
+
65
+ def SetNamedPipeHandleState(name, mode, max, timeout)
66
+ SetNamedPipeHandleState.call(name, mode, max, timeout) != 0
67
+ end
68
+
69
+ def TransactNamedPipe(name, in_buf, in_buf_size, out_buf, out_buf_size, read, overlapped)
70
+ TransactNamedPipe.call(name, in_buf, in_buf_size, out_buf, out_buf_size, read, overlapped) != 0
71
+ end
72
+
73
+ def WaitNamedPipe(name, timeout)
74
+ WaitNamedPipe.call(name, timeout) != 0
75
+ end
76
+ end
77
+ end
@@ -51,19 +51,17 @@ module Windows
51
51
  STARTF_USESTDHANDLES = 0x00000100
52
52
  STARTF_USEHOTKEY = 0x00000200
53
53
 
54
- CreateProcess = Win32API.new('kernel32', 'CreateProcess', 'LPLLLLLLPP', 'I')
54
+ CreateProcess = Win32API.new('kernel32', 'CreateProcess', 'LPLLLLLPPP', 'I')
55
55
  CreateRemoteThread = Win32API.new('kernel32', 'CreateRemoteThread', 'LPLLPLP', 'L')
56
56
  CreateThread = Win32API.new('kernel32', 'CreateThread', 'PLPPLP', 'L')
57
57
  ExitProcess = Win32API.new('kernel32', 'ExitProcess', 'L', 'V')
58
58
  GetCommandLine = Win32API.new('kernel32', 'GetCommandLine', 'V', 'P')
59
- GetCurrentProcess = Win32API.new('kernel32', 'GetCurrentProcess', 'V', 'L')
59
+ GetCurrentProcess = Win32API.new('kernel32', 'GetCurrentProcess', 'V', 'L')
60
60
  GetCurrentProcessId = Win32API.new('kernel32', 'GetCurrentProcessId', 'V', 'L')
61
61
  GetEnvironmentStrings = Win32API.new('kernel32', 'GetEnvironmentStrings', 'V', 'L')
62
62
  GetEnvironmentVariable = Win32API.new('kernel32', 'GetEnvironmentVariable', 'PPL', 'L')
63
63
  GetExitCodeProcess = Win32API.new('kernel32', 'GetExitCodeProcess', 'LP', 'I')
64
64
  GetPriorityClass = Win32API.new('kernel32', 'GetPriorityClass', 'L', 'L')
65
- GetProcessHandleCount = Win32API.new('kernel32', 'GetProcessHandleCount', 'LP', 'I')
66
- GetProcessId = Win32API.new('kernel32', 'GetProcessId', 'L', 'L')
67
65
  GetProcessTimes = Win32API.new('kernel32', 'GetProcessTimes', 'LPPPP', 'I')
68
66
  GetStartupInfo = Win32API.new('kernel32', 'GetStartupInfo', 'P', 'V')
69
67
  OpenProcess = Win32API.new('kernel32', 'OpenProcess', 'LIL', 'L')
@@ -72,6 +70,15 @@ module Windows
72
70
  SleepEx = Win32API.new('kernel32', 'SleepEx', 'LI', 'L')
73
71
  TerminateProcess = Win32API.new('kernel32', 'TerminateProcess', 'LL', 'I')
74
72
  WaitForInputIdle = Win32API.new('user32', 'WaitForInputIdle', 'LL', 'L')
73
+
74
+ # Windows XP or later
75
+ begin
76
+ GetProcessId = Win32API.new('kernel32', 'GetProcessId', 'L', 'L')
77
+ GetProcessHandleCount = Win32API.new('kernel32', 'GetProcessHandleCount', 'LP', 'I')
78
+ rescue Exception
79
+ # Do nothing - not supported on current platform. It's up to you to
80
+ # check for the existence of the constant in your code.
81
+ end
75
82
 
76
83
  def CreateProcess(app, cmd, pattr, tattr, handles, flags, env, dir, sinfo, pinfo)
77
84
  CreateProcess.call(app, cmd, pattr, tattr, handles, flags, env, dir, sinfo, pinfo) != 0
@@ -117,14 +124,6 @@ module Windows
117
124
  GetPriorityClass.call(handle)
118
125
  end
119
126
 
120
- def GetProcessHandleCount(handle, count)
121
- GetProcessHandleCount.call(handle, count) != 0
122
- end
123
-
124
- def GetProcessId(handle)
125
- GetProcessId.call(handle)
126
- end
127
-
128
127
  def GetProcessTimes(handle, t_creation, t_exit, t_kernel, t_user)
129
128
  GetProcessTimes.call(handle, t_creation, t_exit, t_kernel, t_user) != 0
130
129
  end
@@ -156,5 +155,17 @@ module Windows
156
155
  def WaitForInputIdle(handle, milliseconds)
157
156
  WaitForInputIdle.call(handle, milliseconds)
158
157
  end
158
+
159
+ begin
160
+ def GetProcessId(handle)
161
+ GetProcessId.call(handle)
162
+ end
163
+
164
+ def GetProcessHandleCount(handle, count)
165
+ GetProcessHandleCount.call(handle, count) != 0
166
+ end
167
+ rescue Exception
168
+ # Windows XP or later
169
+ end
159
170
  end
160
- end
171
+ end
@@ -0,0 +1,183 @@
1
+ require 'Win32API'
2
+
3
+ module Windows
4
+ module Service
5
+ # SCM access rights
6
+ SC_MANAGER_ALL_ACCESS = 0xF003F
7
+ SC_MANAGER_CREATE_SERVICE = 0x0002
8
+ SC_MANAGER_CONNECT = 0x0001
9
+ SC_MANAGER_ENUMERATE_SERVICE = 0x0004
10
+ SC_MANAGER_LOCK = 0x0008
11
+ SC_MANAGER_MODIFY_BOOT_CONFIG = 0x0020
12
+ SC_MANAGER_QUERY_LOCK_STATUS = 0x0010
13
+ SC_STATUS_PROCESS_INFO = 0
14
+ SC_ENUM_PROCESS_INFO = 0
15
+
16
+ # Service control action types
17
+ SC_ACTION_NONE = 0
18
+ SC_ACTION_REBOOT = 1
19
+ SC_ACTION_RESTART = 2
20
+ SC_ACTION_RUN_COMMAND = 3
21
+
22
+ # Service access rights
23
+ SERVICE_ALL_ACCESS = 0xF01FF
24
+ SERVICE_CHANGE_CONFIG = 0x0002
25
+ SERVICE_ENUMERATE_DEPENDENTS = 0x0008
26
+ SERVICE_INTERROGATE = 0x0080
27
+ SERVICE_PAUSE_CONTINUE = 0x0040
28
+ SERVICE_QUERY_CONFIG = 0x0001
29
+ SERVICE_QUERY_STATUS = 0x0004
30
+ SERVICE_START = 0x0010
31
+ SERVICE_STOP = 0x0020
32
+ SERVICE_USER_DEFINED_CONTROL = 0x0100
33
+
34
+ # Service types
35
+ SERVICE_KERNEL_DRIVER = 0x00000001
36
+ SERVICE_FILE_SYSTEM_DRIVER = 0x00000002
37
+ SERVICE_ADAPTER = 0x00000004
38
+ SERVICE_RECOGNIZER_DRIVER = 0x00000008
39
+ SERVICE_WIN32_OWN_PROCESS = 0x00000010
40
+ SERVICE_WIN32_SHARE_PROCESS = 0x00000020
41
+ SERVICE_WIN32 = 0x00000030
42
+ SERVICE_INTERACTIVE_PROCESS = 0x00000100
43
+ SERVICE_DRIVER = 0x0000000B
44
+ SERVICE_TYPE_ALL = 0x0000013F
45
+
46
+ # Error control
47
+ SERVICE_ERROR_IGNORE = 0x00000000
48
+ SERVICE_ERROR_NORMAL = 0x00000001
49
+ SERVICE_ERROR_SEVERE = 0x00000002
50
+ SERVICE_ERROR_CRITICAL = 0x00000003
51
+
52
+ # Start types
53
+ SERVICE_BOOT_START = 0x00000000
54
+ SERVICE_SYSTEM_START = 0x00000001
55
+ SERVICE_AUTO_START = 0x00000002
56
+ SERVICE_DEMAND_START = 0x00000003
57
+ SERVICE_DISABLED = 0x00000004
58
+
59
+ # Service control
60
+ SERVICE_CONTROL_STOP = 0x00000001
61
+ SERVICE_CONTROL_PAUSE = 0x00000002
62
+ SERVICE_CONTROL_CONTINUE = 0x00000003
63
+ SERVICE_CONTROL_INTERROGATE = 0x00000004
64
+ SERVICE_CONTROL_PARAMCHANGE = 0x00000006
65
+ SERVICE_CONTROL_NETBINDADD = 0x00000007
66
+ SERVICE_CONTROL_NETBINDREMOVE = 0x00000008
67
+ SERVICE_CONTROL_NETBINDENABLE = 0x00000009
68
+ SERVICE_CONTROL_NETBINDDISABLE = 0x0000000A
69
+
70
+ # Service controls accepted
71
+ SERVICE_ACCEPT_STOP = 0x00000001
72
+ SERVICE_ACCEPT_PAUSE_CONTINUE = 0x00000002
73
+ SERVICE_ACCEPT_SHUTDOWN = 0x00000004
74
+ SERVICE_ACCEPT_PARAMCHANGE = 0x00000008
75
+ SERVICE_ACCEPT_NETBINDCHANGE = 0x00000010
76
+ SERVICE_ACCEPT_HARDWAREPROFILECHANGE = 0x00000020
77
+ SERVICE_ACCEPT_POWEREVENT = 0x00000040
78
+ SERVICE_ACCEPT_SESSIONCHANGE = 0x00000080
79
+
80
+ # Service states
81
+ SERVICE_ACTIVE = 0x00000001
82
+ SERVICE_INACTIVE = 0x00000002
83
+ SERVICE_STATE_ALL = 0x00000003
84
+
85
+ # Service current states
86
+ SERVICE_STOPPED = 0x00000001
87
+ SERVICE_START_PENDING = 0x00000002
88
+ SERVICE_STOP_PENDING = 0x00000003
89
+ SERVICE_RUNNING = 0x00000004
90
+ SERVICE_CONTINUE_PENDING = 0x00000005
91
+ SERVICE_PAUSE_PENDING = 0x00000006
92
+ SERVICE_PAUSED = 0x00000007
93
+
94
+ # Info levels
95
+ SERVICE_CONFIG_DESCRIPTION = 1
96
+ SERVICE_CONFIG_FAILURE_ACTIONS = 2
97
+ SERVICE_CONFIG_DELAYED_AUTO_START_INFO = 3
98
+ SERVICE_CONFIG_FAILURE_ACTIONS_FLAG = 4
99
+ SERVICE_CONFIG_SERVICE_SID_INFO = 5
100
+ SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO = 6
101
+ SERVICE_CONFIG_PRESHUTDOWN_INFO = 7
102
+
103
+ ChangeServiceConfig = Win32API.new('advapi32', 'ChangeServiceConfig', 'LLLLPPPPPPP', 'I')
104
+ ChangeServiceConfig2 = Win32API.new('advapi32', 'ChangeServiceConfig2', 'LLP', 'I')
105
+ CloseServiceHandle = Win32API.new('advapi32', 'CloseServiceHandle', 'L', 'I')
106
+ ControlService = Win32API.new('advapi32', 'ControlService', 'LLP', 'I')
107
+ CreateService = Win32API.new('advapi32', 'CreateService', 'LPPLLLLPPPPPP', 'L')
108
+ DeleteService = Win32API.new('advapi32', 'DeleteService', 'L', 'I')
109
+ EnumDependentServices = Win32API.new('advapi32', 'EnumDependentServices', 'LLPLPP', 'I')
110
+ EnumServicesStatus = Win32API.new('advapi32', 'EnumServicesStatus', 'LLLPLPPP', 'I')
111
+ EnumServicesStatusEx = Win32API.new('advapi32', 'EnumServicesStatusEx', 'LLLLPLPPPP', 'I')
112
+ GetServiceDisplayName = Win32API.new('advapi32', 'GetServiceDisplayName', 'LPPP', 'I')
113
+ GetServiceKeyName = Win32API.new('advapi32', 'GetServiceKeyName', 'LPPP', 'I')
114
+ LockServiceDatabase = Win32API.new('advapi32', 'LockServiceDatabase', 'L', 'L')
115
+ NotifyBootConfigStatus = Win32API.new('advapi32', 'NotifyBootConfigStatus', 'I', 'I')
116
+ OpenSCManager = Win32API.new('advapi32', 'OpenSCManager', 'PPL', 'L')
117
+ OpenService = Win32API.new('advapi32', 'OpenService', 'LPL', 'L')
118
+ QueryServiceConfig = Win32API.new('advapi32', 'QueryServiceConfig', 'LPLP', 'I')
119
+ QueryServiceConfig2 = Win32API.new('advapi32', 'QueryServiceConfig2', 'LLPLP', 'I')
120
+ QueryServiceLockStatus = Win32API.new('advapi32', 'QueryServiceLockStatus', 'LPLP', 'I')
121
+ QueryServiceStatus = Win32API.new('advapi32', 'QueryServiceStatus', 'LP', 'I')
122
+ QueryServiceStatusEx = Win32API.new('advapi32', 'QueryServiceStatusEx', 'LLPLP', 'I')
123
+ RegisterServiceCtrlHandler = Win32API.new('advapi32', 'RegisterServiceCtrlHandler', 'PP', 'L')
124
+ RegisterServiceCtrlHandlerEx = Win32API.new('advapi32', 'RegisterServiceCtrlHandlerEx', 'PPP', 'L')
125
+ SetServiceBits = Win32API.new('advapi32', 'SetServiceBits', 'LLII', 'I')
126
+ SetServiceStatus = Win32API.new('advapi32', 'SetServiceStatus', 'LP', 'I')
127
+ StartService = Win32API.new('advapi32', 'StartService', 'LLP', 'I')
128
+ StartServiceCtrlDispatcher = Win32API.new('advapi32', 'StartServiceCtrlDispatcher', 'P', 'I')
129
+ UnlockServiceDatabase = Win32API.new('advapi32', 'UnlockServiceDatabase', 'L', 'I')
130
+
131
+ def CloseServiceHandle(handle)
132
+ CloseServiceHandle.call(handle) != 0
133
+ end
134
+
135
+ def ControlService(service, control, status)
136
+ ControlService.call(service, control, status) != 0
137
+ end
138
+
139
+ def DeleteService(handle)
140
+ DeleteService.call(handle) != 0
141
+ end
142
+
143
+ def EnumServicesStatusEx(handle, info, s_type, s_state, services, size, bytes, s_returned, rhandle, grp)
144
+ EnumServicesStatusEx.call(handle, info, s_type, s_state, services, size, bytes, s_returned, rhandle, grp) != 0
145
+ end
146
+
147
+ def GetServiceDisplayName(handle, service, display, buf)
148
+ GetServiceDisplayName.call(handle, service, display, buf) != 0
149
+ end
150
+
151
+ def GetServiceKeyName(handle, display, service, buf)
152
+ GetServiceKeyName.call(handle, display, service, buf) != 0
153
+ end
154
+
155
+ def OpenSCManager(host, database, access)
156
+ OpenSCManager.call(host, database, access)
157
+ end
158
+
159
+ def OpenService(handle, service, access)
160
+ OpenService.call(handle, service, access)
161
+ end
162
+
163
+ def QueryServiceConfig(handle, buf, buf_size, bytes)
164
+ QueryServiceConfig.call(handle, buf, buf_size, bytes) != 0
165
+ end
166
+
167
+ def QueryServiceConfig2(handle, info, buf, buf_size, bytes)
168
+ QueryServiceConfig2.call(handle, info, buf, buf_size, bytes) != 0
169
+ end
170
+
171
+ def QueryServiceStatusEx(service, info, buf, size, bytes)
172
+ QueryServiceStatusEx.call(service, info, buf, size, bytes) != 0
173
+ end
174
+
175
+ def QueryStatusConfig2(service, info, buf, size, bytes)
176
+ QueryStatusConfig2.call(service, info, buf, size, bytes) != 0
177
+ end
178
+
179
+ def StartService(handle, num_vec, vec)
180
+ StartService.call(handle, num_vec, vec)
181
+ end
182
+ end
183
+ end
@@ -0,0 +1,75 @@
1
+ #####################################################################
2
+ # tc_file.rb
3
+ #
4
+ # Test case for the Windows::File module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require 'windows/file'
14
+ require 'test/unit'
15
+
16
+ class Foo
17
+ include Windows::File
18
+ end
19
+
20
+ class TC_Windows_File < Test::Unit::TestCase
21
+
22
+ def setup
23
+ @foo = Foo.new
24
+ end
25
+
26
+ def test_numeric_constants
27
+ assert_equal(0x00000001, Foo::FILE_ATTRIBUTE_READONLY)
28
+ assert_equal(0x00000002, Foo::FILE_ATTRIBUTE_HIDDEN)
29
+ assert_equal(0x00000004, Foo::FILE_ATTRIBUTE_SYSTEM)
30
+ assert_equal(0x00000010, Foo::FILE_ATTRIBUTE_DIRECTORY)
31
+ assert_equal(0x00000020, Foo::FILE_ATTRIBUTE_ARCHIVE)
32
+ assert_equal(0x00000040, Foo::FILE_ATTRIBUTE_ENCRYPTED)
33
+ assert_equal(0x00000080, Foo::FILE_ATTRIBUTE_NORMAL)
34
+ assert_equal(0x00000100, Foo::FILE_ATTRIBUTE_TEMPORARY)
35
+ assert_equal(0x00000200, Foo::FILE_ATTRIBUTE_SPARSE_FILE)
36
+ assert_equal(0x00000400, Foo::FILE_ATTRIBUTE_REPARSE_POINT)
37
+ assert_equal(0x00000800, Foo::FILE_ATTRIBUTE_COMPRESSED)
38
+ assert_equal(0x00001000, Foo::FILE_ATTRIBUTE_OFFLINE)
39
+ assert_equal(0x00002000, Foo::FILE_ATTRIBUTE_NOT_CONTENT_INDEXED)
40
+ end
41
+
42
+ def test_method_constants
43
+ assert_not_nil(Foo::CopyFile)
44
+ assert_not_nil(Foo::CopyFileEx)
45
+ assert_not_nil(Foo::CreateFile)
46
+ assert_not_nil(Foo::CreateFileW)
47
+ assert_not_nil(Foo::CreateHardLink)
48
+ assert_not_nil(Foo::DecryptFile)
49
+ assert_not_nil(Foo::DeleteFile)
50
+ assert_not_nil(Foo::EncryptFile)
51
+ assert_not_nil(Foo::GetBinaryType)
52
+ assert_not_nil(Foo::GetFileAttributes)
53
+ assert_not_nil(Foo::GetFileAttributesEx)
54
+ assert_not_nil(Foo::GetFileSize)
55
+ assert_not_nil(Foo::GetFileSizeEx)
56
+ assert_not_nil(Foo::GetFileType)
57
+ assert_not_nil(Foo::GetFullPathName)
58
+ assert_not_nil(Foo::GetFullPathNameW)
59
+ assert_not_nil(Foo::GetLongPathName)
60
+ assert_not_nil(Foo::GetShortPathName)
61
+ assert_not_nil(Foo::LockFile)
62
+ assert_not_nil(Foo::LockFileEx)
63
+ assert_not_nil(Foo::ReadFile)
64
+ assert_not_nil(Foo::ReadFileEx)
65
+ assert_not_nil(Foo::SetFileAttributes)
66
+ assert_not_nil(Foo::UnlockFile)
67
+ assert_not_nil(Foo::UnlockFileEx)
68
+ assert_not_nil(Foo::WriteFile)
69
+ assert_not_nil(Foo::WriteFileEx)
70
+ end
71
+
72
+ def teardown
73
+ @foo = nil
74
+ end
75
+ end
@@ -0,0 +1,60 @@
1
+ #####################################################################
2
+ # tc_pipe.rb
3
+ #
4
+ # Test case for the Windows::Pipe module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require 'windows/pipe'
14
+ require 'test/unit'
15
+
16
+ class Foo
17
+ include Windows::Pipe
18
+ end
19
+
20
+ class TC_Windows_Pipe < Test::Unit::TestCase
21
+
22
+ def setup
23
+ @foo = Foo.new
24
+ end
25
+
26
+ def test_numeric_constants
27
+ assert_equal(0x00000001, Foo::NMPWAIT_NOWAIT)
28
+ assert_equal(0xffffffff, Foo::NMPWAIT_WAIT_FOREVER)
29
+ assert_equal(0x00000000, Foo::NMPWAIT_USE_DEFAULT_WAIT)
30
+ assert_equal(0x00000000, Foo::PIPE_WAIT)
31
+ assert_equal(0x00000001, Foo::PIPE_NOWAIT)
32
+ assert_equal(0x00000001, Foo::PIPE_ACCESS_INBOUND)
33
+ assert_equal(0x00000002, Foo::PIPE_ACCESS_OUTBOUND)
34
+ assert_equal(0x00000003, Foo::PIPE_ACCESS_DUPLEX)
35
+ assert_equal(0x00000000, Foo::PIPE_TYPE_BYTE)
36
+ assert_equal(0x00000004, Foo::PIPE_TYPE_MESSAGE)
37
+ assert_equal(0x00000000, Foo::PIPE_READMODE_BYTE)
38
+ assert_equal(0x00000002, Foo::PIPE_READMODE_MESSAGE)
39
+ assert_equal(0x00000000, Foo::PIPE_CLIENT_END)
40
+ assert_equal(0x00000001, Foo::PIPE_SERVER_END)
41
+ end
42
+
43
+ def test_method_constants
44
+ assert_not_nil(Foo::CallNamedPipe)
45
+ assert_not_nil(Foo::ConnectNamedPipe)
46
+ assert_not_nil(Foo::CreateNamedPipe)
47
+ assert_not_nil(Foo::CreatePipe)
48
+ assert_not_nil(Foo::DisconnectNamedPipe)
49
+ assert_not_nil(Foo::GetNamedPipeHandleState)
50
+ assert_not_nil(Foo::GetNamedPipeInfo)
51
+ assert_not_nil(Foo::PeekNamedPipe)
52
+ assert_not_nil(Foo::SetNamedPipeHandleState)
53
+ assert_not_nil(Foo::TransactNamedPipe)
54
+ assert_not_nil(Foo::WaitNamedPipe)
55
+ end
56
+
57
+ def teardown
58
+ @foo = nil
59
+ end
60
+ end
@@ -0,0 +1,36 @@
1
+ #####################################################################
2
+ # tc_process.rb
3
+ #
4
+ # Test case for the Windows::Process module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require 'windows/process'
14
+ require 'test/unit'
15
+
16
+ class Foo
17
+ include Windows::Process
18
+ end
19
+
20
+ class TC_Windows_Process < Test::Unit::TestCase
21
+ def setup
22
+ @foo = Foo.new
23
+ end
24
+
25
+ def test_numeric_constants
26
+ assert_equal(0x1F0FFF, Foo::PROCESS_ALL_ACCESS)
27
+ end
28
+
29
+ def test_method_constants
30
+ assert_not_nil(Foo::CreateProcess)
31
+ end
32
+
33
+ def teardown
34
+ @foo = nil
35
+ end
36
+ end
@@ -0,0 +1,61 @@
1
+ #####################################################################
2
+ # tc_unicode.rb
3
+ #
4
+ # Test case for the Windows::Unicode module.
5
+ #####################################################################
6
+ base = File.basename(Dir.pwd)
7
+ if base == 'test' || base =~ /windows-pr/
8
+ Dir.chdir '..' if base == 'test'
9
+ $LOAD_PATH.unshift Dir.pwd + '/lib'
10
+ Dir.chdir 'test' rescue nil
11
+ end
12
+
13
+ require "windows/unicode"
14
+ require "test/unit"
15
+
16
+ class Foo
17
+ include Windows::Unicode
18
+ end
19
+
20
+ class TC_Windows_Unicode < Test::Unit::TestCase
21
+ def setup
22
+ @foo = Foo.new
23
+ end
24
+
25
+ def test_numeric_constants
26
+ assert_equal(0, Foo::CP_ACP)
27
+ assert_equal(1, Foo::CP_OEMCP)
28
+ assert_equal(2, Foo::CP_MACCP)
29
+ assert_equal(3, Foo::CP_THREAD_ACP)
30
+ assert_equal(42, Foo::CP_SYMBOL)
31
+ assert_equal(65000, Foo::CP_UTF7)
32
+ assert_equal(65001, Foo::CP_UTF8)
33
+
34
+ assert_equal(0x00000001, Foo::MB_PRECOMPOSED)
35
+ assert_equal(0x00000002, Foo::MB_COMPOSITE)
36
+ assert_equal(0x00000004, Foo::MB_USEGLYPHCHARS)
37
+ assert_equal(0x00000008, Foo::MB_ERR_INVALID_CHARS)
38
+
39
+ assert_equal(0x00000200, Foo::WC_COMPOSITECHECK)
40
+ assert_equal(0x00000010, Foo::WC_DISCARDNS)
41
+ assert_equal(0x00000020, Foo::WC_SEPCHARS)
42
+ assert_equal(0x00000040, Foo::WC_DEFAULTCHAR)
43
+ assert_equal(0x00000400, Foo::WC_NO_BEST_FIT_CHARS)
44
+ end
45
+
46
+ def test_method_constants
47
+ assert_not_nil(Foo::GetTextCharset)
48
+ assert_not_nil(Foo::GetTextCharsetInfo)
49
+ assert_not_nil(Foo::IsDBCSLeadByte)
50
+ assert_not_nil(Foo::IsDBCSLeadByteEx)
51
+ assert_not_nil(Foo::IsTextUnicode)
52
+ assert_not_nil(Foo::MultiByteToWideChar)
53
+ assert_not_nil(Foo::TranslateCharsetInfo)
54
+ assert_not_nil(Foo::WideCharToMultiByte)
55
+ end
56
+
57
+ def teardown
58
+ @foo = nil
59
+ @unicode = nil
60
+ end
61
+ end
@@ -8,8 +8,12 @@ Dir.chdir('test') rescue nil
8
8
 
9
9
  require 'tc_console'
10
10
  require 'tc_error'
11
+ require 'tc_file'
12
+ require 'tc_memory'
11
13
  require 'tc_msvcrt_buffer'
12
14
  require 'tc_path'
15
+ require 'tc_pipe'
13
16
  require 'tc_registry'
14
17
  require 'tc_security'
15
- require 'tc_synchronize'
18
+ require 'tc_synchronize'
19
+ require 'tc_unicode'
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: windows-pr
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.1
7
- date: 2006-05-28 00:00:00 -06:00
6
+ version: 0.5.2
7
+ date: 2006-07-29 00:00:00 -06:00
8
8
  summary: Windows functions and constants predefined via Win32API
9
9
  require_paths:
10
10
  - lib
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: mswin32
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Daniel J. Berger
30
31
  files:
@@ -43,9 +44,11 @@ files:
43
44
  - lib/windows/memory.rb
44
45
  - lib/windows/national.rb
45
46
  - lib/windows/path.rb
47
+ - lib/windows/pipe.rb
46
48
  - lib/windows/process.rb
47
49
  - lib/windows/registry.rb
48
50
  - lib/windows/security.rb
51
+ - lib/windows/service.rb
49
52
  - lib/windows/shell.rb
50
53
  - lib/windows/sound.rb
51
54
  - lib/windows/synchronize.rb
@@ -55,14 +58,19 @@ files:
55
58
  - test/ts_all.rb
56
59
  - lib/windows/msvcrt/buffer.rb
57
60
  - lib/windows/msvcrt/file.rb
61
+ - lib/windows/msvcrt/string.rb
58
62
  - test/tc_console.rb
59
63
  - test/tc_error.rb
64
+ - test/tc_file.rb
60
65
  - test/tc_memory.rb
61
66
  - test/tc_msvcrt_buffer.rb
62
67
  - test/tc_path.rb
68
+ - test/tc_pipe.rb
69
+ - test/tc_process.rb
63
70
  - test/tc_registry.rb
64
71
  - test/tc_security.rb
65
72
  - test/tc_synchronize.rb
73
+ - test/tc_unicode.rb
66
74
  - CHANGES
67
75
  - MANIFEST
68
76
  - README