windows-pr 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,15 +1,15 @@
1
- require 'windows/api'
2
-
3
- module Windows
4
- module FileSystem
5
- API.auto_namespace = 'Windows::FileSystem'
6
- API.auto_constant = true
7
- API.auto_method = true
8
- API.auto_unicode = true
9
-
10
- private
11
-
12
- API.new('GetDiskFreeSpace', 'SPPPP', 'B')
13
- API.new('GetDiskFreeSpaceEx', 'SPPP', 'B')
14
- end
15
- end
1
+ require 'windows/api'
2
+
3
+ module Windows
4
+ module FileSystem
5
+ API.auto_namespace = 'Windows::FileSystem'
6
+ API.auto_constant = true
7
+ API.auto_method = true
8
+ API.auto_unicode = true
9
+
10
+ private
11
+
12
+ API.new('GetDiskFreeSpace', 'SPPPP', 'B')
13
+ API.new('GetDiskFreeSpaceEx', 'SPPP', 'B')
14
+ end
15
+ end
@@ -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
@@ -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
@@ -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
@@ -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 = 0x80000000200000
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