annotate loader/wine/ldt.h @ 36660:7fd255e0db1b

stream.c: remove pointless NULL check. Since it currently is a fixed-size array it can never be NULL. But even if this was changed, this check has no real value: it should still only be possible in case of an obvious code bug during development and the crash it would cause would be easy enough to debug.
author reimar
date Sun, 26 Jan 2014 18:59:15 +0000
parents 26f673ba0675
children
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;
28051
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
29 void LDT_BytesToEntry( const unsigned long *buffer, ldt_entry *content );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
30 void LDT_EntryToBytes( unsigned long *buffer, const ldt_entry *content );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
31 int LDT_GetEntry( int entry, ldt_entry *content );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
32 int LDT_SetEntry( int entry, const ldt_entry *content );
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 26045
diff changeset
33 void LDT_Print( int start, int length );
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
34
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
35
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
36 /* This structure is used to build the local copy of the LDT. */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
37 typedef struct
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
38 {
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
39 unsigned long base; /* base address or 0 if entry is free */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
40 unsigned long limit; /* limit in bytes or 0 if entry is free */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
41 } ldt_copy_entry;
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
42
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
43 #define LDT_SIZE 8192
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
44
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
45 extern ldt_copy_entry ldt_copy[LDT_SIZE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
46
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24422
diff changeset
47 #define AHSHIFT 3 /* don't change! */
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24422
diff changeset
48 #define AHINCR (1 << AHSHIFT)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
49
25794
2c8cdb9123b8 Fix a ton of illegal identifiers. Identifiers starting with __ or _ and a
diego
parents: 24422
diff changeset
50 #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
51 #define ENTRY_TO_SELECTOR(i) ((i) ? (((int)(i) << AHSHIFT) | 7) : 0)
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
52 #define IS_LDT_ENTRY_FREE(i) (!(ldt_flags_copy[(i)] & LDT_FLAGS_ALLOCATED))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
53 #define IS_SELECTOR_FREE(sel) (IS_LDT_ENTRY_FREE(SELECTOR_TO_ENTRY(sel)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
54 #define GET_SEL_BASE(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].base)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
55 #define GET_SEL_LIMIT(sel) (ldt_copy[SELECTOR_TO_ENTRY(sel)].limit)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
56
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
57 /* Convert a segmented ptr (16:16) to a linear (32) pointer */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
58
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
59 #define PTR_SEG_OFF_TO_LIN(seg,off) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
60 ((void*)(GET_SEL_BASE(seg) + (unsigned int)(off)))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
61 #define PTR_SEG_TO_LIN(ptr) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
62 PTR_SEG_OFF_TO_LIN(SELECTOROF(ptr),OFFSETOF(ptr))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
63 #define PTR_SEG_OFF_TO_SEGPTR(seg,off) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
64 ((SEGPTR)MAKELONG(off,seg))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
65 #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
66 PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << AHSHIFT), LOWORD(off) )
1
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
67
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
68 #define W32S_APPLICATION() (PROCESS_Current()->flags & PDB32_WIN32S_PROC)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
69 #define W32S_OFFSET 0x10000
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
70 #define W32S_APP2WINE(addr, offset) ((addr)? (DWORD)(addr) + (DWORD)(offset) : 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
71 #define W32S_WINE2APP(addr, offset) ((addr)? (DWORD)(addr) - (DWORD)(offset) : 0)
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
72
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
73 extern unsigned char ldt_flags_copy[LDT_SIZE];
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
74
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
75 #define LDT_FLAGS_TYPE 0x03 /* Mask for segment type */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
76 #define LDT_FLAGS_READONLY 0x04 /* Segment is read-only (data) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
77 #define LDT_FLAGS_EXECONLY 0x04 /* Segment is execute-only (code) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
78 #define LDT_FLAGS_32BIT 0x08 /* Segment is 32-bit (code or stack) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
79 #define LDT_FLAGS_BIG 0x10 /* Segment is big (limit is in pages) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
80 #define LDT_FLAGS_ALLOCATED 0x80 /* Segment is allocated (no longer free) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
81
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
82 #define GET_SEL_FLAGS(sel) (ldt_flags_copy[SELECTOR_TO_ENTRY(sel)])
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
83
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
84 #define FIRST_LDT_ENTRY_TO_ALLOC 17
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
85
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
86 /* Determine if sel is a system selector (i.e. not managed by Wine) */
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
87 #define IS_SELECTOR_SYSTEM(sel) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
88 (!((sel) & 4) || (SELECTOR_TO_ENTRY(sel) < FIRST_LDT_ENTRY_TO_ALLOC))
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
89 #define IS_SELECTOR_32BIT(sel) \
3b5f5d1c5041 Initial revision
arpi_esp
parents:
diff changeset
90 (IS_SELECTOR_SYSTEM(sel) || (GET_SEL_FLAGS(sel) & LDT_FLAGS_32BIT))
26045
a8ea87c71d18 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25794
diff changeset
91
a8ea87c71d18 Add MPLAYER_ prefix to multiple inclusion guards.
diego
parents: 25794
diff changeset
92 #endif /* MPLAYER_LDT_H */