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
64ddb263
Commit
64ddb263
authored
Feb 12, 2013
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ntdll: Check for invalid %gs value in 32-bit code.
Suggested by Alessandro Pignotti.
parent
99d89b34
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
0 deletions
+43
-0
signal_i386.c
dlls/ntdll/signal_i386.c
+43
-0
No files found.
dlls/ntdll/signal_i386.c
View file @
64ddb263
...
...
@@ -1507,6 +1507,47 @@ static inline DWORD is_privileged_instr( CONTEXT *context )
}
}
/***********************************************************************
* check_invalid_gs
*
* Check for fault caused by invalid %gs value (some copy protection schemes mess with it).
*/
static
inline
BOOL
check_invalid_gs
(
CONTEXT
*
context
)
{
unsigned
int
prefix_count
=
0
;
const
BYTE
*
instr
=
(
BYTE
*
)
context
->
Eip
;
WORD
system_gs
=
ntdll_get_thread_data
()
->
gs
;
if
(
context
->
SegGs
==
system_gs
)
return
FALSE
;
if
(
!
wine_ldt_is_system
(
context
->
SegCs
))
return
FALSE
;
/* only handle faults in system libraries */
if
(
virtual_is_valid_code_address
(
instr
,
1
))
return
FALSE
;
for
(;;)
switch
(
*
instr
)
{
/* instruction prefixes */
case
0x2e
:
/* %cs: */
case
0x36
:
/* %ss: */
case
0x3e
:
/* %ds: */
case
0x26
:
/* %es: */
case
0x64
:
/* %fs: */
case
0x66
:
/* opcode size */
case
0x67
:
/* addr size */
case
0xf0
:
/* lock */
case
0xf2
:
/* repne */
case
0xf3
:
/* repe */
if
(
++
prefix_count
>=
15
)
return
FALSE
;
instr
++
;
continue
;
case
0x65
:
/* %gs: */
TRACE
(
"%04x/%04x at %p, fixing up
\n
"
,
context
->
SegGs
,
system_gs
,
instr
);
context
->
SegGs
=
system_gs
;
return
TRUE
;
default
:
return
FALSE
;
}
}
#include "pshpack1.h"
struct
atl_thunk
...
...
@@ -1716,6 +1757,8 @@ static void WINAPI raise_segv_exception( EXCEPTION_RECORD *rec, CONTEXT *context
{
if
(
rec
->
ExceptionInformation
[
0
]
==
EXCEPTION_EXECUTE_FAULT
&&
check_atl_thunk
(
rec
,
context
))
goto
done
;
if
(
rec
->
ExceptionInformation
[
1
]
==
0xffffffff
&&
check_invalid_gs
(
context
))
goto
done
;
if
(
!
(
rec
->
ExceptionCode
=
virtual_handle_fault
(
(
void
*
)
rec
->
ExceptionInformation
[
1
],
rec
->
ExceptionInformation
[
0
]
)))
goto
done
;
...
...
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