Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
f0f125f5
Commit
f0f125f5
authored
Mar 01, 2022
by
Hans Leidekker
Committed by
Alexandre Julliard
Mar 01, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wusa: Use CRT allocation functions.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
d86c22ee
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
93 deletions
+66
-93
main.c
programs/wusa/main.c
+36
-36
manifest.c
programs/wusa/manifest.c
+26
-26
wusa.h
programs/wusa/wusa.h
+4
-31
No files found.
programs/wusa/main.c
View file @
f0f125f5
...
...
@@ -54,12 +54,12 @@ struct installer_state
static
void
*
CDECL
cabinet_alloc
(
ULONG
cb
)
{
return
heap_
alloc
(
cb
);
return
m
alloc
(
cb
);
}
static
void
CDECL
cabinet_free
(
void
*
pv
)
{
heap_
free
(
pv
);
free
(
pv
);
}
static
INT_PTR
CDECL
cabinet_open
(
char
*
pszFile
,
int
oflag
,
int
pmode
)
...
...
@@ -134,7 +134,7 @@ static WCHAR *path_combine(const WCHAR *path, const WCHAR *filename)
if
(
!
path
||
!
filename
)
return
NULL
;
length
=
lstrlenW
(
path
)
+
lstrlenW
(
filename
)
+
2
;
if
(
!
(
result
=
heap_
alloc
(
length
*
sizeof
(
WCHAR
))))
return
NULL
;
if
(
!
(
result
=
m
alloc
(
length
*
sizeof
(
WCHAR
))))
return
NULL
;
lstrcpyW
(
result
,
path
);
if
(
result
[
0
]
&&
result
[
lstrlenW
(
result
)
-
1
]
!=
'\\'
)
lstrcatW
(
result
,
L"
\\
"
);
...
...
@@ -146,7 +146,7 @@ static WCHAR *get_uncompressed_path(PFDINOTIFICATION pfdin)
{
WCHAR
*
file
=
strdupAtoW
(
pfdin
->
psz1
);
WCHAR
*
path
=
path_combine
(
pfdin
->
pv
,
file
);
heap_
free
(
file
);
free
(
file
);
return
path
;
}
...
...
@@ -187,7 +187,7 @@ static BOOL create_parent_directory(const WCHAR *filename)
ret
=
create_directory
(
path
);
done:
heap_
free
(
path
);
free
(
path
);
return
ret
;
}
...
...
@@ -209,7 +209,7 @@ static INT_PTR cabinet_copy_file(FDINOTIFICATIONTYPE fdint, PFDINOTIFICATION pfd
handle
=
CreateFileW
(
file
,
GENERIC_READ
|
GENERIC_WRITE
,
0
,
NULL
,
CREATE_ALWAYS
,
attrs
,
NULL
);
}
heap_
free
(
file
);
free
(
file
);
return
(
handle
!=
INVALID_HANDLE_VALUE
)
?
(
INT_PTR
)
handle
:
-
1
;
}
...
...
@@ -257,7 +257,7 @@ static BOOL extract_cabinet(const WCHAR *filename, const WCHAR *destination)
if
((
filenameA
=
strdupWtoA
(
filename
)))
{
ret
=
FDICopy
(
hfdi
,
filenameA
,
NULL
,
0
,
cabinet_notify
,
NULL
,
(
void
*
)
destination
);
heap_
free
(
filenameA
);
free
(
filenameA
);
}
FDIDestroy
(
hfdi
);
...
...
@@ -271,18 +271,18 @@ static const WCHAR *create_temp_directory(struct installer_state *state)
WCHAR
tmp
[
MAX_PATH
];
if
(
!
GetTempPathW
(
ARRAY_SIZE
(
tmp
),
tmp
))
return
NULL
;
if
(
!
(
entry
=
heap_
alloc
(
sizeof
(
*
entry
))))
return
NULL
;
if
(
!
(
entry
->
path
=
heap_
alloc
((
MAX_PATH
+
20
)
*
sizeof
(
WCHAR
))))
if
(
!
(
entry
=
m
alloc
(
sizeof
(
*
entry
))))
return
NULL
;
if
(
!
(
entry
->
path
=
m
alloc
((
MAX_PATH
+
20
)
*
sizeof
(
WCHAR
))))
{
heap_
free
(
entry
);
free
(
entry
);
return
NULL
;
}
for
(;;)
{
if
(
!
GetTempFileNameW
(
tmp
,
L"msu"
,
++
id
,
entry
->
path
))
{
heap_
free
(
entry
->
path
);
heap_
free
(
entry
);
free
(
entry
->
path
);
free
(
entry
);
return
NULL
;
}
if
(
CreateDirectoryW
(
entry
->
path
,
NULL
))
break
;
...
...
@@ -300,7 +300,7 @@ static BOOL delete_directory(const WCHAR *path)
if
(
!
(
full_path
=
path_combine
(
path
,
L"*"
)))
return
FALSE
;
search
=
FindFirstFileW
(
full_path
,
&
data
);
heap_
free
(
full_path
);
free
(
full_path
);
if
(
search
!=
INVALID_HANDLE_VALUE
)
{
...
...
@@ -313,7 +313,7 @@ static BOOL delete_directory(const WCHAR *path)
delete_directory
(
full_path
);
else
DeleteFileW
(
full_path
);
heap_
free
(
full_path
);
free
(
full_path
);
}
while
(
FindNextFileW
(
search
,
&
data
));
FindClose
(
search
);
...
...
@@ -332,8 +332,8 @@ static void installer_cleanup(struct installer_state *state)
{
list_remove
(
&
tempdir
->
entry
);
delete_directory
(
tempdir
->
path
);
heap_
free
(
tempdir
->
path
);
heap_
free
(
tempdir
);
free
(
tempdir
->
path
);
free
(
tempdir
);
}
LIST_FOR_EACH_ENTRY_SAFE
(
assembly
,
assembly2
,
&
state
->
assemblies
,
struct
assembly_entry
,
entry
)
{
...
...
@@ -377,11 +377,11 @@ static BOOL load_assemblies_from_cab(const WCHAR *filename, struct installer_sta
FIXME
(
"Cabinet uses proprietary msdelta file compression which is not (yet) supported
\n
"
);
FIXME
(
"Installation of msu file will most likely fail
\n
"
);
}
heap_
free
(
path
);
free
(
path
);
if
(
!
(
path
=
path_combine
(
temp_path
,
L"*"
)))
return
FALSE
;
search
=
FindFirstFileW
(
path
,
&
data
);
heap_
free
(
path
);
free
(
path
);
if
(
search
!=
INVALID_HANDLE_VALUE
)
{
...
...
@@ -393,7 +393,7 @@ static BOOL load_assemblies_from_cab(const WCHAR *filename, struct installer_sta
if
(
!
(
path
=
path_combine
(
temp_path
,
data
.
cFileName
)))
continue
;
if
((
assembly
=
load_manifest
(
path
)))
list_add_tail
(
&
state
->
assemblies
,
&
assembly
->
entry
);
heap_
free
(
path
);
free
(
path
);
}
while
(
FindNextFileW
(
search
,
&
data
));
FindClose
(
search
);
...
...
@@ -439,13 +439,13 @@ static BOOL strbuf_init(struct strbuf *buf)
{
buf
->
pos
=
0
;
buf
->
len
=
64
;
buf
->
buf
=
heap_
alloc
(
buf
->
len
*
sizeof
(
WCHAR
));
buf
->
buf
=
m
alloc
(
buf
->
len
*
sizeof
(
WCHAR
));
return
buf
->
buf
!=
NULL
;
}
static
void
strbuf_free
(
struct
strbuf
*
buf
)
{
heap_
free
(
buf
->
buf
);
free
(
buf
->
buf
);
buf
->
buf
=
NULL
;
}
...
...
@@ -461,7 +461,7 @@ static BOOL strbuf_append(struct strbuf *buf, const WCHAR *str, DWORD len)
if
(
buf
->
pos
+
len
+
1
>
buf
->
len
)
{
new_len
=
max
(
buf
->
pos
+
len
+
1
,
buf
->
len
*
2
);
new_buf
=
heap_
realloc
(
buf
->
buf
,
new_len
*
sizeof
(
WCHAR
));
new_buf
=
realloc
(
buf
->
buf
,
new_len
*
sizeof
(
WCHAR
));
if
(
!
new_buf
)
{
strbuf_free
(
buf
);
...
...
@@ -548,10 +548,10 @@ static WCHAR *expand_expression(struct assembly_entry *assembly, const WCHAR *ex
if
(
!
(
key
=
strdupWn
(
pos
,
next
-
pos
)))
goto
error
;
value
=
lookup_expression
(
assembly
,
key
);
heap_
free
(
key
);
free
(
key
);
if
(
!
value
)
goto
error
;
strbuf_append
(
&
buf
,
value
,
~
0U
);
heap_
free
(
value
);
free
(
value
);
}
strbuf_append
(
&
buf
,
pos
,
~
0U
);
...
...
@@ -597,9 +597,9 @@ static BOOL install_files_copy(struct assembly_entry *assembly, const WCHAR *sou
}
error:
heap_
free
(
target_path
);
heap_
free
(
target
);
heap_
free
(
source
);
free
(
target_path
);
free
(
target
);
free
(
source
);
return
ret
;
}
...
...
@@ -620,7 +620,7 @@ static BOOL install_files(struct assembly_entry *assembly, BOOL dryrun)
if
(
!
(
ret
=
install_files_copy
(
assembly
,
source_path
,
fileop
,
dryrun
)))
break
;
}
heap_
free
(
source_path
);
free
(
source_path
);
return
ret
;
}
...
...
@@ -667,7 +667,7 @@ static BOOL install_registry_string(struct assembly_entry *assembly, HKEY key, s
ret
=
FALSE
;
}
heap_
free
(
value
);
free
(
value
);
return
ret
;
}
...
...
@@ -725,7 +725,7 @@ static BOOL install_registry_multisz(struct assembly_entry *assembly, HKEY key,
ret
=
FALSE
;
}
heap_
free
(
value
);
free
(
value
);
return
ret
;
}
...
...
@@ -755,7 +755,7 @@ static BYTE *parse_hex(const WCHAR *input, DWORD *size)
if
(
length
&
1
)
return
NULL
;
length
>>=
1
;
if
(
!
(
output
=
heap_
alloc
(
length
)))
return
NULL
;
if
(
!
(
output
=
m
alloc
(
length
)))
return
NULL
;
for
(
p
=
output
;
*
input
;
input
+=
2
)
{
number
[
0
]
=
input
[
0
];
...
...
@@ -781,7 +781,7 @@ static BOOL install_registry_binary(struct assembly_entry *assembly, HKEY key, s
ret
=
FALSE
;
}
heap_
free
(
value
);
free
(
value
);
return
ret
;
}
...
...
@@ -954,7 +954,7 @@ static BOOL install_msu(const WCHAR *filename, struct installer_state *state)
/* load all manifests from contained cabinet archives */
if
(
!
(
path
=
path_combine
(
temp_path
,
L"*.cab"
)))
goto
done
;
search
=
FindFirstFileW
(
path
,
&
data
);
heap_
free
(
path
);
free
(
path
);
if
(
search
!=
INVALID_HANDLE_VALUE
)
{
...
...
@@ -965,7 +965,7 @@ static BOOL install_msu(const WCHAR *filename, struct installer_state *state)
if
(
!
(
path
=
path_combine
(
temp_path
,
data
.
cFileName
)))
continue
;
if
(
!
load_assemblies_from_cab
(
path
,
state
))
ERR
(
"Failed to load all manifests from %s, ignoring
\n
"
,
debugstr_w
(
path
));
heap_
free
(
path
);
free
(
path
);
}
while
(
FindNextFileW
(
search
,
&
data
));
FindClose
(
search
);
...
...
@@ -974,7 +974,7 @@ static BOOL install_msu(const WCHAR *filename, struct installer_state *state)
/* load all update descriptions */
if
(
!
(
path
=
path_combine
(
temp_path
,
L"*.xml"
)))
goto
done
;
search
=
FindFirstFileW
(
path
,
&
data
);
heap_
free
(
path
);
free
(
path
);
if
(
search
!=
INVALID_HANDLE_VALUE
)
{
...
...
@@ -984,7 +984,7 @@ static BOOL install_msu(const WCHAR *filename, struct installer_state *state)
if
(
!
(
path
=
path_combine
(
temp_path
,
data
.
cFileName
)))
continue
;
if
(
!
load_update
(
path
,
&
state
->
updates
))
ERR
(
"Failed to load all updates from %s, ignoring
\n
"
,
debugstr_w
(
path
));
heap_
free
(
path
);
free
(
path
);
}
while
(
FindNextFileW
(
search
,
&
data
));
FindClose
(
search
);
...
...
programs/wusa/manifest.c
View file @
f0f125f5
...
...
@@ -32,28 +32,28 @@ WINE_DEFAULT_DEBUG_CHANNEL(wusa);
static
struct
dependency_entry
*
alloc_dependency
(
void
)
{
struct
dependency_entry
*
entry
=
heap_alloc_zero
(
sizeof
(
*
entry
));
struct
dependency_entry
*
entry
=
calloc
(
1
,
sizeof
(
*
entry
));
if
(
!
entry
)
ERR
(
"Failed to allocate memory for dependency
\n
"
);
return
entry
;
}
static
struct
fileop_entry
*
alloc_fileop
(
void
)
{
struct
fileop_entry
*
entry
=
heap_alloc_zero
(
sizeof
(
*
entry
));
struct
fileop_entry
*
entry
=
calloc
(
1
,
sizeof
(
*
entry
));
if
(
!
entry
)
ERR
(
"Failed to allocate memory for fileop
\n
"
);
return
entry
;
}
static
struct
registrykv_entry
*
alloc_registrykv
(
void
)
{
struct
registrykv_entry
*
entry
=
heap_alloc_zero
(
sizeof
(
*
entry
));
struct
registrykv_entry
*
entry
=
calloc
(
1
,
sizeof
(
*
entry
));
if
(
!
entry
)
ERR
(
"Failed to allocate memory for registrykv
\n
"
);
return
entry
;
}
static
struct
registryop_entry
*
alloc_registryop
(
void
)
{
struct
registryop_entry
*
entry
=
heap_alloc_zero
(
sizeof
(
*
entry
));
struct
registryop_entry
*
entry
=
calloc
(
1
,
sizeof
(
*
entry
));
if
(
!
entry
)
ERR
(
"Failed to allocate memory for registryop
\n
"
);
else
{
...
...
@@ -64,7 +64,7 @@ static struct registryop_entry *alloc_registryop(void)
static
struct
assembly_entry
*
alloc_assembly
(
void
)
{
struct
assembly_entry
*
entry
=
heap_alloc_zero
(
sizeof
(
*
entry
));
struct
assembly_entry
*
entry
=
calloc
(
1
,
sizeof
(
*
entry
));
if
(
!
entry
)
ERR
(
"Failed to allocate memory for assembly
\n
"
);
else
{
...
...
@@ -77,39 +77,39 @@ static struct assembly_entry *alloc_assembly(void)
static
void
clear_identity
(
struct
assembly_identity
*
entry
)
{
heap_
free
(
entry
->
name
);
heap_
free
(
entry
->
version
);
heap_
free
(
entry
->
architecture
);
heap_
free
(
entry
->
language
);
heap_
free
(
entry
->
pubkey_token
);
free
(
entry
->
name
);
free
(
entry
->
version
);
free
(
entry
->
architecture
);
free
(
entry
->
language
);
free
(
entry
->
pubkey_token
);
}
void
free_dependency
(
struct
dependency_entry
*
entry
)
{
clear_identity
(
&
entry
->
identity
);
heap_
free
(
entry
);
free
(
entry
);
}
static
void
free_fileop
(
struct
fileop_entry
*
entry
)
{
heap_
free
(
entry
->
source
);
heap_
free
(
entry
->
target
);
heap_
free
(
entry
);
free
(
entry
->
source
);
free
(
entry
->
target
);
free
(
entry
);
}
static
void
free_registrykv
(
struct
registrykv_entry
*
entry
)
{
heap_
free
(
entry
->
name
);
heap_
free
(
entry
->
value_type
);
heap_
free
(
entry
->
value
);
heap_
free
(
entry
);
free
(
entry
->
name
);
free
(
entry
->
value_type
);
free
(
entry
->
value
);
free
(
entry
);
}
static
void
free_registryop
(
struct
registryop_entry
*
entry
)
{
struct
registrykv_entry
*
keyvalue
,
*
keyvalue2
;
heap_
free
(
entry
->
key
);
free
(
entry
->
key
);
LIST_FOR_EACH_ENTRY_SAFE
(
keyvalue
,
keyvalue2
,
&
entry
->
keyvalues
,
struct
registrykv_entry
,
entry
)
{
...
...
@@ -117,7 +117,7 @@ static void free_registryop(struct registryop_entry *entry)
free_registrykv
(
keyvalue
);
}
heap_
free
(
entry
);
free
(
entry
);
}
void
free_assembly
(
struct
assembly_entry
*
entry
)
...
...
@@ -126,8 +126,8 @@ void free_assembly(struct assembly_entry *entry)
struct
fileop_entry
*
fileop
,
*
fileop2
;
struct
registryop_entry
*
registryop
,
*
registryop2
;
heap_
free
(
entry
->
filename
);
heap_
free
(
entry
->
displayname
);
free
(
entry
->
filename
);
free
(
entry
->
displayname
);
clear_identity
(
&
entry
->
identity
);
LIST_FOR_EACH_ENTRY_SAFE
(
dependency
,
dependency2
,
&
entry
->
dependencies
,
struct
dependency_entry
,
entry
)
...
...
@@ -146,7 +146,7 @@ void free_assembly(struct assembly_entry *entry)
free_registryop
(
registryop
);
}
heap_
free
(
entry
);
free
(
entry
);
}
static
WCHAR
*
get_xml_attribute
(
IXMLDOMElement
*
root
,
const
WCHAR
*
name
)
...
...
@@ -304,7 +304,7 @@ static BOOL read_dependent_assembly(IXMLDOMElement *root, struct assembly_identi
error:
if
(
child
)
IXMLDOMElement_Release
(
child
);
heap_
free
(
dependency_type
);
free
(
dependency_type
);
return
ret
;
}
...
...
@@ -498,7 +498,7 @@ static BOOL read_registry_keys(IXMLDOMElement *child, WCHAR *tagname, void *cont
free_registryop
(
entry
);
}
heap_
free
(
keyname
);
free
(
keyname
);
return
FALSE
;
}
...
...
@@ -622,7 +622,7 @@ static BOOL read_servicing(IXMLDOMElement *child, WCHAR *tagname, void *context)
else
FIXME
(
"action %s not supported
\n
"
,
debugstr_w
(
action
));
heap_
free
(
action
);
free
(
action
);
return
ret
;
}
...
...
programs/wusa/wusa.h
View file @
f0f125f5
...
...
@@ -78,29 +78,6 @@ void free_dependency(struct dependency_entry *entry) DECLSPEC_HIDDEN;
struct
assembly_entry
*
load_manifest
(
const
WCHAR
*
filename
)
DECLSPEC_HIDDEN
;
BOOL
load_update
(
const
WCHAR
*
filename
,
struct
list
*
update_list
)
DECLSPEC_HIDDEN
;
static
void
*
heap_alloc
(
size_t
len
)
__WINE_ALLOC_SIZE
(
1
);
static
inline
void
*
heap_alloc
(
size_t
len
)
{
return
HeapAlloc
(
GetProcessHeap
(),
0
,
len
);
}
static
void
*
heap_alloc_zero
(
size_t
len
)
__WINE_ALLOC_SIZE
(
1
);
static
inline
void
*
heap_alloc_zero
(
size_t
len
)
{
return
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
len
);
}
static
void
*
heap_realloc
(
void
*
mem
,
size_t
len
)
__WINE_ALLOC_SIZE
(
2
);
static
inline
void
*
heap_realloc
(
void
*
mem
,
size_t
len
)
{
return
HeapReAlloc
(
GetProcessHeap
(),
0
,
mem
,
len
);
}
static
inline
BOOL
heap_free
(
void
*
mem
)
{
return
HeapFree
(
GetProcessHeap
(),
0
,
mem
);
}
static
inline
char
*
strdupWtoA
(
const
WCHAR
*
str
)
{
char
*
ret
=
NULL
;
...
...
@@ -108,8 +85,7 @@ static inline char *strdupWtoA(const WCHAR *str)
if
(
!
str
)
return
ret
;
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
ret
=
heap_alloc
(
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
,
NULL
,
NULL
);
if
((
ret
=
malloc
(
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
,
NULL
,
NULL
);
return
ret
;
}
...
...
@@ -120,8 +96,7 @@ static inline WCHAR *strdupAtoW(const char *str)
if
(
!
str
)
return
ret
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
if
((
ret
=
heap_alloc
(
len
*
sizeof
(
WCHAR
))))
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
);
if
((
ret
=
malloc
(
len
*
sizeof
(
WCHAR
))))
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
ret
,
len
);
return
ret
;
}
...
...
@@ -129,8 +104,7 @@ static inline WCHAR *strdupW(const WCHAR *str)
{
WCHAR
*
ret
;
if
(
!
str
)
return
NULL
;
ret
=
heap_alloc
((
lstrlenW
(
str
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
ret
)
lstrcpyW
(
ret
,
str
);
if
((
ret
=
malloc
((
lstrlenW
(
str
)
+
1
)
*
sizeof
(
WCHAR
))))
lstrcpyW
(
ret
,
str
);
return
ret
;
}
...
...
@@ -138,8 +112,7 @@ static inline WCHAR *strdupWn(const WCHAR *str, DWORD len)
{
WCHAR
*
ret
;
if
(
!
str
)
return
NULL
;
ret
=
heap_alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
if
(
ret
)
if
((
ret
=
malloc
((
len
+
1
)
*
sizeof
(
WCHAR
))))
{
memcpy
(
ret
,
str
,
len
*
sizeof
(
WCHAR
));
ret
[
len
]
=
0
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment