windows-pr 0.2.0 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +47 -2
- data/MANIFEST +13 -0
- data/README +11 -0
- data/doc/conversion_guide.txt +2 -2
- data/lib/windows/clipboard.rb +0 -33
- data/lib/windows/console.rb +323 -0
- data/lib/windows/device_io.rb +17 -70
- data/lib/windows/directory.rb +80 -0
- data/lib/windows/error.rb +260 -39
- data/lib/windows/eventlog.rb +120 -0
- data/lib/windows/file.rb +89 -33
- data/lib/windows/handle.rb +0 -16
- data/lib/windows/library.rb +76 -0
- data/lib/windows/limits.rb +13 -0
- data/lib/windows/memory.rb +58 -33
- data/lib/windows/msvcrt/buffer.rb +1 -1
- data/lib/windows/msvcrt/string.rb +46 -0
- data/lib/windows/national.rb +557 -0
- data/lib/windows/path.rb +1 -77
- data/lib/windows/pipe.rb +77 -0
- data/lib/windows/process.rb +171 -0
- data/lib/windows/registry.rb +238 -0
- data/lib/windows/security.rb +89 -0
- data/lib/windows/service.rb +183 -0
- data/lib/windows/shell.rb +88 -0
- data/lib/windows/synchronize.rb +111 -11
- data/lib/windows/system_info.rb +70 -0
- data/lib/windows/unicode.rb +138 -0
- data/lib/windows/window.rb +22 -0
- data/test/tc_clipboard.rb +58 -0
- data/test/tc_console.rb +107 -0
- data/test/tc_eventlog.rb +65 -0
- data/test/tc_file.rb +75 -0
- data/test/tc_memory.rb +51 -0
- data/test/tc_pipe.rb +60 -0
- data/test/tc_process.rb +36 -0
- data/test/tc_registry.rb +36 -0
- data/test/tc_security.rb +111 -0
- data/test/tc_synchronize.rb +44 -6
- data/test/tc_unicode.rb +61 -0
- data/test/ts_all.rb +10 -1
- metadata +34 -5
data/lib/windows/path.rb
CHANGED
@@ -1,79 +1,3 @@
|
|
1
|
-
######################################################################
|
2
|
-
# path.rb
|
3
|
-
#
|
4
|
-
# Defines the following functions:
|
5
|
-
#
|
6
|
-
# PathAddBackslash()
|
7
|
-
# PathAddExtension()
|
8
|
-
# PathAppend()
|
9
|
-
# PathBuildRoot()
|
10
|
-
# PathCanonicalize()
|
11
|
-
# PathCombine()
|
12
|
-
# PathCommonPrefix()
|
13
|
-
# PathCompactPath()
|
14
|
-
# PathCompactPathEx()
|
15
|
-
# PathCreateFromUrl()
|
16
|
-
# PathFileExists()
|
17
|
-
# PathFindExtension()
|
18
|
-
# PathFindFileName()
|
19
|
-
# PathFindNextComponent()
|
20
|
-
# PathFindOnPath()
|
21
|
-
# PathFindSuffixArray()
|
22
|
-
# PathGetArgs()
|
23
|
-
# PathGetCharType()
|
24
|
-
# PathGetDriveNumber()
|
25
|
-
# PathIsContentType()
|
26
|
-
# PathIsDirectory()
|
27
|
-
# PathIsDirectoryEmpty()
|
28
|
-
# PathIsFileSpec()
|
29
|
-
# PathIsHTMLFile() - BROKEN
|
30
|
-
# PathIsLFNFileSpec()
|
31
|
-
# PathIsNetworkPath()
|
32
|
-
# PathIsPrefix()
|
33
|
-
# PathIsRelative()
|
34
|
-
# PathIsRoot()
|
35
|
-
# PathIsSameRoot()
|
36
|
-
# PathIsSystemFolder()
|
37
|
-
# PathIsUNC()
|
38
|
-
# PathIsUNCServer()
|
39
|
-
# PathIsUNCServerShare()
|
40
|
-
# PathIsURL()
|
41
|
-
# PathMakePretty()
|
42
|
-
# PathMakeSystemFolder()
|
43
|
-
# PathMatchSpec()
|
44
|
-
# PathParseIconLocation()
|
45
|
-
# PathQuoteSpaces()
|
46
|
-
# PathRelativePathTo()
|
47
|
-
# PathRemoveArgs()
|
48
|
-
# PathRemoveBackslash()
|
49
|
-
# PathRemoveBlanks()
|
50
|
-
# PathRemoveExtension()
|
51
|
-
# PathRemoveFileSpec()
|
52
|
-
# PathRenameExtension()
|
53
|
-
# PathSearchAndQualify()
|
54
|
-
# PathSetDlgItemPath()
|
55
|
-
# PathSkipRoot()
|
56
|
-
# PathStripPath()
|
57
|
-
# PathStripToRoot()
|
58
|
-
# PathUndecorate()
|
59
|
-
# PathUnExpandEnvStrings()
|
60
|
-
# PathUnmakeSystemFolder()
|
61
|
-
# PathUnquoteSpaces()
|
62
|
-
#
|
63
|
-
# Defines the following constants:
|
64
|
-
#
|
65
|
-
# GCT_INVALID
|
66
|
-
# GCT_LFNCHAR
|
67
|
-
# GCT_SHORTCHAR
|
68
|
-
# GCT_WILD
|
69
|
-
# GCT_SEPARATOR
|
70
|
-
#
|
71
|
-
# Notes:
|
72
|
-
#
|
73
|
-
# The PathIsHTMLFile() function does not appear to be exported in the
|
74
|
-
# shlwapi.dll file that is currently (March, 2006) shipped with the
|
75
|
-
# free compiler libs from Microsoft.
|
76
|
-
######################################################################
|
77
1
|
require 'Win32API'
|
78
2
|
|
79
3
|
module Windows
|
@@ -160,7 +84,7 @@ module Windows
|
|
160
84
|
end
|
161
85
|
|
162
86
|
def PathCanonicalize(dst, src)
|
163
|
-
PathCanonicalize.call(dst, src)
|
87
|
+
PathCanonicalize.call(dst, src) > 0
|
164
88
|
end
|
165
89
|
|
166
90
|
def PathCombine(dest, dir, file)
|
data/lib/windows/pipe.rb
ADDED
@@ -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
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require 'Win32API'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Process
|
5
|
+
PROCESS_ALL_ACCESS = 0x1F0FFF
|
6
|
+
PROCESS_CREATE_PROCESS = 0x0080
|
7
|
+
PROCESS_CREATE_THREAD = 0x0002
|
8
|
+
PROCESS_DUP_HANDLE = 0x0040
|
9
|
+
PROCESS_QUERY_INFORMATION = 0x0400
|
10
|
+
PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
|
11
|
+
PROCESS_SET_QUOTA = 0x0100
|
12
|
+
PROCESS_SET_INFORMATION = 0x0200
|
13
|
+
PROCESS_SUSPEND_RESUME = 0x0800
|
14
|
+
PROCESS_TERMINATE = 0x0001
|
15
|
+
PROCESS_VM_OPERATION = 0x0008
|
16
|
+
PROCESS_VM_READ = 0x0010
|
17
|
+
PROCESS_VM_WRITE = 0x0020
|
18
|
+
SYNCHRONIZE = 1048576
|
19
|
+
STILL_ACTIVE = 259
|
20
|
+
|
21
|
+
ABOVE_NORMAL_PRIORITY_CLASS = 0x00008000
|
22
|
+
BELOW_NORMAL_PRIORITY_CLASS = 0x00004000
|
23
|
+
HIGH_PRIORITY_CLASS = 0x00000080
|
24
|
+
IDLE_PRIORITY_CLASS = 0x00000040
|
25
|
+
NORMAL_PRIORITY_CLASS = 0x00000020
|
26
|
+
REALTIME_PRIORITY_CLASS = 0x00000100
|
27
|
+
|
28
|
+
# Process creation flags
|
29
|
+
CREATE_BREAKAWAY_FROM_JOB = 0x01000000
|
30
|
+
CREATE_DEFAULT_ERROR_MODE = 0x04000000
|
31
|
+
CREATE_NEW_CONSOLE = 0x00000010
|
32
|
+
CREATE_NEW_PROCESS_GROUP = 0x00000200
|
33
|
+
CREATE_NO_WINDOW = 0x08000000
|
34
|
+
CREATE_PRESERVE_CODE_AUTHZ_LEVEL = 0x02000000
|
35
|
+
CREATE_SEPARATE_WOW_VDM = 0x00000800
|
36
|
+
CREATE_SHARED_WOW_VDM = 0x00001000
|
37
|
+
CREATE_SUSPENDED = 0x00000004
|
38
|
+
CREATE_UNICODE_ENVIRONMENT = 0x00000400
|
39
|
+
DEBUG_ONLY_THIS_PROCESS = 0x00000002
|
40
|
+
DEBUG_PROCESS = 0x00000001
|
41
|
+
DETACHED_PROCESS = 0x00000008
|
42
|
+
|
43
|
+
STARTF_USESHOWWINDOW = 0x00000001
|
44
|
+
STARTF_USESIZE = 0x00000002
|
45
|
+
STARTF_USEPOSITION = 0x00000004
|
46
|
+
STARTF_USECOUNTCHARS = 0x00000008
|
47
|
+
STARTF_USEFILLATTRIBUTE = 0x00000010
|
48
|
+
STARTF_RUNFULLSCREEN = 0x00000020
|
49
|
+
STARTF_FORCEONFEEDBACK = 0x00000040
|
50
|
+
STARTF_FORCEOFFFEEDBACK = 0x00000080
|
51
|
+
STARTF_USESTDHANDLES = 0x00000100
|
52
|
+
STARTF_USEHOTKEY = 0x00000200
|
53
|
+
|
54
|
+
CreateProcess = Win32API.new('kernel32', 'CreateProcess', 'LPLLLLLPPP', 'I')
|
55
|
+
CreateRemoteThread = Win32API.new('kernel32', 'CreateRemoteThread', 'LPLLPLP', 'L')
|
56
|
+
CreateThread = Win32API.new('kernel32', 'CreateThread', 'PLPPLP', 'L')
|
57
|
+
ExitProcess = Win32API.new('kernel32', 'ExitProcess', 'L', 'V')
|
58
|
+
GetCommandLine = Win32API.new('kernel32', 'GetCommandLine', 'V', 'P')
|
59
|
+
GetCurrentProcess = Win32API.new('kernel32', 'GetCurrentProcess', 'V', 'L')
|
60
|
+
GetCurrentProcessId = Win32API.new('kernel32', 'GetCurrentProcessId', 'V', 'L')
|
61
|
+
GetEnvironmentStrings = Win32API.new('kernel32', 'GetEnvironmentStrings', 'V', 'L')
|
62
|
+
GetEnvironmentVariable = Win32API.new('kernel32', 'GetEnvironmentVariable', 'PPL', 'L')
|
63
|
+
GetExitCodeProcess = Win32API.new('kernel32', 'GetExitCodeProcess', 'LP', 'I')
|
64
|
+
GetPriorityClass = Win32API.new('kernel32', 'GetPriorityClass', 'L', 'L')
|
65
|
+
GetProcessTimes = Win32API.new('kernel32', 'GetProcessTimes', 'LPPPP', 'I')
|
66
|
+
GetStartupInfo = Win32API.new('kernel32', 'GetStartupInfo', 'P', 'V')
|
67
|
+
OpenProcess = Win32API.new('kernel32', 'OpenProcess', 'LIL', 'L')
|
68
|
+
SetEnvironmentVariable = Win32API.new('kernel32', 'SetEnvironmentVariable', 'PP', 'I')
|
69
|
+
Sleep = Win32API.new('kernel32', 'Sleep', 'L', 'V')
|
70
|
+
SleepEx = Win32API.new('kernel32', 'SleepEx', 'LI', 'L')
|
71
|
+
TerminateProcess = Win32API.new('kernel32', 'TerminateProcess', 'LL', 'I')
|
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
|
82
|
+
|
83
|
+
def CreateProcess(app, cmd, pattr, tattr, handles, flags, env, dir, sinfo, pinfo)
|
84
|
+
CreateProcess.call(app, cmd, pattr, tattr, handles, flags, env, dir, sinfo, pinfo) != 0
|
85
|
+
end
|
86
|
+
|
87
|
+
def CreateRemoteThread(handle, tattr, size, start, param, flags, tid)
|
88
|
+
CreateRemoteThread.call(handle, tattr, size, start, param, flags, tid)
|
89
|
+
end
|
90
|
+
|
91
|
+
def CreateThread(attr, size, addr, param, flags, id)
|
92
|
+
CreateThread.call(attr, size, addr, param, flags, id)
|
93
|
+
end
|
94
|
+
|
95
|
+
def ExitProcess(exit_code)
|
96
|
+
ExitProcess.call(exit_code)
|
97
|
+
end
|
98
|
+
|
99
|
+
def GetCommandLine
|
100
|
+
GetCommandLine.call
|
101
|
+
end
|
102
|
+
|
103
|
+
def GetCurrentProcess()
|
104
|
+
GetCurrentProcess.call
|
105
|
+
end
|
106
|
+
|
107
|
+
def GetCurrentProcessId()
|
108
|
+
GetCurrentProcessId.call
|
109
|
+
end
|
110
|
+
|
111
|
+
def GetEnvironmentStrings()
|
112
|
+
GetEnvironmentStrings.call
|
113
|
+
end
|
114
|
+
|
115
|
+
def GetEnvironmentVariable(name, buffer, size)
|
116
|
+
GetEnvironmentVariable.call(name, buffer, size)
|
117
|
+
end
|
118
|
+
|
119
|
+
def GetExitCodeProcess(handle, exit_code)
|
120
|
+
GetExitCodeProcess.call(handle, exit_code) != 0
|
121
|
+
end
|
122
|
+
|
123
|
+
def GetPriorityClass(handle)
|
124
|
+
GetPriorityClass.call(handle)
|
125
|
+
end
|
126
|
+
|
127
|
+
def GetProcessTimes(handle, t_creation, t_exit, t_kernel, t_user)
|
128
|
+
GetProcessTimes.call(handle, t_creation, t_exit, t_kernel, t_user) != 0
|
129
|
+
end
|
130
|
+
|
131
|
+
def GetStartupInfo(info_struct)
|
132
|
+
GetStartupInfo.call(info_struct)
|
133
|
+
end
|
134
|
+
|
135
|
+
def OpenProcess(access, handle, pid)
|
136
|
+
OpenProcess.call(access, handle, pid)
|
137
|
+
end
|
138
|
+
|
139
|
+
def SetEnvironmentVariable(name, value)
|
140
|
+
SetEnvironmentVariable.call(name, value)
|
141
|
+
end
|
142
|
+
|
143
|
+
def Sleep(milliseconds)
|
144
|
+
Sleep.call(milliseconds)
|
145
|
+
end
|
146
|
+
|
147
|
+
def SleepEx(milliseconds, alertable)
|
148
|
+
SleepEx.call(milliseconds, alertable)
|
149
|
+
end
|
150
|
+
|
151
|
+
def TerminateProcess(handle, exit_code)
|
152
|
+
TerminateProcess.call(handle, exit_code) != 0
|
153
|
+
end
|
154
|
+
|
155
|
+
def WaitForInputIdle(handle, milliseconds)
|
156
|
+
WaitForInputIdle.call(handle, milliseconds)
|
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
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
require 'windows/file'
|
2
|
+
|
3
|
+
module Windows
|
4
|
+
module Registry
|
5
|
+
include Windows::File
|
6
|
+
|
7
|
+
HKEY_CLASSES_ROOT = 0x80000000
|
8
|
+
KEY_CURRENT_USER = 0x80000001
|
9
|
+
HKEY_LOCAL_MACHINE = 0x80000002
|
10
|
+
HKEY_USERS = 0x80000003
|
11
|
+
HKEY_PERFORMANCE_DATA = 0x80000004
|
12
|
+
HKEY_PERFORMANCE_TEXT = 0x80000050
|
13
|
+
HKEY_PERFORMANCE_NLSTEXT = 0x80000060
|
14
|
+
HKEY_CURRENT_CONFIG = 0x80000005
|
15
|
+
HKEY_DYN_DATA = 0x80000006
|
16
|
+
|
17
|
+
KEY_QUERY_VALUE = 0x0001
|
18
|
+
KEY_SET_VALUE = 0x0002
|
19
|
+
KEY_CREATE_SUB_KEY = 0x0004
|
20
|
+
KEY_ENUMERATE_SUB_KEYS = 0x0008
|
21
|
+
KEY_NOTIFY = 0x0010
|
22
|
+
KEY_CREATE_LINK = 0x0020
|
23
|
+
KEY_WOW64_32KEY = 0x0200
|
24
|
+
KEY_WOW64_64KEY = 0x0100
|
25
|
+
KEY_WOW64_RES = 0x0300
|
26
|
+
|
27
|
+
KEY_READ = (STANDARD_RIGHTS_READ|KEY_QUERY_VALUE|KEY_ENUMERATE_SUB_KEYS|
|
28
|
+
KEY_NOTIFY) & (~SYNCHRONIZE)
|
29
|
+
|
30
|
+
KEY_WRITE = (STANDARD_RIGHTS_WRITE|KEY_SET_VALUE|
|
31
|
+
KEY_CREATE_SUB_KEY) & (~SYNCHRONIZE)
|
32
|
+
|
33
|
+
KEY_EXECUTE = KEY_READ & (~SYNCHRONIZE)
|
34
|
+
|
35
|
+
KEY_ALL_ACCESS = (STANDARD_RIGHTS_ALL|KEY_QUERY_VALUE|KEY_SET_VALUE|
|
36
|
+
KEY_CREATE_SUB_KEY|KEY_ENUMERATE_SUB_KEYS|KEY_NOTIFY|
|
37
|
+
KEY_CREATE_LINK) & (~SYNCHRONIZE)
|
38
|
+
|
39
|
+
REG_OPTION_RESERVED = 0
|
40
|
+
REG_OPTION_NON_VOLATILE = 0
|
41
|
+
REG_OPTION_VOLATILE = 1
|
42
|
+
REG_OPTION_CREATE_LINK = 2
|
43
|
+
REG_OPTION_BACKUP_RESTORE = 4
|
44
|
+
REG_OPTION_OPEN_LINK = 8
|
45
|
+
|
46
|
+
REG_LEGAL_OPTION = REG_OPTION_RESERVED|REG_OPTION_NON_VOLATILE|
|
47
|
+
REG_OPTION_VOLATILE|REG_OPTION_CREATE_LINK|REG_OPTION_BACKUP_RESTORE|
|
48
|
+
REG_OPTION_OPEN_LINK
|
49
|
+
|
50
|
+
REG_CREATED_NEW_KEY = 1
|
51
|
+
REG_OPENED_EXISTING_KEY = 2
|
52
|
+
|
53
|
+
REG_STANDARD_FORMAT = 1
|
54
|
+
REG_LATEST_FORMAT = 2
|
55
|
+
REG_NO_COMPRESSION = 4
|
56
|
+
|
57
|
+
REG_WHOLE_HIVE_VOLATILE = 1
|
58
|
+
REG_REFRESH_HIVE = 2
|
59
|
+
REG_NO_LAZY_FLUSH = 4
|
60
|
+
REG_FORCE_RESTORE = 8
|
61
|
+
|
62
|
+
REG_FORCE_UNLOAD = 1
|
63
|
+
|
64
|
+
REG_NOTIFY_CHANGE_NAME = 1
|
65
|
+
REG_NOTIFY_CHANGE_ATTRIBUTES = 2
|
66
|
+
REG_NOTIFY_CHANGE_LAST_SET = 4
|
67
|
+
REG_NOTIFY_CHANGE_SECURITY = 8
|
68
|
+
|
69
|
+
REG_LEGAL_CHANGE_FILTER = REG_NOTIFY_CHANGE_NAME|
|
70
|
+
REG_NOTIFY_CHANGE_ATTRIBUTES|REG_NOTIFY_CHANGE_LAST_SET|
|
71
|
+
REG_NOTIFY_CHANGE_SECURITY
|
72
|
+
|
73
|
+
REG_NONE = 0
|
74
|
+
REG_SZ = 1
|
75
|
+
REG_EXPAND_SZ = 2
|
76
|
+
REG_BINARY = 3
|
77
|
+
REG_DWORD = 4
|
78
|
+
REG_DWORD_LITTLE_ENDIAN = 4
|
79
|
+
REG_DWORD_BIG_ENDIAN = 5
|
80
|
+
REG_LINK = 6
|
81
|
+
REG_MULTI_SZ = 7
|
82
|
+
REG_RESOURCE_LIST = 8
|
83
|
+
REG_FULL_RESOURCE_DESCRIPTOR = 9
|
84
|
+
REG_RESOURCE_REQUIREMENTS_LIST = 10
|
85
|
+
REG_QWORD = 11
|
86
|
+
REG_QWORD_LITTLE_ENDIAN = 11
|
87
|
+
|
88
|
+
RegCloseKey = Win32API.new('advapi32', 'RegCloseKey', 'L', 'L')
|
89
|
+
RegConnectRegistry = Win32API.new('advapi32', 'RegConnectRegistry', 'PLP', 'L')
|
90
|
+
RegCreateKey = Win32API.new('advapi32', 'RegCreateKey', 'LPP', 'L')
|
91
|
+
RegCreateKeyEx = Win32API.new('advapi32', 'RegCreateKeyEx', 'LPLPLLPPP', 'L')
|
92
|
+
RegDeleteKey = Win32API.new('advapi32', 'RegDeleteKey', 'LP', 'L')
|
93
|
+
RegDeleteValue = Win32API.new('advapi32', 'RegDeleteValue', 'LP', 'L')
|
94
|
+
RegDisablePredefinedCache = Win32API.new('advapi32', 'RegDisablePredefinedCache', 'V', 'L')
|
95
|
+
RegEnumKey = Win32API.new('advapi32', 'RegEnumKey', 'LLPL', 'L')
|
96
|
+
RegEnumKeyEx = Win32API.new('advapi32', 'RegEnumKeyEx', 'LLPPPPP', 'L')
|
97
|
+
RegEnumValue = Win32API.new('advapi32', 'RegEnumValue', 'LLPPPPPP', 'L')
|
98
|
+
RegFlushKey = Win32API.new('advapi32', 'RegFlushKey', 'L', 'L')
|
99
|
+
RegLoadKey = Win32API.new('advapi32', 'RegLoadKey', 'LPP', 'L')
|
100
|
+
RegNotifyChangeKeyValue = Win32API.new('advapi32', 'RegNotifyChangeKeyValue', 'LILLI', 'L')
|
101
|
+
RegOpenCurrentUser = Win32API.new('advapi32', 'RegOpenCurrentUser', 'LP', 'L')
|
102
|
+
RegOpenKey = Win32API.new('advapi32', 'RegOpenKey', 'LPP', 'L')
|
103
|
+
RegOpenKeyEx = Win32API.new('advapi32', 'RegOpenKeyEx', 'LPLLP', 'L')
|
104
|
+
RegOpenUserClassesRoot = Win32API.new('advapi32', 'RegOpenUserClassesRoot', 'LLLP', 'L')
|
105
|
+
RegOverridePredefKey = Win32API.new('advapi32', 'RegOverridePredefKey', 'LL', 'L')
|
106
|
+
RegQueryInfoKey = Win32API.new('advapi32', 'RegQueryInfoKey', 'LPPPPPPPPPPP', 'L')
|
107
|
+
RegQueryMultipleValues = Win32API.new('advapi32', 'RegQueryMultipleValues', 'LPLPP', 'L')
|
108
|
+
RegQueryValueEx = Win32API.new('advapi32', 'RegQueryValueEx', 'LPPPPP', 'L')
|
109
|
+
RegReplaceKey = Win32API.new('advapi32', 'RegReplaceKey', 'LPPP', 'L')
|
110
|
+
RegRestoreKey = Win32API.new('advapi32', 'RegRestoreKey', 'LPL', 'L')
|
111
|
+
RegSaveKey = Win32API.new('advapi32', 'RegSaveKey', 'LPP', 'L')
|
112
|
+
RegSetValueEx = Win32API.new('advapi32', 'RegSetValueEx', 'LPLLPL', 'L')
|
113
|
+
RegUnLoadKey = Win32API.new('advapi32', 'RegUnLoadKey', 'LP', 'L')
|
114
|
+
|
115
|
+
# Windows XP or later
|
116
|
+
begin
|
117
|
+
RegSaveKeyEx = Win32API.new('advapi32', 'RegSaveKeyEx', 'LPPL', 'L')
|
118
|
+
rescue Exception
|
119
|
+
# Do nothing - not supported on current platform. It's up to you to
|
120
|
+
# check for the existence of the constant in your code.
|
121
|
+
end
|
122
|
+
|
123
|
+
def RegCloseKey(key)
|
124
|
+
RegCloseKey.call(key)
|
125
|
+
end
|
126
|
+
|
127
|
+
def RegConnectRegistry(machine, key, result)
|
128
|
+
RegConnectRegistry.call(machine, key, result)
|
129
|
+
end
|
130
|
+
|
131
|
+
def RegCreateKey(key, subkey, result)
|
132
|
+
RegCreateKey.call(key, subkey, result)
|
133
|
+
end
|
134
|
+
|
135
|
+
def RegCreateKeyEx(key, subkey, res, klass, opt, sam, sec, result, disp)
|
136
|
+
RegCreateKeyEx.call(key, subkey, res, klass, opt, sam, sec, result, disp)
|
137
|
+
end
|
138
|
+
|
139
|
+
def RegDeleteKey(key, subkey)
|
140
|
+
RegDeleteKey.call(key, subkey)
|
141
|
+
end
|
142
|
+
|
143
|
+
def RegDeleteValue(key, value)
|
144
|
+
RegDeleteValue.call(key, value)
|
145
|
+
end
|
146
|
+
|
147
|
+
def RegDisablePredefinedCache()
|
148
|
+
RegDisablePredefinedCache.call()
|
149
|
+
end
|
150
|
+
|
151
|
+
def RegEnumKey(key, index, name, size)
|
152
|
+
RegEnumKey.call(key, index, name, size)
|
153
|
+
end
|
154
|
+
|
155
|
+
def RegEnumKeyEx(key, index, name, size, res, klass, ksize, time)
|
156
|
+
RegEnumKeyEx.call(key, index, name, size, res, klass, ksize, time)
|
157
|
+
end
|
158
|
+
|
159
|
+
def RegEnumValue(key, index, value, size, res, type, data, dsize)
|
160
|
+
RegEnumValue.call(key, index, value, size, res, type, data, dsize)
|
161
|
+
end
|
162
|
+
|
163
|
+
def RegOpenKeyEx(key, subkey, options, sam, result)
|
164
|
+
RegOpenKeyEx.call(key, subkey, options, sam, result)
|
165
|
+
end
|
166
|
+
|
167
|
+
def RegFlushKey(key)
|
168
|
+
RegFlushKey.call(key)
|
169
|
+
end
|
170
|
+
|
171
|
+
def RegLoadKey(key, subkey, file)
|
172
|
+
RegLoadKey.call(key, subkey, file)
|
173
|
+
end
|
174
|
+
|
175
|
+
def RegNotifyChangeKeyValue(key, subtree, filter, event, async)
|
176
|
+
RegNotifyChangeKeyValue.call(key, subtree, filter, event, async)
|
177
|
+
end
|
178
|
+
|
179
|
+
def RegOpenCurrentUser(sam, result)
|
180
|
+
RegOpenCurrentUser.call(sam, result)
|
181
|
+
end
|
182
|
+
|
183
|
+
def RegOpenKeyEx(key, subkey, options, sam, result)
|
184
|
+
RegOpenKeyEx.call(key, subkey, options, sam, result)
|
185
|
+
end
|
186
|
+
|
187
|
+
def RegOpenUserClassesRoot(token, options, sam, result)
|
188
|
+
RegOpenUserClassesRoot.call(token, options, sam, result)
|
189
|
+
end
|
190
|
+
|
191
|
+
def RegOverridePredefKey(key, new_key)
|
192
|
+
RegOverridePredefKey.call(key, new_key)
|
193
|
+
end
|
194
|
+
|
195
|
+
def RegQueryInfoKey(key, klass, ksize, res, subkeys, maxkey, maxklass,
|
196
|
+
values, maxname, maxvalue, sec, time)
|
197
|
+
RegQueryInfoKey.call(key, klass, ksize, res, subkeys, maxkey, maxklass,
|
198
|
+
values, maxname, maxvalue, sec, time)
|
199
|
+
end
|
200
|
+
|
201
|
+
def RegQueryMultipleValues(key, val_list, num_vals, buf, size)
|
202
|
+
RegQueryMultipleValues.call(key, val_list, num_vals, buf, size)
|
203
|
+
end
|
204
|
+
|
205
|
+
def RegQueryValueEx(key, value, res, type, data, cbdata)
|
206
|
+
RegQueryValueEx.call(key, value, res, type, data, cbdata)
|
207
|
+
end
|
208
|
+
|
209
|
+
def RegReplaceKey(key, subkey, newfile, oldfile)
|
210
|
+
RegReplaceKey.call(key, subkey, newfile, oldfile)
|
211
|
+
end
|
212
|
+
|
213
|
+
def RegRestoreKey(key, file, flags)
|
214
|
+
RegRestoreKey.call(key, file, flags)
|
215
|
+
end
|
216
|
+
|
217
|
+
def RegSaveKey(key, file, sec)
|
218
|
+
RegSaveKey.call(key, file, sec)
|
219
|
+
end
|
220
|
+
|
221
|
+
def RegSetValueEx(key, value, res, type, data, size)
|
222
|
+
RegSetValueEx.call(key, value, res, type, data, size)
|
223
|
+
end
|
224
|
+
|
225
|
+
def RegUnLoadKey(key, subkey)
|
226
|
+
RegUnLoadKey.call(key, subkey)
|
227
|
+
end
|
228
|
+
|
229
|
+
# Windows XP or later
|
230
|
+
begin
|
231
|
+
def RegSaveKeyEx(key, file, sec, flags)
|
232
|
+
RegSaveKeyEx.call(key, file, sec, flags)
|
233
|
+
end
|
234
|
+
rescue Exception
|
235
|
+
# Do nothing - not supported on current platform
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|