~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/include/wine/library.h

Version: ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~ [ wine-1.0-rc5 ] ~ [ wine-1.0-rc4 ] ~ [ wine-1.0-rc3 ] ~ [ wine-1.0-rc2 ] ~ [ wine-1.0-rc1 ] ~ [ wine-0.9.61 ] ~ [ wine-0.9.60 ] ~ [ wine-0.9.59 ] ~ [ wine-0.9.58 ] ~ [ wine-0.9.57 ] ~ [ wine-0.9.56 ] ~ [ wine-0.9.55 ] ~ [ wine-0.9.54 ] ~ [ wine-0.9.53 ] ~ [ wine-0.9.52 ] ~ [ wine-0.9.51 ] ~ [ wine-0.9.50 ] ~ [ wine-0.9.49 ] ~ [ wine-0.9.48 ] ~ [ wine-0.9.47 ] ~ [ wine-0.9.46 ] ~ [ wine-0.9.45 ] ~ [ wine-0.9.44 ] ~ [ wine-0.9.43 ] ~ [ wine-0.9.42 ] ~ [ wine-0.9.41 ] ~ [ wine-0.9.40 ] ~ [ wine-0.9.39 ] ~ [ wine-0.9.38 ] ~ [ wine-0.9.37 ] ~ [ wine-0.9.36 ] ~ [ wine-0.9.35 ] ~ [ wine-0.9.34 ] ~ [ wine-0.9.33 ] ~ [ wine-0.9.32 ] ~ [ wine-0.9.31 ] ~ [ wine-0.9.30 ] ~ [ wine-0.9.29 ] ~ [ wine-0.9.28 ] ~ [ wine-0.9.27 ] ~ [ wine-0.9.26 ] ~ [ wine-0.9.25 ] ~ [ wine-0.9.24 ] ~ [ wine-0.9.23 ] ~ [ wine-0.9.22 ] ~ [ wine-0.9.21 ] ~ [ wine-0.9.20 ] ~ [ wine-0.9.19 ] ~ [ wine-0.9.18 ] ~ [ wine-0.9.17 ] ~ [ wine-0.9.16 ] ~ [ wine-0.9.15 ] ~ [ wine-0.9.14 ] ~ [ wine-0.9.13 ] ~ [ wine-0.9.12 ] ~ [ wine-0.9.11 ] ~ [ wine-0.9.10 ] ~ [ wine-0.9.9 ] ~ [ wine-0.9.8 ] ~ [ wine-0.9.7 ] ~ [ wine-0.9.6 ] ~ [ wine-0.9.5 ] ~ [ wine-0.9.4 ] ~ [ wine-0.9.3 ] ~ [ wine-0.9.2 ] ~ [ wine-0.9.1 ] ~ [ wine-0.9 ] ~ [ wine20050930 ] ~ [ wine20050830 ] ~ [ wine20050725 ] ~ [ wine20050628 ] ~ [ wine20050524 ] ~ [ wine20050419 ] ~ [ wine20050310 ] ~ [ wine20050211 ] ~ [ wine20050111 ] ~ [ wine20041201 ] ~ [ wine20041019 ] ~ [ wine20040914 ] ~ [ wine20040813 ] ~ [ wine20040716 ] ~ [ wine20040615 ] ~ [ wine20040505 ] ~ [ wine20040408 ] ~ [ wine20040309 ] ~ [ wine20040213 ] ~ [ wine20040121 ] ~ [ wine20031212 ] ~ [ wine20031118 ] ~ [ wine20031016 ] ~ [ wine20030911 ] ~ [ wine20030813 ] ~ [ wine20030709 ] ~ [ wine20030618 ] ~ [ wine20030508 ] ~ [ wine20030408 ] ~ [ wine20030318 ] ~ [ wine20030219 ] ~ [ wine20030115 ] ~ [ wine20021219 ] ~ [ wine20021125 ] ~ [ wine20021031 ] ~ [ wine20021007 ] ~ [ wine20020904 ] ~ [ wine20020804 ] ~ [ wine20020710 ] ~ [ wine20020605 ] ~ [ wine20020509 ] ~ [ wine20020411 ] ~ [ wine20020310 ] ~ [ wine20020228 ] ~ [ wine20011226 ] ~ [ wine20011108 ] ~ [ wine20011004 ] ~ [ wine20010824 ] ~ [ wine20010731 ] ~ [ wine20010629 ] ~ [ wine20010510 ] ~ [ wine20010418 ] ~ [ wine20010326 ] ~ [ wine20010305 ] ~ [ wine20010216 ] ~ [ wine20010112 ] ~ [ wine20001222 ] ~ [ wine20001202 ] ~ [ wine20001026 ] ~ [ wine20001002 ] ~ [ wine20000909 ] ~ [ wine20000821 ] ~ [ wine20000801 ] ~ [ wine20000716 ] ~ [ wine20000326 ] ~ [ wine20000227 ] ~ [ wine20000130 ] ~ [ wine20000109 ] ~

  1 /*
  2  * Definitions for the Wine library
  3  *
  4  * Copyright 2000 Alexandre Julliard
  5  *
  6  * This library is free software; you can redistribute it and/or
  7  * modify it under the terms of the GNU Lesser General Public
  8  * License as published by the Free Software Foundation; either
  9  * version 2.1 of the License, or (at your option) any later version.
 10  *
 11  * This library is distributed in the hope that it will be useful,
 12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 14  * Lesser General Public License for more details.
 15  *
 16  * You should have received a copy of the GNU Lesser General Public
 17  * License along with this library; if not, write to the Free Software
 18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 19  */
 20 
 21 #ifndef __WINE_WINE_LIBRARY_H
 22 #define __WINE_WINE_LIBRARY_H
 23 
 24 #include <stdarg.h>
 25 #include <sys/types.h>
 26 
 27 #include <windef.h>
 28 #include <winbase.h>
 29 
 30 #ifdef __WINE_WINE_TEST_H
 31 #error This file should not be used in Wine tests
 32 #endif
 33 
 34 /* configuration */
 35 
 36 extern const char *wine_get_build_dir(void);
 37 extern const char *wine_get_config_dir(void);
 38 extern const char *wine_get_data_dir(void);
 39 extern const char *wine_get_server_dir(void);
 40 extern const char *wine_get_user_name(void);
 41 extern const char *wine_get_version(void);
 42 extern const char *wine_get_build_id(void);
 43 extern void wine_init_argv0_path( const char *argv0 );
 44 extern void wine_exec_wine_binary( const char *name, char **argv, const char *env_var );
 45 
 46 /* dll loading */
 47 
 48 typedef void (*load_dll_callback_t)( void *, const char * );
 49 
 50 extern void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize );
 51 extern void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize );
 52 extern int wine_dlclose( void *handle, char *error, size_t errorsize );
 53 extern void wine_dll_set_callback( load_dll_callback_t load );
 54 extern void *wine_dll_load( const char *filename, char *error, int errorsize, int *file_exists );
 55 extern void *wine_dll_load_main_exe( const char *name, char *error, int errorsize,
 56                                      int test_only, int *file_exists );
 57 extern void wine_dll_unload( void *handle );
 58 extern const char *wine_dll_enum_load_path( unsigned int index );
 59 extern int wine_dll_get_owner( const char *name, char *buffer, int size, int *file_exists );
 60 
 61 extern int __wine_main_argc;
 62 extern char **__wine_main_argv;
 63 extern WCHAR **__wine_main_wargv;
 64 extern char **__wine_main_environ;
 65 extern void __wine_dll_register( const IMAGE_NT_HEADERS *header, const char *filename );
 66 extern void wine_init( int argc, char *argv[], char *error, int error_size );
 67 
 68 /* portability */
 69 
 70 extern void DECLSPEC_NORETURN wine_switch_to_stack( void (*func)(void *), void *arg, void *stack );
 71 extern int wine_call_on_stack( int (*func)(void *), void *arg, void *stack );
 72 extern void wine_set_pe_load_area( void *base, size_t size );
 73 extern void wine_free_pe_load_area(void);
 74 
 75 /* memory mappings */
 76 
 77 extern void *wine_anon_mmap( void *start, size_t size, int prot, int flags );
 78 extern void wine_mmap_add_reserved_area( void *addr, size_t size );
 79 extern void wine_mmap_remove_reserved_area( void *addr, size_t size, int unmap );
 80 extern int wine_mmap_is_in_reserved_area( void *addr, size_t size );
 81 extern int wine_mmap_enum_reserved_areas( int (*enum_func)(void *base, size_t size, void *arg),
 82                                           void *arg, int top_down );
 83 
 84 /* LDT management */
 85 
 86 extern void wine_ldt_init_locking( void (*lock_func)(void), void (*unlock_func)(void) );
 87 extern void wine_ldt_get_entry( unsigned short sel, LDT_ENTRY *entry );
 88 extern int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry );
 89 extern int wine_ldt_is_system( unsigned short sel );
 90 extern void *wine_ldt_get_ptr( unsigned short sel, unsigned long offset );
 91 extern unsigned short wine_ldt_alloc_entries( int count );
 92 extern unsigned short wine_ldt_realloc_entries( unsigned short sel, int oldcount, int newcount );
 93 extern void wine_ldt_free_entries( unsigned short sel, int count );
 94 #ifdef __i386__
 95 extern unsigned short wine_ldt_alloc_fs(void);
 96 extern void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry );
 97 extern void wine_ldt_free_fs( unsigned short sel );
 98 #else  /* __i386__ */
 99 static inline unsigned short wine_ldt_alloc_fs(void) { return 0x0b; /* pseudo GDT selector */ }
100 static inline void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry ) { }
101 static inline void wine_ldt_free_fs( unsigned short sel ) { }
102 #endif  /* __i386__ */
103 
104 
105 /* the local copy of the LDT */
106 #ifdef __CYGWIN__
107 # ifdef WINE_EXPORT_LDT_COPY
108 #  define WINE_LDT_EXTERN __declspec(dllexport)
109 # else
110 #  define WINE_LDT_EXTERN __declspec(dllimport)
111 # endif
112 #else
113 # define WINE_LDT_EXTERN extern
114 #endif
115 
116 WINE_LDT_EXTERN struct __wine_ldt_copy
117 {
118     void         *base[8192];  /* base address or 0 if entry is free   */
119     unsigned long limit[8192]; /* limit in bytes or 0 if entry is free */
120     unsigned char flags[8192]; /* flags (defined below) */
121 } wine_ldt_copy;
122 
123 #define WINE_LDT_FLAGS_DATA      0x13  /* Data segment */
124 #define WINE_LDT_FLAGS_STACK     0x17  /* Stack segment */
125 #define WINE_LDT_FLAGS_CODE      0x1b  /* Code segment */
126 #define WINE_LDT_FLAGS_TYPE_MASK 0x1f  /* Mask for segment type */
127 #define WINE_LDT_FLAGS_32BIT     0x40  /* Segment is 32-bit (code or stack) */
128 #define WINE_LDT_FLAGS_ALLOCATED 0x80  /* Segment is allocated (no longer free) */
129 
130 /* helper functions to manipulate the LDT_ENTRY structure */
131 static inline void wine_ldt_set_base( LDT_ENTRY *ent, const void *base )
132 {
133     ent->BaseLow               = (WORD)(unsigned long)base;
134     ent->HighWord.Bits.BaseMid = (BYTE)((unsigned long)base >> 16);
135     ent->HighWord.Bits.BaseHi  = (BYTE)((unsigned long)base >> 24);
136 }
137 static inline void wine_ldt_set_limit( LDT_ENTRY *ent, unsigned int limit )
138 {
139     if ((ent->HighWord.Bits.Granularity = (limit >= 0x100000))) limit >>= 12;
140     ent->LimitLow = (WORD)limit;
141     ent->HighWord.Bits.LimitHi = (limit >> 16);
142 }
143 static inline void *wine_ldt_get_base( const LDT_ENTRY *ent )
144 {
145     return (void *)(ent->BaseLow |
146                     (unsigned long)ent->HighWord.Bits.BaseMid << 16 |
147                     (unsigned long)ent->HighWord.Bits.BaseHi << 24);
148 }
149 static inline unsigned int wine_ldt_get_limit( const LDT_ENTRY *ent )
150 {
151     unsigned int limit = ent->LimitLow | (ent->HighWord.Bits.LimitHi << 16);
152     if (ent->HighWord.Bits.Granularity) limit = (limit << 12) | 0xfff;
153     return limit;
154 }
155 static inline void wine_ldt_set_flags( LDT_ENTRY *ent, unsigned char flags )
156 {
157     ent->HighWord.Bits.Dpl         = 3;
158     ent->HighWord.Bits.Pres        = 1;
159     ent->HighWord.Bits.Type        = flags;
160     ent->HighWord.Bits.Sys         = 0;
161     ent->HighWord.Bits.Reserved_0  = 0;
162     ent->HighWord.Bits.Default_Big = (flags & WINE_LDT_FLAGS_32BIT) != 0;
163 }
164 static inline unsigned char wine_ldt_get_flags( const LDT_ENTRY *ent )
165 {
166     unsigned char ret = ent->HighWord.Bits.Type;
167     if (ent->HighWord.Bits.Default_Big) ret |= WINE_LDT_FLAGS_32BIT;
168     return ret;
169 }
170 static inline int wine_ldt_is_empty( const LDT_ENTRY *ent )
171 {
172     const DWORD *dw = (const DWORD *)ent;
173     return (dw[0] | dw[1]) == 0;
174 }
175 
176 /* segment register access */
177 
178 #ifdef __i386__
179 # ifdef __GNUC__
180 #  define __DEFINE_GET_SEG(seg) \
181     extern inline unsigned short wine_get_##seg(void); \
182     extern inline unsigned short wine_get_##seg(void) \
183     { unsigned short res; __asm__ __volatile__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
184 #  define __DEFINE_SET_SEG(seg) \
185     extern inline void wine_set_##seg(int val); \
186     extern inline void wine_set_##seg(int val) { __asm__("movw %w0,%%" #seg : : "r" (val)); }
187 # elif defined(_MSC_VER)
188 #  define __DEFINE_GET_SEG(seg) \
189     extern inline unsigned short wine_get_##seg(void); \
190     extern inline unsigned short wine_get_##seg(void) \
191     { unsigned short res; __asm { mov res, seg } return res; }
192 #  define __DEFINE_SET_SEG(seg) \
193     extern inline void wine_set_##seg(unsigned short val); \
194     extern inline void wine_set_##seg(unsigned short val) { __asm { mov seg, val } }
195 # else  /* __GNUC__ || _MSC_VER */
196 #  define __DEFINE_GET_SEG(seg) extern unsigned short wine_get_##seg(void);
197 #  define __DEFINE_SET_SEG(seg) extern void wine_set_##seg(unsigned int);
198 # endif /* __GNUC__ || _MSC_VER */
199 #else  /* __i386__ */
200 # define __DEFINE_GET_SEG(seg) static inline unsigned short wine_get_##seg(void) { return 0; }
201 # define __DEFINE_SET_SEG(seg) static inline void wine_set_##seg(int val) { /* nothing */ }
202 #endif  /* __i386__ */
203 
204 __DEFINE_GET_SEG(cs)
205 __DEFINE_GET_SEG(ds)
206 __DEFINE_GET_SEG(es)
207 __DEFINE_GET_SEG(fs)
208 __DEFINE_GET_SEG(gs)
209 __DEFINE_GET_SEG(ss)
210 __DEFINE_SET_SEG(fs)
211 __DEFINE_SET_SEG(gs)
212 #undef __DEFINE_GET_SEG
213 #undef __DEFINE_SET_SEG
214 
215 #endif  /* __WINE_WINE_LIBRARY_H */
216 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.