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 extern void wine_dll_unload( void *handle );
24 extern void wine_dbg_add_option( const char *name, unsigned char set, unsigned char clear );
28 extern void *wine_anon_mmap( void *start, size_t size, int prot, int flags );
32 extern void wine_ldt_get_entry( unsigned short sel, LDT_ENTRY *entry );
33 extern int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry );
35 /* the local copy of the LDT */
36 extern struct __wine_ldt_copy
38 void *base[8192]; /* base address or 0 if entry is free */
39 unsigned long limit[8192]; /* limit in bytes or 0 if entry is free */
40 unsigned char flags[8192]; /* flags (defined below) */
43 #define WINE_LDT_FLAGS_DATA 0x13 /* Data segment */
44 #define WINE_LDT_FLAGS_STACK 0x17 /* Stack segment */
45 #define WINE_LDT_FLAGS_CODE 0x1b /* Code segment */
46 #define WINE_LDT_FLAGS_TYPE_MASK 0x1f /* Mask for segment type */
47 #define WINE_LDT_FLAGS_32BIT 0x40 /* Segment is 32-bit (code or stack) */
48 #define WINE_LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
50 /* helper functions to manipulate the LDT_ENTRY structure */
51 inline static void wine_ldt_set_base( LDT_ENTRY *ent, const void *base )
53 ent->BaseLow = (WORD)(unsigned long)base;
54 ent->HighWord.Bits.BaseMid = (BYTE)((unsigned long)base >> 16);
55 ent->HighWord.Bits.BaseHi = (BYTE)((unsigned long)base >> 24);
57 inline static void wine_ldt_set_limit( LDT_ENTRY *ent, unsigned int limit )
59 if ((ent->HighWord.Bits.Granularity = (limit >= 0x100000))) limit >>= 12;
60 ent->LimitLow = (WORD)limit;
61 ent->HighWord.Bits.LimitHi = (limit >> 16);
63 inline static void *wine_ldt_get_base( const LDT_ENTRY *ent )
65 return (void *)(ent->BaseLow |
66 (unsigned long)ent->HighWord.Bits.BaseMid << 16 |
67 (unsigned long)ent->HighWord.Bits.BaseHi << 24);
69 inline static unsigned int wine_ldt_get_limit( const LDT_ENTRY *ent )
71 unsigned int limit = ent->LimitLow | (ent->HighWord.Bits.LimitHi << 16);
72 if (ent->HighWord.Bits.Granularity) limit = (limit << 12) | 0xfff;
75 inline static void wine_ldt_set_flags( LDT_ENTRY *ent, unsigned char flags )
77 ent->HighWord.Bits.Dpl = 3;
78 ent->HighWord.Bits.Pres = 1;
79 ent->HighWord.Bits.Type = flags;
80 ent->HighWord.Bits.Sys = 0;
81 ent->HighWord.Bits.Reserved_0 = 0;
82 ent->HighWord.Bits.Default_Big = (flags & WINE_LDT_FLAGS_32BIT) != 0;
84 inline static unsigned char wine_ldt_get_flags( const LDT_ENTRY *ent )
86 unsigned char ret = ent->HighWord.Bits.Type;
87 if (ent->HighWord.Bits.Default_Big) ret |= WINE_LDT_FLAGS_32BIT;
91 #endif /* __WINE_WINE_LIBRARY_H */