winehq.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2025
February
January
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
January
2003
December
November
October
September
August
July
June
May
April
March
February
January
2002
December
November
October
September
August
July
June
May
April
March
February
January
2001
December
November
October
September
August
July
June
May
April
March
February
List overview
wine-commits
May 2021
----- 2025 -----
February 2025
January 2025
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
----- 2003 -----
December 2003
November 2003
October 2003
September 2003
August 2003
July 2003
June 2003
May 2003
April 2003
March 2003
February 2003
January 2003
----- 2002 -----
December 2002
November 2002
October 2002
September 2002
August 2002
July 2002
June 2002
May 2002
April 2002
March 2002
February 2002
January 2002
----- 2001 -----
December 2001
November 2001
October 2001
September 2001
August 2001
July 2001
June 2001
May 2001
April 2001
March 2001
February 2001
wine-commits@winehq.org
2 participants
770 discussions
Start a n
N
ew thread
Nikolay Sivov : mfmediaengine: Keep device manager reference.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: b20c478bfd1322cf658105ce5695f5447288799f URL:
https://source.winehq.org/git/wine.git/?a=commit;h=b20c478bfd1322cf658105ce…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon May 17 12:26:49 2021 +0300 mfmediaengine: Keep device manager reference. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/mfmediaengine/main.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index 0678768cf08..489cb2cdc6a 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -93,6 +93,8 @@ struct media_engine LONG refcount; IMFMediaEngineNotify *callback; IMFAttributes *attributes; + IMFDXGIDeviceManager *device_manager; + HANDLE device_handle; enum media_engine_mode mode; unsigned int flags; double playback_rate; @@ -974,6 +976,11 @@ static void free_media_engine(struct media_engine *engine) IMFAttributes_Release(engine->attributes); if (engine->resolver) IMFSourceResolver_Release(engine->resolver); + if (engine->device_manager) + { + IMFDXGIDeviceManager_CloseDeviceHandle(engine->device_manager, engine->device_handle); + IMFDXGIDeviceManager_Release(engine->device_manager); + } SysFreeString(engine->current_source); DeleteCriticalSection(&engine->cs); free(engine->video_frame.buffer); @@ -1878,6 +1885,9 @@ static HRESULT init_media_engine(DWORD flags, IMFAttributes *attributes, struct if (FAILED(hr)) return hr; + IMFAttributes_GetUnknown(attributes, &MF_MEDIA_ENGINE_DXGI_MANAGER, &IID_IMFDXGIDeviceManager, + (void **)&engine->device_manager); + if (FAILED(hr = MFCreateMediaSession(NULL, &engine->session))) return hr;
1
0
0
0
Nikolay Sivov : mfmediaengine: Keep latest video frame buffer.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: c7023042e109d7592433b61cb25ca0d3f77d048b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c7023042e109d7592433b61c…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon May 17 12:26:48 2021 +0300 mfmediaengine: Keep latest video frame buffer. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/mfmediaengine/main.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/dlls/mfmediaengine/main.c b/dlls/mfmediaengine/main.c index c6c73b625f1..0678768cf08 100644 --- a/dlls/mfmediaengine/main.c +++ b/dlls/mfmediaengine/main.c @@ -84,14 +84,6 @@ enum media_engine_flags FLAGS_ENGINE_IS_ENDED = 0x4000, }; -struct video_frame -{ - LONGLONG pts; - SIZE size; - SIZE ratio; - TOPOID node_id; -}; - struct media_engine { IMFMediaEngine IMFMediaEngine_iface; @@ -115,7 +107,15 @@ struct media_engine IMFPresentationClock *clock; IMFSourceResolver *resolver; BSTR current_source; - struct video_frame video_frame; + struct + { + LONGLONG pts; + SIZE size; + SIZE ratio; + TOPOID node_id; + BYTE *buffer; + UINT buffer_size; + } video_frame; CRITICAL_SECTION cs; }; @@ -976,6 +976,7 @@ static void free_media_engine(struct media_engine *engine) IMFSourceResolver_Release(engine->resolver); SysFreeString(engine->current_source); DeleteCriticalSection(&engine->cs); + free(engine->video_frame.buffer); free(engine); } @@ -1781,7 +1782,7 @@ static HRESULT WINAPI media_engine_grabber_callback_OnSetPresentationClock(IMFSa static HRESULT WINAPI media_engine_grabber_callback_OnProcessSample(IMFSampleGrabberSinkCallback *iface, REFGUID major_type, DWORD sample_flags, LONGLONG sample_time, LONGLONG sample_duration, - const BYTE *buffer, DWORD sample_size) + const BYTE *buffer, DWORD buffer_size) { struct media_engine *engine = impl_from_IMFSampleGrabberSinkCallback(iface); @@ -1793,6 +1794,14 @@ static HRESULT WINAPI media_engine_grabber_callback_OnProcessSample(IMFSampleGra media_engine_set_flag(engine, FLAGS_ENGINE_FIRST_FRAME, TRUE); } engine->video_frame.pts = sample_time; + if (engine->video_frame.buffer_size < buffer_size) + { + free(engine->video_frame.buffer); + if ((engine->video_frame.buffer = malloc(buffer_size))) + engine->video_frame.buffer_size = buffer_size; + } + if (engine->video_frame.buffer) + memcpy(engine->video_frame.buffer, buffer, buffer_size); LeaveCriticalSection(&engine->cs);
1
0
0
0
Nikolay Sivov : include: Add missing prototypes to mfapi.h.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: 79a71f969148bc370e34847ff16eff033ac7d1a7 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=79a71f969148bc370e34847f…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon May 17 12:26:00 2021 +0300 include: Add missing prototypes to mfapi.h. Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- include/mfapi.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/mfapi.h b/include/mfapi.h index 2ac70793d7a..a3945bd3a7d 100644 --- a/include/mfapi.h +++ b/include/mfapi.h @@ -554,6 +554,7 @@ HRESULT WINAPI MFInitAttributesFromBlob(IMFAttributes *attributes, const UINT8 * HRESULT WINAPI MFInitMediaTypeFromWaveFormatEx(IMFMediaType *mediatype, const WAVEFORMATEX *format, UINT32 size); HRESULT WINAPI MFInvokeCallback(IMFAsyncResult *result); LONGLONG WINAPI MFllMulDiv(LONGLONG val, LONGLONG num, LONGLONG denom, LONGLONG factor); +HRESULT WINAPI MFLockDXGIDeviceManager(UINT *token, IMFDXGIDeviceManager **manager); HRESULT WINAPI MFLockPlatform(void); HRESULT WINAPI MFLockSharedWorkQueue(const WCHAR *name, LONG base_priority, DWORD *taskid, DWORD *queue); DXGI_FORMAT WINAPI MFMapDX9FormatToDXGIFormat(DWORD format); @@ -580,6 +581,7 @@ HRESULT WINAPI MFTRegisterLocalByCLSID(REFCLSID clsid, REFGUID category, LPCWSTR HRESULT WINAPI MFRemovePeriodicCallback(DWORD key); HRESULT WINAPI MFShutdown(void); HRESULT WINAPI MFStartup(ULONG version, DWORD flags); +HRESULT WINAPI MFUnlockDXGIDeviceManager(void); HRESULT WINAPI MFUnlockPlatform(void); HRESULT WINAPI MFUnlockWorkQueue(DWORD queue); HRESULT WINAPI MFUnregisterPlatformFromMMCSS(void);
1
0
0
0
Zhiyi Zhang : winedump: Dump the distance array for EMR_EXTTEXTOUTW records.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: e7de8395132a4f27e4ede3dc6112ccd426283ad4 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e7de8395132a4f27e4ede3dc…
Author: Zhiyi Zhang <zzhang(a)codeweavers.com> Date: Mon May 17 17:09:27 2021 +0800 winedump: Dump the distance array for EMR_EXTTEXTOUTW records. Signed-off-by: Zhiyi Zhang <zzhang(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- tools/winedump/emf.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/winedump/emf.c b/tools/winedump/emf.c index 2f54f73153b..50c3ad092ea 100644 --- a/tools/winedump/emf.c +++ b/tools/winedump/emf.c @@ -378,6 +378,7 @@ static int dump_emfrecord(void) case EMR_EXTTEXTOUTW: { const EMREXTTEXTOUTW *etoW = PRD(offset, sizeof(*etoW)); + const int *dx = (const int *)((const BYTE *)etoW + etoW->emrtext.offDx); printf("%-20s %08x\n", "EMR_EXTTEXTOUTW", length); printf("bounds (%d,%d - %d,%d) mode %#x x_scale %f y_scale %f pt (%d,%d) rect (%d,%d - %d,%d) flags %#x, %s\n", @@ -388,6 +389,14 @@ static int dump_emfrecord(void) etoW->emrtext.rcl.right, etoW->emrtext.rcl.bottom, etoW->emrtext.fOptions, debugstr_wn((LPCWSTR)((const BYTE *)etoW + etoW->emrtext.offString), etoW->emrtext.nChars)); + printf("dx_offset %u {", etoW->emrtext.offDx); + for (i = 0; i < etoW->emrtext.nChars; ++i) + { + printf("%d", dx[i]); + if (i != etoW->emrtext.nChars - 1) + putchar(','); + } + printf("}\n"); break; }
1
0
0
0
Giovanni Mascellani : winegstreamer: Advertise support for thinned or reverse playback.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: 02325ccb67ecee06823ca659ab11d8ab8864c9f9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=02325ccb67ecee06823ca659…
Author: Giovanni Mascellani <gmascellani(a)codeweavers.com> Date: Mon May 17 10:13:08 2021 +0200 winegstreamer: Advertise support for thinned or reverse playback. Signed-off-by: Giovanni Mascellani <gmascellani(a)codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winegstreamer/media_source.c | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c index 8a87992d450..90efc9aaed2 100644 --- a/dlls/winegstreamer/media_source.c +++ b/dlls/winegstreamer/media_source.c @@ -933,13 +933,7 @@ static HRESULT WINAPI media_source_rate_support_GetSlowestRate(IMFRateSupport *i { TRACE("%p, %d, %d, %p.\n", iface, direction, thin, rate); - if (direction == MFRATE_REVERSE) - return MF_E_REVERSE_UNSUPPORTED; - - if (thin) - return MF_E_THINNING_UNSUPPORTED; - - *rate = 1.0f; + *rate = direction == MFRATE_FORWARD ? 1.0f : -1.0f; return S_OK; } @@ -948,31 +942,21 @@ static HRESULT WINAPI media_source_rate_support_GetFastestRate(IMFRateSupport *i { TRACE("%p, %d, %d, %p.\n", iface, direction, thin, rate); - if (direction == MFRATE_REVERSE) - return MF_E_REVERSE_UNSUPPORTED; - - if (thin) - return MF_E_THINNING_UNSUPPORTED; - - *rate = 1.0f; + *rate = direction == MFRATE_FORWARD ? 1.0f : -1.0f; return S_OK; } static HRESULT WINAPI media_source_rate_support_IsRateSupported(IMFRateSupport *iface, BOOL thin, float rate, float *nearest_support_rate) { - TRACE("%p, %d, %f, %p.\n", iface, thin, rate, nearest_support_rate); + const float supported_rate = rate >= 0.0f ? 1.0f : -1.0f; - if (rate < 0.0f) - return MF_E_REVERSE_UNSUPPORTED; - - if (thin) - return MF_E_THINNING_UNSUPPORTED; + TRACE("%p, %d, %f, %p.\n", iface, thin, rate, nearest_support_rate); if (nearest_support_rate) - *nearest_support_rate = 1.0f; + *nearest_support_rate = supported_rate; - return rate == 1.0f ? S_OK : MF_E_UNSUPPORTED_RATE; + return rate == supported_rate ? S_OK : MF_E_UNSUPPORTED_RATE; } static const IMFRateSupportVtbl media_source_rate_support_vtbl =
1
0
0
0
Alexandre Julliard : ntdll: Store the Wow64 context at the top of the 64-bit stack.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: 5ba8f0d73b27e5df7ce40c0413743cb917405d0e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=5ba8f0d73b27e5df7ce40c04…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon May 17 10:49:17 2021 +0200 ntdll: Store the Wow64 context at the top of the 64-bit stack. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/tests/exception.c | 38 ++++++++++++++++++++++++++++++++++++-- dlls/ntdll/unix/signal_arm.c | 5 +++++ dlls/ntdll/unix/signal_i386.c | 5 +++++ dlls/ntdll/unix/thread.c | 23 ++++++++++++++++++++++- include/winternl.h | 1 + 5 files changed, 69 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index d784074394a..2c604408943 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -182,6 +182,7 @@ static VOID (WINAPI *pRtlCaptureContext)(CONTEXT*); static VOID (CDECL *pRtlRestoreContext)(CONTEXT*, EXCEPTION_RECORD*); static NTSTATUS (WINAPI *pRtlWow64GetThreadContext)(HANDLE, WOW64_CONTEXT *); static NTSTATUS (WINAPI *pRtlWow64SetThreadContext)(HANDLE, const WOW64_CONTEXT *); +static NTSTATUS (WINAPI *pRtlWow64GetCpuAreaInfo)(WOW64_CPURESERVED*,ULONG,WOW64_CPU_AREA_INFO*); static VOID (WINAPI *pRtlUnwindEx)(VOID*, VOID*, EXCEPTION_RECORD*, VOID*, CONTEXT*, UNWIND_HISTORY_TABLE*); static int (CDECL *p_setjmp)(_JUMP_BUFFER*); #endif @@ -3748,10 +3749,12 @@ static void test_wow64_context(void) THREAD_BASIC_INFORMATION info; PROCESS_INFORMATION pi; STARTUPINFOA si = {0}; - WOW64_CONTEXT ctx; + WOW64_CONTEXT ctx, *ctx_ptr; NTSTATUS ret; - SIZE_T res; TEB teb; + SIZE_T res, cpu_size; + WOW64_CPURESERVED *cpu = NULL; + WOW64_CPU_AREA_INFO cpu_info; memset(&ctx, 0x55, sizeof(ctx)); ctx.ContextFlags = WOW64_CONTEXT_ALL; @@ -3796,6 +3799,37 @@ static void test_wow64_context(void) teb.DeallocationStack, teb.Tib.StackBase ); } + if (pRtlWow64GetCpuAreaInfo) + { + ok( teb.TlsSlots[WOW64_TLS_CPURESERVED] == teb.Tib.StackBase, "wrong cpu reserved %p / %p\n", + teb.TlsSlots[WOW64_TLS_CPURESERVED], teb.Tib.StackBase ); + cpu_size = 0x1000 - ((ULONG_PTR)teb.TlsSlots[WOW64_TLS_CPURESERVED] & 0xfff); + cpu = malloc( cpu_size ); + if (!ReadProcessMemory( pi.hProcess, teb.TlsSlots[WOW64_TLS_CPURESERVED], cpu, cpu_size, &res )) res = 0; + ok( res == cpu_size, "wrong len %lx\n", res ); + ok( cpu->Machine == IMAGE_FILE_MACHINE_I386, "wrong machine %04x\n", cpu->Machine ); + ret = pRtlWow64GetCpuAreaInfo( cpu, 0, &cpu_info ); + ok( !ret, "RtlWow64GetCpuAreaInfo failed %x\n", ret ); + ctx_ptr = (WOW64_CONTEXT *)cpu_info.Context; + ok(!*(void **)cpu_info.ContextEx, "got context_ex %p\n", *(void **)cpu_info.ContextEx); + ok(ctx_ptr->ContextFlags == WOW64_CONTEXT_ALL, "got context flags %#x\n", ctx_ptr->ContextFlags); + ok(ctx_ptr->Eax == ctx.Eax, "got eax %08x / %08x\n", ctx_ptr->Eax, ctx.Eax); + ok(ctx_ptr->Ebx == ctx.Ebx, "got ebx %08x / %08x\n", ctx_ptr->Ebx, ctx.Ebx); + ok(ctx_ptr->Ecx == ctx.Ecx, "got ecx %08x / %08x\n", ctx_ptr->Ecx, ctx.Ecx); + ok(ctx_ptr->Edx == ctx.Edx, "got edx %08x / %08x\n", ctx_ptr->Edx, ctx.Edx); + ok(ctx_ptr->Ebp == ctx.Ebp, "got ebp %08x / %08x\n", ctx_ptr->Ebp, ctx.Ebp); + ok(ctx_ptr->Esi == ctx.Esi, "got esi %08x / %08x\n", ctx_ptr->Esi, ctx.Esi); + ok(ctx_ptr->Edi == ctx.Edi, "got edi %08x / %08x\n", ctx_ptr->Edi, ctx.Edi); + ok(ctx_ptr->SegCs == ctx.SegCs, "got cs %04x / %04x\n", ctx_ptr->SegCs, ctx.SegCs); + ok(ctx_ptr->SegDs == ctx.SegDs, "got cs %04x / %04x\n", ctx_ptr->SegDs, ctx.SegDs); + ok(ctx_ptr->SegSs == ctx.SegSs, "got cs %04x / %04x\n", ctx_ptr->SegSs, ctx.SegSs); + ok(ctx_ptr->EFlags == ctx.EFlags, "got eflags %08x / %08x\n", ctx_ptr->EFlags, ctx.EFlags); + ok((WORD)ctx_ptr->FloatSave.ControlWord == ctx.FloatSave.ControlWord, + "got control word %08x / %08x\n", ctx_ptr->FloatSave.ControlWord, ctx.FloatSave.ControlWord); + ok(*(WORD *)ctx_ptr->ExtendedRegisters == *(WORD *)ctx.ExtendedRegisters, + "got SSE control word %04x\n", *(WORD *)ctx_ptr->ExtendedRegisters, + *(WORD *)ctx.ExtendedRegisters); + } pNtTerminateProcess(pi.hProcess, 0); } diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c index 56aa251c2c9..d8912d3714a 100644 --- a/dlls/ntdll/unix/signal_arm.c +++ b/dlls/ntdll/unix/signal_arm.c @@ -993,6 +993,11 @@ static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, context->Sp = (DWORD)teb->Tib.StackBase; context->Pc = (DWORD)pRtlUserThreadStart; if (context->Pc & 1) context->Cpsr |= 0x20; /* thumb mode */ + if (NtCurrentTeb64()) + { + WOW64_CPURESERVED *cpu = ULongToPtr( NtCurrentTeb64()->TlsSlots[WOW64_TLS_CPURESERVED] ); + memcpy( cpu + 1, context, sizeof(*context) ); + } } diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c index 754d75a9e61..4ad91141055 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c @@ -2603,6 +2603,11 @@ static void init_thread_context( CONTEXT *context, LPTHREAD_START_ROUTINE entry, context->FloatSave.ControlWord = 0x27f; ((XSAVE_FORMAT *)context->ExtendedRegisters)->ControlWord = 0x27f; ((XSAVE_FORMAT *)context->ExtendedRegisters)->MxCsr = 0x1f80; + if (NtCurrentTeb64()) + { + WOW64_CPURESERVED *cpu = ULongToPtr( NtCurrentTeb64()->TlsSlots[WOW64_TLS_CPURESERVED] ); + memcpy( cpu + 1, context, sizeof(*context) ); + } } diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 6455b5a449e..a612c4b5648 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -119,6 +119,22 @@ static void start_thread( TEB *teb ) } +/*********************************************************************** + * get_machine_context_size + */ +static SIZE_T get_machine_context_size( USHORT machine ) +{ + switch (machine) + { + case IMAGE_FILE_MACHINE_I386: return sizeof(I386_CONTEXT); + case IMAGE_FILE_MACHINE_ARMNT: return sizeof(ARM_CONTEXT); + case IMAGE_FILE_MACHINE_AMD64: return sizeof(AMD64_CONTEXT); + case IMAGE_FILE_MACHINE_ARM64: return sizeof(ARM64_NT_CONTEXT); + default: return 0; + } +} + + /*********************************************************************** * set_thread_id */ @@ -155,18 +171,23 @@ NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR zero_bits, SIZE_T reserve_size, if (teb->WowTebOffset && !(status = virtual_alloc_thread_stack( &stack64, 0, 0x40000, 0x40000, NULL ))) { + SIZE_T cpusize = sizeof(WOW64_CPURESERVED) + + ((get_machine_context_size( main_image_info.Machine ) + 7) & ~7) + sizeof(ULONG64); + WOW64_CPURESERVED *cpu = (WOW64_CPURESERVED *)(((ULONG_PTR)stack64.StackBase - cpusize) & ~15); #ifdef _WIN64 TEB32 *teb32 = (TEB32 *)((char *)teb + teb->WowTebOffset); teb32->Tib.StackBase = PtrToUlong( stack.StackBase ); teb32->Tib.StackLimit = PtrToUlong( stack.StackLimit ); teb32->DeallocationStack = PtrToUlong( stack.DeallocationStack ); + stack64.StackBase = teb->TlsSlots[WOW64_TLS_CPURESERVED] = cpu; stack = stack64; #else TEB64 *teb64 = (TEB64 *)((char *)teb + teb->WowTebOffset); - teb64->Tib.StackBase = PtrToUlong( stack64.StackBase ); + teb64->Tib.StackBase = teb64->TlsSlots[WOW64_TLS_CPURESERVED] = PtrToUlong( cpu ); teb64->Tib.StackLimit = PtrToUlong( stack64.StackLimit ); teb64->DeallocationStack = PtrToUlong( stack64.DeallocationStack ); #endif + cpu->Machine = main_image_info.Machine; } teb->Tib.StackBase = stack.StackBase; teb->Tib.StackLimit = stack.StackLimit; diff --git a/include/winternl.h b/include/winternl.h index c9868fb5e39..691638f359c 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -978,6 +978,7 @@ typedef struct _TEB64 } TEB64; /* reserved TEB64 TLS slots for Wow64 */ +#define WOW64_TLS_CPURESERVED 1 #define WOW64_TLS_FILESYSREDIR 8
1
0
0
0
Alexandre Julliard : ntdll: Only check the is_wow64 flag on 32-bit platforms.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: e40eab977aabfcffaf1505f35f59b017e9441078 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=e40eab977aabfcffaf1505f3…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon May 17 10:12:01 2021 +0200 ntdll: Only check the is_wow64 flag on 32-bit platforms. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/process.c | 15 +++++++-------- dlls/ntdll/unix/server.c | 4 +++- dlls/ntdll/unix/thread.c | 8 +++++++- dlls/ntdll/unix/unix_private.h | 4 +++- dlls/ntdll/unix/virtual.c | 22 ++++++++++++++-------- 5 files changed, 34 insertions(+), 19 deletions(-) diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index 74e16c36fd6..54e9680699e 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -999,6 +999,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class pbi.BasePriority = reply->priority; pbi.UniqueProcessId = reply->pid; pbi.InheritedFromUniqueProcessId = reply->ppid; +#ifndef _WIN64 if (is_wow64) { if (reply->machine != native_machine) @@ -1006,6 +1007,7 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class else pbi.PebBaseAddress = NULL; } +#endif } } SERVER_END_REQ; @@ -1260,20 +1262,17 @@ NTSTATUS WINAPI NtQueryInformationProcess( HANDLE handle, PROCESSINFOCLASS class if (size != len) ret = STATUS_INFO_LENGTH_MISMATCH; else if (!info) ret = STATUS_ACCESS_VIOLATION; else if (!handle) ret = STATUS_INVALID_HANDLE; + else if (handle == GetCurrentProcess()) *(ULONG_PTR *)info = !!NtCurrentTeb()->WowTebOffset; else { ULONG_PTR val = 0; - if (handle == GetCurrentProcess()) val = is_wow64; - else if (is_win64 || is_wow64) + SERVER_START_REQ( get_process_info ) { - SERVER_START_REQ( get_process_info ) - { - req->handle = wine_server_obj_handle( handle ); - if (!(ret = wine_server_call( req ))) val = (reply->machine != native_machine); - } - SERVER_END_REQ; + req->handle = wine_server_obj_handle( handle ); + if (!(ret = wine_server_call( req ))) val = (reply->machine != native_machine); } + SERVER_END_REQ; *(ULONG_PTR *)info = val; } break; diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index 33a49adb8e8..a96c91acc9c 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -104,8 +104,10 @@ static const char *server_dir; unsigned int supported_machines_count = 0; USHORT supported_machines[8] = { 0 }; USHORT native_machine = 0; -BOOL is_wow64 = FALSE; BOOL process_exiting = FALSE; +#ifndef _WIN64 +BOOL is_wow64 = FALSE; +#endif timeout_t server_start_time = 0; /* time of server startup */ diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index d2c14ae33c1..6455b5a449e 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -233,7 +233,9 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT NTSTATUS status; if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3; - if (!is_win64 && !is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3; +#ifndef _WIN64 + if (!is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3; +#endif if (process != NtCurrentProcess()) { @@ -950,6 +952,7 @@ BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time, LA #endif } +#ifndef _WIN64 static BOOL is_process_wow64( const CLIENT_ID *id ) { HANDLE handle; @@ -965,6 +968,7 @@ static BOOL is_process_wow64( const CLIENT_ID *id ) } return ret; } +#endif /****************************************************************************** * NtQueryInformationThread (NTDLL.@) @@ -1000,6 +1004,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class, SERVER_END_REQ; if (status == STATUS_SUCCESS) { +#ifndef _WIN64 if (is_wow64) { if (is_process_wow64( &info.ClientId )) @@ -1007,6 +1012,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class, else info.TebBaseAddress = NULL; } +#endif if (data) memcpy( data, &info, min( length, sizeof(info) )); if (ret_len) *ret_len = min( length, sizeof(info) ); } diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index cdb36584326..464f8ca17c7 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -125,13 +125,15 @@ extern WCHAR **main_wargv DECLSPEC_HIDDEN; extern const WCHAR system_dir[] DECLSPEC_HIDDEN; extern unsigned int supported_machines_count DECLSPEC_HIDDEN; extern USHORT supported_machines[8] DECLSPEC_HIDDEN; -extern BOOL is_wow64 DECLSPEC_HIDDEN; extern BOOL process_exiting DECLSPEC_HIDDEN; extern HANDLE keyed_event DECLSPEC_HIDDEN; extern timeout_t server_start_time DECLSPEC_HIDDEN; extern sigset_t server_block_set DECLSPEC_HIDDEN; extern struct _KUSER_SHARED_DATA *user_shared_data DECLSPEC_HIDDEN; extern SYSTEM_CPU_INFORMATION cpu_info DECLSPEC_HIDDEN; +#ifndef _WIN64 +extern BOOL is_wow64 DECLSPEC_HIDDEN; +#endif #ifdef __i386__ extern struct ldt_copy __wine_ldt_copy DECLSPEC_HIDDEN; #endif diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 572ce960b77..bcab898b0fc 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -722,7 +722,9 @@ static void free_ranges_insert_view( struct file_view *view ) (range->end == view_base && next->base >= view_end)) { /* on Win64, assert that it's correctly aligned so we're not going to be in trouble later */ - assert( (!is_win64 && !is_wow64) || view->base == view_base ); +#ifdef _WIN64 + assert( view->base == view_base ); +#endif WARN( "range %p - %p is already mapped\n", view_base, view_end ); return; } @@ -2962,7 +2964,7 @@ NTSTATUS virtual_alloc_teb( TEB **ret_teb ) NtAllocateVirtualMemory( NtCurrentProcess(), (void **)&ptr, 0, &block_size, MEM_COMMIT, PAGE_READWRITE ); } - *ret_teb = teb = init_teb( ptr, NtCurrentTeb()->Peb, is_wow64 ); + *ret_teb = teb = init_teb( ptr, NtCurrentTeb()->Peb, !!NtCurrentTeb()->WowTebOffset ); server_leave_uninterrupted_section( &virtual_mutex, &sigset ); if ((status = signal_alloc_thread( teb ))) @@ -3674,7 +3676,9 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z if (!size) return STATUS_INVALID_PARAMETER; if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3; - if (!is_win64 && !is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3; +#ifndef _WIN64 + if (!is_wow64 && zero_bits >= 32) return STATUS_INVALID_PARAMETER_3; +#endif if (process != NtCurrentProcess()) { @@ -4344,8 +4348,6 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p /* Check parameters */ if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_4; - if (!is_win64 && !is_wow64 && zero_bits >= 32) - return STATUS_INVALID_PARAMETER_4; /* If both addr_ptr and zero_bits are passed, they have match */ if (*addr_ptr && zero_bits && zero_bits < 32 && @@ -4356,10 +4358,14 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p return STATUS_INVALID_PARAMETER_4; #ifndef _WIN64 - if (!is_wow64 && (alloc_type & AT_ROUND_TO_PAGE)) + if (!is_wow64) { - *addr_ptr = ROUND_ADDR( *addr_ptr, page_mask ); - mask = page_mask; + if (zero_bits >= 32) return STATUS_INVALID_PARAMETER_4; + if (alloc_type & AT_ROUND_TO_PAGE) + { + *addr_ptr = ROUND_ADDR( *addr_ptr, page_mask ); + mask = page_mask; + } } #endif
1
0
0
0
Alexandre Julliard : ntdll: Allocate a separate 64-bit stack for Wow64 threads.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: a8ff0c12f4ce60315156b9cbfd13291ad6cd4452 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a8ff0c12f4ce60315156b9cb…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon May 17 09:58:46 2021 +0200 ntdll: Allocate a separate 64-bit stack for Wow64 threads. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/tests/exception.c | 25 +++++++++++++++++++++++-- dlls/ntdll/unix/loader.c | 6 +----- dlls/ntdll/unix/thread.c | 41 +++++++++++++++++++++++++++++++++++------ dlls/ntdll/unix/unix_private.h | 2 ++ dlls/ntdll/unix/virtual.c | 15 +++++++++++++++ 5 files changed, 76 insertions(+), 13 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index d6565c12fce..d784074394a 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -3745,18 +3745,20 @@ static void test_thread_context(void) static void test_wow64_context(void) { - char cmdline[] = "C:\\windows\\syswow64\\notepad.exe"; + THREAD_BASIC_INFORMATION info; PROCESS_INFORMATION pi; STARTUPINFOA si = {0}; WOW64_CONTEXT ctx; NTSTATUS ret; + SIZE_T res; + TEB teb; memset(&ctx, 0x55, sizeof(ctx)); ctx.ContextFlags = WOW64_CONTEXT_ALL; ret = pRtlWow64GetThreadContext( GetCurrentThread(), &ctx ); ok(ret == STATUS_INVALID_PARAMETER || broken(ret == STATUS_PARTIAL_COPY), "got %#x\n", ret); - CreateProcessA(NULL, cmdline, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi); + CreateProcessA("C:\\windows\\syswow64\\notepad.exe", NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, NULL, NULL, &si, &pi); ret = pRtlWow64GetThreadContext( pi.hThread, &ctx ); ok(ret == STATUS_SUCCESS, "got %#x\n", ret); @@ -3775,6 +3777,25 @@ static void test_wow64_context(void) ret = pRtlWow64SetThreadContext( pi.hThread, &ctx ); ok(ret == STATUS_SUCCESS, "got %#x\n", ret); + pNtQueryInformationThread( pi.hThread, ThreadBasicInformation, &info, sizeof(info), NULL ); + if (!ReadProcessMemory( pi.hProcess, info.TebBaseAddress, &teb, sizeof(teb), &res )) res = 0; + ok( res == sizeof(teb), "wrong len %lx\n", res ); + + if (teb.WowTebOffset > 1) + { + TEB32 teb32; + if (!ReadProcessMemory( pi.hProcess, (char *)info.TebBaseAddress + teb.WowTebOffset, + &teb32, sizeof(teb32), &res )) res = 0; + ok( res == sizeof(teb32), "wrong len %lx\n", res ); + + ok( ((ctx.Esp + 0xfff) & ~0xfff) == teb32.Tib.StackBase, + "esp is not at top of stack: %08x / %08x\n", ctx.Esp, teb32.Tib.StackBase ); + ok( ULongToPtr( teb32.Tib.StackBase ) <= teb.DeallocationStack || + ULongToPtr( teb32.DeallocationStack ) >= teb.Tib.StackBase, + "stacks overlap %08x-%08x / %p-%p\n", teb32.DeallocationStack, teb32.Tib.StackBase, + teb.DeallocationStack, teb.Tib.StackBase ); + } + pNtTerminateProcess(pi.hProcess, 0); } diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index 1f1e6bc2796..1b79b71b252 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1853,7 +1853,6 @@ static struct unix_funcs unix_funcs = static void start_main_thread(void) { NTSTATUS status; - INITIAL_TEB stack; TEB *teb = virtual_alloc_first_teb(); signal_init_threading(); @@ -1871,10 +1870,7 @@ static void start_main_thread(void) if (p___wine_main_argv) *p___wine_main_argv = main_argv; if (p___wine_main_wargv) *p___wine_main_wargv = main_wargv; set_load_order_app_name( main_wargv[0] ); - virtual_alloc_thread_stack( &stack, is_win64 ? 0x7fffffff : 0, 0, 0, NULL ); - teb->Tib.StackBase = stack.StackBase; - teb->Tib.StackLimit = stack.StackLimit; - teb->DeallocationStack = stack.DeallocationStack; + init_thread_stack( teb, is_win64 ? 0x7fffffff : 0, 0, 0, NULL ); NtCreateKeyedEvent( &keyed_event, GENERIC_READ | GENERIC_WRITE, NULL, 0 ); load_ntdll(); status = p__wine_set_unix_funcs( NTDLL_UNIXLIB_VERSION, &unix_funcs ); diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 079ac16952d..d2c14ae33c1 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -141,6 +141,40 @@ void set_thread_id( TEB *teb, DWORD pid, DWORD tid ) } +/*********************************************************************** + * init_thread_stack + */ +NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR zero_bits, SIZE_T reserve_size, + SIZE_T commit_size, SIZE_T *pthread_size ) +{ + INITIAL_TEB stack, stack64; + NTSTATUS status; + + if ((status = virtual_alloc_thread_stack( &stack, zero_bits, reserve_size, commit_size, pthread_size ))) + return status; + + if (teb->WowTebOffset && !(status = virtual_alloc_thread_stack( &stack64, 0, 0x40000, 0x40000, NULL ))) + { +#ifdef _WIN64 + TEB32 *teb32 = (TEB32 *)((char *)teb + teb->WowTebOffset); + teb32->Tib.StackBase = PtrToUlong( stack.StackBase ); + teb32->Tib.StackLimit = PtrToUlong( stack.StackLimit ); + teb32->DeallocationStack = PtrToUlong( stack.DeallocationStack ); + stack = stack64; +#else + TEB64 *teb64 = (TEB64 *)((char *)teb + teb->WowTebOffset); + teb64->Tib.StackBase = PtrToUlong( stack64.StackBase ); + teb64->Tib.StackLimit = PtrToUlong( stack64.StackLimit ); + teb64->DeallocationStack = PtrToUlong( stack64.DeallocationStack ); +#endif + } + teb->Tib.StackBase = stack.StackBase; + teb->Tib.StackLimit = stack.StackLimit; + teb->DeallocationStack = stack.DeallocationStack; + return status; +} + + /*********************************************************************** * update_attr_list * @@ -196,7 +230,6 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT int request_pipe[2]; SIZE_T extra_stack = PTHREAD_STACK_MIN; TEB *teb; - INITIAL_TEB stack; NTSTATUS status; if (zero_bits > 21 && zero_bits < 32) return STATUS_INVALID_PARAMETER_3; @@ -269,7 +302,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT if ((status = virtual_alloc_teb( &teb ))) goto done; - if ((status = virtual_alloc_thread_stack( &stack, zero_bits, stack_reserve, stack_commit, &extra_stack ))) + if ((status = init_thread_stack( teb, zero_bits, stack_reserve, stack_commit, &extra_stack ))) { virtual_free_teb( teb ); goto done; @@ -277,10 +310,6 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT set_thread_id( teb, GetCurrentProcessId(), tid ); - teb->Tib.StackBase = stack.StackBase; - teb->Tib.StackLimit = stack.StackLimit; - teb->DeallocationStack = stack.DeallocationStack; - thread_data = (struct ntdll_thread_data *)&teb->GdiTebBatch; thread_data->request_fd = request_pipe[1]; thread_data->start_stack = (char *)teb->Tib.StackBase; diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 5c340107964..cdb36584326 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -173,6 +173,8 @@ extern void server_init_thread( void *entry_point, BOOL *suspend ) DECLSPEC_HIDD extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN; extern void set_thread_id( TEB *teb, DWORD pid, DWORD tid ) DECLSPEC_HIDDEN; +extern NTSTATUS init_thread_stack( TEB *teb, ULONG_PTR zero_bits, SIZE_T reserve_size, + SIZE_T commit_size, SIZE_T *pthread_size ) DECLSPEC_HIDDEN; extern NTSTATUS context_to_server( context_t *to, const CONTEXT *from ) DECLSPEC_HIDDEN; extern NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN abort_thread( int status ) DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index bcecc21989a..572ce960b77 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -2997,6 +2997,21 @@ void virtual_free_teb( TEB *teb ) size = 0; NtFreeVirtualMemory( GetCurrentProcess(), &thread_data->start_stack, &size, MEM_RELEASE ); } + if (teb->WowTebOffset) + { +#ifdef _WIN64 + TEB32 *teb32 = (TEB32 *)((char *)teb + teb->WowTebOffset); + void *addr = ULongToPtr( teb32->DeallocationStack ); +#else + TEB64 *teb64 = (TEB64 *)((char *)teb + teb->WowTebOffset); + void *addr = ULongToPtr( teb64->DeallocationStack ); +#endif + if (addr) + { + size = 0; + NtFreeVirtualMemory( GetCurrentProcess(), &addr, &size, MEM_RELEASE ); + } + } server_enter_uninterrupted_section( &virtual_mutex, &sigset ); list_remove( &thread_data->entry );
1
0
0
0
Alexandre Julliard : ntdll: Add a helper function to set the thread id.
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: 711bde7cd11bfbb691e0e9b5fa2efae82a4f541c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=711bde7cd11bfbb691e0e9b5…
Author: Alexandre Julliard <julliard(a)winehq.org> Date: Mon May 17 09:39:34 2021 +0200 ntdll: Add a helper function to set the thread id. Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/ntdll/unix/server.c | 38 ++++++++++---------------------------- dlls/ntdll/unix/thread.c | 30 +++++++++++++++++++++++++----- dlls/ntdll/unix/unix_private.h | 1 + 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index 9f10bb135bd..33a49adb8e8 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -1446,22 +1446,6 @@ static int init_thread_pipe(void) } -/*********************************************************************** - * init_teb64 - * - * Initialize the 64-bit part of the TEB for WoW64 threads. - */ -static void init_teb64( TEB *teb ) -{ -#ifndef _WIN64 - TEB64 *teb64 = (TEB64 *)((char *)teb - teb_offset); - - if (!is_wow64) return; - teb64->ClientId.UniqueProcess = PtrToUlong( teb->ClientId.UniqueProcess ); - teb64->ClientId.UniqueThread = PtrToUlong( teb->ClientId.UniqueThread ); -#endif -} - /*********************************************************************** * process_exit_wrapper * @@ -1488,6 +1472,7 @@ size_t server_init_process(void) int ret, reply_pipe; struct sigaction sig_act; size_t info_size; + DWORD pid, tid; server_pid = -1; if (env_socket) @@ -1558,8 +1543,8 @@ size_t server_init_process(void) req->debug_level = (TRACE_ON(server) != 0); wine_server_set_reply( req, supported_machines, sizeof(supported_machines) ); ret = wine_server_call( req ); - NtCurrentTeb()->ClientId.UniqueProcess = ULongToHandle(reply->pid); - NtCurrentTeb()->ClientId.UniqueThread = ULongToHandle(reply->tid); + pid = reply->pid; + tid = reply->tid; info_size = reply->info_size; server_start_time = reply->server_start; supported_machines_count = wine_server_reply_size( reply ) / sizeof(*supported_machines); @@ -1578,13 +1563,11 @@ size_t server_init_process(void) { if (arch && !strcmp( arch, "win32" )) fatal_error( "WINEARCH set to win32 but '%s' is a 64-bit installation.\n", config_dir ); - if (!is_win64) - { - is_wow64 = TRUE; - NtCurrentTeb()->GdiBatchCount = PtrToUlong( (char *)NtCurrentTeb() - teb_offset ); - NtCurrentTeb()->WowTebOffset = -teb_offset; - init_teb64( NtCurrentTeb() ); - } +#ifndef _WIN64 + is_wow64 = TRUE; + NtCurrentTeb()->GdiBatchCount = PtrToUlong( (char *)NtCurrentTeb() - teb_offset ); + NtCurrentTeb()->WowTebOffset = -teb_offset; +#endif } else { @@ -1594,6 +1577,8 @@ size_t server_init_process(void) fatal_error( "WINEARCH set to win64 but '%s' is a 32-bit installation.\n", config_dir ); } + set_thread_id( NtCurrentTeb(), pid, tid ); + for (i = 0; i < supported_machines_count; i++) if (supported_machines[i] == current_machine) return info_size; @@ -1675,12 +1660,9 @@ void server_init_thread( void *entry_point, BOOL *suspend ) req->wait_fd = ntdll_get_thread_data()->wait_fd[1]; wine_server_call( req ); *suspend = reply->suspend; - NtCurrentTeb()->ClientId.UniqueProcess = ULongToHandle(reply->pid); - NtCurrentTeb()->ClientId.UniqueThread = ULongToHandle(reply->tid); } SERVER_END_REQ; close( reply_pipe ); - init_teb64( NtCurrentTeb() ); } diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 01eeb666a44..079ac16952d 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -119,6 +119,28 @@ static void start_thread( TEB *teb ) } +/*********************************************************************** + * set_thread_id + */ +void set_thread_id( TEB *teb, DWORD pid, DWORD tid ) +{ + teb->ClientId.UniqueProcess = ULongToHandle( pid ); + teb->ClientId.UniqueThread = ULongToHandle( tid ); + if (teb->WowTebOffset) + { +#ifdef _WIN64 + TEB32 *teb32 = (TEB32 *)((char *)teb + teb->WowTebOffset); + teb32->ClientId.UniqueProcess = pid; + teb32->ClientId.UniqueThread = tid; +#else + TEB64 *teb64 = (TEB64 *)((char *)teb + teb->WowTebOffset); + teb64->ClientId.UniqueProcess = pid; + teb64->ClientId.UniqueThread = tid; +#endif + } +} + + /*********************************************************************** * update_attr_list * @@ -173,7 +195,6 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT DWORD tid = 0; int request_pipe[2]; SIZE_T extra_stack = PTHREAD_STACK_MIN; - CLIENT_ID client_id; TEB *teb; INITIAL_TEB stack; NTSTATUS status; @@ -200,6 +221,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT if (result.create_thread.status == STATUS_SUCCESS) { + CLIENT_ID client_id; TEB *teb = wine_server_get_ptr( result.create_thread.teb ); *handle = wine_server_ptr_handle( result.create_thread.handle ); client_id.UniqueProcess = ULongToHandle( result.create_thread.pid ); @@ -253,9 +275,7 @@ NTSTATUS WINAPI NtCreateThreadEx( HANDLE *handle, ACCESS_MASK access, OBJECT_ATT goto done; } - client_id.UniqueProcess = ULongToHandle( GetCurrentProcessId() ); - client_id.UniqueThread = ULongToHandle( tid ); - teb->ClientId = client_id; + set_thread_id( teb, GetCurrentProcessId(), tid ); teb->Tib.StackBase = stack.StackBase; teb->Tib.StackLimit = stack.StackLimit; @@ -289,7 +309,7 @@ done: close( request_pipe[1] ); return status; } - if (attr_list) update_attr_list( attr_list, &client_id, teb ); + if (attr_list) update_attr_list( attr_list, &teb->ClientId, teb ); return STATUS_SUCCESS; } diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index ce34cea7fcf..5c340107964 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -172,6 +172,7 @@ extern void server_init_process_done(void) DECLSPEC_HIDDEN; extern void server_init_thread( void *entry_point, BOOL *suspend ) DECLSPEC_HIDDEN; extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN; +extern void set_thread_id( TEB *teb, DWORD pid, DWORD tid ) DECLSPEC_HIDDEN; extern NTSTATUS context_to_server( context_t *to, const CONTEXT *from ) DECLSPEC_HIDDEN; extern NTSTATUS context_from_server( CONTEXT *to, const context_t *from ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN abort_thread( int status ) DECLSPEC_HIDDEN;
1
0
0
0
Zebediah Figura : winegstreamer: Use a static buffer to enumerate stream types in media_stream_init_desc().
by Alexandre Julliard
17 May '21
17 May '21
Module: wine Branch: master Commit: cf02b0bdfafddff74cfbaca88ba70c6bd59ca0b0 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=cf02b0bdfafddff74cfbaca8…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Sun May 16 22:35:30 2021 -0500 winegstreamer: Use a static buffer to enumerate stream types in media_stream_init_desc(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/winegstreamer/media_source.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/dlls/winegstreamer/media_source.c b/dlls/winegstreamer/media_source.c index 7f308973270..8a87992d450 100644 --- a/dlls/winegstreamer/media_source.c +++ b/dlls/winegstreamer/media_source.c @@ -757,8 +757,7 @@ fail: static HRESULT media_stream_init_desc(struct media_stream *stream) { IMFMediaTypeHandler *type_handler = NULL; - IMFMediaType **stream_types = NULL; - IMFMediaType *stream_type = NULL; + IMFMediaType *stream_types[6]; struct wg_format format; DWORD type_count = 0; unsigned int i; @@ -784,8 +783,6 @@ static HRESULT media_stream_init_desc(struct media_stream *stream) IMFMediaType_GetGUID(base_type, &MF_MT_SUBTYPE, &base_subtype); - stream_types = malloc(sizeof(IMFMediaType *) * (ARRAY_SIZE(video_types) + 1)); - stream_types[0] = base_type; type_count = 1; @@ -816,8 +813,6 @@ static HRESULT media_stream_init_desc(struct media_stream *stream) WG_AUDIO_FORMAT_F32LE, }; - stream_types = malloc( sizeof(IMFMediaType *) * (ARRAY_SIZE(audio_types) + 1) ); - stream_types[0] = mf_media_type_from_wg_format(&format); type_count = 1; @@ -833,14 +828,12 @@ static HRESULT media_stream_init_desc(struct media_stream *stream) } else { - stream_type = mf_media_type_from_wg_format(&format); - if (stream_type) - { - stream_types = &stream_type; + if ((stream_types[0] = mf_media_type_from_wg_format(&format))) type_count = 1; - } } + assert(type_count < ARRAY_SIZE(stream_types)); + if (!type_count) { ERR("Failed to establish an IMFMediaType from any of the possible stream caps!\n"); @@ -861,8 +854,6 @@ done: IMFMediaTypeHandler_Release(type_handler); for (i = 0; i < type_count; i++) IMFMediaType_Release(stream_types[i]); - if (stream_types != &stream_type) - free(stream_types); return hr; }
1
0
0
0
← Newer
1
...
38
39
40
41
42
43
44
...
77
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
Results per page:
10
25
50
100
200