2 * Definitions for the Wine library
4 * Copyright 2000 Alexandre Julliard
7 #ifndef __WINE_WINE_LIBRARY_H
8 #define __WINE_WINE_LIBRARY_H
10 #include <sys/types.h>
15 typedef void (*load_dll_callback_t
)( void *, const char * );
17 extern void wine_dll_set_callback( load_dll_callback_t load
);
18 extern void *wine_dll_load( const char *filename
, char *error
, int errorsize
);
19 extern void *wine_dll_load_main_exe( const char *name
, int search_path
,
20 char *error
, int errorsize
);
21 extern void wine_dll_unload( void *handle
);
25 extern void wine_dbg_add_option( const char *name
, unsigned char set
, unsigned char clear
);
29 extern void *wine_anon_mmap( void *start
, size_t size
, int prot
, int flags
);
32 extern int* (*wine_errno_location
)(void);
33 extern int* (*wine_h_errno_location
)(void);
37 extern void wine_ldt_get_entry( unsigned short sel
, LDT_ENTRY
*entry
);
38 extern int wine_ldt_set_entry( unsigned short sel
, const LDT_ENTRY
*entry
);
40 /* the local copy of the LDT */
41 extern struct __wine_ldt_copy
43 void *base
[8192]; /* base address or 0 if entry is free */
44 unsigned long limit
[8192]; /* limit in bytes or 0 if entry is free */
45 unsigned char flags
[8192]; /* flags (defined below) */
48 #define WINE_LDT_FLAGS_DATA 0x13 /* Data segment */
49 #define WINE_LDT_FLAGS_STACK 0x17 /* Stack segment */
50 #define WINE_LDT_FLAGS_CODE 0x1b /* Code segment */
51 #define WINE_LDT_FLAGS_TYPE_MASK 0x1f /* Mask for segment type */
52 #define WINE_LDT_FLAGS_32BIT 0x40 /* Segment is 32-bit (code or stack) */
53 #define WINE_LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
55 /* helper functions to manipulate the LDT_ENTRY structure */
56 inline static void wine_ldt_set_base( LDT_ENTRY
*ent
, const void *base
)
58 ent
->BaseLow
= (WORD
)(unsigned long)base
;
59 ent
->HighWord
.Bits
.BaseMid
= (BYTE
)((unsigned long)base
>> 16);
60 ent
->HighWord
.Bits
.BaseHi
= (BYTE
)((unsigned long)base
>> 24);
62 inline static void wine_ldt_set_limit( LDT_ENTRY
*ent
, unsigned int limit
)
64 if ((ent
->HighWord
.Bits
.Granularity
= (limit
>= 0x100000))) limit
>>= 12;
65 ent
->LimitLow
= (WORD
)limit
;
66 ent
->HighWord
.Bits
.LimitHi
= (limit
>> 16);
68 inline static void *wine_ldt_get_base( const LDT_ENTRY
*ent
)
70 return (void *)(ent
->BaseLow
|
71 (unsigned long)ent
->HighWord
.Bits
.BaseMid
<< 16 |
72 (unsigned long)ent
->HighWord
.Bits
.BaseHi
<< 24);
74 inline static unsigned int wine_ldt_get_limit( const LDT_ENTRY
*ent
)
76 unsigned int limit
= ent
->LimitLow
| (ent
->HighWord
.Bits
.LimitHi
<< 16);
77 if (ent
->HighWord
.Bits
.Granularity
) limit
= (limit
<< 12) | 0xfff;
80 inline static void wine_ldt_set_flags( LDT_ENTRY
*ent
, unsigned char flags
)
82 ent
->HighWord
.Bits
.Dpl
= 3;
83 ent
->HighWord
.Bits
.Pres
= 1;
84 ent
->HighWord
.Bits
.Type
= flags
;
85 ent
->HighWord
.Bits
.Sys
= 0;
86 ent
->HighWord
.Bits
.Reserved_0
= 0;
87 ent
->HighWord
.Bits
.Default_Big
= (flags
& WINE_LDT_FLAGS_32BIT
) != 0;
89 inline static unsigned char wine_ldt_get_flags( const LDT_ENTRY
*ent
)
91 unsigned char ret
= ent
->HighWord
.Bits
.Type
;
92 if (ent
->HighWord
.Bits
.Default_Big
) ret
|= WINE_LDT_FLAGS_32BIT
;
96 #endif /* __WINE_WINE_LIBRARY_H */