mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-06 15:55:03 +00:00
Moved all Wine internal definitions out of process.h.
This commit is contained in:
parent
2a37decc39
commit
becb9a353b
|
@ -25,7 +25,6 @@
|
||||||
*/
|
*/
|
||||||
#include "crtdll.h"
|
#include "crtdll.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "process.h"
|
|
||||||
|
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(crtdll);
|
DEFAULT_DEBUG_CHANNEL(crtdll);
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
* -File handles need some special handling. Sometimes children get
|
* -File handles need some special handling. Sometimes children get
|
||||||
* open file handles, sometimes not. The docs are confusing.
|
* open file handles, sometimes not. The docs are confusing.
|
||||||
* -No check for maximum path/argument/environment size is done.
|
* -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:
|
* Unresolved issues Uwe Bonnes 970904:
|
||||||
* -system-call calls another wine process, but without debugging arguments
|
* -system-call calls another wine process, but without debugging arguments
|
||||||
* and uses the first wine executable in the path
|
* and uses the first wine executable in the path
|
||||||
|
@ -40,7 +39,6 @@
|
||||||
|
|
||||||
#include "crtdll.h"
|
#include "crtdll.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "process.h"
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "crtdll.h"
|
#include "crtdll.h"
|
||||||
#include "process.h"
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "wine/winbase16.h"
|
#include "wine/winbase16.h"
|
||||||
|
#include "ntddk.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
#include "process.h"
|
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(thunk);
|
DEFAULT_DEBUG_CHANNEL(thunk);
|
||||||
|
@ -51,6 +51,8 @@ typedef struct _UTINFO
|
||||||
|
|
||||||
} UTINFO;
|
} UTINFO;
|
||||||
|
|
||||||
|
static UTINFO *UT_head; /* head of Universal Thunk list */
|
||||||
|
|
||||||
typedef DWORD (CALLBACK *UTGLUEPROC)( LPVOID lpBuff, DWORD dwUserDefined );
|
typedef DWORD (CALLBACK *UTGLUEPROC)( LPVOID lpBuff, DWORD dwUserDefined );
|
||||||
|
|
||||||
BOOL WINAPI UTRegister( HMODULE hModule, LPSTR lpsz16BITDLL,
|
BOOL WINAPI UTRegister( HMODULE hModule, LPSTR lpsz16BITDLL,
|
||||||
|
@ -173,8 +175,8 @@ static UTINFO *UTAlloc( HMODULE hModule, HMODULE16 hModule16,
|
||||||
ut->ut32.jmp = 0xe9;
|
ut->ut32.jmp = 0xe9;
|
||||||
ut->ut32.utglue32 = (DWORD)UTGlue32 - ((DWORD)&ut->ut32.utglue32 + sizeof(DWORD));
|
ut->ut32.utglue32 = (DWORD)UTGlue32 - ((DWORD)&ut->ut32.utglue32 + sizeof(DWORD));
|
||||||
|
|
||||||
ut->next = PROCESS_Current()->UTState;
|
ut->next = UT_head;
|
||||||
PROCESS_Current()->UTState = ut;
|
UT_head = ut;
|
||||||
|
|
||||||
return ut;
|
return ut;
|
||||||
}
|
}
|
||||||
|
@ -186,7 +188,7 @@ static void UTFree( UTINFO *ut )
|
||||||
{
|
{
|
||||||
UTINFO **ptr;
|
UTINFO **ptr;
|
||||||
|
|
||||||
for ( ptr = &PROCESS_Current()->UTState; *ptr; ptr = &(*ptr)->next )
|
for ( ptr = &UT_head; *ptr; ptr = &(*ptr)->next )
|
||||||
if ( *ptr == ut )
|
if ( *ptr == ut )
|
||||||
{
|
{
|
||||||
*ptr = ut->next;
|
*ptr = ut->next;
|
||||||
|
@ -203,7 +205,7 @@ static UTINFO *UTFind( HMODULE hModule )
|
||||||
{
|
{
|
||||||
UTINFO *ut;
|
UTINFO *ut;
|
||||||
|
|
||||||
for ( ut = PROCESS_Current()->UTState; ut; ut =ut->next )
|
for ( ut = UT_head; ut; ut =ut->next )
|
||||||
if ( ut->hModule == hModule )
|
if ( ut->hModule == hModule )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -231,12 +233,12 @@ BOOL WINAPI UTRegister( HMODULE hModule, LPSTR lpsz16BITDLL,
|
||||||
|
|
||||||
/* Allocate UTINFO struct */
|
/* Allocate UTINFO struct */
|
||||||
|
|
||||||
EnterCriticalSection( &PROCESS_Current()->crit_section );
|
RtlAcquirePebLock();
|
||||||
if ( (ut = UTFind( hModule )) != NULL )
|
if ( (ut = UTFind( hModule )) != NULL )
|
||||||
ut = NULL;
|
ut = NULL;
|
||||||
else
|
else
|
||||||
ut = UTAlloc( hModule, hModule16, target16, pfnUT32CallBack );
|
ut = UTAlloc( hModule, hModule16, target16, pfnUT32CallBack );
|
||||||
LeaveCriticalSection( &PROCESS_Current()->crit_section );
|
RtlReleasePebLock();
|
||||||
|
|
||||||
if ( !ut )
|
if ( !ut )
|
||||||
{
|
{
|
||||||
|
@ -276,14 +278,14 @@ VOID WINAPI UTUnRegister( HMODULE hModule )
|
||||||
UTINFO *ut;
|
UTINFO *ut;
|
||||||
HMODULE16 hModule16 = 0;
|
HMODULE16 hModule16 = 0;
|
||||||
|
|
||||||
EnterCriticalSection( &PROCESS_Current()->crit_section );
|
RtlAcquirePebLock();
|
||||||
ut = UTFind( hModule );
|
ut = UTFind( hModule );
|
||||||
if ( !ut )
|
if ( !ut )
|
||||||
{
|
{
|
||||||
hModule16 = ut->hModule16;
|
hModule16 = ut->hModule16;
|
||||||
UTFree( ut );
|
UTFree( ut );
|
||||||
}
|
}
|
||||||
LeaveCriticalSection( &PROCESS_Current()->crit_section );
|
RtlReleasePebLock();
|
||||||
|
|
||||||
if ( hModule16 )
|
if ( hModule16 )
|
||||||
FreeLibrary16( hModule16 );
|
FreeLibrary16( hModule16 );
|
||||||
|
|
|
@ -51,6 +51,7 @@ INSTALLED_INCLUDES = \
|
||||||
oledlg.h \
|
oledlg.h \
|
||||||
oleidl.h \
|
oleidl.h \
|
||||||
poppack.h \
|
poppack.h \
|
||||||
|
process.h \
|
||||||
prsht.h \
|
prsht.h \
|
||||||
psapi.h \
|
psapi.h \
|
||||||
pshpack1.h \
|
pshpack1.h \
|
||||||
|
|
|
@ -26,10 +26,10 @@
|
||||||
#define PTR_SEG_OFF_TO_HUGEPTR(seg,off) \
|
#define PTR_SEG_OFF_TO_HUGEPTR(seg,off) \
|
||||||
PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << __AHSHIFT), LOWORD(off) )
|
PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << __AHSHIFT), LOWORD(off) )
|
||||||
|
|
||||||
#define W32S_APPLICATION() (PROCESS_Current()->flags & PDB32_WIN32S_PROC)
|
extern UINT W32S_offset;
|
||||||
#define W32S_OFFSET 0x10000
|
|
||||||
#define W32S_APP2WINE(addr, offset) ((addr)? (DWORD)(addr) + (DWORD)(offset) : 0)
|
#define W32S_APP2WINE(addr) ((addr)? (DWORD)(addr) + W32S_offset : 0)
|
||||||
#define W32S_WINE2APP(addr, offset) ((addr)? (DWORD)(addr) - (DWORD)(offset) : 0)
|
#define W32S_WINE2APP(addr) ((addr)? (DWORD)(addr) - W32S_offset : 0)
|
||||||
|
|
||||||
#define FIRST_LDT_ENTRY_TO_ALLOC 17
|
#define FIRST_LDT_ENTRY_TO_ALLOC 17
|
||||||
|
|
||||||
|
|
|
@ -140,6 +140,7 @@ typedef struct _wine_modref
|
||||||
#define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
|
#define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
|
||||||
#define WINE_MODREF_MARKER 0x80000000
|
#define WINE_MODREF_MARKER 0x80000000
|
||||||
|
|
||||||
|
extern WINE_MODREF *MODULE_modref_list;
|
||||||
|
|
||||||
/* Resource types */
|
/* Resource types */
|
||||||
|
|
||||||
|
@ -231,4 +232,33 @@ extern HMODULE BUILTIN32_LoadExeModule( HMODULE main );
|
||||||
extern void *BUILTIN32_dlopen( const char *name );
|
extern void *BUILTIN32_dlopen( const char *name );
|
||||||
extern int BUILTIN32_dlclose( void *handle );
|
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 */
|
#endif /* __WINE_MODULE_H */
|
||||||
|
|
|
@ -4,165 +4,8 @@
|
||||||
* Copyright 1996 Alexandre Julliard
|
* Copyright 1996 Alexandre Julliard
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __WINE_PROCESS_H
|
#ifndef _INC_PROCESS
|
||||||
#define __WINE_PROCESS_H
|
#define _INC_PROCESS
|
||||||
|
|
||||||
#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 ¤t_process;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* definitions contained in Windows process.h file */
|
|
||||||
/* FIXME: all the stuff above should be moved somewhere else */
|
|
||||||
|
|
||||||
typedef void (*LPBEGINTHREAD)(LPVOID);
|
typedef void (*LPBEGINTHREAD)(LPVOID);
|
||||||
typedef UINT (WINAPI *LPBEGINTHREADEX)(LPVOID);
|
typedef UINT (WINAPI *LPBEGINTHREADEX)(LPVOID);
|
||||||
|
@ -172,4 +15,4 @@ void _endthread(void);
|
||||||
ULONG _beginthreadex(LPVOID,UINT,LPBEGINTHREADEX,LPVOID,UINT,LPUINT);
|
ULONG _beginthreadex(LPVOID,UINT,LPBEGINTHREADEX,LPVOID,UINT,LPUINT);
|
||||||
void _endthreadex(UINT);
|
void _endthreadex(UINT);
|
||||||
|
|
||||||
#endif /* __WINE_PROCESS_H */
|
#endif /* _INC_PROCESS */
|
||||||
|
|
|
@ -1880,13 +1880,33 @@ typedef struct tagSYSLEVEL
|
||||||
INT level;
|
INT level;
|
||||||
} SYSLEVEL;
|
} 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);
|
void WINAPI DisposeLZ32Handle(HANDLE);
|
||||||
HANDLE WINAPI DosFileHandleToWin32Handle(HFILE);
|
HANDLE WINAPI DosFileHandleToWin32Handle(HFILE);
|
||||||
|
DWORD WINAPI GetProcessDword(DWORD,INT);
|
||||||
VOID WINAPI GetpWin16Lock(SYSLEVEL**);
|
VOID WINAPI GetpWin16Lock(SYSLEVEL**);
|
||||||
DWORD WINAPI MapLS(LPCVOID);
|
DWORD WINAPI MapLS(LPCVOID);
|
||||||
|
DWORD WINAPI MapProcessHandle(HANDLE);
|
||||||
LPVOID WINAPI MapSL(DWORD);
|
LPVOID WINAPI MapSL(DWORD);
|
||||||
VOID WINAPI ReleaseThunkLock(DWORD*);
|
VOID WINAPI ReleaseThunkLock(DWORD*);
|
||||||
VOID WINAPI RestoreThunkLock(DWORD);
|
VOID WINAPI RestoreThunkLock(DWORD);
|
||||||
|
void WINAPI SetProcessDword(DWORD,INT,DWORD);
|
||||||
VOID WINAPI UnMapLS(DWORD);
|
VOID WINAPI UnMapLS(DWORD);
|
||||||
HFILE WINAPI Win32HandleToDosFileHandle(HANDLE);
|
HFILE WINAPI Win32HandleToDosFileHandle(HANDLE);
|
||||||
DWORD WINAPI _ConfirmWin16Lock(void);
|
DWORD WINAPI _ConfirmWin16Lock(void);
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "ldt.h"
|
#include "ldt.h"
|
||||||
#include "process.h"
|
|
||||||
#include "miscemu.h"
|
#include "miscemu.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
#include "dosexe.h"
|
#include "dosexe.h"
|
||||||
|
|
|
@ -17,7 +17,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "snoop.h"
|
#include "snoop.h"
|
||||||
#include "process.h"
|
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "process.h"
|
#include "module.h"
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
|
@ -25,6 +25,10 @@
|
||||||
DEFAULT_DEBUG_CHANNEL(module);
|
DEFAULT_DEBUG_CHANNEL(module);
|
||||||
DECLARE_DEBUG_CHANNEL(win32);
|
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
|
* MODULE32_LookupHMODULE
|
||||||
|
@ -36,14 +40,14 @@ static WINE_MODREF *MODULE32_LookupHMODULE( HMODULE hmod )
|
||||||
WINE_MODREF *wm;
|
WINE_MODREF *wm;
|
||||||
|
|
||||||
if (!hmod)
|
if (!hmod)
|
||||||
return PROCESS_Current()->exe_modref;
|
return exe_modref;
|
||||||
|
|
||||||
if (!HIWORD(hmod)) {
|
if (!HIWORD(hmod)) {
|
||||||
ERR("tried to lookup 0x%04x in win32 module handler!\n",hmod);
|
ERR("tried to lookup 0x%04x in win32 module handler!\n",hmod);
|
||||||
SetLastError( ERROR_INVALID_HANDLE );
|
SetLastError( ERROR_INVALID_HANDLE );
|
||||||
return NULL;
|
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)
|
if (wm->module == hmod)
|
||||||
return wm;
|
return wm;
|
||||||
SetLastError( ERROR_INVALID_HANDLE );
|
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++;
|
if ((wm->short_modname = strrchr( wm->short_filename, '\\' ))) wm->short_modname++;
|
||||||
else wm->short_modname = wm->short_filename;
|
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;
|
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;
|
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
|
* list after the attach notification has returned. This implies that the
|
||||||
* detach notifications are called in the reverse of the sequence the attach
|
* detach notifications are called in the reverse of the sequence the attach
|
||||||
* notifications *returned*.
|
* notifications *returned*.
|
||||||
*
|
|
||||||
* NOTE: Assumes that the process critical section is held!
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
|
BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
|
||||||
{
|
{
|
||||||
BOOL retv = TRUE;
|
BOOL retv = TRUE;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
|
if (!wm) wm = exe_modref;
|
||||||
assert( wm );
|
assert( wm );
|
||||||
|
|
||||||
/* prevent infinite recursion in case of cyclical dependencies */
|
/* prevent infinite recursion in case of cyclical dependencies */
|
||||||
if ( ( wm->flags & WINE_MODREF_MARKER )
|
if ( ( wm->flags & WINE_MODREF_MARKER )
|
||||||
|| ( wm->flags & WINE_MODREF_PROCESS_ATTACHED ) )
|
|| ( wm->flags & WINE_MODREF_PROCESS_ATTACHED ) )
|
||||||
return retv;
|
goto done;
|
||||||
|
|
||||||
TRACE("(%s,%p) - START\n", wm->modname, lpReserved );
|
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;
|
if ( wm->next ) wm->next->prev = wm->prev;
|
||||||
|
|
||||||
wm->prev = NULL;
|
wm->prev = NULL;
|
||||||
wm->next = PROCESS_Current()->modref_list;
|
wm->next = MODULE_modref_list;
|
||||||
PROCESS_Current()->modref_list = wm->next->prev = wm;
|
MODULE_modref_list = wm->next->prev = wm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Remove recursion flag */
|
/* Remove recursion flag */
|
||||||
|
@ -188,6 +199,8 @@ BOOL MODULE_DllProcessAttach( WINE_MODREF *wm, LPVOID lpReserved )
|
||||||
|
|
||||||
TRACE("(%s,%p) - END\n", wm->modname, lpReserved );
|
TRACE("(%s,%p) - END\n", wm->modname, lpReserved );
|
||||||
|
|
||||||
|
done:
|
||||||
|
RtlReleasePebLock();
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,11 +215,11 @@ void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved )
|
||||||
{
|
{
|
||||||
WINE_MODREF *wm;
|
WINE_MODREF *wm;
|
||||||
|
|
||||||
EnterCriticalSection( &PROCESS_Current()->crit_section );
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
do
|
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 */
|
/* Check whether to detach this DLL */
|
||||||
if ( !(wm->flags & WINE_MODREF_PROCESS_ATTACHED) )
|
if ( !(wm->flags & WINE_MODREF_PROCESS_ATTACHED) )
|
||||||
|
@ -224,7 +237,7 @@ void MODULE_DllProcessDetach( BOOL bForceDetach, LPVOID lpReserved )
|
||||||
}
|
}
|
||||||
} while ( wm );
|
} while ( wm );
|
||||||
|
|
||||||
LeaveCriticalSection( &PROCESS_Current()->crit_section );
|
RtlReleasePebLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
|
@ -238,9 +251,9 @@ void MODULE_DllThreadAttach( LPVOID lpReserved )
|
||||||
{
|
{
|
||||||
WINE_MODREF *wm;
|
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 )
|
if ( !wm->next )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -254,7 +267,7 @@ void MODULE_DllThreadAttach( LPVOID lpReserved )
|
||||||
MODULE_InitDLL( wm, DLL_THREAD_ATTACH, 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;
|
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) )
|
if ( !(wm->flags & WINE_MODREF_PROCESS_ATTACHED) )
|
||||||
continue;
|
continue;
|
||||||
|
@ -280,7 +293,7 @@ void MODULE_DllThreadDetach( LPVOID lpReserved )
|
||||||
MODULE_InitDLL( wm, DLL_THREAD_DETACH, 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;
|
WINE_MODREF *wm;
|
||||||
BOOL retval = TRUE;
|
BOOL retval = TRUE;
|
||||||
|
|
||||||
EnterCriticalSection( &PROCESS_Current()->crit_section );
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
wm = MODULE32_LookupHMODULE( hModule );
|
wm = MODULE32_LookupHMODULE( hModule );
|
||||||
if ( !wm )
|
if ( !wm )
|
||||||
|
@ -301,7 +314,7 @@ BOOL WINAPI DisableThreadLibraryCalls( HMODULE hModule )
|
||||||
else
|
else
|
||||||
wm->flags |= WINE_MODREF_NO_DLL_CALLS;
|
wm->flags |= WINE_MODREF_NO_DLL_CALLS;
|
||||||
|
|
||||||
LeaveCriticalSection( &PROCESS_Current()->crit_section );
|
RtlReleasePebLock();
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -432,7 +445,7 @@ WINE_MODREF *MODULE_FindModule(
|
||||||
if (!(p = strrchr( dllname, '.')) || strchr( p, '/' ) || strchr( p, '\\'))
|
if (!(p = strrchr( dllname, '.')) || strchr( p, '/' ) || strchr( p, '\\'))
|
||||||
strcat( dllname, ".DLL" );
|
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 ) )
|
if ( !FILE_strcasecmp( dllname, wm->modname ) )
|
||||||
break;
|
break;
|
||||||
|
@ -1155,7 +1168,7 @@ HMODULE WINAPI GetModuleHandleA(LPCSTR module)
|
||||||
WINE_MODREF *wm;
|
WINE_MODREF *wm;
|
||||||
|
|
||||||
if ( module == NULL )
|
if ( module == NULL )
|
||||||
wm = PROCESS_Current()->exe_modref;
|
wm = exe_modref;
|
||||||
else
|
else
|
||||||
wm = MODULE_FindModule( module );
|
wm = MODULE_FindModule( module );
|
||||||
|
|
||||||
|
@ -1190,13 +1203,13 @@ DWORD WINAPI GetModuleFileNameA(
|
||||||
{
|
{
|
||||||
WINE_MODREF *wm;
|
WINE_MODREF *wm;
|
||||||
|
|
||||||
EnterCriticalSection( &PROCESS_Current()->crit_section );
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
lpFileName[0] = 0;
|
lpFileName[0] = 0;
|
||||||
if ((wm = MODULE32_LookupHMODULE( hModule )))
|
if ((wm = MODULE32_LookupHMODULE( hModule )))
|
||||||
lstrcpynA( lpFileName, wm->filename, size );
|
lstrcpynA( lpFileName, wm->filename, size );
|
||||||
|
|
||||||
LeaveCriticalSection( &PROCESS_Current()->crit_section );
|
RtlReleasePebLock();
|
||||||
TRACE("%s\n", lpFileName );
|
TRACE("%s\n", lpFileName );
|
||||||
return strlen(lpFileName);
|
return strlen(lpFileName);
|
||||||
}
|
}
|
||||||
|
@ -1249,7 +1262,7 @@ HMODULE WINAPI LoadLibraryExA(LPCSTR libname, HANDLE hfile, DWORD flags)
|
||||||
return hmod;
|
return hmod;
|
||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&PROCESS_Current()->crit_section);
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
wm = MODULE_LoadLibraryExA( libname, hfile, flags );
|
wm = MODULE_LoadLibraryExA( libname, hfile, flags );
|
||||||
if ( wm )
|
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;
|
return wm ? wm->module : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1323,7 +1335,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
|
||||||
strcat( filename, ".DLL" );
|
strcat( filename, ".DLL" );
|
||||||
}
|
}
|
||||||
|
|
||||||
EnterCriticalSection(&PROCESS_Current()->crit_section);
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
/* Check for already loaded module */
|
/* Check for already loaded module */
|
||||||
if (!(pwm = MODULE_FindModule(filename)) &&
|
if (!(pwm = MODULE_FindModule(filename)) &&
|
||||||
|
@ -1361,7 +1373,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
|
||||||
fixup_imports( pwm );
|
fixup_imports( pwm );
|
||||||
}
|
}
|
||||||
TRACE("Already loaded module '%s' at 0x%08x, count=%d, \n", filename, pwm->module, pwm->refCount);
|
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 );
|
HeapFree ( GetProcessHeap(), 0, filename );
|
||||||
return pwm;
|
return pwm;
|
||||||
}
|
}
|
||||||
|
@ -1407,7 +1419,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
|
||||||
/* decrement the dependencies through the MODULE_FreeLibrary call. */
|
/* decrement the dependencies through the MODULE_FreeLibrary call. */
|
||||||
pwm->refCount++;
|
pwm->refCount++;
|
||||||
|
|
||||||
LeaveCriticalSection(&PROCESS_Current()->crit_section);
|
RtlReleasePebLock();
|
||||||
SetLastError( err ); /* restore last error */
|
SetLastError( err ); /* restore last error */
|
||||||
HeapFree ( GetProcessHeap(), 0, filename );
|
HeapFree ( GetProcessHeap(), 0, filename );
|
||||||
return pwm;
|
return pwm;
|
||||||
|
@ -1417,7 +1429,7 @@ WINE_MODREF *MODULE_LoadLibraryExA( LPCSTR libname, HFILE hfile, DWORD flags )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LeaveCriticalSection(&PROCESS_Current()->crit_section);
|
RtlReleasePebLock();
|
||||||
error:
|
error:
|
||||||
WARN("Failed to load module '%s'; error=0x%08lx, \n", filename, GetLastError());
|
WARN("Failed to load module '%s'; error=0x%08lx, \n", filename, GetLastError());
|
||||||
HeapFree ( GetProcessHeap(), 0, filename );
|
HeapFree ( GetProcessHeap(), 0, filename );
|
||||||
|
@ -1477,7 +1489,7 @@ static void MODULE_FlushModrefs(void)
|
||||||
{
|
{
|
||||||
WINE_MODREF *wm, *next;
|
WINE_MODREF *wm, *next;
|
||||||
|
|
||||||
for(wm = PROCESS_Current()->modref_list; wm; wm = next)
|
for(wm = MODULE_modref_list; wm; wm = next)
|
||||||
{
|
{
|
||||||
next = wm->next;
|
next = wm->next;
|
||||||
|
|
||||||
|
@ -1489,8 +1501,8 @@ static void MODULE_FlushModrefs(void)
|
||||||
wm->next->prev = wm->prev;
|
wm->next->prev = wm->prev;
|
||||||
if(wm->prev)
|
if(wm->prev)
|
||||||
wm->prev->next = wm->next;
|
wm->prev->next = wm->next;
|
||||||
if(wm == PROCESS_Current()->modref_list)
|
if(wm == MODULE_modref_list)
|
||||||
PROCESS_Current()->modref_list = wm->next;
|
MODULE_modref_list = wm->next;
|
||||||
|
|
||||||
TRACE(" unloading %s\n", wm->filename);
|
TRACE(" unloading %s\n", wm->filename);
|
||||||
/* VirtualFree( (LPVOID)wm->module, 0, MEM_RELEASE ); */ /* FIXME */
|
/* VirtualFree( (LPVOID)wm->module, 0, MEM_RELEASE ); */ /* FIXME */
|
||||||
|
@ -1511,8 +1523,8 @@ BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
|
||||||
BOOL retv = FALSE;
|
BOOL retv = FALSE;
|
||||||
WINE_MODREF *wm;
|
WINE_MODREF *wm;
|
||||||
|
|
||||||
EnterCriticalSection( &PROCESS_Current()->crit_section );
|
RtlAcquirePebLock();
|
||||||
PROCESS_Current()->free_lib_count++;
|
free_lib_count++;
|
||||||
|
|
||||||
wm = MODULE32_LookupHMODULE( hLibModule );
|
wm = MODULE32_LookupHMODULE( hLibModule );
|
||||||
if ( !wm || !hLibModule )
|
if ( !wm || !hLibModule )
|
||||||
|
@ -1520,8 +1532,8 @@ BOOL WINAPI FreeLibrary(HINSTANCE hLibModule)
|
||||||
else
|
else
|
||||||
retv = MODULE_FreeLibrary( wm );
|
retv = MODULE_FreeLibrary( wm );
|
||||||
|
|
||||||
PROCESS_Current()->free_lib_count--;
|
free_lib_count--;
|
||||||
LeaveCriticalSection( &PROCESS_Current()->crit_section );
|
RtlReleasePebLock();
|
||||||
|
|
||||||
return retv;
|
return retv;
|
||||||
}
|
}
|
||||||
|
@ -1569,7 +1581,7 @@ BOOL MODULE_FreeLibrary( WINE_MODREF *wm )
|
||||||
MODULE_DecRefCount( wm );
|
MODULE_DecRefCount( wm );
|
||||||
|
|
||||||
/* Call process detach notifications */
|
/* Call process detach notifications */
|
||||||
if ( PROCESS_Current()->free_lib_count <= 1 )
|
if ( free_lib_count <= 1 )
|
||||||
{
|
{
|
||||||
MODULE_DllProcessDetach( FALSE, NULL );
|
MODULE_DllProcessDetach( FALSE, NULL );
|
||||||
SERVER_START_REQ
|
SERVER_START_REQ
|
||||||
|
@ -1700,13 +1712,13 @@ FARPROC MODULE_GetProcAddress(
|
||||||
else
|
else
|
||||||
TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
|
TRACE_(win32)("(%08lx,%p)\n",(DWORD)hModule,function);
|
||||||
|
|
||||||
EnterCriticalSection( &PROCESS_Current()->crit_section );
|
RtlAcquirePebLock();
|
||||||
if ((wm = MODULE32_LookupHMODULE( hModule )))
|
if ((wm = MODULE32_LookupHMODULE( hModule )))
|
||||||
{
|
{
|
||||||
retproc = wm->find_export( wm, function, snoop );
|
retproc = wm->find_export( wm, function, snoop );
|
||||||
if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
|
if (!retproc) SetLastError(ERROR_PROC_NOT_FOUND);
|
||||||
}
|
}
|
||||||
LeaveCriticalSection( &PROCESS_Current()->crit_section );
|
RtlReleasePebLock();
|
||||||
return retproc;
|
return retproc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "process.h"
|
|
||||||
#include "snoop.h"
|
#include "snoop.h"
|
||||||
#include "builtin16.h"
|
#include "builtin16.h"
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
|
@ -1073,6 +1072,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
|
||||||
if (hThread == -1) return 0;
|
if (hThread == -1) return 0;
|
||||||
|
|
||||||
if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error;
|
if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error;
|
||||||
|
teb->tibflags &= ~TEBF_WIN32;
|
||||||
teb->startup = NE_InitProcess;
|
teb->startup = NE_InitProcess;
|
||||||
|
|
||||||
/* Create a task for this process */
|
/* Create a task for this process */
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#endif
|
#endif
|
||||||
#include "wine/winbase16.h"
|
#include "wine/winbase16.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "process.h"
|
|
||||||
#include "snoop.h"
|
#include "snoop.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
@ -639,21 +638,6 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
|
||||||
if ( pe_export )
|
if ( pe_export )
|
||||||
dump_exports( hModule );
|
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 */
|
/* Fixup Imports */
|
||||||
|
|
||||||
if (!(wm->flags & WINE_MODREF_DONT_RESOLVE_REFS) && fixup_imports( wm ))
|
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 */
|
/* remove entry from modref chain */
|
||||||
|
|
||||||
if ( !wm->prev )
|
if ( !wm->prev )
|
||||||
PROCESS_Current()->modref_list = wm->next;
|
MODULE_modref_list = wm->next;
|
||||||
else
|
else
|
||||||
wm->prev->next = wm->next;
|
wm->prev->next = wm->next;
|
||||||
|
|
||||||
|
@ -791,7 +775,7 @@ void PE_InitTls( void )
|
||||||
PIMAGE_TLS_DIRECTORY pdir;
|
PIMAGE_TLS_DIRECTORY pdir;
|
||||||
int delta;
|
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);
|
peh = PE_HEADER(wm->module);
|
||||||
delta = wm->module - peh->OptionalHeader.ImageBase;
|
delta = wm->module - peh->OptionalHeader.ImageBase;
|
||||||
if (!peh->OptionalHeader.DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress)
|
if (!peh->OptionalHeader.DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress)
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "process.h"
|
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
#include "cursoricon.h"
|
#include "cursoricon.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "process.h"
|
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
|
@ -18,7 +18,6 @@
|
||||||
#include "instance.h"
|
#include "instance.h"
|
||||||
#include "miscemu.h"
|
#include "miscemu.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "process.h"
|
|
||||||
#include "queue.h"
|
#include "queue.h"
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
|
@ -283,17 +282,18 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
|
||||||
(int)&((PDB16 *)0)->fileHandles );
|
(int)&((PDB16 *)0)->fileHandles );
|
||||||
pTask->pdb.hFileHandles = 0;
|
pTask->pdb.hFileHandles = 0;
|
||||||
memset( pTask->pdb.fileHandles, 0xff, sizeof(pTask->pdb.fileHandles) );
|
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;
|
pTask->pdb.nbFiles = 20;
|
||||||
|
|
||||||
/* Fill the command line */
|
/* Fill the command line */
|
||||||
|
|
||||||
if (!cmdline)
|
if (!cmdline)
|
||||||
{
|
{
|
||||||
cmdline = current_envdb.cmd_line;
|
cmdline = GetCommandLineA();
|
||||||
/* remove the first word (program name) */
|
/* remove the first word (program name) */
|
||||||
if (*cmdline == '"')
|
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 != ' ') && (*cmdline != '\t')) cmdline++;
|
||||||
while ((*cmdline == ' ') || (*cmdline == '\t')) cmdline++;
|
while ((*cmdline == ' ') || (*cmdline == '\t')) cmdline++;
|
||||||
len = strlen(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,
|
pTask->hCSAlias = GLOBAL_CreateBlock( GMEM_FIXED, (void *)pTask,
|
||||||
sizeof(TDB), pTask->hPDB, WINE_LDT_FLAGS_CODE );
|
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 */
|
/* Default DTA overwrites command line */
|
||||||
|
|
||||||
pTask->dta = PTR_SEG_OFF_TO_SEGPTR( pTask->hPDB,
|
pTask->dta = PTR_SEG_OFF_TO_SEGPTR( pTask->hPDB,
|
||||||
|
@ -1319,18 +1315,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)
|
* GetNumTasks (KERNEL.152)
|
||||||
*/
|
*/
|
||||||
|
|
118
memory/environ.c
118
memory/environ.c
|
@ -9,10 +9,31 @@
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "winnls.h"
|
#include "winnls.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "process.h"
|
#include "ntddk.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "selectors.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:
|
/* Format of an environment block:
|
||||||
* ASCIIZ string 1 (xx=yy format)
|
* ASCIIZ string 1 (xx=yy format)
|
||||||
* ...
|
* ...
|
||||||
|
@ -79,12 +100,13 @@ ENVDB current_envdb =
|
||||||
0, /* break_sem */
|
0, /* break_sem */
|
||||||
0, /* break_event */
|
0, /* break_event */
|
||||||
0, /* break_thread */
|
0, /* break_thread */
|
||||||
0, /* break_handlers */
|
0 /* break_handlers */
|
||||||
CRITICAL_SECTION_INIT, /* section */
|
|
||||||
0, /* cmd_lineW */
|
|
||||||
0 /* env_sel */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static WCHAR *cmdlineW; /* Unicode command line */
|
||||||
|
static WORD env_sel; /* selector to the environment */
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* ENV_FindVariable
|
* ENV_FindVariable
|
||||||
*
|
*
|
||||||
|
@ -108,7 +130,7 @@ static LPCSTR ENV_FindVariable( LPCSTR env, LPCSTR name, INT len )
|
||||||
*
|
*
|
||||||
* Build the environment for the initial process
|
* Build the environment for the initial process
|
||||||
*/
|
*/
|
||||||
BOOL ENV_BuildEnvironment(void)
|
ENVDB *ENV_BuildEnvironment(void)
|
||||||
{
|
{
|
||||||
extern char **environ;
|
extern char **environ;
|
||||||
LPSTR p, *e;
|
LPSTR p, *e;
|
||||||
|
@ -121,9 +143,9 @@ BOOL ENV_BuildEnvironment(void)
|
||||||
|
|
||||||
/* Now allocate the environment */
|
/* 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.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 */
|
/* And fill it with the Unix environment */
|
||||||
|
|
||||||
|
@ -136,6 +158,50 @@ BOOL ENV_BuildEnvironment(void)
|
||||||
/* Now add the program name */
|
/* Now add the program name */
|
||||||
|
|
||||||
FILL_EXTRA_ENV( p );
|
FILL_EXTRA_ENV( p );
|
||||||
|
return ¤t_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;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,12 +219,7 @@ LPSTR WINAPI GetCommandLineA(void)
|
||||||
*/
|
*/
|
||||||
LPWSTR WINAPI GetCommandLineW(void)
|
LPWSTR WINAPI GetCommandLineW(void)
|
||||||
{
|
{
|
||||||
EnterCriticalSection( ¤t_envdb.section );
|
return cmdlineW;
|
||||||
if (!current_envdb.cmd_lineW)
|
|
||||||
current_envdb.cmd_lineW = HEAP_strdupAtoW( GetProcessHeap(), 0,
|
|
||||||
current_envdb.cmd_line );
|
|
||||||
LeaveCriticalSection( ¤t_envdb.section );
|
|
||||||
return current_envdb.cmd_lineW;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -179,7 +240,7 @@ LPWSTR WINAPI GetEnvironmentStringsW(void)
|
||||||
INT size;
|
INT size;
|
||||||
LPWSTR ret;
|
LPWSTR ret;
|
||||||
|
|
||||||
EnterCriticalSection( ¤t_envdb.section );
|
RtlAcquirePebLock();
|
||||||
size = HeapSize( GetProcessHeap(), 0, current_envdb.environ );
|
size = HeapSize( GetProcessHeap(), 0, current_envdb.environ );
|
||||||
if ((ret = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) )) != NULL)
|
if ((ret = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) )) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -187,7 +248,7 @@ LPWSTR WINAPI GetEnvironmentStringsW(void)
|
||||||
LPWSTR pW = ret;
|
LPWSTR pW = ret;
|
||||||
while (size--) *pW++ = (WCHAR)(BYTE)*pA++;
|
while (size--) *pW++ = (WCHAR)(BYTE)*pA++;
|
||||||
}
|
}
|
||||||
LeaveCriticalSection( ¤t_envdb.section );
|
RtlReleasePebLock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,7 +289,7 @@ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size )
|
||||||
SetLastError( ERROR_INVALID_PARAMETER );
|
SetLastError( ERROR_INVALID_PARAMETER );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
EnterCriticalSection( ¤t_envdb.section );
|
RtlAcquirePebLock();
|
||||||
if ((p = ENV_FindVariable( current_envdb.environ, name, strlen(name) )))
|
if ((p = ENV_FindVariable( current_envdb.environ, name, strlen(name) )))
|
||||||
{
|
{
|
||||||
ret = strlen(p);
|
ret = strlen(p);
|
||||||
|
@ -241,7 +302,7 @@ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size )
|
||||||
}
|
}
|
||||||
else if (value) strcpy( value, p );
|
else if (value) strcpy( value, p );
|
||||||
}
|
}
|
||||||
LeaveCriticalSection( ¤t_envdb.section );
|
RtlReleasePebLock();
|
||||||
if (!ret)
|
if (!ret)
|
||||||
SetLastError( ERROR_ENVVAR_NOT_FOUND );
|
SetLastError( ERROR_ENVVAR_NOT_FOUND );
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -276,7 +337,7 @@ BOOL WINAPI SetEnvironmentVariableA( LPCSTR name, LPCSTR value )
|
||||||
LPSTR p, env, new_env;
|
LPSTR p, env, new_env;
|
||||||
BOOL ret = FALSE;
|
BOOL ret = FALSE;
|
||||||
|
|
||||||
EnterCriticalSection( ¤t_envdb.section );
|
RtlAcquirePebLock();
|
||||||
env = p = current_envdb.environ;
|
env = p = current_envdb.environ;
|
||||||
|
|
||||||
/* Find a place to insert the string */
|
/* 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 )))
|
if (!(new_env = HeapReAlloc( GetProcessHeap(), 0, env, old_size + len )))
|
||||||
goto done;
|
goto done;
|
||||||
if (current_envdb.env_sel)
|
if (env_sel) env_sel = SELECTOR_ReallocBlock( env_sel, new_env, old_size + len );
|
||||||
current_envdb.env_sel = SELECTOR_ReallocBlock( current_envdb.env_sel,
|
|
||||||
new_env, old_size + len );
|
|
||||||
p = new_env + (p - env);
|
p = new_env + (p - env);
|
||||||
if (len > 0) memmove( p + len, p, old_size - (p - new_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;
|
ret = TRUE;
|
||||||
|
|
||||||
done:
|
done:
|
||||||
LeaveCriticalSection( ¤t_envdb.section );
|
RtlReleasePebLock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -350,7 +409,7 @@ DWORD WINAPI ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
|
||||||
LPCSTR p, var;
|
LPCSTR p, var;
|
||||||
|
|
||||||
if (!count) dst = NULL;
|
if (!count) dst = NULL;
|
||||||
EnterCriticalSection( ¤t_envdb.section );
|
RtlAcquirePebLock();
|
||||||
|
|
||||||
while (*src)
|
while (*src)
|
||||||
{
|
{
|
||||||
|
@ -395,7 +454,7 @@ DWORD WINAPI ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
|
||||||
count -= len;
|
count -= len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LeaveCriticalSection( ¤t_envdb.section );
|
RtlReleasePebLock();
|
||||||
|
|
||||||
/* Null-terminate the string */
|
/* Null-terminate the string */
|
||||||
if (dst)
|
if (dst)
|
||||||
|
@ -425,6 +484,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)
|
* GetStdHandle (KERNEL32.276)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include "miscemu.h"
|
#include "miscemu.h"
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
#include "process.h"
|
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
#include "toolhelp.h"
|
#include "toolhelp.h"
|
||||||
|
@ -296,7 +295,7 @@ DWORD WINAPI WIN16_GetSelectorBase( WORD sel )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
DWORD base = GetSelectorBase( sel );
|
DWORD base = GetSelectorBase( sel );
|
||||||
return W32S_WINE2APP( base, W32S_APPLICATION() ? W32S_OFFSET : 0 );
|
return W32S_WINE2APP( base );
|
||||||
}
|
}
|
||||||
DWORD WINAPI GetSelectorBase( WORD sel )
|
DWORD WINAPI GetSelectorBase( WORD sel )
|
||||||
{
|
{
|
||||||
|
@ -320,8 +319,7 @@ DWORD WINAPI WIN16_SetSelectorBase( WORD sel, DWORD base )
|
||||||
* See the comment in msdos/vxd.c.
|
* See the comment in msdos/vxd.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SetSelectorBase( sel,
|
SetSelectorBase( sel, W32S_APP2WINE( base ) );
|
||||||
W32S_APP2WINE( base, W32S_APPLICATION() ? W32S_OFFSET : 0 ) );
|
|
||||||
return sel;
|
return sel;
|
||||||
}
|
}
|
||||||
WORD WINAPI SetSelectorBase( WORD sel, DWORD base )
|
WORD WINAPI SetSelectorBase( WORD sel, DWORD base )
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "wine/port.h"
|
#include "wine/port.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "process.h"
|
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "wingdi.h"
|
#include "wingdi.h"
|
||||||
#include "winuser.h"
|
#include "winuser.h"
|
||||||
#include "wine/winbase16.h"
|
#include "wine/winbase16.h"
|
||||||
#include "process.h"
|
#include "module.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
|
@ -259,26 +259,15 @@ static DWORD VERSION_GetSystemDLLVersion( HMODULE hmod )
|
||||||
* 5.12/5.00/5.00/4.00 Win98 calc
|
* 5.12/5.00/5.00/4.00 Win98 calc
|
||||||
* x.xx/5.00/5.00/4.00 win95/win98/NT4 IE5 files
|
* 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;
|
WINE_MODREF *wm;
|
||||||
DWORD WinVersion = NB_WINDOWS_VERSIONS;
|
DWORD WinVersion = NB_WINDOWS_VERSIONS;
|
||||||
PIMAGE_OPTIONAL_HEADER ophd;
|
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
|
/* First check the native dlls provided. These have to be
|
||||||
from one windows version */
|
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);
|
ophd = &(PE_HEADER(wm->module)->OptionalHeader);
|
||||||
|
|
||||||
|
@ -319,10 +308,9 @@ DWORD VERSION_GetLinkedDllVersion(PDB *pdb)
|
||||||
if(WinVersion != NB_WINDOWS_VERSIONS) return WinVersion;
|
if(WinVersion != NB_WINDOWS_VERSIONS) return WinVersion;
|
||||||
|
|
||||||
/* we are using no external system dlls, look at the exe */
|
/* 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",
|
TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
|
||||||
pdb->exe_modref->modname,
|
|
||||||
ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
|
ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
|
||||||
ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
|
ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
|
||||||
ophd->MajorImageVersion, ophd->MinorImageVersion,
|
ophd->MajorImageVersion, ophd->MinorImageVersion,
|
||||||
|
@ -373,7 +361,7 @@ static WINDOWS_VERSION VERSION_GetVersion(void)
|
||||||
return defaultWinVersion;
|
return defaultWinVersion;
|
||||||
|
|
||||||
if (winver == 0xffff) /* to be determined */ {
|
if (winver == 0xffff) /* to be determined */ {
|
||||||
WINDOWS_VERSION retver = VERSION_GetLinkedDllVersion( PROCESS_Current() );
|
WINDOWS_VERSION retver = VERSION_GetLinkedDllVersion();
|
||||||
|
|
||||||
if (retver != WIN31) winver = retver;
|
if (retver != WIN31) winver = retver;
|
||||||
return retver;
|
return retver;
|
||||||
|
|
|
@ -11,9 +11,10 @@
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "dosexe.h"
|
#include "dosexe.h"
|
||||||
#include "process.h"
|
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
extern void PROCESS_InitWine( int argc, char *argv[] ) WINE_NORETURN;
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Main loop of initial task
|
* Main loop of initial task
|
||||||
*/
|
*/
|
||||||
|
|
36
msdos/dpmi.c
36
msdos/dpmi.c
|
@ -19,7 +19,6 @@
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "toolhelp.h"
|
#include "toolhelp.h"
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "process.h"
|
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
@ -698,8 +697,6 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
|
||||||
* shifted by 0x10000 relative to the OS linear address space.
|
* shifted by 0x10000 relative to the OS linear address space.
|
||||||
* See the comment in msdos/vxd.c.
|
* See the comment in msdos/vxd.c.
|
||||||
*/
|
*/
|
||||||
DWORD offset = W32S_APPLICATION() ? W32S_OFFSET : 0;
|
|
||||||
|
|
||||||
DWORD dw;
|
DWORD dw;
|
||||||
BYTE *ptr;
|
BYTE *ptr;
|
||||||
|
|
||||||
|
@ -814,16 +811,16 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CX_reg(context) = HIWORD(W32S_WINE2APP(dw, offset));
|
CX_reg(context) = HIWORD(W32S_WINE2APP(dw));
|
||||||
DX_reg(context) = LOWORD(W32S_WINE2APP(dw, offset));
|
DX_reg(context) = LOWORD(W32S_WINE2APP(dw));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0007: /* Set selector base address */
|
case 0x0007: /* Set selector base address */
|
||||||
TRACE("set selector base address (0x%04x,0x%08lx)\n",
|
TRACE("set selector base address (0x%04x,0x%08lx)\n",
|
||||||
BX_reg(context),
|
BX_reg(context),
|
||||||
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)), offset);
|
dw = W32S_APP2WINE(MAKELONG(DX_reg(context), CX_reg(context)));
|
||||||
if (dw < 0x10000)
|
if (dw < 0x10000)
|
||||||
/* app wants to access lower 64K of DOS memory, map it in now */
|
/* app wants to access lower 64K of DOS memory, map it in now */
|
||||||
DOSMEM_Init(TRUE);
|
DOSMEM_Init(TRUE);
|
||||||
|
@ -854,7 +851,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
|
||||||
TRACE("get descriptor (0x%04x)\n",BX_reg(context));
|
TRACE("get descriptor (0x%04x)\n",BX_reg(context));
|
||||||
{
|
{
|
||||||
LDT_ENTRY entry;
|
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 */
|
/* FIXME: should use ES:EDI for 32-bit clients */
|
||||||
*(LDT_ENTRY *)PTR_SEG_OFF_TO_LIN( context->SegEs, LOWORD(context->Edi) ) = entry;
|
*(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,
|
LDT_ENTRY entry = *(LDT_ENTRY *)PTR_SEG_OFF_TO_LIN( context->SegEs,
|
||||||
LOWORD(context->Edi) );
|
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 );
|
wine_ldt_set_entry( LOWORD(context->Ebx), &entry );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -994,31 +991,30 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
|
||||||
AX_reg(context) = 0x8012; /* linear memory not available */
|
AX_reg(context) = 0x8012; /* linear memory not available */
|
||||||
SET_CFLAG(context);
|
SET_CFLAG(context);
|
||||||
} else {
|
} else {
|
||||||
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr, offset));
|
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr));
|
||||||
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr, offset));
|
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0502: /* Free memory block */
|
case 0x0502: /* Free memory block */
|
||||||
TRACE("free memory block (0x%08lx)\n",
|
TRACE("free memory block (0x%08lx)\n",
|
||||||
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),
|
DPMI_xfree( (void *)W32S_APP2WINE(MAKELONG(DI_reg(context), SI_reg(context))) );
|
||||||
SI_reg(context)), offset) );
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0503: /* Resize memory block */
|
case 0x0503: /* Resize memory block */
|
||||||
TRACE("resize memory block (0x%08lx,%ld)\n",
|
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)));
|
MAKELONG(CX_reg(context),BX_reg(context)));
|
||||||
if (!(ptr = (BYTE *)DPMI_xrealloc(
|
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)))))
|
MAKELONG(CX_reg(context),BX_reg(context)))))
|
||||||
{
|
{
|
||||||
AX_reg(context) = 0x8012; /* linear memory not available */
|
AX_reg(context) = 0x8012; /* linear memory not available */
|
||||||
SET_CFLAG(context);
|
SET_CFLAG(context);
|
||||||
} else {
|
} else {
|
||||||
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr, offset));
|
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr));
|
||||||
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr, offset));
|
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1065,8 +1061,8 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BX_reg(context) = HIWORD(W32S_WINE2APP(ptr, offset));
|
BX_reg(context) = HIWORD(W32S_WINE2APP(ptr));
|
||||||
CX_reg(context) = LOWORD(W32S_WINE2APP(ptr, offset));
|
CX_reg(context) = LOWORD(W32S_WINE2APP(ptr));
|
||||||
RESET_CFLAG(context);
|
RESET_CFLAG(context);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
122
msdos/vxd.c
122
msdos/vxd.c
|
@ -16,9 +16,9 @@
|
||||||
#include "wine/winuser16.h"
|
#include "wine/winuser16.h"
|
||||||
#include "msdos.h"
|
#include "msdos.h"
|
||||||
#include "miscemu.h"
|
#include "miscemu.h"
|
||||||
|
#include "module.h"
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "process.h"
|
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
@ -33,6 +33,7 @@ DEFAULT_DEBUG_CHANNEL(vxd);
|
||||||
CX_reg(context), DX_reg(context), SI_reg(context), \
|
CX_reg(context), DX_reg(context), SI_reg(context), \
|
||||||
DI_reg(context), (WORD)context->SegDs, (WORD)context->SegEs )
|
DI_reg(context), (WORD)context->SegDs, (WORD)context->SegEs )
|
||||||
|
|
||||||
|
UINT W32S_offset = 0;
|
||||||
|
|
||||||
static WORD VXD_WinVersion(void)
|
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
|
* any routine apart from those, e.g. some other VxD handler, that code
|
||||||
* would have to take the offset into account as well!)
|
* would have to take the offset into account as well!)
|
||||||
*
|
*
|
||||||
* The application of the offset is triggered by marking the current process
|
* The offset is set the first time any application calls the GetVersion()
|
||||||
* as a Win32s process by setting the PDB32_WIN32S_PROC flag in the process
|
* service of the Win32s VxD. (Note that the offset is never reset.)
|
||||||
* database. This is done the first time any application calls the GetVersion()
|
|
||||||
* service of the Win32s VxD. (Note that the flag is never removed.)
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -596,7 +595,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* performance of Win32s.
|
* performance of Win32s.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!(PROCESS_Current()->flags & PDB32_WIN32S_PROC))
|
if (!W32S_offset)
|
||||||
{
|
{
|
||||||
HMODULE16 hModule = GetModuleHandle16("win32s16");
|
HMODULE16 hModule = GetModuleHandle16("win32s16");
|
||||||
SEGPTR func1 = (SEGPTR)GetProcAddress16(hModule, "SetFS");
|
SEGPTR func1 = (SEGPTR)GetProcAddress16(hModule, "SetFS");
|
||||||
|
@ -633,8 +632,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Mark process as Win32s, so that subsequent DPMI calls
|
* Mark process as Win32s, so that subsequent DPMI calls
|
||||||
* will perform the W32S_APP2WINE/W32S_WINE2APP address shift.
|
* will perform the W32S_APP2WINE/W32S_WINE2APP address shift.
|
||||||
*/
|
*/
|
||||||
|
W32S_offset = 0x10000;
|
||||||
PROCESS_Current()->flags |= PDB32_WIN32S_PROC;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
@ -743,7 +741,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct Win32sModule *moduleTable =
|
struct Win32sModule *moduleTable =
|
||||||
(struct Win32sModule *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
(struct Win32sModule *)W32S_APP2WINE(context->Edx);
|
||||||
struct Win32sModule *module = moduleTable + context->Ecx;
|
struct Win32sModule *module = moduleTable + context->Ecx;
|
||||||
|
|
||||||
IMAGE_NT_HEADERS *nt_header = PE_HEADER(module->baseAddr);
|
IMAGE_NT_HEADERS *nt_header = PE_HEADER(module->baseAddr);
|
||||||
|
@ -835,7 +833,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: 1 if OK
|
* 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 ... */
|
/* As we didn't map anything, there's nothing to unmap ... */
|
||||||
|
|
||||||
|
@ -858,9 +856,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
|
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0]);
|
||||||
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
|
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1]);
|
||||||
DWORD size = stack[2];
|
DWORD size = stack[2];
|
||||||
DWORD type = stack[3];
|
DWORD type = stack[3];
|
||||||
DWORD prot = stack[4];
|
DWORD prot = stack[4];
|
||||||
|
@ -883,8 +881,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
|
|
||||||
result = (DWORD)VirtualAlloc(base, size, type, prot);
|
result = (DWORD)VirtualAlloc(base, size, type, prot);
|
||||||
|
|
||||||
if (W32S_WINE2APP(result, W32S_OFFSET))
|
if (W32S_WINE2APP(result))
|
||||||
*retv = W32S_WINE2APP(result, W32S_OFFSET),
|
*retv = W32S_WINE2APP(result),
|
||||||
context->Eax = STATUS_SUCCESS;
|
context->Eax = STATUS_SUCCESS;
|
||||||
else
|
else
|
||||||
*retv = 0,
|
*retv = 0,
|
||||||
|
@ -907,9 +905,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
|
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0]);
|
||||||
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
|
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1]);
|
||||||
DWORD size = stack[2];
|
DWORD size = stack[2];
|
||||||
DWORD type = stack[3];
|
DWORD type = stack[3];
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
@ -944,12 +942,12 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
|
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0]);
|
||||||
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
|
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1]);
|
||||||
DWORD size = stack[2];
|
DWORD size = stack[2];
|
||||||
DWORD new_prot = stack[3];
|
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;
|
DWORD result;
|
||||||
|
|
||||||
TRACE("VirtualProtect(%lx, %lx, %lx, %lx, %lx)\n",
|
TRACE("VirtualProtect(%lx, %lx, %lx, %lx, %lx)\n",
|
||||||
|
@ -981,11 +979,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
|
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0]);
|
||||||
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
|
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1]);
|
||||||
LPMEMORY_BASIC_INFORMATION info =
|
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 len = stack[3];
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
|
||||||
|
@ -1064,11 +1062,11 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *) W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *) W32S_APP2WINE(context->Edx);
|
||||||
HANDLE *retv = (HANDLE *)W32S_APP2WINE(stack[0], W32S_OFFSET);
|
HANDLE *retv = (HANDLE *)W32S_APP2WINE(stack[0]);
|
||||||
DWORD flags1 = stack[1];
|
DWORD flags1 = stack[1];
|
||||||
DWORD atom = stack[2];
|
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 protect = stack[4];
|
||||||
DWORD flags2 = stack[5];
|
DWORD flags2 = stack[5];
|
||||||
HANDLE hFile = DosFileHandleToWin32Handle(stack[6]);
|
HANDLE hFile = DosFileHandleToWin32Handle(stack[6]);
|
||||||
|
@ -1117,8 +1115,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
HANDLE *retv = (HANDLE *)W32S_APP2WINE(stack[0], W32S_OFFSET);
|
HANDLE *retv = (HANDLE *)W32S_APP2WINE(stack[0]);
|
||||||
DWORD protect = stack[1];
|
DWORD protect = stack[1];
|
||||||
DWORD atom = stack[2];
|
DWORD atom = stack[2];
|
||||||
|
|
||||||
|
@ -1160,9 +1158,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
HANDLE handle = stack[0];
|
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);
|
TRACE("NtCloseSection(%lx, %lx)\n", (DWORD)handle, (DWORD)id);
|
||||||
|
|
||||||
|
@ -1183,7 +1181,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
HANDLE handle = stack[0];
|
HANDLE handle = stack[0];
|
||||||
HANDLE new_handle;
|
HANDLE new_handle;
|
||||||
|
|
||||||
|
@ -1215,20 +1213,20 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD * stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD * stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
HANDLE SectionHandle = stack[0];
|
HANDLE SectionHandle = stack[0];
|
||||||
DWORD ProcessHandle = stack[1]; /* ignored */
|
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 ZeroBits = stack[3];
|
||||||
DWORD CommitSize = stack[4];
|
DWORD CommitSize = stack[4];
|
||||||
LARGE_INTEGER *SectionOffset = (LARGE_INTEGER *)W32S_APP2WINE(stack[5], W32S_OFFSET);
|
LARGE_INTEGER *SectionOffset = (LARGE_INTEGER *)W32S_APP2WINE(stack[5]);
|
||||||
DWORD * ViewSize = (DWORD *)W32S_APP2WINE(stack[6], W32S_OFFSET);
|
DWORD * ViewSize = (DWORD *)W32S_APP2WINE(stack[6]);
|
||||||
DWORD InheritDisposition = stack[7];
|
DWORD InheritDisposition = stack[7];
|
||||||
DWORD AllocationType = stack[8];
|
DWORD AllocationType = stack[8];
|
||||||
DWORD Protect = stack[9];
|
DWORD Protect = stack[9];
|
||||||
|
|
||||||
LPBYTE address = (LPBYTE)(BaseAddress?
|
LPBYTE address = (LPBYTE)(BaseAddress?
|
||||||
W32S_APP2WINE(*BaseAddress, W32S_OFFSET) : 0);
|
W32S_APP2WINE(*BaseAddress) : 0);
|
||||||
DWORD access = 0, result;
|
DWORD access = 0, result;
|
||||||
|
|
||||||
switch (Protect & ~(PAGE_GUARD|PAGE_NOCACHE))
|
switch (Protect & ~(PAGE_GUARD|PAGE_NOCACHE))
|
||||||
|
@ -1259,9 +1257,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
|
|
||||||
TRACE("NtMapViewOfSection: result=%lx\n", result);
|
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;
|
context->Eax = STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1280,9 +1278,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* 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 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",
|
TRACE("NtUnmapViewOfSection(%lx, %lx)\n",
|
||||||
ProcessHandle, (DWORD)BaseAddress);
|
ProcessHandle, (DWORD)BaseAddress);
|
||||||
|
@ -1306,13 +1304,13 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* 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 ProcessHandle = stack[0]; /* ignored */
|
||||||
DWORD *BaseAddress = (DWORD *)W32S_APP2WINE(stack[1], W32S_OFFSET);
|
DWORD *BaseAddress = (DWORD *)W32S_APP2WINE(stack[1]);
|
||||||
DWORD *ViewSize = (DWORD *)W32S_APP2WINE(stack[2], W32S_OFFSET);
|
DWORD *ViewSize = (DWORD *)W32S_APP2WINE(stack[2]);
|
||||||
DWORD *unknown = (DWORD *)W32S_APP2WINE(stack[3], W32S_OFFSET);
|
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;
|
DWORD size = ViewSize? *ViewSize : 0;
|
||||||
|
|
||||||
TRACE("NtFlushVirtualMemory(%lx, %lx, %lx, %lx)\n",
|
TRACE("NtFlushVirtualMemory(%lx, %lx, %lx, %lx)\n",
|
||||||
|
@ -1413,9 +1411,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
|
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0]);
|
||||||
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
|
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1]);
|
||||||
DWORD size = stack[2];
|
DWORD size = stack[2];
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
|
||||||
|
@ -1447,9 +1445,9 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: EAX: NtStatus
|
* Output: EAX: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx, W32S_OFFSET);
|
DWORD *stack = (DWORD *)W32S_APP2WINE(context->Edx);
|
||||||
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0], W32S_OFFSET);
|
DWORD *retv = (DWORD *)W32S_APP2WINE(stack[0]);
|
||||||
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1], W32S_OFFSET);
|
LPVOID base = (LPVOID) W32S_APP2WINE(stack[1]);
|
||||||
DWORD size = stack[2];
|
DWORD size = stack[2];
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
|
||||||
|
@ -1487,8 +1485,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* FIXME: What about other OSes ?
|
* FIXME: What about other OSes ?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
context->Ecx = W32S_WINE2APP(0x00000000, W32S_OFFSET);
|
context->Ecx = W32S_WINE2APP(0x00000000);
|
||||||
context->Edx = W32S_WINE2APP(0xbfffffff, W32S_OFFSET);
|
context->Edx = W32S_WINE2APP(0xbfffffff);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1511,7 +1509,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Win32sMemoryInfo *info =
|
struct Win32sMemoryInfo *info =
|
||||||
(struct Win32sMemoryInfo *)W32S_APP2WINE(context->Esi, W32S_OFFSET);
|
(struct Win32sMemoryInfo *)W32S_APP2WINE(context->Esi);
|
||||||
|
|
||||||
FIXME("KGlobalMemStat(%lx)\n", (DWORD)info);
|
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),
|
DWORD *stack = PTR_SEG_OFF_TO_LIN(LOWORD(context->Edx),
|
||||||
HIWORD(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 size = stack[1];
|
||||||
DWORD type = stack[2];
|
DWORD type = stack[2];
|
||||||
DWORD prot = stack[3];
|
DWORD prot = stack[3];
|
||||||
|
@ -1565,8 +1563,8 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
|
|
||||||
result = (DWORD)VirtualAlloc(base, size, type, prot);
|
result = (DWORD)VirtualAlloc(base, size, type, prot);
|
||||||
|
|
||||||
if (W32S_WINE2APP(result, W32S_OFFSET))
|
if (W32S_WINE2APP(result))
|
||||||
context->Edx = W32S_WINE2APP(result, W32S_OFFSET),
|
context->Edx = W32S_WINE2APP(result),
|
||||||
context->Eax = STATUS_SUCCESS;
|
context->Eax = STATUS_SUCCESS;
|
||||||
else
|
else
|
||||||
context->Edx = 0,
|
context->Edx = 0,
|
||||||
|
@ -1590,7 +1588,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
{
|
{
|
||||||
DWORD *stack = PTR_SEG_OFF_TO_LIN(LOWORD(context->Edx),
|
DWORD *stack = PTR_SEG_OFF_TO_LIN(LOWORD(context->Edx),
|
||||||
HIWORD(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 size = stack[1];
|
||||||
DWORD type = stack[2];
|
DWORD type = stack[2];
|
||||||
DWORD result;
|
DWORD result;
|
||||||
|
@ -1620,7 +1618,7 @@ void WINAPI VXD_Win32s( CONTEXT86 *context )
|
||||||
* Output: NtStatus
|
* Output: NtStatus
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
DWORD *ptr = (DWORD *)W32S_APP2WINE(context->Ecx, W32S_OFFSET);
|
DWORD *ptr = (DWORD *)W32S_APP2WINE(context->Ecx);
|
||||||
BOOL set = context->Edx;
|
BOOL set = context->Edx;
|
||||||
|
|
||||||
TRACE("FWorkingSetSize(%lx, %lx)\n", (DWORD)ptr, (DWORD)set);
|
TRACE("FWorkingSetSize(%lx, %lx)\n", (DWORD)ptr, (DWORD)set);
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
#include "syslevel.h"
|
#include "syslevel.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "process.h"
|
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(relay);
|
DEFAULT_DEBUG_CHANNEL(relay);
|
||||||
|
@ -114,7 +113,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
|
||||||
|
|
||||||
/* First find the module */
|
/* 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;
|
if (!(wm->flags & WINE_MODREF_INTERNAL)) continue;
|
||||||
base = (char *)wm->module;
|
base = (char *)wm->module;
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
#include "wine/port.h"
|
#include "wine/port.h"
|
||||||
#include "process.h"
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include "wine/winbase16.h"
|
#include "wine/winbase16.h"
|
||||||
#include "wine/exception.h"
|
#include "wine/exception.h"
|
||||||
#include "wine/library.h"
|
#include "wine/library.h"
|
||||||
#include "process.h"
|
|
||||||
#include "drive.h"
|
#include "drive.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
|
@ -35,15 +34,80 @@ DEFAULT_DEBUG_CHANNEL(process);
|
||||||
DECLARE_DEBUG_CHANNEL(relay);
|
DECLARE_DEBUG_CHANNEL(relay);
|
||||||
DECLARE_DEBUG_CHANNEL(win32);
|
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;
|
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_argv;
|
||||||
static char main_exe_name[MAX_PATH];
|
static char main_exe_name[MAX_PATH];
|
||||||
static HANDLE main_exe_file = INVALID_HANDLE_VALUE;
|
static HANDLE main_exe_file = INVALID_HANDLE_VALUE;
|
||||||
static HMODULE main_module;
|
|
||||||
|
|
||||||
unsigned int server_startticks;
|
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
|
* PROCESS_CallUserSignalProc
|
||||||
*
|
*
|
||||||
|
@ -178,7 +242,6 @@ static BOOL process_init( char *argv[] )
|
||||||
current_process.ring0_threads = 1;
|
current_process.ring0_threads = 1;
|
||||||
current_process.group = ¤t_process;
|
current_process.group = ¤t_process;
|
||||||
current_process.priority = 8; /* Normal */
|
current_process.priority = 8; /* Normal */
|
||||||
current_process.env_db = ¤t_envdb;
|
|
||||||
|
|
||||||
/* Setup the server connection */
|
/* Setup the server connection */
|
||||||
NtCurrentTeb()->socket = CLIENT_InitServer();
|
NtCurrentTeb()->socket = CLIENT_InitServer();
|
||||||
|
@ -201,9 +264,12 @@ static BOOL process_init( char *argv[] )
|
||||||
current_startupinfo.dwFlags = req->start_flags;
|
current_startupinfo.dwFlags = req->start_flags;
|
||||||
server_startticks = req->server_start;
|
server_startticks = req->server_start;
|
||||||
current_startupinfo.wShowWindow = req->cmd_show;
|
current_startupinfo.wShowWindow = req->cmd_show;
|
||||||
current_envdb.hStdin = current_startupinfo.hStdInput = req->hstdin;
|
current_startupinfo.hStdInput = req->hstdin;
|
||||||
current_envdb.hStdout = current_startupinfo.hStdOutput = req->hstdout;
|
current_startupinfo.hStdOutput = req->hstdout;
|
||||||
current_envdb.hStderr = current_startupinfo.hStdError = req->hstderr;
|
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;
|
SERVER_END_REQ;
|
||||||
|
@ -214,10 +280,7 @@ static BOOL process_init( char *argv[] )
|
||||||
current_process.heap = HeapCreate( HEAP_GROWABLE, 0, 0 );
|
current_process.heap = HeapCreate( HEAP_GROWABLE, 0, 0 );
|
||||||
|
|
||||||
/* Copy the parent environment */
|
/* Copy the parent environment */
|
||||||
if (!ENV_BuildEnvironment()) return FALSE;
|
if (!(current_process.env_db = ENV_BuildEnvironment())) return FALSE;
|
||||||
|
|
||||||
/* Initialize the critical sections */
|
|
||||||
InitializeCriticalSection( ¤t_process.crit_section );
|
|
||||||
|
|
||||||
/* Parse command line arguments */
|
/* Parse command line arguments */
|
||||||
OPTIONS_ParseOptions( argv );
|
OPTIONS_ParseOptions( argv );
|
||||||
|
@ -226,45 +289,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
|
* start_process
|
||||||
*
|
*
|
||||||
|
@ -277,10 +301,10 @@ static void start_process(void)
|
||||||
WINE_MODREF *wm;
|
WINE_MODREF *wm;
|
||||||
|
|
||||||
/* build command line */
|
/* 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 */
|
/* 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 */
|
/* use original argv[0] as name for the main module */
|
||||||
if (!main_exe_name[0])
|
if (!main_exe_name[0])
|
||||||
|
@ -290,16 +314,16 @@ static void start_process(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Retrieve entry point address */
|
/* Retrieve entry point address */
|
||||||
entry = (LPTHREAD_START_ROUTINE)((char*)main_module +
|
entry = (LPTHREAD_START_ROUTINE)((char*)current_process.module +
|
||||||
PE_HEADER(main_module)->OptionalHeader.AddressOfEntryPoint);
|
PE_HEADER(current_process.module)->OptionalHeader.AddressOfEntryPoint);
|
||||||
console_app = (PE_HEADER(main_module)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI);
|
console_app = (PE_HEADER(current_process.module)->OptionalHeader.Subsystem == IMAGE_SUBSYSTEM_WINDOWS_CUI);
|
||||||
if (console_app) current_process.flags |= PDB32_CONSOLE_PROC;
|
if (console_app) current_process.flags |= PDB32_CONSOLE_PROC;
|
||||||
|
|
||||||
/* Signal the parent process to continue */
|
/* Signal the parent process to continue */
|
||||||
SERVER_START_REQ
|
SERVER_START_REQ
|
||||||
{
|
{
|
||||||
struct init_process_done_request *req = server_alloc_req( sizeof(*req), 0 );
|
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->entry = entry;
|
||||||
req->name = main_exe_name;
|
req->name = main_exe_name;
|
||||||
req->gui = !console_app;
|
req->gui = !console_app;
|
||||||
|
@ -314,14 +338,14 @@ static void start_process(void)
|
||||||
if (!SIGNAL_Init()) goto error;
|
if (!SIGNAL_Init()) goto error;
|
||||||
|
|
||||||
/* create the main modref and load dependencies */
|
/* 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;
|
goto error;
|
||||||
wm->refCount++;
|
wm->refCount++;
|
||||||
|
|
||||||
EnterCriticalSection( ¤t_process.crit_section );
|
RtlAcquirePebLock();
|
||||||
PE_InitTls();
|
PE_InitTls();
|
||||||
MODULE_DllProcessAttach( current_process.exe_modref, (LPVOID)1 );
|
MODULE_DllProcessAttach( NULL, (LPVOID)1 );
|
||||||
LeaveCriticalSection( ¤t_process.crit_section );
|
RtlReleasePebLock();
|
||||||
|
|
||||||
/* Get pointers to USER routines called by KERNEL */
|
/* Get pointers to USER routines called by KERNEL */
|
||||||
THUNK_InitCallout();
|
THUNK_InitCallout();
|
||||||
|
@ -344,7 +368,7 @@ static void start_process(void)
|
||||||
/* Call UserSignalProc ( USIG_PROCESS_RUNNING ... ) only for non-GUI win32 apps */
|
/* Call UserSignalProc ( USIG_PROCESS_RUNNING ... ) only for non-GUI win32 apps */
|
||||||
if (console_app) PROCESS_CallUserSignalProc( USIG_PROCESS_RUNNING, 0 );
|
if (console_app) PROCESS_CallUserSignalProc( USIG_PROCESS_RUNNING, 0 );
|
||||||
|
|
||||||
TRACE_(relay)( "Starting Win32 process %s (entryproc=%p)\n", current_process.exe_modref->filename, entry );
|
TRACE_(relay)( "Starting Win32 process %s (entryproc=%p)\n", main_exe_name, entry );
|
||||||
if (debugged) DbgBreakPoint();
|
if (debugged) DbgBreakPoint();
|
||||||
/* FIXME: should use _PEB as parameter for NT 3.5 programs !
|
/* FIXME: should use _PEB as parameter for NT 3.5 programs !
|
||||||
* Dunno about other OSs */
|
* 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 */
|
/* 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 );
|
ExitProcess( ERROR_BAD_EXE_FORMAT );
|
||||||
stack_size = PE_HEADER(main_module)->OptionalHeader.SizeOfStackReserve;
|
stack_size = PE_HEADER(current_process.module)->OptionalHeader.SizeOfStackReserve;
|
||||||
goto found;
|
goto found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1367,6 +1391,115 @@ UINT WINAPI SetErrorMode( UINT mode )
|
||||||
return old;
|
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)
|
* GetCurrentProcess (KERNEL32.198)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "wine/winbase16.h"
|
#include "wine/winbase16.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "process.h"
|
|
||||||
#include "task.h"
|
#include "task.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
|
@ -35,6 +34,8 @@ DEFAULT_DEBUG_CHANNEL(thread);
|
||||||
/* TEB of the initial thread */
|
/* TEB of the initial thread */
|
||||||
static TEB initial_teb;
|
static TEB initial_teb;
|
||||||
|
|
||||||
|
extern struct _PDB current_process;
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* THREAD_IsWin16
|
* 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 )))
|
if ((teb = THREAD_InitStack( NULL, stack_size, alloc_stack16 )))
|
||||||
{
|
{
|
||||||
teb->tibflags = (current_process.flags & PDB32_WIN16_PROC) ? 0 : TEBF_WIN32;
|
teb->tibflags = TEBF_WIN32;
|
||||||
teb->process = ¤t_process;
|
teb->process = NtCurrentTeb()->process;
|
||||||
teb->socket = fd;
|
teb->socket = fd;
|
||||||
fcntl( fd, F_SETFD, 1 ); /* set close on exec flag */
|
fcntl( fd, F_SETFD, 1 ); /* set close on exec flag */
|
||||||
TRACE("(%p) succeeded\n", teb);
|
TRACE("(%p) succeeded\n", teb);
|
||||||
|
@ -304,7 +305,6 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
|
||||||
close( socket );
|
close( socket );
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
teb->tibflags |= TEBF_WIN32;
|
|
||||||
teb->entry_point = start;
|
teb->entry_point = start;
|
||||||
teb->entry_arg = param;
|
teb->entry_arg = param;
|
||||||
teb->startup = THREAD_Start;
|
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( ¤t_process.crit_section );
|
|
||||||
if (*bits == 0xffffffff)
|
|
||||||
{
|
|
||||||
bits++;
|
|
||||||
ret = 32;
|
|
||||||
if (*bits == 0xffffffff)
|
|
||||||
{
|
|
||||||
LeaveCriticalSection( ¤t_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( ¤t_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( ¤t_process.crit_section );
|
|
||||||
if (index >= 32) bits++;
|
|
||||||
mask = (1 << (index & 31));
|
|
||||||
if (!(*bits & mask)) /* already free? */
|
|
||||||
{
|
|
||||||
LeaveCriticalSection( ¤t_process.crit_section );
|
|
||||||
SetLastError( ERROR_INVALID_PARAMETER );
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
*bits &= ~mask;
|
|
||||||
NtCurrentTeb()->tls_array[index] = 0;
|
|
||||||
/* FIXME: should zero all other thread values */
|
|
||||||
LeaveCriticalSection( ¤t_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.
|
* SetThreadContext [KERNEL32.670] Sets context of thread.
|
||||||
*
|
*
|
||||||
|
|
|
@ -43,7 +43,6 @@
|
||||||
#include "wine/keyboard16.h"
|
#include "wine/keyboard16.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "process.h"
|
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "wincon.h"
|
#include "wincon.h"
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "winreg.h"
|
#include "winreg.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "process.h"
|
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "winioctl.h"
|
#include "winioctl.h"
|
||||||
#include "winnt.h"
|
#include "winnt.h"
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
#include "wine/exception.h"
|
#include "wine/exception.h"
|
||||||
#include "selectors.h"
|
#include "selectors.h"
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
#include "process.h"
|
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
#include "stackframe.h"
|
#include "stackframe.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
@ -37,6 +36,8 @@
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(seh);
|
DEFAULT_DEBUG_CHANNEL(seh);
|
||||||
|
|
||||||
|
static PTOP_LEVEL_EXCEPTION_FILTER top_filter;
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************
|
/*******************************************************************
|
||||||
* RaiseException (KERNEL32.418)
|
* RaiseException (KERNEL32.418)
|
||||||
|
@ -143,7 +144,6 @@ static void format_exception_msg( const EXCEPTION_POINTERS *ptr, char *buffer )
|
||||||
*/
|
*/
|
||||||
DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
|
DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
|
||||||
{
|
{
|
||||||
PDB* pdb = PROCESS_Current();
|
|
||||||
char format[256];
|
char format[256];
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
HKEY hDbgConf;
|
HKEY hDbgConf;
|
||||||
|
@ -179,9 +179,9 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
|
||||||
FIXME("Unsupported yet debug continue value %d (please report)\n", status);
|
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;
|
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 WINAPI SetUnhandledExceptionFilter(
|
||||||
LPTOP_LEVEL_EXCEPTION_FILTER filter )
|
LPTOP_LEVEL_EXCEPTION_FILTER filter )
|
||||||
{
|
{
|
||||||
PDB *pdb = PROCESS_Current();
|
LPTOP_LEVEL_EXCEPTION_FILTER old = top_filter;
|
||||||
LPTOP_LEVEL_EXCEPTION_FILTER old = pdb->top_filter;
|
top_filter = filter;
|
||||||
pdb->top_filter = filter;
|
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winerror.h"
|
#include "winerror.h"
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "process.h"
|
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include "sysmetrics.h"
|
#include "sysmetrics.h"
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
#include "local.h"
|
#include "local.h"
|
||||||
#include "process.h"
|
#include "module.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
DECLARE_DEBUG_CHANNEL(hook);
|
DECLARE_DEBUG_CHANNEL(hook);
|
||||||
|
|
Loading…
Reference in a new issue