windows-pr 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,10 @@
1
+ = 0.7.1 - 21-Sep-2007
2
+ * Added USN (changejournal) macros to Windows::DeviceIO.
3
+ * Added the Heap functions to Windows::Memory.
4
+ * Added the Windows::Time module.
5
+ * Added a Rakefile with tasks for installation and testing.
6
+ * Added and refactored some tests.
7
+
1
8
  = 0.7.0 - 9-Aug-2007
2
9
  * All modules now use the windows-api library behind the scenes.
3
10
  * Added the Windows::NIO module. This contains native Windows IO functions.
data/MANIFEST CHANGED
@@ -1,7 +1,7 @@
1
1
  CHANGES
2
2
  MANIFEST
3
3
  README
4
- install.rb
4
+ Rakefile
5
5
  windows-pr.gemspec
6
6
 
7
7
  doc/conversion_guide.txt
@@ -32,6 +32,7 @@ lib/windows/shell.rb
32
32
  lib/windows/sound.rb
33
33
  lib/windows/synchronize.rb
34
34
  lib/windows/system_info.rb
35
+ lib/windows/time.rb
35
36
  lib/windows/unicode.rb
36
37
  lib/windows/volume.rb
37
38
  lib/windows/window.rb
@@ -42,4 +43,5 @@ lib/windows/gdi/painting_drawing.rb
42
43
 
43
44
  lib/windows/msvcrt/buffer.rb
44
45
  lib/windows/msvcrt/file.rb
46
+ lib/windows/msvcrt/io.rb
45
47
  lib/windows/msvcrt/string.rb
data/README CHANGED
@@ -1,7 +1,7 @@
1
1
  = windows-pr
2
2
  == Description
3
- A collection of Windows functions predefined for you via Win32API. Hence,
4
- the 'pr', for 'Pure Ruby'.
3
+ A collection of Windows functions predefined for you via Win32::API.
4
+ Hence the 'pr', for 'Pure Ruby'.
5
5
 
6
6
  == Synopsis
7
7
  require 'windows/path'
@@ -24,20 +24,20 @@
24
24
  Each of the various files included as part of this package provide a series
25
25
  of constants corresponding to the equivalent Windows API function and
26
26
  related numeric constants. For example, if you require 'windows/path',
27
- you now have PathIsRoot, PathIsUNC, etc, available to you as Win32API
27
+ you now have PathIsRoot, PathIsUNC, etc, available to you as Win32::API
28
28
  objects in the form of constants.
29
29
 
30
30
  A wrapper has been provided for each method in order to avoid the
31
- Win32API#call method. So, instead of PathIsRoot.call(path) you can
32
- invoke it as PathIsRoot(path). If the original function is lower case
31
+ Win32::API#call method. So, instead of PathIsRoot.call(path) you can
32
+ invoke it as PathIsRoot(path). If the original function is lower case
33
33
  then the wrapper method is lower case as well. For example, instead of
34
34
  doing 'Memcpy.call(dest, src, size)' you can do 'memcpy(dest, src, size)'.
35
35
 
36
36
  Remember boys and girls, if you write 'PathIsRoot', you're referring to
37
- the constant. If you write 'PathIsRoot()', you're calling the wrapper
37
+ the constant. If you write 'PathIsRoot()', you're calling the wrapper
38
38
  method.
39
39
 
40
- Boolean methods automatically perform a check for success or failure. So,
40
+ Boolean methods automatically perform a check for success or failure. So,
41
41
  instead of having to do something like 'if PathIsRoot(path) > 0' you can
42
42
  just do 'if PathIsRoot(path)'. However, I do not add this nicety for the
43
43
  MSVCRT functions that return int's because some functions have multiple
@@ -45,8 +45,8 @@
45
45
  guess, I have simply declared that you must inspect return values manually
46
46
  for any MSVCRT module.
47
47
 
48
- Source files contain related functions, by topic. For example, the
49
- clipboard.rb file contains clipboard related functions, such as
48
+ Source files contain related functions, by topic. For example, the
49
+ clipboard.rb file contains clip board related functions, such as
50
50
  CloseClipboard(), as well as constants such as CF_TEXT, CF_BITMAP, etc.
51
51
 
52
52
  == Wide character functions
@@ -56,14 +56,15 @@
56
56
  in the Windows::Unicode module. If $KCODE is set to UTF8, then the code
57
57
  point used is CP_UTF8. Otherwise, CP_ACP is used.
58
58
 
59
- In the future I'll add the wide character functions explicitly. I haven't
60
- added many yet (as of 29-Jul-2006) but I plan on adding as many as I can
61
- as time permits.
59
+ The modules all come with explicit ANSI and Wide (Unicode) functions,
60
+ when available from MS Windows. By default, a function without an explicit
61
+ 'A' at the end of the function name uses the ANSI version. It is up to you
62
+ to use the wide ('W') functions explicitly if you wish.
62
63
 
63
64
  == Platform specific functions
64
65
  Not all functions are defined on all platforms. For example, the
65
66
  AttachConsole() function is only defined on Windows XP and later. If you
66
- need to conditionally test for its existance, simply use the 'defined?'
67
+ need to conditionally test for its existence, simply use the 'defined?'
67
68
  method:
68
69
 
69
70
  if defined? AttachConsole
@@ -95,7 +96,7 @@
95
96
  of memory, hard to organize & maintain, and impossible to test. Second,
96
97
  some of his function declarations are wrong. Third, some of the functions
97
98
  I needed for my own projects are missing. Fourth, there's no gem. Lastly,
98
- I haven't seen an update in over 5 years, which leads me to believe it is
99
+ I haven't seen an update in over 6 years, which leads me to believe it is
99
100
  no longer maintained.
100
101
 
101
102
  == Hey, I'm missing function X!
@@ -115,18 +116,18 @@
115
116
 
116
117
  == Known Issues
117
118
  In some cases the MSDN docs are wrong, and we have to learn it the hard
118
- way. If you should happen to find a documentation bug on their site,
119
- please contact them and let them know. They're generally good about fixing
119
+ way. If you should happen to find a documentation bug on their site,
120
+ please contact them and let them know. They're generally good about fixing
120
121
  them.
121
122
 
122
- In other cases library functions are not exported by the dll. For example,
123
+ In other cases library functions are not exported by the dll. For example,
123
124
  my version of shlwapi.dll does not export the PathIsHTMLFile() function,
124
- despite being well past the minimum version for that dll file. There is
125
- nothing you or I can do about it short of rebuilding the dll file from
125
+ despite being well past the minimum version for that DLL file. There is
126
+ nothing you or I can do about it short of rebuilding the DLL file from
126
127
  scratch and/or reporting the issue to Microsoft.
127
128
 
128
129
  == Supported Platforms
129
- I only support the Windows NT familiy of Windows, and really only Windows
130
+ I only support the Windows NT family of Windows, and really only Windows
130
131
  2000 and later, though I'll make an effort to support NT 4 if there are
131
132
  any NT 4 related issues and requests to support it.
132
133
 
data/Rakefile ADDED
@@ -0,0 +1,42 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rbconfig'
4
+ include Config
5
+
6
+ desc "Install the windows-pr package (non-gem)"
7
+ task :install do
8
+ sitelibdir = CONFIG["sitelibdir"]
9
+ installdir = File.join(sitelibdir, 'windows')
10
+ installdir_msvcrt = File.join(installdir, 'msvcrt')
11
+ installdir_gdi = File.join(installdir, 'gdi')
12
+
13
+ Dir.mkdir(installdir) unless File.exists?(installdir)
14
+ Dir.mkdir(installdir_msvcrt) unless File.exists?(installdir_msvcrt)
15
+ Dir.mkdir(installdir_gdi) unless File.exists?(installdir_gdi)
16
+
17
+ Dir["lib/windows/*.rb"].each{ |file|
18
+ FileUtils.cp(file, installdir, :verbose => true)
19
+ }
20
+
21
+ Dir["lib/windows/msvcrt/*.rb"].each{ |file|
22
+ FileUtils.cp(file, installdir_msvcrt, :verbose => true)
23
+ }
24
+
25
+ Dir["lib/windows/gdi/*.rb"].each{ |file|
26
+ FileUtils.cp(file, installdir_gdi, :verbose => true)
27
+ }
28
+ end
29
+
30
+ desc "Install the windows-pr package as a gem"
31
+ task :install_gem do
32
+ ruby 'windows-pr.gemspec'
33
+ file = Dir["*.gem"].first
34
+ sh "gem install #{file}"
35
+ end
36
+
37
+ Rake::TestTask.new do |t|
38
+ t.libs << 'lib'
39
+ t.libs << 'lib/windows'
40
+ t.warning = true
41
+ t.test_files = FileList['test/tc*']
42
+ end
data/lib/windows/com.rb CHANGED
@@ -6,7 +6,7 @@ module Windows
6
6
  API.auto_namespace = 'Windows::COM'
7
7
  API.auto_constant = true
8
8
  API.auto_method = true
9
- API.auto_unicode = true
9
+ API.auto_unicode = false
10
10
 
11
11
  API.new('BindMoniker', 'PLPP', 'L', 'ole32')
12
12
  API.new('CLSIDFromProgID', 'PP', 'L', 'ole32')
data/lib/windows/debug.rb CHANGED
@@ -16,7 +16,7 @@ module Windows
16
16
  API.new('GetThreadContext', 'LP', 'B')
17
17
  API.new('GetThreadSelectorEntry', 'LLP', 'B')
18
18
  API.new('IsDebuggerPresent', 'V', 'B')
19
- API.new('OutputDebugStringA', 'P', 'V')
19
+ API.new('OutputDebugString', 'P', 'V')
20
20
  API.new('ReadProcessMemory', 'LLPLP', 'B')
21
21
  API.new('SetThreadContext', 'LP', 'B')
22
22
  API.new('WaitForDebugEvent', 'PL', 'B')
@@ -69,22 +69,53 @@ module Windows
69
69
  FILE_DEVICE_FIPS = 0x0000003A
70
70
  FILE_DEVICE_INFINIBAND = 0x0000003B
71
71
 
72
- METHOD_BUFFERED = 0
73
- FILE_ANY_ACCESS = 0
72
+ METHOD_BUFFERED = 0
73
+ METHOD_IN_DIRECT = 1
74
+ METHOD_OUT_DIRECT = 2
75
+ METHOD_NEITHER = 3
74
76
 
75
77
  API.new('DeviceIoControl', 'LLPLPLPP', 'B')
76
78
 
77
79
  # Macros from WinIoCtl.h
80
+
78
81
  def CTL_CODE(device, function, method, access)
79
82
  ((device) << 16) | ((access) << 14) | ((function) << 2) | (method)
80
83
  end
81
84
 
82
85
  def FSCTL_SET_COMPRESSION
83
- CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, 0, 3)
86
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, 3)
87
+ end
88
+
89
+ def FSCTL_READ_USN_JOURNAL
90
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 46, METHOD_NEITHER, 0)
84
91
  end
85
92
 
86
93
  def FSCTL_SET_SPARSE
87
- CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, 0, FILE_ANY_ACCESS)
94
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 49, METHOD_BUFFERED, 0)
95
+ end
96
+
97
+ def FSCTL_CREATE_USN_JOURNAL
98
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 57, METHOD_NEITHER, 0)
99
+ end
100
+
101
+ def FSCTL_READ_FILE_USN_DATA
102
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 58, METHOD_NEITHER, 0)
103
+ end
104
+
105
+ def FSCTL_WRITE_USN_CLOSE_RECORD
106
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 59, METHOD_NEITHER, 0)
107
+ end
108
+
109
+ def FSCTL_EXTEND_VOLUME
110
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 60, METHOD_BUFFERED, 0)
111
+ end
112
+
113
+ def FSCTL_QUERY_USN_JOURNAL
114
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 61, METHOD_BUFFERED, 0)
115
+ end
116
+
117
+ def FSCTL_DELETE_USN_JOURNAL
118
+ CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 62, METHOD_BUFFERED, 0)
88
119
  end
89
120
  end
90
121
  end
@@ -0,0 +1,37 @@
1
+ require 'windows/api'
2
+ include Windows
3
+
4
+ module Windows
5
+ module GDI
6
+ module Bitmap
7
+ API.auto_namespace = 'Windows::GDI::Bitmap'
8
+ API.auto_constant = true
9
+ API.auto_method = true
10
+ API.auto_unicode = true
11
+
12
+ DIB_RGB_COLORS = 0
13
+ DIB_PAL_COLORS = 1
14
+
15
+ # Raster operations
16
+ SRCCOPY = 0x00CC0020
17
+ SRCPAINT = 0x00EE0086
18
+ SRCAND = 0x008800C6
19
+ SRCINVERT = 0x00660046
20
+ SRCERASE = 0x00440328
21
+ NOTSRCCOPY = 0x00330008
22
+ NOTSRCERASE = 0x001100A6
23
+ MERGECOPY = 0x00C000CA
24
+ MERGEPAINT = 0x00BB0226
25
+ PATCOPY = 0x00F00021
26
+ PATPAINT = 0x00FB0A09
27
+ PATINVERT = 0x005A0049
28
+ DSTINVERT = 0x00550009
29
+ BLACKNESS = 0x00000042
30
+ WHITENESS = 0x00FF0062
31
+
32
+ API.new('BitBlt', 'LIIIILIIL', 'B', 'gdi32')
33
+ API.new('CreateCompatibleBitmap', 'LII', 'L', 'gdi32')
34
+ API.new('GetDIBits', 'LLIIPPI', 'I', 'gdi32')
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,45 @@
1
+ require 'windows/api'
2
+ include Windows
3
+
4
+ module Windows
5
+ module GDI
6
+ module DeviceContext
7
+ API.auto_namespace = 'Windows::GDI::DeviceContext'
8
+ API.auto_constant = true
9
+ API.auto_method = true
10
+ API.auto_unicode = true
11
+
12
+ DRIVERVERSION = 0
13
+ TECHNOLOGY = 2
14
+ HORZSIZE = 4
15
+ VERTSIZE = 6
16
+ HORZRES = 8
17
+ VERTRES = 10
18
+ BITSPIXEL = 12
19
+ PLANES = 14
20
+ NUMBRUSHES = 16
21
+ NUMPENS = 18
22
+ NUMMARKERS = 20
23
+ NUMFONTS = 22
24
+ NUMCOLORS = 24
25
+ PDEVICESIZE = 26
26
+ CURVECAPS = 28
27
+ LINECAPS = 30
28
+ POLYGONALCAPS = 32
29
+ TEXTCAPS = 34
30
+ CLIPCAPS = 36
31
+ RASTERCAPS = 38
32
+ ASPECTX = 40
33
+ ASPECTY = 42
34
+ ASPECTXY = 44
35
+
36
+ API.new('CreateCompatibleDC', 'L', 'L', 'gdi32')
37
+ API.new('DeleteDC', 'L', 'B', 'gdi32')
38
+ API.new('DeleteObject', 'L', 'B', 'gdi32')
39
+ API.new('GetDC', 'L', 'L', 'user32')
40
+ API.new('GetDeviceCaps', 'LI', 'I', 'gdi32')
41
+ API.new('ReleaseDC', 'LL', 'I', 'user32')
42
+ API.new('SelectObject', 'LL', 'L', 'gdi32')
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,114 @@
1
+ require 'windows/api'
2
+ include Windows
3
+
4
+ module Windows
5
+ module GDI
6
+ module PaintingDrawing
7
+ API.auto_namespace = 'Windows::GDI::PaintingDrawing'
8
+ API.auto_constant = true
9
+ API.auto_method = true
10
+ API.auto_unicode = false
11
+
12
+ # Flags for DrawCaption
13
+ DC_ACTIVE = 0x0001
14
+ DC_SMALLCAP = 0x0002
15
+ DC_ICON = 0x0004
16
+ DC_TEXT = 0x0008
17
+ DC_INBUTTON = 0x0010
18
+ DC_GRADIENT = 0x0020
19
+ DC_BUTTONS = 0x1000
20
+
21
+ # 3D border styles
22
+ BDR_RAISEDOUTER = 0x0001
23
+ BDR_SUNKENOUTER = 0x0002
24
+ BDR_RAISEDINNER = 0x0004
25
+ BDR_SUNKENINNER = 0x0008
26
+
27
+ BDR_OUTER = (BDR_RAISEDOUTER | BDR_SUNKENOUTER)
28
+ BDR_INNER = (BDR_RAISEDINNER | BDR_SUNKENINNER)
29
+ BDR_RAISED = (BDR_RAISEDOUTER | BDR_RAISEDINNER)
30
+ BDR_SUNKEN = (BDR_SUNKENOUTER | BDR_SUNKENINNER)
31
+
32
+ EDGE_RAISED = (BDR_RAISEDOUTER | BDR_RAISEDINNER)
33
+ EDGE_SUNKEN = (BDR_SUNKENOUTER | BDR_SUNKENINNER)
34
+ EDGE_ETCHED = (BDR_SUNKENOUTER | BDR_RAISEDINNER)
35
+ EDGE_BUMP = (BDR_RAISEDOUTER | BDR_SUNKENINNER)
36
+
37
+ # Border flags
38
+ BF_LEFT = 0x0001
39
+ BF_TOP = 0x0002
40
+ BF_RIGHT = 0x0004
41
+ BF_BOTTOM = 0x0008
42
+
43
+ BF_TOPLEFT = (BF_TOP | BF_LEFT)
44
+ BF_TOPRIGHT = (BF_TOP | BF_RIGHT)
45
+ BF_BOTTOMLEFT = (BF_BOTTOM | BF_LEFT)
46
+ BF_BOTTOMRIGHT = (BF_BOTTOM | BF_RIGHT)
47
+ BF_RECT = (BF_LEFT | BF_TOP | BF_RIGHT | BF_BOTTOM)
48
+
49
+ BF_DIAGONAL = 0x0010
50
+
51
+ BF_DIAGONAL_ENDTOPRIGHT = (BF_DIAGONAL | BF_TOP | BF_RIGHT)
52
+ BF_DIAGONAL_ENDTOPLEFT = (BF_DIAGONAL | BF_TOP | BF_LEFT)
53
+ BF_DIAGONAL_ENDBOTTOMLEFT = (BF_DIAGONAL | BF_BOTTOM | BF_LEFT)
54
+ BF_DIAGONAL_ENDBOTTOMRIGHT = (BF_DIAGONAL | BF_BOTTOM | BF_RIGHT)
55
+
56
+ BF_MIDDLE = 0x0800 # Fill in the middle
57
+ BF_SOFT = 0x1000 # For softer buttons
58
+ BF_ADJUST = 0x2000 # Calculate the space left over
59
+ BF_FLAT = 0x4000 # For flat rather than 3D borders
60
+ BF_MONO = 0x8000 # For monochrome borders
61
+
62
+ # Flags for DrawFrameControl
63
+ DFC_CAPTION = 1
64
+ DFC_MENU = 2
65
+ DFC_SCROLL = 3
66
+ DFC_BUTTON = 4
67
+ DFC_POPUPMENU = 5
68
+
69
+ DFCS_CAPTIONCLOSE = 0x0000
70
+ DFCS_CAPTIONMIN = 0x0001
71
+ DFCS_CAPTIONMAX = 0x0002
72
+ DFCS_CAPTIONRESTORE = 0x0003
73
+ DFCS_CAPTIONHELP = 0x0004
74
+
75
+ DFCS_MENUARROW = 0x0000
76
+ DFCS_MENUCHECK = 0x0001
77
+ DFCS_MENUBULLET = 0x0002
78
+ DFCS_MENUARROWRIGHT = 0x0004
79
+ DFCS_SCROLLUP = 0x0000
80
+ DFCS_SCROLLDOWN = 0x0001
81
+ DFCS_SCROLLLEFT = 0x0002
82
+ DFCS_SCROLLRIGHT = 0x0003
83
+ DFCS_SCROLLCOMBOBOX = 0x0005
84
+ DFCS_SCROLLSIZEGRIP = 0x0008
85
+ DFCS_SCROLLSIZEGRIPRIGHT = 0x0010
86
+
87
+ DFCS_BUTTONCHECK = 0x0000
88
+ DFCS_BUTTONRADIOIMAGE = 0x0001
89
+ DFCS_BUTTONRADIOMASK = 0x0002
90
+ DFCS_BUTTONRADIO = 0x0004
91
+ DFCS_BUTTON3STATE = 0x0008
92
+ DFCS_BUTTONPUSH = 0x0010
93
+
94
+ DFCS_INACTIVE = 0x0100
95
+ DFCS_PUSHED = 0x0200
96
+ DFCS_CHECKED = 0x0400
97
+
98
+ DFCS_TRANSPARENT = 0x0800
99
+ DFCS_HOT = 0x1000
100
+
101
+ DFCS_ADJUSTRECT = 0x2000
102
+ DFCS_FLAT = 0x4000
103
+ DFCS_MONO = 0x8000
104
+
105
+ API.new('BeginPaint', 'LP', 'L', 'user32')
106
+ API.new('GetWindowDC', 'L', 'L', 'user32')
107
+ API.new('DrawAnimatedRects', 'LIPP', 'B', 'user32')
108
+ API.new('DrawCaption', 'LLPL', 'B', 'user32')
109
+ API.new('DrawEdge', 'LPII', 'B', 'user32')
110
+ API.new('DrawFocusRect', 'LP', 'B', 'user32')
111
+ API.new('DrawFrameControl', 'LPLL', 'B', 'user32')
112
+ end
113
+ end
114
+ end
@@ -8,11 +8,17 @@ module Windows
8
8
  API.auto_method = true
9
9
  API.auto_unicode = false
10
10
 
11
- GHND = 0x0042
12
- GMEM_FIXED = 0x0000
13
- GMEM_MOVABLE = 0002
14
- GMEM_ZEROINIT = 0x0040
15
- GPTR = 0x0040
11
+ GHND = 0x0042
12
+ GMEM_FIXED = 0x0000
13
+ GMEM_MOVABLE = 0002
14
+ GMEM_ZEROINIT = 0x0040
15
+ GPTR = 0x0040
16
+
17
+ HEAP_NO_SERIALIZE = 0x00000001
18
+ HEAP_GENERATE_EXCEPTIONS = 0x00000004
19
+ HEAP_ZERO_MEMORY = 0x00000008
20
+ HEAP_REALLOC_IN_PLACE_ONLY = 0x00000010
21
+ HEAP_CREATE_ENABLE_EXECUTE = 0x00040000
16
22
 
17
23
  MEM_COMMIT = 0x1000
18
24
  MEM_RESERVE = 0x2000
@@ -32,6 +38,21 @@ module Windows
32
38
  API.new('GlobalReAlloc', 'III', 'I')
33
39
  API.new('GlobalSize', 'I', 'I')
34
40
  API.new('GlobalUnlock', 'I', 'I')
41
+
42
+ API.new('GetProcessHeap', 'V', 'L')
43
+ API.new('GetProcessHeaps', 'LP', 'L')
44
+ API.new('HeapAlloc', 'LLL', 'P')
45
+ API.new('HeapCompact', 'LL', 'L')
46
+ API.new('HeapCreate', 'LLL', 'L')
47
+ API.new('HeapDestroy', 'L', 'B')
48
+ API.new('HeapFree', 'LLL', 'B')
49
+ API.new('HeapLock', 'L', 'B')
50
+ API.new('HeapReAlloc', 'LLLL', 'L')
51
+ API.new('HeapSize', 'LLL', 'L')
52
+ API.new('HeapUnlock', 'L', 'B')
53
+ API.new('HeapValidate', 'LLL', 'B')
54
+ API.new('HeapWalk', 'LP', 'B')
55
+
35
56
  API.new('VirtualAlloc', 'LLLL', 'P')
36
57
  API.new('VirtualAllocEx', 'LLLLL', 'P')
37
58
  API.new('VirtualFree', 'LLL', 'B')
@@ -43,5 +64,13 @@ module Windows
43
64
  API.new('VirtualQueryEx', 'LLPL', 'L')
44
65
  API.new('VirtualUnlock', 'PL', 'B')
45
66
  API.new('RtlZeroMemory', 'PL', 'L')
67
+
68
+ # Windows XP or later
69
+ begin
70
+ API.new('HeapQueryInformation', 'LIPLL', 'B')
71
+ API.new('HeapSetInformation', 'LIPL', 'B')
72
+ rescue Exception
73
+ # Do nothing - you must check for their existence
74
+ end
46
75
  end
47
76
  end
data/lib/windows/nio.rb CHANGED
@@ -1,26 +1,45 @@
1
- require 'windows/api'
2
- include Windows
3
-
4
- module Windows
5
- module NIO
6
- API.auto_namespace = 'Windows::NIO'
7
- API.auto_constant = true
8
- API.auto_method = true
9
- API.auto_unicode = false
10
-
11
- API.new('CancelIo', 'L', 'B')
12
- API.new('CreateIoCompletionPort', 'LLPL', 'L')
13
- API.new('FlushFileBuffers', 'L', 'B')
14
- API.new('GetQueuedCompletionStatus', 'LPPPL', 'B')
15
- API.new('PostQueuedCompletionStatus', 'LLPP', 'B')
16
- API.new('ReadFile', 'LPLPP', 'B')
17
- API.new('ReadFileEx', 'LPLPP', 'B')
18
- API.new('ReadFileScatter', 'LPLPP', 'B')
19
- API.new('SetEndOfFile', 'L', 'B')
20
- API.new('SetFilePointer', 'LLPL', 'L')
21
- API.new('SetFilePointerEx', 'LLPL', 'L')
22
- API.new('WriteFile', 'LPLPP', 'B')
23
- API.new('WriteFileEx', 'LPLPP', 'B')
24
- API.new('WriteFileGather', 'LPLPP', 'B')
25
- end
26
- end
1
+ require 'windows/api'
2
+ include Windows
3
+
4
+ module Windows
5
+ module NIO
6
+ API.auto_namespace = 'Windows::NIO'
7
+ API.auto_constant = true
8
+ API.auto_method = true
9
+ API.auto_unicode = false
10
+
11
+ # OpenFile() constants
12
+ OF_READ = 0x00000000
13
+ OF_WRITE = 0x00000001
14
+ OF_READWRITE = 0x00000002
15
+ OF_SHARE_COMPAT = 0x00000000
16
+ OF_SHARE_EXCLUSIVE = 0x00000010
17
+ OF_SHARE_DENY_WRITE = 0x00000020
18
+ OF_SHARE_DENY_READ = 0x00000030
19
+ OF_SHARE_DENY_NONE = 0x00000040
20
+ OF_PARSE = 0x00000100
21
+ OF_DELETE = 0x00000200
22
+ OF_VERIFY = 0x00000400
23
+ OF_CANCEL = 0x00000800
24
+ OF_CREATE = 0x00001000
25
+ OF_PROMPT = 0x00002000
26
+ OF_EXIST = 0x00004000
27
+ OF_REOPEN = 0x00008000
28
+
29
+ API.new('CancelIo', 'L', 'B')
30
+ API.new('CreateIoCompletionPort', 'LLPL', 'L')
31
+ API.new('FlushFileBuffers', 'L', 'B')
32
+ API.new('GetQueuedCompletionStatus', 'LPPPL', 'B')
33
+ API.new('OpenFile', 'PPI', 'L')
34
+ API.new('PostQueuedCompletionStatus', 'LLPP', 'B')
35
+ API.new('ReadFile', 'LPLPP', 'B')
36
+ API.new('ReadFileEx', 'LPLPP', 'B')
37
+ API.new('ReadFileScatter', 'LPLPP', 'B')
38
+ API.new('SetEndOfFile', 'L', 'B')
39
+ API.new('SetFilePointer', 'LLPL', 'L')
40
+ API.new('SetFilePointerEx', 'LLPL', 'L')
41
+ API.new('WriteFile', 'LPLPP', 'B')
42
+ API.new('WriteFileEx', 'LPLPP', 'B')
43
+ API.new('WriteFileGather', 'LPLPP', 'B')
44
+ end
45
+ end
@@ -2,6 +2,11 @@ require 'windows/file'
2
2
 
3
3
  module Windows
4
4
  module Registry
5
+ API.auto_namespace = 'Windows::Registry'
6
+ API.auto_constant = true
7
+ API.auto_method = true
8
+ API.auto_unicode = true
9
+
5
10
  include Windows::File
6
11
 
7
12
  HKEY_CLASSES_ROOT = 0x80000000
@@ -0,0 +1,48 @@
1
+ require 'windows/api'
2
+ include Windows
3
+
4
+ # In general you will want to use this module with Windows::National because
5
+ # it contains the various LOCALE and TIME constants.
6
+
7
+ module Windows
8
+ module Time
9
+ API.auto_namespace = 'Windows::Time'
10
+ API.auto_constant = true
11
+ API.auto_method = true
12
+ API.auto_unicode = true
13
+
14
+ TIME_ZONE_ID_UNKNOWN = 0
15
+ TIME_ZONE_ID_STANDARD = 1
16
+ TIME_ZONE_ID_DAYLIGHT = 2
17
+
18
+ API.new('CompareFileTime', 'PP', 'L')
19
+ API.new('DosDateTimeToFileTime', 'IIP', 'B')
20
+ API.new('FileTimeToDosDateTime', 'PPP', 'B')
21
+ API.new('FileTimeToLocalFileTime', 'PP', 'B')
22
+ API.new('FileTimeToSystemTime', 'PP', 'B')
23
+ API.new('GetFileTime', 'LPPP', 'B')
24
+ API.new('GetLocalTime', 'P')
25
+ API.new('GetSystemTime', 'P')
26
+ API.new('GetSystemTimeAdjustment', 'PPP', 'B')
27
+ API.new('GetSystemTimeAsFileTime', 'P')
28
+ API.new('GetTickCount')
29
+ API.new('GetTimeFormat', 'ILPPPI', 'I')
30
+ API.new('GetTimeZoneInformation', 'P', 'L')
31
+ API.new('LocalFileTimeToFileTime', 'PP', 'B')
32
+ API.new('SetFileTime', 'LPPP', 'B')
33
+ API.new('SetLocalTime', 'P', 'B')
34
+ API.new('SetSystemTime', 'P', 'B')
35
+ API.new('SetTimeZoneInformation', 'P', 'B')
36
+ API.new('SetSystemTimeAdjustment', 'LI', 'B')
37
+ API.new('SystemTimeToFileTime', 'PP', 'B')
38
+ API.new('SystemTimeToTzSpecificLocalTime', 'PPP', 'B')
39
+ API.new('TzSpecificLocalTimeToSystemTime', 'PPP', 'B')
40
+
41
+ # Windows XP or later
42
+ begin
43
+ API.new('GetSystemTimes', 'PPP', 'B')
44
+ rescue RuntimeError
45
+ # Do nothing. It's up to you to check your platform.
46
+ end
47
+ end
48
+ end
@@ -1,6 +1,8 @@
1
1
  require 'windows/api'
2
2
  include Windows
3
3
 
4
+ # See WinUser.h
5
+
4
6
  module Windows
5
7
  module Window
6
8
  API.auto_namespace = 'Windows::Window'