Added wine_ldt_is_system() to replace the IS_SELECTOR_SYSTEM macro,
and stop exporting the WINE_LDT_FIRST_ENTRY constant.
This commit is contained in:
parent
ef2d04d4ed
commit
8fb98a41e0
|
@ -54,7 +54,7 @@ inline static void add_stack( CONTEXT86 *context, int offset )
|
|||
inline static void *make_ptr( CONTEXT86 *context, DWORD seg, DWORD off, int long_addr )
|
||||
{
|
||||
if (ISV86(context)) return (void *)((seg << 4) + LOWORD(off));
|
||||
if (IS_SELECTOR_SYSTEM(seg)) return (void *)off;
|
||||
if (wine_ldt_is_system(seg)) return (void *)off;
|
||||
if (!long_addr) off = LOWORD(off);
|
||||
return (char *) MapSL( MAKESEGPTR( seg, 0 ) ) + off;
|
||||
}
|
||||
|
@ -268,7 +268,7 @@ static BYTE *INSTR_GetOperandAddr( CONTEXT86 *context, BYTE *instr,
|
|||
if (segprefix != -1) seg = segprefix;
|
||||
|
||||
/* Make sure the segment and offset are valid */
|
||||
if (IS_SELECTOR_SYSTEM(seg)) return (BYTE *)(base + (index << ss));
|
||||
if (wine_ldt_is_system(seg)) return (BYTE *)(base + (index << ss));
|
||||
if ((seg & 7) != 7) return NULL;
|
||||
wine_ldt_get_entry( seg, &entry );
|
||||
if (wine_ldt_is_empty( &entry )) return NULL;
|
||||
|
@ -716,7 +716,7 @@ DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
|
|||
break; /* Unable to emulate it */
|
||||
|
||||
case 0xcd: /* int <XX> */
|
||||
if (IS_SELECTOR_SYSTEM(context->SegCs)) break; /* don't emulate it in 32-bit code */
|
||||
if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
|
||||
if (!DOS_EmulateInterruptPM) init_winedos();
|
||||
if (DOS_EmulateInterruptPM)
|
||||
{
|
||||
|
@ -727,7 +727,7 @@ DWORD INSTR_EmulateInstruction( EXCEPTION_RECORD *rec, CONTEXT86 *context )
|
|||
break; /* Unable to emulate it */
|
||||
|
||||
case 0xcf: /* iret */
|
||||
if (IS_SELECTOR_SYSTEM(context->SegCs)) break; /* don't emulate it in 32-bit code */
|
||||
if (wine_ldt_is_system(context->SegCs)) break; /* don't emulate it in 32-bit code */
|
||||
if (long_op)
|
||||
{
|
||||
DWORD *stack = get_stack( context );
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "file.h"
|
||||
#include "task.h"
|
||||
#include "miscemu.h"
|
||||
#include "selectors.h"
|
||||
#include "stackframe.h"
|
||||
#include "kernel_private.h"
|
||||
#include "wine/exception.h"
|
||||
|
@ -182,7 +183,7 @@ static DWORD call16_handler( EXCEPTION_RECORD *record, EXCEPTION_REGISTRATION_RE
|
|||
else if (record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
|
||||
record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION)
|
||||
{
|
||||
if (IS_SELECTOR_SYSTEM(context->SegCs))
|
||||
if (wine_ldt_is_system(context->SegCs))
|
||||
{
|
||||
if (fix_selector( context )) return ExceptionContinueExecution;
|
||||
}
|
||||
|
@ -248,7 +249,7 @@ static LONG CALLBACK vectored_handler( EXCEPTION_POINTERS *ptrs )
|
|||
EXCEPTION_RECORD *record = ptrs->ExceptionRecord;
|
||||
CONTEXT *context = ptrs->ContextRecord;
|
||||
|
||||
if (IS_SELECTOR_SYSTEM(context->SegCs) &&
|
||||
if (wine_ldt_is_system(context->SegCs) &&
|
||||
(record->ExceptionCode == EXCEPTION_ACCESS_VIOLATION ||
|
||||
record->ExceptionCode == EXCEPTION_PRIV_INSTRUCTION))
|
||||
{
|
||||
|
|
|
@ -57,7 +57,6 @@
|
|||
#include "winternl.h"
|
||||
#include "wine/library.h"
|
||||
#include "ntdll_misc.h"
|
||||
#include "selectors.h"
|
||||
|
||||
/***********************************************************************
|
||||
* signal context platform-specific definitions
|
||||
|
@ -616,8 +615,8 @@ static void *init_handler( const SIGCONTEXT *sigcontext )
|
|||
wine_set_fs( teb->teb_sel );
|
||||
|
||||
/* now restore a proper %gs for the fault handler */
|
||||
if (!IS_SELECTOR_SYSTEM(CS_sig(sigcontext)) ||
|
||||
!IS_SELECTOR_SYSTEM(SS_sig(sigcontext))) /* 16-bit mode */
|
||||
if (!wine_ldt_is_system(CS_sig(sigcontext)) ||
|
||||
!wine_ldt_is_system(SS_sig(sigcontext))) /* 16-bit mode */
|
||||
{
|
||||
/*
|
||||
* Win16 or DOS protected mode. Note that during switch
|
||||
|
@ -927,8 +926,8 @@ static void WINAPI raise_vm86_sti_exception( EXCEPTION_RECORD *rec, CONTEXT *con
|
|||
merge_vm86_pending_flags( rec );
|
||||
}
|
||||
else if (NtCurrentTeb()->dpmi_vif &&
|
||||
!IS_SELECTOR_SYSTEM(context->SegCs) &&
|
||||
!IS_SELECTOR_SYSTEM(context->SegSs))
|
||||
!wine_ldt_is_system(context->SegCs) &&
|
||||
!wine_ldt_is_system(context->SegSs))
|
||||
{
|
||||
/* Executing DPMI code and virtual interrupts are enabled. */
|
||||
NtCurrentTeb()->vm86_pending = 0;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "wownt32.h"
|
||||
#include "task.h"
|
||||
#include "dosexe.h"
|
||||
#include "selectors.h"
|
||||
|
||||
#include "excpt.h"
|
||||
#include "wine/debug.h"
|
||||
|
@ -339,7 +340,7 @@ static void DPMI_CallRMCBProc( CONTEXT86 *context, RMCB *rmcb, WORD flag )
|
|||
/* Disable virtual interrupts. */
|
||||
NtCurrentTeb()->dpmi_vif = 0;
|
||||
|
||||
if (IS_SELECTOR_SYSTEM( rmcb->proc_sel )) {
|
||||
if (wine_ldt_is_system( rmcb->proc_sel )) {
|
||||
/* Wine-internal RMCB, call directly */
|
||||
((RMCBPROC)rmcb->proc_ofs)(context);
|
||||
} else __TRY {
|
||||
|
|
|
@ -28,10 +28,7 @@ extern WORD SELECTOR_AllocBlock( const void *base, DWORD size, unsigned char fla
|
|||
extern WORD SELECTOR_ReallocBlock( WORD sel, const void *base, DWORD size );
|
||||
extern void SELECTOR_FreeBlock( WORD sel );
|
||||
|
||||
/* Determine if sel is a system selector (i.e. not managed by Wine) */
|
||||
#define IS_SELECTOR_SYSTEM(sel) \
|
||||
(!((sel) & 4) || ((LOWORD(sel) >> 3) < WINE_LDT_FIRST_ENTRY))
|
||||
#define IS_SELECTOR_32BIT(sel) \
|
||||
(IS_SELECTOR_SYSTEM(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
|
||||
(wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
|
||||
|
||||
#endif /* __WINE_SELECTORS_H */
|
||||
|
|
|
@ -75,6 +75,7 @@ extern void *wine_anon_mmap( void *start, size_t size, int prot, int flags );
|
|||
extern void wine_ldt_init_locking( void (*lock_func)(void), void (*unlock_func)(void) );
|
||||
extern void wine_ldt_get_entry( unsigned short sel, LDT_ENTRY *entry );
|
||||
extern int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry );
|
||||
extern int wine_ldt_is_system( unsigned short sel );
|
||||
extern void *wine_ldt_get_ptr( unsigned short sel, unsigned int offset );
|
||||
extern unsigned short wine_ldt_alloc_entries( int count );
|
||||
extern unsigned short wine_ldt_realloc_entries( unsigned short sel, int oldcount, int newcount );
|
||||
|
@ -115,8 +116,6 @@ WINE_LDT_EXTERN struct __wine_ldt_copy
|
|||
#define WINE_LDT_FLAGS_32BIT 0x40 /* Segment is 32-bit (code or stack) */
|
||||
#define WINE_LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
|
||||
|
||||
#define WINE_LDT_FIRST_ENTRY 512
|
||||
|
||||
/* helper functions to manipulate the LDT_ENTRY structure */
|
||||
inline static void wine_ldt_set_base( LDT_ENTRY *ent, const void *base )
|
||||
{
|
||||
|
|
|
@ -124,6 +124,7 @@ struct __wine_ldt_copy wine_ldt_copy;
|
|||
|
||||
static const LDT_ENTRY null_entry; /* all-zeros, used to clear LDT entries */
|
||||
|
||||
#define LDT_FIRST_ENTRY 512
|
||||
#define LDT_SIZE 8192
|
||||
|
||||
/* empty function for default locks */
|
||||
|
@ -182,7 +183,7 @@ static int internal_set_entry( unsigned short sel, const LDT_ENTRY *entry )
|
|||
{
|
||||
int ret = 0, index = sel >> 3;
|
||||
|
||||
if (index < WINE_LDT_FIRST_ENTRY) return 0; /* cannot modify reserved entries */
|
||||
if (index < LDT_FIRST_ENTRY) return 0; /* cannot modify reserved entries */
|
||||
|
||||
#ifdef __i386__
|
||||
|
||||
|
@ -256,6 +257,17 @@ int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry )
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* wine_ldt_is_system
|
||||
*
|
||||
* Check if the selector is a system selector (i.e. not managed by Wine).
|
||||
*/
|
||||
int wine_ldt_is_system( unsigned short sel )
|
||||
{
|
||||
return is_gdt_sel(sel) || ((sel >> 3) < LDT_FIRST_ENTRY);
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* wine_ldt_get_ptr
|
||||
*
|
||||
|
@ -268,7 +280,7 @@ void *wine_ldt_get_ptr( unsigned short sel, unsigned int offset )
|
|||
|
||||
if (is_gdt_sel(sel)) /* GDT selector */
|
||||
return (void *)offset;
|
||||
if ((index = (sel >> 3)) < WINE_LDT_FIRST_ENTRY) /* system selector */
|
||||
if ((index = (sel >> 3)) < LDT_FIRST_ENTRY) /* system selector */
|
||||
return (void *)offset;
|
||||
if (!(wine_ldt_copy.flags[index] & WINE_LDT_FLAGS_32BIT)) offset &= 0xffff;
|
||||
return (char *)wine_ldt_copy.base[index] + offset;
|
||||
|
@ -287,7 +299,7 @@ unsigned short wine_ldt_alloc_entries( int count )
|
|||
|
||||
if (count <= 0) return 0;
|
||||
lock_ldt();
|
||||
for (i = WINE_LDT_FIRST_ENTRY; i < LDT_SIZE; i++)
|
||||
for (i = LDT_FIRST_ENTRY; i < LDT_SIZE; i++)
|
||||
{
|
||||
if (wine_ldt_copy.flags[i] & WINE_LDT_FLAGS_ALLOCATED) size = 0;
|
||||
else if (++size >= count) /* found a large enough block */
|
||||
|
|
|
@ -51,6 +51,7 @@ EXPORTS
|
|||
wine_ldt_get_ptr
|
||||
wine_ldt_init_fs
|
||||
wine_ldt_init_locking
|
||||
wine_ldt_is_system
|
||||
wine_ldt_realloc_entries
|
||||
wine_ldt_set_entry
|
||||
wine_set_fs
|
||||
|
|
Loading…
Reference in New Issue