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
9ed6d24e
Commit
9ed6d24e
authored
Jul 12, 2020
by
Zebediah Figura
Committed by
Alexandre Julliard
Jul 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Implement retrieving mapped sections.
Signed-off-by:
Zebediah Figura
<
z.figura12@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
73fc0a18
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
123 additions
and
2 deletions
+123
-2
profile.c
dlls/kernel32/profile.c
+123
-2
No files found.
dlls/kernel32/profile.c
View file @
9ed6d24e
...
@@ -1040,6 +1040,30 @@ static HKEY open_file_mapping_key( const WCHAR *filename )
...
@@ -1040,6 +1040,30 @@ static HKEY open_file_mapping_key( const WCHAR *filename )
return
NULL
;
return
NULL
;
}
}
static
WCHAR
*
enum_key
(
HKEY
key
,
DWORD
i
)
{
WCHAR
*
value
,
*
new_value
;
DWORD
max
=
256
,
len
;
LSTATUS
res
;
if
(
!
(
value
=
HeapAlloc
(
GetProcessHeap
(),
0
,
max
*
sizeof
(
WCHAR
)
)))
return
NULL
;
len
=
max
;
while
((
res
=
RegEnumValueW
(
key
,
i
,
value
,
&
len
,
NULL
,
NULL
,
NULL
,
NULL
))
==
ERROR_MORE_DATA
)
{
max
*=
2
;
if
(
!
(
new_value
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
value
,
max
*
sizeof
(
WCHAR
)
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
value
);
return
NULL
;
}
value
=
new_value
;
len
=
max
;
}
if
(
!
res
)
return
value
;
HeapFree
(
GetProcessHeap
(),
0
,
value
);
return
NULL
;
}
static
WCHAR
*
get_key_value
(
HKEY
key
,
const
WCHAR
*
value
)
static
WCHAR
*
get_key_value
(
HKEY
key
,
const
WCHAR
*
value
)
{
{
DWORD
size
=
0
;
DWORD
size
=
0
;
...
@@ -1142,6 +1166,103 @@ static BOOL get_mapped_section_key( const WCHAR *filename, const WCHAR *section,
...
@@ -1142,6 +1166,103 @@ static BOOL get_mapped_section_key( const WCHAR *filename, const WCHAR *section,
return
TRUE
;
return
TRUE
;
}
}
static
DWORD
get_mapped_section
(
HKEY
key
,
WCHAR
*
buffer
,
DWORD
size
,
BOOL
return_values
)
{
WCHAR
*
entry
,
*
value
;
DWORD
i
,
ret
=
0
;
for
(
i
=
0
;
(
entry
=
enum_key
(
key
,
i
));
++
i
)
{
lstrcpynW
(
buffer
+
ret
,
entry
,
size
-
ret
-
1
);
ret
=
min
(
ret
+
strlenW
(
entry
)
+
1
,
size
-
1
);
if
(
return_values
&&
ret
<
size
-
1
&&
(
value
=
get_key_value
(
key
,
entry
)))
{
buffer
[
ret
-
1
]
=
'='
;
lstrcpynW
(
buffer
+
ret
,
value
,
size
-
ret
-
1
);
ret
=
min
(
ret
+
strlenW
(
value
)
+
1
,
size
-
1
);
HeapFree
(
GetProcessHeap
(),
0
,
value
);
}
HeapFree
(
GetProcessHeap
(),
0
,
entry
);
}
return
ret
;
}
static
DWORD
get_section
(
const
WCHAR
*
filename
,
const
WCHAR
*
section
,
WCHAR
*
buffer
,
DWORD
size
,
BOOL
return_values
)
{
HKEY
key
,
subkey
,
section_key
;
BOOL
use_ini
=
TRUE
;
DWORD
ret
=
0
;
WCHAR
*
path
;
if
((
key
=
open_file_mapping_key
(
filename
)))
{
if
(
!
RegOpenKeyExW
(
key
,
section
,
0
,
KEY_READ
,
&
subkey
))
{
WCHAR
*
entry
,
*
value
;
HKEY
entry_key
;
DWORD
i
;
for
(
i
=
0
;
(
entry
=
enum_key
(
subkey
,
i
));
++
i
)
{
if
(
!
(
path
=
get_key_value
(
subkey
,
entry
)))
{
HeapFree
(
GetProcessHeap
(),
0
,
entry
);
continue
;
}
entry_key
=
open_mapped_key
(
path
,
FALSE
);
HeapFree
(
GetProcessHeap
(),
0
,
path
);
if
(
!
entry_key
)
{
HeapFree
(
GetProcessHeap
(),
0
,
entry
);
continue
;
}
if
(
entry
[
0
])
{
if
((
value
=
get_key_value
(
entry_key
,
entry
)))
{
lstrcpynW
(
buffer
+
ret
,
entry
,
size
-
ret
-
1
);
ret
=
min
(
ret
+
strlenW
(
entry
)
+
1
,
size
-
1
);
if
(
return_values
&&
ret
<
size
-
1
)
{
buffer
[
ret
-
1
]
=
'='
;
lstrcpynW
(
buffer
+
ret
,
value
,
size
-
ret
-
1
);
ret
=
min
(
ret
+
strlenW
(
value
)
+
1
,
size
-
1
);
}
HeapFree
(
GetProcessHeap
(),
0
,
value
);
}
}
else
{
ret
=
get_mapped_section
(
entry_key
,
buffer
,
size
,
return_values
);
use_ini
=
FALSE
;
}
HeapFree
(
GetProcessHeap
(),
0
,
entry
);
RegCloseKey
(
entry_key
);
}
RegCloseKey
(
subkey
);
}
else
if
(
get_mapped_section_key
(
filename
,
section
,
NULL
,
FALSE
,
&
section_key
))
{
ret
=
get_mapped_section
(
section_key
,
buffer
,
size
,
return_values
);
use_ini
=
FALSE
;
RegCloseKey
(
section_key
);
}
RegCloseKey
(
key
);
}
if
(
use_ini
)
ret
+=
PROFILE_GetSection
(
filename
,
section
,
buffer
+
ret
,
size
-
ret
,
return_values
);
return
ret
;
}
/********************* API functions **********************************/
/********************* API functions **********************************/
...
@@ -1182,7 +1303,7 @@ INT WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry,
...
@@ -1182,7 +1303,7 @@ INT WINAPI GetPrivateProfileStringW( LPCWSTR section, LPCWSTR entry,
if
(
!
section
)
return
GetPrivateProfileSectionNamesW
(
buffer
,
len
,
filename
);
if
(
!
section
)
return
GetPrivateProfileSectionNamesW
(
buffer
,
len
,
filename
);
if
(
!
entry
)
if
(
!
entry
)
{
{
ret
=
PROFILE_GetS
ection
(
filename
,
section
,
buffer
,
len
,
FALSE
);
ret
=
get_s
ection
(
filename
,
section
,
buffer
,
len
,
FALSE
);
if
(
!
buffer
[
0
])
if
(
!
buffer
[
0
])
{
{
PROFILE_CopyEntry
(
buffer
,
def_val
,
len
);
PROFILE_CopyEntry
(
buffer
,
def_val
,
len
);
...
@@ -1400,7 +1521,7 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer,
...
@@ -1400,7 +1521,7 @@ INT WINAPI GetPrivateProfileSectionW( LPCWSTR section, LPWSTR buffer,
TRACE
(
"(%s, %p, %d, %s)
\n
"
,
debugstr_w
(
section
),
buffer
,
len
,
debugstr_w
(
filename
));
TRACE
(
"(%s, %p, %d, %s)
\n
"
,
debugstr_w
(
section
),
buffer
,
len
,
debugstr_w
(
filename
));
return
PROFILE_GetS
ection
(
filename
,
section
,
buffer
,
len
,
TRUE
);
return
get_s
ection
(
filename
,
section
,
buffer
,
len
,
TRUE
);
}
}
/***********************************************************************
/***********************************************************************
...
...
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