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
ccdfa494
Commit
ccdfa494
authored
Dec 16, 2008
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Add support for dynamically generated stub entry points.
Based on a patch by Maarten Lankhorst.
parent
ce635744
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
13 deletions
+37
-13
loader.c
dlls/ntdll/loader.c
+37
-13
No files found.
dlls/ntdll/loader.c
View file @
ccdfa494
...
...
@@ -172,24 +172,20 @@ static inline BOOL call_dll_entry_point( DLLENTRYPROC proc, void *module,
#endif
/* __i386__ */
#if
def __i386__
#if
defined(__i386__) || defined(__x86_64__)
/*************************************************************************
* stub_entry_point
*
* Entry point for stub functions.
*/
static
void
stub_entry_point
(
const
char
*
dll
,
const
char
*
name
,
...
)
static
void
stub_entry_point
(
const
char
*
dll
,
const
char
*
name
,
void
*
ret_addr
)
{
EXCEPTION_RECORD
rec
;
rec
.
ExceptionCode
=
EXCEPTION_WINE_STUB
;
rec
.
ExceptionFlags
=
EH_NONCONTINUABLE
;
rec
.
ExceptionRecord
=
NULL
;
#ifdef __GNUC__
rec
.
ExceptionAddress
=
__builtin_return_address
(
0
);
#else
rec
.
ExceptionAddress
=
*
((
void
**
)
&
dll
-
1
);
#endif
rec
.
ExceptionAddress
=
ret_addr
;
rec
.
NumberParameters
=
2
;
rec
.
ExceptionInformation
[
0
]
=
(
ULONG_PTR
)
dll
;
rec
.
ExceptionInformation
[
1
]
=
(
ULONG_PTR
)
name
;
...
...
@@ -198,17 +194,29 @@ static void stub_entry_point( const char *dll, const char *name, ... )
#include "pshpack1.h"
#ifdef __i386__
struct
stub
{
BYTE
popl_eax
;
/* popl %eax */
BYTE
pushl1
;
/* pushl $name */
const
char
*
name
;
BYTE
pushl2
;
/* pushl $dll */
const
char
*
dll
;
BYTE
pushl_eax
;
/* pushl %eax */
BYTE
jmp
;
/* jmp stub_entry_point */
BYTE
call
;
/* call stub_entry_point */
DWORD
entry
;
};
#else
struct
stub
{
BYTE
movq_rdi
[
2
];
/* movq $dll,%rdi */
const
char
*
dll
;
BYTE
movq_rsi
[
2
];
/* movq $name,%rsi */
const
char
*
name
;
BYTE
movq_rsp_rdx
[
4
];
/* movq (%rsp),%rdx */
BYTE
movq_rax
[
2
];
/* movq $entry, %rax */
const
void
*
entry
;
BYTE
jmpq_rax
[
2
];
/* jmp %rax */
};
#endif
#include "poppack.h"
/*************************************************************************
...
...
@@ -233,14 +241,30 @@ static ULONG_PTR allocate_stub( const char *dll, const char *name )
return
0xdeadbeef
;
}
stub
=
&
stubs
[
nb_stubs
++
];
stub
->
popl_eax
=
0x58
;
/* popl %eax */
#ifdef __i386__
stub
->
pushl1
=
0x68
;
/* pushl $name */
stub
->
name
=
name
;
stub
->
pushl2
=
0x68
;
/* pushl $dll */
stub
->
dll
=
dll
;
stub
->
pushl_eax
=
0x50
;
/* pushl %eax */
stub
->
jmp
=
0xe9
;
/* jmp stub_entry_point */
stub
->
call
=
0xe8
;
/* call stub_entry_point */
stub
->
entry
=
(
BYTE
*
)
stub_entry_point
-
(
BYTE
*
)(
&
stub
->
entry
+
1
);
#else
stub
->
movq_rdi
[
0
]
=
0x48
;
/* movq $dll,%rdi */
stub
->
movq_rdi
[
1
]
=
0xbf
;
stub
->
dll
=
dll
;
stub
->
movq_rsi
[
0
]
=
0x48
;
/* movq $name,%rsi */
stub
->
movq_rsi
[
1
]
=
0xbe
;
stub
->
name
=
name
;
stub
->
movq_rsp_rdx
[
0
]
=
0x48
;
/* movq (%rsp),%rdx */
stub
->
movq_rsp_rdx
[
1
]
=
0x8b
;
stub
->
movq_rsp_rdx
[
2
]
=
0x14
;
stub
->
movq_rsp_rdx
[
3
]
=
0x24
;
stub
->
movq_rax
[
0
]
=
0x48
;
/* movq $entry, %rax */
stub
->
movq_rax
[
1
]
=
0xb8
;
stub
->
entry
=
stub_entry_point
;
stub
->
jmpq_rax
[
0
]
=
0xff
;
/* jmp %rax */
stub
->
jmpq_rax
[
1
]
=
0xe0
;
#endif
return
(
ULONG_PTR
)
stub
;
}
...
...
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