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
6b398977
Commit
6b398977
authored
Aug 24, 2010
by
Damjan Jovanovic
Committed by
Alexandre Julliard
Aug 25, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winemenubuilder: Parse ICO headers in a separate function.
parent
85d8c1da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
28 deletions
+28
-28
winemenubuilder.c
programs/winemenubuilder/winemenubuilder.c
+28
-28
No files found.
programs/winemenubuilder/winemenubuilder.c
View file @
6b398977
...
...
@@ -631,19 +631,15 @@ static HRESULT open_module_icon(LPCWSTR szFileName, int nIndex, IStream **ppStre
return
hr
;
}
static
HRESULT
write_native_icon
(
IStream
*
iconStream
,
const
char
*
icon_name
,
LPCWSTR
szFileName
)
static
HRESULT
read_ico_direntries
(
IStream
*
icoStream
,
ICONDIRENTRY
**
ppIconDirEntries
,
int
*
numEntries
)
{
ICONDIR
iconDir
;
ICONDIRENTRY
*
pIconDirEntry
=
NULL
;
int
nMax
=
0
,
nMaxBits
=
0
;
int
nIndex
=
0
;
void
*
pIcon
=
NULL
;
int
i
;
ULONG
bytesRead
;
LARGE_INTEGER
position
;
HRESULT
hr
;
hr
=
IStream_Read
(
iconStream
,
&
iconDir
,
sizeof
(
ICONDIR
),
&
bytesRead
);
*
ppIconDirEntries
=
NULL
;
hr
=
IStream_Read
(
icoStream
,
&
iconDir
,
sizeof
(
ICONDIR
),
&
bytesRead
);
if
(
FAILED
(
hr
)
||
bytesRead
!=
sizeof
(
ICONDIR
)
||
(
iconDir
.
idReserved
!=
0
)
||
(
iconDir
.
idType
!=
1
))
{
...
...
@@ -651,20 +647,41 @@ static HRESULT write_native_icon(IStream *iconStream, const char *icon_name, LPC
hr
=
E_FAIL
;
goto
end
;
}
*
numEntries
=
iconDir
.
idCount
;
if
((
pIconDirEntry
=
HeapAlloc
(
GetProcessHeap
(),
0
,
iconDir
.
idCount
*
sizeof
(
ICONDIRENTRY
)
))
==
NULL
)
if
((
*
ppIconDirEntries
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
ICONDIRENTRY
)
*
iconDir
.
idCount
))
==
NULL
)
{
hr
=
E_OUTOFMEMORY
;
goto
end
;
}
hr
=
IStream_Read
(
ico
nStream
,
pIconDirEntry
,
sizeof
(
ICONDIRENTRY
)
*
iconDir
.
idCount
,
&
bytesRead
);
hr
=
IStream_Read
(
ico
Stream
,
*
ppIconDirEntries
,
sizeof
(
ICONDIRENTRY
)
*
iconDir
.
idCount
,
&
bytesRead
);
if
(
FAILED
(
hr
)
||
bytesRead
!=
sizeof
(
ICONDIRENTRY
)
*
iconDir
.
idCount
)
{
if
(
SUCCEEDED
(
hr
))
hr
=
E_FAIL
;
goto
end
;
}
for
(
i
=
0
;
i
<
iconDir
.
idCount
;
i
++
)
end:
if
(
FAILED
(
hr
))
HeapFree
(
GetProcessHeap
(),
0
,
*
ppIconDirEntries
);
return
hr
;
}
static
HRESULT
write_native_icon
(
IStream
*
iconStream
,
const
char
*
icon_name
,
LPCWSTR
szFileName
)
{
ICONDIRENTRY
*
pIconDirEntry
=
NULL
;
int
numEntries
;
int
nMax
=
0
,
nMaxBits
=
0
;
int
nIndex
=
0
;
int
i
;
LARGE_INTEGER
position
;
HRESULT
hr
;
hr
=
read_ico_direntries
(
iconStream
,
&
pIconDirEntry
,
&
numEntries
);
if
(
FAILED
(
hr
))
goto
end
;
for
(
i
=
0
;
i
<
numEntries
;
i
++
)
{
WINE_TRACE
(
"[%d]: %d x %d @ %d
\n
"
,
i
,
pIconDirEntry
[
i
].
bWidth
,
pIconDirEntry
[
i
].
bHeight
,
pIconDirEntry
[
i
].
wBitCount
);
if
(
pIconDirEntry
[
i
].
wBitCount
>=
nMaxBits
&&
...
...
@@ -677,22 +694,6 @@ static HRESULT write_native_icon(IStream *iconStream, const char *icon_name, LPC
}
WINE_TRACE
(
"Selected: %d
\n
"
,
nIndex
);
if
((
pIcon
=
HeapAlloc
(
GetProcessHeap
(),
0
,
pIconDirEntry
[
nIndex
].
dwBytesInRes
))
==
NULL
)
{
hr
=
E_OUTOFMEMORY
;
goto
end
;
}
position
.
QuadPart
=
pIconDirEntry
[
nIndex
].
dwImageOffset
;
hr
=
IStream_Seek
(
iconStream
,
position
,
STREAM_SEEK_SET
,
NULL
);
if
(
FAILED
(
hr
))
goto
end
;
hr
=
IStream_Read
(
iconStream
,
pIcon
,
pIconDirEntry
[
nIndex
].
dwBytesInRes
,
&
bytesRead
);
if
(
FAILED
(
hr
)
||
bytesRead
!=
pIconDirEntry
[
nIndex
].
dwBytesInRes
)
{
if
(
SUCCEEDED
(
hr
))
hr
=
E_FAIL
;
goto
end
;
}
position
.
QuadPart
=
0
;
hr
=
IStream_Seek
(
iconStream
,
position
,
STREAM_SEEK_SET
,
NULL
);
if
(
FAILED
(
hr
))
...
...
@@ -700,7 +701,6 @@ static HRESULT write_native_icon(IStream *iconStream, const char *icon_name, LPC
hr
=
convert_to_native_icon
(
iconStream
,
&
nIndex
,
1
,
&
CLSID_WICPngEncoder
,
icon_name
,
szFileName
);
end:
HeapFree
(
GetProcessHeap
(),
0
,
pIcon
);
HeapFree
(
GetProcessHeap
(),
0
,
pIconDirEntry
);
return
hr
;
}
...
...
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