registry loader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



misc/registry.c

use only winapi functions in _convert_winnt_registry_to_wine_format

This enables reading registry from a ntfs volume since mmap fails 
there. The libc-functions where choosen once because of the idea of 
moving the registry loader to a separate utility. This ideas was never 
realized.



---
juergen.schmied@debitel.net



Index: wine/misc/registry.c
===================================================================
RCS file: /home/wine/wine/misc/registry.c,v
retrieving revision 1.106
diff -d -u -r1.106 registry.c
--- wine/misc/registry.c	26 Apr 2002 19:05:17 -0000	1.106
+++ wine/misc/registry.c	7 May 2002 18:58:52 -0000
@@ -948,6 +948,7 @@
     DWORD *vl;
     LPSTR new_key_name = NULL;
 
+    TRACE("%s\n", key_name);
 
     if (nk->SubBlockId != NT_REG_KEY_BLOCK_ID) {
         ERR("unknown node id 0x%04x, please report!\n", nk->SubBlockId);
@@ -1333,25 +1334,26 @@
 /* convert winnt native registry file to wine format [Internal] */
 static LPSTR _convert_winnt_registry_to_wine_format(LPCSTR fn,int level)
 {
-    int fd;
     FILE *f;
-    DOS_FULL_NAME full_name;
     void *base;
     LPSTR ret = NULL;
-    struct stat st;
+    HANDLE hFile;
+    HANDLE hMapping;
 
     nt_regf *regf;
     nt_hbin *hbin;
     nt_hbin_sub *hbin_sub;
     nt_nk *nk;
 
-    if (!DOSFS_GetFullName( fn, 0, &full_name )) return NULL;
+    TRACE("%s\n", fn);
 
-    /* map the registry into the memory */
-    if ((fd = open(full_name.long_name, O_RDONLY | O_NONBLOCK)) == -1) return NULL;
-    if ((fstat(fd, &st) == -1)) goto error1;
-    if (!st.st_size) goto error1;
-    if ((base = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) == MAP_FAILED) goto error1;
+    hFile = CreateFileA( fn, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, 0 );
+    if ( hFile == INVALID_HANDLE_VALUE ) return NULL;
+    hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY|SEC_COMMIT, 0, 0, NULL );
+    if (!hMapping) goto error1;
+    base = MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 );
+    CloseHandle( hMapping );
+    if (!base) goto error1;
 
     /* control signature */
     if (*(LPDWORD)base != NT_REG_HEADER_BLOCK_ID) {
@@ -1389,9 +1391,9 @@
     fclose(f);
 
 error:
-    munmap(base,st.st_size);
+    UnmapViewOfFile( base );
 error1:
-    close(fd);
+    CloseHandle(hFile);
     return ret;
 }
 


[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux