Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
f6fc2dba
Commit
f6fc2dba
authored
Oct 01, 2009
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
version: Simplify the resource loading since we always load the same type and id now.
parent
3ed5986d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
107 deletions
+25
-107
info.c
dlls/version/info.c
+2
-3
resource.c
dlls/version/resource.c
+23
-104
No files found.
dlls/version/info.c
View file @
f6fc2dba
...
...
@@ -38,7 +38,7 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
ver
);
extern
DWORD
find_
resource
(
HFILE
lzfd
,
LPCSTR
type
,
LPCSTR
i
d
,
DWORD
*
reslen
,
DWORD
*
offset
);
extern
DWORD
find_
version_resource
(
HFILE
lzf
d
,
DWORD
*
reslen
,
DWORD
*
offset
);
/******************************************************************************
*
...
...
@@ -355,8 +355,7 @@ static DWORD VERSION_GetFileVersionInfo_16( LPCSTR filename, DWORD datasize, LPV
if
(
lzfd
>=
0
)
{
if
(
find_resource
(
lzfd
,
MAKEINTRESOURCEA
(
VS_FILE_INFO
),
MAKEINTRESOURCEA
(
VS_VERSION_INFO
),
&
len
,
&
offset
))
if
(
find_version_resource
(
lzfd
,
&
len
,
&
offset
))
{
if
(
data
)
{
...
...
dlls/version/resource.c
View file @
f6fc2dba
...
...
@@ -36,6 +36,7 @@
#include "windef.h"
#include "winbase.h"
#include "lzexpand.h"
#include "winver.h"
#include "wine/unicode.h"
#include "wine/winbase16.h"
...
...
@@ -88,56 +89,6 @@ static const IMAGE_RESOURCE_DIRECTORY *find_entry_default( const IMAGE_RESOURCE_
}
/**********************************************************************
* find_entry_by_name
*
* Find an entry by name in a resource directory
* Copied from loader/pe_resource.c
*/
static
const
IMAGE_RESOURCE_DIRECTORY
*
find_entry_by_name
(
const
IMAGE_RESOURCE_DIRECTORY
*
dir
,
LPCSTR
name
,
const
void
*
root
)
{
const
IMAGE_RESOURCE_DIRECTORY
*
ret
=
NULL
;
LPWSTR
nameW
;
DWORD
namelen
;
if
(
!
HIWORD
(
name
))
return
find_entry_by_id
(
dir
,
LOWORD
(
name
),
root
);
if
(
name
[
0
]
==
'#'
)
{
return
find_entry_by_id
(
dir
,
atoi
(
name
+
1
),
root
);
}
namelen
=
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
NULL
,
0
);
if
((
nameW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
namelen
*
sizeof
(
WCHAR
)
)))
{
const
IMAGE_RESOURCE_DIRECTORY_ENTRY
*
entry
;
const
IMAGE_RESOURCE_DIR_STRING_U
*
str
;
int
min
,
max
,
res
,
pos
;
MultiByteToWideChar
(
CP_ACP
,
0
,
name
,
-
1
,
nameW
,
namelen
);
namelen
--
;
/* remove terminating null */
entry
=
(
const
IMAGE_RESOURCE_DIRECTORY_ENTRY
*
)(
dir
+
1
);
min
=
0
;
max
=
dir
->
NumberOfNamedEntries
-
1
;
while
(
min
<=
max
)
{
pos
=
(
min
+
max
)
/
2
;
str
=
(
const
IMAGE_RESOURCE_DIR_STRING_U
*
)((
const
char
*
)
root
+
entry
[
pos
].
u1
.
s1
.
NameOffset
);
res
=
strncmpiW
(
nameW
,
str
->
NameString
,
str
->
Length
);
if
(
!
res
&&
namelen
==
str
->
Length
)
{
ret
=
(
const
IMAGE_RESOURCE_DIRECTORY
*
)((
const
char
*
)
root
+
entry
[
pos
].
u2
.
s3
.
OffsetToDirectory
);
break
;
}
if
(
res
<
0
)
max
=
pos
-
1
;
else
min
=
pos
+
1
;
}
HeapFree
(
GetProcessHeap
(),
0
,
nameW
);
}
return
ret
;
}
/***********************************************************************
* read_xx_header [internal]
*/
...
...
@@ -171,9 +122,10 @@ static int read_xx_header( HFILE lzfd )
/***********************************************************************
* find_ne_resource [internal]
*/
static
BOOL
find_ne_resource
(
HFILE
lzfd
,
LPCSTR
typeid
,
LPCSTR
resid
,
DWORD
*
resLen
,
DWORD
*
resOff
)
static
BOOL
find_ne_resource
(
HFILE
lzfd
,
DWORD
*
resLen
,
DWORD
*
resOff
)
{
const
WORD
typeid
=
VS_FILE_INFO
|
0x8000
;
const
WORD
resid
=
VS_VERSION_INFO
|
0x8000
;
IMAGE_OS2_HEADER
nehd
;
NE_TYPEINFO
*
typeInfo
;
NE_NAMEINFO
*
nameInfo
;
...
...
@@ -206,55 +158,23 @@ static BOOL find_ne_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid,
/* Find resource */
typeInfo
=
(
NE_TYPEINFO
*
)(
resTab
+
2
);
if
(
HIWORD
(
typeid
)
!=
0
)
/* named type */
{
BYTE
len
=
strlen
(
typeid
);
while
(
typeInfo
->
type_id
)
{
if
(
!
(
typeInfo
->
type_id
&
0x8000
))
{
BYTE
*
p
=
resTab
+
typeInfo
->
type_id
;
if
((
*
p
==
len
)
&&
!
strncasecmp
(
(
char
*
)
p
+
1
,
typeid
,
len
))
goto
found_type
;
}
typeInfo
=
(
NE_TYPEINFO
*
)((
char
*
)(
typeInfo
+
1
)
+
typeInfo
->
count
*
sizeof
(
NE_NAMEINFO
));
}
}
else
/* numeric type id */
while
(
typeInfo
->
type_id
)
{
WORD
id
=
LOWORD
(
typeid
)
|
0x8000
;
while
(
typeInfo
->
type_id
)
{
if
(
typeInfo
->
type_id
==
id
)
goto
found_type
;
typeInfo
=
(
NE_TYPEINFO
*
)((
char
*
)(
typeInfo
+
1
)
+
typeInfo
->
count
*
sizeof
(
NE_NAMEINFO
));
}
if
(
typeInfo
->
type_id
==
typeid
)
goto
found_type
;
typeInfo
=
(
NE_TYPEINFO
*
)((
char
*
)(
typeInfo
+
1
)
+
typeInfo
->
count
*
sizeof
(
NE_NAMEINFO
));
}
TRACE
(
"No typeid entry found
for %p
\n
"
,
typeid
);
TRACE
(
"No typeid entry found
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
resTab
);
return
FALSE
;
found_type:
nameInfo
=
(
NE_NAMEINFO
*
)(
typeInfo
+
1
);
if
(
HIWORD
(
resid
)
!=
0
)
/* named resource */
{
BYTE
len
=
strlen
(
resid
);
for
(
count
=
typeInfo
->
count
;
count
>
0
;
count
--
,
nameInfo
++
)
{
BYTE
*
p
=
resTab
+
nameInfo
->
id
;
if
(
nameInfo
->
id
&
0x8000
)
continue
;
if
((
*
p
==
len
)
&&
!
strncasecmp
(
(
char
*
)
p
+
1
,
resid
,
len
))
goto
found_name
;
}
}
else
/* numeric resource id */
{
WORD
id
=
LOWORD
(
resid
)
|
0x8000
;
for
(
count
=
typeInfo
->
count
;
count
>
0
;
count
--
,
nameInfo
++
)
if
(
nameInfo
->
id
==
id
)
goto
found_name
;
}
TRACE
(
"No resid entry found for %p
\n
"
,
typeid
);
for
(
count
=
typeInfo
->
count
;
count
>
0
;
count
--
,
nameInfo
++
)
if
(
nameInfo
->
id
==
resid
)
goto
found_name
;
TRACE
(
"No resid entry found
\n
"
);
HeapFree
(
GetProcessHeap
(),
0
,
resTab
);
return
FALSE
;
...
...
@@ -270,8 +190,7 @@ static BOOL find_ne_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid,
/***********************************************************************
* find_pe_resource [internal]
*/
static
BOOL
find_pe_resource
(
HFILE
lzfd
,
LPCSTR
typeid
,
LPCSTR
resid
,
DWORD
*
resLen
,
DWORD
*
resOff
)
static
BOOL
find_pe_resource
(
HFILE
lzfd
,
DWORD
*
resLen
,
DWORD
*
resOff
)
{
IMAGE_NT_HEADERS
pehd
;
DWORD
pehdoffset
;
...
...
@@ -344,22 +263,22 @@ static BOOL find_pe_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid,
resDir
=
resSection
+
(
resDataDir
->
VirtualAddress
-
sections
[
i
].
VirtualAddress
);
resPtr
=
resDir
;
resPtr
=
find_entry_by_
name
(
resPtr
,
typeid
,
resDir
);
resPtr
=
find_entry_by_
id
(
resPtr
,
VS_FILE_INFO
,
resDir
);
if
(
!
resPtr
)
{
TRACE
(
"No typeid entry found
for %p
\n
"
,
typeid
);
TRACE
(
"No typeid entry found
\n
"
);
goto
done
;
}
resPtr
=
find_entry_by_
name
(
resPtr
,
resid
,
resDir
);
resPtr
=
find_entry_by_
id
(
resPtr
,
VS_VERSION_INFO
,
resDir
);
if
(
!
resPtr
)
{
TRACE
(
"No resid entry found
for %p
\n
"
,
resid
);
TRACE
(
"No resid entry found
\n
"
);
goto
done
;
}
resPtr
=
find_entry_default
(
resPtr
,
resDir
);
if
(
!
resPtr
)
{
TRACE
(
"No default language entry found
for %p
\n
"
,
resid
);
TRACE
(
"No default language entry found
\n
"
);
goto
done
;
}
...
...
@@ -391,19 +310,19 @@ static BOOL find_pe_resource( HFILE lzfd, LPCSTR typeid, LPCSTR resid,
/***********************************************************************
* find_resource [internal]
* find_
version_
resource [internal]
*/
DWORD
find_
resource
(
HFILE
lzfd
,
LPCSTR
type
,
LPCSTR
i
d
,
DWORD
*
reslen
,
DWORD
*
offset
)
DWORD
find_
version_resource
(
HFILE
lzf
d
,
DWORD
*
reslen
,
DWORD
*
offset
)
{
DWORD
magic
=
read_xx_header
(
lzfd
);
switch
(
magic
)
{
case
IMAGE_OS2_SIGNATURE
:
if
(
!
find_ne_resource
(
lzfd
,
type
,
id
,
reslen
,
offset
))
magic
=
0
;
if
(
!
find_ne_resource
(
lzfd
,
reslen
,
offset
))
magic
=
0
;
break
;
case
IMAGE_NT_SIGNATURE
:
if
(
!
find_pe_resource
(
lzfd
,
type
,
id
,
reslen
,
offset
))
magic
=
0
;
if
(
!
find_pe_resource
(
lzfd
,
reslen
,
offset
))
magic
=
0
;
break
;
}
return
magic
;
...
...
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