annotate loader/wine/ldt.h @ 29802:c2e91cf65729

Document sws_freeContext().
author stefano
date Sat, 07 Nov 2009 09:23:11 +0000
parents 0f1b5b68af32
children 26f673ba0675
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
1 /*
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
2 * LDT copy
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
3 *
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
4 * Copyright 1995 Alexandre Julliard
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
5 */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
6
26045
a8ea87c71d18 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25794
diff changeset
7 #ifndef MPLAYER_LDT_H
a8ea87c71d18 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25794
diff changeset
8 #define MPLAYER_LDT_H
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
9
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
10 #include "windef.h"
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
11 enum seg_type
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
12 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
13 SEGMENT_DATA = 0,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
14 SEGMENT_STACK = 1,
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
15 SEGMENT_CODE = 2
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
16 };
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
17
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
18 /* This structure represents a real LDT entry. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
19 /* It is used by get_ldt_entry() and set_ldt_entry(). */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
20 typedef struct
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
21 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
22 unsigned long base; /* base address */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
23 unsigned long limit; /* segment limit (in pages or bytes) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
24 int seg_32bit; /* is segment 32-bit? */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
25 int read_only; /* is segment read-only? */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
26 int limit_in_pages; /* is the limit in pages or bytes? */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
27 enum seg_type type; /* segment type */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
28 } ldt_entry;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
29 #ifdef __cplusplus
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
30 extern "C"
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
31 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
32 #endif
28051
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
33 void LDT_BytesToEntry( const unsigned long *buffer, ldt_entry *content );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
34 void LDT_EntryToBytes( unsigned long *buffer, const ldt_entry *content );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
35 int LDT_GetEntry( int entry, ldt_entry *content );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
36 int LDT_SetEntry( int entry, const ldt_entry *content );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
37 void LDT_Print( int start, int length );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 /* This structure is used to build the local copy of the LDT. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 typedef struct
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 unsigned long base; /* base address or 0 if entry is free */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44 unsigned long limit; /* limit in bytes or 0 if entry is free */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 } ldt_copy_entry;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
47 #define LDT_SIZE 8192
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
48
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49 extern ldt_copy_entry ldt_copy[LDT_SIZE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
50
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24422
diff changeset
51 #define AHSHIFT 3 /* don't change! */
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24422
diff changeset
52 #define AHINCR (1 << AHSHIFT)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24422
diff changeset
54 #define SELECTOR_TO_ENTRY(sel) (((int)(sel) & 0xffff) >> AHSHIFT)
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24422
diff changeset
55 #define ENTRY_TO_SELECTOR(i) ((i) ? (((int)(i) << AHSHIFT) | 7) : 0)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56 #define IS_LDT_ENTRY_FREE(i) (!(ldt_flags_copy[(i)] & LDT_FLAGS_ALLOCATED))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 #define IS_SELECTOR_FREE(sel) (IS_LDT_ENTRY_FREE(SELECTOR_TO_ENTRY(sel)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58 #define GET_SEL_BASE(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].base)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 #define GET_SEL_LIMIT(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].limit)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 /* Convert a segmented ptr (16:16) to a linear (32) pointer */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 #define PTR_SEG_OFF_TO_LIN(seg,off) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 ((void*)(GET_SEL_BASE(seg) + (unsigned int)(off)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 #define PTR_SEG_TO_LIN(ptr) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
66 PTR_SEG_OFF_TO_LIN(SELECTOROF(ptr),OFFSETOF(ptr))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67 #define PTR_SEG_OFF_TO_SEGPTR(seg,off) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 ((SEGPTR)MAKELONG(off,seg))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 #define PTR_SEG_OFF_TO_HUGEPTR(seg,off) \
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24422
diff changeset
70 PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << AHSHIFT), LOWORD(off) )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72 #define W32S_APPLICATION() (PROCESS_Current()->flags & PDB32_WIN32S_PROC)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 #define W32S_OFFSET 0x10000
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74 #define W32S_APP2WINE(addr, offset) ((addr)? (DWORD)(addr) + (DWORD)(offset) : 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 #define W32S_WINE2APP(addr, offset) ((addr)? (DWORD)(addr) - (DWORD)(offset) : 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 extern unsigned char ldt_flags_copy[LDT_SIZE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 #define LDT_FLAGS_TYPE 0x03 /* Mask for segment type */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 #define LDT_FLAGS_READONLY 0x04 /* Segment is read-only (data) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81 #define LDT_FLAGS_EXECONLY 0x04 /* Segment is execute-only (code) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 #define LDT_FLAGS_32BIT 0x08 /* Segment is 32-bit (code or stack) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83 #define LDT_FLAGS_BIG 0x10 /* Segment is big (limit is in pages) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 #define LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 #define GET_SEL_FLAGS(sel) (ldt_flags_copy[SELECTOR_TO_ENTRY(sel)])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 #define FIRST_LDT_ENTRY_TO_ALLOC 17
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 /* Determine if sel is a system selector (i.e. not managed by Wine) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
91 #define IS_SELECTOR_SYSTEM(sel) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
92 (!((sel) & 4) || (SELECTOR_TO_ENTRY(sel) < FIRST_LDT_ENTRY_TO_ALLOC))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
93 #define IS_SELECTOR_32BIT(sel) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
94 (IS_SELECTOR_SYSTEM(sel) || (GET_SEL_FLAGS(sel) & LDT_FLAGS_32BIT))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
95 #ifdef __cplusplus
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
96 }
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
97 #endif
26045
a8ea87c71d18 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25794
diff changeset
98
a8ea87c71d18 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25794
diff changeset
99 #endif /* MPLAYER_LDT_H */