Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
5c9526cb
Commit
5c9526cb
authored
Sep 06, 2015
by
Thomas Faller
Committed by
Alexandre Julliard
Sep 07, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reg: Implement binary data add operation.
parent
ffb4d151
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
3 deletions
+46
-3
reg.c
programs/reg/reg.c
+43
-0
reg.c
programs/reg/tests/reg.c
+3
-3
No files found.
programs/reg/reg.c
View file @
5c9526cb
...
...
@@ -158,6 +158,19 @@ static DWORD wchar_get_type(const WCHAR *type_name)
return
~
0u
;
}
/* hexchar_to_byte from programs/regedit/hexedit.c */
static
inline
BYTE
hexchar_to_byte
(
WCHAR
ch
)
{
if
(
ch
>=
'0'
&&
ch
<=
'9'
)
return
ch
-
'0'
;
else
if
(
ch
>=
'a'
&&
ch
<=
'f'
)
return
ch
-
'a'
+
10
;
else
if
(
ch
>=
'A'
&&
ch
<=
'F'
)
return
ch
-
'A'
+
10
;
else
return
-
1
;
}
static
LPBYTE
get_regdata
(
LPWSTR
data
,
DWORD
reg_type
,
WCHAR
separator
,
DWORD
*
reg_count
)
{
LPBYTE
out_data
=
NULL
;
...
...
@@ -187,6 +200,36 @@ static LPBYTE get_regdata(LPWSTR data, DWORD reg_type, WCHAR separator, DWORD *r
((
LPDWORD
)
out_data
)[
0
]
=
val
;
break
;
}
case
REG_BINARY
:
{
static
const
WCHAR
nohex
[]
=
{
'E'
,
'r'
,
'r'
,
'o'
,
'r'
,
':'
,
' '
,
'/'
,
'd'
,
' '
,
'r'
,
'e'
,
'q'
,
'u'
,
'i'
,
'r'
,
'e'
,
's'
,
' '
,
'h'
,
'e'
,
'x'
,
' '
,
'd'
,
'a'
,
't'
,
'a'
,
'.'
,
'\n'
,
0
};
BYTE
hex0
,
hex1
;
int
i
=
0
,
destByteIndex
=
0
,
datalen
=
lstrlenW
(
data
);
*
reg_count
=
((
datalen
+
datalen
%
2
)
/
2
)
*
sizeof
(
BYTE
);
out_data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
*
reg_count
);
if
(
datalen
%
2
)
{
hex1
=
hexchar_to_byte
(
data
[
i
++
]);
if
(
hex1
==
0xFF
)
goto
no_hex_data
;
out_data
[
destByteIndex
++
]
=
hex1
;
}
for
(;
i
+
1
<
datalen
;
i
+=
2
)
{
hex0
=
hexchar_to_byte
(
data
[
i
]);
hex1
=
hexchar_to_byte
(
data
[
i
+
1
]);
if
(
hex0
==
0xFF
||
hex1
==
0xFF
)
goto
no_hex_data
;
out_data
[
destByteIndex
++
]
=
(
hex0
<<
4
)
|
hex1
;
}
break
;
no_hex_data:
/* cleanup, print error */
HeapFree
(
GetProcessHeap
(),
0
,
out_data
);
reg_printfW
(
nohex
);
out_data
=
NULL
;
break
;
}
default:
{
static
const
WCHAR
unhandled
[]
=
{
'U'
,
'n'
,
'h'
,
'a'
,
'n'
,
'd'
,
'l'
,
'e'
,
'd'
,
' '
,
'T'
,
'y'
,
'p'
,
'e'
,
' '
,
'0'
,
'x'
,
'%'
,
'x'
,
' '
,
' '
,
'd'
,
'a'
,
't'
,
'a'
,
' '
,
'%'
,
's'
,
'\n'
,
0
};
...
...
programs/reg/tests/reg.c
View file @
5c9526cb
...
...
@@ -214,7 +214,7 @@ static void test_add(void)
run_reg_exe
(
"reg add HKEY_CURRENT_USER
\\
"
KEY_BASE
" /ve /t REG_BINARY /d deadbeef /f"
,
&
r
);
ok
(
r
==
REG_EXIT_SUCCESS
,
"got exit code %u
\n
"
,
r
);
dword
=
0xefbeadde
;
verify_reg
(
hkey
,
""
,
REG_BINARY
,
&
dword
,
sizeof
(
DWORD
),
TODO_REG_SIZE
);
verify_reg
(
hkey
,
""
,
REG_BINARY
,
&
dword
,
sizeof
(
DWORD
),
0
);
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_BINARY /v bin1 /f /d 0xDeAdBeEf"
,
&
r
);
todo_wine
ok
(
r
==
REG_EXIT_FAILURE
,
"got exit code %u
\n
"
,
r
);
...
...
@@ -235,8 +235,8 @@ static void test_add(void)
err
=
RegQueryValueExA
(
hkey
,
"bin4"
,
NULL
,
&
type
,
(
void
*
)
(
buffer
+
12
),
&
size
);
ok
(
err
==
ERROR_SUCCESS
,
"RegQueryValueEx failed: got %d
\n
"
,
err
);
ok
(
type
==
REG_BINARY
,
"got wrong type %u
\n
"
,
type
);
todo_wine
ok
(
size
==
6
,
"got wrong size %u
\n
"
,
size
);
todo_wine
ok
(
memcmp
(
buffer
,
buffer
+
12
,
6
)
==
0
||
ok
(
size
==
6
,
"got wrong size %u
\n
"
,
size
);
ok
(
memcmp
(
buffer
,
buffer
+
12
,
6
)
==
0
||
broken
(
memcmp
(
buffer
+
6
,
buffer
+
12
,
6
)
==
0
/* WinXP */
),
"got wrong data
\n
"
);
run_reg_exe
(
"reg add HKCU
\\
"
KEY_BASE
" /t REG_BINARY /v bin5 /d
\"\"
/f"
,
&
r
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment