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
becb9a35
Commit
becb9a35
authored
Dec 11, 2000
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Moved all Wine internal definitions out of process.h.
parent
2a37decc
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
519 additions
and
585 deletions
+519
-585
exit.c
dlls/crtdll/exit.c
+0
-1
spawn.c
dlls/crtdll/spawn.c
+0
-2
time.c
dlls/crtdll/time.c
+0
-1
utthunk.c
dlls/kernel/utthunk.c
+11
-9
Makefile.in
include/Makefile.in
+1
-0
ldt.h
include/ldt.h
+4
-4
module.h
include/module.h
+30
-0
process.h
include/process.h
+3
-160
winbase.h
include/winbase.h
+20
-0
module.c
loader/dos/module.c
+0
-1
elf.c
loader/elf.c
+0
-1
module.c
loader/module.c
+55
-43
module.c
loader/ne/module.c
+1
-1
pe_image.c
loader/pe_image.c
+2
-18
pe_resource.c
loader/pe_resource.c
+0
-1
resource.c
loader/resource.c
+0
-1
task.c
loader/task.c
+4
-20
environ.c
memory/environ.c
+93
-25
selector.c
memory/selector.c
+2
-4
virtual.c
memory/virtual.c
+0
-1
version.c
misc/version.c
+6
-18
main.c
miscemu/main.c
+2
-1
dpmi.c
msdos/dpmi.c
+16
-20
vxd.c
msdos/vxd.c
+61
-63
relay386.c
relay32/relay386.c
+1
-2
client.c
scheduler/client.c
+0
-1
process.c
scheduler/process.c
+196
-63
thread.c
scheduler/thread.c
+4
-113
console.c
win32/console.c
+0
-1
device.c
win32/device.c
+0
-1
except.c
win32/except.c
+6
-7
file.c
win32/file.c
+0
-1
user.c
windows/user.c
+1
-1
No files found.
dlls/crtdll/exit.c
View file @
becb9a35
...
...
@@ -25,7 +25,6 @@
*/
#include "crtdll.h"
#include <errno.h>
#include "process.h"
DEFAULT_DEBUG_CHANNEL
(
crtdll
);
...
...
dlls/crtdll/spawn.c
View file @
becb9a35
...
...
@@ -32,7 +32,6 @@
* -File handles need some special handling. Sometimes children get
* open file handles, sometimes not. The docs are confusing.
* -No check for maximum path/argument/environment size is done.
* -Wine has a "process.h" which is not the same as any crt version.
* Unresolved issues Uwe Bonnes 970904:
* -system-call calls another wine process, but without debugging arguments
* and uses the first wine executable in the path
...
...
@@ -40,7 +39,6 @@
#include "crtdll.h"
#include <errno.h>
#include "process.h"
#include <stdlib.h>
...
...
dlls/crtdll/time.c
View file @
becb9a35
...
...
@@ -11,7 +11,6 @@
*/
#include "crtdll.h"
#include "process.h"
#include <stdlib.h>
#include <sys/times.h>
...
...
dlls/kernel/utthunk.c
View file @
becb9a35
...
...
@@ -5,11 +5,11 @@
*/
#include "wine/winbase16.h"
#include "ntddk.h"
#include "heap.h"
#include "module.h"
#include "selectors.h"
#include "callback.h"
#include "process.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL
(
thunk
);
...
...
@@ -51,6 +51,8 @@ typedef struct _UTINFO
}
UTINFO
;
static
UTINFO
*
UT_head
;
/* head of Universal Thunk list */
typedef
DWORD
(
CALLBACK
*
UTGLUEPROC
)(
LPVOID
lpBuff
,
DWORD
dwUserDefined
);
BOOL
WINAPI
UTRegister
(
HMODULE
hModule
,
LPSTR
lpsz16BITDLL
,
...
...
@@ -173,8 +175,8 @@ static UTINFO *UTAlloc( HMODULE hModule, HMODULE16 hModule16,
ut
->
ut32
.
jmp
=
0xe9
;
ut
->
ut32
.
utglue32
=
(
DWORD
)
UTGlue32
-
((
DWORD
)
&
ut
->
ut32
.
utglue32
+
sizeof
(
DWORD
));
ut
->
next
=
PROCESS_Current
()
->
UTState
;
PROCESS_Current
()
->
UTState
=
ut
;
ut
->
next
=
UT_head
;
UT_head
=
ut
;
return
ut
;
}
...
...
@@ -186,7 +188,7 @@ static void UTFree( UTINFO *ut )
{
UTINFO
**
ptr
;
for
(
ptr
=
&
PROCESS_Current
()
->
UTState
;
*
ptr
;
ptr
=
&
(
*
ptr
)
->
next
)
for
(
ptr
=
&
UT_head
;
*
ptr
;
ptr
=
&
(
*
ptr
)
->
next
)
if
(
*
ptr
==
ut
)
{
*
ptr
=
ut
->
next
;
...
...
@@ -203,7 +205,7 @@ static UTINFO *UTFind( HMODULE hModule )
{
UTINFO
*
ut
;
for
(
ut
=
PROCESS_Current
()
->
UTState
;
ut
;
ut
=
ut
->
next
)
for
(
ut
=
UT_head
;
ut
;
ut
=
ut
->
next
)
if
(
ut
->
hModule
==
hModule
)
break
;
...
...
@@ -231,12 +233,12 @@ BOOL WINAPI UTRegister( HMODULE hModule, LPSTR lpsz16BITDLL,
/* Allocate UTINFO struct */
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
if
(
(
ut
=
UTFind
(
hModule
))
!=
NULL
)
ut
=
NULL
;
else
ut
=
UTAlloc
(
hModule
,
hModule16
,
target16
,
pfnUT32CallBack
);
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
if
(
!
ut
)
{
...
...
@@ -276,14 +278,14 @@ VOID WINAPI UTUnRegister( HMODULE hModule )
UTINFO
*
ut
;
HMODULE16
hModule16
=
0
;
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
ut
=
UTFind
(
hModule
);
if
(
!
ut
)
{
hModule16
=
ut
->
hModule16
;
UTFree
(
ut
);
}
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
if
(
hModule16
)
FreeLibrary16
(
hModule16
);
...
...
include/Makefile.in
View file @
becb9a35
...
...
@@ -51,6 +51,7 @@ INSTALLED_INCLUDES = \
oledlg.h
\
oleidl.h
\
poppack.h
\
process.h
\
prsht.h
\
psapi.h
\
pshpack1.h
\
...
...
include/ldt.h
View file @
becb9a35
...
...
@@ -26,10 +26,10 @@
#define PTR_SEG_OFF_TO_HUGEPTR(seg,off) \
PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << __AHSHIFT), LOWORD(off) )
#define W32S_APPLICATION() (PROCESS_Current()->flags & PDB32_WIN32S_PROC)
#define W32S_OFFSET 0x10000
#define W32S_APP2WINE(addr
, offset) ((addr)? (DWORD)(addr) + (DWORD)(offset)
: 0)
#define W32S_WINE2APP(addr
, offset) ((addr)? (DWORD)(addr) - (DWORD)(offset)
: 0)
extern
UINT
W32S_offset
;
#define W32S_APP2WINE(addr
) ((addr)? (DWORD)(addr) + W32S_offset
: 0)
#define W32S_WINE2APP(addr
) ((addr)? (DWORD)(addr) - W32S_offset
: 0)
#define FIRST_LDT_ENTRY_TO_ALLOC 17
...
...
include/module.h
View file @
becb9a35
...
...
@@ -140,6 +140,7 @@ typedef struct _wine_modref
#define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
#define WINE_MODREF_MARKER 0x80000000
extern
WINE_MODREF
*
MODULE_modref_list
;
/* Resource types */
...
...
@@ -231,4 +232,33 @@ extern HMODULE BUILTIN32_LoadExeModule( HMODULE main );
extern
void
*
BUILTIN32_dlopen
(
const
char
*
name
);
extern
int
BUILTIN32_dlclose
(
void
*
handle
);
/* USER signal proc flags and codes */
/* See PROCESS_CallUserSignalProc for comments */
#define USIG_FLAGS_WIN32 0x0001
#define USIG_FLAGS_GUI 0x0002
#define USIG_FLAGS_FEEDBACK 0x0004
#define USIG_FLAGS_FAULT 0x0008
#define USIG_DLL_UNLOAD_WIN16 0x0001
#define USIG_DLL_UNLOAD_WIN32 0x0002
#define USIG_FAULT_DIALOG_PUSH 0x0003
#define USIG_FAULT_DIALOG_POP 0x0004
#define USIG_DLL_UNLOAD_ORPHANS 0x0005
#define USIG_THREAD_INIT 0x0010
#define USIG_THREAD_EXIT 0x0020
#define USIG_PROCESS_CREATE 0x0100
#define USIG_PROCESS_INIT 0x0200
#define USIG_PROCESS_EXIT 0x0300
#define USIG_PROCESS_DESTROY 0x0400
#define USIG_PROCESS_RUNNING 0x0500
#define USIG_PROCESS_LOADED 0x0600
/* scheduler/process.c */
extern
void
PROCESS_CallUserSignalProc
(
UINT
uCode
,
HMODULE
hModule
);
extern
BOOL
PROCESS_Create
(
HFILE
hFile
,
LPCSTR
filename
,
LPSTR
cmd_line
,
LPCSTR
env
,
LPSECURITY_ATTRIBUTES
psa
,
LPSECURITY_ATTRIBUTES
tsa
,
BOOL
inherit
,
DWORD
flags
,
STARTUPINFOA
*
startup
,
PROCESS_INFORMATION
*
info
,
LPCSTR
lpCurrentDirectory
);
#endif
/* __WINE_MODULE_H */
include/process.h
View file @
becb9a35
...
...
@@ -4,165 +4,8 @@
* Copyright 1996 Alexandre Julliard
*/
#ifndef __WINE_PROCESS_H
#define __WINE_PROCESS_H
#include "windef.h"
#include "module.h"
#include "thread.h"
struct
_NE_MODULE
;
struct
_THREAD_ENTRY
;
struct
_UTINFO
;
/* Win32 process environment database */
typedef
struct
{
LPSTR
environ
;
/* 00 Process environment strings */
DWORD
unknown1
;
/* 04 Unknown */
LPSTR
cmd_line
;
/* 08 Command line */
LPSTR
cur_dir
;
/* 0c Current directory */
STARTUPINFOA
*
startup_info
;
/* 10 Startup information */
HANDLE
hStdin
;
/* 14 Handle for standard input */
HANDLE
hStdout
;
/* 18 Handle for standard output */
HANDLE
hStderr
;
/* 1c Handle for standard error */
DWORD
unknown2
;
/* 20 Unknown */
DWORD
inherit_console
;
/* 24 Inherit console flag */
DWORD
break_type
;
/* 28 Console events flag */
void
*
break_sem
;
/* 2c SetConsoleCtrlHandler semaphore */
void
*
break_event
;
/* 30 SetConsoleCtrlHandler event */
void
*
break_thread
;
/* 34 SetConsoleCtrlHandler thread */
void
*
break_handlers
;
/* 38 List of console handlers */
/* The following are Wine-specific fields */
CRITICAL_SECTION
section
;
/* 3c Env DB critical section */
LPWSTR
cmd_lineW
;
/* 40 Unicode command line */
WORD
env_sel
;
/* 44 Environment strings selector */
}
ENVDB
;
/* Win32 process database */
typedef
struct
_PDB
{
LONG
header
[
2
];
/* 00 Kernel object header */
HMODULE
module
;
/* 08 Main exe module (NT) */
void
*
event
;
/* 0c Pointer to an event object (unused) */
DWORD
exit_code
;
/* 10 Process exit code */
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 */
ENVDB
*
env_db
;
/* 40 Environment database */
void
*
handle_table
;
/* 44 Handle table */
struct
_PDB
*
parent
;
/* 48 Parent process */
WINE_MODREF
*
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 */
WINE_MODREF
*
exe_modref
;
/* 98 MODREF for the process EXE */
LPTOP_LEVEL_EXCEPTION_FILTER
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 */
struct
_UTINFO
*
UTState
;
/* bc Head of Univeral Thunk list */
DWORD
unknown8
;
/* c0 Unknown (NT) */
LCID
locale
;
/* c4 Locale to be queried by GetThreadLocale (NT) */
}
PDB
;
/* Process flags */
#define PDB32_DEBUGGED 0x0001
/* Process is being debugged */
#define PDB32_WIN16_PROC 0x0008
/* Win16 process */
#define PDB32_DOS_PROC 0x0010
/* Dos process */
#define PDB32_CONSOLE_PROC 0x0020
/* Console process */
#define PDB32_FILE_APIS_OEM 0x0040
/* File APIs are OEM */
#define PDB32_WIN32S_PROC 0x8000
/* Win32s process */
/* USER signal proc flags and codes */
/* See PROCESS_CallUserSignalProc for comments */
#define USIG_FLAGS_WIN32 0x0001
#define USIG_FLAGS_GUI 0x0002
#define USIG_FLAGS_FEEDBACK 0x0004
#define USIG_FLAGS_FAULT 0x0008
#define USIG_DLL_UNLOAD_WIN16 0x0001
#define USIG_DLL_UNLOAD_WIN32 0x0002
#define USIG_FAULT_DIALOG_PUSH 0x0003
#define USIG_FAULT_DIALOG_POP 0x0004
#define USIG_DLL_UNLOAD_ORPHANS 0x0005
#define USIG_THREAD_INIT 0x0010
#define USIG_THREAD_EXIT 0x0020
#define USIG_PROCESS_CREATE 0x0100
#define USIG_PROCESS_INIT 0x0200
#define USIG_PROCESS_EXIT 0x0300
#define USIG_PROCESS_DESTROY 0x0400
#define USIG_PROCESS_RUNNING 0x0500
#define USIG_PROCESS_LOADED 0x0600
/* [GS]etProcessDword offsets */
#define GPD_APP_COMPAT_FLAGS (-56)
#define GPD_LOAD_DONE_EVENT (-52)
#define GPD_HINSTANCE16 (-48)
#define GPD_WINDOWS_VERSION (-44)
#define GPD_THDB (-40)
#define GPD_PDB (-36)
#define GPD_STARTF_SHELLDATA (-32)
#define GPD_STARTF_HOTKEY (-28)
#define GPD_STARTF_SHOWWINDOW (-24)
#define GPD_STARTF_SIZE (-20)
#define GPD_STARTF_POSITION (-16)
#define GPD_STARTF_FLAGS (-12)
#define GPD_PARENT (- 8)
#define GPD_FLAGS (- 4)
#define GPD_USERDATA ( 0)
extern
DWORD
WINAPI
GetProcessDword
(
DWORD
dwProcessID
,
INT
offset
);
extern
void
WINAPI
SetProcessDword
(
DWORD
dwProcessID
,
INT
offset
,
DWORD
value
);
extern
DWORD
WINAPI
MapProcessHandle
(
HANDLE
handle
);
/* memory/environ.c */
extern
BOOL
ENV_BuildEnvironment
(
void
);
/* scheduler/process.c */
extern
void
PROCESS_InitWine
(
int
argc
,
char
*
argv
[]
)
WINE_NORETURN
;
extern
void
PROCESS_InitWinelib
(
int
argc
,
char
*
argv
[]
)
WINE_NORETURN
;
extern
void
PROCESS_CallUserSignalProc
(
UINT
uCode
,
HMODULE
hModule
);
extern
BOOL
PROCESS_Create
(
HFILE
hFile
,
LPCSTR
filename
,
LPSTR
cmd_line
,
LPCSTR
env
,
LPSECURITY_ATTRIBUTES
psa
,
LPSECURITY_ATTRIBUTES
tsa
,
BOOL
inherit
,
DWORD
flags
,
STARTUPINFOA
*
startup
,
PROCESS_INFORMATION
*
info
,
LPCSTR
lpCurrentDirectory
);
extern
PDB
current_process
;
extern
ENVDB
current_envdb
;
extern
STARTUPINFOA
current_startupinfo
;
static
inline
PDB
WINE_UNUSED
*
PROCESS_Current
(
void
)
{
return
&
current_process
;
}
/* definitions contained in Windows process.h file */
/* FIXME: all the stuff above should be moved somewhere else */
#ifndef _INC_PROCESS
#define _INC_PROCESS
typedef
void
(
*
LPBEGINTHREAD
)(
LPVOID
);
typedef
UINT
(
WINAPI
*
LPBEGINTHREADEX
)(
LPVOID
);
...
...
@@ -172,4 +15,4 @@ void _endthread(void);
ULONG
_beginthreadex
(
LPVOID
,
UINT
,
LPBEGINTHREADEX
,
LPVOID
,
UINT
,
LPUINT
);
void
_endthreadex
(
UINT
);
#endif
/* _
_WINE_PROCESS_H
*/
#endif
/* _
INC_PROCESS
*/
include/winbase.h
View file @
becb9a35
...
...
@@ -1880,13 +1880,33 @@ typedef struct tagSYSLEVEL
INT
level
;
}
SYSLEVEL
;
/* [GS]etProcessDword offsets */
#define GPD_APP_COMPAT_FLAGS (-56)
#define GPD_LOAD_DONE_EVENT (-52)
#define GPD_HINSTANCE16 (-48)
#define GPD_WINDOWS_VERSION (-44)
#define GPD_THDB (-40)
#define GPD_PDB (-36)
#define GPD_STARTF_SHELLDATA (-32)
#define GPD_STARTF_HOTKEY (-28)
#define GPD_STARTF_SHOWWINDOW (-24)
#define GPD_STARTF_SIZE (-20)
#define GPD_STARTF_POSITION (-16)
#define GPD_STARTF_FLAGS (-12)
#define GPD_PARENT (- 8)
#define GPD_FLAGS (- 4)
#define GPD_USERDATA ( 0)
void
WINAPI
DisposeLZ32Handle
(
HANDLE
);
HANDLE
WINAPI
DosFileHandleToWin32Handle
(
HFILE
);
DWORD
WINAPI
GetProcessDword
(
DWORD
,
INT
);
VOID
WINAPI
GetpWin16Lock
(
SYSLEVEL
**
);
DWORD
WINAPI
MapLS
(
LPCVOID
);
DWORD
WINAPI
MapProcessHandle
(
HANDLE
);
LPVOID
WINAPI
MapSL
(
DWORD
);
VOID
WINAPI
ReleaseThunkLock
(
DWORD
*
);
VOID
WINAPI
RestoreThunkLock
(
DWORD
);
void
WINAPI
SetProcessDword
(
DWORD
,
INT
,
DWORD
);
VOID
WINAPI
UnMapLS
(
DWORD
);
HFILE
WINAPI
Win32HandleToDosFileHandle
(
HANDLE
);
DWORD
WINAPI
_ConfirmWin16Lock
(
void
);
...
...
loader/dos/module.c
View file @
becb9a35
...
...
@@ -26,7 +26,6 @@
#include "selectors.h"
#include "file.h"
#include "ldt.h"
#include "process.h"
#include "miscemu.h"
#include "debugtools.h"
#include "dosexe.h"
...
...
loader/elf.c
View file @
becb9a35
...
...
@@ -17,7 +17,6 @@
#include <sys/types.h>
#include "snoop.h"
#include "process.h"
#include "heap.h"
#include "file.h"
#include "module.h"
...
...
loader/module.c
View file @
becb9a35
...
...
@@ -15,7 +15,7 @@
#include "winerror.h"
#include "heap.h"
#include "file.h"
#include "
process
.h"
#include "
module
.h"
#include "selectors.h"
#include "debugtools.h"
#include "callback.h"
...
...
@@ -25,6 +25,10 @@
DEFAULT_DEBUG_CHANNEL
(
module
);
DECLARE_DEBUG_CHANNEL
(
win32
);
WINE_MODREF
*
MODULE_modref_list
=
NULL
;
static
WINE_MODREF
*
exe_modref
;
static
int
free_lib_count
;
/* recursion depth of FreeLibrary calls */
/*************************************************************************
* MODULE32_LookupHMODULE
...
...
@@ -36,14 +40,14 @@ static WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hmod )
WINE_MODREF
*
wm
;
if
(
!
hmod
)
return
PROCESS_Current
()
->
exe_modref
;
return
exe_modref
;
if
(
!
HIWORD
(
hmod
))
{
ERR
(
"tried to lookup 0x%04x in win32 module handler!
\n
"
,
hmod
);
SetLastError
(
ERROR_INVALID_HANDLE
);
return
NULL
;
}
for
(
wm
=
PROCESS_Current
()
->
modref_list
;
wm
;
wm
=
wm
->
next
)
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
wm
->
next
)
if
(
wm
->
module
==
hmod
)
return
wm
;
SetLastError
(
ERROR_INVALID_HANDLE
);
...
...
@@ -76,9 +80,15 @@ WINE_MODREF *MODULE_AllocModRef( HMODULE hModule, LPCSTR filename )
if
((
wm
->
short_modname
=
strrchr
(
wm
->
short_filename
,
'\\'
)))
wm
->
short_modname
++
;
else
wm
->
short_modname
=
wm
->
short_filename
;
wm
->
next
=
PROCESS_Current
()
->
modref_list
;
wm
->
next
=
MODULE_
modref_list
;
if
(
wm
->
next
)
wm
->
next
->
prev
=
wm
;
PROCESS_Current
()
->
modref_list
=
wm
;
MODULE_modref_list
=
wm
;
if
(
!
(
PE_HEADER
(
hModule
)
->
FileHeader
.
Characteristics
&
IMAGE_FILE_DLL
))
{
if
(
!
exe_modref
)
exe_modref
=
wm
;
else
FIXME
(
"Trying to load second .EXE file: %s
\n
"
,
filename
);
}
}
return
wm
;
}
...
...
@@ -139,20 +149,21 @@ static BOOL MODULE_InitDLL( WINE_MODREF *wm, DWORD type, LPVOID lpReserved )
* list after the attach notification has returned. This implies that the
* detach notifications are called in the reverse of the sequence the attach
* notifications *returned*.
*
* NOTE: Assumes that the process critical section is held!
*
*/
BOOL
MODULE_DllProcessAttach
(
WINE_MODREF
*
wm
,
LPVOID
lpReserved
)
{
BOOL
retv
=
TRUE
;
int
i
;
RtlAcquirePebLock
();
if
(
!
wm
)
wm
=
exe_modref
;
assert
(
wm
);
/* prevent infinite recursion in case of cyclical dependencies */
if
(
(
wm
->
flags
&
WINE_MODREF_MARKER
)
||
(
wm
->
flags
&
WINE_MODREF_PROCESS_ATTACHED
)
)
return
retv
;
goto
done
;
TRACE
(
"(%s,%p) - START
\n
"
,
wm
->
modname
,
lpReserved
);
...
...
@@ -179,8 +190,8 @@ BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
if
(
wm
->
next
)
wm
->
next
->
prev
=
wm
->
prev
;
wm
->
prev
=
NULL
;
wm
->
next
=
PROCESS_Current
()
->
modref_list
;
PROCESS_Current
()
->
modref_list
=
wm
->
next
->
prev
=
wm
;
wm
->
next
=
MODULE_
modref_list
;
MODULE_
modref_list
=
wm
->
next
->
prev
=
wm
;
}
/* Remove recursion flag */
...
...
@@ -188,6 +199,8 @@ BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
TRACE
(
"(%s,%p) - END
\n
"
,
wm
->
modname
,
lpReserved
);
done:
RtlReleasePebLock
();
return
retv
;
}
...
...
@@ -202,11 +215,11 @@ void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved )
{
WINE_MODREF
*
wm
;
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
do
{
for
(
wm
=
PROCESS_Current
()
->
modref_list
;
wm
;
wm
=
wm
->
next
)
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
wm
->
next
)
{
/* Check whether to detach this DLL */
if
(
!
(
wm
->
flags
&
WINE_MODREF_PROCESS_ATTACHED
)
)
...
...
@@ -224,7 +237,7 @@ void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved )
}
}
while
(
wm
);
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
}
/*************************************************************************
...
...
@@ -238,9 +251,9 @@ void MODULE_DllThreadAttach( LPVOID lpReserved )
{
WINE_MODREF
*
wm
;
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
for
(
wm
=
PROCESS_Current
()
->
modref_list
;
wm
;
wm
=
wm
->
next
)
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
wm
->
next
)
if
(
!
wm
->
next
)
break
;
...
...
@@ -254,7 +267,7 @@ void MODULE_DllThreadAttach( LPVOID lpReserved )
MODULE_InitDLL
(
wm
,
DLL_THREAD_ATTACH
,
lpReserved
);
}
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
}
/*************************************************************************
...
...
@@ -268,9 +281,9 @@ void MODULE_DllThreadDetach( LPVOID lpReserved )
{
WINE_MODREF
*
wm
;
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
for
(
wm
=
PROCESS_Current
()
->
modref_list
;
wm
;
wm
=
wm
->
next
)
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
wm
->
next
)
{
if
(
!
(
wm
->
flags
&
WINE_MODREF_PROCESS_ATTACHED
)
)
continue
;
...
...
@@ -280,7 +293,7 @@ void MODULE_DllThreadDetach( LPVOID lpReserved )
MODULE_InitDLL
(
wm
,
DLL_THREAD_DETACH
,
lpReserved
);
}
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
}
/****************************************************************************
...
...
@@ -293,7 +306,7 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule )
WINE_MODREF
*
wm
;
BOOL
retval
=
TRUE
;
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
wm
=
MODULE32_LookupHMODULE
(
hModule
);
if
(
!
wm
)
...
...
@@ -301,7 +314,7 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule )
else
wm
->
flags
|=
WINE_MODREF_NO_DLL_CALLS
;
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
return
retval
;
}
...
...
@@ -432,7 +445,7 @@ WINE_MODREF *MODULE_FindModule(
if
(
!
(
p
=
strrchr
(
dllname
,
'.'
))
||
strchr
(
p
,
'/'
)
||
strchr
(
p
,
'\\'
))
strcat
(
dllname
,
".DLL"
);
for
(
wm
=
PROCESS_Current
()
->
modref_list
;
wm
;
wm
=
wm
->
next
)
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
wm
->
next
)
{
if
(
!
FILE_strcasecmp
(
dllname
,
wm
->
modname
)
)
break
;
...
...
@@ -1155,7 +1168,7 @@ HMODULE WINAPI GetModuleHandleA(LPCSTR module)
WINE_MODREF
*
wm
;
if
(
module
==
NULL
)
wm
=
PROCESS_Current
()
->
exe_modref
;
wm
=
exe_modref
;
else
wm
=
MODULE_FindModule
(
module
);
...
...
@@ -1190,13 +1203,13 @@ DWORD WINAPI GetModuleFileNameA(
{
WINE_MODREF
*
wm
;
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
lpFileName
[
0
]
=
0
;
if
((
wm
=
MODULE32_LookupHMODULE
(
hModule
)))
lstrcpynA
(
lpFileName
,
wm
->
filename
,
size
);
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
TRACE
(
"%s
\n
"
,
lpFileName
);
return
strlen
(
lpFileName
);
}
...
...
@@ -1249,7 +1262,7 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
return
hmod
;
}
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
wm
=
MODULE_LoadLibraryExA
(
libname
,
hfile
,
flags
);
if
(
wm
)
...
...
@@ -1263,8 +1276,7 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
}
}
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
();
return
wm
?
wm
->
module
:
0
;
}
...
...
@@ -1323,7 +1335,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
strcat
(
filename
,
".DLL"
);
}
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
/* Check for already loaded module */
if
(
!
(
pwm
=
MODULE_FindModule
(
filename
))
&&
...
...
@@ -1361,7 +1373,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
fixup_imports
(
pwm
);
}
TRACE
(
"Already loaded module '%s' at 0x%08x, count=%d,
\n
"
,
filename
,
pwm
->
module
,
pwm
->
refCount
);
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
return
pwm
;
}
...
...
@@ -1407,7 +1419,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
/* decrement the dependencies through the MODULE_FreeLibrary call. */
pwm
->
refCount
++
;
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
SetLastError
(
err
);
/* restore last error */
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
return
pwm
;
...
...
@@ -1417,7 +1429,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
break
;
}
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
error:
WARN
(
"Failed to load module '%s'; error=0x%08lx,
\n
"
,
filename
,
GetLastError
());
HeapFree
(
GetProcessHeap
(),
0
,
filename
);
...
...
@@ -1477,7 +1489,7 @@ static void MODULE_FlushModrefs(void)
{
WINE_MODREF
*
wm
,
*
next
;
for
(
wm
=
PROCESS_Current
()
->
modref_list
;
wm
;
wm
=
next
)
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
next
)
{
next
=
wm
->
next
;
...
...
@@ -1489,8 +1501,8 @@ static void MODULE_FlushModrefs(void)
wm
->
next
->
prev
=
wm
->
prev
;
if
(
wm
->
prev
)
wm
->
prev
->
next
=
wm
->
next
;
if
(
wm
==
PROCESS_Current
()
->
modref_list
)
PROCESS_Current
()
->
modref_list
=
wm
->
next
;
if
(
wm
==
MODULE_
modref_list
)
MODULE_
modref_list
=
wm
->
next
;
TRACE
(
" unloading %s
\n
"
,
wm
->
filename
);
/* VirtualFree( (LPVOID)wm->module, 0, MEM_RELEASE ); */
/* FIXME */
...
...
@@ -1511,8 +1523,8 @@ BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
BOOL
retv
=
FALSE
;
WINE_MODREF
*
wm
;
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
PROCESS_Current
()
->
free_lib_count
++
;
RtlAcquirePebLock
(
);
free_lib_count
++
;
wm
=
MODULE32_LookupHMODULE
(
hLibModule
);
if
(
!
wm
||
!
hLibModule
)
...
...
@@ -1520,8 +1532,8 @@ BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
else
retv
=
MODULE_FreeLibrary
(
wm
);
PROCESS_Current
()
->
free_lib_count
--
;
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
free_lib_count
--
;
RtlReleasePebLock
(
);
return
retv
;
}
...
...
@@ -1569,7 +1581,7 @@ BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
MODULE_DecRefCount
(
wm
);
/* Call process detach notifications */
if
(
PROCESS_Current
()
->
free_lib_count
<=
1
)
if
(
free_lib_count
<=
1
)
{
MODULE_DllProcessDetach
(
FALSE
,
NULL
);
SERVER_START_REQ
...
...
@@ -1700,13 +1712,13 @@ FARPROC MODULE_GetProcAddress(
else
TRACE_
(
win32
)(
"(%08lx,%p)
\n
"
,(
DWORD
)
hModule
,
function
);
EnterCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlAcquirePebLock
(
);
if
((
wm
=
MODULE32_LookupHMODULE
(
hModule
)))
{
retproc
=
wm
->
find_export
(
wm
,
function
,
snoop
);
if
(
!
retproc
)
SetLastError
(
ERROR_PROC_NOT_FOUND
);
}
LeaveCriticalSection
(
&
PROCESS_Current
()
->
crit_section
);
RtlReleasePebLock
(
);
return
retproc
;
}
...
...
loader/ne/module.c
View file @
becb9a35
...
...
@@ -19,7 +19,6 @@
#include "heap.h"
#include "task.h"
#include "global.h"
#include "process.h"
#include "snoop.h"
#include "builtin16.h"
#include "stackframe.h"
...
...
@@ -1073,6 +1072,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
if
(
hThread
==
-
1
)
return
0
;
if
(
!
(
teb
=
THREAD_Create
(
socket
,
0
,
FALSE
)))
goto
error
;
teb
->
tibflags
&=
~
TEBF_WIN32
;
teb
->
startup
=
NE_InitProcess
;
/* Create a task for this process */
...
...
loader/pe_image.c
View file @
becb9a35
...
...
@@ -31,7 +31,6 @@
#endif
#include "wine/winbase16.h"
#include "winerror.h"
#include "process.h"
#include "snoop.h"
#include "server.h"
#include "debugtools.h"
...
...
@@ -639,21 +638,6 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
if
(
pe_export
)
dump_exports
(
hModule
);
/* The exe_modref must be in place, before implicit linked DLLs are loaded
by fixup_imports, otherwhise GetModuleFileName will not work and modules
in the executables directory can not be found */
if
(
!
(
nt
->
FileHeader
.
Characteristics
&
IMAGE_FILE_DLL
))
{
if
(
PROCESS_Current
()
->
exe_modref
)
FIXME
(
"Trying to load second .EXE file: %s
\n
"
,
filename
);
else
{
PROCESS_Current
()
->
exe_modref
=
wm
;
PROCESS_Current
()
->
module
=
wm
->
module
;
}
}
/* Fixup Imports */
if
(
!
(
wm
->
flags
&
WINE_MODREF_DONT_RESOLVE_REFS
)
&&
fixup_imports
(
wm
))
...
...
@@ -661,7 +645,7 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
/* remove entry from modref chain */
if
(
!
wm
->
prev
)
PROCESS_Current
()
->
modref_list
=
wm
->
next
;
MODULE_
modref_list
=
wm
->
next
;
else
wm
->
prev
->
next
=
wm
->
next
;
...
...
@@ -791,7 +775,7 @@ void PE_InitTls( void )
PIMAGE_TLS_DIRECTORY
pdir
;
int
delta
;
for
(
wm
=
PROCESS_Current
()
->
modref_list
;
wm
;
wm
=
wm
->
next
)
{
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
wm
->
next
)
{
peh
=
PE_HEADER
(
wm
->
module
);
delta
=
wm
->
module
-
peh
->
OptionalHeader
.
ImageBase
;
if
(
!
peh
->
OptionalHeader
.
DataDirectory
[
IMAGE_FILE_THREAD_LOCAL_STORAGE
].
VirtualAddress
)
...
...
loader/pe_resource.c
View file @
becb9a35
...
...
@@ -20,7 +20,6 @@
#include "module.h"
#include "heap.h"
#include "task.h"
#include "process.h"
#include "stackframe.h"
#include "debugtools.h"
...
...
loader/resource.c
View file @
becb9a35
...
...
@@ -22,7 +22,6 @@
#include "callback.h"
#include "cursoricon.h"
#include "task.h"
#include "process.h"
#include "module.h"
#include "file.h"
#include "debugtools.h"
...
...
loader/task.c
View file @
becb9a35
...
...
@@ -18,7 +18,6 @@
#include "instance.h"
#include "miscemu.h"
#include "module.h"
#include "process.h"
#include "queue.h"
#include "selectors.h"
#include "stackframe.h"
...
...
@@ -283,17 +282,18 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
(
int
)
&
((
PDB16
*
)
0
)
->
fileHandles
);
pTask
->
pdb
.
hFileHandles
=
0
;
memset
(
pTask
->
pdb
.
fileHandles
,
0xff
,
sizeof
(
pTask
->
pdb
.
fileHandles
)
);
pTask
->
pdb
.
environment
=
current_envdb
.
env_sel
;
/* FIXME: should we make a copy of the environment? */
pTask
->
pdb
.
environment
=
SELECTOROF
(
GetDOSEnvironment16
());
pTask
->
pdb
.
nbFiles
=
20
;
/* Fill the command line */
if
(
!
cmdline
)
{
cmdline
=
current_envdb
.
cmd_line
;
cmdline
=
GetCommandLineA
()
;
/* remove the first word (program name) */
if
(
*
cmdline
==
'"'
)
if
(
!
(
cmdline
=
strchr
(
cmdline
+
1
,
'"'
)))
cmdline
=
current_envdb
.
cmd_line
;
if
(
!
(
cmdline
=
strchr
(
cmdline
+
1
,
'"'
)))
cmdline
=
GetCommandLineA
()
;
while
(
*
cmdline
&&
(
*
cmdline
!=
' '
)
&&
(
*
cmdline
!=
'\t'
))
cmdline
++
;
while
((
*
cmdline
==
' '
)
||
(
*
cmdline
==
'\t'
))
cmdline
++
;
len
=
strlen
(
cmdline
);
...
...
@@ -314,10 +314,6 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
pTask
->
hCSAlias
=
GLOBAL_CreateBlock
(
GMEM_FIXED
,
(
void
*
)
pTask
,
sizeof
(
TDB
),
pTask
->
hPDB
,
WINE_LDT_FLAGS_CODE
);
/* Set the owner of the environment block */
FarSetOwner16
(
pTask
->
pdb
.
environment
,
pTask
->
hPDB
);
/* Default DTA overwrites command line */
pTask
->
dta
=
PTR_SEG_OFF_TO_SEGPTR
(
pTask
->
hPDB
,
...
...
@@ -1320,18 +1316,6 @@ UINT16 WINAPI SetErrorMode16( UINT16 mode )
/***********************************************************************
* GetDOSEnvironment (KERNEL.131)
*/
SEGPTR
WINAPI
GetDOSEnvironment16
(
void
)
{
TDB
*
pTask
;
if
(
!
(
pTask
=
(
TDB
*
)
GlobalLock16
(
GetCurrentTask
()
)))
return
0
;
return
PTR_SEG_OFF_TO_SEGPTR
(
pTask
->
pdb
.
environment
,
0
);
}
/***********************************************************************
* GetNumTasks (KERNEL.152)
*/
UINT16
WINAPI
GetNumTasks16
(
void
)
...
...
memory/environ.c
View file @
becb9a35
...
...
@@ -9,10 +9,31 @@
#include "windef.h"
#include "winnls.h"
#include "winerror.h"
#include "
process
.h"
#include "
ntddk
.h"
#include "heap.h"
#include "selectors.h"
/* Win32 process environment database */
typedef
struct
_ENVDB
{
LPSTR
environ
;
/* 00 Process environment strings */
DWORD
unknown1
;
/* 04 Unknown */
LPSTR
cmd_line
;
/* 08 Command line */
LPSTR
cur_dir
;
/* 0c Current directory */
STARTUPINFOA
*
startup_info
;
/* 10 Startup information */
HANDLE
hStdin
;
/* 14 Handle for standard input */
HANDLE
hStdout
;
/* 18 Handle for standard output */
HANDLE
hStderr
;
/* 1c Handle for standard error */
DWORD
unknown2
;
/* 20 Unknown */
DWORD
inherit_console
;
/* 24 Inherit console flag */
DWORD
break_type
;
/* 28 Console events flag */
void
*
break_sem
;
/* 2c SetConsoleCtrlHandler semaphore */
void
*
break_event
;
/* 30 SetConsoleCtrlHandler event */
void
*
break_thread
;
/* 34 SetConsoleCtrlHandler thread */
void
*
break_handlers
;
/* 38 List of console handlers */
}
ENVDB
;
/* Format of an environment block:
* ASCIIZ string 1 (xx=yy format)
* ...
...
...
@@ -79,12 +100,13 @@ ENVDB current_envdb =
0
,
/* break_sem */
0
,
/* break_event */
0
,
/* break_thread */
0
,
/* break_handlers */
CRITICAL_SECTION_INIT
,
/* section */
0
,
/* cmd_lineW */
0
/* env_sel */
0
/* break_handlers */
};
static
WCHAR
*
cmdlineW
;
/* Unicode command line */
static
WORD
env_sel
;
/* selector to the environment */
/***********************************************************************
* ENV_FindVariable
*
...
...
@@ -108,7 +130,7 @@ static LPCSTR ENV_FindVariable( LPCSTR env, LPCSTR name, INT len )
*
* Build the environment for the initial process
*/
BOOL
ENV_BuildEnvironment
(
void
)
ENVDB
*
ENV_BuildEnvironment
(
void
)
{
extern
char
**
environ
;
LPSTR
p
,
*
e
;
...
...
@@ -121,9 +143,9 @@ BOOL ENV_BuildEnvironment(void)
/* Now allocate the environment */
if
(
!
(
p
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
return
FALSE
;
if
(
!
(
p
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
)))
return
NULL
;
current_envdb
.
environ
=
p
;
current_envdb
.
env_sel
=
SELECTOR_AllocBlock
(
p
,
0x10000
,
WINE_LDT_FLAGS_DATA
);
env_sel
=
SELECTOR_AllocBlock
(
p
,
0x10000
,
WINE_LDT_FLAGS_DATA
);
/* And fill it with the Unix environment */
...
...
@@ -136,6 +158,50 @@ BOOL ENV_BuildEnvironment(void)
/* Now add the program name */
FILL_EXTRA_ENV
(
p
);
return
&
current_envdb
;
}
/***********************************************************************
* ENV_BuildCommandLine
*
* Build the command line of a process from the argv array.
*
* Note that it does NOT necessarily include the file name.
* Sometimes we don't even have any command line options at all.
*/
BOOL
ENV_BuildCommandLine
(
char
**
argv
)
{
int
len
,
quote
=
0
;
char
*
p
,
**
arg
;
for
(
arg
=
argv
,
len
=
0
;
*
arg
;
arg
++
)
len
+=
strlen
(
*
arg
)
+
1
;
if
((
argv
[
0
])
&&
(
quote
=
(
strchr
(
argv
[
0
],
' '
)
!=
NULL
)))
len
+=
2
;
if
(
!
(
p
=
current_envdb
.
cmd_line
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
return
FALSE
;
arg
=
argv
;
if
(
quote
)
{
*
p
++
=
'\"'
;
strcpy
(
p
,
*
arg
);
p
+=
strlen
(
p
);
*
p
++
=
'\"'
;
*
p
++
=
' '
;
arg
++
;
}
while
(
*
arg
)
{
strcpy
(
p
,
*
arg
);
p
+=
strlen
(
p
);
*
p
++
=
' '
;
arg
++
;
}
if
(
p
>
current_envdb
.
cmd_line
)
p
--
;
/* remove last space */
*
p
=
0
;
/* now allocate the Unicode version */
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
current_envdb
.
cmd_line
,
-
1
,
NULL
,
0
);
if
(
!
(
cmdlineW
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
MultiByteToWideChar
(
CP_ACP
,
0
,
current_envdb
.
cmd_line
,
-
1
,
cmdlineW
,
len
);
return
TRUE
;
}
...
...
@@ -153,12 +219,7 @@ LPSTR WINAPI GetCommandLineA(void)
*/
LPWSTR
WINAPI
GetCommandLineW
(
void
)
{
EnterCriticalSection
(
&
current_envdb
.
section
);
if
(
!
current_envdb
.
cmd_lineW
)
current_envdb
.
cmd_lineW
=
HEAP_strdupAtoW
(
GetProcessHeap
(),
0
,
current_envdb
.
cmd_line
);
LeaveCriticalSection
(
&
current_envdb
.
section
);
return
current_envdb
.
cmd_lineW
;
return
cmdlineW
;
}
...
...
@@ -179,7 +240,7 @@ LPWSTR WINAPI GetEnvironmentStringsW(void)
INT
size
;
LPWSTR
ret
;
EnterCriticalSection
(
&
current_envdb
.
section
);
RtlAcquirePebLock
(
);
size
=
HeapSize
(
GetProcessHeap
(),
0
,
current_envdb
.
environ
);
if
((
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
*
sizeof
(
WCHAR
)
))
!=
NULL
)
{
...
...
@@ -187,7 +248,7 @@ LPWSTR WINAPI GetEnvironmentStringsW(void)
LPWSTR
pW
=
ret
;
while
(
size
--
)
*
pW
++
=
(
WCHAR
)(
BYTE
)
*
pA
++
;
}
LeaveCriticalSection
(
&
current_envdb
.
section
);
RtlReleasePebLock
(
);
return
ret
;
}
...
...
@@ -228,7 +289,7 @@ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size )
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
0
;
}
EnterCriticalSection
(
&
current_envdb
.
section
);
RtlAcquirePebLock
(
);
if
((
p
=
ENV_FindVariable
(
current_envdb
.
environ
,
name
,
strlen
(
name
)
)))
{
ret
=
strlen
(
p
);
...
...
@@ -241,7 +302,7 @@ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size )
}
else
if
(
value
)
strcpy
(
value
,
p
);
}
LeaveCriticalSection
(
&
current_envdb
.
section
);
RtlReleasePebLock
(
);
if
(
!
ret
)
SetLastError
(
ERROR_ENVVAR_NOT_FOUND
);
return
ret
;
...
...
@@ -276,7 +337,7 @@ BOOL WINAPI SetEnvironmentVariableA( LPCSTR name, LPCSTR value )
LPSTR
p
,
env
,
new_env
;
BOOL
ret
=
FALSE
;
EnterCriticalSection
(
&
current_envdb
.
section
);
RtlAcquirePebLock
(
);
env
=
p
=
current_envdb
.
environ
;
/* Find a place to insert the string */
...
...
@@ -302,9 +363,7 @@ BOOL WINAPI SetEnvironmentVariableA( LPCSTR name, LPCSTR value )
}
if
(
!
(
new_env
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
env
,
old_size
+
len
)))
goto
done
;
if
(
current_envdb
.
env_sel
)
current_envdb
.
env_sel
=
SELECTOR_ReallocBlock
(
current_envdb
.
env_sel
,
new_env
,
old_size
+
len
);
if
(
env_sel
)
env_sel
=
SELECTOR_ReallocBlock
(
env_sel
,
new_env
,
old_size
+
len
);
p
=
new_env
+
(
p
-
env
);
if
(
len
>
0
)
memmove
(
p
+
len
,
p
,
old_size
-
(
p
-
new_env
)
);
...
...
@@ -320,7 +379,7 @@ BOOL WINAPI SetEnvironmentVariableA( LPCSTR name, LPCSTR value )
ret
=
TRUE
;
done:
LeaveCriticalSection
(
&
current_envdb
.
section
);
RtlReleasePebLock
(
);
return
ret
;
}
...
...
@@ -350,7 +409,7 @@ DWORD WINAPI ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
LPCSTR
p
,
var
;
if
(
!
count
)
dst
=
NULL
;
EnterCriticalSection
(
&
current_envdb
.
section
);
RtlAcquirePebLock
(
);
while
(
*
src
)
{
...
...
@@ -395,7 +454,7 @@ DWORD WINAPI ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
count
-=
len
;
}
}
LeaveCriticalSection
(
&
current_envdb
.
section
);
RtlReleasePebLock
(
);
/* Null-terminate the string */
if
(
dst
)
...
...
@@ -426,6 +485,15 @@ DWORD WINAPI ExpandEnvironmentStringsW( LPCWSTR src, LPWSTR dst, DWORD len )
/***********************************************************************
* GetDOSEnvironment (KERNEL.131)
*/
SEGPTR
WINAPI
GetDOSEnvironment16
(
void
)
{
return
PTR_SEG_OFF_TO_SEGPTR
(
env_sel
,
0
);
}
/***********************************************************************
* GetStdHandle (KERNEL32.276)
*/
HANDLE
WINAPI
GetStdHandle
(
DWORD
std_handle
)
...
...
memory/selector.c
View file @
becb9a35
...
...
@@ -13,7 +13,6 @@
#include "miscemu.h"
#include "selectors.h"
#include "stackframe.h"
#include "process.h"
#include "server.h"
#include "debugtools.h"
#include "toolhelp.h"
...
...
@@ -296,7 +295,7 @@ DWORD WINAPI WIN16_GetSelectorBase( WORD sel )
*/
DWORD
base
=
GetSelectorBase
(
sel
);
return
W32S_WINE2APP
(
base
,
W32S_APPLICATION
()
?
W32S_OFFSET
:
0
);
return
W32S_WINE2APP
(
base
);
}
DWORD
WINAPI
GetSelectorBase
(
WORD
sel
)
{
...
...
@@ -320,8 +319,7 @@ DWORD WINAPI WIN16_SetSelectorBase( WORD sel, DWORD base )
* See the comment in msdos/vxd.c.
*/
SetSelectorBase
(
sel
,
W32S_APP2WINE
(
base
,
W32S_APPLICATION
()
?
W32S_OFFSET
:
0
)
);
SetSelectorBase
(
sel
,
W32S_APP2WINE
(
base
)
);
return
sel
;
}
WORD
WINAPI
SetSelectorBase
(
WORD
sel
,
DWORD
base
)
...
...
memory/virtual.c
View file @
becb9a35
...
...
@@ -28,7 +28,6 @@
#include "wine/port.h"
#include "winerror.h"
#include "file.h"
#include "process.h"
#include "global.h"
#include "server.h"
#include "debugtools.h"
...
...
misc/version.c
View file @
becb9a35
...
...
@@ -15,7 +15,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "wine/winbase16.h"
#include "
process
.h"
#include "
module
.h"
#include "options.h"
#include "debugtools.h"
#include "winerror.h"
...
...
@@ -259,26 +259,15 @@ static DWORD VERSION_GetSystemDLLVersion( HMODULE hmod )
* 5.12/5.00/5.00/4.00 Win98 calc
* x.xx/5.00/5.00/4.00 win95/win98/NT4 IE5 files
*/
DWORD
VERSION_GetLinkedDllVersion
(
PDB
*
pdb
)
DWORD
VERSION_GetLinkedDllVersion
(
void
)
{
WINE_MODREF
*
wm
;
DWORD
WinVersion
=
NB_WINDOWS_VERSIONS
;
PIMAGE_OPTIONAL_HEADER
ophd
;
if
(
!
pdb
->
exe_modref
)
{
if
(
!
pdb
->
modref_list
)
return
WIN31
;
/* FIXME: The above condition will never trigger, since all our
* standard dlls load their win32 equivalents. We have usually at
* this point: kernel32.dll and ntdll.dll.
*/
return
WIN95
;
}
/* First check the native dlls provided. These have to be
from one windows version */
for
(
wm
=
pdb
->
modref_list
;
wm
;
wm
=
wm
->
next
)
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
wm
->
next
)
{
ophd
=
&
(
PE_HEADER
(
wm
->
module
)
->
OptionalHeader
);
...
...
@@ -319,10 +308,9 @@ DWORD VERSION_GetLinkedDllVersion(PDB *pdb)
if
(
WinVersion
!=
NB_WINDOWS_VERSIONS
)
return
WinVersion
;
/* we are using no external system dlls, look at the exe */
ophd
=
&
(
PE_HEADER
(
pdb
->
exe_modref
->
module
)
->
OptionalHeader
);
ophd
=
&
(
PE_HEADER
(
GetModuleHandleA
(
NULL
)
)
->
OptionalHeader
);
TRACE
(
"-%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x
\n
"
,
pdb
->
exe_modref
->
modname
,
TRACE
(
"%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x
\n
"
,
ophd
->
MajorLinkerVersion
,
ophd
->
MinorLinkerVersion
,
ophd
->
MajorOperatingSystemVersion
,
ophd
->
MinorOperatingSystemVersion
,
ophd
->
MajorImageVersion
,
ophd
->
MinorImageVersion
,
...
...
@@ -373,7 +361,7 @@ static WINDOWS_VERSION VERSION_GetVersion(void)
return
defaultWinVersion
;
if
(
winver
==
0xffff
)
/* to be determined */
{
WINDOWS_VERSION
retver
=
VERSION_GetLinkedDllVersion
(
PROCESS_Current
()
);
WINDOWS_VERSION
retver
=
VERSION_GetLinkedDllVersion
();
if
(
retver
!=
WIN31
)
winver
=
retver
;
return
retver
;
...
...
miscemu/main.c
View file @
becb9a35
...
...
@@ -11,9 +11,10 @@
#include "callback.h"
#include "options.h"
#include "dosexe.h"
#include "process.h"
#include "debugtools.h"
extern
void
PROCESS_InitWine
(
int
argc
,
char
*
argv
[]
)
WINE_NORETURN
;
/***********************************************************************
* Main loop of initial task
*/
...
...
msdos/dpmi.c
View file @
becb9a35
...
...
@@ -19,7 +19,6 @@
#include "task.h"
#include "toolhelp.h"
#include "selectors.h"
#include "process.h"
#include "callback.h"
#include "debugtools.h"
...
...
@@ -698,8 +697,6 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
* shifted by 0x10000 relative to the OS linear address space.
* See the comment in msdos/vxd.c.
*/
DWORD
offset
=
W32S_APPLICATION
()
?
W32S_OFFSET
:
0
;
DWORD
dw
;
BYTE
*
ptr
;
...
...
@@ -814,16 +811,16 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
}
else
{
CX_reg
(
context
)
=
HIWORD
(
W32S_WINE2APP
(
dw
,
offset
));
DX_reg
(
context
)
=
LOWORD
(
W32S_WINE2APP
(
dw
,
offset
));
CX_reg
(
context
)
=
HIWORD
(
W32S_WINE2APP
(
dw
));
DX_reg
(
context
)
=
LOWORD
(
W32S_WINE2APP
(
dw
));
}
break
;
case
0x0007
:
/* Set selector base address */
TRACE
(
"set selector base address (0x%04x,0x%08lx)
\n
"
,
BX_reg
(
context
),
W32S_APP2WINE
(
MAKELONG
(
DX_reg
(
context
),
CX_reg
(
context
))
,
offset
));
dw
=
W32S_APP2WINE
(
MAKELONG
(
DX_reg
(
context
),
CX_reg
(
context
))
,
offset
);
W32S_APP2WINE
(
MAKELONG
(
DX_reg
(
context
),
CX_reg
(
context
))));
dw
=
W32S_APP2WINE
(
MAKELONG
(
DX_reg
(
context
),
CX_reg
(
context
)));
if
(
dw
<
0x10000
)
/* app wants to access lower 64K of DOS memory, map it in now */
DOSMEM_Init
(
TRUE
);
...
...
@@ -854,7 +851,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
TRACE
(
"get descriptor (0x%04x)
\n
"
,
BX_reg
(
context
));
{
LDT_ENTRY
entry
;
wine_ldt_set_base
(
&
entry
,
(
void
*
)
W32S_WINE2APP
(
wine_ldt_get_base
(
&
entry
)
,
offset
)
);
wine_ldt_set_base
(
&
entry
,
(
void
*
)
W32S_WINE2APP
(
wine_ldt_get_base
(
&
entry
))
);
/* FIXME: should use ES:EDI for 32-bit clients */
*
(
LDT_ENTRY
*
)
PTR_SEG_OFF_TO_LIN
(
context
->
SegEs
,
LOWORD
(
context
->
Edi
)
)
=
entry
;
}
...
...
@@ -865,7 +862,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
{
LDT_ENTRY
entry
=
*
(
LDT_ENTRY
*
)
PTR_SEG_OFF_TO_LIN
(
context
->
SegEs
,
LOWORD
(
context
->
Edi
)
);
wine_ldt_set_base
(
&
entry
,
(
void
*
)
W32S_APP2WINE
(
wine_ldt_get_base
(
&
entry
)
,
offset
)
);
wine_ldt_set_base
(
&
entry
,
(
void
*
)
W32S_APP2WINE
(
wine_ldt_get_base
(
&
entry
))
);
wine_ldt_set_entry
(
LOWORD
(
context
->
Ebx
),
&
entry
);
}
break
;
...
...
@@ -994,31 +991,30 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
AX_reg
(
context
)
=
0x8012
;
/* linear memory not available */
SET_CFLAG
(
context
);
}
else
{
BX_reg
(
context
)
=
SI_reg
(
context
)
=
HIWORD
(
W32S_WINE2APP
(
ptr
,
offset
));
CX_reg
(
context
)
=
DI_reg
(
context
)
=
LOWORD
(
W32S_WINE2APP
(
ptr
,
offset
));
BX_reg
(
context
)
=
SI_reg
(
context
)
=
HIWORD
(
W32S_WINE2APP
(
ptr
));
CX_reg
(
context
)
=
DI_reg
(
context
)
=
LOWORD
(
W32S_WINE2APP
(
ptr
));
}
break
;
case
0x0502
:
/* Free memory block */
TRACE
(
"free memory block (0x%08lx)
\n
"
,
W32S_APP2WINE
(
MAKELONG
(
DI_reg
(
context
),
SI_reg
(
context
)),
offset
));
DPMI_xfree
(
(
void
*
)
W32S_APP2WINE
(
MAKELONG
(
DI_reg
(
context
),
SI_reg
(
context
)),
offset
)
);
W32S_APP2WINE
(
MAKELONG
(
DI_reg
(
context
),
SI_reg
(
context
))));
DPMI_xfree
(
(
void
*
)
W32S_APP2WINE
(
MAKELONG
(
DI_reg
(
context
),
SI_reg
(
context
)))
);
break
;
case
0x0503
:
/* Resize memory block */
TRACE
(
"resize memory block (0x%08lx,%ld)
\n
"
,
W32S_APP2WINE
(
MAKELONG
(
DI_reg
(
context
),
SI_reg
(
context
))
,
offset
),
W32S_APP2WINE
(
MAKELONG
(
DI_reg
(
context
),
SI_reg
(
context
))),
MAKELONG
(
CX_reg
(
context
),
BX_reg
(
context
)));
if
(
!
(
ptr
=
(
BYTE
*
)
DPMI_xrealloc
(
(
void
*
)
W32S_APP2WINE
(
MAKELONG
(
DI_reg
(
context
),
SI_reg
(
context
))
,
offset
),
(
void
*
)
W32S_APP2WINE
(
MAKELONG
(
DI_reg
(
context
),
SI_reg
(
context
))),
MAKELONG
(
CX_reg
(
context
),
BX_reg
(
context
)))))
{
AX_reg
(
context
)
=
0x8012
;
/* linear memory not available */
SET_CFLAG
(
context
);
}
else
{
BX_reg
(
context
)
=
SI_reg
(
context
)
=
HIWORD
(
W32S_WINE2APP
(
ptr
,
offset
));
CX_reg
(
context
)
=
DI_reg
(
context
)
=
LOWORD
(
W32S_WINE2APP
(
ptr
,
offset
));
BX_reg
(
context
)
=
SI_reg
(
context
)
=
HIWORD
(
W32S_WINE2APP
(
ptr
));
CX_reg
(
context
)
=
DI_reg
(
context
)
=
LOWORD
(
W32S_WINE2APP
(
ptr
));
}
break
;
...
...
@@ -1065,8 +1061,8 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
}
else
{
BX_reg
(
context
)
=
HIWORD
(
W32S_WINE2APP
(
ptr
,
offset
));
CX_reg
(
context
)
=
LOWORD
(
W32S_WINE2APP
(
ptr
,
offset
));
BX_reg
(
context
)
=
HIWORD
(
W32S_WINE2APP
(
ptr
));
CX_reg
(
context
)
=
LOWORD
(
W32S_WINE2APP
(
ptr
));
RESET_CFLAG
(
context
);
}
break
;
...
...
msdos/vxd.c
View file @
becb9a35
...
...
@@ -16,9 +16,9 @@
#include "wine/winuser16.h"
#include "msdos.h"
#include "miscemu.h"
#include "module.h"
#include "selectors.h"
#include "task.h"
#include "process.h"
#include "file.h"
#include "debugtools.h"
...
...
@@ -33,6 +33,7 @@ DEFAULT_DEBUG_CHANNEL(vxd);
CX_reg(context), DX_reg(context), SI_reg(context), \
DI_reg(context), (WORD)context->SegDs, (WORD)context->SegEs )
UINT
W32S_offset
=
0
;
static
WORD
VXD_WinVersion
(
void
)
{
...
...
@@ -515,10 +516,8 @@ void WINAPI VXD_APM ( CONTEXT86 *context )
* any routine apart from those, e.g. some other VxD handler, that code
* would have to take the offset into account as well!)
*
* The application of the offset is triggered by marking the current process
* as a Win32s process by setting the PDB32_WIN32S_PROC flag in the process
* database. This is done the first time any application calls the GetVersion()
* service of the Win32s VxD. (Note that the flag is never removed.)
* The offset is set the first time any application calls the GetVersion()
* service of the Win32s VxD. (Note that the offset is never reset.)
*
*/
...
...
@@ -596,7 +595,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* performance of Win32s.
*/
if
(
!
(
PROCESS_Current
()
->
flags
&
PDB32_WIN32S_PROC
)
)
if
(
!
W32S_offset
)
{
HMODULE16
hModule
=
GetModuleHandle16
(
"win32s16"
);
SEGPTR
func1
=
(
SEGPTR
)
GetProcAddress16
(
hModule
,
"SetFS"
);
...
...
@@ -633,9 +632,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Mark process as Win32s, so that subsequent DPMI calls
* will perform the W32S_APP2WINE/W32S_WINE2APP address shift.
*/
PROCESS_Current
()
->
flags
|=
PDB32_WIN32S_PROC
;
break
;
W32S_offset
=
0x10000
;
break
;
case
0x0001
:
/* Install Exception Handling */
...
...
@@ -743,7 +741,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
*/
struct
Win32sModule
*
moduleTable
=
(
struct
Win32sModule
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
(
struct
Win32sModule
*
)
W32S_APP2WINE
(
context
->
Edx
);
struct
Win32sModule
*
module
=
moduleTable
+
context
->
Ecx
;
IMAGE_NT_HEADERS
*
nt_header
=
PE_HEADER
(
module
->
baseAddr
);
...
...
@@ -835,7 +833,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: 1 if OK
*/
TRACE
(
"UnMapModule: %lx
\n
"
,
(
DWORD
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
));
TRACE
(
"UnMapModule: %lx
\n
"
,
(
DWORD
)
W32S_APP2WINE
(
context
->
Edx
));
/* As we didn't map anything, there's nothing to unmap ... */
...
...
@@ -858,9 +856,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]);
DWORD
size
=
stack
[
2
];
DWORD
type
=
stack
[
3
];
DWORD
prot
=
stack
[
4
];
...
...
@@ -883,8 +881,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
result
=
(
DWORD
)
VirtualAlloc
(
base
,
size
,
type
,
prot
);
if
(
W32S_WINE2APP
(
result
,
W32S_OFFSET
))
*
retv
=
W32S_WINE2APP
(
result
,
W32S_OFFSET
),
if
(
W32S_WINE2APP
(
result
))
*
retv
=
W32S_WINE2APP
(
result
),
context
->
Eax
=
STATUS_SUCCESS
;
else
*
retv
=
0
,
...
...
@@ -907,9 +905,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]);
DWORD
size
=
stack
[
2
];
DWORD
type
=
stack
[
3
];
DWORD
result
;
...
...
@@ -944,12 +942,12 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]);
DWORD
size
=
stack
[
2
];
DWORD
new_prot
=
stack
[
3
];
DWORD
*
old_prot
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
4
]
,
W32S_OFFSET
);
DWORD
*
old_prot
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
4
]);
DWORD
result
;
TRACE
(
"VirtualProtect(%lx, %lx, %lx, %lx, %lx)
\n
"
,
...
...
@@ -981,11 +979,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]);
LPMEMORY_BASIC_INFORMATION
info
=
(
LPMEMORY_BASIC_INFORMATION
)
W32S_APP2WINE
(
stack
[
2
]
,
W32S_OFFSET
);
(
LPMEMORY_BASIC_INFORMATION
)
W32S_APP2WINE
(
stack
[
2
]);
DWORD
len
=
stack
[
3
];
DWORD
result
;
...
...
@@ -1064,11 +1062,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
HANDLE
*
retv
=
(
HANDLE
*
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
HANDLE
*
retv
=
(
HANDLE
*
)
W32S_APP2WINE
(
stack
[
0
]);
DWORD
flags1
=
stack
[
1
];
DWORD
atom
=
stack
[
2
];
LARGE_INTEGER
*
size
=
(
LARGE_INTEGER
*
)
W32S_APP2WINE
(
stack
[
3
]
,
W32S_OFFSET
);
LARGE_INTEGER
*
size
=
(
LARGE_INTEGER
*
)
W32S_APP2WINE
(
stack
[
3
]);
DWORD
protect
=
stack
[
4
];
DWORD
flags2
=
stack
[
5
];
HANDLE
hFile
=
DosFileHandleToWin32Handle
(
stack
[
6
]);
...
...
@@ -1117,8 +1115,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
HANDLE
*
retv
=
(
HANDLE
*
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
HANDLE
*
retv
=
(
HANDLE
*
)
W32S_APP2WINE
(
stack
[
0
]);
DWORD
protect
=
stack
[
1
];
DWORD
atom
=
stack
[
2
];
...
...
@@ -1160,9 +1158,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
HANDLE
handle
=
stack
[
0
];
DWORD
*
id
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
DWORD
*
id
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
1
]);
TRACE
(
"NtCloseSection(%lx, %lx)
\n
"
,
(
DWORD
)
handle
,
(
DWORD
)
id
);
...
...
@@ -1183,7 +1181,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
HANDLE
handle
=
stack
[
0
];
HANDLE
new_handle
;
...
...
@@ -1215,20 +1213,20 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
HANDLE
SectionHandle
=
stack
[
0
];
DWORD
ProcessHandle
=
stack
[
1
];
/* ignored */
DWORD
*
BaseAddress
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
2
]
,
W32S_OFFSET
);
DWORD
*
BaseAddress
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
2
]);
DWORD
ZeroBits
=
stack
[
3
];
DWORD
CommitSize
=
stack
[
4
];
LARGE_INTEGER
*
SectionOffset
=
(
LARGE_INTEGER
*
)
W32S_APP2WINE
(
stack
[
5
]
,
W32S_OFFSET
);
DWORD
*
ViewSize
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
6
]
,
W32S_OFFSET
);
LARGE_INTEGER
*
SectionOffset
=
(
LARGE_INTEGER
*
)
W32S_APP2WINE
(
stack
[
5
]);
DWORD
*
ViewSize
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
6
]);
DWORD
InheritDisposition
=
stack
[
7
];
DWORD
AllocationType
=
stack
[
8
];
DWORD
Protect
=
stack
[
9
];
LPBYTE
address
=
(
LPBYTE
)(
BaseAddress
?
W32S_APP2WINE
(
*
BaseAddress
,
W32S_OFFSET
)
:
0
);
W32S_APP2WINE
(
*
BaseAddress
)
:
0
);
DWORD
access
=
0
,
result
;
switch
(
Protect
&
~
(
PAGE_GUARD
|
PAGE_NOCACHE
))
...
...
@@ -1259,9 +1257,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
TRACE
(
"NtMapViewOfSection: result=%lx
\n
"
,
result
);
if
(
W32S_WINE2APP
(
result
,
W32S_OFFSET
))
if
(
W32S_WINE2APP
(
result
))
{
if
(
BaseAddress
)
*
BaseAddress
=
W32S_WINE2APP
(
result
,
W32S_OFFSET
);
if
(
BaseAddress
)
*
BaseAddress
=
W32S_WINE2APP
(
result
);
context
->
Eax
=
STATUS_SUCCESS
;
}
else
...
...
@@ -1280,9 +1278,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
DWORD
ProcessHandle
=
stack
[
0
];
/* ignored */
LPBYTE
BaseAddress
=
(
LPBYTE
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
LPBYTE
BaseAddress
=
(
LPBYTE
)
W32S_APP2WINE
(
stack
[
1
]);
TRACE
(
"NtUnmapViewOfSection(%lx, %lx)
\n
"
,
ProcessHandle
,
(
DWORD
)
BaseAddress
);
...
...
@@ -1306,13 +1304,13 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
DWORD
ProcessHandle
=
stack
[
0
];
/* ignored */
DWORD
*
BaseAddress
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
DWORD
*
ViewSize
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
2
]
,
W32S_OFFSET
);
DWORD
*
unknown
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
3
]
,
W32S_OFFSET
);
DWORD
*
BaseAddress
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
1
]);
DWORD
*
ViewSize
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
2
]);
DWORD
*
unknown
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
3
]);
LPBYTE
address
=
(
LPBYTE
)(
BaseAddress
?
W32S_APP2WINE
(
*
BaseAddress
,
W32S_OFFSET
)
:
0
);
LPBYTE
address
=
(
LPBYTE
)(
BaseAddress
?
W32S_APP2WINE
(
*
BaseAddress
)
:
0
);
DWORD
size
=
ViewSize
?
*
ViewSize
:
0
;
TRACE
(
"NtFlushVirtualMemory(%lx, %lx, %lx, %lx)
\n
"
,
...
...
@@ -1413,9 +1411,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]);
DWORD
size
=
stack
[
2
];
DWORD
result
;
...
...
@@ -1447,9 +1445,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: EAX: NtStatus
*/
{
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
,
W32S_OFFSET
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]
,
W32S_OFFSET
);
DWORD
*
stack
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Edx
);
DWORD
*
retv
=
(
DWORD
*
)
W32S_APP2WINE
(
stack
[
0
]);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
1
]);
DWORD
size
=
stack
[
2
];
DWORD
result
;
...
...
@@ -1487,8 +1485,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* FIXME: What about other OSes ?
*/
context
->
Ecx
=
W32S_WINE2APP
(
0x00000000
,
W32S_OFFSET
);
context
->
Edx
=
W32S_WINE2APP
(
0xbfffffff
,
W32S_OFFSET
);
context
->
Ecx
=
W32S_WINE2APP
(
0x00000000
);
context
->
Edx
=
W32S_WINE2APP
(
0xbfffffff
);
break
;
...
...
@@ -1511,7 +1509,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
};
struct
Win32sMemoryInfo
*
info
=
(
struct
Win32sMemoryInfo
*
)
W32S_APP2WINE
(
context
->
Esi
,
W32S_OFFSET
);
(
struct
Win32sMemoryInfo
*
)
W32S_APP2WINE
(
context
->
Esi
);
FIXME
(
"KGlobalMemStat(%lx)
\n
"
,
(
DWORD
)
info
);
...
...
@@ -1548,7 +1546,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
{
DWORD
*
stack
=
PTR_SEG_OFF_TO_LIN
(
LOWORD
(
context
->
Edx
),
HIWORD
(
context
->
Edx
));
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
0
]);
DWORD
size
=
stack
[
1
];
DWORD
type
=
stack
[
2
];
DWORD
prot
=
stack
[
3
];
...
...
@@ -1565,8 +1563,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
result
=
(
DWORD
)
VirtualAlloc
(
base
,
size
,
type
,
prot
);
if
(
W32S_WINE2APP
(
result
,
W32S_OFFSET
))
context
->
Edx
=
W32S_WINE2APP
(
result
,
W32S_OFFSET
),
if
(
W32S_WINE2APP
(
result
))
context
->
Edx
=
W32S_WINE2APP
(
result
),
context
->
Eax
=
STATUS_SUCCESS
;
else
context
->
Edx
=
0
,
...
...
@@ -1590,7 +1588,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
{
DWORD
*
stack
=
PTR_SEG_OFF_TO_LIN
(
LOWORD
(
context
->
Edx
),
HIWORD
(
context
->
Edx
));
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
0
]
,
W32S_OFFSET
);
LPVOID
base
=
(
LPVOID
)
W32S_APP2WINE
(
stack
[
0
]);
DWORD
size
=
stack
[
1
];
DWORD
type
=
stack
[
2
];
DWORD
result
;
...
...
@@ -1620,7 +1618,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
* Output: NtStatus
*/
{
DWORD
*
ptr
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Ecx
,
W32S_OFFSET
);
DWORD
*
ptr
=
(
DWORD
*
)
W32S_APP2WINE
(
context
->
Ecx
);
BOOL
set
=
context
->
Edx
;
TRACE
(
"FWorkingSetSize(%lx, %lx)
\n
"
,
(
DWORD
)
ptr
,
(
DWORD
)
set
);
...
...
relay32/relay386.c
View file @
becb9a35
...
...
@@ -16,7 +16,6 @@
#include "syslevel.h"
#include "main.h"
#include "module.h"
#include "process.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL
(
relay
);
...
...
@@ -114,7 +113,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
/* First find the module */
for
(
wm
=
PROCESS_Current
()
->
modref_list
;
wm
;
wm
=
wm
->
next
)
for
(
wm
=
MODULE_
modref_list
;
wm
;
wm
=
wm
->
next
)
{
if
(
!
(
wm
->
flags
&
WINE_MODREF_INTERNAL
))
continue
;
base
=
(
char
*
)
wm
->
module
;
...
...
scheduler/client.c
View file @
becb9a35
...
...
@@ -31,7 +31,6 @@
#include <stdarg.h>
#include "wine/port.h"
#include "process.h"
#include "thread.h"
#include "server.h"
#include "winerror.h"
...
...
scheduler/process.c
View file @
becb9a35
...
...
@@ -15,7 +15,6 @@
#include "wine/winbase16.h"
#include "wine/exception.h"
#include "wine/library.h"
#include "process.h"
#include "drive.h"
#include "main.h"
#include "module.h"
...
...
@@ -35,15 +34,80 @@ DEFAULT_DEBUG_CHANNEL(process);
DECLARE_DEBUG_CHANNEL
(
relay
);
DECLARE_DEBUG_CHANNEL
(
win32
);
struct
_ENVDB
;
/* Win32 process database */
typedef
struct
_PDB
{
LONG
header
[
2
];
/* 00 Kernel object header */
HMODULE
module
;
/* 08 Main exe module (NT) */
void
*
event
;
/* 0c Pointer to an event object (unused) */
DWORD
exit_code
;
/* 10 Process exit code */
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
;
PDB
current_process
;
/* Process flags */
#define PDB32_DEBUGGED 0x0001
/* Process is being debugged */
#define PDB32_WIN16_PROC 0x0008
/* Win16 process */
#define PDB32_DOS_PROC 0x0010
/* Dos process */
#define PDB32_CONSOLE_PROC 0x0020
/* Console process */
#define PDB32_FILE_APIS_OEM 0x0040
/* File APIs are OEM */
#define PDB32_WIN32S_PROC 0x8000
/* Win32s process */
static
char
**
main_exe_argv
;
static
char
main_exe_name
[
MAX_PATH
];
static
HANDLE
main_exe_file
=
INVALID_HANDLE_VALUE
;
static
HMODULE
main_module
;
unsigned
int
server_startticks
;
/* memory/environ.c */
extern
struct
_ENVDB
*
ENV_BuildEnvironment
(
void
);
extern
BOOL
ENV_BuildCommandLine
(
char
**
argv
);
extern
STARTUPINFOA
current_startupinfo
;
/***********************************************************************
* PROCESS_CallUserSignalProc
*
...
...
@@ -178,7 +242,6 @@ static BOOL process_init( char *argv[] )
current_process
.
ring0_threads
=
1
;
current_process
.
group
=
&
current_process
;
current_process
.
priority
=
8
;
/* Normal */
current_process
.
env_db
=
&
current_envdb
;
/* Setup the server connection */
NtCurrentTeb
()
->
socket
=
CLIENT_InitServer
();
...
...
@@ -201,9 +264,12 @@ static BOOL process_init( char *argv[] )
current_startupinfo
.
dwFlags
=
req
->
start_flags
;
server_startticks
=
req
->
server_start
;
current_startupinfo
.
wShowWindow
=
req
->
cmd_show
;
current_envdb
.
hStdin
=
current_startupinfo
.
hStdInput
=
req
->
hstdin
;
current_envdb
.
hStdout
=
current_startupinfo
.
hStdOutput
=
req
->
hstdout
;
current_envdb
.
hStderr
=
current_startupinfo
.
hStdError
=
req
->
hstderr
;
current_startupinfo
.
hStdInput
=
req
->
hstdin
;
current_startupinfo
.
hStdOutput
=
req
->
hstdout
;
current_startupinfo
.
hStdError
=
req
->
hstderr
;
SetStdHandle
(
STD_INPUT_HANDLE
,
current_startupinfo
.
hStdInput
);
SetStdHandle
(
STD_OUTPUT_HANDLE
,
current_startupinfo
.
hStdOutput
);
SetStdHandle
(
STD_ERROR_HANDLE
,
current_startupinfo
.
hStdError
);
}
}
SERVER_END_REQ
;
...
...
@@ -214,10 +280,7 @@ static BOOL process_init( char *argv[] )
current_process
.
heap
=
HeapCreate
(
HEAP_GROWABLE
,
0
,
0
);
/* Copy the parent environment */
if
(
!
ENV_BuildEnvironment
())
return
FALSE
;
/* Initialize the critical sections */
InitializeCriticalSection
(
&
current_process
.
crit_section
);
if
(
!
(
current_process
.
env_db
=
ENV_BuildEnvironment
()))
return
FALSE
;
/* Parse command line arguments */
OPTIONS_ParseOptions
(
argv
);
...
...
@@ -227,45 +290,6 @@ static BOOL process_init( char *argv[] )
/***********************************************************************
* build_command_line
*
* Build the command line of a process from the argv array.
*
* Note that it does NOT necessarily include the file name.
* Sometimes we don't even have any command line options at all.
*/
static
inline
char
*
build_command_line
(
char
**
argv
)
{
int
len
,
quote
=
0
;
char
*
cmdline
,
*
p
,
**
arg
;
for
(
arg
=
argv
,
len
=
0
;
*
arg
;
arg
++
)
len
+=
strlen
(
*
arg
)
+
1
;
if
((
argv
[
0
])
&&
(
quote
=
(
strchr
(
argv
[
0
],
' '
)
!=
NULL
)))
len
+=
2
;
if
(
!
(
p
=
cmdline
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
)))
return
NULL
;
arg
=
argv
;
if
(
quote
)
{
*
p
++
=
'\"'
;
strcpy
(
p
,
*
arg
);
p
+=
strlen
(
p
);
*
p
++
=
'\"'
;
*
p
++
=
' '
;
arg
++
;
}
while
(
*
arg
)
{
strcpy
(
p
,
*
arg
);
p
+=
strlen
(
p
);
*
p
++
=
' '
;
arg
++
;
}
if
(
p
>
cmdline
)
p
--
;
/* remove last space */
*
p
=
0
;
return
cmdline
;
}
/***********************************************************************
* start_process
*
* Startup routine of a new process. Runs on the new process stack.
...
...
@@ -277,10 +301,10 @@ static void start_process(void)
WINE_MODREF
*
wm
;
/* build command line */
if
(
!
(
current_envdb
.
cmd_line
=
build_command_line
(
main_exe_argv
)
))
goto
error
;
if
(
!
ENV_BuildCommandLine
(
main_exe_argv
))
goto
error
;
/* create 32-bit module for main exe */
if
(
!
(
main_module
=
BUILTIN32_LoadExeModule
(
main_
module
)))
goto
error
;
if
(
!
(
current_process
.
module
=
BUILTIN32_LoadExeModule
(
current_process
.
module
)))
goto
error
;
/* use original argv[0] as name for the main module */
if
(
!
main_exe_name
[
0
])
...
...
@@ -290,16 +314,16 @@ static void start_process(void)
}
/* Retrieve entry point address */
entry
=
(
LPTHREAD_START_ROUTINE
)((
char
*
)
main_
module
+
PE_HEADER
(
main_
module
)
->
OptionalHeader
.
AddressOfEntryPoint
);
console_app
=
(
PE_HEADER
(
main_
module
)
->
OptionalHeader
.
Subsystem
==
IMAGE_SUBSYSTEM_WINDOWS_CUI
);
entry
=
(
LPTHREAD_START_ROUTINE
)((
char
*
)
current_process
.
module
+
PE_HEADER
(
current_process
.
module
)
->
OptionalHeader
.
AddressOfEntryPoint
);
console_app
=
(
PE_HEADER
(
current_process
.
module
)
->
OptionalHeader
.
Subsystem
==
IMAGE_SUBSYSTEM_WINDOWS_CUI
);
if
(
console_app
)
current_process
.
flags
|=
PDB32_CONSOLE_PROC
;
/* Signal the parent process to continue */
SERVER_START_REQ
{
struct
init_process_done_request
*
req
=
server_alloc_req
(
sizeof
(
*
req
),
0
);
req
->
module
=
(
void
*
)
main_
module
;
req
->
module
=
(
void
*
)
current_process
.
module
;
req
->
entry
=
entry
;
req
->
name
=
main_exe_name
;
req
->
gui
=
!
console_app
;
...
...
@@ -314,14 +338,14 @@ static void start_process(void)
if
(
!
SIGNAL_Init
())
goto
error
;
/* create the main modref and load dependencies */
if
(
!
(
wm
=
PE_CreateModule
(
main_
module
,
main_exe_name
,
0
,
main_exe_file
,
FALSE
)))
if
(
!
(
wm
=
PE_CreateModule
(
current_process
.
module
,
main_exe_name
,
0
,
main_exe_file
,
FALSE
)))
goto
error
;
wm
->
refCount
++
;
EnterCriticalSection
(
&
current_process
.
crit_section
);
RtlAcquirePebLock
(
);
PE_InitTls
();
MODULE_DllProcessAttach
(
current_process
.
exe_modref
,
(
LPVOID
)
1
);
LeaveCriticalSection
(
&
current_process
.
crit_section
);
MODULE_DllProcessAttach
(
NULL
,
(
LPVOID
)
1
);
RtlReleasePebLock
(
);
/* Get pointers to USER routines called by KERNEL */
THUNK_InitCallout
();
...
...
@@ -344,7 +368,7 @@ static void start_process(void)
/* Call UserSignalProc ( USIG_PROCESS_RUNNING ... ) only for non-GUI win32 apps */
if
(
console_app
)
PROCESS_CallUserSignalProc
(
USIG_PROCESS_RUNNING
,
0
);
TRACE_
(
relay
)(
"Starting Win32 process %s (entryproc=%p)
\n
"
,
current_process
.
exe_modref
->
file
name
,
entry
);
TRACE_
(
relay
)(
"Starting Win32 process %s (entryproc=%p)
\n
"
,
main_exe_
name
,
entry
);
if
(
debugged
)
DbgBreakPoint
();
/* FIXME: should use _PEB as parameter for NT 3.5 programs !
* Dunno about other OSs */
...
...
@@ -443,11 +467,11 @@ void PROCESS_InitWine( int argc, char *argv[] )
}
/* first try Win32 format; this will fail if the file is not a PE binary */
if
((
main_
module
=
PE_LoadImage
(
main_exe_file
,
main_exe_name
,
0
)))
if
((
current_process
.
module
=
PE_LoadImage
(
main_exe_file
,
main_exe_name
,
0
)))
{
if
(
PE_HEADER
(
main_
module
)
->
FileHeader
.
Characteristics
&
IMAGE_FILE_DLL
)
if
(
PE_HEADER
(
current_process
.
module
)
->
FileHeader
.
Characteristics
&
IMAGE_FILE_DLL
)
ExitProcess
(
ERROR_BAD_EXE_FORMAT
);
stack_size
=
PE_HEADER
(
main_
module
)
->
OptionalHeader
.
SizeOfStackReserve
;
stack_size
=
PE_HEADER
(
current_process
.
module
)
->
OptionalHeader
.
SizeOfStackReserve
;
goto
found
;
}
...
...
@@ -1367,6 +1391,115 @@ UINT WINAPI SetErrorMode( UINT mode )
return
old
;
}
/**********************************************************************
* TlsAlloc [KERNEL32.530] Allocates a TLS index.
*
* Allocates a thread local storage index
*
* RETURNS
* Success: TLS Index
* Failure: 0xFFFFFFFF
*/
DWORD
WINAPI
TlsAlloc
(
void
)
{
DWORD
i
,
mask
,
ret
=
0
;
DWORD
*
bits
=
current_process
.
tls_bits
;
RtlAcquirePebLock
();
if
(
*
bits
==
0xffffffff
)
{
bits
++
;
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
();
return
ret
+
i
;
}
/**********************************************************************
* TlsFree [KERNEL32.531] Releases a TLS index.
*
* Releases a thread local storage index, making it available for reuse
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL
WINAPI
TlsFree
(
DWORD
index
)
/* [in] TLS Index to free */
{
DWORD
mask
=
(
1
<<
(
index
&
31
));
DWORD
*
bits
=
current_process
.
tls_bits
;
if
(
index
>=
64
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
if
(
index
>=
32
)
bits
++
;
RtlAcquirePebLock
();
if
(
!
(
*
bits
&
mask
))
/* already free? */
{
RtlReleasePebLock
();
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
*
bits
&=
~
mask
;
NtCurrentTeb
()
->
tls_array
[
index
]
=
0
;
/* FIXME: should zero all other thread values */
RtlReleasePebLock
();
return
TRUE
;
}
/**********************************************************************
* TlsGetValue [KERNEL32.532] Gets value in a thread's TLS slot
*
* RETURNS
* Success: Value stored in calling thread's TLS slot for index
* Failure: 0 and GetLastError returns NO_ERROR
*/
LPVOID
WINAPI
TlsGetValue
(
DWORD
index
)
/* [in] TLS index to retrieve value for */
{
if
(
index
>=
64
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
}
SetLastError
(
ERROR_SUCCESS
);
return
NtCurrentTeb
()
->
tls_array
[
index
];
}
/**********************************************************************
* TlsSetValue [KERNEL32.533] Stores a value in the thread's TLS slot.
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL
WINAPI
TlsSetValue
(
DWORD
index
,
/* [in] TLS index to set value for */
LPVOID
value
)
/* [in] Value to be stored */
{
if
(
index
>=
64
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
NtCurrentTeb
()
->
tls_array
[
index
]
=
value
;
return
TRUE
;
}
/***********************************************************************
* GetCurrentProcess (KERNEL32.198)
*/
...
...
scheduler/thread.c
View file @
becb9a35
...
...
@@ -15,7 +15,6 @@
#include <unistd.h>
#include "wine/winbase16.h"
#include "thread.h"
#include "process.h"
#include "task.h"
#include "module.h"
#include "global.h"
...
...
@@ -35,6 +34,8 @@ DEFAULT_DEBUG_CHANNEL(thread);
/* TEB of the initial thread */
static
TEB
initial_teb
;
extern
struct
_PDB
current_process
;
/***********************************************************************
* THREAD_IsWin16
*/
...
...
@@ -239,8 +240,8 @@ TEB *THREAD_Create( int fd, DWORD stack_size, BOOL alloc_stack16 )
if
((
teb
=
THREAD_InitStack
(
NULL
,
stack_size
,
alloc_stack16
)))
{
teb
->
tibflags
=
(
current_process
.
flags
&
PDB32_WIN16_PROC
)
?
0
:
TEBF_WIN32
;
teb
->
process
=
&
current_
process
;
teb
->
tibflags
=
TEBF_WIN32
;
teb
->
process
=
NtCurrentTeb
()
->
process
;
teb
->
socket
=
fd
;
fcntl
(
fd
,
F_SETFD
,
1
);
/* set close on exec flag */
TRACE
(
"(%p) succeeded
\n
"
,
teb
);
...
...
@@ -304,7 +305,6 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
close
(
socket
);
return
0
;
}
teb
->
tibflags
|=
TEBF_WIN32
;
teb
->
entry_point
=
start
;
teb
->
entry_arg
=
param
;
teb
->
startup
=
THREAD_Start
;
...
...
@@ -379,115 +379,6 @@ void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */
}
/**********************************************************************
* TlsAlloc [KERNEL32.530] Allocates a TLS index.
*
* Allocates a thread local storage index
*
* RETURNS
* Success: TLS Index
* Failure: 0xFFFFFFFF
*/
DWORD
WINAPI
TlsAlloc
(
void
)
{
DWORD
i
,
mask
,
ret
=
0
;
DWORD
*
bits
=
current_process
.
tls_bits
;
EnterCriticalSection
(
&
current_process
.
crit_section
);
if
(
*
bits
==
0xffffffff
)
{
bits
++
;
ret
=
32
;
if
(
*
bits
==
0xffffffff
)
{
LeaveCriticalSection
(
&
current_process
.
crit_section
);
SetLastError
(
ERROR_NO_MORE_ITEMS
);
return
0xffffffff
;
}
}
for
(
i
=
0
,
mask
=
1
;
i
<
32
;
i
++
,
mask
<<=
1
)
if
(
!
(
*
bits
&
mask
))
break
;
*
bits
|=
mask
;
LeaveCriticalSection
(
&
current_process
.
crit_section
);
return
ret
+
i
;
}
/**********************************************************************
* TlsFree [KERNEL32.531] Releases a TLS index.
*
* Releases a thread local storage index, making it available for reuse
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL
WINAPI
TlsFree
(
DWORD
index
)
/* [in] TLS Index to free */
{
DWORD
mask
;
DWORD
*
bits
=
current_process
.
tls_bits
;
if
(
index
>=
64
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
EnterCriticalSection
(
&
current_process
.
crit_section
);
if
(
index
>=
32
)
bits
++
;
mask
=
(
1
<<
(
index
&
31
));
if
(
!
(
*
bits
&
mask
))
/* already free? */
{
LeaveCriticalSection
(
&
current_process
.
crit_section
);
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
*
bits
&=
~
mask
;
NtCurrentTeb
()
->
tls_array
[
index
]
=
0
;
/* FIXME: should zero all other thread values */
LeaveCriticalSection
(
&
current_process
.
crit_section
);
return
TRUE
;
}
/**********************************************************************
* TlsGetValue [KERNEL32.532] Gets value in a thread's TLS slot
*
* RETURNS
* Success: Value stored in calling thread's TLS slot for index
* Failure: 0 and GetLastError returns NO_ERROR
*/
LPVOID
WINAPI
TlsGetValue
(
DWORD
index
)
/* [in] TLS index to retrieve value for */
{
if
(
index
>=
64
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
NULL
;
}
SetLastError
(
ERROR_SUCCESS
);
return
NtCurrentTeb
()
->
tls_array
[
index
];
}
/**********************************************************************
* TlsSetValue [KERNEL32.533] Stores a value in the thread's TLS slot.
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL
WINAPI
TlsSetValue
(
DWORD
index
,
/* [in] TLS index to set value for */
LPVOID
value
)
/* [in] Value to be stored */
{
if
(
index
>=
64
)
{
SetLastError
(
ERROR_INVALID_PARAMETER
);
return
FALSE
;
}
NtCurrentTeb
()
->
tls_array
[
index
]
=
value
;
return
TRUE
;
}
/***********************************************************************
* SetThreadContext [KERNEL32.670] Sets context of thread.
*
...
...
win32/console.c
View file @
becb9a35
...
...
@@ -43,7 +43,6 @@
#include "wine/keyboard16.h"
#include "thread.h"
#include "file.h"
#include "process.h"
#include "winerror.h"
#include "wincon.h"
#include "heap.h"
...
...
win32/device.c
View file @
becb9a35
...
...
@@ -27,7 +27,6 @@
#include "winreg.h"
#include "winerror.h"
#include "file.h"
#include "process.h"
#include "heap.h"
#include "winioctl.h"
#include "winnt.h"
...
...
win32/except.c
View file @
becb9a35
...
...
@@ -29,7 +29,6 @@
#include "wine/exception.h"
#include "selectors.h"
#include "callback.h"
#include "process.h"
#include "thread.h"
#include "stackframe.h"
#include "server.h"
...
...
@@ -37,6 +36,8 @@
DEFAULT_DEBUG_CHANNEL
(
seh
);
static
PTOP_LEVEL_EXCEPTION_FILTER
top_filter
;
/*******************************************************************
* RaiseException (KERNEL32.418)
...
...
@@ -143,7 +144,6 @@ static void format_exception_msg( const EXCEPTION_POINTERS *ptr, char *buffer )
*/
DWORD
WINAPI
UnhandledExceptionFilter
(
PEXCEPTION_POINTERS
epointers
)
{
PDB
*
pdb
=
PROCESS_Current
();
char
format
[
256
];
char
buffer
[
256
];
HKEY
hDbgConf
;
...
...
@@ -179,9 +179,9 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
FIXME
(
"Unsupported yet debug continue value %d (please report)
\n
"
,
status
);
}
if
(
pdb
->
top_filter
)
if
(
top_filter
)
{
DWORD
ret
=
pdb
->
top_filter
(
epointers
);
DWORD
ret
=
top_filter
(
epointers
);
if
(
ret
!=
EXCEPTION_CONTINUE_SEARCH
)
return
ret
;
}
...
...
@@ -265,9 +265,8 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
LPTOP_LEVEL_EXCEPTION_FILTER
WINAPI
SetUnhandledExceptionFilter
(
LPTOP_LEVEL_EXCEPTION_FILTER
filter
)
{
PDB
*
pdb
=
PROCESS_Current
();
LPTOP_LEVEL_EXCEPTION_FILTER
old
=
pdb
->
top_filter
;
pdb
->
top_filter
=
filter
;
LPTOP_LEVEL_EXCEPTION_FILTER
old
=
top_filter
;
top_filter
=
filter
;
return
old
;
}
...
...
win32/file.c
View file @
becb9a35
...
...
@@ -23,7 +23,6 @@
#include "winbase.h"
#include "winerror.h"
#include "file.h"
#include "process.h"
#include "heap.h"
#include "debugtools.h"
...
...
windows/user.c
View file @
becb9a35
...
...
@@ -24,7 +24,7 @@
#include "sysmetrics.h"
#include "callback.h"
#include "local.h"
#include "
process
.h"
#include "
module
.h"
#include "debugtools.h"
DECLARE_DEBUG_CHANNEL
(
hook
);
...
...
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