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
91e33020
Commit
91e33020
authored
Sep 12, 2008
by
Roy Shea
Committed by
Alexandre Julliard
Sep 15, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel32/test: Test import entries of a core windows DLL.
parent
0025ef60
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
1 deletion
+70
-1
loader.c
dlls/kernel32/tests/loader.c
+70
-1
No files found.
dlls/kernel32/tests/loader.c
View file @
91e33020
...
...
@@ -27,6 +27,13 @@
#define ALIGN_SIZE(size, alignment) (((size) + (alignment - 1)) & ~((alignment - 1)))
static
PVOID
RVAToAddr
(
DWORD_PTR
rva
,
HMODULE
module
)
{
if
(
rva
==
0
)
return
NULL
;
return
((
char
*
)
module
)
+
rva
;
}
static
const
struct
{
WORD
e_magic
;
/* 00: MZ Header signature */
...
...
@@ -103,7 +110,7 @@ static IMAGE_SECTION_HEADER section =
IMAGE_SCN_CNT_INITIALIZED_DATA
|
IMAGE_SCN_MEM_READ
,
/* Characteristics */
};
START_TEST
(
loader
)
static
void
test_Loader
(
void
)
{
static
const
struct
test_data
{
...
...
@@ -480,3 +487,65 @@ endloop:
ok
(
DeleteFile
(
dll_name
),
"DeleteFile error %d
\n
"
,
GetLastError
());
}
}
/* Verify linking style of import descriptors */
static
void
test_ImportDescriptors
(
void
)
{
HMODULE
kernel32_module
=
NULL
;
PIMAGE_DOS_HEADER
d_header
;
PIMAGE_NT_HEADERS
nt_headers
;
DWORD
import_dir_size
;
DWORD_PTR
dir_offset
;
PIMAGE_IMPORT_DESCRIPTOR
import_chunk
;
/* Load kernel32 module */
kernel32_module
=
GetModuleHandleA
(
"kernel32.dll"
);
assert
(
kernel32_module
!=
NULL
);
/* Get PE header info from module image */
d_header
=
(
PIMAGE_DOS_HEADER
)
kernel32_module
;
nt_headers
=
(
PIMAGE_NT_HEADERS
)
(((
char
*
)
d_header
)
+
d_header
->
e_lfanew
);
/* Get size of import entry directory */
import_dir_size
=
nt_headers
->
OptionalHeader
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_IMPORT
].
Size
;
if
(
!
import_dir_size
)
{
skip
(
"Unable to continue testing due to missing import directory.
\n
"
);
return
;
}
/* Get address of first import chunk */
dir_offset
=
nt_headers
->
OptionalHeader
.
DataDirectory
[
IMAGE_DIRECTORY_ENTRY_IMPORT
].
VirtualAddress
;
import_chunk
=
RVAToAddr
(
dir_offset
,
kernel32_module
);
ok
(
import_chunk
!=
0
,
"Invalid import_chunk: %p
\n
"
,
import_chunk
);
if
(
!
import_chunk
)
return
;
/* Iterate through import descriptors and verify set name,
* OriginalFirstThunk, and FirstThunk. Core Windows DLLs, such as
* kernel32.dll, don't use Borland-style linking, where the table of
* imported names is stored directly in FirstThunk and overwritten
* by the relocation, instead of being stored in OriginalFirstThunk.
* */
for
(;
import_chunk
->
FirstThunk
;
import_chunk
++
)
{
LPCSTR
module_name
=
(
LPCSTR
)
RVAToAddr
(
import_chunk
->
Name
,
kernel32_module
);
PIMAGE_THUNK_DATA
name_table
=
(
PIMAGE_THUNK_DATA
)
RVAToAddr
(
import_chunk
->
OriginalFirstThunk
,
kernel32_module
);
PIMAGE_THUNK_DATA
iat
=
(
PIMAGE_THUNK_DATA
)
RVAToAddr
(
import_chunk
->
FirstThunk
,
kernel32_module
);
ok
(
module_name
!=
NULL
,
"Imported module name should not be NULL
\n
"
);
ok
(
name_table
!=
NULL
,
"Name table for imported module %s should not be NULL
\n
"
,
module_name
);
ok
(
iat
!=
NULL
,
"IAT for imported module %s should not be NULL
\n
"
,
module_name
);
}
}
START_TEST
(
loader
)
{
test_Loader
();
test_ImportDescriptors
();
}
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