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
38e27fa9
Commit
38e27fa9
authored
Jan 11, 2007
by
Mike McCormack
Committed by
Alexandre Julliard
Jan 11, 2007
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32: Split update_add_resource() into two functions.
parent
8f8fecd0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
20 deletions
+42
-20
resource.c
dlls/kernel32/resource.c
+42
-20
No files found.
dlls/kernel32/resource.c
View file @
38e27fa9
...
...
@@ -646,7 +646,7 @@ struct resource_data {
LANGID
lang
;
DWORD
codepage
;
DWORD
cbData
;
BYTE
data
[
1
]
;
void
*
lpData
;
};
static
int
resource_strcmp
(
LPCWSTR
a
,
LPCWSTR
b
)
...
...
@@ -737,15 +737,13 @@ static void res_free_str( LPWSTR str )
}
static
BOOL
update_add_resource
(
QUEUEDUPDATES
*
updates
,
LPCWSTR
Type
,
LPCWSTR
Name
,
WORD
Language
,
DWORD
codepage
,
LPCVOID
lpData
,
DWORD
cbData
)
struct
resource_data
*
resdata
,
BOOL
overwrite_existing
)
{
struct
resource_dir_entry
*
restype
,
*
resname
;
struct
resource_data
*
resdata
;
TRACE
(
"%p %s %s %04x %04x %p %d bytes
\n
"
,
updates
,
debugstr_w
(
Type
),
debugstr_w
(
Name
),
Language
,
codepage
,
lpData
,
cbData
);
struct
resource_data
*
existing
;
if
(
!
lpData
||
!
cbData
)
return
FALSE
;
TRACE
(
"%p %s %s %p %d
\n
"
,
updates
,
debugstr_w
(
Type
),
debugstr_w
(
Name
),
resdata
,
overwrite_existing
)
;
restype
=
find_resource_dir_entry
(
&
updates
->
root
,
Type
);
if
(
!
restype
)
...
...
@@ -769,24 +767,46 @@ static BOOL update_add_resource( QUEUEDUPDATES *updates, LPCWSTR Type, LPCWSTR N
* If there's an existing resource entry with matching (Type,Name,Language)
* it needs to be removed before adding the new data.
*/
resdata
=
find_resource_data
(
&
resname
->
children
,
Language
);
if
(
resdata
)
existing
=
find_resource_data
(
&
resname
->
children
,
resdata
->
lang
);
if
(
existing
)
{
list_remove
(
&
resdata
->
entry
);
HeapFree
(
GetProcessHeap
(),
0
,
resdata
);
if
(
!
overwrite_existing
)
return
TRUE
;
list_remove
(
&
existing
->
entry
);
HeapFree
(
GetProcessHeap
(),
0
,
existing
);
}
resdata
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
*
resdata
+
cbData
);
resdata
->
lang
=
Language
;
resdata
->
codepage
=
codepage
;
resdata
->
cbData
=
cbData
;
memcpy
(
resdata
->
data
,
lpData
,
cbData
);
add_resource_data_entry
(
&
resname
->
children
,
resdata
);
return
TRUE
;
}
static
struct
resource_data
*
allocate_resource_data
(
WORD
Language
,
DWORD
codepage
,
LPVOID
lpData
,
DWORD
cbData
,
BOOL
copy_data
)
{
struct
resource_data
*
resdata
;
if
(
!
lpData
||
!
cbData
)
return
NULL
;
resdata
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
*
resdata
+
(
copy_data
?
cbData
:
0
)
);
if
(
resdata
)
{
resdata
->
lang
=
Language
;
resdata
->
codepage
=
codepage
;
resdata
->
cbData
=
cbData
;
if
(
copy_data
)
{
resdata
->
lpData
=
&
resdata
[
1
];
memcpy
(
resdata
->
lpData
,
lpData
,
cbData
);
}
else
resdata
->
lpData
=
lpData
;
}
return
resdata
;
}
static
void
free_resource_directory
(
struct
list
*
head
,
int
level
)
{
struct
list
*
ptr
=
NULL
;
...
...
@@ -1184,7 +1204,7 @@ static BOOL write_resources( QUEUEDUPDATES *updates, LPBYTE base, struct resourc
si
->
data_entry_ofs
+=
sizeof
(
IMAGE_RESOURCE_DATA_ENTRY
);
/* write out the resource data */
memcpy
(
&
base
[
si
->
data_ofs
],
data
->
d
ata
,
data
->
cbData
);
memcpy
(
&
base
[
si
->
data_ofs
],
data
->
lpD
ata
,
data
->
cbData
);
si
->
data_ofs
+=
data
->
cbData
;
pad_size
=
(
-
si
->
data_ofs
)
&
3
;
...
...
@@ -1492,8 +1512,10 @@ BOOL WINAPI UpdateResourceW( HANDLE hUpdate, LPCWSTR lpType, LPCWSTR lpName,
updates
=
GlobalLock
(
hUpdate
);
if
(
updates
)
{
ret
=
update_add_resource
(
updates
,
lpType
,
lpName
,
wLanguage
,
GetACP
(),
lpData
,
cbData
);
struct
resource_data
*
data
;
data
=
allocate_resource_data
(
wLanguage
,
0
,
lpData
,
cbData
,
TRUE
);
if
(
data
)
ret
=
update_add_resource
(
updates
,
lpType
,
lpName
,
data
,
TRUE
);
GlobalUnlock
(
hUpdate
);
}
return
ret
;
...
...
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