ReactOS 0.4.15-dev-8102-g108db8f
Go to the documentation of this file.
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
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 Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
24#include <stdarg.h>
25#include <sys/types.h>
26#include <stdint.h>
28#include <windef.h>
29#include <winbase.h>
31/* configuration */
33extern const char *wine_get_build_dir(void);
34extern const char *wine_get_config_dir(void);
35extern const char *wine_get_data_dir(void);
36extern const char *wine_get_server_dir(void);
37extern const char *wine_get_user_name(void);
38extern void wine_init_argv0_path( const char *argv0 );
39extern void wine_exec_wine_binary( const char *name, char **argv, char **envp, int use_preloader );
41/* dll loading */
43typedef void (*load_dll_callback_t)( void *, const char * );
45extern void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize );
46extern void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize );
47extern int wine_dlclose( void *handle, char *error, size_t errorsize );
49extern void *wine_dll_load( const char *filename, char *error, int errorsize, int *file_exists );
50extern void *wine_dll_load_main_exe( const char *name, char *error, int errorsize,
51 int test_only, int *file_exists );
52extern void wine_dll_unload( void *handle );
53extern int wine_dll_get_owner( const char *name, char *buffer, int size, int *file_exists );
55extern int __wine_main_argc;
56extern char **__wine_main_argv;
58extern char **__wine_main_environ;
59extern void wine_init( int argc, char *argv[], char *error, int error_size );
61/* debugging */
63extern const char * (*__wine_dbgstr_an)( const char * s, int n );
64extern const char * (*__wine_dbgstr_wn)( const WCHAR *s, int n );
65extern const char * (*__wine_dbg_vsprintf)( const char *format, va_list args );
66extern int (*__wine_dbg_vprintf)( const char *format, va_list args );
67extern int (*__wine_dbg_vlog)( unsigned int cls, const char *channel,
68 const char *function, const char *format, va_list args );
70extern void wine_dbg_add_option( const char *name, unsigned char set, unsigned char clear );
71extern int wine_dbg_parse_options( const char *str );
73/* portability */
75extern void DECLSPEC_NORETURN wine_switch_to_stack( void (*func)(void *), void *arg, void *stack );
76extern void wine_set_pe_load_area( void *base, size_t size );
77extern void wine_free_pe_load_area(void);
79/* memory mappings */
81extern void *wine_anon_mmap( void *start, size_t size, int prot, int flags );
82extern void wine_mmap_add_reserved_area( void *addr, size_t size );
83extern void wine_mmap_remove_reserved_area( void *addr, size_t size, int unmap );
84extern int wine_mmap_is_in_reserved_area( void *addr, size_t size );
86/* LDT management */
88extern void wine_ldt_init_locking( void (*lock_func)(void), void (*unlock_func)(void) );
89extern void wine_ldt_get_entry( unsigned short sel, LDT_ENTRY *entry );
90extern int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry );
91extern int wine_ldt_is_system( unsigned short sel );
92extern void *wine_ldt_get_ptr( unsigned short sel, unsigned int offset );
93extern unsigned short wine_ldt_alloc_entries( int count );
94extern unsigned short wine_ldt_realloc_entries( unsigned short sel, int oldcount, int newcount );
95extern void wine_ldt_free_entries( unsigned short sel, int count );
96#ifdef __i386__
97extern unsigned short wine_ldt_alloc_fs(void);
98extern void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry );
99extern void wine_ldt_free_fs( unsigned short sel );
100#else /* __i386__ */
101static inline unsigned short wine_ldt_alloc_fs(void) { return 0x0b; /* pseudo GDT selector */ }
102static inline void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry ) { }
103static inline void wine_ldt_free_fs( unsigned short sel ) { }
104#endif /* __i386__ */
107/* the local copy of the LDT */
108#ifdef __CYGWIN__
110# define WINE_LDT_EXTERN __declspec(dllexport)
111# else
112# define WINE_LDT_EXTERN __declspec(dllimport)
113# endif
115# define WINE_LDT_EXTERN extern
120 void *base[8192]; /* base address or 0 if entry is free */
121 unsigned long limit[8192]; /* limit in bytes or 0 if entry is free */
122 unsigned char flags[8192]; /* flags (defined below) */
125#define WINE_LDT_FLAGS_DATA 0x13 /* Data segment */
126#define WINE_LDT_FLAGS_STACK 0x17 /* Stack segment */
127#define WINE_LDT_FLAGS_CODE 0x1b /* Code segment */
128#define WINE_LDT_FLAGS_TYPE_MASK 0x1f /* Mask for segment type */
129#define WINE_LDT_FLAGS_32BIT 0x40 /* Segment is 32-bit (code or stack) */
130#define WINE_LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
132/* helper functions to manipulate the LDT_ENTRY structure */
133inline static void wine_ldt_set_base( LDT_ENTRY *ent, const void *base )
135 ent->BaseLow = (WORD)(intptr_t)base;
136 ent->HighWord.Bits.BaseMid = (BYTE)((intptr_t)base >> 16);
137 ent->HighWord.Bits.BaseHi = (BYTE)((intptr_t)base >> 24);
139inline static void wine_ldt_set_limit( LDT_ENTRY *ent, unsigned int limit )
141 if ((ent->HighWord.Bits.Granularity = (limit >= 0x100000))) limit >>= 12;
142 ent->LimitLow = (WORD)limit;
143 ent->HighWord.Bits.LimitHi = (limit >> 16);
145inline static void *wine_ldt_get_base( const LDT_ENTRY *ent )
147 return (void *)(ent->BaseLow |
148 (intptr_t)ent->HighWord.Bits.BaseMid << 16 |
149 (intptr_t)ent->HighWord.Bits.BaseHi << 24);
151inline static unsigned int wine_ldt_get_limit( const LDT_ENTRY *ent )
153 unsigned int limit = ent->LimitLow | (ent->HighWord.Bits.LimitHi << 16);
154 if (ent->HighWord.Bits.Granularity) limit = (limit << 12) | 0xfff;
155 return limit;
157inline static void wine_ldt_set_flags( LDT_ENTRY *ent, unsigned char flags )
159 ent->HighWord.Bits.Dpl = 3;
160 ent->HighWord.Bits.Pres = 1;
161 ent->HighWord.Bits.Type = flags;
162 ent->HighWord.Bits.Sys = 0;
163 ent->HighWord.Bits.Reserved_0 = 0;
164 ent->HighWord.Bits.Default_Big = (flags & WINE_LDT_FLAGS_32BIT) != 0;
166inline static unsigned char wine_ldt_get_flags( const LDT_ENTRY *ent )
168 unsigned char ret = ent->HighWord.Bits.Type;
169 if (ent->HighWord.Bits.Default_Big) ret |= WINE_LDT_FLAGS_32BIT;
170 return ret;
172inline static int wine_ldt_is_empty( const LDT_ENTRY *ent )
174 const DWORD *dw = (const DWORD *)ent;
175 return (dw[0] | dw[1]) == 0;
178/* segment register access */
180#ifdef __i386__
181# ifdef __GNUC__
182# define __DEFINE_GET_SEG(seg) \
183 static inline unsigned short wine_get_##seg(void) \
184 { unsigned short res; __asm__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
185# define __DEFINE_SET_SEG(seg) \
186 static 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 { unsigned short res; __asm { mov res, seg } return res; }
191# define __DEFINE_SET_SEG(seg) \
192 extern inline void wine_set_##seg(unsigned short val) { __asm { mov seg, val } }
193# else /* __GNUC__ || _MSC_VER */
194# define __DEFINE_GET_SEG(seg) extern unsigned short wine_get_##seg(void);
195# define __DEFINE_SET_SEG(seg) extern void wine_set_##seg(unsigned int);
196# endif /* __GNUC__ || _MSC_VER */
197#else /* __i386__ */
198# define __DEFINE_GET_SEG(seg) inline static unsigned short wine_get_##seg(void) { return 0; }
199# define __DEFINE_SET_SEG(seg) inline static void wine_set_##seg(int val) { /* nothing */ }
200#endif /* __i386__ */
210#undef __DEFINE_GET_SEG
211#undef __DEFINE_SET_SEG
213#endif /* __WINE_WINE_LIBRARY_H */
static int argc
Definition: ServiceArgs.c:12
char * va_list
Definition: acmsvcex.h:78
static BOOL file_exists(const WCHAR *file_name)
Definition: axinstall.c:70
Definition: _set.h:50
Definition: _stack.h:55
int intptr_t
Definition: crtdefs.h:304
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint start
Definition: gl.h:1545
GLdouble s
Definition: gl.h:2039
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
GLsizeiptr size
Definition: glext.h:5919
GLenum func
Definition: glext.h:6028
GLdouble n
Definition: glext.h:7729
GLuint buffer
Definition: glext.h:5915
GLint limit
Definition: glext.h:10326
GLbitfield flags
Definition: glext.h:7161
GLenum const GLvoid * addr
Definition: glext.h:9621
GLintptr offset
Definition: glext.h:5920
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean flag
Definition: glfuncs.h:52
#define es
Definition: i386-dis.c:440
#define ss
Definition: i386-dis.c:441
#define ds
Definition: i386-dis.c:443
#define cs
Definition: i386-dis.c:442
#define gs
Definition: i386-dis.c:445
Definition: atlbase.h:40
const char * filename
Definition: ioapi.h:137
uint32_t entry
Definition: isohybrid.c:63
void(* load_dll_callback_t)(void *, const char *)
Definition: library.h:43
void wine_ldt_free_entries(unsigned short sel, int count)
void wine_exec_wine_binary(const char *name, char **argv, char **envp, int use_preloader)
void * wine_ldt_get_ptr(unsigned short sel, unsigned int offset)
void wine_ldt_init_locking(void(*lock_func)(void), void(*unlock_func)(void))
static unsigned char wine_ldt_get_flags(const LDT_ENTRY *ent)
Definition: library.h:166
Definition: library.h:129
#define __DEFINE_SET_SEG(seg)
Definition: library.h:199
unsigned short wine_ldt_realloc_entries(unsigned short sel, int oldcount, int newcount)
const char * wine_get_build_dir(void)
Definition: config.c:30
static int wine_ldt_is_empty(const LDT_ENTRY *ent)
Definition: library.h:172
char ** __wine_main_argv
void wine_free_pe_load_area(void)
void * wine_dlopen(const char *filename, int flag, char *error, size_t errorsize)
Definition: loader.c:53
#define __DEFINE_GET_SEG(seg)
Definition: library.h:198
void wine_set_pe_load_area(void *base, size_t size)
const char * wine_get_user_name(void)
void wine_dbg_add_option(const char *name, unsigned char set, unsigned char clear)
unsigned short wine_ldt_alloc_entries(int count)
int wine_dbg_parse_options(const char *str)
const char * wine_get_config_dir(void)
void wine_dll_set_callback(load_dll_callback_t load)
WINE_LDT_EXTERN struct __wine_ldt_copy wine_ldt_copy
int wine_mmap_is_in_reserved_area(void *addr, size_t size)
void wine_ldt_get_entry(unsigned short sel, LDT_ENTRY *entry)
char ** __wine_main_environ
Definition: library.h:115
static void wine_ldt_set_base(LDT_ENTRY *ent, const void *base)
Definition: library.h:133
void * wine_dll_load(const char *filename, char *error, int errorsize, int *file_exists)
const char * wine_get_data_dir(void)
Definition: config.c:24
void wine_mmap_add_reserved_area(void *addr, size_t size)
int wine_dlclose(void *handle, char *error, size_t errorsize)
Definition: loader.c:58
void * wine_anon_mmap(void *start, size_t size, int prot, int flags)
WCHAR ** __wine_main_wargv
static unsigned short wine_ldt_alloc_fs(void)
Definition: library.h:101
const char * wine_get_server_dir(void)
int wine_ldt_set_entry(unsigned short sel, const LDT_ENTRY *entry)
void * wine_dlsym(void *handle, const char *symbol, char *error, size_t errorsize)
Definition: loader.c:48
static void wine_ldt_set_limit(LDT_ENTRY *ent, unsigned int limit)
Definition: library.h:139
int wine_ldt_is_system(unsigned short sel)
static void * wine_ldt_get_base(const LDT_ENTRY *ent)
Definition: library.h:145
int __wine_main_argc
static unsigned int wine_ldt_get_limit(const LDT_ENTRY *ent)
Definition: library.h:151
void wine_init_argv0_path(const char *argv0)
static void wine_ldt_free_fs(unsigned short sel)
Definition: library.h:103
void wine_dll_unload(void *handle)
static void wine_ldt_set_flags(LDT_ENTRY *ent, unsigned char flags)
Definition: library.h:157
int(* __wine_dbg_vlog)(unsigned int cls, const char *channel, const char *function, const char *format, va_list args)
int wine_dll_get_owner(const char *name, char *buffer, int size, int *file_exists)
void wine_mmap_remove_reserved_area(void *addr, size_t size, int unmap)
void DECLSPEC_NORETURN wine_switch_to_stack(void(*func)(void *), void *arg, void *stack)
void * wine_dll_load_main_exe(const char *name, char *error, int errorsize, int test_only, int *file_exists)
void wine_init(int argc, char *argv[], char *error, int error_size)
int(* __wine_dbg_vprintf)(const char *format, va_list args)
static void wine_ldt_init_fs(unsigned short sel, const LDT_ENTRY *entry)
Definition: library.h:102
#define error(str)
Definition: mkdosfs.c:1605
#define argv
Definition: mplay32.c:18
int load
Definition: msacm.c:1365
Definition: ntbasedef.h:176
const WCHAR * str
#define args
Definition: format.c:66
static char argv0[MAX_PATH]
Definition: shlexec.c:49
Definition: compat.h:777
WORD LimitLow
Definition: compat.h:778
WORD BaseLow
Definition: compat.h:779
struct _LDT_ENTRY::@360::@362 Bits
union _LDT_ENTRY::@360 HighWord
Definition: ffs.h:70
Definition: name.c:39
int ret
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193