Zebediah Figura : kernel32: Implement registry mapping in WritePrivateProfileSection().
Alexandre Julliard
julliard at winehq.org
Wed Jul 15 16:44:46 CDT 2020
Module: wine
Branch: master
Commit: d2b83336c7b219b3267035bd6ab9af5480184743
URL: https://source.winehq.org/git/wine.git/?a=commit;h=d2b83336c7b219b3267035bd6ab9af5480184743
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Sun Jul 12 20:32:11 2020 -0500
kernel32: Implement registry mapping in WritePrivateProfileSection().
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/profile.c | 39 +++++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/dlls/kernel32/profile.c b/dlls/kernel32/profile.c
index 6d8d64fc81..d4f2b32654 100644
--- a/dlls/kernel32/profile.c
+++ b/dlls/kernel32/profile.c
@@ -1674,6 +1674,7 @@ BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section,
{
BOOL ret = FALSE;
LPWSTR p;
+ HKEY key, section_key;
if (!section && !string)
{
@@ -1687,6 +1688,44 @@ BOOL WINAPI WritePrivateProfileSectionW( LPCWSTR section,
}
if (!string) return PROFILE_DeleteSection( filename, section );
+ if ((key = open_file_mapping_key( filename )))
+ {
+ /* replace existing entries, but only if they are mapped, and do not
+ * delete any keys */
+
+ const WCHAR *entry, *p;
+
+ for (entry = string; *entry; entry += strlenW( entry ) + 1)
+ {
+ if ((p = strchrW( entry, '=' )))
+ {
+ WCHAR *entry_copy;
+ p++;
+ if (!(entry_copy = HeapAlloc( GetProcessHeap(), 0, (p - entry) * sizeof(WCHAR) )))
+ {
+ SetLastError( ERROR_NOT_ENOUGH_MEMORY );
+ RegCloseKey( key );
+ return FALSE;
+ }
+ lstrcpynW( entry_copy, entry, p - entry );
+ if (get_mapped_section_key( filename, section, entry_copy, TRUE, §ion_key ))
+ {
+ LSTATUS res = RegSetValueExW( section_key, entry_copy, 0, REG_SZ, (const BYTE *)p,
+ (strlenW( p ) + 1) * sizeof(WCHAR) );
+ RegCloseKey( section_key );
+ if (res)
+ {
+ SetLastError( res );
+ RegCloseKey( key );
+ return FALSE;
+ }
+ }
+ }
+ }
+ RegCloseKey( key );
+ return TRUE;
+ }
+
EnterCriticalSection( &PROFILE_CritSect );
if (PROFILE_Open( filename, TRUE ))
More information about the wine-cvs
mailing list