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
fd941d4d
Commit
fd941d4d
authored
May 11, 2004
by
Mike McCormack
Committed by
Alexandre Julliard
May 11, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement ImageEnumerateCertificates and ImageGetCertificateHeader.
parent
89525a19
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
105 additions
and
20 deletions
+105
-20
integrity.c
dlls/imagehlp/integrity.c
+105
-20
No files found.
dlls/imagehlp/integrity.c
View file @
fd941d4d
...
@@ -44,12 +44,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(imagehlp);
...
@@ -44,12 +44,12 @@ WINE_DEFAULT_DEBUG_CHANNEL(imagehlp);
* Read a file's PE header, and return the offset and size of the
* Read a file's PE header, and return the offset and size of the
* security directory.
* security directory.
*/
*/
static
BOOL
IMAGEHLP_GetSecurityDirOffset
(
HANDLE
handle
,
DWORD
num
,
static
BOOL
IMAGEHLP_GetSecurityDirOffset
(
HANDLE
handle
,
DWORD
*
pdwOfs
,
DWORD
*
pdwSize
)
DWORD
*
pdwOfs
,
DWORD
*
pdwSize
)
{
{
IMAGE_DOS_HEADER
dos_hdr
;
IMAGE_DOS_HEADER
dos_hdr
;
IMAGE_NT_HEADERS
nt_hdr
;
IMAGE_NT_HEADERS
nt_hdr
;
DWORD
size
,
count
,
offset
,
len
;
DWORD
count
;
BOOL
r
;
BOOL
r
;
IMAGE_DATA_DIRECTORY
*
sd
;
IMAGE_DATA_DIRECTORY
*
sd
;
...
@@ -80,16 +80,35 @@ static BOOL IMAGEHLP_GetSecurityDirOffset( HANDLE handle, DWORD num,
...
@@ -80,16 +80,35 @@ static BOOL IMAGEHLP_GetSecurityDirOffset( HANDLE handle, DWORD num,
sd
=
&
nt_hdr
.
OptionalHeader
.
sd
=
&
nt_hdr
.
OptionalHeader
.
DataDirectory
[
IMAGE_FILE_SECURITY_DIRECTORY
];
DataDirectory
[
IMAGE_FILE_SECURITY_DIRECTORY
];
TRACE
(
"len = %lx addr = %lx
\n
"
,
sd
->
Size
,
sd
->
VirtualAddress
);
TRACE
(
"size = %lx addr = %lx
\n
"
,
sd
->
Size
,
sd
->
VirtualAddress
);
*
pdwSize
=
sd
->
Size
;
*
pdwOfs
=
sd
->
VirtualAddress
;
offset
=
0
;
return
TRUE
;
size
=
sd
->
Size
;
}
/***********************************************************************
* IMAGEHLP_GetCertificateOffset (INTERNAL)
*
* Read a file's PE header, and return the offset and size of the
* security directory.
*/
static
BOOL
IMAGEHLP_GetCertificateOffset
(
HANDLE
handle
,
DWORD
num
,
DWORD
*
pdwOfs
,
DWORD
*
pdwSize
)
{
DWORD
size
,
count
,
offset
,
len
,
sd_VirtualAddr
;
BOOL
r
;
r
=
IMAGEHLP_GetSecurityDirOffset
(
handle
,
&
sd_VirtualAddr
,
&
size
);
if
(
!
r
)
return
FALSE
;
offset
=
0
;
/* take the n'th certificate */
/* take the n'th certificate */
while
(
1
)
while
(
1
)
{
{
/* read the length of the current certificate */
/* read the length of the current certificate */
count
=
SetFilePointer
(
handle
,
sd
->
VirtualAddress
+
offset
,
count
=
SetFilePointer
(
handle
,
sd
_VirtualAddr
+
offset
,
NULL
,
FILE_BEGIN
);
NULL
,
FILE_BEGIN
);
if
(
count
==
INVALID_SET_FILE_POINTER
)
if
(
count
==
INVALID_SET_FILE_POINTER
)
return
FALSE
;
return
FALSE
;
...
@@ -113,10 +132,10 @@ static BOOL IMAGEHLP_GetSecurityDirOffset( HANDLE handle, DWORD num,
...
@@ -113,10 +132,10 @@ static BOOL IMAGEHLP_GetSecurityDirOffset( HANDLE handle, DWORD num,
return
FALSE
;
return
FALSE
;
}
}
*
pdwOfs
=
sd
->
VirtualAddress
+
offset
;
*
pdwOfs
=
sd
_VirtualAddr
+
offset
;
*
pdwSize
=
len
;
*
pdwSize
=
len
;
TRACE
(
"len = %lx addr = %lx
\n
"
,
len
,
sd
->
VirtualAddress
+
offset
);
TRACE
(
"len = %lx addr = %lx
\n
"
,
len
,
sd
_VirtualAddr
+
offset
);
return
TRUE
;
return
TRUE
;
}
}
...
@@ -140,14 +159,62 @@ BOOL WINAPI ImageAddCertificate(
...
@@ -140,14 +159,62 @@ BOOL WINAPI ImageAddCertificate(
* ImageEnumerateCertificates (IMAGEHLP.@)
* ImageEnumerateCertificates (IMAGEHLP.@)
*/
*/
BOOL
WINAPI
ImageEnumerateCertificates
(
BOOL
WINAPI
ImageEnumerateCertificates
(
HANDLE
FileH
andle
,
WORD
TypeFilter
,
PDWORD
CertificateCount
,
HANDLE
h
andle
,
WORD
TypeFilter
,
PDWORD
CertificateCount
,
PDWORD
Indices
,
DWORD
IndexCount
)
PDWORD
Indices
,
DWORD
IndexCount
)
{
{
FIXME
(
"(%p, %hd, %p, %p, %ld): stub
\n
"
,
DWORD
size
,
count
,
offset
,
sd_VirtualAddr
;
FileHandle
,
TypeFilter
,
CertificateCount
,
Indices
,
IndexCount
WIN_CERTIFICATE
hdr
;
);
const
size_t
cert_hdr_size
=
sizeof
hdr
-
sizeof
hdr
.
bCertificate
;
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
BOOL
r
;
TRACE
(
"%p %hd %p %p %ld
\n
"
,
handle
,
TypeFilter
,
CertificateCount
,
Indices
,
IndexCount
);
if
(
Indices
)
{
FIXME
(
"Indicies not handled!
\n
"
);
return
FALSE
;
}
r
=
IMAGEHLP_GetSecurityDirOffset
(
handle
,
&
sd_VirtualAddr
,
&
size
);
if
(
!
r
)
return
FALSE
;
return
FALSE
;
offset
=
0
;
*
CertificateCount
=
0
;
while
(
offset
<
size
)
{
/* read the length of the current certificate */
count
=
SetFilePointer
(
handle
,
sd_VirtualAddr
+
offset
,
NULL
,
FILE_BEGIN
);
if
(
count
==
INVALID_SET_FILE_POINTER
)
return
FALSE
;
r
=
ReadFile
(
handle
,
&
hdr
,
cert_hdr_size
,
&
count
,
NULL
);
if
(
!
r
)
return
FALSE
;
if
(
count
!=
cert_hdr_size
)
return
FALSE
;
TRACE
(
"Size = %08lx id = %08hx
\n
"
,
hdr
.
dwLength
,
hdr
.
wCertificateType
);
/* check the certificate is not too big or too small */
if
(
hdr
.
dwLength
<
cert_hdr_size
)
return
FALSE
;
if
(
hdr
.
dwLength
>
(
size
-
offset
)
)
return
FALSE
;
if
(
(
TypeFilter
==
CERT_SECTION_TYPE_ANY
)
||
(
TypeFilter
==
hdr
.
wCertificateType
)
)
{
(
*
CertificateCount
)
++
;
}
/* next certificate */
offset
+=
hdr
.
dwLength
;
}
return
TRUE
;
}
}
/***********************************************************************
/***********************************************************************
...
@@ -163,7 +230,7 @@ BOOL WINAPI ImageGetCertificateData(
...
@@ -163,7 +230,7 @@ BOOL WINAPI ImageGetCertificateData(
TRACE
(
"%p %ld %p %p
\n
"
,
handle
,
Index
,
Certificate
,
RequiredLength
);
TRACE
(
"%p %ld %p %p
\n
"
,
handle
,
Index
,
Certificate
,
RequiredLength
);
if
(
!
IMAGEHLP_Get
SecurityDir
Offset
(
handle
,
Index
,
&
ofs
,
&
size
)
)
if
(
!
IMAGEHLP_Get
Certificate
Offset
(
handle
,
Index
,
&
ofs
,
&
size
)
)
return
FALSE
;
return
FALSE
;
if
(
!
Certificate
)
if
(
!
Certificate
)
...
@@ -200,14 +267,32 @@ BOOL WINAPI ImageGetCertificateData(
...
@@ -200,14 +267,32 @@ BOOL WINAPI ImageGetCertificateData(
* ImageGetCertificateHeader (IMAGEHLP.@)
* ImageGetCertificateHeader (IMAGEHLP.@)
*/
*/
BOOL
WINAPI
ImageGetCertificateHeader
(
BOOL
WINAPI
ImageGetCertificateHeader
(
HANDLE
FileHandle
,
DWORD
CertificateIndex
,
HANDLE
handle
,
DWORD
index
,
PWIN_CERTIFICATE
pCert
)
PWIN_CERTIFICATE
Certificateheader
)
{
{
FIXME
(
"(%p, %ld, %p): stub
\n
"
,
DWORD
r
,
offset
,
ofs
,
size
,
count
;
FileHandle
,
CertificateIndex
,
Certificateheader
const
size_t
cert_hdr_size
=
sizeof
*
pCert
-
sizeof
pCert
->
bCertificate
;
);
SetLastError
(
ERROR_CALL_NOT_IMPLEMENTED
);
TRACE
(
"%p %ld %p
\n
"
,
handle
,
index
,
pCert
);
if
(
!
IMAGEHLP_GetCertificateOffset
(
handle
,
index
,
&
ofs
,
&
size
)
)
return
FALSE
;
if
(
size
<
cert_hdr_size
)
return
FALSE
;
offset
=
SetFilePointer
(
handle
,
ofs
,
NULL
,
FILE_BEGIN
);
if
(
offset
==
INVALID_SET_FILE_POINTER
)
return
FALSE
;
return
FALSE
;
r
=
ReadFile
(
handle
,
pCert
,
cert_hdr_size
,
&
count
,
NULL
);
if
(
!
r
)
return
FALSE
;
if
(
count
!=
cert_hdr_size
)
return
FALSE
;
TRACE
(
"OK
\n
"
);
return
TRUE
;
}
}
/***********************************************************************
/***********************************************************************
...
...
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