ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

library.h
Go to the documentation of this file.
00001 /*
00002  * Definitions for the Wine library
00003  *
00004  * Copyright 2000 Alexandre Julliard
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00019  */
00020 
00021 #ifndef __WINE_WINE_LIBRARY_H
00022 #define __WINE_WINE_LIBRARY_H
00023 
00024 #include <stdarg.h>
00025 #include <sys/types.h>
00026 #include <stdint.h>
00027 
00028 #include <windef.h>
00029 #include <winbase.h>
00030 
00031 /* configuration */
00032 
00033 extern const char *wine_get_build_dir(void);
00034 extern const char *wine_get_config_dir(void);
00035 extern const char *wine_get_data_dir(void);
00036 extern const char *wine_get_server_dir(void);
00037 extern const char *wine_get_user_name(void);
00038 extern void wine_init_argv0_path( const char *argv0 );
00039 extern void wine_exec_wine_binary( const char *name, char **argv, char **envp, int use_preloader );
00040 
00041 /* dll loading */
00042 
00043 typedef void (*load_dll_callback_t)( void *, const char * );
00044 
00045 extern void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize );
00046 extern void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize );
00047 extern int wine_dlclose( void *handle, char *error, size_t errorsize );
00048 extern void wine_dll_set_callback( load_dll_callback_t load );
00049 extern void *wine_dll_load( const char *filename, char *error, int errorsize, int *file_exists );
00050 extern void *wine_dll_load_main_exe( const char *name, char *error, int errorsize,
00051                                      int test_only, int *file_exists );
00052 extern void wine_dll_unload( void *handle );
00053 extern int wine_dll_get_owner( const char *name, char *buffer, int size, int *file_exists );
00054 
00055 extern int __wine_main_argc;
00056 extern char **__wine_main_argv;
00057 extern WCHAR **__wine_main_wargv;
00058 extern char **__wine_main_environ;
00059 extern void wine_init( int argc, char *argv[], char *error, int error_size );
00060 
00061 /* debugging */
00062 
00063 extern const char * (*__wine_dbgstr_an)( const char * s, int n );
00064 extern const char * (*__wine_dbgstr_wn)( const WCHAR *s, int n );
00065 extern const char * (*__wine_dbg_vsprintf)( const char *format, va_list args );
00066 extern int (*__wine_dbg_vprintf)( const char *format, va_list args );
00067 extern int (*__wine_dbg_vlog)( unsigned int cls, const char *channel,
00068                                const char *function, const char *format, va_list args );
00069 
00070 extern void wine_dbg_add_option( const char *name, unsigned char set, unsigned char clear );
00071 extern int wine_dbg_parse_options( const char *str );
00072 
00073 /* portability */
00074 
00075 extern void DECLSPEC_NORETURN wine_switch_to_stack( void (*func)(void *), void *arg, void *stack );
00076 extern void wine_set_pe_load_area( void *base, size_t size );
00077 extern void wine_free_pe_load_area(void);
00078 
00079 /* memory mappings */
00080 
00081 extern void *wine_anon_mmap( void *start, size_t size, int prot, int flags );
00082 extern void wine_mmap_add_reserved_area( void *addr, size_t size );
00083 extern void wine_mmap_remove_reserved_area( void *addr, size_t size, int unmap );
00084 extern int wine_mmap_is_in_reserved_area( void *addr, size_t size );
00085 
00086 /* LDT management */
00087 
00088 extern void wine_ldt_init_locking( void (*lock_func)(void), void (*unlock_func)(void) );
00089 extern void wine_ldt_get_entry( unsigned short sel, LDT_ENTRY *entry );
00090 extern int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry );
00091 extern int wine_ldt_is_system( unsigned short sel );
00092 extern void *wine_ldt_get_ptr( unsigned short sel, unsigned int offset );
00093 extern unsigned short wine_ldt_alloc_entries( int count );
00094 extern unsigned short wine_ldt_realloc_entries( unsigned short sel, int oldcount, int newcount );
00095 extern void wine_ldt_free_entries( unsigned short sel, int count );
00096 #ifdef __i386__
00097 extern unsigned short wine_ldt_alloc_fs(void);
00098 extern void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry );
00099 extern void wine_ldt_free_fs( unsigned short sel );
00100 #else  /* __i386__ */
00101 static inline unsigned short wine_ldt_alloc_fs(void) { return 0x0b; /* pseudo GDT selector */ }
00102 static inline void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry ) { }
00103 static inline void wine_ldt_free_fs( unsigned short sel ) { }
00104 #endif  /* __i386__ */
00105 
00106 
00107 /* the local copy of the LDT */
00108 #ifdef __CYGWIN__
00109 # ifdef WINE_EXPORT_LDT_COPY
00110 #  define WINE_LDT_EXTERN __declspec(dllexport)
00111 # else
00112 #  define WINE_LDT_EXTERN __declspec(dllimport)
00113 # endif
00114 #else
00115 # define WINE_LDT_EXTERN extern
00116 #endif
00117 
00118 WINE_LDT_EXTERN struct __wine_ldt_copy
00119 {
00120     void         *base[8192];  /* base address or 0 if entry is free   */
00121     unsigned long limit[8192]; /* limit in bytes or 0 if entry is free */
00122     unsigned char flags[8192]; /* flags (defined below) */
00123 } wine_ldt_copy;
00124 
00125 #define WINE_LDT_FLAGS_DATA      0x13  /* Data segment */
00126 #define WINE_LDT_FLAGS_STACK     0x17  /* Stack segment */
00127 #define WINE_LDT_FLAGS_CODE      0x1b  /* Code segment */
00128 #define WINE_LDT_FLAGS_TYPE_MASK 0x1f  /* Mask for segment type */
00129 #define WINE_LDT_FLAGS_32BIT     0x40  /* Segment is 32-bit (code or stack) */
00130 #define WINE_LDT_FLAGS_ALLOCATED 0x80  /* Segment is allocated (no longer free) */
00131 
00132 /* helper functions to manipulate the LDT_ENTRY structure */
00133 inline static void wine_ldt_set_base( LDT_ENTRY *ent, const void *base )
00134 {
00135     ent->BaseLow               = (WORD)(intptr_t)base;
00136     ent->HighWord.Bits.BaseMid = (BYTE)((intptr_t)base >> 16);
00137     ent->HighWord.Bits.BaseHi  = (BYTE)((intptr_t)base >> 24);
00138 }
00139 inline static void wine_ldt_set_limit( LDT_ENTRY *ent, unsigned int limit )
00140 {
00141     if ((ent->HighWord.Bits.Granularity = (limit >= 0x100000))) limit >>= 12;
00142     ent->LimitLow = (WORD)limit;
00143     ent->HighWord.Bits.LimitHi = (limit >> 16);
00144 }
00145 inline static void *wine_ldt_get_base( const LDT_ENTRY *ent )
00146 {
00147     return (void *)(ent->BaseLow |
00148                     (intptr_t)ent->HighWord.Bits.BaseMid << 16 |
00149                     (intptr_t)ent->HighWord.Bits.BaseHi << 24);
00150 }
00151 inline static unsigned int wine_ldt_get_limit( const LDT_ENTRY *ent )
00152 {
00153     unsigned int limit = ent->LimitLow | (ent->HighWord.Bits.LimitHi << 16);
00154     if (ent->HighWord.Bits.Granularity) limit = (limit << 12) | 0xfff;
00155     return limit;
00156 }
00157 inline static void wine_ldt_set_flags( LDT_ENTRY *ent, unsigned char flags )
00158 {
00159     ent->HighWord.Bits.Dpl         = 3;
00160     ent->HighWord.Bits.Pres        = 1;
00161     ent->HighWord.Bits.Type        = flags;
00162     ent->HighWord.Bits.Sys         = 0;
00163     ent->HighWord.Bits.Reserved_0  = 0;
00164     ent->HighWord.Bits.Default_Big = (flags & WINE_LDT_FLAGS_32BIT) != 0;
00165 }
00166 inline static unsigned char wine_ldt_get_flags( const LDT_ENTRY *ent )
00167 {
00168     unsigned char ret = ent->HighWord.Bits.Type;
00169     if (ent->HighWord.Bits.Default_Big) ret |= WINE_LDT_FLAGS_32BIT;
00170     return ret;
00171 }
00172 inline static int wine_ldt_is_empty( const LDT_ENTRY *ent )
00173 {
00174     const DWORD *dw = (const DWORD *)ent;
00175     return (dw[0] | dw[1]) == 0;
00176 }
00177 
00178 /* segment register access */
00179 
00180 #ifdef __i386__
00181 # ifdef __GNUC__
00182 #  define __DEFINE_GET_SEG(seg) \
00183     static inline unsigned short wine_get_##seg(void) \
00184     { unsigned short res; __asm__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
00185 #  define __DEFINE_SET_SEG(seg) \
00186     static inline void wine_set_##seg(int val) { __asm__("movw %w0,%%" #seg : : "r" (val)); }
00187 # elif defined(_MSC_VER)
00188 #  define __DEFINE_GET_SEG(seg) \
00189     extern inline unsigned short wine_get_##seg(void) \
00190     { unsigned short res; __asm { mov res, seg } return res; }
00191 #  define __DEFINE_SET_SEG(seg) \
00192     extern inline void wine_set_##seg(unsigned short val) { __asm { mov seg, val } }
00193 # else  /* __GNUC__ || _MSC_VER */
00194 #  define __DEFINE_GET_SEG(seg) extern unsigned short wine_get_##seg(void);
00195 #  define __DEFINE_SET_SEG(seg) extern void wine_set_##seg(unsigned int);
00196 # endif /* __GNUC__ || _MSC_VER */
00197 #else  /* __i386__ */
00198 # define __DEFINE_GET_SEG(seg) inline static unsigned short wine_get_##seg(void) { return 0; }
00199 # define __DEFINE_SET_SEG(seg) inline static void wine_set_##seg(int val) { /* nothing */ }
00200 #endif  /* __i386__ */
00201 
00202 __DEFINE_GET_SEG(cs)
00203 __DEFINE_GET_SEG(ds)
00204 __DEFINE_GET_SEG(es)
00205 __DEFINE_GET_SEG(fs)
00206 __DEFINE_GET_SEG(gs)
00207 __DEFINE_GET_SEG(ss)
00208 __DEFINE_SET_SEG(fs)
00209 __DEFINE_SET_SEG(gs)
00210 #undef __DEFINE_GET_SEG
00211 #undef __DEFINE_SET_SEG
00212 
00213 #endif  /* __WINE_WINE_LIBRARY_H */

Generated on Sun May 27 2012 04:33:19 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.