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
40ce6658
Commit
40ce6658
authored
Jul 19, 2017
by
Hugh McMaster
Committed by
Alexandre Julliard
Jul 19, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
regedit: Export value names from a separate function.
Signed-off-by:
Hugh McMaster
<
hugh.mcmaster@outlook.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c189effe
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
15 deletions
+77
-15
regproc.c
programs/regedit/regproc.c
+77
-15
No files found.
programs/regedit/regproc.c
View file @
40ce6658
...
...
@@ -1241,24 +1241,12 @@ static void REGPROC_write_line(FILE *file, const WCHAR* str, BOOL unicode)
* Is resized if necessary.
* val_size - size of the buffer for storing values in bytes.
*/
static
void
export_hkey
(
FILE
*
file
,
WCHAR
**
val_name_buf
,
DWORD
*
val_name_size
,
DWORD
value_type
,
BYTE
**
val_buf
,
DWORD
*
val_size
,
static
void
export_hkey
(
FILE
*
file
,
DWORD
value_type
,
BYTE
**
val_buf
,
DWORD
*
val_size
,
WCHAR
**
line_buf
,
DWORD
*
line_buf_size
,
BOOL
unicode
)
{
DWORD
line_len
=
0
;
DWORD
val_size1
=
*
val_size
;
if
(
*
val_name_buf
&&
(
*
val_name_buf
)[
0
])
{
const
WCHAR
val_start
[]
=
{
'"'
,
'%'
,
's'
,
'"'
,
'='
,
0
};
REGPROC_export_string
(
line_buf
,
line_buf_size
,
&
line_len
,
*
val_name_buf
,
lstrlenW
(
*
val_name_buf
));
line_len
=
sprintfW
(
*
line_buf
,
val_start
,
*
val_name_buf
);
}
else
{
const
WCHAR
std_val
[]
=
{
'@'
,
'='
,
0
};
line_len
=
2
;
lstrcpyW
(
*
line_buf
,
std_val
);
}
switch
(
value_type
)
{
case
REG_SZ
:
{
...
...
@@ -1375,6 +1363,80 @@ void delete_registry_key(WCHAR *reg_key_name)
RegDeleteTreeW
(
key_class
,
key_name
);
}
static
WCHAR
*
REGPROC_escape_string
(
WCHAR
*
str
,
size_t
str_len
,
size_t
*
line_len
)
{
size_t
i
,
escape_count
,
pos
;
WCHAR
*
buf
;
for
(
i
=
0
,
escape_count
=
0
;
i
<
str_len
;
i
++
)
{
WCHAR
c
=
str
[
i
];
if
(
c
==
'\r'
||
c
==
'\n'
||
c
==
'\\'
||
c
==
'"'
||
c
==
'\0'
)
escape_count
++
;
}
buf
=
resize_buffer
(
NULL
,
(
str_len
+
escape_count
+
1
)
*
sizeof
(
WCHAR
));
for
(
i
=
0
,
pos
=
0
;
i
<
str_len
;
i
++
,
pos
++
)
{
WCHAR
c
=
str
[
i
];
switch
(
c
)
{
case
'\r'
:
buf
[
pos
++
]
=
'\\'
;
buf
[
pos
]
=
'r'
;
break
;
case
'\n'
:
buf
[
pos
++
]
=
'\\'
;
buf
[
pos
]
=
'n'
;
break
;
case
'\\'
:
buf
[
pos
++
]
=
'\\'
;
buf
[
pos
]
=
'\\'
;
break
;
case
'"'
:
buf
[
pos
++
]
=
'\\'
;
buf
[
pos
]
=
'"'
;
break
;
case
'\0'
:
buf
[
pos
++
]
=
'\\'
;
buf
[
pos
]
=
'0'
;
break
;
default:
buf
[
pos
]
=
c
;
}
}
buf
[
pos
]
=
0
;
*
line_len
=
pos
;
return
buf
;
}
static
size_t
export_value_name
(
FILE
*
fp
,
WCHAR
*
name
,
size_t
len
,
BOOL
unicode
)
{
static
const
WCHAR
quoted_fmt
[]
=
{
'"'
,
'%'
,
's'
,
'"'
,
'='
,
0
};
static
const
WCHAR
default_name
[]
=
{
'@'
,
'='
,
0
};
size_t
line_len
;
if
(
name
&&
*
name
)
{
WCHAR
*
str
=
REGPROC_escape_string
(
name
,
len
,
&
line_len
);
WCHAR
*
buf
=
resize_buffer
(
NULL
,
(
line_len
+
4
)
*
sizeof
(
WCHAR
));
line_len
=
sprintfW
(
buf
,
quoted_fmt
,
str
);
REGPROC_write_line
(
fp
,
buf
,
unicode
);
HeapFree
(
GetProcessHeap
(),
0
,
buf
);
HeapFree
(
GetProcessHeap
(),
0
,
str
);
}
else
{
line_len
=
lstrlenW
(
default_name
);
REGPROC_write_line
(
fp
,
default_name
,
unicode
);
}
return
line_len
;
}
static
WCHAR
*
build_subkey_path
(
WCHAR
*
path
,
DWORD
path_len
,
WCHAR
*
subkey_name
,
DWORD
subkey_len
)
{
WCHAR
*
subkey_path
;
...
...
@@ -1428,8 +1490,8 @@ static int export_registry_data(FILE *fp, HKEY key, WCHAR *path, BOOL unicode)
rc
=
RegEnumValueW
(
key
,
i
,
value_name
,
&
value_len
,
NULL
,
&
type
,
data
,
&
data_size
);
if
(
rc
==
ERROR_SUCCESS
)
{
export_
hkey
(
fp
,
&
value_name
,
&
value_len
,
type
,
&
data
,
&
data_size
,
&
line_buf
,
&
line_buf_size
,
unicode
);
export_
value_name
(
fp
,
value_name
,
value_len
,
unicode
);
export_hkey
(
fp
,
type
,
&
data
,
&
data_size
,
&
line_buf
,
&
line_buf_size
,
unicode
);
i
++
;
}
else
if
(
rc
==
ERROR_MORE_DATA
)
...
...
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