advpack

Huw D M Davies h.davies1 at physics.ox.ac.uk
Mon Sep 27 11:44:19 CDT 2004


On Mon, Sep 27, 2004 at 05:27:22PM +0100, Huw D M Davies wrote:
>         Huw Davies <huw at codeweavers.com>
>         Partial implementation of advpack.RegInstall

This time with the spec file - sorry.

        Huw Davies <huw at codeweavers.com>
        Partial implementation of advpack.RegInstall

-- 
Huw Davies
huw at codeweavers.com
Index: configure.ac
===================================================================
RCS file: /home/wine/wine/configure.ac,v
retrieving revision 1.312
diff -u -r1.312 configure.ac
--- configure.ac	23 Sep 2004 04:48:24 -0000	1.312
+++ configure.ac	27 Sep 2004 16:17:14 -0000
@@ -1539,6 +1539,7 @@
 dlls/Makefile
 dlls/advapi32/Makefile
 dlls/advapi32/tests/Makefile
+dlls/advpack/Makefile
 dlls/amstream/Makefile
 dlls/atl/Makefile
 dlls/avicap32/Makefile
Index: dlls/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/Makefile.in,v
retrieving revision 1.226
diff -u -r1.226 Makefile.in
--- dlls/Makefile.in	22 Sep 2004 04:08:38 -0000	1.226
+++ dlls/Makefile.in	27 Sep 2004 16:17:15 -0000
@@ -17,6 +17,7 @@
 
 BASEDIRS = \
 	advapi32 \
+	advpack \
 	amstream \
 	atl \
 	avicap32 \
@@ -242,6 +243,7 @@
 	$(EXTRADIRS:%=%.dll.so) \
 	@WIN16_FILES@ \
 	advapi32.dll.so \
+	advpack.dll.so \
 	amstream.dll.so \
 	atl.dll.so \
 	avicap32.dll.so \
@@ -408,6 +410,9 @@
 advapi32.dll.so: advapi32/advapi32.dll.so
 	$(RM) $@ && $(LN_S) advapi32/advapi32.dll.so $@
 
+advpack.dll.so: advpack/advpack.dll.so
+	$(RM) $@ && $(LN_S) advpack/advpack.dll.so $@
+
 amstream.dll.so: amstream/amstream.dll.so
 	$(RM) $@ && $(LN_S) amstream/amstream.dll.so $@
 
@@ -973,6 +978,7 @@
 
 IMPORT_LIBS = \
 	libadvapi32.$(IMPLIBEXT) \
+	libadvpack.$(IMPLIBEXT) \
 	libamstream.$(IMPLIBEXT) \
 	libatl.$(IMPLIBEXT) \
 	libavicap32.$(IMPLIBEXT) \
@@ -1110,6 +1116,11 @@
 libadvapi32.a: advapi32/advapi32.spec.def
 	$(DLLTOOL) -k -l $@ -d advapi32/advapi32.spec.def
 
+libadvpack.def: advpack/advpack.spec.def
+	$(RM) $@ && $(LN_S) advpack/advpack.spec.def $@
+libadvpack.a: advpack/advpack.spec.def
+	$(DLLTOOL) -k -l $@ -d advpack/advpack.spec.def
+
 libamstream.def: amstream/amstream.spec.def
 	$(RM) $@ && $(LN_S) amstream/amstream.spec.def $@
 libamstream.a: amstream/amstream.spec.def
@@ -1731,6 +1742,7 @@
 	$(DLLTOOL) -k -l $@ -d x11drv/x11drv.spec.def
 
 advapi32/advapi32.spec.def: $(WINEBUILD)
+advpack/advpack.spec.def: $(WINEBUILD)
 amstream/amstream.spec.def: $(WINEBUILD)
 atl/atl.spec.def: $(WINEBUILD)
 avicap32/avicap32.spec.def: $(WINEBUILD)
@@ -1862,6 +1874,7 @@
 # Map library name to the corresponding directory
 
 advapi32/advapi32.dll.so: advapi32
+advpack/advpack.dll.so: advpack
 amstream/amstream.dll.so: amstream
 atl/atl.dll.so: atl
 avicap32/avicap32.dll.so: avicap32
--- /dev/null	2003-01-30 10:24:37.000000000 +0000
+++ dlls/advpack/Makefile.in	2004-09-27 17:19:10.000000000 +0100
@@ -0,0 +1,15 @@
+TOPSRCDIR = @top_srcdir@
+TOPOBJDIR = ../..
+SRCDIR    = @srcdir@
+VPATH     = @srcdir@
+MODULE    = advpack.dll
+EXTRALIBS = $(LIBUNICODE)
+IMPORTS   = setupapi user32 kernel32 ntdll
+
+C_SRCS = \
+	advpack.c \
+	reg.c
+
+ at MAKE_DLL_RULES@
+
+### Dependencies:
--- /dev/null	2003-01-30 10:24:37.000000000 +0000
+++ dlls/advpack/advpack.c	2004-09-27 17:18:04.000000000 +0100
@@ -0,0 +1,39 @@
+/*
+ * Advpack main
+ *
+ * Copyright 2004 Huw D M Davies
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <windef.h>
+#include <stdarg.h>
+#include <winbase.h>
+#include <wine/debug.h>
+
+WINE_DEFAULT_DEBUG_CHANNEL(advpack);
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+    TRACE("(%p, %ld, %p)\n",hinstDLL, fdwReason, lpvReserved);
+
+    if (fdwReason == DLL_PROCESS_ATTACH)
+        DisableThreadLibraryCalls(hinstDLL);
+
+    return TRUE;
+}
+
+
--- /dev/null	2003-01-30 10:24:37.000000000 +0000
+++ dlls/advpack/reg.c	2004-09-27 17:19:18.000000000 +0100
@@ -0,0 +1,179 @@
+/*
+ * Advpack registry functions
+ *
+ * Copyright 2004 Huw D M Davies
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <windef.h>
+#include <stdarg.h>
+#include <winbase.h>
+#include <winreg.h>
+#include <winerror.h>
+#include <wine/unicode.h>
+#include <wine/debug.h>
+#include <winuser.h>
+#include <winternl.h>
+#include <setupapi.h>
+#include <advpub.h>
+
+
+WINE_DEFAULT_DEBUG_CHANNEL(advpack);
+
+static const WCHAR REGINST[] = {'R','E','G','I','N','S','T',0};
+static const WCHAR Strings[] = {'S','t','r','i','n','g','s',0};
+static const WCHAR MOD_PATH[] = {'_','M','O','D','_','P','A','T','H',0};
+static const WCHAR SYS_MOD_PATH[] = {'_','S','Y','S','_','M','O','D','_','P','A','T','H',0};
+static const WCHAR SystemRoot[] = {'S','y','s','t','e','m','R','o','o','t',0};
+static const WCHAR escaped_SystemRoot[] = {'%','S','y','s','t','e','m','R','o','o','t','%',0};
+
+static BOOL get_temp_ini_path(LPWSTR name)
+{
+    WCHAR tmp_dir[MAX_PATH];
+    WCHAR prefix[] = {'a','v','p',0};
+
+    if(!GetTempPathW(sizeof(tmp_dir)/sizeof(WCHAR), tmp_dir))
+       return FALSE;
+
+    if(!GetTempFileNameW(tmp_dir, prefix, 0, name))
+        return FALSE;
+    return TRUE;
+}
+
+static BOOL create_tmp_ini_file(HMODULE hm, WCHAR *ini_file)
+{
+    HRSRC hrsrc;
+    HGLOBAL hmem = NULL;
+    DWORD rsrc_size, bytes_written;
+    VOID *rsrc_data;
+    HANDLE hf = INVALID_HANDLE_VALUE;
+
+    if(!get_temp_ini_path(ini_file)) {
+        ERR("Can't get temp ini file path\n");
+        goto error;
+    }
+
+    if(!(hrsrc = FindResourceW(hm, REGINST, REGINST))) {
+        ERR("Can't find REGINST resource\n");
+        goto error;
+    }
+
+    rsrc_size = SizeofResource(hm, hrsrc);
+    hmem = LoadResource(hm, hrsrc);
+    rsrc_data = LockResource(hmem);
+
+    if(!rsrc_data || !rsrc_size) {
+        ERR("Can't load REGINST resource\n");
+        goto error;
+    }       
+
+    if((hf = CreateFileW(ini_file, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
+                         FILE_ATTRIBUTE_NORMAL, NULL)) == INVALID_HANDLE_VALUE) {
+        ERR("Unable to create temp ini file\n");
+        goto error;
+    }
+    if(!WriteFile(hf, rsrc_data, rsrc_size, &bytes_written, NULL) || rsrc_size != bytes_written) {
+        ERR("Write failed\n");
+        goto error;
+    }
+    FreeResource(hmem);
+    CloseHandle(hf);
+    return TRUE;
+error:
+    if(hmem) FreeResource(hmem);
+    if(hf != INVALID_HANDLE_VALUE) CloseHandle(hf);
+    return FALSE;
+}
+
+/***********************************************************************
+ *          RegInstall (advpack.@)
+ *
+ */
+HRESULT WINAPI RegInstall(HMODULE hm, LPCSTR pszSection, LPCSTRTABLE pstTable)
+{
+    int i;
+    WCHAR tmp_ini_path[MAX_PATH];
+    WCHAR mod_path[MAX_PATH + 2], sys_mod_path[MAX_PATH + 2], sys_root[MAX_PATH];
+    HINF hinf;
+    WCHAR quote[] = {'\"',0};
+    UNICODE_STRING section;
+
+    TRACE("(%p %s %p)\n", hm, pszSection, pstTable);
+
+    for(i = 0; i < pstTable->cEntries; i++)
+        TRACE("%d: %s -> %s\n", i, pstTable->pse[i].pszName,
+             pstTable->pse[i].pszValue);
+
+    if(!create_tmp_ini_file(hm, tmp_ini_path))
+        return E_FAIL;
+
+    /* Write a couple of pre-defined strings */
+    mod_path[0] = '\"';
+    GetModuleFileNameW(hm, mod_path + 1, sizeof(mod_path)/sizeof(WCHAR) - 2);
+    strcatW(mod_path, quote);
+    WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, tmp_ini_path);
+    
+    *sys_root = '\0';
+    GetEnvironmentVariableW(SystemRoot, sys_root, sizeof(sys_root)/sizeof(WCHAR));
+    if(!strncmpiW(sys_root, mod_path + 1, strlenW(sys_root))) {
+        sys_mod_path[0] = '\"';
+        strcpyW(sys_mod_path + 1, escaped_SystemRoot);
+        strcatW(sys_mod_path, mod_path + 1 + strlenW(sys_root));
+    } else {
+        FIXME("SYS_MOD_PATH needs more work\n");
+        strcpyW(sys_mod_path, mod_path);
+    }
+    WritePrivateProfileStringW(Strings, SYS_MOD_PATH, sys_mod_path, tmp_ini_path);
+
+    /* Write the additional string table */
+    for(i = 0; i < pstTable->cEntries; i++) {
+        char tmp_value[MAX_PATH + 2];
+        UNICODE_STRING name, value;
+        tmp_value[0] = '\"';
+        strcpy(tmp_value + 1, pstTable->pse[i].pszValue);
+        strcat(tmp_value, "\"");
+        RtlCreateUnicodeStringFromAsciiz(&name, pstTable->pse[i].pszName);
+        RtlCreateUnicodeStringFromAsciiz(&value, tmp_value);
+        WritePrivateProfileStringW(Strings, name.Buffer, value.Buffer, tmp_ini_path);
+        RtlFreeUnicodeString(&name);
+        RtlFreeUnicodeString(&value);
+    }
+    /* flush cache */
+    WritePrivateProfileStringW(NULL, NULL, NULL, tmp_ini_path);
+
+
+    if((hinf = SetupOpenInfFileW(tmp_ini_path, NULL, INF_STYLE_WIN4, NULL)) ==
+       INVALID_HANDLE_VALUE) {
+        ERR("Setupapi can't open inf\n");
+        return E_FAIL;
+    }
+
+    /* append any layout files */
+    SetupOpenAppendInfFileW(NULL, hinf, NULL);
+
+    /* Need to do a lot more here */
+    RtlCreateUnicodeStringFromAsciiz(&section, pszSection);
+    SetupInstallFromInfSectionW(NULL, hinf, section.Buffer,
+                                SPINST_INIFILES | SPINST_REGISTRY | SPINST_PROFILEITEMS,
+                                HKEY_LOCAL_MACHINE, NULL, 0, NULL, NULL, NULL, NULL);
+    RtlFreeUnicodeString(&section);
+
+    
+    SetupCloseInfFile(hinf);
+    DeleteFileW(tmp_ini_path);
+
+    return S_OK;
+}
--- /dev/null	2003-01-30 10:24:37.000000000 +0000
+++ include/advpub.h	2004-09-27 17:16:21.000000000 +0100
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2004 Huw D M Davies
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifndef __WINE_ADVPUB_H
+#define __WINE_ADVPUB_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct _StrEntry {
+    LPSTR pszName;
+    LPSTR pszValue;
+} STRENTRY, *LPSTRENTRY;
+
+typedef const STRENTRY CSTRENTRY;
+typedef CSTRENTRY *LPCSTRENTRY;
+
+typedef struct _StrTable {
+    DWORD cEntries;
+    LPSTRENTRY pse;
+} STRTABLE, *LPSTRTABLE;
+
+typedef const STRTABLE CSTRTABLE;
+typedef CSTRTABLE *LPCSTRTABLE;
+
+HRESULT WINAPI RegInstall(HMODULE hm, LPCSTR pszSection, LPCSTRTABLE pstTable);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __WINE_ADVPUB_H */
--- /dev/null	2003-01-30 10:24:37.000000000 +0000
+++ dlls/advpack/advpack.spec	2004-09-27 12:23:39.000000000 +0100
@@ -0,0 +1,32 @@
+@ stub AddDelBackupEntry
+@ stub AdvInstallFile
+@ stub CloseINFEngine
+@ stub DelNode
+@ stub DelNodeRunDLL32
+@ stub DllMain
+@ stub DoInfInstall
+@ stub ExecuteCab
+@ stub ExtractFiles
+@ stub FileSaveMarkNotExist
+@ stub FileSaveRestore
+@ stub FileSaveRestoreOnINF
+@ stub GetVersionFromFile
+@ stub GetVersionFromFileEx
+@ stub IsNTAdmin
+@ stub LaunchINFSection
+@ stub LaunchINFSectionEx
+@ stub NeedReboot
+@ stub NeedRebootInit
+@ stub OpenINFEngine
+@ stub RebootCheckOnInstall
+@ stdcall RegInstall(ptr str ptr)
+@ stub RegRestoreAll
+@ stub RegSaveRestore
+@ stub RegSaveRestoreOnINF
+@ stub RegisterOCX
+@ stub RunSetupCommand
+@ stub SetPerUserSecValues
+@ stub TranslateInfString
+@ stub TranslateInfStringEx
+@ stub UserInstStubWrapper
+@ stub UserUnInstStubWrapper



More information about the wine-patches mailing list