Signed-off-by: Gijs Vermeulen <gijsvrm@gmail.com>
---
������dlls/avrt/avrt.spec |������ 4 +--
������dlls/avrt/main.c������ ������ | 86 ++++++++++++++++++++++++++++++++++++---------
������include/avrt.h������ ������ ������ |������ 2 +-
������3 files changed, 72 insertions(+), 20 deletions(-)
diff --git a/dlls/avrt/avrt.spec b/dlls/avrt/avrt.spec
index a7dfc42879c..0a05abcdbca 100644
--- a/dlls/avrt/avrt.spec
+++ b/dlls/avrt/avrt.spec
@@ -7,8 +7,8 @@
������@ stub AvRtJoinThreadOrderingGroup
������@ stub AvRtLeaveThreadOrderingGroup
������@ stub AvRtWaitOnThreadOrderingGroup
-@ stub AvSetMmMaxThreadCharacteristicsA
-@ stub AvSetMmMaxThreadCharacteristicsW
+@ stdcall AvSetMmMaxThreadCharacteristicsA(str str ptr)
+@ stdcall AvSetMmMaxThreadCharacteristicsW(wstr wstr ptr)
������@ stdcall AvSetMmThreadCharacteristicsA(str ptr)
������@ stdcall AvSetMmThreadCharacteristicsW(wstr ptr)
������@ stdcall AvSetMmThreadPriority(ptr long)
diff --git a/dlls/avrt/main.c b/dlls/avrt/main.c
index eb5704cc508..258c525e198 100644
--- a/dlls/avrt/main.c
+++ b/dlls/avrt/main.c
@@ -23,10 +23,21 @@
������#include "winbase.h"
������#include "winnls.h"
������#include "wine/debug.h"
+#include "wine/heap.h"
������#include "avrt.h"
������WINE_DEFAULT_DEBUG_CHANNEL(avrt);
+static inline WCHAR *heap_strdupAW(const char *src)
+{
+������ ������ int len;
+������ ������ WCHAR *dst;
+������ ������ if (!src) return NULL;
+������ ������ len = MultiByteToWideChar(CP_ACP, 0, src, -1, NULL, 0);
+������ ������ if ((dst = heap_alloc(len * sizeof(*dst)))) MultiByteToWideChar(CP_ACP, 0, src, -1, dst, len);
+������ ������ return dst;
+}
+
������BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
������{
������ ������ ������TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
@@ -43,41 +54,39 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
������ ������ ������return TRUE;
������}
-HANDLE WINAPI AvSetMmThreadCharacteristicsA(LPCSTR TaskName, LPDWORD TaskIndex)
+HANDLE WINAPI AvSetMmThreadCharacteristicsA(const char *name, DWORD *index)
������{
+������ ������ WCHAR *nameW = NULL;
������ ������ ������HANDLE ret;
-������ ������ LPWSTR str = NULL;
-������ ������ if (TaskName)
+������ ������ if (name && !(nameW = heap_strdupAW(name)))
������ ������ ������{
-������ ������ ������ ������ DWORD len = (lstrlenA(TaskName)+1);
-������ ������ ������ ������ str = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
-������ ������ ������ ������ if (!str)
-������ ������ ������ ������ {
-������ ������ ������ ������ ������ ������ SetLastError(ERROR_OUTOFMEMORY);
-������ ������ ������ ������ ������ ������ return NULL;
-������ ������ ������ ������ }
-������ ������ ������ ������ MultiByteToWideChar(CP_ACP, 0, TaskName, len, str, len);
+������ ������ ������ ������ SetLastError(ERROR_OUTOFMEMORY);
+������ ������ ������ ������ return NULL;
������ ������ ������}
-������ ������ ret = AvSetMmThreadCharacteristicsW(str, TaskIndex);
-������ ������ HeapFree(GetProcessHeap(), 0, str);
+
+������ ������ ret = AvSetMmThreadCharacteristicsW(nameW, index);
+
+������ ������ heap_free(nameW);
������ ������ ������return ret;
������}
-HANDLE WINAPI AvSetMmThreadCharacteristicsW(LPCWSTR TaskName, LPDWORD TaskIndex)
+HANDLE WINAPI AvSetMmThreadCharacteristicsW(const WCHAR *name, DWORD *index)
������{
-������ ������ FIXME("(%s,%p): stub\n", debugstr_w(TaskName), TaskIndex);
+������ ������ FIXME("(%s,%p): stub\n", debugstr_w(name), index);
-������ ������ if (!TaskName)
+������ ������ if (!name)
������ ������ ������{
������ ������ ������ ������ ������SetLastError(ERROR_INVALID_TASK_NAME);
������ ������ ������ ������ ������return NULL;
������ ������ ������}
-������ ������ if (!TaskIndex)
+
+������ ������ if (!index)
������ ������ ������{
������ ������ ������ ������ ������SetLastError(ERROR_INVALID_HANDLE);
������ ������ ������ ������ ������return NULL;
������ ������ ������}
+
������ ������ ������return (HANDLE)0x12345678;
������}
@@ -98,3 +107,46 @@ BOOL WINAPI AvSetMmThreadPriority(HANDLE AvrtHandle, AVRT_PRIORITY prio)
������ ������ ������FIXME("(%p)->(%u) stub\n", AvrtHandle, prio);
������ ������ ������return TRUE;
������}
+
+HANDLE WINAPI AvSetMmMaxThreadCharacteristicsA(const char *task1, const char *task2, DWORD *index)
+{
+������ ������ WCHAR *task1W = NULL, *task2W = NULL;
+������ ������ HANDLE ret;
+
+������ ������ if (task1 && !(task1W = heap_strdupAW(task1)))
+������ ������ {
+������ ������ ������ ������ SetLastError(ERROR_OUTOFMEMORY);
+������ ������ ������ ������ return NULL;
+������ ������ }
+
+������ ������ if (task2 && !(task2W = heap_strdupAW(task2)))
+������ ������ {
+������ ������ ������ ������ SetLastError(ERROR_OUTOFMEMORY);
+������ ������ ������ ������ return NULL;
+������ ������ }
+
+������ ������ ret = AvSetMmMaxThreadCharacteristicsW(task1W, task2W, index);
+
+������ ������ heap_free(task2W);
+������ ������ heap_free(task1W);
+������ ������ return ret;
+}
+
+HANDLE WINAPI AvSetMmMaxThreadCharacteristicsW(const WCHAR *task1, const WCHAR *task2, DWORD *index)
+{
+������ ������ FIXME("(%s,%s,%p): stub\n", debugstr_w(task1), debugstr_w(task2), index);
+
+������ ������ if (!task1 || task2)
+������ ������ {
+������ ������ ������ ������ SetLastError(ERROR_INVALID_TASK_NAME);
+������ ������ ������ ������ return NULL;
+������ ������ }
+
+������ ������ if (!index)
+������ ������ {
+������ ������ ������ ������ SetLastError(ERROR_INVALID_HANDLE);
+������ ������ ������ ������ return NULL;
+������ ������ }
+
+������ ������ return (HANDLE)0x12345678;
+}
diff --git a/include/avrt.h b/include/avrt.h
index 9d12c1b5b1b..88beebb0bf8 100644
--- a/include/avrt.h
+++ b/include/avrt.h
@@ -43,7 +43,7 @@ HANDLE WINAPI AvSetMmThreadCharacteristicsW(LPCWSTR TaskName, LPDWORD TaskIndex)
������#define AvSetMmThreadCharacteristics WINELIB_NAME_AW(AvSetMmThreadCharacteristics)
������HANDLE WINAPI AvSetMmMaxThreadCharacteristicsA(LPCSTR FirstTask, LPCSTR SecondTask, LPDWORD TaskIndex);
-HANDLE WINAPI AvSetMmMaxThreadCharacteristicsW(LPCSTR FirstTask, LPCSTR SecondTask, LPDWORD TaskIndex);
+HANDLE WINAPI AvSetMmMaxThreadCharacteristicsW(LPCWSTR FirstTask, LPCWSTR SecondTask, LPDWORD TaskIndex);
������#define AvSetMmMaxThreadCharacteristics WINELIB_NAME_AW(AvSetMmMaxThreadCharacteristics)
������BOOL WINAPI AvRevertMmThreadCharacteristics(HANDLE AvrtHandle);
--
2.29.2