mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 08:03:03 +00:00
[WINESYNC] setupapi: Move strdupW and strdupWtoA to the setupapi_private.h header.
wine commit id 44ab294e0b6f285f1aab5fc8533a36e852be38fa by Alexandre Julliard <julliard@winehq.org>
[WINESYNC] setupapi: Remove unneeded address-of operator from array name.
wine commit id ce2184e2f14e6ace87cd50c938b5e99d35ca80c1 by Andrew Talbot <andrew.talbot@talbotville.com>
[WINESYNC] setupapi: Do not cast NULL.
wine commit id d62b48df2acece81b533a92fbca566cc4023be43 by Michael Stefaniuc <mstefani@redhat.de>
[WINESYNC] setupapi: Implement SetupInstallFile{A, W}.
wine commit id 19764fcf4c7c05d5badbef54be64170c2ebadd83 by Hans Leidekker <hans@codeweavers.com>
NOTE: Already committed in ReactOS in commit 336ef53fa
(r37876).
The lost memory cleanup on failure will be recovered by wine commit
4d796458d0ed517d45adc57a1aedaf1c3bdde232
[WINESYNC] setupapi: Implement StringTableAddStringEx.
wine commit id c2f99f30143e1180620980f3d5713456392c8ecf by Hans Leidekker <hans@codeweavers.com>
+ Re-integrate existing ReactOS bug fixes
+ Add missing dwExtraDataSize && lpExtraData zero/NULL checks in StringTableAddStringEx
Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
[WINESYNC] setupapi: Fix typo in StringTableGetExtraData.
wine commit id d8dad22c9783e1868ec4bb72d8051dd0a5f4f0a7 by Hans Leidekker <hans@codeweavers.com>
[WINESYNC] setupapi: Implement StringTableLookUpStringEx.
wine commit id 18b5366c35f95eb6e7fc6e19c50c371a81d5a980 by Hans Leidekker <hans@codeweavers.com>
[WINESYNC] setupapi: Add some tests for StringTableLookUpStringEx. Make them pass.
wine commit id 601870a4351753555bfa351a23328b2e1109c7b0 by Hans Leidekker <hans@codeweavers.com>
[WINESYNC] setupapi: Fix the StringTableLookUpStringEx() prototype.
wine commit id 916d6a44500735b3fecf0e7c485c2aa7e8025644 by Francois Gouget <fgouget@free.fr>
These commits have been grouped together, since all of these were
partially already present in the forked stringtable.c code.
[WINESYNC] setupapi: Implement SetupInstallFileExA/W.
wine commit id bd9c265cc26a4cf2c9141a99dadb2f9ccf4b6f8c by Hans Leidekker <hans@codeweavers.com>
[WINESYNC] setupapi: Remove superfluous pointer casts.
wine commit id ffae0123ac46ba6dfac74d7c84422073fd53b580 by Michael Stefaniuc <mstefani@redhat.de>
[WINESYNC] setupapi: Fix memory leak.
Found by Valgrind.
wine commit id 63231be8044441218fb82899e748900e1ace3d0d by Huw Davies <huw@codeweavers.com>
NOTE: Some of the code was already present as part of ReactOS-specific
changes. It has been slightly adapted to suit Wine changes.
Co-authored-by: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
[WINESYNC] setupapi: Destination directory defaults to system directory.
wine commit id 1b8ba2537111f0d691d2592bb4ffb6bc4fe4f20e by Hans Leidekker <hans@codeweavers.com>
[WINESYNC] setupapi: Avoid hardcoding the Unicode string literal lengths.
wine commit id 9097fa132e56cc542fa3ea77706fea79353d2f4a by Francois Gouget <fgouget@free.fr>
[WINESYNC] setupapi: Avoid memory leaks (coverity).
wine commit id 4d796458d0ed517d45adc57a1aedaf1c3bdde232 by André Hentschel <nerv@dawncrow.de>
[WINESYNC]: setupapi/stringtable.c is now in sync with wine-staging wine-1.7.18
This commit is contained in:
parent
e087c1ab10
commit
56ece9b185
6 changed files with 173 additions and 241 deletions
|
@ -69,29 +69,6 @@ struct file_queue
|
|||
};
|
||||
|
||||
|
||||
static inline WCHAR *strdupW( const WCHAR *str )
|
||||
{
|
||||
WCHAR *ret = NULL;
|
||||
if (str)
|
||||
{
|
||||
int len = (strlenW(str) + 1) * sizeof(WCHAR);
|
||||
if ((ret = HeapAlloc( GetProcessHeap(), 0, len ))) memcpy( ret, str, len );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static inline char *strdupWtoA( const WCHAR *str )
|
||||
{
|
||||
char *ret = NULL;
|
||||
if (str)
|
||||
{
|
||||
DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL );
|
||||
if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
|
||||
WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* append a file operation to a queue */
|
||||
static inline void queue_file_op( struct file_op_queue *queue, struct file_op *op )
|
||||
{
|
||||
|
@ -203,7 +180,7 @@ UINT CALLBACK QUEUE_callback_WtoA( void *context, UINT notification,
|
|||
switch(notification)
|
||||
{
|
||||
case SPFILENOTIFY_COPYERROR:
|
||||
param2 = (UINT_PTR)&buffer;
|
||||
param2 = (UINT_PTR)buffer;
|
||||
/* fall through */
|
||||
case SPFILENOTIFY_STARTDELETE:
|
||||
case SPFILENOTIFY_ENDDELETE:
|
||||
|
@ -363,10 +340,17 @@ static WCHAR *get_destination_dir( HINF hinf, const WCHAR *section )
|
|||
static const WCHAR Dest[] = {'D','e','s','t','i','n','a','t','i','o','n','D','i','r','s',0};
|
||||
static const WCHAR Def[] = {'D','e','f','a','u','l','t','D','e','s','t','D','i','r',0};
|
||||
INFCONTEXT context;
|
||||
WCHAR systemdir[MAX_PATH], *dir;
|
||||
BOOL ret;
|
||||
|
||||
if (!SetupFindFirstLineW( hinf, Dest, section, &context ) &&
|
||||
!SetupFindFirstLineW( hinf, Dest, Def, &context )) return NULL;
|
||||
return PARSER_get_dest_dir( &context );
|
||||
if (!(ret = SetupFindFirstLineW( hinf, Dest, section, &context )))
|
||||
ret = SetupFindFirstLineW( hinf, Dest, Def, &context );
|
||||
|
||||
if (ret && (dir = PARSER_get_dest_dir( &context )))
|
||||
return dir;
|
||||
|
||||
GetSystemDirectoryW( systemdir, MAX_PATH );
|
||||
return strdupW( systemdir );
|
||||
}
|
||||
|
||||
struct extract_cab_ctx
|
||||
|
@ -798,7 +782,7 @@ BOOL WINAPI SetupQueueCopySectionW( HSPFILEQ queue, PCWSTR src_root, HINF hinf,
|
|||
INFCONTEXT security_context;
|
||||
#endif
|
||||
INFCONTEXT context;
|
||||
WCHAR dest[MAX_PATH], src[MAX_PATH];
|
||||
WCHAR dest[MAX_PATH], src[MAX_PATH], *dest_dir;
|
||||
INT flags;
|
||||
BOOL ret;
|
||||
|
||||
|
@ -851,19 +835,20 @@ BOOL WINAPI SetupQueueCopySectionW( HSPFILEQ queue, PCWSTR src_root, HINF hinf,
|
|||
if (!hlist) hlist = hinf;
|
||||
if (!hinf) hinf = hlist;
|
||||
if (!SetupFindFirstLineW( hlist, section, NULL, &context )) goto done;
|
||||
if (!(params.TargetDirectory = get_destination_dir( hinf, section ))) goto done;
|
||||
if (!(params.TargetDirectory = dest_dir = get_destination_dir( hinf, section ))) goto done;
|
||||
do
|
||||
{
|
||||
if (!SetupGetStringFieldW( &context, 1, dest, sizeof(dest)/sizeof(WCHAR), NULL ))
|
||||
goto done;
|
||||
goto end;
|
||||
if (!SetupGetStringFieldW( &context, 2, src, sizeof(src)/sizeof(WCHAR), NULL )) *src = 0;
|
||||
if (!SetupGetIntField( &context, 4, &flags )) flags = 0; /* FIXME */
|
||||
|
||||
params.SourceFilename = *src ? src : NULL;
|
||||
if (!SetupQueueCopyIndirectW( ¶ms )) goto done;
|
||||
if (!SetupQueueCopyIndirectW( ¶ms )) goto end;
|
||||
} while (SetupFindNextLine( &context, &context ));
|
||||
ret = TRUE;
|
||||
|
||||
end:
|
||||
HeapFree(GetProcessHeap(), 0, dest_dir);
|
||||
done:
|
||||
#ifdef __REACTOS__
|
||||
if (security_descriptor)
|
||||
|
@ -1163,7 +1148,7 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
|||
VS_FIXEDFILEINFO *TargetInfo;
|
||||
VS_FIXEDFILEINFO *SourceInfo;
|
||||
UINT length;
|
||||
WCHAR SubBlock[2]={'\\',0};
|
||||
static const WCHAR SubBlock[]={'\\',0};
|
||||
DWORD ret;
|
||||
|
||||
VersionSource = HeapAlloc(GetProcessHeap(),0,VersionSizeSource);
|
||||
|
@ -1263,17 +1248,17 @@ static BOOL do_file_copyW( LPCWSTR source, LPCWSTR target, DWORD style,
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupInstallFileA (SETUPAPI.@)
|
||||
* SetupInstallFileExA (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupInstallFileA( HINF hinf, PINFCONTEXT inf_context, PCSTR source, PCSTR root,
|
||||
PCSTR dest, DWORD style, PSP_FILE_CALLBACK_A handler, PVOID context )
|
||||
BOOL WINAPI SetupInstallFileExA( HINF hinf, PINFCONTEXT inf_context, PCSTR source, PCSTR root,
|
||||
PCSTR dest, DWORD style, PSP_FILE_CALLBACK_A handler, PVOID context, PBOOL in_use )
|
||||
{
|
||||
BOOL ret = FALSE;
|
||||
struct callback_WtoA_context ctx;
|
||||
UNICODE_STRING sourceW, rootW, destW;
|
||||
|
||||
TRACE("%p %p %s %s %s %x %p %p\n", hinf, inf_context, debugstr_a(source), debugstr_a(root),
|
||||
debugstr_a(dest), style, handler, context);
|
||||
TRACE("%p %p %s %s %s %x %p %p %p\n", hinf, inf_context, debugstr_a(source), debugstr_a(root),
|
||||
debugstr_a(dest), style, handler, context, in_use);
|
||||
|
||||
sourceW.Buffer = rootW.Buffer = destW.Buffer = NULL;
|
||||
if (source && !RtlCreateUnicodeStringFromAsciiz( &sourceW, source ))
|
||||
|
@ -1295,7 +1280,7 @@ BOOL WINAPI SetupInstallFileA( HINF hinf, PINFCONTEXT inf_context, PCSTR source,
|
|||
ctx.orig_context = context;
|
||||
ctx.orig_handler = handler;
|
||||
|
||||
ret = SetupInstallFileW( hinf, inf_context, sourceW.Buffer, rootW.Buffer, destW.Buffer, style, QUEUE_callback_WtoA, &ctx );
|
||||
ret = SetupInstallFileExW( hinf, inf_context, sourceW.Buffer, rootW.Buffer, destW.Buffer, style, QUEUE_callback_WtoA, &ctx, in_use );
|
||||
|
||||
exit:
|
||||
RtlFreeUnicodeString( &sourceW );
|
||||
|
@ -1305,10 +1290,19 @@ exit:
|
|||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupInstallFileW (SETUPAPI.@)
|
||||
* SetupInstallFileA (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupInstallFileW( HINF hinf, PINFCONTEXT inf_context, PCWSTR source, PCWSTR root,
|
||||
PCWSTR dest, DWORD style, PSP_FILE_CALLBACK_W handler, PVOID context )
|
||||
BOOL WINAPI SetupInstallFileA( HINF hinf, PINFCONTEXT inf_context, PCSTR source, PCSTR root,
|
||||
PCSTR dest, DWORD style, PSP_FILE_CALLBACK_A handler, PVOID context )
|
||||
{
|
||||
return SetupInstallFileExA( hinf, inf_context, source, root, dest, style, handler, context, NULL );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupInstallFileExW (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupInstallFileExW( HINF hinf, PINFCONTEXT inf_context, PCWSTR source, PCWSTR root,
|
||||
PCWSTR dest, DWORD style, PSP_FILE_CALLBACK_W handler, PVOID context, PBOOL in_use )
|
||||
{
|
||||
static const WCHAR CopyFiles[] = {'C','o','p','y','F','i','l','e','s',0};
|
||||
|
||||
|
@ -1316,8 +1310,10 @@ BOOL WINAPI SetupInstallFileW( HINF hinf, PINFCONTEXT inf_context, PCWSTR source
|
|||
WCHAR *buffer, *p, *inf_source = NULL;
|
||||
unsigned int len;
|
||||
|
||||
TRACE("%p %p %s %s %s %x %p %p\n", hinf, inf_context, debugstr_w(source), debugstr_w(root),
|
||||
debugstr_w(dest), style, handler, context);
|
||||
TRACE("%p %p %s %s %s %x %p %p %p\n", hinf, inf_context, debugstr_w(source), debugstr_w(root),
|
||||
debugstr_w(dest), style, handler, context, in_use);
|
||||
|
||||
if (in_use) FIXME("no file in use support\n");
|
||||
|
||||
if (hinf)
|
||||
{
|
||||
|
@ -1373,6 +1369,15 @@ BOOL WINAPI SetupInstallFileW( HINF hinf, PINFCONTEXT inf_context, PCWSTR source
|
|||
return ret;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupInstallFileW (SETUPAPI.@)
|
||||
*/
|
||||
BOOL WINAPI SetupInstallFileW( HINF hinf, PINFCONTEXT inf_context, PCWSTR source, PCWSTR root,
|
||||
PCWSTR dest, DWORD style, PSP_FILE_CALLBACK_W handler, PVOID context )
|
||||
{
|
||||
return SetupInstallFileExW( hinf, inf_context, source, root, dest, style, handler, context, NULL );
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
* SetupCommitFileQueueW (SETUPAPI.@)
|
||||
*/
|
||||
|
@ -1699,7 +1704,7 @@ UINT WINAPI SetupDefaultQueueCallbackA( PVOID context, UINT notification,
|
|||
UINT_PTR param1, UINT_PTR param2 )
|
||||
{
|
||||
FILEPATHS_A *paths = (FILEPATHS_A *)param1;
|
||||
struct default_callback_context *ctx = (struct default_callback_context *)context;
|
||||
struct default_callback_context *ctx = context;
|
||||
|
||||
switch(notification)
|
||||
{
|
||||
|
@ -1763,7 +1768,7 @@ UINT WINAPI SetupDefaultQueueCallbackW( PVOID context, UINT notification,
|
|||
UINT_PTR param1, UINT_PTR param2 )
|
||||
{
|
||||
FILEPATHS_W *paths = (FILEPATHS_W *)param1;
|
||||
struct default_callback_context *ctx = (struct default_callback_context *)context;
|
||||
struct default_callback_context *ctx = context;
|
||||
|
||||
switch(notification)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue