Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
5cb5aa63
Commit
5cb5aa63
authored
Oct 09, 2003
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the Rtl bitmap functions to implement Tls allocation.
Get rid of the PDB structure.
parent
30b58895
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
113 deletions
+45
-113
process.c
dlls/kernel/process.c
+23
-97
thread.c
dlls/ntdll/thread.c
+4
-1
winternl.h
include/winternl.h
+18
-15
No files found.
dlls/kernel/process.c
View file @
5cb5aa63
...
@@ -46,57 +46,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(process);
...
@@ -46,57 +46,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(process);
WINE_DECLARE_DEBUG_CHANNEL
(
server
);
WINE_DECLARE_DEBUG_CHANNEL
(
server
);
WINE_DECLARE_DEBUG_CHANNEL
(
relay
);
WINE_DECLARE_DEBUG_CHANNEL
(
relay
);
/* Win32 process database */
static
UINT
process_error_mode
;
typedef
struct
_PDB
{
LONG
header
[
2
];
/* 00 Kernel object header */
HMODULE
module
;
/* 08 Main exe module (NT) */
PPEB_LDR_DATA
LdrData
;
/* 0c Pointer to loader information */
RTL_USER_PROCESS_PARAMETERS
*
ProcessParameters
;
/* 10 Process parameters */
DWORD
unknown2
;
/* 14 Unknown */
HANDLE
heap
;
/* 18 Default process heap */
HANDLE
mem_context
;
/* 1c Process memory context */
DWORD
flags
;
/* 20 Flags */
void
*
pdb16
;
/* 24 DOS PSP */
WORD
PSP_sel
;
/* 28 Selector to DOS PSP */
WORD
imte
;
/* 2a IMTE for the process module */
WORD
threads
;
/* 2c Number of threads */
WORD
running_threads
;
/* 2e Number of running threads */
WORD
free_lib_count
;
/* 30 Recursion depth of FreeLibrary calls */
WORD
ring0_threads
;
/* 32 Number of ring 0 threads */
HANDLE
system_heap
;
/* 34 System heap to allocate handles */
HTASK
task
;
/* 38 Win16 task */
void
*
mem_map_files
;
/* 3c Pointer to mem-mapped files */
struct
_ENVDB
*
env_db
;
/* 40 Environment database */
void
*
handle_table
;
/* 44 Handle table */
struct
_PDB
*
parent
;
/* 48 Parent process */
void
*
modref_list
;
/* 4c MODREF list */
void
*
thread_list
;
/* 50 List of threads */
void
*
debuggee_CB
;
/* 54 Debuggee context block */
void
*
local_heap_free
;
/* 58 Head of local heap free list */
DWORD
unknown4
;
/* 5c Unknown */
CRITICAL_SECTION
crit_section
;
/* 60 Critical section */
DWORD
unknown5
[
3
];
/* 78 Unknown */
void
*
console
;
/* 84 Console */
DWORD
tls_bits
[
2
];
/* 88 TLS in-use bits */
DWORD
process_dword
;
/* 90 Unknown */
struct
_PDB
*
group
;
/* 94 Process group */
void
*
exe_modref
;
/* 98 MODREF for the process EXE */
void
*
top_filter
;
/* 9c Top exception filter */
DWORD
priority
;
/* a0 Priority level */
HANDLE
heap_list
;
/* a4 Head of process heap list */
void
*
heap_handles
;
/* a8 Head of heap handles list */
DWORD
unknown6
;
/* ac Unknown */
void
*
console_provider
;
/* b0 Console provider (??) */
WORD
env_selector
;
/* b4 Selector to process environment */
WORD
error_mode
;
/* b6 Error mode */
HANDLE
load_done_evt
;
/* b8 Event for process loading done */
void
*
UTState
;
/* bc Head of Univeral Thunk list */
DWORD
unknown8
;
/* c0 Unknown (NT) */
LCID
locale
;
/* c4 Locale to be queried by GetThreadLocale (NT) */
}
PDB
;
static
PDB
*
current_process
;
static
HANDLE
main_exe_file
;
static
HANDLE
main_exe_file
;
static
DWORD
shutdown_flags
=
0
;
static
DWORD
shutdown_flags
=
0
;
...
@@ -661,21 +611,13 @@ static BOOL process_init( char *argv[] )
...
@@ -661,21 +611,13 @@ static BOOL process_init( char *argv[] )
BOOL
ret
;
BOOL
ret
;
size_t
info_size
=
0
;
size_t
info_size
=
0
;
RTL_USER_PROCESS_PARAMETERS
*
params
;
RTL_USER_PROCESS_PARAMETERS
*
params
;
PEB
*
peb
=
NtCurrentTeb
()
->
Peb
;
HANDLE
hstdin
,
hstdout
,
hstderr
;
HANDLE
hstdin
,
hstdout
,
hstderr
;
setbuf
(
stdout
,
NULL
);
setbuf
(
stdout
,
NULL
);
setbuf
(
stderr
,
NULL
);
setbuf
(
stderr
,
NULL
);
setlocale
(
LC_CTYPE
,
""
);
setlocale
(
LC_CTYPE
,
""
);
/* Fill the initial process structure */
current_process
=
(
PDB
*
)
NtCurrentTeb
()
->
Peb
;
/* FIXME: should be a PEB */
params
=
current_process
->
ProcessParameters
;
current_process
->
threads
=
1
;
current_process
->
running_threads
=
1
;
current_process
->
ring0_threads
=
1
;
current_process
->
group
=
current_process
;
current_process
->
priority
=
8
;
/* Normal */
/* Setup the server connection */
/* Setup the server connection */
wine_server_init_thread
();
wine_server_init_thread
();
...
@@ -698,10 +640,12 @@ static BOOL process_init( char *argv[] )
...
@@ -698,10 +640,12 @@ static BOOL process_init( char *argv[] )
if
(
!
ret
)
return
FALSE
;
if
(
!
ret
)
return
FALSE
;
/* Create the process heap */
/* Create the process heap */
current_process
->
h
eap
=
RtlCreateHeap
(
HEAP_GROWABLE
,
NULL
,
0
,
0
,
NULL
,
NULL
);
peb
->
ProcessH
eap
=
RtlCreateHeap
(
HEAP_GROWABLE
,
NULL
,
0
,
0
,
NULL
,
NULL
);
if
(
info_size
==
0
)
if
(
info_size
==
0
)
{
{
params
=
peb
->
ProcessParameters
;
/* This is wine specific: we have no parent (we're started from unix)
/* This is wine specific: we have no parent (we're started from unix)
* so, create a simple console with bare handles to unix stdio
* so, create a simple console with bare handles to unix stdio
* input & output streams (aka simple console)
* input & output streams (aka simple console)
...
@@ -723,7 +667,7 @@ static BOOL process_init( char *argv[] )
...
@@ -723,7 +667,7 @@ static BOOL process_init( char *argv[] )
else
else
{
{
if
(
!
(
params
=
init_user_process_params
(
info_size
)))
return
FALSE
;
if
(
!
(
params
=
init_user_process_params
(
info_size
)))
return
FALSE
;
current_process
->
ProcessParameters
=
params
;
peb
->
ProcessParameters
=
params
;
/* convert value from server:
/* convert value from server:
* + 0 => INVALID_HANDLE_VALUE
* + 0 => INVALID_HANDLE_VALUE
...
@@ -1942,8 +1886,8 @@ BOOL WINAPI GetExitCodeProcess(
...
@@ -1942,8 +1886,8 @@ BOOL WINAPI GetExitCodeProcess(
*/
*/
UINT
WINAPI
SetErrorMode
(
UINT
mode
)
UINT
WINAPI
SetErrorMode
(
UINT
mode
)
{
{
UINT
old
=
current_process
->
error_mode
;
UINT
old
=
process_
error_mode
;
current_process
->
error_mode
=
mode
;
process_
error_mode
=
mode
;
return
old
;
return
old
;
}
}
...
@@ -1959,25 +1903,14 @@ UINT WINAPI SetErrorMode( UINT mode )
...
@@ -1959,25 +1903,14 @@ UINT WINAPI SetErrorMode( UINT mode )
*/
*/
DWORD
WINAPI
TlsAlloc
(
void
)
DWORD
WINAPI
TlsAlloc
(
void
)
{
{
DWORD
i
,
mask
,
ret
=
0
;
DWORD
i
ndex
;
DWORD
*
bits
=
current_process
->
tls_bits
;
RtlAcquirePebLock
();
RtlAcquirePebLock
();
if
(
*
bits
==
0xffffffff
)
index
=
RtlFindClearBitsAndSet
(
NtCurrentTeb
()
->
Peb
->
TlsBitmap
,
1
,
0
);
{
if
(
index
!=
~
0UL
)
NtCurrentTeb
()
->
TlsSlots
[
index
]
=
0
;
/* clear the value */
bits
++
;
else
SetLastError
(
ERROR_NO_MORE_ITEMS
);
ret
=
32
;
if
(
*
bits
==
0xffffffff
)
{
RtlReleasePebLock
();
SetLastError
(
ERROR_NO_MORE_ITEMS
);
return
0xffffffff
;
}
}
for
(
i
=
0
,
mask
=
1
;
i
<
32
;
i
++
,
mask
<<=
1
)
if
(
!
(
*
bits
&
mask
))
break
;
*
bits
|=
mask
;
RtlReleasePebLock
();
RtlReleasePebLock
();
NtCurrentTeb
()
->
TlsSlots
[
ret
+
i
]
=
0
;
/* clear the value */
return
index
;
return
ret
+
i
;
}
}
...
@@ -1993,23 +1926,16 @@ DWORD WINAPI TlsAlloc( void )
...
@@ -1993,23 +1926,16 @@ DWORD WINAPI TlsAlloc( void )
BOOL
WINAPI
TlsFree
(
BOOL
WINAPI
TlsFree
(
DWORD
index
)
/* [in] TLS Index to free */
DWORD
index
)
/* [in] TLS Index to free */
{
{
DWORD
mask
=
(
1
<<
(
index
&
31
));
BOOL
ret
;
DWORD
*
bits
=
current_process
->
tls_bits
;
if
(
index
>=
64
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
index
>=
32
)
bits
++
;
RtlAcquirePebLock
();
RtlAcquirePebLock
();
if
(
!
(
*
bits
&
mask
))
/* already free? */
ret
=
RtlAreBitsSet
(
NtCurrentTeb
()
->
Peb
->
TlsBitmap
,
index
,
1
);
if
(
ret
)
{
{
RtlReleasePebLock
();
RtlClearBits
(
NtCurrentTeb
()
->
Peb
->
TlsBitmap
,
index
,
1
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
NtSetInformationThread
(
GetCurrentThread
(),
ThreadZeroTlsCell
,
&
index
,
sizeof
(
index
)
);
return
FALSE
;
}
}
*
bits
&=
~
mask
;
else
SetLastError
(
ERROR_INVALID_PARAMETER
);
NtSetInformationThread
(
GetCurrentThread
(),
ThreadZeroTlsCell
,
&
index
,
sizeof
(
index
)
);
RtlReleasePebLock
();
RtlReleasePebLock
();
return
TRUE
;
return
TRUE
;
}
}
...
@@ -2025,7 +1951,7 @@ BOOL WINAPI TlsFree(
...
@@ -2025,7 +1951,7 @@ BOOL WINAPI TlsFree(
LPVOID
WINAPI
TlsGetValue
(
LPVOID
WINAPI
TlsGetValue
(
DWORD
index
)
/* [in] TLS index to retrieve value for */
DWORD
index
)
/* [in] TLS index to retrieve value for */
{
{
if
(
index
>=
64
)
if
(
index
>=
NtCurrentTeb
()
->
Peb
->
TlsBitmap
->
SizeOfBitMap
)
{
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
return
NULL
;
...
@@ -2046,7 +1972,7 @@ BOOL WINAPI TlsSetValue(
...
@@ -2046,7 +1972,7 @@ BOOL WINAPI TlsSetValue(
DWORD
index
,
/* [in] TLS index to set value for */
DWORD
index
,
/* [in] TLS index to set value for */
LPVOID
value
)
/* [in] Value to be stored */
LPVOID
value
)
/* [in] Value to be stored */
{
{
if
(
index
>=
64
)
if
(
index
>=
NtCurrentTeb
()
->
Peb
->
TlsBitmap
->
SizeOfBitMap
)
{
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
return
FALSE
;
...
...
dlls/ntdll/thread.c
View file @
5cb5aa63
...
@@ -44,6 +44,7 @@ DECL_GLOBAL_CONSTRUCTOR(thread_init)
...
@@ -44,6 +44,7 @@ DECL_GLOBAL_CONSTRUCTOR(thread_init)
static
PEB
peb
;
static
PEB
peb
;
static
PEB_LDR_DATA
ldr
;
static
PEB_LDR_DATA
ldr
;
static
RTL_USER_PROCESS_PARAMETERS
params
;
/* default parameters if no parent */
static
RTL_USER_PROCESS_PARAMETERS
params
;
/* default parameters if no parent */
static
RTL_BITMAP
tls_bitmap
;
static
struct
debug_info
info
;
/* debug info for initial thread */
static
struct
debug_info
info
;
/* debug info for initial thread */
if
(
teb
.
Tib
.
Self
)
return
;
/* do it only once */
if
(
teb
.
Tib
.
Self
)
return
;
/* do it only once */
...
@@ -67,7 +68,9 @@ DECL_GLOBAL_CONSTRUCTOR(thread_init)
...
@@ -67,7 +68,9 @@ DECL_GLOBAL_CONSTRUCTOR(thread_init)
InitializeListHead
(
&
teb
.
TlsLinks
);
InitializeListHead
(
&
teb
.
TlsLinks
);
peb
.
ProcessParameters
=
&
params
;
peb
.
ProcessParameters
=
&
params
;
peb
.
LdrData
=
&
ldr
;
peb
.
TlsBitmap
=
&
tls_bitmap
;
peb
.
LdrData
=
&
ldr
;
RtlInitializeBitMap
(
&
tls_bitmap
,
(
BYTE
*
)
peb
.
TlsBitmapBits
,
sizeof
(
peb
.
TlsBitmapBits
)
*
8
);
InitializeListHead
(
&
ldr
.
InLoadOrderModuleList
);
InitializeListHead
(
&
ldr
.
InLoadOrderModuleList
);
InitializeListHead
(
&
ldr
.
InMemoryOrderModuleList
);
InitializeListHead
(
&
ldr
.
InMemoryOrderModuleList
);
InitializeListHead
(
&
ldr
.
InInitializationOrderModuleList
);
InitializeListHead
(
&
ldr
.
InInitializationOrderModuleList
);
...
...
include/winternl.h
View file @
5cb5aa63
...
@@ -81,6 +81,20 @@ typedef struct RTL_DRIVE_LETTER_CURDIR
...
@@ -81,6 +81,20 @@ typedef struct RTL_DRIVE_LETTER_CURDIR
UNICODE_STRING
DosPath
;
UNICODE_STRING
DosPath
;
}
RTL_DRIVE_LETTER_CURDIR
,
*
PRTL_DRIVE_LETTER_CURDIR
;
}
RTL_DRIVE_LETTER_CURDIR
,
*
PRTL_DRIVE_LETTER_CURDIR
;
typedef
struct
tagRTL_BITMAP
{
ULONG
SizeOfBitMap
;
/* Number of bits in the bitmap */
LPBYTE
BitMapBuffer
;
/* Bitmap data, assumed sized to a DWORD boundary */
}
RTL_BITMAP
,
*
PRTL_BITMAP
;
typedef
const
RTL_BITMAP
*
PCRTL_BITMAP
;
typedef
struct
tagRTL_BITMAP_RUN
{
ULONG
StartOfRun
;
/* Bit position at which run starts - FIXME: Name? */
ULONG
SizeOfRun
;
/* Size of the run in bits - FIXME: Name? */
}
RTL_BITMAP_RUN
,
*
PRTL_BITMAP_RUN
;
typedef
const
RTL_BITMAP_RUN
*
PCRTL_BITMAP_RUN
;
typedef
struct
_RTL_USER_PROCESS_PARAMETERS
typedef
struct
_RTL_USER_PROCESS_PARAMETERS
{
{
ULONG
AllocationSize
;
ULONG
AllocationSize
;
...
@@ -140,7 +154,10 @@ typedef struct _PEB
...
@@ -140,7 +154,10 @@ typedef struct _PEB
RTL_USER_PROCESS_PARAMETERS
*
ProcessParameters
;
/* 10 */
RTL_USER_PROCESS_PARAMETERS
*
ProcessParameters
;
/* 10 */
PVOID
__pad_14
;
/* 14 */
PVOID
__pad_14
;
/* 14 */
HANDLE
ProcessHeap
;
/* 18 */
HANDLE
ProcessHeap
;
/* 18 */
BYTE
__pad_1c
[
204
];
/* 1c */
BYTE
__pad_1c
[
36
];
/* 1c */
PRTL_BITMAP
TlsBitmap
;
/* 40 */
ULONG
TlsBitmapBits
[
2
];
/* 44 */
BYTE
__pad_4c
[
156
];
/* 4c */
PVOID
Reserved3
[
59
];
/* e8 */
PVOID
Reserved3
[
59
];
/* e8 */
ULONG
SessionId
;
/* 1d4 */
ULONG
SessionId
;
/* 1d4 */
}
PEB
,
*
PPEB
;
}
PEB
,
*
PPEB
;
...
@@ -652,20 +669,6 @@ typedef struct _RTL_HEAP_DEFINITION {
...
@@ -652,20 +669,6 @@ typedef struct _RTL_HEAP_DEFINITION {
ULONG
Unknown
[
11
];
ULONG
Unknown
[
11
];
}
RTL_HEAP_DEFINITION
,
*
PRTL_HEAP_DEFINITION
;
}
RTL_HEAP_DEFINITION
,
*
PRTL_HEAP_DEFINITION
;
typedef
struct
tagRTL_BITMAP
{
ULONG
SizeOfBitMap
;
/* Number of bits in the bitmap */
LPBYTE
BitMapBuffer
;
/* Bitmap data, assumed sized to a DWORD boundary */
}
RTL_BITMAP
,
*
PRTL_BITMAP
;
typedef
const
RTL_BITMAP
*
PCRTL_BITMAP
;
typedef
struct
tagRTL_BITMAP_RUN
{
ULONG
StartOfRun
;
/* Bit position at which run starts - FIXME: Name? */
ULONG
SizeOfRun
;
/* Size of the run in bits - FIXME: Name? */
}
RTL_BITMAP_RUN
,
*
PRTL_BITMAP_RUN
;
typedef
const
RTL_BITMAP_RUN
*
PCRTL_BITMAP_RUN
;
typedef
struct
_RTL_RWLOCK
{
typedef
struct
_RTL_RWLOCK
{
RTL_CRITICAL_SECTION
rtlCS
;
RTL_CRITICAL_SECTION
rtlCS
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment