Commit becb9a35 authored by Alexandre Julliard's avatar Alexandre Julliard

Moved all Wine internal definitions out of process.h.

parent 2a37decc
......@@ -25,7 +25,6 @@
*/
#include "crtdll.h"
#include <errno.h>
#include "process.h"
DEFAULT_DEBUG_CHANNEL(crtdll);
......
......@@ -32,7 +32,6 @@
* -File handles need some special handling. Sometimes children get
* open file handles, sometimes not. The docs are confusing.
* -No check for maximum path/argument/environment size is done.
* -Wine has a "process.h" which is not the same as any crt version.
* Unresolved issues Uwe Bonnes 970904:
* -system-call calls another wine process, but without debugging arguments
* and uses the first wine executable in the path
......@@ -40,7 +39,6 @@
#include "crtdll.h"
#include <errno.h>
#include "process.h"
#include <stdlib.h>
......
......@@ -11,7 +11,6 @@
*/
#include "crtdll.h"
#include "process.h"
#include <stdlib.h>
#include <sys/times.h>
......
......@@ -5,11 +5,11 @@
*/
#include "wine/winbase16.h"
#include "ntddk.h"
#include "heap.h"
#include "module.h"
#include "selectors.h"
#include "callback.h"
#include "process.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(thunk);
......@@ -51,6 +51,8 @@ typedef struct _UTINFO
} UTINFO;
static UTINFO *UT_head; /* head of Universal Thunk list */
typedef DWORD (CALLBACK *UTGLUEPROC)( LPVOID lpBuff, DWORD dwUserDefined );
BOOL WINAPI UTRegister( HMODULE hModule, LPSTR lpsz16BITDLL,
......@@ -173,8 +175,8 @@ static UTINFO *UTAlloc( HMODULE hModule, HMODULE16 hModule16,
ut->ut32.jmp = 0xe9;
ut->ut32.utglue32 = (DWORD)UTGlue32 - ((DWORD)&ut->ut32.utglue32 + sizeof(DWORD));
ut->next = PROCESS_Current()->UTState;
PROCESS_Current()->UTState = ut;
ut->next = UT_head;
UT_head = ut;
return ut;
}
......@@ -186,7 +188,7 @@ static void UTFree( UTINFO *ut )
{
UTINFO **ptr;
for ( ptr = &PROCESS_Current()->UTState; *ptr; ptr = &(*ptr)->next )
for ( ptr = &UT_head; *ptr; ptr = &(*ptr)->next )
if ( *ptr == ut )
{
*ptr = ut->next;
......@@ -203,7 +205,7 @@ static UTINFO *UTFind( HMODULE hModule )
{
UTINFO *ut;
for ( ut = PROCESS_Current()->UTState; ut; ut =ut->next )
for ( ut = UT_head; ut; ut =ut->next )
if ( ut->hModule == hModule )
break;
......@@ -231,12 +233,12 @@ BOOL WINAPI UTRegister( HMODULE hModule, LPSTR lpsz16BITDLL,
/* Allocate UTINFO struct */
EnterCriticalSection( &PROCESS_Current()->crit_section );
RtlAcquirePebLock();
if ( (ut = UTFind( hModule )) != NULL )
ut = NULL;
else
ut = UTAlloc( hModule, hModule16, target16, pfnUT32CallBack );
LeaveCriticalSection( &PROCESS_Current()->crit_section );
RtlReleasePebLock();
if ( !ut )
{
......@@ -276,14 +278,14 @@ VOID WINAPI UTUnRegister( HMODULE hModule )
UTINFO *ut;
HMODULE16 hModule16 = 0;
EnterCriticalSection( &PROCESS_Current()->crit_section );
RtlAcquirePebLock();
ut = UTFind( hModule );
if ( !ut )
{
hModule16 = ut->hModule16;
UTFree( ut );
}
LeaveCriticalSection( &PROCESS_Current()->crit_section );
RtlReleasePebLock();
if ( hModule16 )
FreeLibrary16( hModule16 );
......
......@@ -51,6 +51,7 @@ INSTALLED_INCLUDES = \
oledlg.h \
oleidl.h \
poppack.h \
process.h \
prsht.h \
psapi.h \
pshpack1.h \
......
......@@ -26,10 +26,10 @@
#define PTR_SEG_OFF_TO_HUGEPTR(seg,off) \
PTR_SEG_OFF_TO_SEGPTR( (seg) + (HIWORD(off) << __AHSHIFT), LOWORD(off) )
#define W32S_APPLICATION() (PROCESS_Current()->flags & PDB32_WIN32S_PROC)
#define W32S_OFFSET 0x10000
#define W32S_APP2WINE(addr, offset) ((addr)? (DWORD)(addr) + (DWORD)(offset) : 0)
#define W32S_WINE2APP(addr, offset) ((addr)? (DWORD)(addr) - (DWORD)(offset) : 0)
extern UINT W32S_offset;
#define W32S_APP2WINE(addr) ((addr)? (DWORD)(addr) + W32S_offset : 0)
#define W32S_WINE2APP(addr) ((addr)? (DWORD)(addr) - W32S_offset : 0)
#define FIRST_LDT_ENTRY_TO_ALLOC 17
......
......@@ -140,6 +140,7 @@ typedef struct _wine_modref
#define WINE_MODREF_DONT_RESOLVE_REFS 0x00000020
#define WINE_MODREF_MARKER 0x80000000
extern WINE_MODREF *MODULE_modref_list;
/* Resource types */
......@@ -231,4 +232,33 @@ extern HMODULE BUILTIN32_LoadExeModule( HMODULE main );
extern void *BUILTIN32_dlopen( const char *name );
extern int BUILTIN32_dlclose( void *handle );
/* USER signal proc flags and codes */
/* See PROCESS_CallUserSignalProc for comments */
#define USIG_FLAGS_WIN32 0x0001
#define USIG_FLAGS_GUI 0x0002
#define USIG_FLAGS_FEEDBACK 0x0004
#define USIG_FLAGS_FAULT 0x0008
#define USIG_DLL_UNLOAD_WIN16 0x0001
#define USIG_DLL_UNLOAD_WIN32 0x0002
#define USIG_FAULT_DIALOG_PUSH 0x0003
#define USIG_FAULT_DIALOG_POP 0x0004
#define USIG_DLL_UNLOAD_ORPHANS 0x0005
#define USIG_THREAD_INIT 0x0010
#define USIG_THREAD_EXIT 0x0020
#define USIG_PROCESS_CREATE 0x0100
#define USIG_PROCESS_INIT 0x0200
#define USIG_PROCESS_EXIT 0x0300
#define USIG_PROCESS_DESTROY 0x0400
#define USIG_PROCESS_RUNNING 0x0500
#define USIG_PROCESS_LOADED 0x0600
/* scheduler/process.c */
extern void PROCESS_CallUserSignalProc( UINT uCode, HMODULE hModule );
extern BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
BOOL inherit, DWORD flags,
STARTUPINFOA *startup, PROCESS_INFORMATION *info,
LPCSTR lpCurrentDirectory );
#endif /* __WINE_MODULE_H */
......@@ -4,165 +4,8 @@
* Copyright 1996 Alexandre Julliard
*/
#ifndef __WINE_PROCESS_H
#define __WINE_PROCESS_H
#include "windef.h"
#include "module.h"
#include "thread.h"
struct _NE_MODULE;
struct _THREAD_ENTRY;
struct _UTINFO;
/* Win32 process environment database */
typedef struct
{
LPSTR environ; /* 00 Process environment strings */
DWORD unknown1; /* 04 Unknown */
LPSTR cmd_line; /* 08 Command line */
LPSTR cur_dir; /* 0c Current directory */
STARTUPINFOA *startup_info; /* 10 Startup information */
HANDLE hStdin; /* 14 Handle for standard input */
HANDLE hStdout; /* 18 Handle for standard output */
HANDLE hStderr; /* 1c Handle for standard error */
DWORD unknown2; /* 20 Unknown */
DWORD inherit_console; /* 24 Inherit console flag */
DWORD break_type; /* 28 Console events flag */
void *break_sem; /* 2c SetConsoleCtrlHandler semaphore */
void *break_event; /* 30 SetConsoleCtrlHandler event */
void *break_thread; /* 34 SetConsoleCtrlHandler thread */
void *break_handlers; /* 38 List of console handlers */
/* The following are Wine-specific fields */
CRITICAL_SECTION section; /* 3c Env DB critical section */
LPWSTR cmd_lineW; /* 40 Unicode command line */
WORD env_sel; /* 44 Environment strings selector */
} ENVDB;
/* Win32 process database */
typedef struct _PDB
{
LONG header[2]; /* 00 Kernel object header */
HMODULE module; /* 08 Main exe module (NT) */
void *event; /* 0c Pointer to an event object (unused) */
DWORD exit_code; /* 10 Process exit code */
DWORD unknown2; /* 14 Unknown */
HANDLE heap; /* 18 Default process heap */
HANDLE mem_context; /* 1c Process memory context */
DWORD flags; /* 20 Flags */
void *pdb16; /* 24 DOS PSP */
WORD PSP_sel; /* 28 Selector to DOS PSP */
WORD imte; /* 2a IMTE for the process module */
WORD threads; /* 2c Number of threads */
WORD running_threads; /* 2e Number of running threads */
WORD free_lib_count; /* 30 Recursion depth of FreeLibrary calls */
WORD ring0_threads; /* 32 Number of ring 0 threads */
HANDLE system_heap; /* 34 System heap to allocate handles */
HTASK task; /* 38 Win16 task */
void *mem_map_files; /* 3c Pointer to mem-mapped files */
ENVDB *env_db; /* 40 Environment database */
void *handle_table; /* 44 Handle table */
struct _PDB *parent; /* 48 Parent process */
WINE_MODREF *modref_list; /* 4c MODREF list */
void *thread_list; /* 50 List of threads */
void *debuggee_CB; /* 54 Debuggee context block */
void *local_heap_free; /* 58 Head of local heap free list */
DWORD unknown4; /* 5c Unknown */
CRITICAL_SECTION crit_section; /* 60 Critical section */
DWORD unknown5[3]; /* 78 Unknown */
void *console; /* 84 Console */
DWORD tls_bits[2]; /* 88 TLS in-use bits */
DWORD process_dword; /* 90 Unknown */
struct _PDB *group; /* 94 Process group */
WINE_MODREF *exe_modref; /* 98 MODREF for the process EXE */
LPTOP_LEVEL_EXCEPTION_FILTER top_filter; /* 9c Top exception filter */
DWORD priority; /* a0 Priority level */
HANDLE heap_list; /* a4 Head of process heap list */
void *heap_handles; /* a8 Head of heap handles list */
DWORD unknown6; /* ac Unknown */
void *console_provider; /* b0 Console provider (??) */
WORD env_selector; /* b4 Selector to process environment */
WORD error_mode; /* b6 Error mode */
HANDLE load_done_evt; /* b8 Event for process loading done */
struct _UTINFO *UTState; /* bc Head of Univeral Thunk list */
DWORD unknown8; /* c0 Unknown (NT) */
LCID locale; /* c4 Locale to be queried by GetThreadLocale (NT) */
} PDB;
/* Process flags */
#define PDB32_DEBUGGED 0x0001 /* Process is being debugged */
#define PDB32_WIN16_PROC 0x0008 /* Win16 process */
#define PDB32_DOS_PROC 0x0010 /* Dos process */
#define PDB32_CONSOLE_PROC 0x0020 /* Console process */
#define PDB32_FILE_APIS_OEM 0x0040 /* File APIs are OEM */
#define PDB32_WIN32S_PROC 0x8000 /* Win32s process */
/* USER signal proc flags and codes */
/* See PROCESS_CallUserSignalProc for comments */
#define USIG_FLAGS_WIN32 0x0001
#define USIG_FLAGS_GUI 0x0002
#define USIG_FLAGS_FEEDBACK 0x0004
#define USIG_FLAGS_FAULT 0x0008
#define USIG_DLL_UNLOAD_WIN16 0x0001
#define USIG_DLL_UNLOAD_WIN32 0x0002
#define USIG_FAULT_DIALOG_PUSH 0x0003
#define USIG_FAULT_DIALOG_POP 0x0004
#define USIG_DLL_UNLOAD_ORPHANS 0x0005
#define USIG_THREAD_INIT 0x0010
#define USIG_THREAD_EXIT 0x0020
#define USIG_PROCESS_CREATE 0x0100
#define USIG_PROCESS_INIT 0x0200
#define USIG_PROCESS_EXIT 0x0300
#define USIG_PROCESS_DESTROY 0x0400
#define USIG_PROCESS_RUNNING 0x0500
#define USIG_PROCESS_LOADED 0x0600
/* [GS]etProcessDword offsets */
#define GPD_APP_COMPAT_FLAGS (-56)
#define GPD_LOAD_DONE_EVENT (-52)
#define GPD_HINSTANCE16 (-48)
#define GPD_WINDOWS_VERSION (-44)
#define GPD_THDB (-40)
#define GPD_PDB (-36)
#define GPD_STARTF_SHELLDATA (-32)
#define GPD_STARTF_HOTKEY (-28)
#define GPD_STARTF_SHOWWINDOW (-24)
#define GPD_STARTF_SIZE (-20)
#define GPD_STARTF_POSITION (-16)
#define GPD_STARTF_FLAGS (-12)
#define GPD_PARENT (- 8)
#define GPD_FLAGS (- 4)
#define GPD_USERDATA ( 0)
extern DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset );
extern void WINAPI SetProcessDword( DWORD dwProcessID, INT offset, DWORD value );
extern DWORD WINAPI MapProcessHandle( HANDLE handle );
/* memory/environ.c */
extern BOOL ENV_BuildEnvironment(void);
/* scheduler/process.c */
extern void PROCESS_InitWine( int argc, char *argv[] ) WINE_NORETURN;
extern void PROCESS_InitWinelib( int argc, char *argv[] ) WINE_NORETURN;
extern void PROCESS_CallUserSignalProc( UINT uCode, HMODULE hModule );
extern BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR env,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
BOOL inherit, DWORD flags,
STARTUPINFOA *startup, PROCESS_INFORMATION *info,
LPCSTR lpCurrentDirectory );
extern PDB current_process;
extern ENVDB current_envdb;
extern STARTUPINFOA current_startupinfo;
static inline PDB WINE_UNUSED *PROCESS_Current(void)
{
return &current_process;
}
/* definitions contained in Windows process.h file */
/* FIXME: all the stuff above should be moved somewhere else */
#ifndef _INC_PROCESS
#define _INC_PROCESS
typedef void (*LPBEGINTHREAD)(LPVOID);
typedef UINT (WINAPI *LPBEGINTHREADEX)(LPVOID);
......@@ -172,4 +15,4 @@ void _endthread(void);
ULONG _beginthreadex(LPVOID,UINT,LPBEGINTHREADEX,LPVOID,UINT,LPUINT);
void _endthreadex(UINT);
#endif /* __WINE_PROCESS_H */
#endif /* _INC_PROCESS */
......@@ -1880,13 +1880,33 @@ typedef struct tagSYSLEVEL
INT level;
} SYSLEVEL;
/* [GS]etProcessDword offsets */
#define GPD_APP_COMPAT_FLAGS (-56)
#define GPD_LOAD_DONE_EVENT (-52)
#define GPD_HINSTANCE16 (-48)
#define GPD_WINDOWS_VERSION (-44)
#define GPD_THDB (-40)
#define GPD_PDB (-36)
#define GPD_STARTF_SHELLDATA (-32)
#define GPD_STARTF_HOTKEY (-28)
#define GPD_STARTF_SHOWWINDOW (-24)
#define GPD_STARTF_SIZE (-20)
#define GPD_STARTF_POSITION (-16)
#define GPD_STARTF_FLAGS (-12)
#define GPD_PARENT (- 8)
#define GPD_FLAGS (- 4)
#define GPD_USERDATA ( 0)
void WINAPI DisposeLZ32Handle(HANDLE);
HANDLE WINAPI DosFileHandleToWin32Handle(HFILE);
DWORD WINAPI GetProcessDword(DWORD,INT);
VOID WINAPI GetpWin16Lock(SYSLEVEL**);
DWORD WINAPI MapLS(LPCVOID);
DWORD WINAPI MapProcessHandle(HANDLE);
LPVOID WINAPI MapSL(DWORD);
VOID WINAPI ReleaseThunkLock(DWORD*);
VOID WINAPI RestoreThunkLock(DWORD);
void WINAPI SetProcessDword(DWORD,INT,DWORD);
VOID WINAPI UnMapLS(DWORD);
HFILE WINAPI Win32HandleToDosFileHandle(HANDLE);
DWORD WINAPI _ConfirmWin16Lock(void);
......
......@@ -26,7 +26,6 @@
#include "selectors.h"
#include "file.h"
#include "ldt.h"
#include "process.h"
#include "miscemu.h"
#include "debugtools.h"
#include "dosexe.h"
......
......@@ -17,7 +17,6 @@
#include <sys/types.h>
#include "snoop.h"
#include "process.h"
#include "heap.h"
#include "file.h"
#include "module.h"
......
......@@ -19,7 +19,6 @@
#include "heap.h"
#include "task.h"
#include "global.h"
#include "process.h"
#include "snoop.h"
#include "builtin16.h"
#include "stackframe.h"
......@@ -1073,6 +1072,7 @@ HINSTANCE16 WINAPI LoadModule16( LPCSTR name, LPVOID paramBlock )
if (hThread == -1) return 0;
if (!(teb = THREAD_Create( socket, 0, FALSE ))) goto error;
teb->tibflags &= ~TEBF_WIN32;
teb->startup = NE_InitProcess;
/* Create a task for this process */
......
......@@ -31,7 +31,6 @@
#endif
#include "wine/winbase16.h"
#include "winerror.h"
#include "process.h"
#include "snoop.h"
#include "server.h"
#include "debugtools.h"
......@@ -639,21 +638,6 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
if ( pe_export )
dump_exports( hModule );
/* The exe_modref must be in place, before implicit linked DLLs are loaded
by fixup_imports, otherwhise GetModuleFileName will not work and modules
in the executables directory can not be found */
if (!(nt->FileHeader.Characteristics & IMAGE_FILE_DLL))
{
if ( PROCESS_Current()->exe_modref )
FIXME( "Trying to load second .EXE file: %s\n", filename );
else
{
PROCESS_Current()->exe_modref = wm;
PROCESS_Current()->module = wm->module;
}
}
/* Fixup Imports */
if (!(wm->flags & WINE_MODREF_DONT_RESOLVE_REFS) && fixup_imports( wm ))
......@@ -661,7 +645,7 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
/* remove entry from modref chain */
if ( !wm->prev )
PROCESS_Current()->modref_list = wm->next;
MODULE_modref_list = wm->next;
else
wm->prev->next = wm->next;
......@@ -791,7 +775,7 @@ void PE_InitTls( void )
PIMAGE_TLS_DIRECTORY pdir;
int delta;
for (wm = PROCESS_Current()->modref_list;wm;wm=wm->next) {
for (wm = MODULE_modref_list;wm;wm=wm->next) {
peh = PE_HEADER(wm->module);
delta = wm->module - peh->OptionalHeader.ImageBase;
if (!peh->OptionalHeader.DataDirectory[IMAGE_FILE_THREAD_LOCAL_STORAGE].VirtualAddress)
......
......@@ -20,7 +20,6 @@
#include "module.h"
#include "heap.h"
#include "task.h"
#include "process.h"
#include "stackframe.h"
#include "debugtools.h"
......
......@@ -22,7 +22,6 @@
#include "callback.h"
#include "cursoricon.h"
#include "task.h"
#include "process.h"
#include "module.h"
#include "file.h"
#include "debugtools.h"
......
......@@ -18,7 +18,6 @@
#include "instance.h"
#include "miscemu.h"
#include "module.h"
#include "process.h"
#include "queue.h"
#include "selectors.h"
#include "stackframe.h"
......@@ -283,17 +282,18 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
(int)&((PDB16 *)0)->fileHandles );
pTask->pdb.hFileHandles = 0;
memset( pTask->pdb.fileHandles, 0xff, sizeof(pTask->pdb.fileHandles) );
pTask->pdb.environment = current_envdb.env_sel;
/* FIXME: should we make a copy of the environment? */
pTask->pdb.environment = SELECTOROF(GetDOSEnvironment16());
pTask->pdb.nbFiles = 20;
/* Fill the command line */
if (!cmdline)
{
cmdline = current_envdb.cmd_line;
cmdline = GetCommandLineA();
/* remove the first word (program name) */
if (*cmdline == '"')
if (!(cmdline = strchr( cmdline+1, '"' ))) cmdline = current_envdb.cmd_line;
if (!(cmdline = strchr( cmdline+1, '"' ))) cmdline = GetCommandLineA();
while (*cmdline && (*cmdline != ' ') && (*cmdline != '\t')) cmdline++;
while ((*cmdline == ' ') || (*cmdline == '\t')) cmdline++;
len = strlen(cmdline);
......@@ -314,10 +314,6 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
pTask->hCSAlias = GLOBAL_CreateBlock( GMEM_FIXED, (void *)pTask,
sizeof(TDB), pTask->hPDB, WINE_LDT_FLAGS_CODE );
/* Set the owner of the environment block */
FarSetOwner16( pTask->pdb.environment, pTask->hPDB );
/* Default DTA overwrites command line */
pTask->dta = PTR_SEG_OFF_TO_SEGPTR( pTask->hPDB,
......@@ -1320,18 +1316,6 @@ UINT16 WINAPI SetErrorMode16( UINT16 mode )
/***********************************************************************
* GetDOSEnvironment (KERNEL.131)
*/
SEGPTR WINAPI GetDOSEnvironment16(void)
{
TDB *pTask;
if (!(pTask = (TDB *)GlobalLock16( GetCurrentTask() ))) return 0;
return PTR_SEG_OFF_TO_SEGPTR( pTask->pdb.environment, 0 );
}
/***********************************************************************
* GetNumTasks (KERNEL.152)
*/
UINT16 WINAPI GetNumTasks16(void)
......
......@@ -9,10 +9,31 @@
#include "windef.h"
#include "winnls.h"
#include "winerror.h"
#include "process.h"
#include "ntddk.h"
#include "heap.h"
#include "selectors.h"
/* Win32 process environment database */
typedef struct _ENVDB
{
LPSTR environ; /* 00 Process environment strings */
DWORD unknown1; /* 04 Unknown */
LPSTR cmd_line; /* 08 Command line */
LPSTR cur_dir; /* 0c Current directory */
STARTUPINFOA *startup_info; /* 10 Startup information */
HANDLE hStdin; /* 14 Handle for standard input */
HANDLE hStdout; /* 18 Handle for standard output */
HANDLE hStderr; /* 1c Handle for standard error */
DWORD unknown2; /* 20 Unknown */
DWORD inherit_console; /* 24 Inherit console flag */
DWORD break_type; /* 28 Console events flag */
void *break_sem; /* 2c SetConsoleCtrlHandler semaphore */
void *break_event; /* 30 SetConsoleCtrlHandler event */
void *break_thread; /* 34 SetConsoleCtrlHandler thread */
void *break_handlers; /* 38 List of console handlers */
} ENVDB;
/* Format of an environment block:
* ASCIIZ string 1 (xx=yy format)
* ...
......@@ -79,12 +100,13 @@ ENVDB current_envdb =
0, /* break_sem */
0, /* break_event */
0, /* break_thread */
0, /* break_handlers */
CRITICAL_SECTION_INIT, /* section */
0, /* cmd_lineW */
0 /* env_sel */
0 /* break_handlers */
};
static WCHAR *cmdlineW; /* Unicode command line */
static WORD env_sel; /* selector to the environment */
/***********************************************************************
* ENV_FindVariable
*
......@@ -108,7 +130,7 @@ static LPCSTR ENV_FindVariable( LPCSTR env, LPCSTR name, INT len )
*
* Build the environment for the initial process
*/
BOOL ENV_BuildEnvironment(void)
ENVDB *ENV_BuildEnvironment(void)
{
extern char **environ;
LPSTR p, *e;
......@@ -121,9 +143,9 @@ BOOL ENV_BuildEnvironment(void)
/* Now allocate the environment */
if (!(p = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE;
if (!(p = HeapAlloc( GetProcessHeap(), 0, size ))) return NULL;
current_envdb.environ = p;
current_envdb.env_sel = SELECTOR_AllocBlock( p, 0x10000, WINE_LDT_FLAGS_DATA );
env_sel = SELECTOR_AllocBlock( p, 0x10000, WINE_LDT_FLAGS_DATA );
/* And fill it with the Unix environment */
......@@ -136,6 +158,50 @@ BOOL ENV_BuildEnvironment(void)
/* Now add the program name */
FILL_EXTRA_ENV( p );
return &current_envdb;
}
/***********************************************************************
* ENV_BuildCommandLine
*
* Build the command line of a process from the argv array.
*
* Note that it does NOT necessarily include the file name.
* Sometimes we don't even have any command line options at all.
*/
BOOL ENV_BuildCommandLine( char **argv )
{
int len, quote = 0;
char *p, **arg;
for (arg = argv, len = 0; *arg; arg++) len += strlen(*arg) + 1;
if ((argv[0]) && (quote = (strchr( argv[0], ' ' ) != NULL))) len += 2;
if (!(p = current_envdb.cmd_line = HeapAlloc( GetProcessHeap(), 0, len ))) return FALSE;
arg = argv;
if (quote)
{
*p++ = '\"';
strcpy( p, *arg );
p += strlen(p);
*p++ = '\"';
*p++ = ' ';
arg++;
}
while (*arg)
{
strcpy( p, *arg );
p += strlen(p);
*p++ = ' ';
arg++;
}
if (p > current_envdb.cmd_line) p--; /* remove last space */
*p = 0;
/* now allocate the Unicode version */
len = MultiByteToWideChar( CP_ACP, 0, current_envdb.cmd_line, -1, NULL, 0 );
if (!(cmdlineW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
return FALSE;
MultiByteToWideChar( CP_ACP, 0, current_envdb.cmd_line, -1, cmdlineW, len );
return TRUE;
}
......@@ -153,12 +219,7 @@ LPSTR WINAPI GetCommandLineA(void)
*/
LPWSTR WINAPI GetCommandLineW(void)
{
EnterCriticalSection( &current_envdb.section );
if (!current_envdb.cmd_lineW)
current_envdb.cmd_lineW = HEAP_strdupAtoW( GetProcessHeap(), 0,
current_envdb.cmd_line );
LeaveCriticalSection( &current_envdb.section );
return current_envdb.cmd_lineW;
return cmdlineW;
}
......@@ -179,7 +240,7 @@ LPWSTR WINAPI GetEnvironmentStringsW(void)
INT size;
LPWSTR ret;
EnterCriticalSection( &current_envdb.section );
RtlAcquirePebLock();
size = HeapSize( GetProcessHeap(), 0, current_envdb.environ );
if ((ret = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) )) != NULL)
{
......@@ -187,7 +248,7 @@ LPWSTR WINAPI GetEnvironmentStringsW(void)
LPWSTR pW = ret;
while (size--) *pW++ = (WCHAR)(BYTE)*pA++;
}
LeaveCriticalSection( &current_envdb.section );
RtlReleasePebLock();
return ret;
}
......@@ -228,7 +289,7 @@ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size )
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
EnterCriticalSection( &current_envdb.section );
RtlAcquirePebLock();
if ((p = ENV_FindVariable( current_envdb.environ, name, strlen(name) )))
{
ret = strlen(p);
......@@ -241,7 +302,7 @@ DWORD WINAPI GetEnvironmentVariableA( LPCSTR name, LPSTR value, DWORD size )
}
else if (value) strcpy( value, p );
}
LeaveCriticalSection( &current_envdb.section );
RtlReleasePebLock();
if (!ret)
SetLastError( ERROR_ENVVAR_NOT_FOUND );
return ret;
......@@ -276,7 +337,7 @@ BOOL WINAPI SetEnvironmentVariableA( LPCSTR name, LPCSTR value )
LPSTR p, env, new_env;
BOOL ret = FALSE;
EnterCriticalSection( &current_envdb.section );
RtlAcquirePebLock();
env = p = current_envdb.environ;
/* Find a place to insert the string */
......@@ -302,9 +363,7 @@ BOOL WINAPI SetEnvironmentVariableA( LPCSTR name, LPCSTR value )
}
if (!(new_env = HeapReAlloc( GetProcessHeap(), 0, env, old_size + len )))
goto done;
if (current_envdb.env_sel)
current_envdb.env_sel = SELECTOR_ReallocBlock( current_envdb.env_sel,
new_env, old_size + len );
if (env_sel) env_sel = SELECTOR_ReallocBlock( env_sel, new_env, old_size + len );
p = new_env + (p - env);
if (len > 0) memmove( p + len, p, old_size - (p - new_env) );
......@@ -320,7 +379,7 @@ BOOL WINAPI SetEnvironmentVariableA( LPCSTR name, LPCSTR value )
ret = TRUE;
done:
LeaveCriticalSection( &current_envdb.section );
RtlReleasePebLock();
return ret;
}
......@@ -350,7 +409,7 @@ DWORD WINAPI ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
LPCSTR p, var;
if (!count) dst = NULL;
EnterCriticalSection( &current_envdb.section );
RtlAcquirePebLock();
while (*src)
{
......@@ -395,7 +454,7 @@ DWORD WINAPI ExpandEnvironmentStringsA( LPCSTR src, LPSTR dst, DWORD count )
count -= len;
}
}
LeaveCriticalSection( &current_envdb.section );
RtlReleasePebLock();
/* Null-terminate the string */
if (dst)
......@@ -426,6 +485,15 @@ DWORD WINAPI ExpandEnvironmentStringsW( LPCWSTR src, LPWSTR dst, DWORD len )
/***********************************************************************
* GetDOSEnvironment (KERNEL.131)
*/
SEGPTR WINAPI GetDOSEnvironment16(void)
{
return PTR_SEG_OFF_TO_SEGPTR( env_sel, 0 );
}
/***********************************************************************
* GetStdHandle (KERNEL32.276)
*/
HANDLE WINAPI GetStdHandle( DWORD std_handle )
......
......@@ -13,7 +13,6 @@
#include "miscemu.h"
#include "selectors.h"
#include "stackframe.h"
#include "process.h"
#include "server.h"
#include "debugtools.h"
#include "toolhelp.h"
......@@ -296,7 +295,7 @@ DWORD WINAPI WIN16_GetSelectorBase( WORD sel )
*/
DWORD base = GetSelectorBase( sel );
return W32S_WINE2APP( base, W32S_APPLICATION() ? W32S_OFFSET : 0 );
return W32S_WINE2APP( base );
}
DWORD WINAPI GetSelectorBase( WORD sel )
{
......@@ -320,8 +319,7 @@ DWORD WINAPI WIN16_SetSelectorBase( WORD sel, DWORD base )
* See the comment in msdos/vxd.c.
*/
SetSelectorBase( sel,
W32S_APP2WINE( base, W32S_APPLICATION() ? W32S_OFFSET : 0 ) );
SetSelectorBase( sel, W32S_APP2WINE( base ) );
return sel;
}
WORD WINAPI SetSelectorBase( WORD sel, DWORD base )
......
......@@ -28,7 +28,6 @@
#include "wine/port.h"
#include "winerror.h"
#include "file.h"
#include "process.h"
#include "global.h"
#include "server.h"
#include "debugtools.h"
......
......@@ -15,7 +15,7 @@
#include "wingdi.h"
#include "winuser.h"
#include "wine/winbase16.h"
#include "process.h"
#include "module.h"
#include "options.h"
#include "debugtools.h"
#include "winerror.h"
......@@ -259,26 +259,15 @@ static DWORD VERSION_GetSystemDLLVersion( HMODULE hmod )
* 5.12/5.00/5.00/4.00 Win98 calc
* x.xx/5.00/5.00/4.00 win95/win98/NT4 IE5 files
*/
DWORD VERSION_GetLinkedDllVersion(PDB *pdb)
DWORD VERSION_GetLinkedDllVersion(void)
{
WINE_MODREF *wm;
DWORD WinVersion = NB_WINDOWS_VERSIONS;
PIMAGE_OPTIONAL_HEADER ophd;
if (!pdb->exe_modref)
{
if (!pdb->modref_list)
return WIN31;
/* FIXME: The above condition will never trigger, since all our
* standard dlls load their win32 equivalents. We have usually at
* this point: kernel32.dll and ntdll.dll.
*/
return WIN95;
}
/* First check the native dlls provided. These have to be
from one windows version */
for ( wm = pdb->modref_list; wm; wm=wm->next )
for ( wm = MODULE_modref_list; wm; wm=wm->next )
{
ophd = &(PE_HEADER(wm->module)->OptionalHeader);
......@@ -319,10 +308,9 @@ DWORD VERSION_GetLinkedDllVersion(PDB *pdb)
if(WinVersion != NB_WINDOWS_VERSIONS) return WinVersion;
/* we are using no external system dlls, look at the exe */
ophd = &(PE_HEADER(pdb->exe_modref->module)->OptionalHeader);
ophd = &(PE_HEADER(GetModuleHandleA(NULL))->OptionalHeader);
TRACE("-%s: %02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
pdb->exe_modref->modname,
TRACE("%02x.%02x/%02x.%02x/%02x.%02x/%02x.%02x\n",
ophd->MajorLinkerVersion, ophd->MinorLinkerVersion,
ophd->MajorOperatingSystemVersion, ophd->MinorOperatingSystemVersion,
ophd->MajorImageVersion, ophd->MinorImageVersion,
......@@ -373,7 +361,7 @@ static WINDOWS_VERSION VERSION_GetVersion(void)
return defaultWinVersion;
if (winver == 0xffff) /* to be determined */ {
WINDOWS_VERSION retver = VERSION_GetLinkedDllVersion( PROCESS_Current() );
WINDOWS_VERSION retver = VERSION_GetLinkedDllVersion();
if (retver != WIN31) winver = retver;
return retver;
......
......@@ -11,9 +11,10 @@
#include "callback.h"
#include "options.h"
#include "dosexe.h"
#include "process.h"
#include "debugtools.h"
extern void PROCESS_InitWine( int argc, char *argv[] ) WINE_NORETURN;
/***********************************************************************
* Main loop of initial task
*/
......
......@@ -19,7 +19,6 @@
#include "task.h"
#include "toolhelp.h"
#include "selectors.h"
#include "process.h"
#include "callback.h"
#include "debugtools.h"
......@@ -698,8 +697,6 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
* shifted by 0x10000 relative to the OS linear address space.
* See the comment in msdos/vxd.c.
*/
DWORD offset = W32S_APPLICATION() ? W32S_OFFSET : 0;
DWORD dw;
BYTE *ptr;
......@@ -814,16 +811,16 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
}
else
{
CX_reg(context) = HIWORD(W32S_WINE2APP(dw, offset));
DX_reg(context) = LOWORD(W32S_WINE2APP(dw, offset));
CX_reg(context) = HIWORD(W32S_WINE2APP(dw));
DX_reg(context) = LOWORD(W32S_WINE2APP(dw));
}
break;
case 0x0007: /* Set selector base address */
TRACE("set selector base address (0x%04x,0x%08lx)\n",
BX_reg(context),
W32S_APP2WINE(MAKELONG(DX_reg(context),CX_reg(context)), offset));
dw = W32S_APP2WINE(MAKELONG(DX_reg(context), CX_reg(context)), offset);
W32S_APP2WINE(MAKELONG(DX_reg(context),CX_reg(context))));
dw = W32S_APP2WINE(MAKELONG(DX_reg(context), CX_reg(context)));
if (dw < 0x10000)
/* app wants to access lower 64K of DOS memory, map it in now */
DOSMEM_Init(TRUE);
......@@ -854,7 +851,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
TRACE("get descriptor (0x%04x)\n",BX_reg(context));
{
LDT_ENTRY entry;
wine_ldt_set_base( &entry, (void*)W32S_WINE2APP(wine_ldt_get_base(&entry), offset) );
wine_ldt_set_base( &entry, (void*)W32S_WINE2APP(wine_ldt_get_base(&entry)) );
/* FIXME: should use ES:EDI for 32-bit clients */
*(LDT_ENTRY *)PTR_SEG_OFF_TO_LIN( context->SegEs, LOWORD(context->Edi) ) = entry;
}
......@@ -865,7 +862,7 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
{
LDT_ENTRY entry = *(LDT_ENTRY *)PTR_SEG_OFF_TO_LIN( context->SegEs,
LOWORD(context->Edi) );
wine_ldt_set_base( &entry, (void*)W32S_APP2WINE(wine_ldt_get_base(&entry), offset) );
wine_ldt_set_base( &entry, (void*)W32S_APP2WINE(wine_ldt_get_base(&entry)) );
wine_ldt_set_entry( LOWORD(context->Ebx), &entry );
}
break;
......@@ -994,31 +991,30 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
AX_reg(context) = 0x8012; /* linear memory not available */
SET_CFLAG(context);
} else {
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr, offset));
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr, offset));
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr));
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr));
}
break;
case 0x0502: /* Free memory block */
TRACE("free memory block (0x%08lx)\n",
W32S_APP2WINE(MAKELONG(DI_reg(context),SI_reg(context)), offset));
DPMI_xfree( (void *)W32S_APP2WINE(MAKELONG(DI_reg(context),
SI_reg(context)), offset) );
W32S_APP2WINE(MAKELONG(DI_reg(context),SI_reg(context))));
DPMI_xfree( (void *)W32S_APP2WINE(MAKELONG(DI_reg(context), SI_reg(context))) );
break;
case 0x0503: /* Resize memory block */
TRACE("resize memory block (0x%08lx,%ld)\n",
W32S_APP2WINE(MAKELONG(DI_reg(context),SI_reg(context)), offset),
W32S_APP2WINE(MAKELONG(DI_reg(context),SI_reg(context))),
MAKELONG(CX_reg(context),BX_reg(context)));
if (!(ptr = (BYTE *)DPMI_xrealloc(
(void *)W32S_APP2WINE(MAKELONG(DI_reg(context),SI_reg(context)), offset),
(void *)W32S_APP2WINE(MAKELONG(DI_reg(context),SI_reg(context))),
MAKELONG(CX_reg(context),BX_reg(context)))))
{
AX_reg(context) = 0x8012; /* linear memory not available */
SET_CFLAG(context);
} else {
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr, offset));
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr, offset));
BX_reg(context) = SI_reg(context) = HIWORD(W32S_WINE2APP(ptr));
CX_reg(context) = DI_reg(context) = LOWORD(W32S_WINE2APP(ptr));
}
break;
......@@ -1065,8 +1061,8 @@ void WINAPI INT_Int31Handler( CONTEXT86 *context )
}
else
{
BX_reg(context) = HIWORD(W32S_WINE2APP(ptr, offset));
CX_reg(context) = LOWORD(W32S_WINE2APP(ptr, offset));
BX_reg(context) = HIWORD(W32S_WINE2APP(ptr));
CX_reg(context) = LOWORD(W32S_WINE2APP(ptr));
RESET_CFLAG(context);
}
break;
......
......@@ -16,7 +16,6 @@
#include "syslevel.h"
#include "main.h"
#include "module.h"
#include "process.h"
#include "debugtools.h"
DEFAULT_DEBUG_CHANNEL(relay);
......@@ -114,7 +113,7 @@ static void get_entry_point( char *buffer, DEBUG_ENTRY_POINT *relay )
/* First find the module */
for (wm = PROCESS_Current()->modref_list; wm; wm = wm->next)
for (wm = MODULE_modref_list; wm; wm = wm->next)
{
if (!(wm->flags & WINE_MODREF_INTERNAL)) continue;
base = (char *)wm->module;
......
......@@ -31,7 +31,6 @@
#include <stdarg.h>
#include "wine/port.h"
#include "process.h"
#include "thread.h"
#include "server.h"
#include "winerror.h"
......
......@@ -15,7 +15,6 @@
#include <unistd.h>
#include "wine/winbase16.h"
#include "thread.h"
#include "process.h"
#include "task.h"
#include "module.h"
#include "global.h"
......@@ -35,6 +34,8 @@ DEFAULT_DEBUG_CHANNEL(thread);
/* TEB of the initial thread */
static TEB initial_teb;
extern struct _PDB current_process;
/***********************************************************************
* THREAD_IsWin16
*/
......@@ -239,8 +240,8 @@ TEB *THREAD_Create( int fd, DWORD stack_size, BOOL alloc_stack16 )
if ((teb = THREAD_InitStack( NULL, stack_size, alloc_stack16 )))
{
teb->tibflags = (current_process.flags & PDB32_WIN16_PROC) ? 0 : TEBF_WIN32;
teb->process = &current_process;
teb->tibflags = TEBF_WIN32;
teb->process = NtCurrentTeb()->process;
teb->socket = fd;
fcntl( fd, F_SETFD, 1 ); /* set close on exec flag */
TRACE("(%p) succeeded\n", teb);
......@@ -304,7 +305,6 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
close( socket );
return 0;
}
teb->tibflags |= TEBF_WIN32;
teb->entry_point = start;
teb->entry_arg = param;
teb->startup = THREAD_Start;
......@@ -379,115 +379,6 @@ void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */
}
/**********************************************************************
* TlsAlloc [KERNEL32.530] Allocates a TLS index.
*
* Allocates a thread local storage index
*
* RETURNS
* Success: TLS Index
* Failure: 0xFFFFFFFF
*/
DWORD WINAPI TlsAlloc( void )
{
DWORD i, mask, ret = 0;
DWORD *bits = current_process.tls_bits;
EnterCriticalSection( &current_process.crit_section );
if (*bits == 0xffffffff)
{
bits++;
ret = 32;
if (*bits == 0xffffffff)
{
LeaveCriticalSection( &current_process.crit_section );
SetLastError( ERROR_NO_MORE_ITEMS );
return 0xffffffff;
}
}
for (i = 0, mask = 1; i < 32; i++, mask <<= 1) if (!(*bits & mask)) break;
*bits |= mask;
LeaveCriticalSection( &current_process.crit_section );
return ret + i;
}
/**********************************************************************
* TlsFree [KERNEL32.531] Releases a TLS index.
*
* Releases a thread local storage index, making it available for reuse
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL WINAPI TlsFree(
DWORD index) /* [in] TLS Index to free */
{
DWORD mask;
DWORD *bits = current_process.tls_bits;
if (index >= 64)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
EnterCriticalSection( &current_process.crit_section );
if (index >= 32) bits++;
mask = (1 << (index & 31));
if (!(*bits & mask)) /* already free? */
{
LeaveCriticalSection( &current_process.crit_section );
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
*bits &= ~mask;
NtCurrentTeb()->tls_array[index] = 0;
/* FIXME: should zero all other thread values */
LeaveCriticalSection( &current_process.crit_section );
return TRUE;
}
/**********************************************************************
* TlsGetValue [KERNEL32.532] Gets value in a thread's TLS slot
*
* RETURNS
* Success: Value stored in calling thread's TLS slot for index
* Failure: 0 and GetLastError returns NO_ERROR
*/
LPVOID WINAPI TlsGetValue(
DWORD index) /* [in] TLS index to retrieve value for */
{
if (index >= 64)
{
SetLastError( ERROR_INVALID_PARAMETER );
return NULL;
}
SetLastError( ERROR_SUCCESS );
return NtCurrentTeb()->tls_array[index];
}
/**********************************************************************
* TlsSetValue [KERNEL32.533] Stores a value in the thread's TLS slot.
*
* RETURNS
* Success: TRUE
* Failure: FALSE
*/
BOOL WINAPI TlsSetValue(
DWORD index, /* [in] TLS index to set value for */
LPVOID value) /* [in] Value to be stored */
{
if (index >= 64)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
NtCurrentTeb()->tls_array[index] = value;
return TRUE;
}
/***********************************************************************
* SetThreadContext [KERNEL32.670] Sets context of thread.
*
......
......@@ -43,7 +43,6 @@
#include "wine/keyboard16.h"
#include "thread.h"
#include "file.h"
#include "process.h"
#include "winerror.h"
#include "wincon.h"
#include "heap.h"
......
......@@ -27,7 +27,6 @@
#include "winreg.h"
#include "winerror.h"
#include "file.h"
#include "process.h"
#include "heap.h"
#include "winioctl.h"
#include "winnt.h"
......
......@@ -29,7 +29,6 @@
#include "wine/exception.h"
#include "selectors.h"
#include "callback.h"
#include "process.h"
#include "thread.h"
#include "stackframe.h"
#include "server.h"
......@@ -37,6 +36,8 @@
DEFAULT_DEBUG_CHANNEL(seh);
static PTOP_LEVEL_EXCEPTION_FILTER top_filter;
/*******************************************************************
* RaiseException (KERNEL32.418)
......@@ -143,7 +144,6 @@ static void format_exception_msg( const EXCEPTION_POINTERS *ptr, char *buffer )
*/
DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
{
PDB* pdb = PROCESS_Current();
char format[256];
char buffer[256];
HKEY hDbgConf;
......@@ -179,9 +179,9 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
FIXME("Unsupported yet debug continue value %d (please report)\n", status);
}
if (pdb->top_filter)
if (top_filter)
{
DWORD ret = pdb->top_filter( epointers );
DWORD ret = top_filter( epointers );
if (ret != EXCEPTION_CONTINUE_SEARCH) return ret;
}
......@@ -265,9 +265,8 @@ DWORD WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS epointers)
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter(
LPTOP_LEVEL_EXCEPTION_FILTER filter )
{
PDB *pdb = PROCESS_Current();
LPTOP_LEVEL_EXCEPTION_FILTER old = pdb->top_filter;
pdb->top_filter = filter;
LPTOP_LEVEL_EXCEPTION_FILTER old = top_filter;
top_filter = filter;
return old;
}
......
......@@ -23,7 +23,6 @@
#include "winbase.h"
#include "winerror.h"
#include "file.h"
#include "process.h"
#include "heap.h"
#include "debugtools.h"
......
......@@ -24,7 +24,7 @@
#include "sysmetrics.h"
#include "callback.h"
#include "local.h"
#include "process.h"
#include "module.h"
#include "debugtools.h"
DECLARE_DEBUG_CHANNEL(hook);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment