Compare commits

...

11 commits

Author SHA1 Message Date
Eric Pouech
446f3b207f dbghelp: Implement SymRefreshModuleList().
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-11-18 11:54:35 +01:00
Eric Pouech
90ffd6c7dc dbghelp/tests: Add tests for SymRefreshModuleList().
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-11-18 11:54:35 +01:00
Eric Pouech
3ca383e34e dbghelp/tests: Add retry wrapper around SymRefreshModuleList().
Signed-off-by: Eric Pouech <epouech@codeweavers.com>
2024-11-18 11:54:35 +01:00
Rémi Bernon
c5a726e8a3 winebus: Enable hidraw by default for various HOTAS controllers.
Based on contributions from Andrew Conrad, Arkadiusz Hiler, Ivo Ivanov,
and Kai Krakow.
2024-11-18 11:53:54 +01:00
Rémi Bernon
a10ea7e662 winebus: Count HID buttons and pass it to is_hidraw_enabled. 2024-11-18 11:53:54 +01:00
Rémi Bernon
b787e0654a winebus: Lookup device HID usage and usage page on the PE side. 2024-11-18 11:53:54 +01:00
Rémi Bernon
29226ef249 winebus: Build HID report descriptors on device creation. 2024-11-18 11:53:54 +01:00
Rémi Bernon
933b885ce7 winebus: Enable all PID effect types for wheel devices.
Forza Horizon 5 doesn't like unsupported racing wheel force feedback
effects and gives up too soon.

On Windows many wheel devices have custom drivers which report support
for all types of force feedback effects.
2024-11-18 11:53:39 +01:00
Rémi Bernon
c3b1f1430c winebus: Always return success from PID effect control.
Forza Horizon 5 doesn't like unsupported racing wheel force feedback
effects.
2024-11-18 11:53:37 +01:00
Zhiyi Zhang
a308076081 wintypes/tests: Add RoParseTypeName() tests. 2024-11-18 11:52:15 +01:00
Zhiyi Zhang
6e79260df0 wintypes: Implement RoParseTypeName(). 2024-11-18 11:52:12 +01:00
15 changed files with 665 additions and 95 deletions

View file

@ -300,20 +300,6 @@ BOOL WINAPI SymGetSearchPath(HANDLE hProcess, PSTR szSearchPath,
return ret;
}
/******************************************************************
* invade_process
*
* SymInitialize helper: loads in dbghelp all known (and loaded modules)
* this assumes that hProcess is a handle on a valid process
*/
static BOOL WINAPI process_invade_cb(PCWSTR name, ULONG64 base, ULONG size, PVOID user)
{
HANDLE hProcess = user;
SymLoadModuleExW(hProcess, 0, name, NULL, base, size, NULL, 0);
return TRUE;
}
const WCHAR *process_getenv(const struct process *process, const WCHAR *name)
{
size_t name_len;
@ -432,7 +418,10 @@ static BOOL check_live_target(struct process* pcs, BOOL wow64, BOOL child_wow64)
TRACE("got debug info address %#I64x from PEB %p\n", base, pbi.PebBaseAddress);
if (!elf_read_wine_loader_dbg_info(pcs, base) && !macho_read_wine_loader_dbg_info(pcs, base))
{
WARN("couldn't load process debug info at %#I64x\n", base);
pcs->loader = &empty_loader_ops;
}
return TRUE;
}
@ -510,8 +499,9 @@ BOOL WINAPI SymInitializeW(HANDLE hProcess, PCWSTR UserSearchPath, BOOL fInvadeP
if (check_live_target(pcs, wow64, child_wow64))
{
if (fInvadeProcess)
EnumerateLoadedModulesW64(hProcess, process_invade_cb, hProcess);
if (pcs->loader) pcs->loader->synchronize_module_list(pcs);
module_refresh_list(pcs);
else
pcs->loader->synchronize_module_list(pcs);
}
else if (fInvadeProcess)
{

View file

@ -743,6 +743,7 @@ extern BOOL module_remove(struct process* pcs,
extern void module_set_module(struct module* module, const WCHAR* name);
extern WCHAR* get_wine_loader_name(struct process *pcs) __WINE_DEALLOC(HeapFree, 3) __WINE_MALLOC;
extern BOOL module_is_wine_host(const WCHAR* module_name, const WCHAR* ext);
extern BOOL module_refresh_list(struct process *pcs);
/* msc.c */
extern BOOL pe_load_debug_directory(const struct process* pcs,

View file

@ -1785,7 +1785,6 @@ BOOL elf_read_wine_loader_dbg_info(struct process* pcs, ULONG_PTR addr)
{
ERR("Unable to access ELF libraries (outside 32bit limit)\n");
module_remove(pcs, elf_info.module);
pcs->loader = &empty_loader_ops;
return FALSE;
}
TRACE("Found ELF debug header %#I64x\n", elf_info.dbg_hdr_addr);

View file

@ -24,6 +24,8 @@
#include <string.h>
#include <assert.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "dbghelp_private.h"
#include "image_private.h"
#include "psapi.h"
@ -1317,7 +1319,11 @@ BOOL WINAPI EnumerateLoadedModulesW64(HANDLE process,
size_t sysdir_len = 0, wowdir_len = 0;
/* process might not be a handle to a live process */
if (!IsWow64Process2(process, &pcs_machine, &native_machine)) return FALSE;
if (!IsWow64Process2(process, &pcs_machine, &native_machine))
{
SetLastError(STATUS_INVALID_CID);
return FALSE;
}
with_32bit_modules = sizeof(void*) > sizeof(int) &&
pcs_machine != IMAGE_FILE_MACHINE_UNKNOWN &&
(dbghelp_options & SYMOPT_INCLUDE_32BIT_MODULES);
@ -1600,6 +1606,30 @@ void module_reset_debug_info(struct module* module)
module->sources = NULL;
}
static BOOL WINAPI process_invade_cb(PCWSTR name, ULONG64 base, ULONG size, PVOID user)
{
HANDLE hProcess = user;
/* Note: this follows native behavior:
* If a PE module has been unloaded from debuggee, it's not immediately removed
* from module list in dbghelp.
* Removal may eventually happen when loading a another module with SymLoadModule:
* if the module to be loaded overlaps an existing one, SymLoadModule will
* automatically unload the eldest one.
*/
SymLoadModuleExW(hProcess, 0, name, NULL, base, size, NULL, 0);
return TRUE;
}
BOOL module_refresh_list(struct process *pcs)
{
BOOL ret;
ret = pcs->loader->synchronize_module_list(pcs);
ret = EnumerateLoadedModulesW64(pcs->handle, process_invade_cb, pcs->handle) && ret;
return ret;
}
/******************************************************************
* SymRefreshModuleList (DBGHELP.@)
*/
@ -1610,8 +1640,7 @@ BOOL WINAPI SymRefreshModuleList(HANDLE hProcess)
TRACE("(%p)\n", hProcess);
if (!(pcs = process_find_by_handle(hProcess))) return FALSE;
return pcs->loader->synchronize_module_list(pcs);
return module_refresh_list(pcs);
}
/***********************************************************************

View file

@ -372,6 +372,29 @@ static unsigned get_native_module_count(HANDLE proc)
return count;
}
struct module_present
{
const WCHAR* module_name;
BOOL found;
};
static BOOL CALLBACK is_module_present_cb(const WCHAR* name, DWORD64 base, void* usr)
{
struct module_present* present = usr;
if (!wcsicmp(name, present->module_name))
{
present->found = TRUE;
return FALSE;
}
return TRUE;
}
static BOOL is_module_present(HANDLE proc, const WCHAR* module_name)
{
struct module_present present = { .module_name = module_name };
return SymEnumerateModulesW64(proc, is_module_present_cb, &present) && present.found;
}
struct nth_module
{
HANDLE proc;
@ -424,6 +447,28 @@ static BOOL wrapper_EnumerateLoadedModulesW64(HANDLE proc, PENUMLOADED_MODULES_C
return ret;
}
/* wrapper around SymRefreshModuleList which sometimes fails (it's very likely implemented on top
* of EnumerateLoadedModulesW64 on native too)
*/
static BOOL wrapper_SymRefreshModuleList(HANDLE proc)
{
BOOL ret;
int retry;
int retry_count = !strcmp(winetest_platform, "wine") ? 1 : 5;
for (retry = retry_count - 1; retry >= 0; retry--)
{
ret = SymRefreshModuleList(proc);
if (ret || (GetLastError() != STATUS_INFO_LENGTH_MISMATCH && GetLastError() == STATUS_PARTIAL_COPY))
break;
Sleep(10);
}
if (retry + 1 < retry_count)
trace("used wrapper retry: ret=%d retry=%d top=%d\n", ret, retry, retry_count);
return ret;
}
static BOOL test_modules(void)
{
BOOL ret;
@ -492,6 +537,7 @@ static BOOL test_modules(void)
ret = SymRefreshModuleList(dummy);
ok(!ret, "SymRefreshModuleList should have failed\n");
ok(GetLastError() == STATUS_INVALID_CID, "Unexpected last error %lx\n", GetLastError());
count = get_module_count(dummy);
ok(count == 0, "Unexpected count (%u instead of 0)\n", count);
@ -825,6 +871,11 @@ static void test_loaded_modules(void)
ok(ret, "got error %lu\n", GetLastError());
strcat(buffer, "\\msinfo32.exe");
/* testing invalid process handle */
ret = wrapper_EnumerateLoadedModulesW64((HANDLE)(ULONG_PTR)0xffffffc0, NULL, FALSE);
ok(!ret, "EnumerateLoadedModulesW64 should have failed\n");
ok(GetLastError() == STATUS_INVALID_CID, "Unexpected last error %lx\n", GetLastError());
/* testing with child process of different machines */
ret = CreateProcessA(NULL, buffer, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
ok(ret, "CreateProcess failed: %lu\n", GetLastError());
@ -885,9 +936,10 @@ static void test_loaded_modules(void)
pcskind = get_process_kind(pi.hProcess);
ret = SymRefreshModuleList(pi.hProcess);
todo_wine_if(pcskind == PCSKIND_WOW64)
ok(ret || broken(GetLastError() == STATUS_PARTIAL_COPY /* Win11 in some cases */), "SymRefreshModuleList failed: %lu\n", GetLastError());
ret = wrapper_SymRefreshModuleList(pi.hProcess);
ok(ret || broken(GetLastError() == STATUS_PARTIAL_COPY /* Win11 in some cases */ ||
GetLastError() == STATUS_INFO_LENGTH_MISMATCH /* Win11 in some cases */),
"SymRefreshModuleList failed: %lx\n", GetLastError());
if (!strcmp(winetest_platform, "wine"))
{
@ -945,8 +997,8 @@ static void test_loaded_modules(void)
"Wrong directory aggregation count %u %u\n",
aggregation.count_systemdir, aggregation.count_wowdir);
}
ret = SymRefreshModuleList(pi.hProcess);
ok(ret, "SymRefreshModuleList failed: %lu\n", GetLastError());
ret = wrapper_SymRefreshModuleList(pi.hProcess);
ok(ret, "SymRefreshModuleList failed: %lx\n", GetLastError());
if (!strcmp(winetest_platform, "wine"))
{
@ -1007,8 +1059,8 @@ static void test_loaded_modules(void)
break;
}
ret = SymRefreshModuleList(pi.hProcess);
ok(ret, "SymRefreshModuleList failed: %lu\n", GetLastError());
ret = wrapper_SymRefreshModuleList(pi.hProcess);
ok(ret, "SymRefreshModuleList failed: %lx\n", GetLastError());
if (!strcmp(winetest_platform, "wine"))
{
@ -1529,6 +1581,75 @@ static void test_function_tables(void)
SymCleanup(GetCurrentProcess());
}
static void test_refresh_modules(void)
{
BOOL ret;
unsigned count, count_current;
HMODULE hmod;
IMAGEHLP_MODULEW64 module_info = { .SizeOfStruct = sizeof(module_info) };
/* pick a DLL: which isn't already loaded by test, and that will not load other DLLs for deps */
static const WCHAR* unused_dll = L"psapi";
ret = SymInitialize(GetCurrentProcess(), 0, TRUE);
ok(ret, "SymInitialize failed: %lu\n", GetLastError());
count = get_module_count(GetCurrentProcess());
ok(count, "Unexpected module count %u\n", count);
ret = SymCleanup(GetCurrentProcess());
ok(ret, "SymCleanup failed: %lu\n", GetLastError());
ret = SymInitialize(GetCurrentProcess(), 0, FALSE);
ok(ret, "SymInitialize failed: %lu\n", GetLastError());
count_current = get_module_count(GetCurrentProcess());
ok(!count_current, "Unexpected module count %u\n", count_current);
ret = wrapper_SymRefreshModuleList(GetCurrentProcess());
ok(ret, "SymRefreshModuleList failed: %lx\n", GetLastError());
count_current = get_module_count(GetCurrentProcess());
ok(count == count_current, "Unexpected module count %u, %u\n", count, count_current);
hmod = GetModuleHandleW(unused_dll);
ok(hmod == NULL, "Expecting DLL %ls not be loaded\n", unused_dll);
hmod = LoadLibraryW(unused_dll);
ok(hmod != NULL, "LoadLibraryW failed: %lu\n", GetLastError());
count_current = get_module_count(GetCurrentProcess());
ok(count == count_current, "Unexpected module count %u, %u\n", count, count_current);
ret = is_module_present(GetCurrentProcess(), unused_dll);
ok(!ret, "Couldn't find module %ls\n", unused_dll);
ret = wrapper_SymRefreshModuleList(GetCurrentProcess());
ok(ret, "SymRefreshModuleList failed: %lx\n", GetLastError());
count_current = get_module_count(GetCurrentProcess());
ok(count + 1 == count_current, "Unexpected module count %u, %u\n", count, count_current);
ret = is_module_present(GetCurrentProcess(), unused_dll);
ok(ret, "Couldn't find module %ls\n", unused_dll);
ret = FreeLibrary(hmod);
ok(ret, "LoadLibraryW failed: %lu\n", GetLastError());
count_current = get_module_count(GetCurrentProcess());
ok(count + 1 == count_current, "Unexpected module count %u, %u\n", count, count_current);
ret = wrapper_SymRefreshModuleList(GetCurrentProcess());
ok(ret, "SymRefreshModuleList failed: %lx\n", GetLastError());
/* SymRefreshModuleList() doesn't remove the unloaded modules... */
count_current = get_module_count(GetCurrentProcess());
ok(count + 1 == count_current, "Unexpected module count %u != %u\n", count, count_current);
ret = is_module_present(GetCurrentProcess(), unused_dll);
ok(ret, "Couldn't find module %ls\n", unused_dll);
ret = SymCleanup(GetCurrentProcess());
ok(ret, "SymCleanup failed: %lu\n", GetLastError());
}
START_TEST(dbghelp)
{
BOOL ret;
@ -1559,6 +1680,7 @@ START_TEST(dbghelp)
test_modules_overlap();
test_loaded_modules();
test_live_modules();
test_refresh_modules();
}
test_function_tables();
}

View file

@ -275,10 +275,11 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void *
.serialnumber = {'0','0','0','0',0},
};
struct iohid_device *impl;
USAGE_AND_PAGE usages;
CFStringRef str;
desc.usages.UsagePage = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDPrimaryUsagePageKey)));
desc.usages.Usage = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDPrimaryUsageKey)));
usages.UsagePage = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDPrimaryUsagePageKey)));
usages.Usage = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDPrimaryUsageKey)));
desc.vid = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDVendorIDKey)));
desc.pid = CFNumberToDWORD(IOHIDDeviceGetProperty(IOHIDDevice, CFSTR(kIOHIDProductIDKey)));
@ -289,8 +290,8 @@ static void handle_DeviceMatchingCallback(void *context, IOReturn result, void *
desc.is_bluetooth = !CFStringCompare(str, CFSTR(kIOHIDTransportBluetoothValue), 0) ||
!CFStringCompare(str, CFSTR(kIOHIDTransportBluetoothLowEnergyValue), 0);
if (desc.usages.UsagePage != HID_USAGE_PAGE_GENERIC ||
!(desc.usages.Usage == HID_USAGE_GENERIC_JOYSTICK || desc.usages.Usage == HID_USAGE_GENERIC_GAMEPAD))
if (usages.UsagePage != HID_USAGE_PAGE_GENERIC ||
!(usages.Usage == HID_USAGE_GENERIC_JOYSTICK || usages.Usage == HID_USAGE_GENERIC_GAMEPAD))
{
/* winebus isn't currently meant to handle anything but these, and
* opening keyboards, mice, or the Touch Bar on older MacBooks triggers

View file

@ -198,7 +198,7 @@ static void set_hat_value(struct unix_device *iface, int index, int value)
hid_device_set_hatswitch_y(iface, index, y);
}
static BOOL descriptor_add_haptic(struct sdl_device *impl)
static BOOL descriptor_add_haptic(struct sdl_device *impl, BOOL force)
{
USHORT i, count = 0;
USAGE usages[16];
@ -227,16 +227,16 @@ static BOOL descriptor_add_haptic(struct sdl_device *impl)
if ((impl->effect_support & EFFECT_SUPPORT_PHYSICAL))
{
/* SDL_HAPTIC_SQUARE doesn't exist */
if (impl->effect_support & SDL_HAPTIC_SINE) usages[count++] = PID_USAGE_ET_SINE;
if (impl->effect_support & SDL_HAPTIC_TRIANGLE) usages[count++] = PID_USAGE_ET_TRIANGLE;
if (impl->effect_support & SDL_HAPTIC_SAWTOOTHUP) usages[count++] = PID_USAGE_ET_SAWTOOTH_UP;
if (impl->effect_support & SDL_HAPTIC_SAWTOOTHDOWN) usages[count++] = PID_USAGE_ET_SAWTOOTH_DOWN;
if (impl->effect_support & SDL_HAPTIC_SPRING) usages[count++] = PID_USAGE_ET_SPRING;
if (impl->effect_support & SDL_HAPTIC_DAMPER) usages[count++] = PID_USAGE_ET_DAMPER;
if (impl->effect_support & SDL_HAPTIC_INERTIA) usages[count++] = PID_USAGE_ET_INERTIA;
if (impl->effect_support & SDL_HAPTIC_FRICTION) usages[count++] = PID_USAGE_ET_FRICTION;
if (impl->effect_support & SDL_HAPTIC_CONSTANT) usages[count++] = PID_USAGE_ET_CONSTANT_FORCE;
if (impl->effect_support & SDL_HAPTIC_RAMP) usages[count++] = PID_USAGE_ET_RAMP;
if (force || (impl->effect_support & SDL_HAPTIC_SINE)) usages[count++] = PID_USAGE_ET_SINE;
if (force || (impl->effect_support & SDL_HAPTIC_TRIANGLE)) usages[count++] = PID_USAGE_ET_TRIANGLE;
if (force || (impl->effect_support & SDL_HAPTIC_SAWTOOTHUP)) usages[count++] = PID_USAGE_ET_SAWTOOTH_UP;
if (force || (impl->effect_support & SDL_HAPTIC_SAWTOOTHDOWN)) usages[count++] = PID_USAGE_ET_SAWTOOTH_DOWN;
if (force || (impl->effect_support & SDL_HAPTIC_SPRING)) usages[count++] = PID_USAGE_ET_SPRING;
if (force || (impl->effect_support & SDL_HAPTIC_DAMPER)) usages[count++] = PID_USAGE_ET_DAMPER;
if (force || (impl->effect_support & SDL_HAPTIC_INERTIA)) usages[count++] = PID_USAGE_ET_INERTIA;
if (force || (impl->effect_support & SDL_HAPTIC_FRICTION)) usages[count++] = PID_USAGE_ET_FRICTION;
if (force || (impl->effect_support & SDL_HAPTIC_CONSTANT)) usages[count++] = PID_USAGE_ET_CONSTANT_FORCE;
if (force || (impl->effect_support & SDL_HAPTIC_RAMP)) usages[count++] = PID_USAGE_ET_RAMP;
if (!hid_device_add_physical(&impl->unix_device, usages, count))
return FALSE;
@ -360,7 +360,7 @@ static NTSTATUS build_joystick_report_descriptor(struct unix_device *iface)
if (!hid_device_end_input_report(iface))
return STATUS_NO_MEMORY;
if (!descriptor_add_haptic(impl))
if (!descriptor_add_haptic(impl, physical_usage.Usage == HID_USAGE_SIMULATION_AUTOMOBILE_SIMULATION_DEVICE))
return STATUS_NO_MEMORY;
if (!hid_device_end_report_descriptor(iface))
@ -414,7 +414,7 @@ static NTSTATUS build_controller_report_descriptor(struct unix_device *iface)
if (!hid_device_end_input_report(iface))
return STATUS_NO_MEMORY;
if (!descriptor_add_haptic(impl))
if (!descriptor_add_haptic(impl, FALSE))
return STATUS_NO_MEMORY;
if (!hid_device_end_report_descriptor(iface))
@ -443,17 +443,12 @@ static void sdl_device_destroy(struct unix_device *iface)
static NTSTATUS sdl_device_start(struct unix_device *iface)
{
struct sdl_device *impl = impl_from_unix_device(iface);
NTSTATUS status;
pthread_mutex_lock(&sdl_cs);
if (impl->sdl_controller) status = build_controller_report_descriptor(iface);
else status = build_joystick_report_descriptor(iface);
impl->started = !status;
impl->started = TRUE;
pthread_mutex_unlock(&sdl_cs);
return status;
return STATUS_SUCCESS;
}
static void sdl_device_stop(struct unix_device *iface)
@ -595,7 +590,7 @@ static NTSTATUS sdl_device_physical_effect_control(struct unix_device *iface, BY
TRACE("iface %p, index %u, control %04x, iterations %u.\n", iface, index, control, iterations);
if (impl->effect_ids[index] < 0) return STATUS_UNSUCCESSFUL;
if (id < 0) return STATUS_SUCCESS;
switch (control)
{
@ -991,8 +986,6 @@ static void sdl_add_device(unsigned int index)
if (controller)
{
desc.is_gamepad = TRUE;
desc.usages.UsagePage = HID_USAGE_PAGE_GENERIC;
desc.usages.Usage = HID_USAGE_GENERIC_GAMEPAD;
axis_count = 6;
}
else
@ -1000,12 +993,12 @@ static void sdl_add_device(unsigned int index)
int button_count = pSDL_JoystickNumButtons(joystick);
axis_count = pSDL_JoystickNumAxes(joystick);
desc.is_gamepad = (axis_count == 6 && button_count >= 14);
desc.usages.UsagePage = HID_USAGE_PAGE_GENERIC;
desc.usages.Usage = HID_USAGE_GENERIC_JOYSTICK;
}
for (axis_offset = 0; axis_offset < axis_count; axis_offset += (options.split_controllers ? 6 : axis_count))
{
NTSTATUS status;
if (!axis_offset) strcpy(buffer, product);
else snprintf(buffer, ARRAY_SIZE(buffer), "%s %d", product, axis_offset / 6);
ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc.product, ARRAY_SIZE(desc.product));
@ -1019,6 +1012,15 @@ static void sdl_add_device(unsigned int index)
impl->id = id;
impl->axis_offset = axis_offset;
if (impl->sdl_controller) status = build_controller_report_descriptor(&impl->unix_device);
else status = build_joystick_report_descriptor(&impl->unix_device);
if (status)
{
list_remove(&impl->unix_device.entry);
impl->unix_device.vtbl->destroy(&impl->unix_device);
return;
}
bus_event_queue_device_created(&event_queue, &impl->unix_device, &desc);
}
}

View file

@ -728,12 +728,6 @@ static void lnxev_device_destroy(struct unix_device *iface)
static NTSTATUS lnxev_device_start(struct unix_device *iface)
{
struct lnxev_device *impl = lnxev_impl_from_unix_device(iface);
NTSTATUS status;
if ((status = build_report_descriptor(iface, impl->base.udev_device)))
return status;
pthread_mutex_lock(&udev_cs);
start_polling_device(iface);
pthread_mutex_unlock(&udev_cs);
@ -1254,7 +1248,6 @@ static void udev_add_device(struct udev_device *dev, int fd)
#ifdef HAS_PROPER_INPUT_HEADER
else if (!strcmp(subsystem, "input"))
{
const USAGE_AND_PAGE device_usage = *what_am_I(dev, fd);
static const WCHAR evdev[] = {'e','v','d','e','v',0};
struct input_id device_id = {0};
char buffer[MAX_PATH];
@ -1275,8 +1268,6 @@ static void udev_add_device(struct udev_device *dev, int fd)
if (!desc.serialnumber[0] && ioctl(fd, EVIOCGUNIQ(sizeof(buffer)), buffer) >= 0)
ntdll_umbstowcs(buffer, strlen(buffer) + 1, desc.serialnumber, ARRAY_SIZE(desc.serialnumber));
desc.usages = device_usage;
}
#endif
@ -1321,6 +1312,13 @@ static void udev_add_device(struct udev_device *dev, int fd)
strcpy(impl->devnode, devnode);
impl->device_fd = fd;
if (build_report_descriptor(&impl->unix_device, impl->udev_device))
{
list_remove(&impl->unix_device.entry);
impl->unix_device.vtbl->destroy(&impl->unix_device);
return;
}
bus_event_queue_device_created(&event_queue, &impl->unix_device, &desc);
}
#endif

View file

@ -417,7 +417,7 @@ static DWORD check_bus_option(const WCHAR *option, DWORD default_value)
return default_value;
}
static BOOL is_hidraw_enabled(WORD vid, WORD pid, const USAGE_AND_PAGE *usages)
static BOOL is_hidraw_enabled(WORD vid, WORD pid, const USAGE_AND_PAGE *usages, UINT buttons)
{
char buffer[FIELD_OFFSET(KEY_VALUE_PARTIAL_INFORMATION, Data[1024])];
KEY_VALUE_PARTIAL_INFORMATION *info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer;
@ -436,6 +436,48 @@ static BOOL is_hidraw_enabled(WORD vid, WORD pid, const USAGE_AND_PAGE *usages)
if (is_dualshock4_gamepad(vid, pid)) prefer_hidraw = TRUE;
if (is_dualsense_gamepad(vid, pid)) prefer_hidraw = TRUE;
switch (vid)
{
case 0x044f:
if (pid == 0xb679) prefer_hidraw = TRUE; /* ThrustMaster T-Rudder */
if (pid == 0xb687) prefer_hidraw = TRUE; /* ThrustMaster TWCS Throttle */
if (pid == 0xb10a) prefer_hidraw = TRUE; /* ThrustMaster T.16000M Joystick */
break;
case 0x16d0:
if (pid == 0x0d61) prefer_hidraw = TRUE; /* Simucube 2 Sport */
if (pid == 0x0d60) prefer_hidraw = TRUE; /* Simucube 2 Pro */
if (pid == 0x0d5f) prefer_hidraw = TRUE; /* Simucube 2 Ultimate */
if (pid == 0x0d5a) prefer_hidraw = TRUE; /* Simucube 1 */
break;
case 0x0eb7:
if (pid == 0x183b) prefer_hidraw = TRUE; /* Fanatec ClubSport Pedals v3 */
if (pid == 0x1839) prefer_hidraw = TRUE; /* Fanatec ClubSport Pedals v1/v2 */
break;
case 0x231d:
/* comes with 128 buttons in the default configuration */
if (buttons == 128) prefer_hidraw = TRUE;
/* if customized, less than 128 buttons may be shown, decide by PID */
if (pid == 0x0200) prefer_hidraw = TRUE; /* VKBsim Gladiator EVO Right Grip */
if (pid == 0x0201) prefer_hidraw = TRUE; /* VKBsim Gladiator EVO Left Grip */
if (pid == 0x0126) prefer_hidraw = TRUE; /* VKB-Sim Space Gunfighter */
if (pid == 0x0127) prefer_hidraw = TRUE; /* VKB-Sim Space Gunfighter L */
break;
case 0x3344:
/* comes with 31 buttons in the default configuration, or 128 max */
if ((buttons == 31) || (buttons == 128)) prefer_hidraw = TRUE;
/* users may have configured button limits, usually 32/50/64 */
if ((buttons == 32) || (buttons == 50) || (buttons == 64)) prefer_hidraw = TRUE;
/* if customized, arbitrary amount of buttons may be shown, decide by PID */
if (pid == 0x412f) prefer_hidraw = TRUE; /* Virpil Constellation ALPHA-R */
if (pid == 0x812c) prefer_hidraw = TRUE; /* Virpil Constellation ALPHA-L */
break;
case 0x03eb:
/* users may have configured button limits, usually 32/50/64 */
if ((buttons == 32) || (buttons == 50) || (buttons == 64)) prefer_hidraw = TRUE;
if (pid == 0x2055) prefer_hidraw = TRUE; /* ATMEL/VIRPIL/200325 VPC Throttle MT-50 CM2 */
break;
}
RtlInitUnicodeString(&str, L"EnableHidraw");
if (!NtQueryValueKey(driver_key, &str, KeyValuePartialInformation, info,
sizeof(buffer) - sizeof(WCHAR), &size))
@ -684,22 +726,41 @@ static NTSTATUS get_device_descriptors(UINT64 unix_device, BYTE **report_desc, U
return STATUS_SUCCESS;
}
static USAGE_AND_PAGE get_hidraw_device_usages(UINT64 unix_device)
static USAGE_AND_PAGE get_device_usages(UINT64 unix_device, UINT *buttons)
{
HIDP_DEVICE_DESC device_desc;
USAGE_AND_PAGE usages = {0};
UINT report_desc_length;
UINT i, count = 0, report_desc_length;
HIDP_BUTTON_CAPS *button_caps;
BYTE *report_desc;
NTSTATUS status;
HIDP_CAPS caps;
if (!(status = get_device_descriptors(unix_device, &report_desc, &report_desc_length, &device_desc)))
{
PHIDP_PREPARSED_DATA preparsed = device_desc.CollectionDesc[0].PreparsedData;
usages.UsagePage = device_desc.CollectionDesc[0].UsagePage;
usages.Usage = device_desc.CollectionDesc[0].Usage;
if ((status = HidP_GetCaps(preparsed, &caps)) == HIDP_STATUS_SUCCESS &&
(button_caps = malloc(sizeof(*button_caps) * caps.NumberInputButtonCaps)))
{
status = HidP_GetButtonCaps(HidP_Input, button_caps, &caps.NumberInputButtonCaps, preparsed);
if (status != HIDP_STATUS_SUCCESS) WARN("HidP_GetButtonCaps returned %#lx\n", status);
else for (i = 0; i < caps.NumberInputButtonCaps; i++)
{
if (button_caps[i].UsagePage != HID_USAGE_PAGE_BUTTON) continue;
if (button_caps[i].IsRange) count = max(count, button_caps[i].Range.UsageMax);
else count = max(count, button_caps[i].NotRange.Usage);
}
free(button_caps);
}
HidP_FreeCollectionDescription(&device_desc);
RtlFreeHeap(GetProcessHeap(), 0, report_desc);
}
*buttons = count;
return usages;
}
@ -749,18 +810,21 @@ static DWORD CALLBACK bus_main_thread(void *args)
case BUS_EVENT_TYPE_DEVICE_CREATED:
{
struct device_desc desc = event->device_created.desc;
if (desc.is_hidraw && !desc.usages.UsagePage) desc.usages = get_hidraw_device_usages(event->device);
if (!desc.is_hidraw != !is_hidraw_enabled(desc.vid, desc.pid, &desc.usages))
USAGE_AND_PAGE usages;
UINT buttons;
usages = get_device_usages(event->device, &buttons);
if (!desc.is_hidraw != !is_hidraw_enabled(desc.vid, desc.pid, &usages, buttons))
{
struct device_remove_params params = {.device = event->device};
WARN("ignoring %shidraw device %04x:%04x with usages %04x:%04x\n", desc.is_hidraw ? "" : "non-",
desc.vid, desc.pid, desc.usages.UsagePage, desc.usages.Usage);
desc.vid, desc.pid, usages.UsagePage, usages.Usage);
winebus_call(device_remove, &params);
break;
}
TRACE("creating %shidraw device %04x:%04x with usages %04x:%04x\n", desc.is_hidraw ? "" : "non-",
desc.vid, desc.pid, desc.usages.UsagePage, desc.usages.Usage);
desc.vid, desc.pid, usages.UsagePage, usages.Usage);
device = bus_create_hid_device(&event->device_created.desc, event->device);
if (device) IoInvalidateDeviceRelations(bus_pdo, BusRelations);

View file

@ -49,14 +49,6 @@ static void mouse_destroy(struct unix_device *iface)
static NTSTATUS mouse_start(struct unix_device *iface)
{
const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_MOUSE};
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_BUTTON, 1, 3))
return STATUS_NO_MEMORY;
if (!hid_device_end_report_descriptor(iface))
return STATUS_NO_MEMORY;
return STATUS_SUCCESS;
}
@ -123,9 +115,21 @@ static const struct device_desc mouse_device_desc =
static NTSTATUS mouse_device_create(void *args)
{
const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_MOUSE};
struct device_create_params *params = args;
struct unix_device *iface;
if (!(iface = hid_device_create(&mouse_vtbl, sizeof(struct mouse_device))))
return STATUS_NO_MEMORY;
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_BUTTON, 1, 3))
return STATUS_NO_MEMORY;
if (!hid_device_end_report_descriptor(iface))
return STATUS_NO_MEMORY;
params->desc = mouse_device_desc;
params->device = (UINT_PTR)hid_device_create(&mouse_vtbl, sizeof(struct mouse_device));
params->device = (UINT_PTR)iface;
return STATUS_SUCCESS;
}
@ -140,14 +144,6 @@ static void keyboard_destroy(struct unix_device *iface)
static NTSTATUS keyboard_start(struct unix_device *iface)
{
const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_KEYBOARD};
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_KEYBOARD, 0, 101))
return STATUS_NO_MEMORY;
if (!hid_device_end_report_descriptor(iface))
return STATUS_NO_MEMORY;
return STATUS_SUCCESS;
}
@ -214,9 +210,21 @@ static const struct device_desc keyboard_device_desc =
static NTSTATUS keyboard_device_create(void *args)
{
const USAGE_AND_PAGE device_usage = {.UsagePage = HID_USAGE_PAGE_GENERIC, .Usage = HID_USAGE_GENERIC_KEYBOARD};
struct device_create_params *params = args;
struct unix_device *iface;
if (!(iface = hid_device_create(&keyboard_vtbl, sizeof(struct keyboard_device))))
return STATUS_NO_MEMORY;
if (!hid_device_begin_report_descriptor(iface, &device_usage))
return STATUS_NO_MEMORY;
if (!hid_device_add_buttons(iface, HID_USAGE_PAGE_KEYBOARD, 0, 101))
return STATUS_NO_MEMORY;
if (!hid_device_end_report_descriptor(iface))
return STATUS_NO_MEMORY;
params->desc = keyboard_device_desc;
params->device = (UINT_PTR)hid_device_create(&keyboard_vtbl, sizeof(struct keyboard_device));
params->device = (UINT_PTR)iface;
return STATUS_SUCCESS;
}

View file

@ -38,7 +38,6 @@ struct device_desc
UINT version;
UINT input;
UINT uid;
USAGE_AND_PAGE usages;
BOOL is_gamepad;
BOOL is_hidraw;
BOOL is_bluetooth;
@ -151,8 +150,8 @@ enum unix_funcs
static inline const char *debugstr_device_desc(struct device_desc *desc)
{
if (!desc) return "(null)";
return wine_dbg_sprintf("{vid %04x, pid %04x, version %04x, input %d, uid %08x, usage %04x:%04x, is_gamepad %u, is_hidraw %u, is_bluetooth %u}",
desc->vid, desc->pid, desc->version, desc->input, desc->uid, desc->usages.UsagePage, desc->usages.Usage,
return wine_dbg_sprintf("{vid %04x, pid %04x, version %04x, input %d, uid %08x, is_gamepad %u, is_hidraw %u, is_bluetooth %u}",
desc->vid, desc->pid, desc->version, desc->input, desc->uid,
desc->is_gamepad, desc->is_hidraw, desc->is_bluetooth);
}

View file

@ -1240,3 +1240,211 @@ HRESULT WINAPI RoResolveNamespace(HSTRING name, HSTRING windowsMetaDataDir,
return RO_E_METADATA_NAME_NOT_FOUND;
}
struct parse_type_context
{
DWORD allocated_parts_count;
DWORD parts_count;
HSTRING *parts;
};
static HRESULT add_part(struct parse_type_context *context, const WCHAR *part, size_t length)
{
DWORD new_parts_count;
HSTRING *new_parts;
HRESULT hr;
if (context->parts_count == context->allocated_parts_count)
{
new_parts_count = context->allocated_parts_count ? context->allocated_parts_count * 2 : 4;
new_parts = CoTaskMemRealloc(context->parts, new_parts_count * sizeof(*context->parts));
if (!new_parts)
return E_OUTOFMEMORY;
context->allocated_parts_count = new_parts_count;
context->parts = new_parts;
}
if (FAILED(hr = WindowsCreateString(part, length, &context->parts[context->parts_count])))
return hr;
context->parts_count++;
return S_OK;
}
static HRESULT parse_part(struct parse_type_context *context, const WCHAR *input, unsigned int length)
{
const WCHAR *start, *end, *ptr;
start = input;
end = start + length;
/* Remove leading spaces */
while (start < end && *start == ' ')
start++;
/* Remove trailing spaces */
while (end - 1 >= start && end[-1] == ' ')
end--;
/* Only contains spaces */
if (start == end)
return RO_E_METADATA_INVALID_TYPE_FORMAT;
/* Has spaces in the middle */
for (ptr = start; ptr < end; ptr++)
{
if (*ptr == ' ')
return RO_E_METADATA_INVALID_TYPE_FORMAT;
}
return add_part(context, start, end - start);
}
static HRESULT parse_type(struct parse_type_context *context, const WCHAR *input, unsigned int length)
{
unsigned int i, parameter_count, nested_level;
const WCHAR *start, *end, *part_start, *ptr;
HRESULT hr;
start = input;
end = start + length;
part_start = start;
ptr = start;
/* Read until the end of input or '`' or '<' or '>' or ',' */
while (ptr < end && *ptr != '`' && *ptr != '<' && *ptr != '>' && *ptr != ',')
ptr++;
/* If the type name has '`' and there are characters before '`' */
if (ptr > start && ptr < end && *ptr == '`')
{
/* Move past the '`' */
ptr++;
/* Read the number of type parameters, expecting '1' to '9' */
if (!(ptr < end && *ptr >= '1' && *ptr <= '9'))
return RO_E_METADATA_INVALID_TYPE_FORMAT;
parameter_count = *ptr - '0';
/* Move past the number of type parameters, expecting '<' */
ptr++;
if (!(ptr < end && *ptr == '<'))
return RO_E_METADATA_INVALID_TYPE_FORMAT;
/* Add the name of parameterized interface, e.g., the "interface`1" in "interface`1<parameter>" */
if (FAILED(hr = parse_part(context, part_start, ptr - part_start)))
return hr;
/* Move past the '<' */
ptr++;
nested_level = 1;
/* Read parameters inside brackets, e.g., the "p1" and "p2" in "interface`2<p1, p2>" */
for (i = 0; i < parameter_count; i++)
{
/* Read a new parameter */
part_start = ptr;
/* Read until ','. The comma must be at the same nested bracket level */
while (ptr < end)
{
if (*ptr == '<')
{
nested_level++;
ptr++;
}
else if (*ptr == '>')
{
/* The last parameter before '>' */
if (i == parameter_count - 1 && nested_level == 1)
{
if (FAILED(hr = parse_type(context, part_start, ptr - part_start)))
return hr;
nested_level--;
ptr++;
/* Finish reading all parameters */
break;
}
nested_level--;
ptr++;
}
else if (*ptr == ',' && nested_level == 1)
{
/* Parse the parameter, which can be another parameterized type */
if (FAILED(hr = parse_type(context, part_start, ptr - part_start)))
return hr;
/* Move past the ',' */
ptr++;
/* Finish reading one parameter */
break;
}
else
{
ptr++;
}
}
}
/* Mismatching brackets or not enough parameters */
if (nested_level != 0 || i != parameter_count)
return RO_E_METADATA_INVALID_TYPE_FORMAT;
/* The remaining characters must be spaces */
while (ptr < end)
{
if (*ptr++ != ' ')
return RO_E_METADATA_INVALID_TYPE_FORMAT;
}
return S_OK;
}
/* Contain invalid '`', '<', '>' or ',' */
else if (ptr != end)
{
return RO_E_METADATA_INVALID_TYPE_FORMAT;
}
/* Non-parameterized */
else
{
return parse_part(context, part_start, ptr - part_start);
}
}
HRESULT WINAPI RoParseTypeName(HSTRING type_name, DWORD *parts_count, HSTRING **parts)
{
struct parse_type_context context = {0};
const WCHAR *input;
unsigned int i;
HRESULT hr;
TRACE("%s %p %p.\n", debugstr_hstring(type_name), parts_count, parts);
/* Empty string */
if (!WindowsGetStringLen(type_name))
return E_INVALIDARG;
input = WindowsGetStringRawBuffer(type_name, NULL);
/* The string has a leading space */
if (input[0] == ' ')
return RO_E_METADATA_INVALID_TYPE_FORMAT;
*parts_count = 0;
*parts = NULL;
if (FAILED(hr = parse_type(&context, input, wcslen(input))))
{
for (i = 0; i < context.parts_count; i++)
WindowsDeleteString(context.parts[i]);
CoTaskMemFree(context.parts);
return hr;
}
*parts_count = context.parts_count;
*parts = context.parts;
return S_OK;
}

View file

@ -814,11 +814,159 @@ static void test_RoResolveNamespace(void)
RoUninitialize();
}
static void test_RoParseTypeName(void)
{
static const struct
{
const WCHAR *type_name;
HRESULT hr;
DWORD parts_count;
const WCHAR *parts[16];
}
tests[] =
{
/* Invalid type names */
{L"", E_INVALIDARG},
{L" ", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"`", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"<", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L">", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L",", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"<>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"`<>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a b", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a,b", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"1<>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L" a", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L" a ", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a<", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a<>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`<>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`1<>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a<b>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`<b> ", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"`1<b>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L" a`1<b>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`1<b>c", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`1<b,>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`2<b, <c, d>>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`10<b1, b2, b3, b4, b5, b6, b7, b8, b9, b10>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`0xa<b1, b2, b3, b4, b5, b6, b7, b8, b9, b10>", RO_E_METADATA_INVALID_TYPE_FORMAT},
{L"a`a<b1, b2, b3, b4, b5, b6, b7, b8, b9, b10>", RO_E_METADATA_INVALID_TYPE_FORMAT},
/* Valid type names */
{L"1", S_OK, 1, {L"1"}},
{L"a", S_OK, 1, {L"a"}},
{L"-", S_OK, 1, {L"-"}},
{L"a ", S_OK, 1, {L"a"}},
{L"0`1<b>", S_OK, 2, {L"0`1", L"b"}},
{L"a`1<b>", S_OK, 2, {L"a`1", L"b"}},
{L"a`1<b> ", S_OK, 2, {L"a`1", L"b"}},
{L"a`1<b >", S_OK, 2, {L"a`1", L"b"}},
{L"a`1< b>", S_OK, 2, {L"a`1", L"b"}},
{L"a`1< b >", S_OK, 2, {L"a`1", L"b"}},
{L"a`2<b,c>", S_OK, 3, {L"a`2", L"b", L"c"}},
{L"a`2<b, c>", S_OK, 3, {L"a`2", L"b", L"c"}},
{L"a`2<b ,c>", S_OK, 3, {L"a`2", L"b", L"c"}},
{L"a`2<b , c>", S_OK, 3, {L"a`2", L"b", L"c"}},
{L"a`3<b, c, d>", S_OK, 4, {L"a`3", L"b", L"c", L"d"}},
{L"a`1<b`1<c>>", S_OK, 3, {L"a`1", L"b`1", L"c"}},
{L"a`1<b`2<c, d>>", S_OK, 4, {L"a`1", L"b`2", L"c", L"d"}},
{L"a`2<b`2<c, d>, e>", S_OK, 5, {L"a`2", L"b`2", L"c", L"d", L"e"}},
{L"a`2<b, c`2<d, e>>", S_OK, 5, {L"a`2", L"b", L"c`2", L"d", L"e"}},
{L"a`9<b1, b2, b3, b4, b5, b6, b7, b8, b9>", S_OK, 10, {L"a`9", L"b1", L"b2", L"b3", L"b4", L"b5", L"b6", L"b7", L"b8", L"b9"}},
{L"Windows.Foundation.IExtensionInformation", S_OK, 1, {L"Windows.Foundation.IExtensionInformation"}},
{L"Windows.Foundation.IReference`1<Windows.UI.Color>", S_OK, 2, {L"Windows.Foundation.IReference`1", L"Windows.UI.Color"}},
{L"Windows.Foundation.Collections.IIterator`1<Windows.Foundation.Collections.IMapView`2<Windows.Foundation.Collections.IVector`1<String>, String>>",
S_OK, 5, {L"Windows.Foundation.Collections.IIterator`1",
L"Windows.Foundation.Collections.IMapView`2",
L"Windows.Foundation.Collections.IVector`1",
L"String",
L"String"}},
};
HSTRING type_name, *parts;
const WCHAR *buffer;
DWORD parts_count;
unsigned int i, j;
HRESULT hr;
/* Parameter checks */
hr = WindowsCreateString(L"a", 1, &type_name);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
hr = RoParseTypeName(NULL, &parts_count, &parts);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
/* Crash on Windows */
if (0)
{
hr = RoParseTypeName(type_name, NULL, &parts);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
hr = RoParseTypeName(type_name, &parts_count, NULL);
ok(hr == E_INVALIDARG, "Got unexpected hr %#lx.\n", hr);
}
hr = RoParseTypeName(type_name, &parts_count, &parts);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
ok(parts_count == 1, "Got unexpected %ld.\n", parts_count);
hr = WindowsDeleteString(parts[0]);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
CoTaskMemFree(parts);
hr = WindowsDeleteString(type_name);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
/* Parsing checks */
for (i = 0; i < ARRAY_SIZE(tests); i++)
{
winetest_push_context("%s", wine_dbgstr_w(tests[i].type_name));
if (tests[i].type_name)
{
hr = WindowsCreateString(tests[i].type_name, wcslen(tests[i].type_name), &type_name);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
}
else
{
type_name = NULL;
}
parts_count = 0;
hr = RoParseTypeName(type_name, &parts_count, &parts);
ok(hr == tests[i].hr, "Got unexpected hr %#lx.\n", hr);
if (FAILED(hr))
{
hr = WindowsDeleteString(type_name);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
winetest_pop_context();
continue;
}
ok(parts_count == tests[i].parts_count, "Got unexpected %lu.\n", parts_count);
for (j = 0; j < parts_count; j++)
{
winetest_push_context("%s", wine_dbgstr_w(tests[i].parts[j]));
buffer = WindowsGetStringRawBuffer(parts[j], NULL);
ok(!lstrcmpW(tests[i].parts[j], buffer), "Got unexpected %s.\n", wine_dbgstr_w(buffer));
hr = WindowsDeleteString(parts[j]);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
winetest_pop_context();
}
CoTaskMemFree(parts);
hr = WindowsDeleteString(type_name);
ok(hr == S_OK, "Got unexpected hr %#lx.\n", hr);
winetest_pop_context();
}
}
START_TEST(wintypes)
{
IsWow64Process(GetCurrentProcess(), &is_wow64);
test_IApiInformationStatics();
test_IPropertyValueStatics();
test_RoParseTypeName();
test_RoResolveNamespace();
}

View file

@ -7,5 +7,5 @@
@ stub RoGetMetaDataFile
@ stdcall RoIsApiContractMajorVersionPresent(wstr long ptr)
@ stub RoIsApiContractPresent
@ stub RoParseTypeName
@ stdcall RoParseTypeName(ptr ptr ptr)
@ stdcall RoResolveNamespace(ptr ptr long ptr ptr ptr ptr ptr)

View file

@ -23,6 +23,7 @@
#include <hstring.h>
HRESULT WINAPI RoIsApiContractMajorVersionPresent(const WCHAR *, UINT16, BOOL *);
HRESULT WINAPI RoParseTypeName(HSTRING, DWORD *, HSTRING **);
HRESULT WINAPI RoResolveNamespace(HSTRING, HSTRING, DWORD, const HSTRING *, DWORD *, HSTRING **, DWORD *, HSTRING **);
#endif /* _ROMETADATARESOLUTION_H */