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
April 2019
----- 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
1 participants
803 discussions
Start a n
N
ew thread
Nikolay Sivov : dbgeng: Implement GetModuleByOffset().
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: 9fb20dda0f87c50a209fe22b06d0d0987febfe79 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=9fb20dda0f87c50a209fe22b…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Apr 22 09:42:29 2019 +0300 dbgeng: Implement GetModuleByOffset(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dbgeng/dbgeng.c | 25 +++++++++++++++++++++++-- dlls/dbgeng/tests/dbgeng.c | 22 +++++++++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c index b5650d8..1acfe0b 100644 --- a/dlls/dbgeng/dbgeng.c +++ b/dlls/dbgeng/dbgeng.c @@ -1053,9 +1053,30 @@ static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleByModuleName(IDebugSymbol static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleByOffset(IDebugSymbols3 *iface, ULONG64 offset, ULONG start_index, ULONG *index, ULONG64 *base) { - FIXME("%p, %s, %u, %p, %p stub.\n", iface, wine_dbgstr_longlong(offset), start_index, index, base); + struct debug_client *debug_client = impl_from_IDebugSymbols3(iface); + static struct target_process *target; + const struct module_info *info; - return E_NOTIMPL; + TRACE("%p, %s, %u, %p, %p.\n", iface, wine_dbgstr_longlong(offset), start_index, index, base); + + if (!(target = debug_client_get_target(debug_client))) + return E_UNEXPECTED; + + while ((info = debug_target_get_module_info(target, start_index))) + { + if (offset >= info->params.Base && offset < info->params.Base + info->params.Size) + { + if (index) + *index = start_index; + if (base) + *base = info->params.Base; + return S_OK; + } + + start_index++; + } + + return E_INVALIDARG; } static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleNames(IDebugSymbols3 *iface, ULONG index, ULONG64 base, diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c index 2002beb..2a2dd3ad 100644 --- a/dlls/dbgeng/tests/dbgeng.c +++ b/dlls/dbgeng/tests/dbgeng.c @@ -322,8 +322,8 @@ todo_wine static void test_module_information(void) { static const char *event_name = "dbgeng_test_event"; + unsigned int loaded, unloaded, index; DEBUG_MODULE_PARAMETERS params[2]; - unsigned int loaded, unloaded; PROCESS_INFORMATION info; IDebugSymbols *symbols; IDebugControl *control; @@ -372,7 +372,27 @@ static void test_module_information(void) ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!!base, "Unexpected module base.\n"); + hr = symbols->lpVtbl->GetModuleByOffset(symbols, 0, 0, &index, &base); + ok(FAILED(hr), "Unexpected hr %#x.\n", hr); + + hr = symbols->lpVtbl->GetModuleByOffset(symbols, base, 0, &index, &base); + ok(hr == S_OK, "Failed to get module, hr %#x.\n", hr); + + hr = symbols->lpVtbl->GetModuleByOffset(symbols, base, 0, NULL, NULL); + ok(hr == S_OK, "Failed to get module, hr %#x.\n", hr); + + hr = symbols->lpVtbl->GetModuleByOffset(symbols, base + 1, 0, NULL, NULL); + ok(hr == S_OK, "Failed to get module, hr %#x.\n", hr); + + hr = symbols->lpVtbl->GetModuleByOffset(symbols, base, loaded, NULL, NULL); + ok(FAILED(hr), "Unexpected hr %#x.\n", hr); + /* Parameters. */ + base = 0; + hr = symbols->lpVtbl->GetModuleByIndex(symbols, 0, &base); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!!base, "Unexpected module base.\n"); + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, NULL, 0, params); ok(hr == S_OK, "Failed to get module parameters, hr %#x.\n", hr); ok(params[0].Base == base, "Unexpected module base.\n");
1
0
0
0
Nikolay Sivov : dbgeng: Implement GetModuleParameters().
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: d337e7a6561b8da248f4d2bc97e01e1eedfd0251 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d337e7a6561b8da248f4d2bc…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Apr 22 09:42:28 2019 +0300 dbgeng: Implement GetModuleParameters(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dbgeng/dbgeng.c | 55 +++++++++++++++++++++++++++++++++++++++++++--- dlls/dbgeng/tests/dbgeng.c | 29 ++++++++++++++++++++++++ include/dbgeng.h | 2 ++ 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c index d4f8205..b5650d8 100644 --- a/dlls/dbgeng/dbgeng.c +++ b/dlls/dbgeng/dbgeng.c @@ -144,6 +144,22 @@ static const struct module_info *debug_target_get_module_info(struct target_proc return &target->modules.info[i]; } +static const struct module_info *debug_target_get_module_info_by_base(struct target_process *target, ULONG64 base) +{ + unsigned int i; + + if (FAILED(debug_target_init_modules_info(target))) + return NULL; + + for (i = 0; i < target->modules.loaded; ++i) + { + if (target->modules.info[i].params.Base == base) + return &target->modules.info[i]; + } + + return NULL; +} + static void debug_client_detach_target(struct target_process *target) { NTSTATUS status; @@ -1055,11 +1071,44 @@ static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleNames(IDebugSymbols3 *ifa } static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleParameters(IDebugSymbols3 *iface, ULONG count, ULONG64 *bases, - ULONG start, DEBUG_MODULE_PARAMETERS *parameters) + ULONG start, DEBUG_MODULE_PARAMETERS *params) { - FIXME("%p, %u, %p, %u, %p stub.\n", iface, count, bases, start, parameters); + struct debug_client *debug_client = impl_from_IDebugSymbols3(iface); + const struct module_info *info; + struct target_process *target; + unsigned int i; - return E_NOTIMPL; + TRACE("%p, %u, %p, %u, %p.\n", iface, count, bases, start, params); + + if (!(target = debug_client_get_target(debug_client))) + return E_UNEXPECTED; + + if (bases) + { + for (i = 0; i < count; ++i) + { + if ((info = debug_target_get_module_info_by_base(target, bases[i]))) + { + params[i] = info->params; + } + else + { + memset(¶ms[i], 0, sizeof(*params)); + params[i].Base = DEBUG_INVALID_OFFSET; + } + } + } + else + { + for (i = start; i < start + count; ++i) + { + if (!(info = debug_target_get_module_info(target, i))) + return E_INVALIDARG; + params[i] = info->params; + } + } + + return S_OK; } static HRESULT STDMETHODCALLTYPE debugsymbols_GetSymbolModule(IDebugSymbols3 *iface, const char *symbol, ULONG64 *base) diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c index 74f9e7c..2002beb 100644 --- a/dlls/dbgeng/tests/dbgeng.c +++ b/dlls/dbgeng/tests/dbgeng.c @@ -322,11 +322,13 @@ todo_wine static void test_module_information(void) { static const char *event_name = "dbgeng_test_event"; + DEBUG_MODULE_PARAMETERS params[2]; unsigned int loaded, unloaded; PROCESS_INFORMATION info; IDebugSymbols *symbols; IDebugControl *control; IDebugClient *client; + ULONG64 bases[2]; ULONG64 base; HANDLE event; HRESULT hr; @@ -370,6 +372,33 @@ static void test_module_information(void) ok(hr == S_OK, "Unexpected hr %#x.\n", hr); ok(!!base, "Unexpected module base.\n"); + /* Parameters. */ + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, NULL, 0, params); + ok(hr == S_OK, "Failed to get module parameters, hr %#x.\n", hr); + ok(params[0].Base == base, "Unexpected module base.\n"); + + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, &base, 100, params); + ok(hr == S_OK, "Failed to get module parameters, hr %#x.\n", hr); + ok(params[0].Base == base, "Unexpected module base.\n"); + + bases[0] = base + 1; + bases[1] = base; + hr = symbols->lpVtbl->GetModuleParameters(symbols, 2, bases, 0, params); + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* XP */, "Failed to get module parameters, hr %#x.\n", hr); + ok(params[0].Base == DEBUG_INVALID_OFFSET, "Unexpected module base.\n"); + ok(params[0].Size == 0, "Unexpected module size.\n"); + ok(params[1].Base == base, "Unexpected module base.\n"); + ok(params[1].Size != 0, "Unexpected module size.\n"); + + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, bases, 0, params); + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* XP */, "Failed to get module parameters, hr %#x.\n", hr); + + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, bases, loaded, params); + ok(hr == S_OK || broken(hr == E_NOINTERFACE) /* XP */, "Failed to get module parameters, hr %#x.\n", hr); + + hr = symbols->lpVtbl->GetModuleParameters(symbols, 1, NULL, loaded, params); + ok(FAILED(hr), "Unexpected hr %#x.\n", hr); + hr = client->lpVtbl->DetachProcesses(client); ok(hr == S_OK, "Failed to detach, hr %#x.\n", hr); diff --git a/include/dbgeng.h b/include/dbgeng.h index 3b7ff2b..f50a1ca 100644 --- a/include/dbgeng.h +++ b/include/dbgeng.h @@ -162,6 +162,8 @@ DEFINE_GUID(IID_IDebugSystemObjects3, 0xe9676e2f, 0xe286, 0x4ea3, 0xb0, 0xf9 #define DEBUG_CDS_REFRESH_INLINESTEP 16 #define DEBUG_CDS_REFRESH_INLINESTEP_PSEUDO 17 +#define DEBUG_INVALID_OFFSET ((ULONG64)-1) + typedef struct _DEBUG_MODULE_PARAMETERS { ULONG64 Base;
1
0
0
0
Nikolay Sivov : dbgeng: Implement GetModuleByIndex().
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: d33180aebdce4bd6859dc206977dbb8bdcc53a7e URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d33180aebdce4bd6859dc206…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Apr 22 09:42:27 2019 +0300 dbgeng: Implement GetModuleByIndex(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dbgeng/dbgeng.c | 74 +++++++++++++++++++++++++++++++++++++++++++--- dlls/dbgeng/tests/dbgeng.c | 63 ++++++++++++++++++++++++++++++--------- 2 files changed, 119 insertions(+), 18 deletions(-) diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c index 077de3b..d4f8205 100644 --- a/dlls/dbgeng/dbgeng.c +++ b/dlls/dbgeng/dbgeng.c @@ -39,6 +39,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbgeng); extern NTSTATUS WINAPI NtSuspendProcess(HANDLE handle); extern NTSTATUS WINAPI NtResumeProcess(HANDLE handle); +struct module_info +{ + DEBUG_MODULE_PARAMETERS params; +}; + struct target_process { struct list entry; @@ -47,6 +52,7 @@ struct target_process HANDLE handle; struct { + struct module_info *info; unsigned int loaded; unsigned int unloaded; BOOL initialized; @@ -75,6 +81,9 @@ static struct target_process *debug_client_get_target(struct debug_client *debug static HRESULT debug_target_init_modules_info(struct target_process *target) { + unsigned int i, count; + HMODULE *modules; + MODULEINFO info; DWORD needed; if (target->modules.initialized) @@ -88,7 +97,35 @@ static HRESULT debug_target_init_modules_info(struct target_process *target) if (!needed) return E_FAIL; - target->modules.loaded = needed / sizeof(HMODULE); + count = needed / sizeof(HMODULE); + + if (!(modules = heap_alloc(count * sizeof(*modules)))) + return E_OUTOFMEMORY; + + if (!(target->modules.info = heap_alloc_zero(count * sizeof(*target->modules.info)))) + { + heap_free(modules); + return E_OUTOFMEMORY; + } + + if (EnumProcessModules(target->handle, modules, count * sizeof(*modules), &needed)) + { + for (i = 0; i < count; ++i) + { + if (!GetModuleInformation(target->handle, modules[i], &info, sizeof(info))) + { + WARN("Failed to get module information, error %d.\n", GetLastError()); + continue; + } + + target->modules.info[i].params.Base = (ULONG_PTR)info.lpBaseOfDll; + target->modules.info[i].params.Size = info.SizeOfImage; + } + } + + heap_free(modules); + + target->modules.loaded = count; target->modules.unloaded = 0; /* FIXME */ target->modules.initialized = TRUE; @@ -96,6 +133,17 @@ static HRESULT debug_target_init_modules_info(struct target_process *target) return S_OK; } +static const struct module_info *debug_target_get_module_info(struct target_process *target, unsigned int i) +{ + if (FAILED(debug_target_init_modules_info(target))) + return NULL; + + if (i >= target->modules.loaded) + return NULL; + + return &target->modules.info[i]; +} + static void debug_client_detach_target(struct target_process *target) { NTSTATUS status; @@ -185,6 +233,12 @@ static ULONG STDMETHODCALLTYPE debugclient_AddRef(IDebugClient *iface) return refcount; } +static void debug_target_free(struct target_process *target) +{ + heap_free(target->modules.info); + heap_free(target); +} + static ULONG STDMETHODCALLTYPE debugclient_Release(IDebugClient *iface) { struct debug_client *debug_client = impl_from_IDebugClient(iface); @@ -199,7 +253,7 @@ static ULONG STDMETHODCALLTYPE debugclient_Release(IDebugClient *iface) { debug_client_detach_target(cur); list_remove(&cur->entry); - heap_free(cur); + debug_target_free(cur); } if (debug_client->event_callbacks) debug_client->event_callbacks->lpVtbl->Release(debug_client->event_callbacks); @@ -955,9 +1009,21 @@ static HRESULT STDMETHODCALLTYPE debugsymbols_GetNumberModules(IDebugSymbols3 *i static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleByIndex(IDebugSymbols3 *iface, ULONG index, ULONG64 *base) { - FIXME("%p, %u, %p stub.\n", iface, index, base); + struct debug_client *debug_client = impl_from_IDebugSymbols3(iface); + const struct module_info *info; + struct target_process *target; - return E_NOTIMPL; + TRACE("%p, %u, %p.\n", iface, index, base); + + if (!(target = debug_client_get_target(debug_client))) + return E_UNEXPECTED; + + if (!(info = debug_target_get_module_info(target, index))) + return E_INVALIDARG; + + *base = info->params.Base; + + return S_OK; } static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleByModuleName(IDebugSymbols3 *iface, const char *name, diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c index 6e6e2d3..74f9e7c 100644 --- a/dlls/dbgeng/tests/dbgeng.c +++ b/dlls/dbgeng/tests/dbgeng.c @@ -224,23 +224,36 @@ static const IDebugEventCallbacksVtbl event_callbacks_vtbl = event_callbacks_ChangeSymbolState, }; -static const char *event_name = "dbgeng_test_event"; - -static BOOL create_target_process(PROCESS_INFORMATION *info) +static BOOL create_target_process(const char *event_name, PROCESS_INFORMATION *info) { + static const char *event_target_ready_name = "dbgeng_test_target_ready_event"; char path_name[MAX_PATH]; STARTUPINFOA startup; + HANDLE ready_event; char **argv; + BOOL ret; + + ready_event = CreateEventA(NULL, FALSE, FALSE, event_target_ready_name); + ok(ready_event != NULL, "Failed to create event.\n"); winetest_get_mainargs(&argv); memset(&startup, 0, sizeof(startup)); startup.cb = sizeof(startup); - sprintf(path_name, "%s dbgeng target", argv[0]); - return CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, info); + sprintf(path_name, "%s dbgeng target %s %s", argv[0], event_name, event_target_ready_name); + ret = CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, info); + if (ret) + { + WaitForSingleObject(ready_event, INFINITE); + } + + CloseHandle(ready_event); + + return ret; } static void test_attach(void) { + static const char *event_name = "dbgeng_test_event"; IDebugEventCallbacks event_callbacks = { &event_callbacks_vtbl }; PROCESS_INFORMATION info; IDebugControl *control; @@ -262,7 +275,7 @@ static void test_attach(void) event = CreateEventA(NULL, FALSE, FALSE, event_name); ok(event != NULL, "Failed to create event.\n"); - ret = create_target_process(&info); + ret = create_target_process(event_name, &info); ok(ret, "Failed to create target process.\n"); is_debugged = TRUE; @@ -308,11 +321,13 @@ todo_wine static void test_module_information(void) { + static const char *event_name = "dbgeng_test_event"; unsigned int loaded, unloaded; PROCESS_INFORMATION info; IDebugSymbols *symbols; IDebugControl *control; IDebugClient *client; + ULONG64 base; HANDLE event; HRESULT hr; BOOL ret; @@ -329,9 +344,12 @@ static void test_module_information(void) event = CreateEventA(NULL, FALSE, FALSE, event_name); ok(event != NULL, "Failed to create event.\n"); - ret = create_target_process(&info); + ret = create_target_process(event_name, &info); ok(ret, "Failed to create target process.\n"); + hr = control->lpVtbl->SetEngineOptions(control, DEBUG_ENGOPT_INITIAL_BREAK); + ok(hr == S_OK, "Failed to set engine options, hr %#x.\n", hr); + hr = client->lpVtbl->AttachProcess(client, 0, info.dwProcessId, DEBUG_ATTACH_NONINVASIVE); ok(hr == S_OK, "Failed to attach to process, hr %#x.\n", hr); @@ -341,6 +359,16 @@ static void test_module_information(void) /* Number of modules. */ hr = symbols->lpVtbl->GetNumberModules(symbols, &loaded, &unloaded); ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(loaded > 0, "Unexpected module count %u.\n", loaded); + + /* Module base. */ + hr = symbols->lpVtbl->GetModuleByIndex(symbols, loaded, &base); + ok(FAILED(hr), "Unexpected hr %#x.\n", hr); + + base = 0; + hr = symbols->lpVtbl->GetModuleByIndex(symbols, 0, &base); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + ok(!!base, "Unexpected module base.\n"); hr = client->lpVtbl->DetachProcesses(client); ok(hr == S_OK, "Failed to detach, hr %#x.\n", hr); @@ -356,19 +384,26 @@ static void test_module_information(void) symbols->lpVtbl->Release(symbols); } -static void target_proc(void) +static void target_proc(const char *event_name, const char *event_ready_name) { - HANDLE event = OpenEventA(SYNCHRONIZE, FALSE, event_name); + HANDLE terminate_event, ready_event; - ok(event != NULL, "Failed to open event handle.\n"); + terminate_event = OpenEventA(SYNCHRONIZE, FALSE, event_name); + ok(terminate_event != NULL, "Failed to open event handle.\n"); + + ready_event = OpenEventA(EVENT_MODIFY_STATE, FALSE, event_ready_name); + ok(ready_event != NULL, "Failed to open event handle.\n"); + + SetEvent(ready_event); for (;;) { - if (WaitForSingleObject(event, 100) == WAIT_OBJECT_0) + if (WaitForSingleObject(terminate_event, 100) == WAIT_OBJECT_0) break; } - CloseHandle(event); + CloseHandle(terminate_event); + CloseHandle(ready_event); } START_TEST(dbgeng) @@ -378,9 +413,9 @@ START_TEST(dbgeng) argc = winetest_get_mainargs(&argv); - if (argc >= 3 && !strcmp(argv[2], "target")) + if (argc > 4 && !strcmp(argv[2], "target")) { - target_proc(); + target_proc(argv[3], argv[4]); return; }
1
0
0
0
Nikolay Sivov : dbgeng: Implement GetNumberModules().
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: 73a8fe94e631c38a3b0af2c610e998538f595ed4 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=73a8fe94e631c38a3b0af2c6…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Apr 22 09:42:26 2019 +0300 dbgeng: Implement GetNumberModules(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dbgeng/dbgeng.c | 63 ++++++++++++++++++++++++++++++++++----- dlls/dbgeng/tests/dbgeng.c | 73 +++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 121 insertions(+), 15 deletions(-) diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c index 8ce7ac6..077de3b 100644 --- a/dlls/dbgeng/dbgeng.c +++ b/dlls/dbgeng/dbgeng.c @@ -25,6 +25,7 @@ #include "windef.h" #include "winbase.h" #include "winternl.h" +#include "psapi.h" #include "initguid.h" #include "dbgeng.h" @@ -44,6 +45,12 @@ struct target_process unsigned int pid; unsigned int attach_flags; HANDLE handle; + struct + { + unsigned int loaded; + unsigned int unloaded; + BOOL initialized; + } modules; }; struct debug_client @@ -58,6 +65,37 @@ struct debug_client IDebugEventCallbacks *event_callbacks; }; +static struct target_process *debug_client_get_target(struct debug_client *debug_client) +{ + if (list_empty(&debug_client->targets)) + return NULL; + + return LIST_ENTRY(list_head(&debug_client->targets), struct target_process, entry); +} + +static HRESULT debug_target_init_modules_info(struct target_process *target) +{ + DWORD needed; + + if (target->modules.initialized) + return S_OK; + + if (!target->handle) + return E_UNEXPECTED; + + needed = 0; + EnumProcessModules(target->handle, NULL, 0, &needed); + if (!needed) + return E_FAIL; + + target->modules.loaded = needed / sizeof(HMODULE); + target->modules.unloaded = 0; /* FIXME */ + + target->modules.initialized = TRUE; + + return S_OK; +} + static void debug_client_detach_target(struct target_process *target) { NTSTATUS status; @@ -255,7 +293,7 @@ static HRESULT STDMETHODCALLTYPE debugclient_AttachProcess(IDebugClient *iface, return E_NOTIMPL; } - if (!(process = heap_alloc(sizeof(*process)))) + if (!(process = heap_alloc_zero(sizeof(*process)))) return E_OUTOFMEMORY; process->pid = pid; @@ -897,9 +935,22 @@ static HRESULT STDMETHODCALLTYPE debugsymbols_GetOffsetByLine(IDebugSymbols3 *if static HRESULT STDMETHODCALLTYPE debugsymbols_GetNumberModules(IDebugSymbols3 *iface, ULONG *loaded, ULONG *unloaded) { - FIXME("%p, %p, %p stub.\n", iface, loaded, unloaded); + struct debug_client *debug_client = impl_from_IDebugSymbols3(iface); + static struct target_process *target; + HRESULT hr; - return E_NOTIMPL; + TRACE("%p, %p, %p.\n", iface, loaded, unloaded); + + if (!(target = debug_client_get_target(debug_client))) + return E_UNEXPECTED; + + if (FAILED(hr = debug_target_init_modules_info(target))) + return hr; + + *loaded = target->modules.loaded; + *unloaded = target->modules.unloaded; + + return S_OK; } static HRESULT STDMETHODCALLTYPE debugsymbols_GetModuleByIndex(IDebugSymbols3 *iface, ULONG index, ULONG64 *base) @@ -2679,15 +2730,13 @@ static HRESULT STDMETHODCALLTYPE debugcontrol_WaitForEvent(IDebugControl2 *iface /* FIXME: only one target is used currently */ - if (list_empty(&debug_client->targets)) + if (!(target = debug_client_get_target(debug_client))) return E_UNEXPECTED; - target = LIST_ENTRY(list_head(&debug_client->targets), struct target_process, entry); - if (target->attach_flags & DEBUG_ATTACH_NONINVASIVE) { BOOL suspend = !(target->attach_flags & DEBUG_ATTACH_NONINVASIVE_NO_SUSPEND); - DWORD access = PROCESS_VM_READ | PROCESS_VM_WRITE; + DWORD access = PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_QUERY_LIMITED_INFORMATION; NTSTATUS status; if (suspend) diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c index 650ab4a..6e6e2d3 100644 --- a/dlls/dbgeng/tests/dbgeng.c +++ b/dlls/dbgeng/tests/dbgeng.c @@ -226,17 +226,27 @@ static const IDebugEventCallbacksVtbl event_callbacks_vtbl = static const char *event_name = "dbgeng_test_event"; +static BOOL create_target_process(PROCESS_INFORMATION *info) +{ + char path_name[MAX_PATH]; + STARTUPINFOA startup; + char **argv; + + winetest_get_mainargs(&argv); + memset(&startup, 0, sizeof(startup)); + startup.cb = sizeof(startup); + sprintf(path_name, "%s dbgeng target", argv[0]); + return CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, info); +} + static void test_attach(void) { IDebugEventCallbacks event_callbacks = { &event_callbacks_vtbl }; PROCESS_INFORMATION info; - char path_name[MAX_PATH]; IDebugControl *control; IDebugClient *client; - STARTUPINFOA startup; BOOL is_debugged; HANDLE event; - char **argv; HRESULT hr; BOOL ret; @@ -252,11 +262,7 @@ static void test_attach(void) event = CreateEventA(NULL, FALSE, FALSE, event_name); ok(event != NULL, "Failed to create event.\n"); - winetest_get_mainargs(&argv); - memset(&startup, 0, sizeof(startup)); - startup.cb = sizeof(startup); - sprintf(path_name, "%s dbgeng target", argv[0]); - ret = CreateProcessA(NULL, path_name, NULL, NULL, FALSE, 0, NULL, NULL, &startup, &info), + ret = create_target_process(&info); ok(ret, "Failed to create target process.\n"); is_debugged = TRUE; @@ -300,6 +306,56 @@ todo_wine control->lpVtbl->Release(control); } +static void test_module_information(void) +{ + unsigned int loaded, unloaded; + PROCESS_INFORMATION info; + IDebugSymbols *symbols; + IDebugControl *control; + IDebugClient *client; + HANDLE event; + HRESULT hr; + BOOL ret; + + hr = DebugCreate(&IID_IDebugClient, (void **)&client); + ok(hr == S_OK, "Failed to create engine object, hr %#x.\n", hr); + + hr = client->lpVtbl->QueryInterface(client, &IID_IDebugControl, (void **)&control); + ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr); + + hr = client->lpVtbl->QueryInterface(client, &IID_IDebugSymbols, (void **)&symbols); + ok(hr == S_OK, "Failed to get interface pointer, hr %#x.\n", hr); + + event = CreateEventA(NULL, FALSE, FALSE, event_name); + ok(event != NULL, "Failed to create event.\n"); + + ret = create_target_process(&info); + ok(ret, "Failed to create target process.\n"); + + hr = client->lpVtbl->AttachProcess(client, 0, info.dwProcessId, DEBUG_ATTACH_NONINVASIVE); + ok(hr == S_OK, "Failed to attach to process, hr %#x.\n", hr); + + hr = control->lpVtbl->WaitForEvent(control, 0, INFINITE); + ok(hr == S_OK, "Waiting for event failed, hr %#x.\n", hr); + + /* Number of modules. */ + hr = symbols->lpVtbl->GetNumberModules(symbols, &loaded, &unloaded); + ok(hr == S_OK, "Unexpected hr %#x.\n", hr); + + hr = client->lpVtbl->DetachProcesses(client); + ok(hr == S_OK, "Failed to detach, hr %#x.\n", hr); + + SetEvent(event); + winetest_wait_child_process(info.hProcess); + + CloseHandle(info.hProcess); + CloseHandle(info.hThread); + + client->lpVtbl->Release(client); + control->lpVtbl->Release(control); + symbols->lpVtbl->Release(symbols); +} + static void target_proc(void) { HANDLE event = OpenEventA(SYNCHRONIZE, FALSE, event_name); @@ -330,4 +386,5 @@ START_TEST(dbgeng) test_engine_options(); test_attach(); + test_module_information(); }
1
0
0
0
Nikolay Sivov : dbgeng: Add support for non-invasive attach on WaitForEvent().
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: 4557a007d70cac23e76d7e444a6dcfbf5e02349b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=4557a007d70cac23e76d7e44…
Author: Nikolay Sivov <nsivov(a)codeweavers.com> Date: Mon Apr 22 09:42:25 2019 +0300 dbgeng: Add support for non-invasive attach on WaitForEvent(). Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/dbgeng/dbgeng.c | 81 ++++++++++++++++++++++++++++++++++++++++++++-- dlls/dbgeng/tests/dbgeng.c | 2 -- 2 files changed, 78 insertions(+), 5 deletions(-) diff --git a/dlls/dbgeng/dbgeng.c b/dlls/dbgeng/dbgeng.c index c54d13f..8ce7ac6 100644 --- a/dlls/dbgeng/dbgeng.c +++ b/dlls/dbgeng/dbgeng.c @@ -35,11 +35,15 @@ WINE_DEFAULT_DEBUG_CHANNEL(dbgeng); +extern NTSTATUS WINAPI NtSuspendProcess(HANDLE handle); +extern NTSTATUS WINAPI NtResumeProcess(HANDLE handle); + struct target_process { struct list entry; unsigned int pid; unsigned int attach_flags; + HANDLE handle; }; struct debug_client @@ -54,6 +58,28 @@ struct debug_client IDebugEventCallbacks *event_callbacks; }; +static void debug_client_detach_target(struct target_process *target) +{ + NTSTATUS status; + + if (!target->handle) + return; + + if (target->attach_flags & DEBUG_ATTACH_NONINVASIVE) + { + BOOL resume = !(target->attach_flags & DEBUG_ATTACH_NONINVASIVE_NO_SUSPEND); + + if (resume) + { + if ((status = NtResumeProcess(target->handle))) + WARN("Failed to resume process, status %#x.\n", status); + } + } + + CloseHandle(target->handle); + target->handle = NULL; +} + static struct debug_client *impl_from_IDebugClient(IDebugClient *iface) { return CONTAINING_RECORD(iface, struct debug_client, IDebugClient_iface); @@ -133,6 +159,7 @@ static ULONG STDMETHODCALLTYPE debugclient_Release(IDebugClient *iface) { LIST_FOR_EACH_ENTRY_SAFE(cur, cur2, &debug_client->targets, struct target_process, entry) { + debug_client_detach_target(cur); list_remove(&cur->entry); heap_free(cur); } @@ -329,9 +356,17 @@ static HRESULT STDMETHODCALLTYPE debugclient_TerminateProcesses(IDebugClient *if static HRESULT STDMETHODCALLTYPE debugclient_DetachProcesses(IDebugClient *iface) { - FIXME("%p stub.\n", iface); + struct debug_client *debug_client = impl_from_IDebugClient(iface); + struct target_process *target; - return E_NOTIMPL; + TRACE("%p.\n", iface); + + LIST_FOR_EACH_ENTRY(target, &debug_client->targets, struct target_process, entry) + { + debug_client_detach_target(target); + } + + return S_OK; } static HRESULT STDMETHODCALLTYPE debugclient_EndSession(IDebugClient *iface, ULONG flags) @@ -2637,7 +2672,47 @@ static HRESULT STDMETHODCALLTYPE debugcontrol_SetExceptionFilterSecondCommand(ID static HRESULT STDMETHODCALLTYPE debugcontrol_WaitForEvent(IDebugControl2 *iface, ULONG flags, ULONG timeout) { - FIXME("%p, %#x, %u stub.\n", iface, flags, timeout); + struct debug_client *debug_client = impl_from_IDebugControl2(iface); + struct target_process *target; + + TRACE("%p, %#x, %u.\n", iface, flags, timeout); + + /* FIXME: only one target is used currently */ + + if (list_empty(&debug_client->targets)) + return E_UNEXPECTED; + + target = LIST_ENTRY(list_head(&debug_client->targets), struct target_process, entry); + + if (target->attach_flags & DEBUG_ATTACH_NONINVASIVE) + { + BOOL suspend = !(target->attach_flags & DEBUG_ATTACH_NONINVASIVE_NO_SUSPEND); + DWORD access = PROCESS_VM_READ | PROCESS_VM_WRITE; + NTSTATUS status; + + if (suspend) + access |= PROCESS_SUSPEND_RESUME; + + target->handle = OpenProcess(access, FALSE, target->pid); + if (!target->handle) + { + WARN("Failed to get process handle for pid %#x.\n", target->pid); + return E_UNEXPECTED; + } + + if (suspend) + { + status = NtSuspendProcess(target->handle); + if (status) + WARN("Failed to suspend a process, status %#x.\n", status); + } + + return S_OK; + } + else + { + FIXME("Unsupported attach flags %#x.\n", target->attach_flags); + } return E_NOTIMPL; } diff --git a/dlls/dbgeng/tests/dbgeng.c b/dlls/dbgeng/tests/dbgeng.c index baec60a..650ab4a 100644 --- a/dlls/dbgeng/tests/dbgeng.c +++ b/dlls/dbgeng/tests/dbgeng.c @@ -273,7 +273,6 @@ static void test_attach(void) ok(!is_debugged, "Unexpected mode.\n"); hr = control->lpVtbl->WaitForEvent(control, 0, INFINITE); -todo_wine ok(hr == S_OK, "Waiting for event failed, hr %#x.\n", hr); is_debugged = TRUE; @@ -282,7 +281,6 @@ todo_wine ok(!is_debugged, "Unexpected mode.\n"); hr = client->lpVtbl->DetachProcesses(client); -todo_wine ok(hr == S_OK, "Failed to detach, hr %#x.\n", hr); hr = client->lpVtbl->EndSession(client, DEBUG_END_ACTIVE_DETACH);
1
0
0
0
Zebediah Figura : amstream/tests: Add some tests for querying pin information.
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: c5584f5ff1900782b1991a374ab6dc5dfbf4a141 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=c5584f5ff1900782b1991a37…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Sun Apr 21 15:22:44 2019 -0500 amstream/tests: Add some tests for querying pin information. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/amstream/tests/amstream.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 52fafd2..148e6bd 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -797,6 +797,55 @@ static void test_find_pin(void) ok(!ref, "Got outstanding refcount %d.\n", ref); } +static void test_pin_info(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaStreamFilter *filter; + IMediaStream *stream; + PIN_DIRECTION dir; + ULONG ref, count; + PIN_INFO info; + HRESULT hr; + WCHAR *id; + IPin *pin; + + /* FIXME: This call should not be necessary. */ + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IPin_QueryPinInfo(pin, &info); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(info.pFilter == (IBaseFilter *)filter, "Expected filter %p, got %p.\n", filter, info.pFilter); + ok(info.dir == PINDIR_INPUT, "Got direction %d.\n", info.dir); + ok(!lstrcmpW(info.achName, primary_video_sink_id), "Got name %s.\n", wine_dbgstr_w(info.achName)); + IBaseFilter_Release(info.pFilter); + + hr = IPin_QueryDirection(pin, &dir); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(dir == PINDIR_INPUT, "Got direction %d.\n", dir); + + hr = IPin_QueryId(pin, &id); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(!lstrcmpW(id, primary_video_sink_id), "Got id %s.\n", wine_dbgstr_w(id)); + CoTaskMemFree(id); + + hr = IPin_QueryInternalConnections(pin, NULL, &count); + ok(hr == E_NOTIMPL, "Got hr %#x.\n", hr); + + IPin_Release(pin); + IMediaStreamFilter_Release(filter); + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_IDirectDrawStreamSample(void) { DDSURFACEDESC desc = { sizeof(desc) }; @@ -1171,6 +1220,7 @@ START_TEST(amstream) test_media_streams(); test_enum_pins(); test_find_pin(); + test_pin_info(); test_IDirectDrawStreamSample(); file = CreateFileW(filenameW, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
1
0
0
0
Zebediah Figura : amstream/tests: Add some tests for IMediaStreamFilter:: FindPin().
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: a0d2325ac52ca07f50f6150d3b7b92d7924d528c URL:
https://source.winehq.org/git/wine.git/?a=commit;h=a0d2325ac52ca07f50f6150d…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Sun Apr 21 15:22:43 2019 -0500 amstream/tests: Add some tests for IMediaStreamFilter::FindPin(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/amstream/tests/amstream.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index 56d22af..52fafd2 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -29,6 +29,10 @@ #include "ks.h" #include "ksmedia.h" +static const WCHAR primary_video_sink_id[] = {'I','{','A','3','5','F','F','5','6','A', + '-','9','F','D','A','-','1','1','D','0','-','8','F','D','F', + '-','0','0','C','0','4','F','D','9','1','8','9','D','}',0}; + #define EXPECT_REF(obj,ref) _expect_ref((IUnknown*)obj, ref, __LINE__) static void _expect_ref(IUnknown* obj, ULONG ref, int line) { @@ -758,6 +762,41 @@ static void test_enum_pins(void) todo_wine ok(!ref, "Got outstanding refcount %d.\n", ref); } +static void test_find_pin(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaStreamFilter *filter; + IMediaStream *stream; + IPin *pin, *pin2; + HRESULT hr; + ULONG ref; + + /* FIXME: This call should not be necessary. */ + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_FindPin(filter, primary_video_sink_id, &pin2); + ok(hr == VFW_E_NOT_FOUND, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_FindPin(filter, primary_video_sink_id, &pin2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(pin2 == pin, "Expected pin %p, got %p.\n", pin, pin2); + + IPin_Release(pin2); + IPin_Release(pin); + IMediaStreamFilter_Release(filter); + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_IDirectDrawStreamSample(void) { DDSURFACEDESC desc = { sizeof(desc) }; @@ -1131,6 +1170,7 @@ START_TEST(amstream) test_interfaces(); test_media_streams(); test_enum_pins(); + test_find_pin(); test_IDirectDrawStreamSample(); file = CreateFileW(filenameW, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
1
0
0
0
Zebediah Figura : amstream/tests: Add tests for IMediaStreamFilter:: EnumPins().
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: d4f99f4fbc3771166125ab7e99dd875c239837d9 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=d4f99f4fbc3771166125ab7e…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Sun Apr 21 15:22:42 2019 -0500 amstream/tests: Add tests for IMediaStreamFilter::EnumPins(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/amstream/tests/amstream.c | 144 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index bda7bf1..56d22af 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -96,6 +96,13 @@ static void release_directdraw(void) IDirectDraw7_Release(pdd7); } +static ULONG get_refcount(void *iface) +{ + IUnknown *unknown = iface; + IUnknown_AddRef(unknown); + return IUnknown_Release(unknown); +} + #define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) { @@ -615,6 +622,142 @@ static void test_media_streams(void) IAMMultiMediaStream_Release(pams); } +static void test_enum_pins(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaStreamFilter *filter; + IEnumPins *enum1, *enum2; + IMediaStream *stream; + IPin *pins[3], *pin; + ULONG ref, count; + HRESULT hr; + + /* FIXME: This call should not be necessary. */ + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ref = get_refcount(filter); + ok(ref == 3, "Got unexpected refcount %d.\n", ref); + + hr = IMediaStreamFilter_EnumPins(filter, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IMediaStreamFilter_EnumPins(filter, &enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ref = get_refcount(filter); + todo_wine ok(ref == 3, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + + hr = IEnumPins_Next(enum1, 1, NULL, NULL); + ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 0); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 1); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + hr = IMediaStream_QueryInterface(stream, &IID_IPin, (void **)&pin); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + /* Reset() isn't enough; we have to call EnumPins() again to see the updated + * pin count. */ + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + IEnumPins_Release(enum1); + + hr = IMediaStreamFilter_EnumPins(filter, &enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + ref = get_refcount(filter); + ok(ref == 4, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pin); + todo_wine ok(ref == 4, "Got unexpected refcount %d.\n", ref); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(pins[0] == pin, "Expected pin %p, got %p.\n", pin, pins[0]); + ref = get_refcount(filter); + ok(ref == 4, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(enum1); + ok(ref == 1, "Got unexpected refcount %d.\n", ref); + ref = get_refcount(pin); + todo_wine ok(ref == 5, "Got unexpected refcount %d.\n", ref); + IPin_Release(pins[0]); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, &count); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + ok(pins[0] == pin, "Expected pin %p, got %p.\n", pin, pins[0]); + IPin_Release(pins[0]); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 2, pins, NULL); + todo_wine ok(hr == E_POINTER, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 2, pins, &count); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + ok(count == 1, "Got count %u.\n", count); + ok(pins[0] == pin, "Expected pin %p, got %p.\n", pin, pins[0]); + IPin_Release(pins[0]); + + hr = IEnumPins_Reset(enum1); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Clone(enum1, &enum2); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 0); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + hr = IEnumPins_Skip(enum1, 1); + todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum1, 1, pins, NULL); + ok(hr == S_FALSE, "Got hr %#x.\n", hr); + + hr = IEnumPins_Next(enum2, 1, pins, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + ok(pins[0] == pin, "Expected pin %p, got %p.\n", pin, pins[0]); + IPin_Release(pins[0]); + + IEnumPins_Release(enum2); + IEnumPins_Release(enum1); + + IMediaStreamFilter_Release(filter); + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %d.\n", ref); + IMediaStream_Release(stream); + ref = IPin_Release(pin); + todo_wine ok(!ref, "Got outstanding refcount %d.\n", ref); +} + static void test_IDirectDrawStreamSample(void) { DDSURFACEDESC desc = { sizeof(desc) }; @@ -987,6 +1130,7 @@ START_TEST(amstream) test_interfaces(); test_media_streams(); + test_enum_pins(); test_IDirectDrawStreamSample(); file = CreateFileW(filenameW, 0, 0, NULL, OPEN_EXISTING, 0, NULL);
1
0
0
0
Zebediah Figura : amstream/tests: Add some test for supported interfaces.
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: aca1b2ea6ecb4e547204720807e157cdf08a2b5b URL:
https://source.winehq.org/git/wine.git/?a=commit;h=aca1b2ea6ecb4e5472047208…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Sun Apr 21 15:22:41 2019 -0500 amstream/tests: Add some test for supported interfaces. Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/amstream/tests/amstream.c | 112 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 2 deletions(-) diff --git a/dlls/amstream/tests/amstream.c b/dlls/amstream/tests/amstream.c index b87f955..bda7bf1 100644 --- a/dlls/amstream/tests/amstream.c +++ b/dlls/amstream/tests/amstream.c @@ -46,8 +46,9 @@ static IDirectDrawSurface7* pdds7; static IAMMultiMediaStream *create_ammultimediastream(void) { IAMMultiMediaStream *stream = NULL; - CoCreateInstance(&CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER, &IID_IAMMultiMediaStream, - (void**)&stream); + HRESULT hr = CoCreateInstance(&CLSID_AMMultiMediaStream, NULL, CLSCTX_INPROC_SERVER, + &IID_IAMMultiMediaStream, (void **)&stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); return stream; } @@ -95,6 +96,112 @@ static void release_directdraw(void) IDirectDraw7_Release(pdd7); } +#define check_interface(a, b, c) check_interface_(__LINE__, a, b, c) +static void check_interface_(unsigned int line, void *iface_ptr, REFIID iid, BOOL supported) +{ + IUnknown *iface = iface_ptr; + HRESULT hr, expected_hr; + IUnknown *unk; + + expected_hr = supported ? S_OK : E_NOINTERFACE; + + hr = IUnknown_QueryInterface(iface, iid, (void **)&unk); + ok_(__FILE__, line)(hr == expected_hr, "Got hr %#x, expected %#x.\n", hr, expected_hr); + if (SUCCEEDED(hr)) + IUnknown_Release(unk); +} + +static void test_interfaces(void) +{ + IAMMultiMediaStream *mmstream = create_ammultimediastream(); + IMediaStreamFilter *filter; + IMediaStream *stream; + HRESULT hr; + ULONG ref; + + /* FIXME: This call should not be necessary. */ + hr = IAMMultiMediaStream_Initialize(mmstream, STREAMTYPE_READ, 0, NULL); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_interface(mmstream, &IID_IAMMultiMediaStream, TRUE); + check_interface(mmstream, &IID_IMultiMediaStream, TRUE); + check_interface(mmstream, &IID_IUnknown, TRUE); + + check_interface(mmstream, &IID_IAMMediaStream, FALSE); + check_interface(mmstream, &IID_IAMMediaTypeStream, FALSE); + check_interface(mmstream, &IID_IAudioMediaStream, FALSE); + check_interface(mmstream, &IID_IBaseFilter, FALSE); + check_interface(mmstream, &IID_IDirectDrawMediaStream, FALSE); + check_interface(mmstream, &IID_IMediaFilter, FALSE); + check_interface(mmstream, &IID_IMediaStream, FALSE); + check_interface(mmstream, &IID_IMediaStreamFilter, FALSE); + check_interface(mmstream, &IID_IPin, FALSE); + + hr = IAMMultiMediaStream_GetFilter(mmstream, &filter); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_interface(filter, &IID_IBaseFilter, TRUE); + check_interface(filter, &IID_IMediaFilter, TRUE); + check_interface(filter, &IID_IMediaStreamFilter, TRUE); + check_interface(filter, &IID_IPersist, TRUE); + check_interface(filter, &IID_IUnknown, TRUE); + + check_interface(filter, &IID_IAMMediaStream, FALSE); + check_interface(filter, &IID_IAMMediaTypeStream, FALSE); + check_interface(filter, &IID_IAMMultiMediaStream, FALSE); + check_interface(filter, &IID_IAudioMediaStream, FALSE); + check_interface(filter, &IID_IDirectDrawMediaStream, FALSE); + check_interface(filter, &IID_IMediaStream, FALSE); + check_interface(filter, &IID_IMultiMediaStream, FALSE); + check_interface(filter, &IID_IPin, FALSE); + + IMediaStreamFilter_Release(filter); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryAudio, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_interface(stream, &IID_IAMMediaStream, TRUE); + check_interface(stream, &IID_IAudioMediaStream, TRUE); + check_interface(stream, &IID_IMediaStream, TRUE); + check_interface(stream, &IID_IPin, TRUE); + check_interface(stream, &IID_IUnknown, TRUE); + + check_interface(stream, &IID_IAMMediaTypeStream, FALSE); + check_interface(stream, &IID_IAMMultiMediaStream, FALSE); + check_interface(stream, &IID_IBaseFilter, FALSE); + check_interface(stream, &IID_IDirectDrawMediaStream, FALSE); + check_interface(stream, &IID_IMediaFilter, FALSE); + check_interface(stream, &IID_IMediaStreamFilter, FALSE); + check_interface(stream, &IID_IMultiMediaStream, FALSE); + check_interface(stream, &IID_IPersist, FALSE); + + IMediaStream_Release(stream); + + hr = IAMMultiMediaStream_AddMediaStream(mmstream, NULL, &MSPID_PrimaryVideo, 0, &stream); + ok(hr == S_OK, "Got hr %#x.\n", hr); + + check_interface(stream, &IID_IAMMediaStream, TRUE); + check_interface(stream, &IID_IDirectDrawMediaStream, TRUE); + check_interface(stream, &IID_IMediaStream, TRUE); + check_interface(stream, &IID_IPin, TRUE); + check_interface(stream, &IID_IUnknown, TRUE); + + check_interface(stream, &IID_IAMMediaTypeStream, FALSE); + check_interface(stream, &IID_IAMMultiMediaStream, FALSE); + check_interface(stream, &IID_IAudioMediaStream, FALSE); + check_interface(stream, &IID_IBaseFilter, FALSE); + check_interface(stream, &IID_IDirectDraw, FALSE); + check_interface(stream, &IID_IMediaFilter, FALSE); + check_interface(stream, &IID_IMediaStreamFilter, FALSE); + check_interface(stream, &IID_IMultiMediaStream, FALSE); + check_interface(stream, &IID_IPersist, FALSE); + + IMediaStream_Release(stream); + + ref = IAMMultiMediaStream_Release(mmstream); + ok(!ref, "Got outstanding refcount %u.\n", ref); +} + static void test_openfile(void) { IAMMultiMediaStream *pams; @@ -878,6 +985,7 @@ START_TEST(amstream) CoInitializeEx(NULL, COINIT_MULTITHREADED); + test_interfaces(); test_media_streams(); test_IDirectDrawStreamSample();
1
0
0
0
Zebediah Figura : amstream: Reference the returned IMediaStream pointer in IAMMultiMediaStream:: AddMediaStream().
by Alexandre Julliard
22 Apr '19
22 Apr '19
Module: wine Branch: master Commit: eec4a05e768560df3d71ca5408fe38d042e385e2 URL:
https://source.winehq.org/git/wine.git/?a=commit;h=eec4a05e768560df3d71ca54…
Author: Zebediah Figura <z.figura12(a)gmail.com> Date: Sun Apr 21 15:22:40 2019 -0500 amstream: Reference the returned IMediaStream pointer in IAMMultiMediaStream::AddMediaStream(). Signed-off-by: Zebediah Figura <z.figura12(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/amstream/amstream.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/amstream/amstream.c b/dlls/amstream/amstream.c index f9c9abf..8354df8 100644 --- a/dlls/amstream/amstream.c +++ b/dlls/amstream/amstream.c @@ -380,7 +380,9 @@ static HRESULT WINAPI IAMMultiMediaStreamImpl_AddMediaStream(IAMMultiMediaStream This->nbStreams++; if (ppNewStream) - *ppNewStream = (IMediaStream*)pStream; + { + IMediaStream_AddRef(*ppNewStream = (IMediaStream*)pStream); + } } if (SUCCEEDED(hr))
1
0
0
0
← Newer
1
...
22
23
24
25
26
27
28
...
81
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
78
79
80
81
Results per page:
10
25
50
100
200