Commit 52900c81 authored by Alexandre Julliard's avatar Alexandre Julliard

Make PDB, ENVDB and STARTUPINFO global variables.

Added 'module' field in PDB, and removed Wine-specific fields.
parent 46733de1
......@@ -43,7 +43,7 @@ typedef struct
typedef struct _PDB
{
LONG header[2]; /* 00 Kernel object header */
DWORD unknown1; /* 08 Unknown */
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 */
......@@ -52,7 +52,7 @@ typedef struct _PDB
DWORD flags; /* 20 Flags */
void *pdb16; /* 24 DOS PSP */
WORD PSP_sel; /* 28 Selector to DOS PSP */
WORD module; /* 2a IMTE for the process module */
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 */
......@@ -87,10 +87,6 @@ typedef struct _PDB
struct _UTINFO *UTState; /* bc Head of Univeral Thunk list */
DWORD unknown8; /* c0 Unknown (NT) */
LCID locale; /* c4 Locale to be queried by GetThreadLocale (NT) */
/* The following are Wine-specific fields */
HANDLE *dos_handles; /* Handles mapping DOS -> Win32 */
WORD winver; /* Windows version figured out by VERSION_GetVersion */
struct _SERVICETABLE *service_table; /* Service table for service thread */
} PDB;
/* Process flags */
......@@ -149,7 +145,6 @@ 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 PDB *PROCESS_IdToPDB( DWORD id );
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,
......@@ -157,9 +152,13 @@ extern BOOL PROCESS_Create( HFILE hFile, LPCSTR filename, LPSTR cmd_line, LPCSTR
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 NtCurrentTeb()->process;
return &current_process;
}
#endif /* __WINE_PROCESS_H */
......@@ -863,7 +863,10 @@ WINE_MODREF *PE_CreateModule( HMODULE hModule, LPCSTR filename, DWORD flags,
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 */
......
......@@ -15,7 +15,6 @@
#include "file.h"
#include "global.h"
#include "instance.h"
#include "message.h"
#include "miscemu.h"
#include "module.h"
#include "neexe.h"
......@@ -224,7 +223,6 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
HTASK16 hTask;
TDB *pTask;
char name[10];
PDB *pdb32 = PROCESS_Current();
/* Allocate the task structure */
......@@ -270,7 +268,7 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
/* Allocate a selector for the PDB */
pTask->hPDB = GLOBAL_CreateBlock( GMEM_FIXED, &pTask->pdb, sizeof(PDB16),
pModule->self, FALSE, FALSE, FALSE, NULL );
pModule->self, FALSE, FALSE, FALSE );
/* Fill the PDB */
......@@ -286,17 +284,17 @@ 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 = pdb32->env_db->env_sel;
pTask->pdb.environment = current_envdb.env_sel;
pTask->pdb.nbFiles = 20;
/* Fill the command line */
if (!cmdline)
{
cmdline = pdb32->env_db->cmd_line;
cmdline = current_envdb.cmd_line;
/* remove the first word (program name) */
if (*cmdline == '"')
if (!(cmdline = strchr( cmdline+1, '"' ))) cmdline = pdb32->env_db->cmd_line;
if (!(cmdline = strchr( cmdline+1, '"' ))) cmdline = current_envdb.cmd_line;
while (*cmdline && (*cmdline != ' ') && (*cmdline != '\t')) cmdline++;
while ((*cmdline == ' ') || (*cmdline == '\t')) cmdline++;
len = strlen(cmdline);
......@@ -316,7 +314,7 @@ BOOL TASK_Create( NE_MODULE *pModule, UINT16 cmdShow, TEB *teb, LPCSTR cmdline,
pTask->hCSAlias = GLOBAL_CreateBlock( GMEM_FIXED, (void *)pTask,
sizeof(TDB), pTask->hPDB, TRUE,
FALSE, FALSE, NULL );
FALSE, FALSE );
/* Set the owner of the environment block */
......
......@@ -35,9 +35,6 @@ DEFAULT_DEBUG_CHANNEL(thread);
/* TEB of the initial thread */
static TEB initial_teb;
/* The initial process PDB */
static PDB initial_pdb;
/***********************************************************************
* THREAD_IsWin16
*/
......@@ -216,7 +213,7 @@ void THREAD_Init(void)
{
THREAD_InitTEB( &initial_teb );
assert( initial_teb.teb_sel );
initial_teb.process = &initial_pdb;
initial_teb.process = &current_process;
SYSDEPS_SetCurThread( &initial_teb );
}
}
......@@ -233,8 +230,8 @@ TEB *THREAD_Create( int fd, DWORD stack_size, BOOL alloc_stack16 )
if ((teb = THREAD_InitStack( NULL, stack_size, alloc_stack16 )))
{
teb->tibflags = (PROCESS_Current()->flags & PDB32_WIN16_PROC) ? 0 : TEBF_WIN32;
teb->process = PROCESS_Current();
teb->tibflags = (current_process.flags & PDB32_WIN16_PROC) ? 0 : TEBF_WIN32;
teb->process = &current_process;
teb->socket = fd;
fcntl( fd, F_SETFD, 1 ); /* set close on exec flag */
TRACE("(%p) succeeded\n", teb);
......@@ -368,24 +365,23 @@ void WINAPI ExitThread( DWORD code ) /* [in] Exit code for this thread */
*/
DWORD WINAPI TlsAlloc( void )
{
PDB *process = PROCESS_Current();
DWORD i, mask, ret = 0;
DWORD *bits = process->tls_bits;
EnterCriticalSection( &process->crit_section );
DWORD *bits = current_process.tls_bits;
EnterCriticalSection( &current_process.crit_section );
if (*bits == 0xffffffff)
{
bits++;
ret = 32;
if (*bits == 0xffffffff)
{
LeaveCriticalSection( &process->crit_section );
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( &process->crit_section );
LeaveCriticalSection( &current_process.crit_section );
return ret + i;
}
......@@ -402,27 +398,26 @@ DWORD WINAPI TlsAlloc( void )
BOOL WINAPI TlsFree(
DWORD index) /* [in] TLS Index to free */
{
PDB *process = PROCESS_Current();
DWORD mask;
DWORD *bits = process->tls_bits;
DWORD *bits = current_process.tls_bits;
if (index >= 64)
{
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
EnterCriticalSection( &process->crit_section );
EnterCriticalSection( &current_process.crit_section );
if (index >= 32) bits++;
mask = (1 << (index & 31));
if (!(*bits & mask)) /* already free? */
{
LeaveCriticalSection( &process->crit_section );
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( &process->crit_section );
LeaveCriticalSection( &current_process.crit_section );
return TRUE;
}
......
......@@ -14,7 +14,6 @@
#include "heap.h"
#include "task.h"
#include "debugtools.h"
#include "process.h"
DEFAULT_DEBUG_CHANNEL(win32);
......@@ -27,60 +26,6 @@ static WINE_EXCEPTION_FILTER(page_fault)
}
/***********************************************************************
* GetStartupInfoA (KERNEL32.273)
*/
VOID WINAPI GetStartupInfoA(LPSTARTUPINFOA lpStartupInfo)
{
LPSTARTUPINFOA startup;
startup = ((LPSTARTUPINFOA )PROCESS_Current()->env_db->startup_info);
memcpy ( lpStartupInfo, startup, sizeof (STARTUPINFOA) );
TRACE("size: %ld\n"
"\tlpReserverd: %s, lpDesktop: %s, lpTitle: %s\n"
"\tdwX: %ld, dwY: %ld, dwXSize: %ld, dwYSize: %ld\n"
"\tdwFlags: %lx, wShowWindow: %x\n", lpStartupInfo->cb,
debugstr_a(lpStartupInfo->lpReserved),
debugstr_a(lpStartupInfo->lpDesktop),
debugstr_a(lpStartupInfo->lpTitle),
lpStartupInfo->dwX, lpStartupInfo->dwY,
lpStartupInfo->dwXSize, lpStartupInfo->dwYSize,
lpStartupInfo->dwFlags, lpStartupInfo->wShowWindow );
}
/***********************************************************************
* GetStartupInfoW (KERNEL32.274)
*/
VOID WINAPI GetStartupInfoW(LPSTARTUPINFOW lpStartupInfo)
{
STARTUPINFOA startup;
GetStartupInfoA ( &startup );
lpStartupInfo->cb = sizeof(STARTUPINFOW);
lpStartupInfo->lpReserved =
HEAP_strdupAtoW (GetProcessHeap(), 0, startup.lpReserved );
lpStartupInfo->lpDesktop =
HEAP_strdupAtoW (GetProcessHeap(), 0, startup.lpDesktop );
lpStartupInfo->lpTitle =
HEAP_strdupAtoW (GetProcessHeap(), 0, startup.lpTitle );
lpStartupInfo->dwX = startup.dwX;
lpStartupInfo->dwY = startup.dwY;
lpStartupInfo->dwXSize = startup.dwXSize;
lpStartupInfo->dwXCountChars = startup.dwXCountChars;
lpStartupInfo->dwYCountChars = startup.dwYCountChars;
lpStartupInfo->dwFillAttribute = startup.dwFillAttribute;
lpStartupInfo->dwFlags = startup.dwFlags;
lpStartupInfo->wShowWindow = startup.wShowWindow;
lpStartupInfo->cbReserved2 = startup.cbReserved2;
lpStartupInfo->lpReserved2 = startup.lpReserved2;
lpStartupInfo->hStdInput = startup.hStdInput;
lpStartupInfo->hStdOutput = startup.hStdOutput;
lpStartupInfo->hStdError = startup.hStdError;
}
/***********************************************************************
* GetComputerNameA (KERNEL32.165)
*/
BOOL WINAPI GetComputerNameA(LPSTR name,LPDWORD size)
......
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