From f3bfa3a4b010808c7e7afe9bffdd58a85126183e Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Sun, 30 Jan 2000 21:16:06 +0000 Subject: [PATCH] Mark initial process as 32-bit for WineLib apps. Use teb->tibflags instead of teb->flags (for Win95 USER32 compatibility). Removed unused thread event. --- include/main.h | 2 +- include/process.h | 2 +- include/task.h | 1 - loader/main.c | 6 +++--- scheduler/process.c | 15 ++++++--------- scheduler/thread.c | 15 ++++----------- 6 files changed, 15 insertions(+), 26 deletions(-) diff --git a/include/main.h b/include/main.h index c473364244e..58db6c957d5 100644 --- a/include/main.h +++ b/include/main.h @@ -8,7 +8,7 @@ #include "windef.h" 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 HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] ); extern int MAIN_GetLanguageID(char*lang, char*country, char*charset, char*dialect); diff --git a/include/process.h b/include/process.h index 7f1f4a116c7..7ad864eed40 100644 --- a/include/process.h +++ b/include/process.h @@ -155,7 +155,7 @@ extern BOOL ENV_InheritEnvironment( LPCSTR env ); extern void ENV_FreeEnvironment( PDB *pdb ); /* scheduler/process.c */ -extern BOOL PROCESS_Init( void ); +extern BOOL PROCESS_Init( BOOL win32 ); extern BOOL PROCESS_IsCurrent( HANDLE handle ); extern PDB *PROCESS_Initial(void); extern PDB *PROCESS_IdToPDB( DWORD id ); diff --git a/include/task.h b/include/task.h index eac23022084..d3e6a12ce7a 100644 --- a/include/task.h +++ b/include/task.h @@ -143,7 +143,6 @@ typedef struct _THHOOK #include "poppack.h" extern THHOOK *pThhook; -extern void (*TASK_AddTaskEntryBreakpoint)( HTASK16 hTask ); extern BOOL TASK_Create( struct _NE_MODULE *pModule, UINT16 cmdShow ); extern void TASK_KillTask( HTASK16 hTask ); diff --git a/loader/main.c b/loader/main.c index c3d7cc31ab2..c0f2d196dfb 100644 --- a/loader/main.c +++ b/loader/main.c @@ -56,13 +56,13 @@ DEFAULT_DEBUG_CHANNEL(server) /*********************************************************************** * Main initialisation routine */ -BOOL MAIN_MainInit( int *argc, char *argv[] ) +BOOL MAIN_MainInit( int *argc, char *argv[], BOOL win32 ) { /* store the program name */ argv0 = argv[0]; /* Create the initial process */ - if (!PROCESS_Init()) return 0; + if (!PROCESS_Init( win32 )) return 0; /* Initialize syslevel handling */ SYSLEVEL_Init(); @@ -297,7 +297,7 @@ HINSTANCE MAIN_WinelibInit( int *argc, char *argv[] ) HMODULE16 hModule; /* Main initialization */ - if (!MAIN_MainInit( argc, argv )) return 0; + if (!MAIN_MainInit( argc, argv, TRUE )) return 0; /* Create and switch to initial task */ if (!(wm = ELF_CreateDummyModule( argv[0], argv[0] ))) diff --git a/scheduler/process.c b/scheduler/process.c index eb6c4bd6a96..e5dcf296102 100644 --- a/scheduler/process.c +++ b/scheduler/process.c @@ -26,6 +26,7 @@ #include "server.h" #include "options.h" #include "callback.h" +#include "debugger.h" #include "debugtools.h" DEFAULT_DEBUG_CHANNEL(process) @@ -38,9 +39,6 @@ static PDB initial_pdb; static PDB *PROCESS_First = &initial_pdb; - /* Pointer to debugger callback routine */ -void (*TASK_AddTaskEntryBreakpoint)( HTASK16 hTask ) = NULL; - /*********************************************************************** * PROCESS_WalkProcess @@ -322,7 +320,7 @@ static PDB *PROCESS_CreatePDB( PDB *parent, BOOL inherit ) /*********************************************************************** * PROCESS_Init */ -BOOL PROCESS_Init(void) +BOOL PROCESS_Init( BOOL win32 ) { TEB *teb; int server_fd; @@ -337,7 +335,7 @@ BOOL PROCESS_Init(void) initial_pdb.ring0_threads = 1; initial_pdb.group = &initial_pdb; 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.main_queue = INVALID_HANDLE_VALUE16; @@ -494,9 +492,8 @@ void PROCESS_Start(void) } /* If requested, add entry point breakpoint */ - if ( (Options.debug && TASK_AddTaskEntryBreakpoint) || - (pdb->flags & PDB32_DEBUGGED)) - TASK_AddTaskEntryBreakpoint( pdb->task ); + if ( Options.debug || (pdb->flags & PDB32_DEBUGGED) ) + DEBUG_AddTaskEntryBreakpoint( pdb->task ); /* Call UserSignalProc ( USIG_PROCESS_RUNNING ... ) only for non-GUI win32 apps */ 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; case GPD_PARENT: - return (DWORD)process->parent->server_pid; + return process->parent? (DWORD)process->parent->server_pid : 0; case GPD_FLAGS: return process->flags; diff --git a/scheduler/thread.c b/scheduler/thread.c index f36ccc1b5bb..c2d55390452 100644 --- a/scheduler/thread.c +++ b/scheduler/thread.c @@ -44,7 +44,7 @@ TEB *THREAD_First = &initial_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; } - /* Create the thread event */ - - if (!(teb->event = CreateEventA( NULL, FALSE, FALSE, NULL ))) goto error; - teb->event = ConvertToGlobalHandle( teb->event ); - /* StaticUnicodeString */ teb->StaticUnicodeString.MaximumLength = sizeof(teb->StaticUnicodeBuffer); @@ -132,7 +127,6 @@ static BOOL THREAD_InitTEB( TEB *teb, DWORD stack_size, BOOL alloc_stack16, return TRUE; error: - if (teb->event) CloseHandle( teb->event ); if (teb->stack_sel) SELECTOR_FreeBlock( teb->stack_sel, 1 ); if (teb->stack_base) VirtualFree( teb->stack_base, 0, MEM_RELEASE ); return FALSE; @@ -155,7 +149,6 @@ void CALLBACK THREAD_FreeTEB( ULONG_PTR arg ) PROCESS_CallUserSignalProc( USIG_THREAD_EXIT, (DWORD)teb->tid, 0 ); - CloseHandle( teb->event ); while (*pptr && (*pptr != teb)) pptr = &(*pptr)->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.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.process = pdb; 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->htask16 = pdb->task; 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->process = pdb; teb->exit_code = 0x103; /* STILL_ACTIVE */ @@ -300,7 +293,7 @@ HANDLE WINAPI CreateThread( SECURITY_ATTRIBUTES *sa, DWORD stack, int handle = -1; TEB *teb = THREAD_Create( PROCESS_Current(), -1, flags, stack, TRUE, sa, &handle ); if (!teb) return 0; - teb->flags |= TEBF_WIN32; + teb->tibflags |= TEBF_WIN32; teb->entry_point = start; teb->entry_arg = param; teb->startup = THREAD_Start;