Partial implementation of advpack.RegInstall.

This commit is contained in:
Huw Davies 2004-09-27 20:39:40 +00:00 committed by Alexandre Julliard
parent c25c8cafe1
commit 20313b8306
10 changed files with 332 additions and 1 deletions

3
configure vendored

File diff suppressed because one or more lines are too long

View File

@ -1539,6 +1539,7 @@ Makefile
dlls/Makefile
dlls/advapi32/Makefile
dlls/advapi32/tests/Makefile
dlls/advpack/Makefile
dlls/amstream/Makefile
dlls/atl/Makefile
dlls/avicap32/Makefile

View File

@ -17,6 +17,7 @@ EXTRADIRS = @GLU32FILES@ @GLUT32FILES@ @OPENGLFILES@ @XFILES@
BASEDIRS = \
advapi32 \
advpack \
amstream \
atl \
avicap32 \
@ -242,6 +243,7 @@ SYMLINKS_SO = \
$(EXTRADIRS:%=%.dll.so) \
@WIN16_FILES@ \
advapi32.dll.so \
advpack.dll.so \
amstream.dll.so \
atl.dll.so \
avicap32.dll.so \
@ -408,6 +410,9 @@ symlinks: $(BUILDSUBDIRS)
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 @@ libuuid.a: uuid/libuuid.a
IMPORT_LIBS = \
libadvapi32.$(IMPLIBEXT) \
libadvpack.$(IMPLIBEXT) \
libamstream.$(IMPLIBEXT) \
libatl.$(IMPLIBEXT) \
libavicap32.$(IMPLIBEXT) \
@ -1110,6 +1116,11 @@ libadvapi32.def: advapi32/advapi32.spec.def
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 @@ libx11drv.a: x11drv/x11drv.spec.def
$(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 @@ $(INSTALLSUBDIRS:%=%/__install__): $(IMPORT_LIBS)
# 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

3
dlls/advpack/.cvsignore Normal file
View File

@ -0,0 +1,3 @@
Makefile
advpack.dll.dbg.c
advpack.spec.def

15
dlls/advpack/Makefile.in Normal file
View File

@ -0,0 +1,15 @@
TOPSRCDIR = @top_srcdir@
TOPOBJDIR = ../..
SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = advpack.dll
IMPORTS = setupapi user32 kernel32 ntdll
EXTRALIBS = $(LIBUNICODE)
C_SRCS = \
advpack.c \
reg.c
@MAKE_DLL_RULES@
### Dependencies:

39
dlls/advpack/advpack.c Normal file
View File

@ -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;
}

32
dlls/advpack/advpack.spec Normal file
View File

@ -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

179
dlls/advpack/reg.c Normal file
View File

@ -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;
}

View File

@ -42,6 +42,7 @@ WINDOWS_INCLUDES = \
$(IDL_INCLUDES) \
accctrl.h \
aclapi.h \
advpub.h \
audevcod.h \
aviriff.h \
basetsd.h \

47
include/advpub.h Normal file
View File

@ -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 */