VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Wine/include/wine/library.h@ 16477

最後變更 在這個檔案從16477是 16477,由 vboxsync 提交於 16 年 前

LGPL disclaimer by filemuncher

  • 屬性 svn:eol-style 設為 native
檔案大小: 9.6 KB
 
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/*
22 * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
23 * other than GPL or LGPL is available it will apply instead, Sun elects to use only
24 * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
25 * a choice of LGPL license versions is made available with the language indicating
26 * that LGPLv2 or any later version may be used, or where a choice of which version
27 * of the LGPL is applied is otherwise unspecified.
28 */
29
30#ifndef __WINE_WINE_LIBRARY_H
31#define __WINE_WINE_LIBRARY_H
32
33#include <stdarg.h>
34#include <sys/types.h>
35
36#include <windef.h>
37#include <winbase.h>
38
39#ifdef __WINE_WINE_TEST_H
40#error This file should not be used in Wine tests
41#endif
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47/* configuration */
48
49extern const char *wine_get_build_dir(void);
50extern const char *wine_get_config_dir(void);
51extern const char *wine_get_data_dir(void);
52extern const char *wine_get_server_dir(void);
53extern const char *wine_get_user_name(void);
54extern const char *wine_get_version(void);
55extern const char *wine_get_build_id(void);
56extern void wine_init_argv0_path( const char *argv0 );
57extern void wine_exec_wine_binary( const char *name, char **argv, const char *env_var );
58
59/* dll loading */
60
61typedef void (*load_dll_callback_t)( void *, const char * );
62
63extern void *wine_dlopen( const char *filename, int flag, char *error, size_t errorsize );
64extern void *wine_dlsym( void *handle, const char *symbol, char *error, size_t errorsize );
65extern int wine_dlclose( void *handle, char *error, size_t errorsize );
66extern void wine_dll_set_callback( load_dll_callback_t load );
67extern void *wine_dll_load( const char *filename, char *error, int errorsize, int *file_exists );
68extern void *wine_dll_load_main_exe( const char *name, char *error, int errorsize,
69 int test_only, int *file_exists );
70extern void wine_dll_unload( void *handle );
71extern const char *wine_dll_enum_load_path( unsigned int index );
72extern int wine_dll_get_owner( const char *name, char *buffer, int size, int *file_exists );
73
74extern int __wine_main_argc;
75extern char **__wine_main_argv;
76extern WCHAR **__wine_main_wargv;
77extern char **__wine_main_environ;
78extern void __wine_dll_register( const IMAGE_NT_HEADERS *header, const char *filename );
79extern void wine_init( int argc, char *argv[], char *error, int error_size );
80
81/* portability */
82
83extern void DECLSPEC_NORETURN wine_switch_to_stack( void (*func)(void *), void *arg, void *stack );
84extern int wine_call_on_stack( int (*func)(void *), void *arg, void *stack );
85
86/* memory mappings */
87
88extern void *wine_anon_mmap( void *start, size_t size, int prot, int flags );
89extern void wine_mmap_add_reserved_area( void *addr, size_t size );
90extern void wine_mmap_remove_reserved_area( void *addr, size_t size, int unmap );
91extern int wine_mmap_is_in_reserved_area( void *addr, size_t size );
92extern int wine_mmap_enum_reserved_areas( int (*enum_func)(void *base, size_t size, void *arg),
93 void *arg, int top_down );
94
95/* LDT management */
96
97extern void wine_ldt_init_locking( void (*lock_func)(void), void (*unlock_func)(void) );
98extern void wine_ldt_get_entry( unsigned short sel, LDT_ENTRY *entry );
99extern int wine_ldt_set_entry( unsigned short sel, const LDT_ENTRY *entry );
100extern int wine_ldt_is_system( unsigned short sel );
101extern void *wine_ldt_get_ptr( unsigned short sel, unsigned long offset );
102extern unsigned short wine_ldt_alloc_entries( int count );
103extern unsigned short wine_ldt_realloc_entries( unsigned short sel, int oldcount, int newcount );
104extern void wine_ldt_free_entries( unsigned short sel, int count );
105#if defined(__i386__) && !defined(__MINGW32__) && !defined(_MSC_VER)
106extern unsigned short wine_ldt_alloc_fs(void);
107extern void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry );
108extern void wine_ldt_free_fs( unsigned short sel );
109#else /* __i386__ */
110static inline unsigned short wine_ldt_alloc_fs(void) { return 0x0b; /* pseudo GDT selector */ }
111static inline void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry ) { }
112static inline void wine_ldt_free_fs( unsigned short sel ) { }
113#endif /* __i386__ */
114
115
116/* the local copy of the LDT */
117#ifdef __CYGWIN__
118# ifdef WINE_EXPORT_LDT_COPY
119# define WINE_LDT_EXTERN __declspec(dllexport)
120# else
121# define WINE_LDT_EXTERN __declspec(dllimport)
122# endif
123#else
124# define WINE_LDT_EXTERN extern
125#endif
126
127WINE_LDT_EXTERN struct __wine_ldt_copy
128{
129 void *base[8192]; /* base address or 0 if entry is free */
130 unsigned long limit[8192]; /* limit in bytes or 0 if entry is free */
131 unsigned char flags[8192]; /* flags (defined below) */
132} wine_ldt_copy;
133
134#define WINE_LDT_FLAGS_DATA 0x13 /* Data segment */
135#define WINE_LDT_FLAGS_STACK 0x17 /* Stack segment */
136#define WINE_LDT_FLAGS_CODE 0x1b /* Code segment */
137#define WINE_LDT_FLAGS_TYPE_MASK 0x1f /* Mask for segment type */
138#define WINE_LDT_FLAGS_32BIT 0x40 /* Segment is 32-bit (code or stack) */
139#define WINE_LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
140
141/* helper functions to manipulate the LDT_ENTRY structure */
142static inline void wine_ldt_set_base( LDT_ENTRY *ent, const void *base )
143{
144 ent->BaseLow = (WORD)(unsigned long)base;
145 ent->HighWord.Bits.BaseMid = (BYTE)((unsigned long)base >> 16);
146 ent->HighWord.Bits.BaseHi = (BYTE)((unsigned long)base >> 24);
147}
148static inline void wine_ldt_set_limit( LDT_ENTRY *ent, unsigned int limit )
149{
150 if ((ent->HighWord.Bits.Granularity = (limit >= 0x100000))) limit >>= 12;
151 ent->LimitLow = (WORD)limit;
152 ent->HighWord.Bits.LimitHi = (limit >> 16);
153}
154static inline void *wine_ldt_get_base( const LDT_ENTRY *ent )
155{
156 return (void *)(ent->BaseLow |
157 (unsigned long)ent->HighWord.Bits.BaseMid << 16 |
158 (unsigned long)ent->HighWord.Bits.BaseHi << 24);
159}
160static inline unsigned int wine_ldt_get_limit( const LDT_ENTRY *ent )
161{
162 unsigned int limit = ent->LimitLow | (ent->HighWord.Bits.LimitHi << 16);
163 if (ent->HighWord.Bits.Granularity) limit = (limit << 12) | 0xfff;
164 return limit;
165}
166static inline void wine_ldt_set_flags( LDT_ENTRY *ent, unsigned char flags )
167{
168 ent->HighWord.Bits.Dpl = 3;
169 ent->HighWord.Bits.Pres = 1;
170 ent->HighWord.Bits.Type = flags;
171 ent->HighWord.Bits.Sys = 0;
172 ent->HighWord.Bits.Reserved_0 = 0;
173 ent->HighWord.Bits.Default_Big = (flags & WINE_LDT_FLAGS_32BIT) != 0;
174}
175static inline unsigned char wine_ldt_get_flags( const LDT_ENTRY *ent )
176{
177 unsigned char ret = ent->HighWord.Bits.Type;
178 if (ent->HighWord.Bits.Default_Big) ret |= WINE_LDT_FLAGS_32BIT;
179 return ret;
180}
181static inline int wine_ldt_is_empty( const LDT_ENTRY *ent )
182{
183 const DWORD *dw = (const DWORD *)ent;
184 return (dw[0] | dw[1]) == 0;
185}
186
187/* segment register access */
188
189#ifdef __i386__
190# ifdef __MINGW32__
191# define __DEFINE_GET_SEG(seg) \
192 static inline unsigned short wine_get_##seg(void); \
193 static inline unsigned short wine_get_##seg(void) \
194 { unsigned short res; __asm__ __volatile__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
195# define __DEFINE_SET_SEG(seg) \
196 static inline void wine_set_##seg(int val); \
197 static inline void wine_set_##seg(int val) { __asm__("movw %w0,%%" #seg : : "r" (val)); }
198# elif defined(__GNUC__)
199# define __DEFINE_GET_SEG(seg) \
200 extern inline unsigned short wine_get_##seg(void); \
201 extern inline unsigned short wine_get_##seg(void) \
202 { unsigned short res; __asm__ __volatile__("movw %%" #seg ",%w0" : "=r"(res)); return res; }
203# define __DEFINE_SET_SEG(seg) \
204 extern inline void wine_set_##seg(int val); \
205 extern inline void wine_set_##seg(int val) { __asm__("movw %w0,%%" #seg : : "r" (val)); }
206# elif defined(_MSC_VER)
207# define __DEFINE_GET_SEG(seg) \
208 extern inline unsigned short wine_get_##seg(void); \
209 extern inline unsigned short wine_get_##seg(void) \
210 { unsigned short res; __asm { mov res, seg } return res; }
211# define __DEFINE_SET_SEG(seg) \
212 extern inline void wine_set_##seg(unsigned short val); \
213 extern inline void wine_set_##seg(unsigned short val) { __asm { mov seg, val } }
214# else /* __GNUC__ || _MSC_VER */
215# define __DEFINE_GET_SEG(seg) extern unsigned short wine_get_##seg(void);
216# define __DEFINE_SET_SEG(seg) extern void wine_set_##seg(unsigned int);
217# endif /* __GNUC__ || _MSC_VER */
218#else /* __i386__ */
219# define __DEFINE_GET_SEG(seg) static inline unsigned short wine_get_##seg(void) { return 0; }
220# define __DEFINE_SET_SEG(seg) static inline void wine_set_##seg(int val) { /* nothing */ }
221#endif /* __i386__ */
222
223__DEFINE_GET_SEG(cs)
224__DEFINE_GET_SEG(ds)
225__DEFINE_GET_SEG(es)
226__DEFINE_GET_SEG(fs)
227__DEFINE_GET_SEG(gs)
228__DEFINE_GET_SEG(ss)
229__DEFINE_SET_SEG(fs)
230__DEFINE_SET_SEG(gs)
231#undef __DEFINE_GET_SEG
232#undef __DEFINE_SET_SEG
233
234#ifdef __cplusplus
235}
236#endif
237
238#endif /* __WINE_WINE_LIBRARY_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette