mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-06 05:40:59 +00:00
Added hack to fetch the current directory from the subsystem tid so
that it is handled correctly in ntdll also for 16-bit tasks.
This commit is contained in:
parent
bd1fdeddaa
commit
186b419e02
|
@ -21,23 +21,6 @@
|
|||
#ifndef __WINE_KERNEL_PRIVATE_H
|
||||
#define __WINE_KERNEL_PRIVATE_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include "windef.h"
|
||||
#include "winbase.h"
|
||||
#include "winreg.h"
|
||||
#include "winternl.h"
|
||||
|
||||
/* The thread information for 16-bit threads */
|
||||
/* NtCurrentTeb()->SubSystemTib points to this */
|
||||
typedef struct
|
||||
{
|
||||
void *unknown; /* 00 unknown */
|
||||
UNICODE_STRING *exe_name; /* 04 exe module name */
|
||||
|
||||
/* the following fields do not exist under Windows */
|
||||
UNICODE_STRING exe_str; /* exe name string pointed to by exe_name */
|
||||
} WIN16_SUBSYSTEM_TIB;
|
||||
|
||||
HANDLE WINAPI OpenConsoleW(LPCWSTR, DWORD, BOOL, DWORD);
|
||||
BOOL WINAPI VerifyConsoleIoHandle(HANDLE);
|
||||
HANDLE WINAPI DuplicateConsoleHandle(HANDLE, DWORD, BOOL, DWORD);
|
||||
|
|
|
@ -432,6 +432,7 @@ static WIN16_SUBSYSTEM_TIB *allocate_win16_tib( TDB *pTask )
|
|||
{
|
||||
WCHAR path[MAX_PATH];
|
||||
WIN16_SUBSYSTEM_TIB *tib;
|
||||
UNICODE_STRING *curdir;
|
||||
NE_MODULE *pModule = NE_GetPtr( pTask->hModule );
|
||||
|
||||
if (!(tib = HeapAlloc( GetProcessHeap(), 0, sizeof(*tib) ))) return NULL;
|
||||
|
@ -439,6 +440,15 @@ static WIN16_SUBSYSTEM_TIB *allocate_win16_tib( TDB *pTask )
|
|||
GetLongPathNameW( path, path, MAX_PATH );
|
||||
if (RtlCreateUnicodeString( &tib->exe_str, path )) tib->exe_name = &tib->exe_str;
|
||||
else tib->exe_name = NULL;
|
||||
|
||||
RtlAcquirePebLock();
|
||||
curdir = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectoryName;
|
||||
tib->curdir.MaximumLength = sizeof(tib->curdir_buffer);
|
||||
tib->curdir.Length = min( curdir->Length, tib->curdir.MaximumLength-sizeof(WCHAR) );
|
||||
tib->curdir.Buffer = tib->curdir_buffer;
|
||||
memcpy( tib->curdir_buffer, curdir->Buffer, tib->curdir.Length );
|
||||
tib->curdir_buffer[tib->curdir.Length/sizeof(WCHAR)] = 0;
|
||||
RtlReleasePebLock();
|
||||
return tib;
|
||||
}
|
||||
|
||||
|
@ -518,6 +528,7 @@ static void TASK_CallTaskSignalProc( UINT16 uCode, HANDLE16 hTaskOrModule )
|
|||
*/
|
||||
void TASK_ExitTask(void)
|
||||
{
|
||||
WIN16_SUBSYSTEM_TIB *tib;
|
||||
TDB *pTask;
|
||||
DWORD lockCount;
|
||||
|
||||
|
@ -553,6 +564,13 @@ void TASK_ExitTask(void)
|
|||
|
||||
TASK_DeleteTask( pTask->hSelf );
|
||||
|
||||
if ((tib = NtCurrentTeb()->Tib.SubSystemTib))
|
||||
{
|
||||
if (tib->exe_name) RtlFreeUnicodeString( tib->exe_name );
|
||||
HeapFree( GetProcessHeap(), 0, tib );
|
||||
NtCurrentTeb()->Tib.SubSystemTib = NULL;
|
||||
}
|
||||
|
||||
/* ... and completely release the Win16Lock, just in case. */
|
||||
ReleaseThunkLock( &lockCount );
|
||||
}
|
||||
|
|
|
@ -541,7 +541,10 @@ static ULONG get_full_path_helper(LPCWSTR name, LPWSTR buffer, ULONG size)
|
|||
|
||||
RtlAcquirePebLock();
|
||||
|
||||
cd = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectoryName;
|
||||
if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */
|
||||
cd = &((WIN16_SUBSYSTEM_TIB *)NtCurrentTeb()->Tib.SubSystemTib)->curdir;
|
||||
else
|
||||
cd = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectoryName;
|
||||
|
||||
switch (type = RtlDetermineDosPathNameType_U(name))
|
||||
{
|
||||
|
@ -851,7 +854,11 @@ NTSTATUS WINAPI RtlGetCurrentDirectory_U(ULONG buflen, LPWSTR buf)
|
|||
|
||||
RtlAcquirePebLock();
|
||||
|
||||
us = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectoryName;
|
||||
if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */
|
||||
us = &((WIN16_SUBSYSTEM_TIB *)NtCurrentTeb()->Tib.SubSystemTib)->curdir;
|
||||
else
|
||||
us = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectoryName;
|
||||
|
||||
len = us->Length / sizeof(WCHAR);
|
||||
if (us->Buffer[len - 1] == '\\' && us->Buffer[len - 2] != ':')
|
||||
len--;
|
||||
|
@ -886,7 +893,11 @@ NTSTATUS WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING* dir)
|
|||
|
||||
RtlAcquirePebLock();
|
||||
|
||||
curdir = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectoryName;
|
||||
if (NtCurrentTeb()->Tib.SubSystemTib) /* FIXME: hack */
|
||||
curdir = &((WIN16_SUBSYSTEM_TIB *)NtCurrentTeb()->Tib.SubSystemTib)->curdir;
|
||||
else
|
||||
curdir = &NtCurrentTeb()->Peb->ProcessParameters->CurrentDirectoryName;
|
||||
|
||||
size = curdir->MaximumLength;
|
||||
|
||||
buf = RtlAllocateHeap(GetProcessHeap(), 0, size);
|
||||
|
@ -929,24 +940,6 @@ NTSTATUS WINAPI RtlSetCurrentDirectory_U(const UNICODE_STRING* dir)
|
|||
memmove(curdir->Buffer, buf, size + sizeof(WCHAR));
|
||||
curdir->Length = size;
|
||||
|
||||
#if 0
|
||||
if (curdir->Buffer[1] == ':')
|
||||
{
|
||||
UNICODE_STRING env;
|
||||
WCHAR var[4];
|
||||
|
||||
var[0] = '=';
|
||||
var[1] = curdir->Buffer[0];
|
||||
var[2] = ':';
|
||||
var[3] = 0;
|
||||
env.Length = 3 * sizeof(WCHAR);
|
||||
env.MaximumLength = 4 * sizeof(WCHAR);
|
||||
env.Buffer = var;
|
||||
|
||||
RtlSetEnvironmentVariable(NULL, &env, curdir);
|
||||
}
|
||||
#endif
|
||||
|
||||
out:
|
||||
if (buf) RtlFreeHeap(GetProcessHeap(), 0, buf);
|
||||
|
||||
|
|
|
@ -133,6 +133,20 @@ typedef struct _TEB
|
|||
} TEB;
|
||||
#endif /* WINE_TEB_DEFINED */
|
||||
|
||||
|
||||
/* The thread information for 16-bit threads */
|
||||
/* NtCurrentTeb()->SubSystemTib points to this */
|
||||
typedef struct
|
||||
{
|
||||
void *unknown; /* 00 unknown */
|
||||
UNICODE_STRING *exe_name; /* 04 exe module name */
|
||||
|
||||
/* the following fields do not exist under Windows */
|
||||
UNICODE_STRING exe_str; /* exe name string pointed to by exe_name */
|
||||
UNICODE_STRING curdir; /* current directory */
|
||||
WCHAR curdir_buffer[MAX_PATH];
|
||||
} WIN16_SUBSYSTEM_TIB;
|
||||
|
||||
/* scheduler/thread.c */
|
||||
extern TEB *THREAD_InitStack( TEB *teb, DWORD stack_size );
|
||||
|
||||
|
|
Loading…
Reference in a new issue