mirror of
https://github.com/reactos/reactos.git
synced 2025-08-02 20:47:21 +00:00
Autosyncing with Wine HEAD
svn path=/trunk/; revision=23882
This commit is contained in:
parent
aa69c69afb
commit
8dff62e1f8
11 changed files with 3454 additions and 867 deletions
File diff suppressed because it is too large
Load diff
|
@ -1,37 +0,0 @@
|
|||
LIBRARY advpack.dll
|
||||
|
||||
EXPORTS
|
||||
AddDelBackupEntry@16
|
||||
AdvInstallFile@28
|
||||
CloseINFEngine@4
|
||||
DelNode@8
|
||||
DelNodeRunDLL32@16
|
||||
DllMain@12
|
||||
DoInfInstall@4
|
||||
ExecuteCab@12
|
||||
ExtractFiles@24
|
||||
FileSaveMarkNotExist@12
|
||||
FileSaveRestore@20
|
||||
FileSaveRestoreOnINF@28
|
||||
GetVersionFromFile@16
|
||||
GetVersionFromFileEx@16
|
||||
IsNTAdmin@8
|
||||
LaunchINFSection@16
|
||||
LaunchINFSectionEx@16
|
||||
NeedReboot@4
|
||||
NeedRebootInit@0
|
||||
OpenINFEngine@20
|
||||
RebootCheckOnInstall@16
|
||||
RegInstall@12
|
||||
RegRestoreAll@12
|
||||
RegSaveRestore@28
|
||||
RegSaveRestoreOnINF@28
|
||||
RegisterOCX@4
|
||||
RunSetupCommand@32
|
||||
SetPerUserSecValues@4
|
||||
TranslateInfString@28
|
||||
TranslateInfStringEx@32
|
||||
UserInstStubWrapper@16
|
||||
UserUnInstStubWrapper@16
|
||||
|
||||
; EOF
|
|
@ -1,254 +0,0 @@
|
|||
/*
|
||||
ADVPACK.H
|
||||
*/
|
||||
|
||||
#ifndef _ADVPACK_H
|
||||
#define _ADVPACK_H
|
||||
#if __GNUC__ >=3
|
||||
#pragma GCC system_header
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct _StrEntry {
|
||||
LPSTR Name;
|
||||
LPSTR Value;
|
||||
} STRENTRY, *LPSTRENTRY;
|
||||
|
||||
typedef const STRENTRY CSTRENTRY;
|
||||
typedef CSTRENTRY *LPCSTRENTRY;
|
||||
|
||||
typedef struct _StrTable {
|
||||
DWORD Entries;
|
||||
LPSTRENTRY Array;
|
||||
} STRTABLE, *LPSTRTABLE;
|
||||
|
||||
typedef const STRTABLE CSTRTABLE;
|
||||
typedef CSTRTABLE *LPCSTRTABLE;
|
||||
|
||||
typedef struct _CabInfo {
|
||||
PSTR Cab;
|
||||
PSTR Inf;
|
||||
PSTR Section;
|
||||
char Path[MAX_PATH];
|
||||
DWORD Flags;
|
||||
} CABINFO, *PCABINFO;
|
||||
|
||||
typedef PVOID HINF;
|
||||
|
||||
typedef struct _PERUSERSECTION {
|
||||
char GUID[59];
|
||||
char DisplayName[128];
|
||||
char Locale[10];
|
||||
char Stub[MAX_PATH*4];
|
||||
char Version[32];
|
||||
char CompId[128];
|
||||
DWORD IsInstalled;
|
||||
BOOL RollBack;
|
||||
} PERUSERSECTION, *PPERUSERSECTION;
|
||||
|
||||
|
||||
HRESULT WINAPI
|
||||
AddDelBackupEntry( LPCSTR FileList,
|
||||
LPCSTR BackupDir,
|
||||
LPCSTR BaseName,
|
||||
DWORD Flags );
|
||||
|
||||
HRESULT WINAPI
|
||||
AdvInstallFile( HWND hwnd,
|
||||
LPCSTR SourceDir,
|
||||
LPCSTR SourceFile,
|
||||
LPCSTR DestDir,
|
||||
LPCSTR DestFile,
|
||||
DWORD Flags,
|
||||
DWORD Reserved);
|
||||
|
||||
HRESULT WINAPI
|
||||
CloseINFEngine( HINF hinf );
|
||||
|
||||
HRESULT WINAPI
|
||||
DelNode( LPCSTR FileOrDirName,
|
||||
DWORD Flags );
|
||||
|
||||
HRESULT WINAPI
|
||||
DelNodeRunDLL32( HWND hwnd,
|
||||
HINSTANCE Inst,
|
||||
PSTR Params,
|
||||
INT Index );
|
||||
|
||||
|
||||
HRESULT WINAPI
|
||||
ExecuteCab( HWND hwnd,
|
||||
PCABINFO Cab,
|
||||
LPVOID Reserved );
|
||||
|
||||
HRESULT WINAPI
|
||||
ExtractFiles( LPCSTR CabName,
|
||||
LPCSTR ExpandDir,
|
||||
DWORD Flags,
|
||||
LPCSTR FileList,
|
||||
LPVOID LReserved,
|
||||
DWORD Reserved );
|
||||
|
||||
HRESULT WINAPI
|
||||
FileSaveMarkNotExist( LPSTR FileList,
|
||||
LPSTR PathDir,
|
||||
LPSTR BackupBaseName );
|
||||
|
||||
HRESULT WINAPI
|
||||
FileSaveRestore( HWND hwnd,
|
||||
LPSTR FileList,
|
||||
LPSTR PathDir,
|
||||
LPSTR BackupBaseName,
|
||||
DWORD Flags );
|
||||
|
||||
|
||||
HRESULT WINAPI
|
||||
FileSaveRestoreOnINF( HWND hwnd,
|
||||
PCSTR Title,
|
||||
PCSTR InfFilename,
|
||||
PCSTR Section,
|
||||
HKEY BackupKey,
|
||||
HKEY NBackupKey,
|
||||
DWORD Flags );
|
||||
|
||||
|
||||
HRESULT WINAPI
|
||||
GetVersionFromFile( LPSTR Filename,
|
||||
LPDWORD MajorVer,
|
||||
LPDWORD MinorVer,
|
||||
BOOL Version );
|
||||
|
||||
HRESULT WINAPI
|
||||
GetVersionFromFileEx( LPSTR Filename,
|
||||
LPDWORD MajorVer,
|
||||
LPDWORD MinorVer,
|
||||
BOOL Version );
|
||||
|
||||
BOOL WINAPI
|
||||
IsNTAdmin( DWORD Reserved,
|
||||
PDWORD PReserved );
|
||||
|
||||
INT WINAPI
|
||||
LaunchINFSection( HWND hwnd,
|
||||
HINSTANCE Inst,
|
||||
PSTR Params,
|
||||
INT Index );
|
||||
|
||||
HRESULT WINAPI
|
||||
LaunchINFSectionEx( HWND hwnd,
|
||||
HINSTANCE Inst,
|
||||
PSTR Params,
|
||||
INT Index );
|
||||
|
||||
BOOL WINAPI
|
||||
NeedReboot( DWORD RebootCheck );
|
||||
|
||||
DWORD WINAPI
|
||||
NeedRebootInit( VOID );
|
||||
|
||||
HRESULT WINAPI
|
||||
OpenINFEngine( PCSTR InfFilename,
|
||||
PCSTR InstallSection,
|
||||
DWORD Flags,
|
||||
HINF hinf,
|
||||
PVOID Reserved );
|
||||
|
||||
HRESULT WINAPI
|
||||
RebootCheckOnInstall( HWND hwnd,
|
||||
PCSTR InfFilename,
|
||||
PCSTR InfSection,
|
||||
DWORD Reserved );
|
||||
|
||||
HRESULT WINAPI
|
||||
RegInstall( HMODULE hm,
|
||||
LPCSTR InfSectionExec,
|
||||
LPCSTRTABLE TabStringSub );
|
||||
|
||||
HRESULT WINAPI
|
||||
RegRestoreAll( HWND hwnd,
|
||||
PCSTR TitleString,
|
||||
HKEY BackupKey );
|
||||
|
||||
HRESULT WINAPI
|
||||
RegSaveRestore( HWND hwnd,
|
||||
PCSTR TitleString,
|
||||
HKEY BackupKey,
|
||||
PCSTR RootKey,
|
||||
PCSTR SubKey,
|
||||
PCSTR ValueName,
|
||||
DWORD Flags );
|
||||
|
||||
HRESULT WINAPI
|
||||
RegSaveRestoreOnINF( HWND hwnd,
|
||||
PCSTR Title,
|
||||
PCSTR InfFilename,
|
||||
PCSTR Section,
|
||||
HKEY BackupKey,
|
||||
HKEY NBackupKey,
|
||||
DWORD Flags );
|
||||
|
||||
|
||||
HRESULT WINAPI
|
||||
RunSetupCommand( HWND hwnd,
|
||||
LPCSTR ExeFilename,
|
||||
LPCSTR InfSection,
|
||||
LPCSTR PathExtractedFile,
|
||||
LPCSTR DialogTitle,
|
||||
PHANDLE HExeWait,
|
||||
DWORD Flags,
|
||||
LPVOID Reserved);
|
||||
|
||||
|
||||
HRESULT WINAPI
|
||||
TranslateInfString( PCSTR InfFilename,
|
||||
PCSTR InstallSection,
|
||||
PCSTR TranslateSection,
|
||||
PCSTR TranslateKey,
|
||||
PSTR BufferToKey,
|
||||
DWORD BufferSize,
|
||||
PVOID Reserved );
|
||||
|
||||
HRESULT WINAPI
|
||||
TranslateInfStringEx( HINF hinf,
|
||||
PCSTR InfFilename,
|
||||
PCSTR InstallSection,
|
||||
PCSTR TranslateSection,
|
||||
PCSTR TranslateKey,
|
||||
PSTR BufferToKey,
|
||||
DWORD BufferSize,
|
||||
PVOID Reserved );
|
||||
|
||||
HRESULT WINAPI
|
||||
SetPerUserSecValues( PPERUSERSECTION PerUser );
|
||||
|
||||
HRESULT WINAPI
|
||||
UserInstStubWrapper( HWND hwnd,
|
||||
HINSTANCE Inst,
|
||||
PSTR Params,
|
||||
INT Index );
|
||||
|
||||
HRESULT WINAPI
|
||||
UserUnInstStubWrapper( HWND hwnd,
|
||||
HINSTANCE Inst,
|
||||
PSTR Params,
|
||||
INT Index );
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
HRESULT WINAPI
|
||||
DoInfInstall( DWORD Unknown);
|
||||
|
||||
HRESULT WINAPI
|
||||
RegisterOCX( LPCTSTR Filename );
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,20 +1,23 @@
|
|||
<module name="advpack" type="win32dll" baseaddress="${BASEADDRESS_ADVPACK}" installbase="system32" installname="advpack.dll">
|
||||
<importlibrary definition="advpack.def" />
|
||||
<module name="advpack" type="win32dll" baseaddress="${BASEADDRESS_ADVPACK}" installbase="system32" installname="advpack.dll" allowwarnings="true">
|
||||
<importlibrary definition="advpack.spec.def" />
|
||||
<include base="advpack">.</include>
|
||||
<define name="UNICODE" />
|
||||
<define name="_UNICODE" />
|
||||
<include base="ReactOS">include/reactos/wine</include>
|
||||
<define name="__REACTOS__" />
|
||||
<define name="__WINESRC__" />
|
||||
<define name="__USE_W32API" />
|
||||
<define name="_WIN32_IE">0x0600</define>
|
||||
<define name="_WIN32_IE">0x600</define>
|
||||
<define name="_WIN32_WINNT">0x501</define>
|
||||
<library>ntdll</library>
|
||||
<library>kernel32</library>
|
||||
<library>user32</library>
|
||||
<library>gdi32</library>
|
||||
<library>advapi32</library>
|
||||
<library>ole32</library>
|
||||
<define name="WINVER">0x501</define>
|
||||
<library>wine</library>
|
||||
<library>setupapi</library>
|
||||
<library>version</library>
|
||||
<library>user32</library>
|
||||
<library>advapi32</library>
|
||||
<library>kernel32</library>
|
||||
<library>ntdll</library>
|
||||
<file>advpack.c</file>
|
||||
<file>stubs.c</file>
|
||||
<file>advpack.rc</file>
|
||||
<file>files.c</file>
|
||||
<file>install.c</file>
|
||||
<file>reg.c</file>
|
||||
<file>advpack.spec</file>
|
||||
</module>
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
#include <windows.h>
|
||||
|
||||
#define REACTOS_VERSION_DLL
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Advpack User Library\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "advpack\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "advpack.dll\0"
|
||||
#include <reactos/version.rc>
|
82
reactos/dll/win32/advpack/advpack.spec
Normal file
82
reactos/dll/win32/advpack/advpack.spec
Normal file
|
@ -0,0 +1,82 @@
|
|||
@ stdcall AddDelBackupEntryA(str str str long)
|
||||
@ stdcall AddDelBackupEntryW(wstr wstr wstr long)
|
||||
@ stdcall AddDelBackupEntry(str str str long) AddDelBackupEntryA
|
||||
@ stdcall AdvInstallFileA(long str str str str long long)
|
||||
@ stdcall AdvInstallFileW(long wstr wstr wstr wstr long long)
|
||||
@ stdcall AdvInstallFile(long str str str str long long) AdvInstallFileA
|
||||
@ stdcall CloseINFEngine(long)
|
||||
@ stdcall DelNodeA(str long)
|
||||
@ stdcall DelNodeW(wstr long)
|
||||
@ stdcall DelNode(str long) DelNodeA
|
||||
@ stdcall DelNodeRunDLL32A(ptr ptr str long)
|
||||
@ stdcall DelNodeRunDLL32W(ptr ptr wstr long)
|
||||
@ stdcall DelNodeRunDLL32(ptr ptr str long) DelNodeRunDLL32A
|
||||
@ stdcall -private DllMain(long long ptr)
|
||||
@ stdcall DoInfInstall(ptr)
|
||||
@ stdcall ExecuteCabA(ptr ptr ptr)
|
||||
@ stdcall ExecuteCabW(ptr ptr ptr)
|
||||
@ stdcall ExecuteCab(ptr ptr ptr) ExecuteCabA
|
||||
@ stdcall ExtractFilesA(str str long ptr ptr long)
|
||||
# stdcall ExtractFilesW(wstr wstr long ptr ptr long)
|
||||
@ stdcall ExtractFiles(str str long ptr ptr long) ExtractFilesA
|
||||
@ stdcall FileSaveMarkNotExistA(str str str)
|
||||
@ stdcall FileSaveMarkNotExistW(wstr wstr wstr)
|
||||
@ stdcall FileSaveMarkNotExist(str str str) FileSaveMarkNotExistA
|
||||
@ stdcall FileSaveRestoreA(ptr str str str long)
|
||||
@ stdcall FileSaveRestoreW(ptr wstr wstr wstr long)
|
||||
@ stdcall FileSaveRestore(ptr str str str long) FileSaveRestoreA
|
||||
@ stdcall FileSaveRestoreOnINFA(ptr str str str str str long)
|
||||
@ stdcall FileSaveRestoreOnINFW(ptr wstr wstr wstr wstr wstr long)
|
||||
@ stdcall FileSaveRestoreOnINF(ptr str str str str str long) FileSaveRestoreOnINFA
|
||||
@ stdcall GetVersionFromFileA(str ptr ptr long)
|
||||
@ stdcall GetVersionFromFileW(wstr ptr ptr long)
|
||||
@ stdcall GetVersionFromFile(str ptr ptr long) GetVersionFromFileA
|
||||
@ stdcall GetVersionFromFileExA(str ptr ptr long)
|
||||
@ stdcall GetVersionFromFileExW(wstr ptr ptr long)
|
||||
@ stdcall GetVersionFromFileEx(str ptr ptr long) GetVersionFromFileExA
|
||||
@ stdcall IsNTAdmin(long ptr)
|
||||
@ stdcall LaunchINFSectionA(ptr ptr str long)
|
||||
@ stdcall LaunchINFSectionW(ptr ptr wstr long)
|
||||
@ stdcall LaunchINFSection(ptr ptr str long) LaunchINFSectionA
|
||||
@ stdcall LaunchINFSectionExA(ptr ptr str long)
|
||||
@ stdcall LaunchINFSectionExW(ptr ptr wstr long)
|
||||
@ stdcall LaunchINFSectionEx(ptr ptr str long) LaunchINFSectionExA
|
||||
@ stdcall NeedReboot(long)
|
||||
@ stdcall NeedRebootInit()
|
||||
@ stdcall OpenINFEngineA(str str long ptr ptr)
|
||||
@ stdcall OpenINFEngineW(wstr wstr long ptr ptr)
|
||||
@ stdcall OpenINFEngine(str str long ptr ptr) OpenINFEngineA
|
||||
@ stdcall RebootCheckOnInstallA(long str str long)
|
||||
@ stdcall RebootCheckOnInstallW(long wstr wstr long)
|
||||
@ stdcall RebootCheckOnInstall(long str str long) RebootCheckOnInstallA
|
||||
@ stdcall RegInstallA(ptr str ptr)
|
||||
@ stdcall RegInstallW(ptr wstr ptr)
|
||||
@ stdcall RegInstall(ptr str ptr) RegInstallA
|
||||
@ stdcall RegRestoreAllA(ptr str long)
|
||||
@ stdcall RegRestoreAllW(ptr wstr long)
|
||||
@ stdcall RegRestoreAll(ptr str long) RegRestoreAllA
|
||||
@ stdcall RegSaveRestoreA(ptr str long str str str long)
|
||||
@ stdcall RegSaveRestoreW(ptr wstr long wstr wstr wstr long)
|
||||
@ stdcall RegSaveRestore(ptr str long str str str long) RegSaveRestoreA
|
||||
@ stdcall RegSaveRestoreOnINFA(ptr str str str long long long)
|
||||
@ stdcall RegSaveRestoreOnINFW(ptr wstr wstr wstr long long long)
|
||||
@ stdcall RegSaveRestoreOnINF(ptr str str str long long long) RegSaveRestoreOnINFA
|
||||
@ stdcall RegisterOCX(ptr ptr str long)
|
||||
@ stdcall RunSetupCommandA(long str str str str ptr long ptr)
|
||||
@ stdcall RunSetupCommandW(long wstr wstr wstr wstr ptr long ptr)
|
||||
@ stdcall RunSetupCommand(long str str str str ptr long ptr) RunSetupCommandA
|
||||
@ stdcall SetPerUserSecValuesA(ptr)
|
||||
@ stdcall SetPerUserSecValuesW(ptr)
|
||||
@ stdcall SetPerUserSecValues(ptr) SetPerUserSecValuesA
|
||||
@ stdcall TranslateInfStringA(str str str str ptr long ptr ptr)
|
||||
@ stdcall TranslateInfStringW(wstr wstr wstr wstr ptr long ptr ptr)
|
||||
@ stdcall TranslateInfString(str str str str ptr long ptr ptr) TranslateInfStringA
|
||||
@ stdcall TranslateInfStringExA(long str str str str long ptr ptr)
|
||||
@ stdcall TranslateInfStringExW(long wstr wstr wstr wstr long ptr ptr)
|
||||
@ stdcall TranslateInfStringEx(long str str str str long ptr ptr) TranslateInfStringExA
|
||||
@ stdcall UserInstStubWrapperA(long long str long)
|
||||
@ stdcall UserInstStubWrapperW(long long wstr long)
|
||||
@ stdcall UserInstStubWrapper(long long str long) UserInstStubWrapperA
|
||||
@ stdcall UserUnInstStubWrapperA(long long str long)
|
||||
@ stdcall UserUnInstStubWrapperW(long long wstr long)
|
||||
@ stdcall UserUnInstStubWrapper(long long str long) UserUnInstStubWrapperA
|
|
@ -1,6 +1,7 @@
|
|||
/*
|
||||
* ReactOS Advpack Stub Library
|
||||
* Copyright (C) 2004 ReactOS Team
|
||||
* Advpack private header
|
||||
*
|
||||
* Copyright 2006 James Hawkins
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -14,22 +15,17 @@
|
|||
*
|
||||
* 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
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <windows.h>
|
||||
#include "advpack.h"
|
||||
#include "wine/debug.h"
|
||||
#ifndef __ADVPACK_PRIVATE_H
|
||||
#define __ADVPACK_PRIVATE_H
|
||||
|
||||
HRESULT WINAPI
|
||||
DoInfInstall(DWORD Unknown)
|
||||
{
|
||||
FIXME("DoInfInstall not implemented\n");
|
||||
HRESULT do_ocx_reg(HMODULE hocx, BOOL do_reg);
|
||||
LPWSTR get_parameter(LPWSTR *params, WCHAR separator);
|
||||
void set_ldids(HINF hInf, LPCWSTR pszInstallSection, LPCWSTR pszWorkingDir);
|
||||
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE);
|
||||
HRESULT do_ocx_reg(HMODULE hocx, BOOL do_reg);
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
||||
#endif /* __ADVPACK_PRIVATE_H */
|
1073
reactos/dll/win32/advpack/files.c
Normal file
1073
reactos/dll/win32/advpack/files.c
Normal file
File diff suppressed because it is too large
Load diff
951
reactos/dll/win32/advpack/install.c
Normal file
951
reactos/dll/win32/advpack/install.c
Normal file
|
@ -0,0 +1,951 @@
|
|||
/*
|
||||
* Advpack install functions
|
||||
*
|
||||
* Copyright 2006 James Hawkins
|
||||
*
|
||||
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winuser.h"
|
||||
#include "winreg.h"
|
||||
#include "winver.h"
|
||||
#include "winternl.h"
|
||||
#include "winnls.h"
|
||||
#include "setupapi.h"
|
||||
#include "advpub.h"
|
||||
#include "wine/debug.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "advpack_private.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(advpack);
|
||||
|
||||
#define SPAPI_ERROR 0xE0000000L
|
||||
#define SPAPI_PREFIX 0x800F0000L
|
||||
#define SPAPI_MASK 0xFFFFL
|
||||
#define HRESULT_FROM_SPAPI(x) ((x & SPAPI_MASK) | SPAPI_PREFIX)
|
||||
|
||||
#define ADV_HRESULT(x) ((x & SPAPI_ERROR) ? HRESULT_FROM_SPAPI(x) : HRESULT_FROM_WIN32(x))
|
||||
|
||||
#define ADV_SUCCESS 0
|
||||
#define ADV_FAILURE 1
|
||||
|
||||
/* contains information about a specific install instance */
|
||||
typedef struct _ADVInfo
|
||||
{
|
||||
HINF hinf;
|
||||
LPWSTR inf_filename;
|
||||
LPWSTR install_sec;
|
||||
LPWSTR working_dir;
|
||||
DWORD flags;
|
||||
BOOL need_reboot;
|
||||
} ADVInfo;
|
||||
|
||||
typedef HRESULT (*iterate_fields_func)(HINF hinf, PCWSTR field, void *arg);
|
||||
|
||||
/* Advanced INF commands */
|
||||
static const WCHAR CheckAdminRights[] = {
|
||||
'C','h','e','c','k','A','d','m','i','n','R','i','g','h','t','s',0
|
||||
};
|
||||
static const WCHAR DelDirs[] = {'D','e','l','D','i','r','s',0};
|
||||
static const WCHAR PerUserInstall[] = {'P','e','r','U','s','e','r','I','n','s','t','a','l','l',0};
|
||||
static const WCHAR RegisterOCXs[] = {'R','e','g','i','s','t','e','r','O','C','X','s',0};
|
||||
static const WCHAR RunPreSetupCommands[] = {
|
||||
'R','u','n','P','r','e','S','e','t','u','p','C','o','m','m','a','n','d','s',0
|
||||
};
|
||||
static const WCHAR RunPostSetupCommands[] = {
|
||||
'R','u','n','P','o','s','t','S','e','t','u','p','C','o','m','m','a','n','d','s',0
|
||||
};
|
||||
|
||||
/* Advanced INF callbacks */
|
||||
static HRESULT del_dirs_callback(HINF hinf, PCWSTR field, void *arg)
|
||||
{
|
||||
INFCONTEXT context;
|
||||
HRESULT hr = S_OK;
|
||||
DWORD size;
|
||||
|
||||
BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context);
|
||||
|
||||
for (; ok; ok = SetupFindNextLine(&context, &context))
|
||||
{
|
||||
WCHAR directory[MAX_INF_STRING_LENGTH];
|
||||
|
||||
if (!SetupGetLineTextW(&context, NULL, NULL, NULL, directory,
|
||||
MAX_INF_STRING_LENGTH, &size))
|
||||
continue;
|
||||
|
||||
if (DelNodeW(directory, ADN_DEL_IF_EMPTY))
|
||||
hr = E_FAIL;
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT per_user_install_callback(HINF hinf, PCWSTR field, void *arg)
|
||||
{
|
||||
PERUSERSECTIONW per_user;
|
||||
INFCONTEXT context;
|
||||
DWORD size;
|
||||
|
||||
static const WCHAR disp_name[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
|
||||
static const WCHAR version[] = {'V','e','r','s','i','o','n',0};
|
||||
static const WCHAR is_installed[] = {'I','s','I','n','s','t','a','l','l','e','d',0};
|
||||
static const WCHAR comp_id[] = {'C','o','m','p','o','n','e','n','t','I','D',0};
|
||||
static const WCHAR guid[] = {'G','U','I','D',0};
|
||||
static const WCHAR locale[] = {'L','o','c','a','l','e',0};
|
||||
static const WCHAR stub_path[] = {'S','t','u','b','P','a','t','h',0};
|
||||
|
||||
per_user.bRollback = FALSE;
|
||||
per_user.dwIsInstalled = 0;
|
||||
|
||||
SetupGetLineTextW(NULL, hinf, field, disp_name, per_user.szDispName,
|
||||
sizeof(per_user.szDispName) / sizeof(WCHAR), &size);
|
||||
|
||||
SetupGetLineTextW(NULL, hinf, field, version, per_user.szVersion,
|
||||
sizeof(per_user.szVersion) / sizeof(WCHAR), &size);
|
||||
|
||||
if (SetupFindFirstLineW(hinf, field, is_installed, &context))
|
||||
{
|
||||
SetupGetIntField(&context, 1, (PINT)&per_user.dwIsInstalled);
|
||||
}
|
||||
|
||||
SetupGetLineTextW(NULL, hinf, field, comp_id, per_user.szCompID,
|
||||
sizeof(per_user.szCompID) / sizeof(WCHAR), &size);
|
||||
|
||||
SetupGetLineTextW(NULL, hinf, field, guid, per_user.szGUID,
|
||||
sizeof(per_user.szGUID) / sizeof(WCHAR), &size);
|
||||
|
||||
SetupGetLineTextW(NULL, hinf, field, locale, per_user.szLocale,
|
||||
sizeof(per_user.szLocale) / sizeof(WCHAR), &size);
|
||||
|
||||
SetupGetLineTextW(NULL, hinf, field, stub_path, per_user.szStub,
|
||||
sizeof(per_user.szStub) / sizeof(WCHAR), &size);
|
||||
|
||||
return SetPerUserSecValuesW(&per_user);
|
||||
}
|
||||
|
||||
static HRESULT register_ocxs_callback(HINF hinf, PCWSTR field, void *arg)
|
||||
{
|
||||
HMODULE hm;
|
||||
INFCONTEXT context;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context);
|
||||
|
||||
for (; ok; ok = SetupFindNextLine(&context, &context))
|
||||
{
|
||||
WCHAR buffer[MAX_INF_STRING_LENGTH];
|
||||
|
||||
/* get OCX filename */
|
||||
if (!SetupGetStringFieldW(&context, 1, buffer,
|
||||
sizeof(buffer) / sizeof(WCHAR), NULL))
|
||||
continue;
|
||||
|
||||
hm = LoadLibraryExW(buffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
|
||||
if (!hm)
|
||||
continue;
|
||||
|
||||
if (do_ocx_reg(hm, TRUE))
|
||||
hr = E_FAIL;
|
||||
|
||||
FreeLibrary(hm);
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT run_setup_commands_callback(HINF hinf, PCWSTR field, void *arg)
|
||||
{
|
||||
ADVInfo *info = (ADVInfo *)arg;
|
||||
INFCONTEXT context;
|
||||
HRESULT hr = S_OK;
|
||||
DWORD size;
|
||||
|
||||
BOOL ok = SetupFindFirstLineW(hinf, field, NULL, &context);
|
||||
|
||||
for (; ok; ok = SetupFindNextLine(&context, &context))
|
||||
{
|
||||
WCHAR buffer[MAX_INF_STRING_LENGTH];
|
||||
|
||||
if (!SetupGetLineTextW(&context, NULL, NULL, NULL, buffer,
|
||||
MAX_INF_STRING_LENGTH, &size))
|
||||
continue;
|
||||
|
||||
if (launch_exe(buffer, info->working_dir, NULL))
|
||||
hr = E_FAIL;
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/* sequentially returns pointers to parameters in a parameter list
|
||||
* returns NULL if the parameter is empty, e.g. one,,three */
|
||||
LPWSTR get_parameter(LPWSTR *params, WCHAR separator)
|
||||
{
|
||||
LPWSTR token = *params;
|
||||
|
||||
if (!*params)
|
||||
return NULL;
|
||||
|
||||
*params = strchrW(*params, separator);
|
||||
if (*params)
|
||||
*(*params)++ = '\0';
|
||||
|
||||
if (!*token)
|
||||
return NULL;
|
||||
|
||||
return token;
|
||||
}
|
||||
|
||||
static BOOL is_full_path(LPWSTR path)
|
||||
{
|
||||
const int MIN_PATH_LEN = 3;
|
||||
|
||||
if (!path || lstrlenW(path) < MIN_PATH_LEN)
|
||||
return FALSE;
|
||||
|
||||
if (path[1] == ':' || (path[0] == '\\' && path[1] == '\\'))
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* retrieves the contents of a field, dynamically growing the buffer if necessary */
|
||||
static WCHAR *get_field_string(INFCONTEXT *context, DWORD index, WCHAR *buffer,
|
||||
WCHAR *static_buffer, DWORD *size)
|
||||
{
|
||||
DWORD required;
|
||||
|
||||
if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
|
||||
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
|
||||
{
|
||||
/* now grow the buffer */
|
||||
if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
|
||||
if (!(buffer = HeapAlloc(GetProcessHeap(), 0, required*sizeof(WCHAR)))) return NULL;
|
||||
*size = required;
|
||||
if (SetupGetStringFieldW(context, index, buffer, *size, &required)) return buffer;
|
||||
}
|
||||
|
||||
if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* iterates over all fields of a certain key of a certain section */
|
||||
static HRESULT iterate_section_fields(HINF hinf, PCWSTR section, PCWSTR key,
|
||||
iterate_fields_func callback, void *arg)
|
||||
{
|
||||
WCHAR static_buffer[200];
|
||||
WCHAR *buffer = static_buffer;
|
||||
DWORD size = sizeof(static_buffer) / sizeof(WCHAR);
|
||||
INFCONTEXT context;
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
BOOL ok = SetupFindFirstLineW(hinf, section, key, &context);
|
||||
while (ok)
|
||||
{
|
||||
UINT i, count = SetupGetFieldCount(&context);
|
||||
|
||||
for (i = 1; i <= count; i++)
|
||||
{
|
||||
if (!(buffer = get_field_string(&context, i, buffer, static_buffer, &size)))
|
||||
goto done;
|
||||
|
||||
if ((hr = callback(hinf, buffer, arg)) != S_OK)
|
||||
goto done;
|
||||
}
|
||||
|
||||
ok = SetupFindNextMatchLineW(&context, key, &context);
|
||||
}
|
||||
|
||||
hr = S_OK;
|
||||
|
||||
done:
|
||||
if (buffer != static_buffer) HeapFree(GetProcessHeap(), 0, buffer);
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT check_admin_rights(ADVInfo *info)
|
||||
{
|
||||
INT check;
|
||||
INFCONTEXT context;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
if (!SetupFindFirstLineW(info->hinf, info->install_sec,
|
||||
CheckAdminRights, &context))
|
||||
return S_OK;
|
||||
|
||||
if (!SetupGetIntField(&context, 1, &check))
|
||||
return S_OK;
|
||||
|
||||
if (check == 1)
|
||||
hr = IsNTAdmin(0, NULL) ? S_OK : E_FAIL;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/* performs a setupapi-level install of the INF file */
|
||||
static HRESULT spapi_install(ADVInfo *info)
|
||||
{
|
||||
BOOL ret;
|
||||
HRESULT res;
|
||||
PVOID context;
|
||||
|
||||
context = SetupInitDefaultQueueCallbackEx(NULL, INVALID_HANDLE_VALUE, 0, 0, NULL);
|
||||
if (!context)
|
||||
return ADV_HRESULT(GetLastError());
|
||||
|
||||
ret = SetupInstallFromInfSectionW(NULL, info->hinf, info->install_sec,
|
||||
SPINST_FILES, NULL, info->working_dir,
|
||||
SP_COPY_NEWER, SetupDefaultQueueCallbackW,
|
||||
context, NULL, NULL);
|
||||
if (!ret)
|
||||
{
|
||||
res = ADV_HRESULT(GetLastError());
|
||||
SetupTermDefaultQueueCallback(context);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
SetupTermDefaultQueueCallback(context);
|
||||
|
||||
ret = SetupInstallFromInfSectionW(NULL, info->hinf, info->install_sec,
|
||||
SPINST_INIFILES | SPINST_REGISTRY,
|
||||
HKEY_LOCAL_MACHINE, NULL, 0,
|
||||
NULL, NULL, NULL, NULL);
|
||||
if (!ret)
|
||||
return ADV_HRESULT(GetLastError());
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* processes the Advanced INF commands */
|
||||
static HRESULT adv_install(ADVInfo *info)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
hr = check_admin_rights(info);
|
||||
if (hr != S_OK)
|
||||
return hr;
|
||||
|
||||
hr = iterate_section_fields(info->hinf, info->install_sec, RunPreSetupCommands,
|
||||
run_setup_commands_callback, info);
|
||||
if (hr != S_OK)
|
||||
return hr;
|
||||
|
||||
hr = iterate_section_fields(info->hinf, info->install_sec,
|
||||
RegisterOCXs, register_ocxs_callback, NULL);
|
||||
if (hr != S_OK)
|
||||
return hr;
|
||||
|
||||
hr = iterate_section_fields(info->hinf, info->install_sec,
|
||||
PerUserInstall, per_user_install_callback, info);
|
||||
if (hr != S_OK)
|
||||
return hr;
|
||||
|
||||
hr = iterate_section_fields(info->hinf, info->install_sec, RunPostSetupCommands,
|
||||
run_setup_commands_callback, info);
|
||||
if (hr != S_OK)
|
||||
return hr;
|
||||
|
||||
hr = iterate_section_fields(info->hinf, info->install_sec,
|
||||
DelDirs, del_dirs_callback, info);
|
||||
if (hr != S_OK)
|
||||
return hr;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/* loads the INF file and performs checks on it */
|
||||
HRESULT install_init(LPCWSTR inf_filename, LPCWSTR install_sec,
|
||||
LPCWSTR working_dir, DWORD flags, ADVInfo *info)
|
||||
{
|
||||
DWORD len;
|
||||
LPCWSTR ptr;
|
||||
|
||||
static const WCHAR default_install[] = {
|
||||
'D','e','f','a','u','l','t','I','n','s','t','a','l','l',0
|
||||
};
|
||||
|
||||
len = lstrlenW(inf_filename);
|
||||
|
||||
info->inf_filename = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
|
||||
if (!info->inf_filename)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
lstrcpyW(info->inf_filename, inf_filename);
|
||||
|
||||
/* FIXME: determine the proper platform to install (NTx86, etc) */
|
||||
if (!install_sec || !*install_sec)
|
||||
{
|
||||
len = sizeof(default_install) - 1;
|
||||
ptr = default_install;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = lstrlenW(install_sec);
|
||||
ptr = install_sec;
|
||||
}
|
||||
|
||||
info->install_sec = HeapAlloc(GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR));
|
||||
if (!info->install_sec)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
lstrcpyW(info->install_sec, ptr);
|
||||
|
||||
/* FIXME: need to get the real working directory */
|
||||
if (!working_dir || !*working_dir)
|
||||
{
|
||||
ptr = strrchrW(info->inf_filename, '\\');
|
||||
len = ptr - info->inf_filename + 1;
|
||||
ptr = info->inf_filename;
|
||||
}
|
||||
else
|
||||
{
|
||||
len = lstrlenW(working_dir) + 1;
|
||||
ptr = working_dir;
|
||||
}
|
||||
|
||||
info->working_dir = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
|
||||
if (!info->working_dir)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
lstrcpynW(info->working_dir, ptr, len);
|
||||
|
||||
info->hinf = SetupOpenInfFileW(info->inf_filename, NULL, INF_STYLE_WIN4, NULL);
|
||||
if (info->hinf == INVALID_HANDLE_VALUE)
|
||||
return ADV_HRESULT(GetLastError());
|
||||
|
||||
set_ldids(info->hinf, info->install_sec, info->working_dir);
|
||||
|
||||
/* FIXME: check that the INF is advanced */
|
||||
|
||||
info->flags = flags;
|
||||
info->need_reboot = FALSE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/* release the install instance information */
|
||||
void install_release(ADVInfo *info)
|
||||
{
|
||||
if (info->hinf && info->hinf != INVALID_HANDLE_VALUE)
|
||||
SetupCloseInfFile(info->hinf);
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, info->inf_filename);
|
||||
HeapFree(GetProcessHeap(), 0, info->install_sec);
|
||||
HeapFree(GetProcessHeap(), 0, info->working_dir);
|
||||
}
|
||||
|
||||
/* this structure very closely resembles parameters of RunSetupCommand() */
|
||||
typedef struct
|
||||
{
|
||||
HWND hwnd;
|
||||
LPCSTR title;
|
||||
LPCSTR inf_name;
|
||||
LPCSTR dir;
|
||||
LPCSTR section_name;
|
||||
} SETUPCOMMAND_PARAMS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HWND hwnd;
|
||||
LPCWSTR title;
|
||||
LPCWSTR inf_name;
|
||||
LPCWSTR dir;
|
||||
LPCWSTR section_name;
|
||||
} SETUPCOMMAND_PARAMSW;
|
||||
|
||||
/* internal: see DoInfInstall */
|
||||
static HRESULT DoInfInstallW(const SETUPCOMMAND_PARAMSW *setup)
|
||||
{
|
||||
ADVInfo info;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p)\n", setup);
|
||||
|
||||
ZeroMemory(&info, sizeof(ADVInfo));
|
||||
|
||||
hr = install_init(setup->inf_name, setup->section_name, setup->dir, 0, &info);
|
||||
if (hr != S_OK)
|
||||
goto done;
|
||||
|
||||
hr = spapi_install(&info);
|
||||
if (hr != S_OK)
|
||||
goto done;
|
||||
|
||||
hr = adv_install(&info);
|
||||
|
||||
done:
|
||||
install_release(&info);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* DoInfInstall (ADVPACK.@)
|
||||
*
|
||||
* Install an INF section.
|
||||
*
|
||||
* PARAMS
|
||||
* setup [I] Structure containing install information.
|
||||
*
|
||||
* RETURNS
|
||||
* S_OK Everything OK
|
||||
* HRESULT_FROM_WIN32(GetLastError()) Some other error
|
||||
*/
|
||||
HRESULT WINAPI DoInfInstall(const SETUPCOMMAND_PARAMS *setup)
|
||||
{
|
||||
UNICODE_STRING title, inf, section, dir;
|
||||
SETUPCOMMAND_PARAMSW params;
|
||||
HRESULT hr;
|
||||
|
||||
if (!setup)
|
||||
return E_INVALIDARG;
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&title, setup->title);
|
||||
RtlCreateUnicodeStringFromAsciiz(&inf, setup->inf_name);
|
||||
RtlCreateUnicodeStringFromAsciiz(§ion, setup->section_name);
|
||||
RtlCreateUnicodeStringFromAsciiz(&dir, setup->dir);
|
||||
|
||||
params.title = title.Buffer;
|
||||
params.inf_name = inf.Buffer;
|
||||
params.section_name = section.Buffer;
|
||||
params.dir = dir.Buffer;
|
||||
params.hwnd = setup->hwnd;
|
||||
|
||||
hr = DoInfInstallW(¶ms);
|
||||
|
||||
RtlFreeUnicodeString(&title);
|
||||
RtlFreeUnicodeString(&inf);
|
||||
RtlFreeUnicodeString(§ion);
|
||||
RtlFreeUnicodeString(&dir);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* ExecuteCabA (ADVPACK.@)
|
||||
*
|
||||
* See ExecuteCabW.
|
||||
*/
|
||||
HRESULT WINAPI ExecuteCabA(HWND hwnd, CABINFOA* pCab, LPVOID pReserved)
|
||||
{
|
||||
UNICODE_STRING cab, inf, section;
|
||||
CABINFOW cabinfo;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %p, %p)\n", hwnd, pCab, pReserved);
|
||||
|
||||
if (!pCab)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (pCab->pszCab)
|
||||
{
|
||||
RtlCreateUnicodeStringFromAsciiz(&cab, pCab->pszCab);
|
||||
cabinfo.pszCab = cab.Buffer;
|
||||
}
|
||||
else
|
||||
cabinfo.pszCab = NULL;
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&inf, pCab->pszInf);
|
||||
RtlCreateUnicodeStringFromAsciiz(§ion, pCab->pszSection);
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, pCab->szSrcPath, -1, cabinfo.szSrcPath,
|
||||
sizeof(cabinfo.szSrcPath) / sizeof(WCHAR));
|
||||
|
||||
cabinfo.pszInf = inf.Buffer;
|
||||
cabinfo.pszSection = section.Buffer;
|
||||
cabinfo.dwFlags = pCab->dwFlags;
|
||||
|
||||
hr = ExecuteCabW(hwnd, &cabinfo, pReserved);
|
||||
|
||||
if (pCab->pszCab)
|
||||
RtlFreeUnicodeString(&cab);
|
||||
|
||||
RtlFreeUnicodeString(&inf);
|
||||
RtlFreeUnicodeString(§ion);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* ExecuteCabW (ADVPACK.@)
|
||||
*
|
||||
* Installs the INF file extracted from a specified cabinet file.
|
||||
*
|
||||
* PARAMS
|
||||
* hwnd [I] Handle to the window used for the display.
|
||||
* pCab [I] Information about the cabinet file.
|
||||
* pReserved [I] Reserved. Must be NULL.
|
||||
*
|
||||
* RETURNS
|
||||
* Success: S_OK.
|
||||
* Failure: E_FAIL.
|
||||
*/
|
||||
HRESULT WINAPI ExecuteCabW(HWND hwnd, CABINFOW* pCab, LPVOID pReserved)
|
||||
{
|
||||
ADVInfo info;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %p, %p)\n", hwnd, pCab, pReserved);
|
||||
|
||||
ZeroMemory(&info, sizeof(ADVInfo));
|
||||
|
||||
if (pCab->pszCab && *pCab->pszCab)
|
||||
FIXME("Cab archive not extracted!\n");
|
||||
|
||||
hr = install_init(pCab->pszInf, pCab->pszSection, pCab->szSrcPath, pCab->dwFlags, &info);
|
||||
if (hr != S_OK)
|
||||
goto done;
|
||||
|
||||
hr = spapi_install(&info);
|
||||
if (hr != S_OK)
|
||||
goto done;
|
||||
|
||||
hr = adv_install(&info);
|
||||
|
||||
done:
|
||||
install_release(&info);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* LaunchINFSectionA (ADVPACK.@)
|
||||
*
|
||||
* See LaunchINFSectionW.
|
||||
*/
|
||||
INT WINAPI LaunchINFSectionA(HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show)
|
||||
{
|
||||
UNICODE_STRING cmd;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_a(cmdline), show);
|
||||
|
||||
if (!cmdline)
|
||||
return ADV_FAILURE;
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&cmd, cmdline);
|
||||
|
||||
hr = LaunchINFSectionW(hWnd, hInst, cmd.Buffer, show);
|
||||
|
||||
RtlFreeUnicodeString(&cmd);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* LaunchINFSectionW (ADVPACK.@)
|
||||
*
|
||||
* Installs an INF section without BACKUP/ROLLBACK capabilities.
|
||||
*
|
||||
* PARAMS
|
||||
* hWnd [I] Handle to parent window, NULL for desktop.
|
||||
* hInst [I] Instance of the process.
|
||||
* cmdline [I] Contains parameters in the order INF,section,flags,reboot.
|
||||
* show [I] How the window should be shown.
|
||||
*
|
||||
* RETURNS
|
||||
* Success: ADV_SUCCESS.
|
||||
* Failure: ADV_FAILURE.
|
||||
*
|
||||
* NOTES
|
||||
* INF - Filename of the INF to launch.
|
||||
* section - INF section to install.
|
||||
* flags - see advpub.h.
|
||||
* reboot - smart reboot behavior
|
||||
* 'A' Always reboot.
|
||||
* 'I' Reboot if needed (default).
|
||||
* 'N' No reboot.
|
||||
*/
|
||||
INT WINAPI LaunchINFSectionW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
|
||||
{
|
||||
ADVInfo info;
|
||||
LPWSTR cmdline_copy, cmdline_ptr;
|
||||
LPWSTR inf_filename, install_sec;
|
||||
LPWSTR str_flags;
|
||||
DWORD flags = 0;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
TRACE("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_w(cmdline), show);
|
||||
|
||||
if (!cmdline)
|
||||
return ADV_FAILURE;
|
||||
|
||||
cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
|
||||
cmdline_ptr = cmdline_copy;
|
||||
lstrcpyW(cmdline_copy, cmdline);
|
||||
|
||||
inf_filename = get_parameter(&cmdline_ptr, ',');
|
||||
install_sec = get_parameter(&cmdline_ptr, ',');
|
||||
|
||||
str_flags = get_parameter(&cmdline_ptr, ',');
|
||||
if (str_flags)
|
||||
flags = atolW(str_flags);
|
||||
|
||||
ZeroMemory(&info, sizeof(ADVInfo));
|
||||
|
||||
hr = install_init(inf_filename, install_sec, NULL, flags, &info);
|
||||
if (hr != S_OK)
|
||||
goto done;
|
||||
|
||||
hr = spapi_install(&info);
|
||||
if (hr != S_OK)
|
||||
goto done;
|
||||
|
||||
hr = adv_install(&info);
|
||||
|
||||
done:
|
||||
install_release(&info);
|
||||
HeapFree(GetProcessHeap(), 0, cmdline_copy);
|
||||
|
||||
return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* LaunchINFSectionExA (ADVPACK.@)
|
||||
*
|
||||
* See LaunchINFSectionExW.
|
||||
*/
|
||||
HRESULT WINAPI LaunchINFSectionExA(HWND hWnd, HINSTANCE hInst, LPSTR cmdline, INT show)
|
||||
{
|
||||
UNICODE_STRING cmd;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %p, %s, %i)\n", hWnd, hInst, debugstr_a(cmdline), show);
|
||||
|
||||
if (!cmdline)
|
||||
return ADV_FAILURE;
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&cmd, cmdline);
|
||||
|
||||
hr = LaunchINFSectionExW(hWnd, hInst, cmd.Buffer, show);
|
||||
|
||||
RtlFreeUnicodeString(&cmd);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* LaunchINFSectionExW (ADVPACK.@)
|
||||
*
|
||||
* Installs an INF section with BACKUP/ROLLBACK capabilities.
|
||||
*
|
||||
* PARAMS
|
||||
* hWnd [I] Handle to parent window, NULL for desktop.
|
||||
* hInst [I] Instance of the process.
|
||||
* cmdline [I] Contains parameters in the order INF,section,CAB,flags,reboot.
|
||||
* show [I] How the window should be shown.
|
||||
*
|
||||
* RETURNS
|
||||
* Success: ADV_SUCCESS.
|
||||
* Failure: ADV_FAILURE.
|
||||
*
|
||||
* NOTES
|
||||
* INF - Filename of the INF to launch.
|
||||
* section - INF section to install.
|
||||
* flags - see advpub.h.
|
||||
* reboot - smart reboot behavior
|
||||
* 'A' Always reboot.
|
||||
* 'I' Reboot if needed (default).
|
||||
* 'N' No reboot.
|
||||
*
|
||||
* BUGS
|
||||
* Doesn't handle the reboot flag.
|
||||
*/
|
||||
HRESULT WINAPI LaunchINFSectionExW(HWND hWnd, HINSTANCE hInst, LPWSTR cmdline, INT show)
|
||||
{
|
||||
LPWSTR cmdline_copy, cmdline_ptr;
|
||||
LPWSTR flags, ptr;
|
||||
CABINFOW cabinfo;
|
||||
HRESULT hr = S_OK;
|
||||
|
||||
TRACE("(%p, %p, %s, %d)\n", hWnd, hInst, debugstr_w(cmdline), show);
|
||||
|
||||
if (!cmdline)
|
||||
return ADV_FAILURE;
|
||||
|
||||
cmdline_copy = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(cmdline) + 1) * sizeof(WCHAR));
|
||||
cmdline_ptr = cmdline_copy;
|
||||
lstrcpyW(cmdline_copy, cmdline);
|
||||
|
||||
cabinfo.pszInf = get_parameter(&cmdline_ptr, ',');
|
||||
cabinfo.pszSection = get_parameter(&cmdline_ptr, ',');
|
||||
cabinfo.pszCab = get_parameter(&cmdline_ptr, ',');
|
||||
*cabinfo.szSrcPath = '\0';
|
||||
|
||||
flags = get_parameter(&cmdline_ptr, ',');
|
||||
if (flags)
|
||||
cabinfo.dwFlags = atolW(flags);
|
||||
|
||||
/* get the source path from the cab filename */
|
||||
if (cabinfo.pszCab && *cabinfo.pszCab)
|
||||
{
|
||||
if (!is_full_path(cabinfo.pszCab))
|
||||
goto done;
|
||||
|
||||
lstrcpyW(cabinfo.szSrcPath, cabinfo.pszCab);
|
||||
ptr = strrchrW(cabinfo.szSrcPath, '\\');
|
||||
*(++ptr) = '\0';
|
||||
}
|
||||
|
||||
hr = ExecuteCabW(hWnd, &cabinfo, NULL);
|
||||
|
||||
done:
|
||||
HeapFree(GetProcessHeap(), 0, cmdline_copy);
|
||||
|
||||
return SUCCEEDED(hr) ? ADV_SUCCESS : ADV_FAILURE;
|
||||
}
|
||||
|
||||
HRESULT launch_exe(LPCWSTR cmd, LPCWSTR dir, HANDLE *phEXE)
|
||||
{
|
||||
STARTUPINFOW si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
if (phEXE) *phEXE = NULL;
|
||||
|
||||
ZeroMemory(&pi, sizeof(pi));
|
||||
ZeroMemory(&si, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
|
||||
if (!CreateProcessW(NULL, (LPWSTR)cmd, NULL, NULL, FALSE,
|
||||
CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP,
|
||||
NULL, dir, &si, &pi))
|
||||
{
|
||||
return HRESULT_FROM_WIN32(GetLastError());
|
||||
}
|
||||
|
||||
CloseHandle(pi.hThread);
|
||||
|
||||
if (phEXE)
|
||||
{
|
||||
*phEXE = pi.hProcess;
|
||||
return S_ASYNCHRONOUS;
|
||||
}
|
||||
|
||||
/* wait for the child process to finish */
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
CloseHandle(pi.hProcess);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RunSetupCommandA (ADVPACK.@)
|
||||
*
|
||||
* See RunSetupCommandW.
|
||||
*/
|
||||
HRESULT WINAPI RunSetupCommandA(HWND hWnd, LPCSTR szCmdName,
|
||||
LPCSTR szInfSection, LPCSTR szDir,
|
||||
LPCSTR lpszTitle, HANDLE *phEXE,
|
||||
DWORD dwFlags, LPVOID pvReserved)
|
||||
{
|
||||
UNICODE_STRING cmdname, infsec;
|
||||
UNICODE_STRING dir, title;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %s, %s, %s, %s, %p, %ld, %p)\n",
|
||||
hWnd, debugstr_a(szCmdName), debugstr_a(szInfSection),
|
||||
debugstr_a(szDir), debugstr_a(lpszTitle),
|
||||
phEXE, dwFlags, pvReserved);
|
||||
|
||||
if (!szCmdName || !szDir)
|
||||
return E_INVALIDARG;
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&cmdname, szCmdName);
|
||||
RtlCreateUnicodeStringFromAsciiz(&infsec, szInfSection);
|
||||
RtlCreateUnicodeStringFromAsciiz(&dir, szDir);
|
||||
RtlCreateUnicodeStringFromAsciiz(&title, lpszTitle);
|
||||
|
||||
hr = RunSetupCommandW(hWnd, cmdname.Buffer, infsec.Buffer, dir.Buffer,
|
||||
title.Buffer, phEXE, dwFlags, pvReserved);
|
||||
|
||||
RtlFreeUnicodeString(&cmdname);
|
||||
RtlFreeUnicodeString(&infsec);
|
||||
RtlFreeUnicodeString(&dir);
|
||||
RtlFreeUnicodeString(&title);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RunSetupCommandW (ADVPACK.@)
|
||||
*
|
||||
* Executes an install section in an INF file or a program.
|
||||
*
|
||||
* PARAMS
|
||||
* hWnd [I] Handle to parent window, NULL for quiet mode
|
||||
* szCmdName [I] Inf or EXE filename to execute
|
||||
* szInfSection [I] Inf section to install, NULL for DefaultInstall
|
||||
* szDir [I] Path to extracted files
|
||||
* szTitle [I] Title of all dialogs
|
||||
* phEXE [O] Handle of EXE to wait for
|
||||
* dwFlags [I] Flags; see include/advpub.h
|
||||
* pvReserved [I] Reserved
|
||||
*
|
||||
* RETURNS
|
||||
* S_OK Everything OK
|
||||
* S_ASYNCHRONOUS OK, required to wait on phEXE
|
||||
* ERROR_SUCCESS_REBOOT_REQUIRED Reboot required
|
||||
* E_INVALIDARG Invalid argument given
|
||||
* HRESULT_FROM_WIN32(ERROR_OLD_WIN_VERSION)
|
||||
* Not supported on this Windows version
|
||||
* E_UNEXPECTED Unexpected error
|
||||
* HRESULT_FROM_WIN32(GetLastError()) Some other error
|
||||
*/
|
||||
HRESULT WINAPI RunSetupCommandW(HWND hWnd, LPCWSTR szCmdName,
|
||||
LPCWSTR szInfSection, LPCWSTR szDir,
|
||||
LPCWSTR lpszTitle, HANDLE *phEXE,
|
||||
DWORD dwFlags, LPVOID pvReserved)
|
||||
{
|
||||
ADVInfo info;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %s, %s, %s, %s, %p, %ld, %p)\n",
|
||||
hWnd, debugstr_w(szCmdName), debugstr_w(szInfSection),
|
||||
debugstr_w(szDir), debugstr_w(lpszTitle),
|
||||
phEXE, dwFlags, pvReserved);
|
||||
|
||||
if (dwFlags & RSC_FLAG_UPDHLPDLLS)
|
||||
FIXME("Unhandled flag: RSC_FLAG_UPDHLPDLLS\n");
|
||||
|
||||
if (!szCmdName || !szDir)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (!(dwFlags & RSC_FLAG_INF))
|
||||
return launch_exe(szCmdName, szDir, phEXE);
|
||||
|
||||
ZeroMemory(&info, sizeof(ADVInfo));
|
||||
|
||||
hr = install_init(szCmdName, szInfSection, szDir, dwFlags, &info);
|
||||
if (hr != S_OK)
|
||||
goto done;
|
||||
|
||||
hr = spapi_install(&info);
|
||||
if (hr != S_OK)
|
||||
goto done;
|
||||
|
||||
hr = adv_install(&info);
|
||||
|
||||
done:
|
||||
install_release(&info);
|
||||
|
||||
return hr;
|
||||
}
|
439
reactos/dll/win32/advpack/reg.c
Normal file
439
reactos/dll/win32/advpack/reg.c
Normal file
|
@ -0,0 +1,439 @@
|
|||
/*
|
||||
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#include "winerror.h"
|
||||
#include "winuser.h"
|
||||
#include "winternl.h"
|
||||
#include "setupapi.h"
|
||||
#include "advpub.h"
|
||||
#include "wine/unicode.h"
|
||||
#include "wine/debug.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 const WCHAR quote[] = {'\"',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;
|
||||
}
|
||||
|
||||
static void strentry_atow(STRENTRYA *aentry, STRENTRYW *wentry)
|
||||
{
|
||||
DWORD name_len, val_len;
|
||||
|
||||
name_len = MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, NULL, 0);
|
||||
val_len = MultiByteToWideChar(CP_ACP, 0, aentry->pszValue, -1, NULL, 0);
|
||||
|
||||
wentry->pszName = HeapAlloc(GetProcessHeap(), 0, name_len * sizeof(WCHAR));
|
||||
wentry->pszValue = HeapAlloc(GetProcessHeap(), 0, val_len * sizeof(WCHAR));
|
||||
|
||||
MultiByteToWideChar(CP_ACP, 0, aentry->pszName, -1, wentry->pszName, name_len);
|
||||
MultiByteToWideChar(CP_ACP, 0, aentry->pszValue, -1, wentry->pszValue, val_len);
|
||||
}
|
||||
|
||||
static STRTABLEW *strtable_atow(const STRTABLEA *atable)
|
||||
{
|
||||
STRTABLEW *wtable;
|
||||
DWORD j;
|
||||
|
||||
wtable = HeapAlloc(GetProcessHeap(), 0, sizeof(STRTABLEW));
|
||||
wtable->pse = HeapAlloc(GetProcessHeap(), 0, atable->cEntries * sizeof(STRENTRYW));
|
||||
wtable->cEntries = atable->cEntries;
|
||||
|
||||
for (j = 0; j < wtable->cEntries; j++)
|
||||
strentry_atow(&atable->pse[j], &wtable->pse[j]);
|
||||
|
||||
return wtable;
|
||||
}
|
||||
|
||||
static void free_strtable(STRTABLEW *wtable)
|
||||
{
|
||||
DWORD j;
|
||||
|
||||
for (j = 0; j < wtable->cEntries; j++)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, wtable->pse[j].pszName);
|
||||
HeapFree(GetProcessHeap(), 0, wtable->pse[j].pszValue);
|
||||
}
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, wtable->pse);
|
||||
HeapFree(GetProcessHeap(), 0, wtable);
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RegInstallA (advpack.@)
|
||||
*
|
||||
* See RegInstallW.
|
||||
*/
|
||||
HRESULT WINAPI RegInstallA(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable)
|
||||
{
|
||||
UNICODE_STRING section;
|
||||
STRTABLEW *wtable;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %s, %p)\n", hm, debugstr_a(pszSection), pstTable);
|
||||
|
||||
if (pstTable)
|
||||
wtable = strtable_atow(pstTable);
|
||||
else
|
||||
wtable = NULL;
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(§ion, pszSection);
|
||||
|
||||
hr = RegInstallW(hm, section.Buffer, wtable);
|
||||
|
||||
if (pstTable)
|
||||
free_strtable(wtable);
|
||||
|
||||
RtlFreeUnicodeString(§ion);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
static HRESULT write_predefined_strings(HMODULE hm, LPWSTR ini_path)
|
||||
{
|
||||
WCHAR mod_path[MAX_PATH + 2];
|
||||
WCHAR sys_mod_path[MAX_PATH + 2];
|
||||
WCHAR sys_root[MAX_PATH];
|
||||
|
||||
*mod_path = '\"';
|
||||
if (!GetModuleFileNameW(hm, mod_path + 1, sizeof(mod_path) / sizeof(WCHAR) - 2))
|
||||
return E_FAIL;
|
||||
|
||||
lstrcatW(mod_path, quote);
|
||||
WritePrivateProfileStringW(Strings, MOD_PATH, mod_path, 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 = '\"';
|
||||
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, ini_path);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RegInstallW (advpack.@)
|
||||
*
|
||||
* Loads an INF from a string resource, adds entries to the string
|
||||
* substitution table, and executes the INF.
|
||||
*
|
||||
* PARAMS
|
||||
* hm [I] Module that contains the REGINST resouce.
|
||||
* pszSection [I] The INF section to execute.
|
||||
* pstTable [I] Table of string substitutions.
|
||||
*
|
||||
* RETURNS
|
||||
* Success: S_OK.
|
||||
* Failure: E_FAIL.
|
||||
*/
|
||||
HRESULT WINAPI RegInstallW(HMODULE hm, LPCWSTR pszSection, const STRTABLEW* pstTable)
|
||||
{
|
||||
int i;
|
||||
CABINFOW cabinfo;
|
||||
WCHAR tmp_ini_path[MAX_PATH];
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
TRACE("(%p, %s, %p)\n", hm, debugstr_w(pszSection), pstTable);
|
||||
|
||||
if(!create_tmp_ini_file(hm, tmp_ini_path))
|
||||
return E_FAIL;
|
||||
|
||||
if (write_predefined_strings(hm, tmp_ini_path))
|
||||
goto done;
|
||||
|
||||
/* Write the additional string table */
|
||||
if (pstTable)
|
||||
{
|
||||
for(i = 0; i < pstTable->cEntries; i++)
|
||||
{
|
||||
WCHAR tmp_value[MAX_PATH + 2];
|
||||
|
||||
tmp_value[0] = '\"';
|
||||
lstrcpyW(tmp_value + 1, pstTable->pse[i].pszValue);
|
||||
lstrcatW(tmp_value, quote);
|
||||
|
||||
WritePrivateProfileStringW(Strings, pstTable->pse[i].pszName, tmp_value, tmp_ini_path);
|
||||
}
|
||||
}
|
||||
|
||||
/* flush cache */
|
||||
WritePrivateProfileStringW(NULL, NULL, NULL, tmp_ini_path);
|
||||
|
||||
/* FIXME: read AdvOptions val for dwFlags */
|
||||
ZeroMemory(&cabinfo, sizeof(CABINFOW));
|
||||
cabinfo.pszInf = tmp_ini_path;
|
||||
cabinfo.pszSection = (LPWSTR)pszSection;
|
||||
cabinfo.dwFlags = 0;
|
||||
|
||||
hr = ExecuteCabW(NULL, &cabinfo, NULL);
|
||||
|
||||
done:
|
||||
|
||||
DeleteFileW(tmp_ini_path);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RegRestoreAllA (advpack.@)
|
||||
*
|
||||
* See RegRestoreAllW.
|
||||
*/
|
||||
HRESULT WINAPI RegRestoreAllA(HWND hWnd, LPSTR pszTitleString, HKEY hkBackupKey)
|
||||
{
|
||||
UNICODE_STRING title;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %s, %p)\n", hWnd, debugstr_a(pszTitleString), hkBackupKey);
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&title, pszTitleString);
|
||||
|
||||
hr = RegRestoreAllW(hWnd, title.Buffer, hkBackupKey);
|
||||
|
||||
RtlFreeUnicodeString(&title);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RegRestoreAllW (advpack.@)
|
||||
*
|
||||
* Restores all saved registry entries.
|
||||
*
|
||||
* PARAMS
|
||||
* hWnd [I] Handle to the window used for the display.
|
||||
* pszTitleString [I] Title of the window.
|
||||
* hkBackupKey [I] Handle to the backup key.
|
||||
*
|
||||
* RETURNS
|
||||
* Success: S_OK.
|
||||
* Failure: E_FAIL.
|
||||
*
|
||||
* BUGS
|
||||
* Unimplemented.
|
||||
*/
|
||||
HRESULT WINAPI RegRestoreAllW(HWND hWnd, LPWSTR pszTitleString, HKEY hkBackupKey)
|
||||
{
|
||||
FIXME("(%p, %s, %p) stub\n", hWnd, debugstr_w(pszTitleString), hkBackupKey);
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RegSaveRestoreA (advpack.@)
|
||||
*
|
||||
* See RegSaveRestoreW.
|
||||
*/
|
||||
HRESULT WINAPI RegSaveRestoreA(HWND hWnd, LPCSTR pszTitleString, HKEY hkBackupKey,
|
||||
LPCSTR pcszRootKey, LPCSTR pcszSubKey,
|
||||
LPCSTR pcszValueName, DWORD dwFlags)
|
||||
{
|
||||
UNICODE_STRING title, root, subkey, value;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %s, %p, %s, %s, %s, %ld)\n", hWnd, debugstr_a(pszTitleString),
|
||||
hkBackupKey, debugstr_a(pcszRootKey), debugstr_a(pcszSubKey),
|
||||
debugstr_a(pcszValueName), dwFlags);
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&title, pszTitleString);
|
||||
RtlCreateUnicodeStringFromAsciiz(&root, pcszRootKey);
|
||||
RtlCreateUnicodeStringFromAsciiz(&subkey, pcszSubKey);
|
||||
RtlCreateUnicodeStringFromAsciiz(&value, pcszValueName);
|
||||
|
||||
hr = RegSaveRestoreW(hWnd, title.Buffer, hkBackupKey, root.Buffer,
|
||||
subkey.Buffer, value.Buffer, dwFlags);
|
||||
|
||||
RtlFreeUnicodeString(&title);
|
||||
RtlFreeUnicodeString(&root);
|
||||
RtlFreeUnicodeString(&subkey);
|
||||
RtlFreeUnicodeString(&value);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RegSaveRestoreW (advpack.@)
|
||||
*
|
||||
* Saves or restores the specified registry value.
|
||||
*
|
||||
* PARAMS
|
||||
* hWnd [I] Handle to the window used for the display.
|
||||
* pszTitleString [I] Title of the window.
|
||||
* hkBackupKey [I] Key used to store the backup data.
|
||||
* pcszRootKey [I] Root key of the registry value
|
||||
* pcszSubKey [I] Sub key of the registry value.
|
||||
* pcszValueName [I] Value to save or restore.
|
||||
* dwFlags [I] See advpub.h.
|
||||
*
|
||||
* RETURNS
|
||||
* Success: S_OK.
|
||||
* Failure: E_FAIL.
|
||||
*
|
||||
* BUGS
|
||||
* Unimplemented.
|
||||
*/
|
||||
HRESULT WINAPI RegSaveRestoreW(HWND hWnd, LPCWSTR pszTitleString, HKEY hkBackupKey,
|
||||
LPCWSTR pcszRootKey, LPCWSTR pcszSubKey,
|
||||
LPCWSTR pcszValueName, DWORD dwFlags)
|
||||
{
|
||||
FIXME("(%p, %s, %p, %s, %s, %s, %ld): stub\n", hWnd, debugstr_w(pszTitleString),
|
||||
hkBackupKey, debugstr_w(pcszRootKey), debugstr_w(pcszSubKey),
|
||||
debugstr_w(pcszValueName), dwFlags);
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RegSaveRestoreOnINFA (advpack.@)
|
||||
*
|
||||
* See RegSaveRestoreOnINFW.
|
||||
*/
|
||||
HRESULT WINAPI RegSaveRestoreOnINFA(HWND hWnd, LPCSTR pszTitle, LPCSTR pszINF,
|
||||
LPCSTR pszSection, HKEY hHKLMBackKey,
|
||||
HKEY hHKCUBackKey, DWORD dwFlags)
|
||||
{
|
||||
UNICODE_STRING title, inf, section;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("(%p, %s, %s, %s, %p, %p, %ld)\n", hWnd, debugstr_a(pszTitle),
|
||||
debugstr_a(pszINF), debugstr_a(pszSection),
|
||||
hHKLMBackKey, hHKCUBackKey, dwFlags);
|
||||
|
||||
RtlCreateUnicodeStringFromAsciiz(&title, pszTitle);
|
||||
RtlCreateUnicodeStringFromAsciiz(&inf, pszINF);
|
||||
RtlCreateUnicodeStringFromAsciiz(§ion, pszSection);
|
||||
|
||||
hr = RegSaveRestoreOnINFW(hWnd, title.Buffer, inf.Buffer, section.Buffer,
|
||||
hHKLMBackKey, hHKCUBackKey, dwFlags);
|
||||
|
||||
RtlFreeUnicodeString(&title);
|
||||
RtlFreeUnicodeString(&inf);
|
||||
RtlFreeUnicodeString(§ion);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* RegSaveRestoreOnINFW (advpack.@)
|
||||
*
|
||||
* Saves or restores the specified INF Reg section.
|
||||
*
|
||||
* PARAMS
|
||||
* hWnd [I] Handle to the window used for the display.
|
||||
* pszTitle [I] Title of the window.
|
||||
* pszINF [I] Filename of the INF.
|
||||
* pszSection [I] Section to save or restore.
|
||||
* hHKLMBackKey [I] Opened key in HKLM to store data.
|
||||
* hHKCUBackKey [I] Opened key in HKCU to store data.
|
||||
* dwFlags [I] See advpub.h
|
||||
*
|
||||
* RETURNS
|
||||
* Success: S_OK.
|
||||
* Failure: E_FAIL.
|
||||
*
|
||||
* BUGS
|
||||
* Unimplemented.
|
||||
*/
|
||||
HRESULT WINAPI RegSaveRestoreOnINFW(HWND hWnd, LPCWSTR pszTitle, LPCWSTR pszINF,
|
||||
LPCWSTR pszSection, HKEY hHKLMBackKey,
|
||||
HKEY hHKCUBackKey, DWORD dwFlags)
|
||||
{
|
||||
FIXME("(%p, %s, %s, %s, %p, %p, %ld): stub\n", hWnd, debugstr_w(pszTitle),
|
||||
debugstr_w(pszINF), debugstr_w(pszSection),
|
||||
hHKLMBackKey, hHKCUBackKey, dwFlags);
|
||||
|
||||
return E_FAIL;
|
||||
}
|
|
@ -37,6 +37,7 @@ reactos/tools/widl # Synced to Wine-20060729
|
|||
|
||||
The following libraries are shared with Wine.
|
||||
|
||||
reactos/dll/win32/advpack # Autosync
|
||||
reactos/dll/win32/avifil32 # Autosync
|
||||
reactos/dll/win32/cabinet # Autosync
|
||||
reactos/dll/win32/comctl32 # Autosync
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue