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.
- checksums.yaml +7 -0
- data/CHANGES +444 -438
- data/MANIFEST +68 -65
- data/README +154 -153
- data/Rakefile +42 -37
- data/doc/conversion_guide.txt +37 -37
- data/lib/windows/clipboard.rb +61 -61
- data/lib/windows/com.rb +192 -192
- data/lib/windows/com/accessibility.rb +16 -16
- data/lib/windows/com/automation.rb +149 -149
- data/lib/windows/com/variant.rb +24 -24
- data/lib/windows/console.rb +114 -114
- data/lib/windows/debug.rb +35 -35
- data/lib/windows/device_io.rb +248 -248
- data/lib/windows/directory.rb +27 -27
- data/lib/windows/error.rb +504 -498
- data/lib/windows/eventlog.rb +80 -80
- data/lib/windows/file.rb +264 -264
- data/lib/windows/file_mapping.rb +25 -25
- data/lib/windows/filesystem.rb +15 -15
- data/lib/windows/gdi/bitmap.rb +65 -65
- data/lib/windows/gdi/device_context.rb +46 -46
- data/lib/windows/gdi/metafile.rb +40 -40
- data/lib/windows/gdi/painting_drawing.rb +115 -115
- data/lib/windows/handle.rb +23 -23
- data/lib/windows/library.rb +44 -44
- data/lib/windows/limits.rb +34 -34
- data/lib/windows/mailslot.rb +24 -24
- data/lib/windows/memory.rb +128 -128
- data/lib/windows/msvcrt/buffer.rb +75 -75
- data/lib/windows/msvcrt/directory.rb +31 -31
- data/lib/windows/msvcrt/file.rb +47 -47
- data/lib/windows/msvcrt/io.rb +73 -73
- data/lib/windows/msvcrt/string.rb +182 -182
- data/lib/windows/msvcrt/time.rb +169 -169
- data/lib/windows/national.rb +580 -580
- data/lib/windows/network/management.rb +525 -525
- data/lib/windows/network/snmp.rb +92 -92
- data/lib/windows/network/winsock.rb +128 -128
- data/lib/windows/nio.rb +50 -50
- data/lib/windows/ntfs/winternl.rb +117 -117
- data/lib/windows/path.rb +143 -143
- data/lib/windows/pipe.rb +42 -42
- data/lib/windows/process.rb +176 -176
- data/lib/windows/registry.rb +171 -171
- data/lib/windows/security.rb +479 -479
- data/lib/windows/security/authentication.rb +32 -32
- data/lib/windows/security/sspi.rb +153 -0
- data/lib/windows/service.rb +142 -142
- data/lib/windows/shell.rb +171 -171
- data/lib/windows/socket.rb +86 -86
- data/lib/windows/sound.rb +39 -39
- data/lib/windows/synchronize.rb +133 -133
- data/lib/windows/system_info.rb +229 -229
- data/lib/windows/thread.rb +64 -64
- data/lib/windows/time.rb +48 -48
- data/lib/windows/tool_helper.rb +36 -36
- data/lib/windows/unicode.rb +155 -155
- data/lib/windows/volume.rb +61 -61
- data/lib/windows/window.rb +81 -81
- data/lib/windows/window/classes.rb +59 -59
- data/lib/windows/window/dialog.rb +91 -91
- data/lib/windows/window/menu.rb +102 -102
- data/lib/windows/window/message.rb +297 -297
- data/lib/windows/window/properties.rb +20 -20
- data/lib/windows/window/timer.rb +19 -19
- data/lib/windows/wsa.rb +102 -102
- data/test/tc_clipboard.rb +41 -41
- data/test/tc_com.rb +32 -32
- data/test/tc_com_automation.rb +15 -15
- data/test/tc_console.rb +108 -108
- data/test/tc_debug.rb +48 -48
- data/test/tc_device_io.rb +29 -29
- data/test/tc_directory.rb +25 -25
- data/test/tc_error.rb +38 -38
- data/test/tc_eventlog.rb +58 -58
- data/test/tc_file.rb +67 -67
- data/test/tc_file_mapping.rb +38 -38
- data/test/tc_filesystem.rb +27 -27
- data/test/tc_gdi_bitmap.rb +25 -25
- data/test/tc_gdi_metafile.rb +23 -23
- data/test/tc_handle.rb +36 -36
- data/test/tc_library.rb +37 -37
- data/test/tc_limits.rb +34 -34
- data/test/tc_mailslot.rb +22 -22
- data/test/tc_memory.rb +44 -44
- data/test/tc_msvcrt_buffer.rb +63 -63
- data/test/tc_msvcrt_directory.rb +96 -96
- data/test/tc_msvcrt_file.rb +80 -80
- data/test/tc_msvcrt_io.rb +48 -48
- data/test/tc_msvcrt_string.rb +94 -94
- data/test/tc_msvcrt_time.rb +19 -19
- data/test/tc_national.rb +38 -38
- data/test/tc_network_management.rb +32 -32
- data/test/tc_network_snmp.rb +31 -31
- data/test/tc_network_winsock.rb +34 -34
- data/test/tc_nio.rb +32 -32
- data/test/tc_ntfs_winternl.rb +48 -48
- data/test/tc_path.rb +90 -90
- data/test/tc_pipe.rb +53 -53
- data/test/tc_process.rb +24 -24
- data/test/tc_registry.rb +29 -29
- data/test/tc_security.rb +104 -104
- data/test/tc_security_authentication.rb +34 -34
- data/test/tc_security_sspi.rb +23 -0
- data/test/tc_service.rb +57 -57
- data/test/tc_shell.rb +34 -34
- data/test/tc_socket.rb +20 -20
- data/test/tc_sound.rb +37 -37
- data/test/tc_synchronize.rb +75 -75
- data/test/tc_system_info.rb +33 -33
- data/test/tc_thread.rb +29 -29
- data/test/tc_time.rb +32 -32
- data/test/tc_tool_helper.rb +29 -29
- data/test/tc_unicode.rb +83 -83
- data/test/tc_volume.rb +47 -47
- data/test/tc_window.rb +45 -45
- data/test/tc_window_classes.rb +33 -33
- data/test/tc_window_dialog.rb +33 -33
- data/test/tc_window_menu.rb +29 -29
- data/test/tc_window_message.rb +33 -33
- data/test/tc_window_properties.rb +29 -29
- data/test/tc_window_timer.rb +29 -29
- data/test/tc_wsa.rb +19 -19
- data/windows-pr.gemspec +33 -34
- metadata +31 -32
data/lib/windows/handle.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
require 'windows/api'
|
2
|
-
|
3
|
-
module Windows
|
4
|
-
module Handle
|
5
|
-
API.auto_namespace = 'Windows::Handle'
|
6
|
-
API.auto_constant = true
|
7
|
-
API.auto_method = true
|
8
|
-
API.auto_unicode = false
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
INVALID_HANDLE_VALUE = 0xFFFFFFFF
|
13
|
-
HANDLE_FLAG_INHERIT = 0x00000001
|
14
|
-
HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002
|
15
|
-
|
16
|
-
API.new('CloseHandle', 'L', 'B')
|
17
|
-
API.new('DuplicateHandle', 'LLLPLIL', 'B')
|
18
|
-
API.new('GetHandleInformation', 'LL', 'B')
|
19
|
-
API.new('SetHandleInformation', 'LLL', 'B')
|
20
|
-
API.new('_get_osfhandle', 'I', 'L', MSVCRT_DLL)
|
21
|
-
API.new('_open_osfhandle', 'LI', 'I', MSVCRT_DLL)
|
22
|
-
end
|
23
|
-
end
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Handle
|
5
|
+
API.auto_namespace = 'Windows::Handle'
|
6
|
+
API.auto_constant = true
|
7
|
+
API.auto_method = true
|
8
|
+
API.auto_unicode = false
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
INVALID_HANDLE_VALUE = 0xFFFFFFFF
|
13
|
+
HANDLE_FLAG_INHERIT = 0x00000001
|
14
|
+
HANDLE_FLAG_PROTECT_FROM_CLOSE = 0x00000002
|
15
|
+
|
16
|
+
API.new('CloseHandle', 'L', 'B')
|
17
|
+
API.new('DuplicateHandle', 'LLLPLIL', 'B')
|
18
|
+
API.new('GetHandleInformation', 'LL', 'B')
|
19
|
+
API.new('SetHandleInformation', 'LLL', 'B')
|
20
|
+
API.new('_get_osfhandle', 'I', 'L', MSVCRT_DLL)
|
21
|
+
API.new('_open_osfhandle', 'LI', 'I', MSVCRT_DLL)
|
22
|
+
end
|
23
|
+
end
|
data/lib/windows/library.rb
CHANGED
@@ -1,44 +1,44 @@
|
|
1
|
-
require 'windows/api'
|
2
|
-
|
3
|
-
module Windows
|
4
|
-
module Library
|
5
|
-
API.auto_namespace = 'Windows::Library'
|
6
|
-
API.auto_constant = true
|
7
|
-
API.auto_method = true
|
8
|
-
API.auto_unicode = true
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
DLL_PROCESS_DETACH = 0
|
13
|
-
DLL_PROCESS_ATTACH = 1
|
14
|
-
DLL_THREAD_ATTACH = 2
|
15
|
-
DLL_THREAD_DETACH = 3
|
16
|
-
|
17
|
-
GET_MODULE_HANDLE_EX_FLAG_PIN = 1
|
18
|
-
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2
|
19
|
-
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 4
|
20
|
-
|
21
|
-
DONT_RESOLVE_DLL_REFERENCES = 0x00000001
|
22
|
-
LOAD_LIBRARY_AS_DATAFILE = 0x00000002
|
23
|
-
LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
|
24
|
-
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010
|
25
|
-
|
26
|
-
API.new('DisableThreadLibraryCalls', 'L', 'B')
|
27
|
-
API.new('FreeLibrary', 'L', 'B')
|
28
|
-
API.new('FreeLibraryAndExitThread', 'LL', 'V')
|
29
|
-
API.new('GetModuleFileName', 'LPL', 'L')
|
30
|
-
API.new('GetModuleHandle', 'P', 'L')
|
31
|
-
API.new('GetProcAddress', 'LP', 'L')
|
32
|
-
API.new('LoadLibrary', 'P', 'L')
|
33
|
-
API.new('LoadLibraryEx', 'PLL', 'L')
|
34
|
-
API.new('LoadModule', 'PP', 'L')
|
35
|
-
|
36
|
-
begin
|
37
|
-
API.new('GetDllDirectory', 'LP', 'L')
|
38
|
-
API.new('GetModuleHandleEx', 'LPP', 'I')
|
39
|
-
API.new('SetDllDirectory', 'P', 'I')
|
40
|
-
rescue Win32::API::LoadLibraryError
|
41
|
-
# Windows XP or later
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Library
|
5
|
+
API.auto_namespace = 'Windows::Library'
|
6
|
+
API.auto_constant = true
|
7
|
+
API.auto_method = true
|
8
|
+
API.auto_unicode = true
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
DLL_PROCESS_DETACH = 0
|
13
|
+
DLL_PROCESS_ATTACH = 1
|
14
|
+
DLL_THREAD_ATTACH = 2
|
15
|
+
DLL_THREAD_DETACH = 3
|
16
|
+
|
17
|
+
GET_MODULE_HANDLE_EX_FLAG_PIN = 1
|
18
|
+
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT = 2
|
19
|
+
GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS = 4
|
20
|
+
|
21
|
+
DONT_RESOLVE_DLL_REFERENCES = 0x00000001
|
22
|
+
LOAD_LIBRARY_AS_DATAFILE = 0x00000002
|
23
|
+
LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008
|
24
|
+
LOAD_IGNORE_CODE_AUTHZ_LEVEL = 0x00000010
|
25
|
+
|
26
|
+
API.new('DisableThreadLibraryCalls', 'L', 'B')
|
27
|
+
API.new('FreeLibrary', 'L', 'B')
|
28
|
+
API.new('FreeLibraryAndExitThread', 'LL', 'V')
|
29
|
+
API.new('GetModuleFileName', 'LPL', 'L')
|
30
|
+
API.new('GetModuleHandle', 'P', 'L')
|
31
|
+
API.new('GetProcAddress', 'LP', 'L')
|
32
|
+
API.new('LoadLibrary', 'P', 'L')
|
33
|
+
API.new('LoadLibraryEx', 'PLL', 'L')
|
34
|
+
API.new('LoadModule', 'PP', 'L')
|
35
|
+
|
36
|
+
begin
|
37
|
+
API.new('GetDllDirectory', 'LP', 'L')
|
38
|
+
API.new('GetModuleHandleEx', 'LPP', 'I')
|
39
|
+
API.new('SetDllDirectory', 'P', 'I')
|
40
|
+
rescue Win32::API::LoadLibraryError
|
41
|
+
# Windows XP or later
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/lib/windows/limits.rb
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
module Windows
|
2
|
-
module Limits
|
3
|
-
private
|
4
|
-
|
5
|
-
MINCHAR = 0x80
|
6
|
-
MAXCHAR = 0x7f
|
7
|
-
MINSHORT = 0x8000
|
8
|
-
MAXSHORT = 0x7fff
|
9
|
-
MINLONG = 0x80000000
|
10
|
-
MAXLONG = 0x7fffffff
|
11
|
-
MAXBYTE = 0xff
|
12
|
-
MAXWORD = 0xffff
|
13
|
-
MAXDWORD = 0xffffffff
|
14
|
-
|
15
|
-
# For wide character functions the actual path limit is actually 32k
|
16
|
-
# for most functions that deal with paths, but in the interests of not
|
17
|
-
# wasting huge chunks of memory on buffers I limit it to 1k, which
|
18
|
-
# should be more than enough in practice.
|
19
|
-
#
|
20
|
-
if RUBY_VERSION.to_f >= 1.9
|
21
|
-
if __ENCODING__.name == 'UTF-8'
|
22
|
-
MAXPATH = 1024
|
23
|
-
else
|
24
|
-
MAXPATH = 256
|
25
|
-
end
|
26
|
-
else
|
27
|
-
if $KCODE == 'UTF8'
|
28
|
-
MAXPATH = 1024
|
29
|
-
else
|
30
|
-
MAXPATH = 256
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
1
|
+
module Windows
|
2
|
+
module Limits
|
3
|
+
private
|
4
|
+
|
5
|
+
MINCHAR = 0x80
|
6
|
+
MAXCHAR = 0x7f
|
7
|
+
MINSHORT = 0x8000
|
8
|
+
MAXSHORT = 0x7fff
|
9
|
+
MINLONG = 0x80000000
|
10
|
+
MAXLONG = 0x7fffffff
|
11
|
+
MAXBYTE = 0xff
|
12
|
+
MAXWORD = 0xffff
|
13
|
+
MAXDWORD = 0xffffffff
|
14
|
+
|
15
|
+
# For wide character functions the actual path limit is actually 32k
|
16
|
+
# for most functions that deal with paths, but in the interests of not
|
17
|
+
# wasting huge chunks of memory on buffers I limit it to 1k, which
|
18
|
+
# should be more than enough in practice.
|
19
|
+
#
|
20
|
+
if RUBY_VERSION.to_f >= 1.9
|
21
|
+
if __ENCODING__.name == 'UTF-8'
|
22
|
+
MAXPATH = 1024
|
23
|
+
else
|
24
|
+
MAXPATH = 256
|
25
|
+
end
|
26
|
+
else
|
27
|
+
if $KCODE == 'UTF8'
|
28
|
+
MAXPATH = 1024
|
29
|
+
else
|
30
|
+
MAXPATH = 256
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/windows/mailslot.rb
CHANGED
@@ -1,24 +1,24 @@
|
|
1
|
-
require 'windows/api'
|
2
|
-
|
3
|
-
# The Windows module serves as a namespace only.
|
4
|
-
module Windows
|
5
|
-
# The Mailslot module contains functions and constants related to the
|
6
|
-
# Windows mailslot IPC mechanism.
|
7
|
-
module Mailslot
|
8
|
-
API.auto_namespace = 'Windows::Mailslot'
|
9
|
-
API.auto_constant = true
|
10
|
-
API.auto_method = true
|
11
|
-
API.auto_unicode = true
|
12
|
-
|
13
|
-
private
|
14
|
-
|
15
|
-
# Constants
|
16
|
-
|
17
|
-
MAILSLOT_WAIT_FOREVER = 0xFFFFFFFF
|
18
|
-
MAILSLOT_NO_MESSAGE = 0xFFFFFFFF
|
19
|
-
|
20
|
-
API.new('CreateMailslot', 'SLLP', 'L')
|
21
|
-
API.new('GetMailslotInfo', 'LPPPP', 'B')
|
22
|
-
API.new('SetMailslotInfo', 'LL', 'B')
|
23
|
-
end
|
24
|
-
end
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
# The Windows module serves as a namespace only.
|
4
|
+
module Windows
|
5
|
+
# The Mailslot module contains functions and constants related to the
|
6
|
+
# Windows mailslot IPC mechanism.
|
7
|
+
module Mailslot
|
8
|
+
API.auto_namespace = 'Windows::Mailslot'
|
9
|
+
API.auto_constant = true
|
10
|
+
API.auto_method = true
|
11
|
+
API.auto_unicode = true
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# Constants
|
16
|
+
|
17
|
+
MAILSLOT_WAIT_FOREVER = 0xFFFFFFFF
|
18
|
+
MAILSLOT_NO_MESSAGE = 0xFFFFFFFF
|
19
|
+
|
20
|
+
API.new('CreateMailslot', 'SLLP', 'L')
|
21
|
+
API.new('GetMailslotInfo', 'LPPPP', 'B')
|
22
|
+
API.new('SetMailslotInfo', 'LL', 'B')
|
23
|
+
end
|
24
|
+
end
|
data/lib/windows/memory.rb
CHANGED
@@ -1,128 +1,128 @@
|
|
1
|
-
require 'windows/api'
|
2
|
-
|
3
|
-
module Windows
|
4
|
-
module Memory
|
5
|
-
API.auto_namespace = 'Windows::Memory'
|
6
|
-
API.auto_constant = true
|
7
|
-
API.auto_method = true
|
8
|
-
API.auto_unicode = false
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
GHND = 0x0042
|
13
|
-
GMEM_FIXED = 0x0000
|
14
|
-
GMEM_MOVABLE = 0002
|
15
|
-
GMEM_ZEROINIT = 0x0040
|
16
|
-
GPTR = 0x0040
|
17
|
-
|
18
|
-
HEAP_NO_SERIALIZE = 0x00000001
|
19
|
-
HEAP_GENERATE_EXCEPTIONS = 0x00000004
|
20
|
-
HEAP_ZERO_MEMORY = 0x00000008
|
21
|
-
HEAP_REALLOC_IN_PLACE_ONLY = 0x00000010
|
22
|
-
HEAP_CREATE_ENABLE_EXECUTE = 0x00040000
|
23
|
-
|
24
|
-
MEM_COMMIT = 0x1000
|
25
|
-
MEM_RESERVE = 0x2000
|
26
|
-
MEM_DECOMMIT = 0x4000
|
27
|
-
MEM_RELEASE = 0x8000
|
28
|
-
MEM_FREE = 0x10000
|
29
|
-
MEM_PRIVATE = 0x20000
|
30
|
-
MEM_MAPPED = 0x40000
|
31
|
-
MEM_RESET = 0x80000
|
32
|
-
MEM_TOP_DOWN = 0x100000
|
33
|
-
MEM_WRITE_WATCH = 0x200000
|
34
|
-
MEM_PHYSICAL = 0x400000
|
35
|
-
MEM_LARGE_PAGES = 0x20000000
|
36
|
-
MEM_4MB_PAGES = 0x80000000
|
37
|
-
|
38
|
-
PAGE_NOACCESS = 0x01
|
39
|
-
PAGE_READONLY = 0x02
|
40
|
-
PAGE_READWRITE = 0x04
|
41
|
-
PAGE_WRITECOPY = 0x08
|
42
|
-
PAGE_EXECUTE = 0x10
|
43
|
-
PAGE_EXECUTE_READ = 0x20
|
44
|
-
PAGE_EXECUTE_READWRITE = 0x40
|
45
|
-
PAGE_EXECUTE_WRITECOPY = 0x80
|
46
|
-
PAGE_GUARD = 0x100
|
47
|
-
PAGE_NOCACHE = 0x200
|
48
|
-
PAGE_WRITECOMBINE = 0x400
|
49
|
-
|
50
|
-
SEC_FILE = 0x800000
|
51
|
-
SEC_IMAGE = 0x1000000
|
52
|
-
SEC_VLM = 0x2000000
|
53
|
-
SEC_RESERVE = 0x4000000
|
54
|
-
SEC_COMMIT = 0x8000000
|
55
|
-
SEC_NOCACHE = 0x10000000
|
56
|
-
|
57
|
-
LMEM_FIXED = 0x0000
|
58
|
-
LMEM_MOVEABLE = 0x0002
|
59
|
-
LMEM_NOCOMPACT = 0x0010
|
60
|
-
LMEM_NODISCARD = 0x0020
|
61
|
-
LMEM_ZEROINIT = 0x0040
|
62
|
-
LMEM_MODIFY = 0x0080
|
63
|
-
LMEM_DISCARDABLE = 0x0F00
|
64
|
-
LMEM_VALID_FLAGS = 0x0F72
|
65
|
-
LMEM_INVALID_HANDLE = 0x8000
|
66
|
-
LMEM_DISCARDED = 0x4000
|
67
|
-
LMEM_LOCKCOUNT = 0x00FF
|
68
|
-
|
69
|
-
API.new('GlobalAlloc', 'LL', 'L')
|
70
|
-
API.new('GlobalFlags', 'L', 'L')
|
71
|
-
API.new('GlobalFree', 'L', 'L')
|
72
|
-
API.new('GlobalHandle', 'P', 'L')
|
73
|
-
API.new('GlobalLock', 'L', 'L')
|
74
|
-
API.new('GlobalMemoryStatus', 'P', 'V')
|
75
|
-
API.new('GlobalMemoryStatusEx', 'P', 'V')
|
76
|
-
API.new('GlobalReAlloc', 'LLL', 'L')
|
77
|
-
API.new('GlobalSize', 'L', 'L')
|
78
|
-
API.new('GlobalUnlock', 'L', 'L')
|
79
|
-
|
80
|
-
API.new('GetProcessHeap', 'V', 'L')
|
81
|
-
API.new('GetProcessHeaps', 'LP', 'L')
|
82
|
-
API.new('HeapAlloc', 'LLL', 'P')
|
83
|
-
API.new('HeapCompact', 'LL', 'L')
|
84
|
-
API.new('HeapCreate', 'LLL', 'L')
|
85
|
-
API.new('HeapDestroy', 'L', 'B')
|
86
|
-
API.new('HeapFree', 'LLL', 'B')
|
87
|
-
API.new('HeapLock', 'L', 'B')
|
88
|
-
API.new('HeapReAlloc', 'LLLL', 'L')
|
89
|
-
API.new('HeapSize', 'LLL', 'L')
|
90
|
-
API.new('HeapUnlock', 'L', 'B')
|
91
|
-
API.new('HeapValidate', 'LLL', 'B')
|
92
|
-
API.new('HeapWalk', 'LP', 'B')
|
93
|
-
|
94
|
-
API.new('LocalAlloc', 'LL', 'L')
|
95
|
-
API.new('LocalFlags', 'L', 'L')
|
96
|
-
API.new('LocalFree', 'L', 'L')
|
97
|
-
API.new('LocalHandle', 'L', 'L')
|
98
|
-
API.new('LocalLock', 'L', 'L')
|
99
|
-
API.new('LocalReAlloc', 'LLL', 'L')
|
100
|
-
API.new('LocalSize', 'L', 'L')
|
101
|
-
API.new('LocalUnlock', 'L', 'B')
|
102
|
-
|
103
|
-
API.new('VirtualAlloc', 'LLLL', 'L')
|
104
|
-
API.new('VirtualAllocEx', 'LLLLL', 'L')
|
105
|
-
API.new('VirtualFree', 'LLL', 'B')
|
106
|
-
API.new('VirtualFreeEx', 'LLLL', 'B')
|
107
|
-
API.new('VirtualLock', 'LL', 'B')
|
108
|
-
API.new('VirtualProtect', 'LLLP', 'B')
|
109
|
-
API.new('VirtualProtectEx', 'LLLLP', 'B')
|
110
|
-
API.new('VirtualQuery', 'LPL', 'L')
|
111
|
-
API.new('VirtualQueryEx', 'LLPL', 'L')
|
112
|
-
API.new('VirtualUnlock', 'LL', 'B')
|
113
|
-
API.new('RtlZeroMemory', 'PL', 'L')
|
114
|
-
|
115
|
-
# The LocalDiscard macro from winbase.h
|
116
|
-
def LocalDiscard(mem_loc)
|
117
|
-
LocalReAlloc(mem_loc, 0, LMEM_MOVEABLE)
|
118
|
-
end
|
119
|
-
|
120
|
-
# Windows XP or later
|
121
|
-
begin
|
122
|
-
API.new('HeapQueryInformation', 'LIPLL', 'B')
|
123
|
-
API.new('HeapSetInformation', 'LIPL', 'B')
|
124
|
-
rescue Win32::API::LoadLibraryError
|
125
|
-
# Do nothing - you must check for their existence
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
1
|
+
require 'windows/api'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Memory
|
5
|
+
API.auto_namespace = 'Windows::Memory'
|
6
|
+
API.auto_constant = true
|
7
|
+
API.auto_method = true
|
8
|
+
API.auto_unicode = false
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
GHND = 0x0042
|
13
|
+
GMEM_FIXED = 0x0000
|
14
|
+
GMEM_MOVABLE = 0002
|
15
|
+
GMEM_ZEROINIT = 0x0040
|
16
|
+
GPTR = 0x0040
|
17
|
+
|
18
|
+
HEAP_NO_SERIALIZE = 0x00000001
|
19
|
+
HEAP_GENERATE_EXCEPTIONS = 0x00000004
|
20
|
+
HEAP_ZERO_MEMORY = 0x00000008
|
21
|
+
HEAP_REALLOC_IN_PLACE_ONLY = 0x00000010
|
22
|
+
HEAP_CREATE_ENABLE_EXECUTE = 0x00040000
|
23
|
+
|
24
|
+
MEM_COMMIT = 0x1000
|
25
|
+
MEM_RESERVE = 0x2000
|
26
|
+
MEM_DECOMMIT = 0x4000
|
27
|
+
MEM_RELEASE = 0x8000
|
28
|
+
MEM_FREE = 0x10000
|
29
|
+
MEM_PRIVATE = 0x20000
|
30
|
+
MEM_MAPPED = 0x40000
|
31
|
+
MEM_RESET = 0x80000
|
32
|
+
MEM_TOP_DOWN = 0x100000
|
33
|
+
MEM_WRITE_WATCH = 0x200000
|
34
|
+
MEM_PHYSICAL = 0x400000
|
35
|
+
MEM_LARGE_PAGES = 0x20000000
|
36
|
+
MEM_4MB_PAGES = 0x80000000
|
37
|
+
|
38
|
+
PAGE_NOACCESS = 0x01
|
39
|
+
PAGE_READONLY = 0x02
|
40
|
+
PAGE_READWRITE = 0x04
|
41
|
+
PAGE_WRITECOPY = 0x08
|
42
|
+
PAGE_EXECUTE = 0x10
|
43
|
+
PAGE_EXECUTE_READ = 0x20
|
44
|
+
PAGE_EXECUTE_READWRITE = 0x40
|
45
|
+
PAGE_EXECUTE_WRITECOPY = 0x80
|
46
|
+
PAGE_GUARD = 0x100
|
47
|
+
PAGE_NOCACHE = 0x200
|
48
|
+
PAGE_WRITECOMBINE = 0x400
|
49
|
+
|
50
|
+
SEC_FILE = 0x800000
|
51
|
+
SEC_IMAGE = 0x1000000
|
52
|
+
SEC_VLM = 0x2000000
|
53
|
+
SEC_RESERVE = 0x4000000
|
54
|
+
SEC_COMMIT = 0x8000000
|
55
|
+
SEC_NOCACHE = 0x10000000
|
56
|
+
|
57
|
+
LMEM_FIXED = 0x0000
|
58
|
+
LMEM_MOVEABLE = 0x0002
|
59
|
+
LMEM_NOCOMPACT = 0x0010
|
60
|
+
LMEM_NODISCARD = 0x0020
|
61
|
+
LMEM_ZEROINIT = 0x0040
|
62
|
+
LMEM_MODIFY = 0x0080
|
63
|
+
LMEM_DISCARDABLE = 0x0F00
|
64
|
+
LMEM_VALID_FLAGS = 0x0F72
|
65
|
+
LMEM_INVALID_HANDLE = 0x8000
|
66
|
+
LMEM_DISCARDED = 0x4000
|
67
|
+
LMEM_LOCKCOUNT = 0x00FF
|
68
|
+
|
69
|
+
API.new('GlobalAlloc', 'LL', 'L')
|
70
|
+
API.new('GlobalFlags', 'L', 'L')
|
71
|
+
API.new('GlobalFree', 'L', 'L')
|
72
|
+
API.new('GlobalHandle', 'P', 'L')
|
73
|
+
API.new('GlobalLock', 'L', 'L')
|
74
|
+
API.new('GlobalMemoryStatus', 'P', 'V')
|
75
|
+
API.new('GlobalMemoryStatusEx', 'P', 'V')
|
76
|
+
API.new('GlobalReAlloc', 'LLL', 'L')
|
77
|
+
API.new('GlobalSize', 'L', 'L')
|
78
|
+
API.new('GlobalUnlock', 'L', 'L')
|
79
|
+
|
80
|
+
API.new('GetProcessHeap', 'V', 'L')
|
81
|
+
API.new('GetProcessHeaps', 'LP', 'L')
|
82
|
+
API.new('HeapAlloc', 'LLL', 'P')
|
83
|
+
API.new('HeapCompact', 'LL', 'L')
|
84
|
+
API.new('HeapCreate', 'LLL', 'L')
|
85
|
+
API.new('HeapDestroy', 'L', 'B')
|
86
|
+
API.new('HeapFree', 'LLL', 'B')
|
87
|
+
API.new('HeapLock', 'L', 'B')
|
88
|
+
API.new('HeapReAlloc', 'LLLL', 'L')
|
89
|
+
API.new('HeapSize', 'LLL', 'L')
|
90
|
+
API.new('HeapUnlock', 'L', 'B')
|
91
|
+
API.new('HeapValidate', 'LLL', 'B')
|
92
|
+
API.new('HeapWalk', 'LP', 'B')
|
93
|
+
|
94
|
+
API.new('LocalAlloc', 'LL', 'L')
|
95
|
+
API.new('LocalFlags', 'L', 'L')
|
96
|
+
API.new('LocalFree', 'L', 'L')
|
97
|
+
API.new('LocalHandle', 'L', 'L')
|
98
|
+
API.new('LocalLock', 'L', 'L')
|
99
|
+
API.new('LocalReAlloc', 'LLL', 'L')
|
100
|
+
API.new('LocalSize', 'L', 'L')
|
101
|
+
API.new('LocalUnlock', 'L', 'B')
|
102
|
+
|
103
|
+
API.new('VirtualAlloc', 'LLLL', 'L')
|
104
|
+
API.new('VirtualAllocEx', 'LLLLL', 'L')
|
105
|
+
API.new('VirtualFree', 'LLL', 'B')
|
106
|
+
API.new('VirtualFreeEx', 'LLLL', 'B')
|
107
|
+
API.new('VirtualLock', 'LL', 'B')
|
108
|
+
API.new('VirtualProtect', 'LLLP', 'B')
|
109
|
+
API.new('VirtualProtectEx', 'LLLLP', 'B')
|
110
|
+
API.new('VirtualQuery', 'LPL', 'L')
|
111
|
+
API.new('VirtualQueryEx', 'LLPL', 'L')
|
112
|
+
API.new('VirtualUnlock', 'LL', 'B')
|
113
|
+
API.new('RtlZeroMemory', 'PL', 'L')
|
114
|
+
|
115
|
+
# The LocalDiscard macro from winbase.h
|
116
|
+
def LocalDiscard(mem_loc)
|
117
|
+
LocalReAlloc(mem_loc, 0, LMEM_MOVEABLE)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Windows XP or later
|
121
|
+
begin
|
122
|
+
API.new('HeapQueryInformation', 'LIPLL', 'B')
|
123
|
+
API.new('HeapSetInformation', 'LIPL', 'B')
|
124
|
+
rescue Win32::API::LoadLibraryError
|
125
|
+
# Do nothing - you must check for their existence
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|