update wine to wine-1.1.7
[sugaredwine.git] / patches / 0001-setupapi-add-minimal-implementation-of-ProfileItems.patch
blobe313b475e74cc24bb626c2fc1b35e55bc94fce13
1 From 5a2d7be3f6ce4dedf2ec876c51adce9c23c749dc Mon Sep 17 00:00:00 2001
2 From: Vincent Povirk <vincent@codeweavers.com>
3 Date: Wed, 10 Sep 2008 16:08:14 -0500
4 Subject: [PATCH] setupapi: add minimal implementation of ProfileItems directive
6 ---
7 dlls/setupapi/Makefile.in | 2 +-
8 dlls/setupapi/install.c | 136 ++++++++++++++++++++++++++++++++++++++++++++-
9 2 files changed, 136 insertions(+), 2 deletions(-)
11 diff --git a/dlls/setupapi/Makefile.in b/dlls/setupapi/Makefile.in
12 index 1f633a4..91bc87b 100644
13 --- a/dlls/setupapi/Makefile.in
14 +++ b/dlls/setupapi/Makefile.in
15 @@ -6,7 +6,7 @@ VPATH = @srcdir@
16 MODULE = setupapi.dll
17 IMPORTLIB = setupapi
18 IMPORTS = uuid user32 version advapi32 rpcrt4 kernel32 ntdll
19 -DELAYIMPORTS = shell32 wintrust
20 +DELAYIMPORTS = shell32 wintrust ole32
22 C_SRCS = \
23 devinst.c \
24 diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c
25 index 321d4d4..aa0c6cb 100644
26 --- a/dlls/setupapi/install.c
27 +++ b/dlls/setupapi/install.c
28 @@ -20,6 +20,8 @@
30 #include <stdarg.h>
32 +#define COBJMACROS
34 #include "windef.h"
35 #include "winbase.h"
36 #include "winreg.h"
37 @@ -29,6 +31,9 @@
38 #include "winuser.h"
39 #include "winnls.h"
40 #include "winsvc.h"
41 +#include "shlobj.h"
42 +#include "objidl.h"
43 +#include "objbase.h"
44 #include "setupapi.h"
45 #include "setupapi_private.h"
46 #include "wine/unicode.h"
47 @@ -79,6 +84,8 @@ static const WCHAR UpdateIniFields[] = {'U','p','d','a','t','e','I','n','i','F',
48 static const WCHAR RegisterDlls[] = {'R','e','g','i','s','t','e','r','D','l','l','s',0};
49 static const WCHAR UnregisterDlls[] = {'U','n','r','e','g','i','s','t','e','r','D','l','l','s',0};
50 static const WCHAR ProfileItems[] = {'P','r','o','f','i','l','e','I','t','e','m','s',0};
51 +static const WCHAR Name[] = {'N','a','m','e',0};
52 +static const WCHAR CmdLine[] = {'C','m','d','L','i','n','e',0};
53 static const WCHAR WineFakeDlls[] = {'W','i','n','e','F','a','k','e','D','l','l','s',0};
54 static const WCHAR DisplayName[] = {'D','i','s','p','l','a','y','N','a','m','e',0};
55 static const WCHAR Description[] = {'D','e','s','c','r','i','p','t','i','o','n',0};
56 @@ -773,9 +780,136 @@ static BOOL bitreg_callback( HINF hinf, PCWSTR field, void *arg )
57 return TRUE;
60 +static LPCWSTR pathsepW( LPCWSTR path )
62 + static const WCHAR backslash[] = {'\\',0};
64 + if (path && path[0] && path[strlenW(path)-1] != '\\')
65 + return backslash;
66 + else
67 + return NULL;
70 +static LPWSTR join_stringsW(DWORD count, ...)
72 + size_t len=0;
73 + va_list va;
74 + int i;
75 + LPWSTR result, end;
77 + va_start(va, count);
78 + for (i=0; i<count; i++)
79 + {
80 + LPCWSTR str = va_arg(va, LPCWSTR);
81 + if (str) len += strlenW(str);
82 + }
83 + va_end(va);
85 + end = result = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
86 + if (!result)
87 + return NULL;
89 + va_start(va, count);
90 + for (i=0; i<count; i++)
91 + {
92 + LPCWSTR str = va_arg(va, LPCWSTR);
94 + if (str)
95 + {
96 + strcpyW(end, str);
97 + end = end + strlenW(str);
98 + }
99 + }
100 + va_end(va);
102 + return result;
105 static BOOL profile_items_callback( HINF hinf, PCWSTR field, void *arg )
107 - FIXME( "should do profile items %s\n", debugstr_w(field) );
108 + LPWSTR name=NULL, lnkpath=NULL, cmdline=NULL;
109 + WCHAR lnkdir[MAX_PATH];
110 + INFCONTEXT context;
111 + IShellLinkW* shelllink=NULL;
112 + IPersistFile* persistfile=NULL;
113 + int attrs=0;
115 + static const WCHAR dotlnk[] = {'.','l','n','k',0};
117 + TRACE( "(%s)\n", debugstr_w(field) );
119 + if (SetupFindFirstLineW( hinf, field, Name, &context ))
121 + name = dup_section_line_field( hinf, field, Name, 1 );
123 + SetupGetIntField( &context, 2, &attrs );
125 + if (attrs)
126 + FIXME( "unhandled attributes: %x\n", attrs );
129 + if (!name)
131 + ERR( "missing Name entry\n" );
133 + return TRUE;
136 + if (SetupFindFirstLineW( hinf, field, CmdLine, &context ))
138 + LPWSTR dir=NULL, filename=NULL;
140 + if ((dir = PARSER_get_dest_dir( &context )) &&
141 + (filename = dup_section_line_field( hinf, field, CmdLine, 3 )))
143 + cmdline = join_stringsW( 3, dir, pathsepW(dir), filename );
146 + HeapFree( GetProcessHeap(), 0, dir );
147 + HeapFree( GetProcessHeap(), 0, filename );
150 + if (!cmdline)
152 + ERR( "missing CmdLine entry\n" );
154 + HeapFree( GetProcessHeap(), 0, cmdline );
155 + return TRUE;
158 + TRACE( "name: %s\n", debugstr_w(name) );
159 + TRACE( "cmdline: %s\n", debugstr_w(cmdline) );
161 + CoInitialize(NULL);
163 + if (!SUCCEEDED(CoCreateInstance( &CLSID_ShellLink, NULL,
164 + CLSCTX_INPROC_SERVER, &IID_IShellLinkW, (LPVOID*)&shelllink)))
166 + ERR( "failed to create IShellLink instance\n" );
167 + return TRUE;
170 + IShellLinkW_SetPath( shelllink, cmdline );
172 + SHGetFolderPathW( NULL, CSIDL_COMMON_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, lnkdir );
174 + lnkpath = join_stringsW( 4, lnkdir, pathsepW(lnkdir), name, dotlnk );
176 + if (SUCCEEDED(IShellLinkW_QueryInterface( shelllink, &IID_IPersistFile, (LPVOID*)&persistfile)))
178 + TRACE( "writing link: %s\n", debugstr_w(lnkpath) );
180 + IPersistFile_Save( persistfile, lnkpath, FALSE );
182 + IPersistFile_Release( persistfile );
185 + HeapFree( GetProcessHeap(), 0, name );
186 + HeapFree( GetProcessHeap(), 0, cmdline );
187 + HeapFree( GetProcessHeap(), 0, lnkpath );
189 + IShellLinkW_Release( shelllink );
191 return TRUE;
195 1.5.6.5