Mark initial process as 32-bit for WineLib apps.
Use teb->tibflags instead of teb->flags (for Win95 USER32 compatibility). Removed unused thread event.
This commit is contained in:
parent
17b1f46150
commit
f3bfa3a4b0
|
@ -8,7 +8,7 @@
|
||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
|
|
||||||
extern void MAIN_Usage(char*);
|
extern void MAIN_Usage(char*);
|
||||||
extern BOOL MAIN_MainInit( int *argc, char *argv[] );
|
extern BOOL MAIN_MainInit( int *argc, char *argv[], BOOL win32 );
|
||||||
extern BOOL MAIN_WineInit( int *argc, char *argv[] );
|
extern BOOL MAIN_WineInit( int *argc, char *argv[] );
|
||||||
extern HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
|
extern HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] );
|
||||||
extern int MAIN_GetLanguageID(char*lang, char*country, char*charset, char*dialect);
|
extern int MAIN_GetLanguageID(char*lang, char*country, char*charset, char*dialect);
|
||||||
|
|
|
@ -155,7 +155,7 @@ extern BOOL ENV_InheritEnvironment( LPCSTR env );
|
||||||
extern void ENV_FreeEnvironment( PDB *pdb );
|
extern void ENV_FreeEnvironment( PDB *pdb );
|
||||||
|
|
||||||
/* scheduler/process.c */
|
/* scheduler/process.c */
|
||||||
extern BOOL PROCESS_Init( void );
|
extern BOOL PROCESS_Init( BOOL win32 );
|
||||||
extern BOOL PROCESS_IsCurrent( HANDLE handle );
|
extern BOOL PROCESS_IsCurrent( HANDLE handle );
|
||||||
extern PDB *PROCESS_Initial(void);
|
extern PDB *PROCESS_Initial(void);
|
||||||
extern PDB *PROCESS_IdToPDB( DWORD id );
|
extern PDB *PROCESS_IdToPDB( DWORD id );
|
||||||
|
|
|
@ -143,7 +143,6 @@ typedef struct _THHOOK
|
||||||
#include "poppack.h"
|
#include "poppack.h"
|
||||||
|
|
||||||
extern THHOOK *pThhook;
|
extern THHOOK *pThhook;
|
||||||
extern void (*TASK_AddTaskEntryBreakpoint)( HTASK16 hTask );
|
|
||||||
|
|
||||||
extern BOOL TASK_Create( struct _NE_MODULE *pModule, UINT16 cmdShow );
|
extern BOOL TASK_Create( struct _NE_MODULE *pModule, UINT16 cmdShow );
|
||||||
extern void TASK_KillTask( HTASK16 hTask );
|
extern void TASK_KillTask( HTASK16 hTask );
|
||||||
|
|
|
@ -56,13 +56,13 @@ DEFAULT_DEBUG_CHANNEL(server)
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* Main initialisation routine
|
* Main initialisation routine
|
||||||
*/
|
*/
|
||||||
BOOL MAIN_MainInit( int *argc, char *argv[] )
|
BOOL MAIN_MainInit( int *argc, char *argv[], BOOL win32 )
|
||||||
{
|
{
|
||||||
/* store the program name */
|
/* store the program name */
|
||||||
argv0 = argv[0];
|
argv0 = argv[0];
|
||||||
|
|
||||||
/* Create the initial process */
|
/* Create the initial process */
|
||||||
if (!PROCESS_Init()) return 0;
|
if (!PROCESS_Init( win32 )) return 0;
|
||||||
|
|
||||||
/* Initialize syslevel handling */
|
/* Initialize syslevel handling */
|
||||||
SYSLEVEL_Init();
|
SYSLEVEL_Init();
|
||||||
|
@ -297,7 +297,7 @@ HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] )
|
||||||
HMODULE16 hModule;
|
HMODULE16 hModule;
|
||||||
|
|
||||||
/* Main initialization */
|
/* Main initialization */
|
||||||
if (!MAIN_MainInit( argc, argv )) return 0;
|
if (!MAIN_MainInit( argc, argv, TRUE )) return 0;
|
||||||
|
|
||||||
/* Create and switch to initial task */
|
/* Create and switch to initial task */
|
||||||
if (!(wm = ELF_CreateDummyModule( argv[0], argv[0] )))
|
if (!(wm = ELF_CreateDummyModule( argv[0], argv[0] )))
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "callback.h"
|
#include "callback.h"
|
||||||
|
#include "debugger.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
|
|
||||||
DEFAULT_DEBUG_CHANNEL(process)
|
DEFAULT_DEBUG_CHANNEL(process)
|
||||||
|
@ -38,9 +39,6 @@ static PDB initial_pdb;
|
||||||
|
|
||||||
static PDB *PROCESS_First = &initial_pdb;
|
static PDB *PROCESS_First = &initial_pdb;
|
||||||
|
|
||||||
/* Pointer to debugger callback routine */
|
|
||||||
void (*TASK_AddTaskEntryBreakpoint)( HTASK16 hTask ) = NULL;
|
|
||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* PROCESS_WalkProcess
|
* PROCESS_WalkProcess
|
||||||
|
@ -322,7 +320,7 @@ static PDB *PROCESS_CreatePDB( PDB *parent, BOOL inherit )
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* PROCESS_Init
|
* PROCESS_Init
|
||||||
*/
|
*/
|
||||||
BOOL PROCESS_Init(void)
|
BOOL PROCESS_Init( BOOL win32 )
|
||||||
{
|
{
|
||||||
TEB *teb;
|
TEB *teb;
|
||||||
int server_fd;
|
int server_fd;
|
||||||
|
@ -337,7 +335,7 @@ BOOL PROCESS_Init(void)
|
||||||
initial_pdb.ring0_threads = 1;
|
initial_pdb.ring0_threads = 1;
|
||||||
initial_pdb.group = &initial_pdb;
|
initial_pdb.group = &initial_pdb;
|
||||||
initial_pdb.priority = 8; /* Normal */
|
initial_pdb.priority = 8; /* Normal */
|
||||||
initial_pdb.flags = PDB32_WIN16_PROC;
|
initial_pdb.flags = win32? 0 : PDB32_WIN16_PROC;
|
||||||
initial_pdb.winver = 0xffff; /* to be determined */
|
initial_pdb.winver = 0xffff; /* to be determined */
|
||||||
initial_pdb.main_queue = INVALID_HANDLE_VALUE16;
|
initial_pdb.main_queue = INVALID_HANDLE_VALUE16;
|
||||||
|
|
||||||
|
@ -494,9 +492,8 @@ void PROCESS_Start(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If requested, add entry point breakpoint */
|
/* If requested, add entry point breakpoint */
|
||||||
if ( (Options.debug && TASK_AddTaskEntryBreakpoint) ||
|
if ( Options.debug || (pdb->flags & PDB32_DEBUGGED) )
|
||||||
(pdb->flags & PDB32_DEBUGGED))
|
DEBUG_AddTaskEntryBreakpoint( pdb->task );
|
||||||
TASK_AddTaskEntryBreakpoint( pdb->task );
|
|
||||||
|
|
||||||
/* Call UserSignalProc ( USIG_PROCESS_RUNNING ... ) only for non-GUI win32 apps */
|
/* Call UserSignalProc ( USIG_PROCESS_RUNNING ... ) only for non-GUI win32 apps */
|
||||||
if ( type != PROC_WIN16 && (pdb->flags & PDB32_CONSOLE_PROC))
|
if ( type != PROC_WIN16 && (pdb->flags & PDB32_CONSOLE_PROC))
|
||||||
|
@ -760,7 +757,7 @@ DWORD WINAPI GetProcessDword( DWORD dwProcessID, INT offset )
|
||||||
return process->env_db->startup_info->dwFlags;
|
return process->env_db->startup_info->dwFlags;
|
||||||
|
|
||||||
case GPD_PARENT:
|
case GPD_PARENT:
|
||||||
return (DWORD)process->parent->server_pid;
|
return process->parent? (DWORD)process->parent->server_pid : 0;
|
||||||
|
|
||||||
case GPD_FLAGS:
|
case GPD_FLAGS:
|
||||||
return process->flags;
|
return process->flags;
|
||||||
|
|
|
@ -44,7 +44,7 @@ TEB *THREAD_First = &initial_teb;
|
||||||
*/
|
*/
|
||||||
BOOL THREAD_IsWin16( TEB *teb )
|
BOOL THREAD_IsWin16( TEB *teb )
|
||||||
{
|
{
|
||||||
return !teb || !(teb->flags & TEBF_WIN32);
|
return !teb || !(teb->tibflags & TEBF_WIN32);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
@ -119,11 +119,6 @@ static BOOL THREAD_InitTEB( TEB *teb, DWORD stack_size, BOOL alloc_stack16,
|
||||||
teb->signal_stack = (char *)teb->signal_stack + 0x10000;
|
teb->signal_stack = (char *)teb->signal_stack + 0x10000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Create the thread event */
|
|
||||||
|
|
||||||
if (!(teb->event = CreateEventA( NULL, FALSE, FALSE, NULL ))) goto error;
|
|
||||||
teb->event = ConvertToGlobalHandle( teb->event );
|
|
||||||
|
|
||||||
/* StaticUnicodeString */
|
/* StaticUnicodeString */
|
||||||
|
|
||||||
teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer);
|
teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer);
|
||||||
|
@ -132,7 +127,6 @@ static BOOL THREAD_InitTEB( TEB *teb, DWORD stack_size, BOOL alloc_stack16,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (teb->event) CloseHandle( teb->event );
|
|
||||||
if (teb->stack_sel) SELECTOR_FreeBlock( teb->stack_sel, 1 );
|
if (teb->stack_sel) SELECTOR_FreeBlock( teb->stack_sel, 1 );
|
||||||
if (teb->stack_base) VirtualFree( teb->stack_base, 0, MEM_RELEASE );
|
if (teb->stack_base) VirtualFree( teb->stack_base, 0, MEM_RELEASE );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -155,7 +149,6 @@ void CALLBACK THREAD_FreeTEB( ULONG_PTR arg )
|
||||||
|
|
||||||
PROCESS_CallUserSignalProc( USIG_THREAD_EXIT, (DWORD)teb->tid, 0 );
|
PROCESS_CallUserSignalProc( USIG_THREAD_EXIT, (DWORD)teb->tid, 0 );
|
||||||
|
|
||||||
CloseHandle( teb->event );
|
|
||||||
while (*pptr && (*pptr != teb)) pptr = &(*pptr)->next;
|
while (*pptr && (*pptr != teb)) pptr = &(*pptr)->next;
|
||||||
if (*pptr) *pptr = teb->next;
|
if (*pptr) *pptr = teb->next;
|
||||||
|
|
||||||
|
@ -180,7 +173,7 @@ TEB *THREAD_CreateInitialThread( PDB *pdb, int server_fd )
|
||||||
{
|
{
|
||||||
initial_teb.except = (void *)-1;
|
initial_teb.except = (void *)-1;
|
||||||
initial_teb.self = &initial_teb;
|
initial_teb.self = &initial_teb;
|
||||||
initial_teb.flags = /* TEBF_WIN32 */ 0;
|
initial_teb.tibflags = (pdb->flags & PDB32_WIN16_PROC)? 0 : TEBF_WIN32;
|
||||||
initial_teb.tls_ptr = initial_teb.tls_array;
|
initial_teb.tls_ptr = initial_teb.tls_array;
|
||||||
initial_teb.process = pdb;
|
initial_teb.process = pdb;
|
||||||
initial_teb.exit_code = 0x103; /* STILL_ACTIVE */
|
initial_teb.exit_code = 0x103; /* STILL_ACTIVE */
|
||||||
|
@ -224,7 +217,7 @@ TEB *THREAD_Create( PDB *pdb, int fd, DWORD flags, DWORD stack_size, BOOL alloc_
|
||||||
teb->except = (void *)-1;
|
teb->except = (void *)-1;
|
||||||
teb->htask16 = pdb->task;
|
teb->htask16 = pdb->task;
|
||||||
teb->self = teb;
|
teb->self = teb;
|
||||||
teb->flags = (pdb->flags & PDB32_WIN16_PROC)? 0 : TEBF_WIN32;
|
teb->tibflags = (pdb->flags & PDB32_WIN16_PROC)? 0 : TEBF_WIN32;
|
||||||
teb->tls_ptr = teb->tls_array;
|
teb->tls_ptr = teb->tls_array;
|
||||||
teb->process = pdb;
|
teb->process = pdb;
|
||||||
teb->exit_code = 0x103; /* STILL_ACTIVE */
|
teb->exit_code = 0x103; /* STILL_ACTIVE */
|
||||||
|
@ -300,7 +293,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack,
|
||||||
int handle = -1;
|
int handle = -1;
|
||||||
TEB *teb = THREAD_Create( PROCESS_Current(), -1, flags, stack, TRUE, sa, &handle );
|
TEB *teb = THREAD_Create( PROCESS_Current(), -1, flags, stack, TRUE, sa, &handle );
|
||||||
if (!teb) return 0;
|
if (!teb) return 0;
|
||||||
teb->flags |= TEBF_WIN32;
|
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;
|
||||||
|
|
Loading…
Reference in New Issue