Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
e92b7eed
Commit
e92b7eed
authored
Feb 12, 2004
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store the kernel32 module handle globally to avoid some
GetModuleHandle calls that can cause deadlocks with the loader section. Moved some 16-bit definitions out of kernel_private.h.
parent
a4d1826c
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
35 additions
and
32 deletions
+35
-32
dosmem.c
dlls/kernel/dosmem.c
+1
-0
format_msg.c
dlls/kernel/format_msg.c
+3
-3
kernel_main.c
dlls/kernel/kernel_main.c
+1
-0
kernel_private.h
dlls/kernel/kernel_private.h
+2
-6
locale.c
dlls/kernel/locale.c
+11
-17
ne_segment.c
dlls/kernel/ne_segment.c
+1
-0
process.c
dlls/kernel/process.c
+4
-0
thunk.c
dlls/kernel/thunk.c
+5
-6
toolhelp.h
dlls/kernel/toolhelp.h
+7
-0
No files found.
dlls/kernel/dosmem.c
View file @
e92b7eed
...
...
@@ -41,6 +41,7 @@
#include "wine/winbase16.h"
#include "kernel_private.h"
#include "toolhelp.h"
#include "miscemu.h"
#include "wine/debug.h"
...
...
dlls/kernel/format_msg.c
View file @
e92b7eed
...
...
@@ -33,7 +33,7 @@
#include "winuser.h"
#include "winnls.h"
#include "wine/unicode.h"
#include "kernel_private.h"
#include "heap.h"
#include "wine/debug.h"
...
...
@@ -172,7 +172,7 @@ DWORD WINAPI FormatMessageA(
}
if
((
dwFlags
&
FORMAT_MESSAGE_FROM_SYSTEM
)
&&
(
!
bufsize
))
{
hmodule
=
GetModuleHandleA
(
"kernel32"
)
;
hmodule
=
kernel32_handle
;
bufsize
=
load_messageA
(
hmodule
,
dwMessageId
,
dwLanguageId
,
NULL
,
100
);
}
...
...
@@ -399,7 +399,7 @@ DWORD WINAPI FormatMessageW(
}
if
((
dwFlags
&
FORMAT_MESSAGE_FROM_SYSTEM
)
&&
(
!
bufsize
))
{
hmodule
=
GetModuleHandleA
(
"kernel32"
)
;
hmodule
=
kernel32_handle
;
bufsize
=
load_messageA
(
hmodule
,
dwMessageId
,
dwLanguageId
,
NULL
,
100
);
}
...
...
dlls/kernel/kernel_main.c
View file @
e92b7eed
...
...
@@ -42,6 +42,7 @@
#include "thread.h"
#include "stackframe.h"
#include "wincon.h"
#include "toolhelp.h"
#include "kernel_private.h"
#include "console_private.h"
...
...
dlls/kernel/kernel_private.h
View file @
e92b7eed
...
...
@@ -44,6 +44,8 @@ static inline HANDLE console_handle_unmap(HANDLE h)
return
h
!=
INVALID_HANDLE_VALUE
?
(
HANDLE
)((
DWORD
)
h
^
3
)
:
INVALID_HANDLE_VALUE
;
}
extern
HMODULE
kernel32_handle
;
/* Size of per-process table of DOS handles */
#define DOS_TABLE_SIZE 256
extern
HANDLE
dos_handles
[
DOS_TABLE_SIZE
];
...
...
@@ -65,12 +67,6 @@ extern void SELECTOR_FreeBlock( WORD sel );
#define IS_SELECTOR_32BIT(sel) \
(wine_ldt_is_system(sel) || (wine_ldt_copy.flags[LOWORD(sel) >> 3] & WINE_LDT_FLAGS_32BIT))
extern
HGLOBAL16
GLOBAL_CreateBlock
(
UINT16
flags
,
const
void
*
ptr
,
DWORD
size
,
HGLOBAL16
hOwner
,
unsigned
char
selflags
);
extern
BOOL16
GLOBAL_FreeBlock
(
HGLOBAL16
handle
);
extern
BOOL16
GLOBAL_MoveBlock
(
HGLOBAL16
handle
,
const
void
*
ptr
,
DWORD
size
);
extern
HGLOBAL16
GLOBAL_Alloc
(
WORD
flags
,
DWORD
size
,
HGLOBAL16
hOwner
,
unsigned
char
selflags
);
/* this structure is always located at offset 0 of the DGROUP segment */
#include "pshpack1.h"
typedef
struct
...
...
dlls/kernel/locale.c
View file @
e92b7eed
...
...
@@ -41,14 +41,13 @@
#include "winnls.h"
#include "winerror.h"
#include "thread.h"
#include "kernel_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
nls
);
#define LOCALE_LOCALEINFOFLAGSMASK (LOCALE_NOUSEROVERRIDE|LOCALE_USE_CP_ACP|LOCALE_RETURN_NUMBER)
static
const
WCHAR
kernel32W
[]
=
{
'K'
,
'E'
,
'R'
,
'N'
,
'E'
,
'L'
,
'3'
,
'2'
,
'\0'
};
/* current code pages */
static
const
union
cptable
*
ansi_cptable
;
static
const
union
cptable
*
oem_cptable
;
...
...
@@ -383,7 +382,6 @@ found:
static
LANGID
get_language_id
(
LPCSTR
Lang
,
LPCSTR
Country
,
LPCSTR
Charset
,
LPCSTR
Dialect
)
{
LANG_FIND_DATA
l_data
;
HMODULE
hKernel32
;
if
(
!
Lang
)
{
...
...
@@ -397,9 +395,7 @@ static LANGID get_language_id(LPCSTR Lang, LPCSTR Country, LPCSTR Charset, LPCST
if
(
Country
)
strcpynAtoW
(
l_data
.
country
,
Country
,
sizeof
(
l_data
.
country
));
else
l_data
.
country
[
0
]
=
0
;
hKernel32
=
GetModuleHandleW
(
kernel32W
);
EnumResourceLanguagesW
(
hKernel32
,
(
LPCWSTR
)
RT_STRING
,
(
LPCWSTR
)
LOCALE_ILANGUAGE
,
EnumResourceLanguagesW
(
kernel32_handle
,
(
LPCWSTR
)
RT_STRING
,
(
LPCWSTR
)
LOCALE_ILANGUAGE
,
find_language_id_proc
,
(
LPARAM
)
&
l_data
);
if
(
l_data
.
n_found
==
1
)
goto
END
;
...
...
@@ -410,7 +406,7 @@ static LANGID get_language_id(LPCSTR Lang, LPCSTR Country, LPCSTR Charset, LPCST
{
/* retry without country name */
l_data
.
country
[
0
]
=
0
;
EnumResourceLanguagesW
(
hKernel32
,
(
LPCWSTR
)
RT_STRING
,
(
LPCWSTR
)
LOCALE_ILANGUAGE
,
EnumResourceLanguagesW
(
kernel32_handle
,
(
LPCWSTR
)
RT_STRING
,
(
LPCWSTR
)
LOCALE_ILANGUAGE
,
find_language_id_proc
,
(
LONG
)
&
l_data
);
if
(
!
l_data
.
n_found
)
{
...
...
@@ -882,7 +878,6 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
LANGID
lang_id
;
HRSRC
hrsrc
;
HGLOBAL
hmem
;
HMODULE
hModule
;
INT
ret
;
UINT
lcflags
;
const
WCHAR
*
p
;
...
...
@@ -945,13 +940,13 @@ INT WINAPI GetLocaleInfoW( LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len )
if
(
SUBLANGID
(
lang_id
)
==
SUBLANG_NEUTRAL
)
lang_id
=
MAKELANGID
(
PRIMARYLANGID
(
lang_id
),
SUBLANG_DEFAULT
);
hModule
=
GetModuleHandleW
(
kernel32W
);
if
(
!
(
hrsrc
=
FindResourceExW
(
hModule
,
(
LPWSTR
)
RT_STRING
,
(
LPCWSTR
)((
lctype
>>
4
)
+
1
),
lang_id
)))
if
(
!
(
hrsrc
=
FindResourceExW
(
kernel32_handle
,
(
LPWSTR
)
RT_STRING
,
(
LPCWSTR
)((
lctype
>>
4
)
+
1
),
lang_id
)))
{
SetLastError
(
ERROR_INVALID_FLAGS
);
/* no such lctype */
return
0
;
}
if
(
!
(
hmem
=
LoadResource
(
hModu
le
,
hrsrc
)))
if
(
!
(
hmem
=
LoadResource
(
kernel32_hand
le
,
hrsrc
)))
return
0
;
p
=
LockResource
(
hmem
);
...
...
@@ -1675,7 +1670,7 @@ LCID WINAPI ConvertDefaultLocale( LCID lcid )
BOOL
WINAPI
IsValidLocale
(
LCID
lcid
,
DWORD
flags
)
{
/* check if language is registered in the kernel32 resources */
return
FindResourceExW
(
GetModuleHandleW
(
kernel32W
)
,
(
LPWSTR
)
RT_STRING
,
return
FindResourceExW
(
kernel32_handle
,
(
LPWSTR
)
RT_STRING
,
(
LPCWSTR
)
LOCALE_ILANGUAGE
,
LANGIDFROMLCID
(
lcid
))
!=
0
;
}
...
...
@@ -1716,7 +1711,7 @@ static BOOL CALLBACK enum_lang_proc_w( HMODULE hModule, LPCWSTR type,
BOOL
WINAPI
EnumSystemLocalesA
(
LOCALE_ENUMPROCA
lpfnLocaleEnum
,
DWORD
dwFlags
)
{
TRACE
(
"(%p,%08lx)
\n
"
,
lpfnLocaleEnum
,
dwFlags
);
EnumResourceLanguagesA
(
GetModuleHandleW
(
kernel32W
)
,
(
LPSTR
)
RT_STRING
,
EnumResourceLanguagesA
(
kernel32_handle
,
(
LPSTR
)
RT_STRING
,
(
LPCSTR
)
LOCALE_ILANGUAGE
,
enum_lang_proc_a
,
(
LONG
)
lpfnLocaleEnum
);
return
TRUE
;
...
...
@@ -1731,7 +1726,7 @@ BOOL WINAPI EnumSystemLocalesA( LOCALE_ENUMPROCA lpfnLocaleEnum, DWORD dwFlags )
BOOL
WINAPI
EnumSystemLocalesW
(
LOCALE_ENUMPROCW
lpfnLocaleEnum
,
DWORD
dwFlags
)
{
TRACE
(
"(%p,%08lx)
\n
"
,
lpfnLocaleEnum
,
dwFlags
);
EnumResourceLanguagesW
(
GetModuleHandleW
(
kernel32W
)
,
(
LPWSTR
)
RT_STRING
,
EnumResourceLanguagesW
(
kernel32_handle
,
(
LPWSTR
)
RT_STRING
,
(
LPCWSTR
)
LOCALE_ILANGUAGE
,
enum_lang_proc_w
,
(
LONG
)
lpfnLocaleEnum
);
return
TRUE
;
...
...
@@ -2548,7 +2543,6 @@ static BOOL NLS_RegGetDword(HKEY hKey, LPCWSTR szValueName, DWORD *lpVal)
static
BOOL
NLS_GetLanguageGroupName
(
LGRPID
lgrpid
,
LPWSTR
szName
,
ULONG
nameSize
)
{
HMODULE
hModule
=
GetModuleHandleW
(
kernel32W
);
LANGID
langId
;
LPCWSTR
szResourceName
=
(
LPCWSTR
)(((
lgrpid
+
0x2000
)
>>
4
)
+
1
);
HRSRC
hResource
;
...
...
@@ -2560,11 +2554,11 @@ static BOOL NLS_GetLanguageGroupName(LGRPID lgrpid, LPWSTR szName, ULONG nameSiz
if
(
SUBLANGID
(
langId
)
==
SUBLANG_NEUTRAL
)
langId
=
MAKELANGID
(
PRIMARYLANGID
(
langId
),
SUBLANG_DEFAULT
);
hResource
=
FindResourceExW
(
hModu
le
,
(
LPWSTR
)
RT_STRING
,
szResourceName
,
langId
);
hResource
=
FindResourceExW
(
kernel32_hand
le
,
(
LPWSTR
)
RT_STRING
,
szResourceName
,
langId
);
if
(
hResource
)
{
HGLOBAL
hResDir
=
LoadResource
(
hModu
le
,
hResource
);
HGLOBAL
hResDir
=
LoadResource
(
kernel32_hand
le
,
hResource
);
if
(
hResDir
)
{
...
...
dlls/kernel/ne_segment.c
View file @
e92b7eed
...
...
@@ -41,6 +41,7 @@
#include "module.h"
#include "stackframe.h"
#include "builtin16.h"
#include "toolhelp.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
fixup
);
...
...
dlls/kernel/process.c
View file @
e92b7eed
...
...
@@ -64,6 +64,7 @@ static BOOL oem_file_apis;
static
unsigned
int
server_startticks
;
int
main_create_flags
=
0
;
HMODULE
kernel32_handle
=
0
;
/* Process flags */
#define PDB32_DEBUGGED 0x0001
/* Process is being debugged */
...
...
@@ -613,6 +614,7 @@ static RTL_USER_PROCESS_PARAMETERS *init_user_process_params( size_t info_size )
*/
static
BOOL
process_init
(
char
*
argv
[],
char
**
environ
)
{
static
const
WCHAR
kernel32W
[]
=
{
'k'
,
'e'
,
'r'
,
'n'
,
'e'
,
'l'
,
'3'
,
'2'
,
0
};
BOOL
ret
;
size_t
info_size
=
0
;
RTL_USER_PROCESS_PARAMETERS
*
params
;
...
...
@@ -698,6 +700,8 @@ static BOOL process_init( char *argv[], char **environ )
params
->
hStdError
=
hstderr
;
}
kernel32_handle
=
GetModuleHandleW
(
kernel32W
);
LOCALE_Init
();
/* Copy the parent environment */
...
...
dlls/kernel/thunk.c
View file @
e92b7eed
...
...
@@ -127,7 +127,7 @@ static void _write_ftprolog(LPBYTE relayCode ,DWORD *targetTable) {
*
x
++
=
0x0f
;
*
x
++=
0xb6
;
*
x
++=
0xd1
;
/* movzbl edx,cl */
*
x
++
=
0x8B
;
*
x
++=
0x14
;
*
x
++=
0x95
;
*
(
DWORD
**
)
x
=
targetTable
;
x
+=
4
;
/* mov edx, [4*edx + targetTable] */
*
x
++
=
0x68
;
*
(
DWORD
*
)
x
=
(
DWORD
)
GetProcAddress
(
GetModuleHandleA
(
"KERNEL32"
)
,
"FT_Prolog"
);
*
x
++
=
0x68
;
*
(
DWORD
*
)
x
=
(
DWORD
)
GetProcAddress
(
kernel32_handle
,
"FT_Prolog"
);
x
+=
4
;
/* push FT_Prolog */
*
x
++
=
0xC3
;
/* lret */
/* fill rest with 0xCC / int 3 */
...
...
@@ -154,7 +154,7 @@ static void _write_qtthunk(
*
x
++
=
0x8A
;
*
x
++=
0x4D
;
*
x
++=
0xFC
;
/* movb cl,[ebp-04] */
*
x
++
=
0x8B
;
*
x
++=
0x14
;
*
x
++=
0x8D
;
*
(
DWORD
**
)
x
=
targetTable
;
x
+=
4
;
/* mov edx, [4*ecx + targetTable */
*
x
++
=
0xB8
;
*
(
DWORD
*
)
x
=
(
DWORD
)
GetProcAddress
(
GetModuleHandleA
(
"KERNEL32"
)
,
"QT_Thunk"
);
*
x
++
=
0xB8
;
*
(
DWORD
*
)
x
=
(
DWORD
)
GetProcAddress
(
kernel32_handle
,
"QT_Thunk"
);
x
+=
4
;
/* mov eax , QT_Thunk */
*
x
++
=
0xFF
;
*
x
++
=
0xE0
;
/* jmp eax */
/* should fill the rest of the 32 bytes with 0xCC */
...
...
@@ -817,13 +817,12 @@ LPVOID WINAPI ThunkInitLSF(
LPCSTR
dll16
,
/* [in] name of win16 dll */
LPCSTR
dll32
/* [in] name of win32 dll */
)
{
HMODULE
hkrnl32
=
GetModuleHandleA
(
"KERNEL32"
);
LPDWORD
addr
,
addr2
;
/* FIXME: add checks for valid code ... */
/* write pointers to kernel32.89 and kernel32.90 (+ordinal base of 1) */
*
(
DWORD
*
)(
thunk
+
0x35
)
=
(
DWORD
)
GetProcAddress
(
hkrnl32
,(
LPSTR
)
90
);
*
(
DWORD
*
)(
thunk
+
0x6D
)
=
(
DWORD
)
GetProcAddress
(
hkrnl32
,(
LPSTR
)
89
);
*
(
DWORD
*
)(
thunk
+
0x35
)
=
(
DWORD
)
GetProcAddress
(
kernel32_handle
,(
LPSTR
)
90
);
*
(
DWORD
*
)(
thunk
+
0x6D
)
=
(
DWORD
)
GetProcAddress
(
kernel32_handle
,(
LPSTR
)
89
);
if
(
!
(
addr
=
_loadthunk
(
dll16
,
thkbuf
,
dll32
,
NULL
,
len
)))
...
...
@@ -1973,7 +1972,7 @@ SEGPTR WINAPI Get16DLLAddress(HMODULE16 handle, LPSTR func_name)
/* jmpl QT_Thunk */
*
thunk
++
=
0xea
;
*
(
FARPROC
*
)
thunk
=
GetProcAddress
(
GetModuleHandleA
(
"KERNEL32"
)
,
"QT_Thunk"
);
*
(
FARPROC
*
)
thunk
=
GetProcAddress
(
kernel32_handle
,
"QT_Thunk"
);
thunk
+=
sizeof
(
FARPROC16
);
*
(
WORD
*
)
thunk
=
wine_get_cs
();
...
...
dlls/kernel/toolhelp.h
View file @
e92b7eed
...
...
@@ -103,6 +103,13 @@ BOOL16 WINAPI GlobalEntryHandle16( GLOBALENTRY *pGlobal, HGLOBAL16 hItem );
BOOL16
WINAPI
GlobalEntryModule16
(
GLOBALENTRY
*
pGlobal
,
HMODULE16
hModule
,
WORD
wSeg
);
/* FIXME: Wine internal functions */
extern
HGLOBAL16
GLOBAL_CreateBlock
(
UINT16
flags
,
const
void
*
ptr
,
DWORD
size
,
HGLOBAL16
hOwner
,
unsigned
char
selflags
);
extern
BOOL16
GLOBAL_FreeBlock
(
HGLOBAL16
handle
);
extern
BOOL16
GLOBAL_MoveBlock
(
HGLOBAL16
handle
,
const
void
*
ptr
,
DWORD
size
);
extern
HGLOBAL16
GLOBAL_Alloc
(
WORD
flags
,
DWORD
size
,
HGLOBAL16
hOwner
,
unsigned
char
selflags
);
/* Local heap */
typedef
struct
...
...
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