diff --git a/configure b/configure index e6fa900a9ff..8f9243773b0 100755 --- a/configure +++ b/configure @@ -14664,7 +14664,7 @@ wine_fn_config_test dlls/pdh/tests pdh_test wine_fn_config_dll pidgen enable_pidgen wine_fn_config_dll powrprof enable_powrprof powrprof wine_fn_config_dll printui enable_printui -wine_fn_config_dll propsys enable_propsys +wine_fn_config_dll propsys enable_propsys propsys wine_fn_config_dll psapi enable_psapi psapi wine_fn_config_test dlls/psapi/tests psapi_test wine_fn_config_dll pstorec enable_pstorec diff --git a/configure.ac b/configure.ac index 68c151fdbe2..0180928c0d7 100644 --- a/configure.ac +++ b/configure.ac @@ -2533,7 +2533,7 @@ WINE_CONFIG_TEST(dlls/pdh/tests) WINE_CONFIG_DLL(pidgen) WINE_CONFIG_DLL(powrprof,,[powrprof]) WINE_CONFIG_DLL(printui) -WINE_CONFIG_DLL(propsys) +WINE_CONFIG_DLL(propsys,,[propsys]) WINE_CONFIG_DLL(psapi,,[psapi]) WINE_CONFIG_TEST(dlls/psapi/tests) WINE_CONFIG_DLL(pstorec) diff --git a/dlls/propsys/Makefile.in b/dlls/propsys/Makefile.in index 4170751f495..e217ac4329c 100644 --- a/dlls/propsys/Makefile.in +++ b/dlls/propsys/Makefile.in @@ -3,6 +3,7 @@ TOPOBJDIR = ../.. SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = propsys.dll +IMPORTLIB = propsys C_SRCS = \ propsys_main.c \ diff --git a/dlls/propsys/propsys.spec b/dlls/propsys/propsys.spec index 1848b47c130..cd41d903c7f 100644 --- a/dlls/propsys/propsys.spec +++ b/dlls/propsys/propsys.spec @@ -91,7 +91,7 @@ @ stub PSRefreshPropertySchema @ stdcall PSRegisterPropertySchema(wstr) @ stub PSSetPropertyValue -@ stub PSStringFromPropertyKey +@ stdcall PSStringFromPropertyKey(ptr ptr long) @ stdcall PSUnregisterPropertySchema(wstr) @ stdcall PropVariantChangeType(ptr ptr long long) @ stub PropVariantCompareEx diff --git a/dlls/propsys/propsys_main.c b/dlls/propsys/propsys_main.c index cdda06df1f7..cd180fe0993 100644 --- a/dlls/propsys/propsys_main.c +++ b/dlls/propsys/propsys_main.c @@ -24,7 +24,10 @@ #include "windef.h" #include "winbase.h" +#include "objbase.h" +#include "propsys.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(propsys); @@ -61,3 +64,69 @@ HRESULT WINAPI PSUnregisterPropertySchema(PCWSTR path) return E_NOTIMPL; } + +HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY pkey, LPWSTR psz, UINT cch) +{ + static const WCHAR guid_fmtW[] = {'{','%','0','8','X','-','%','0','4','X','-', + '%','0','4','X','-','%','0','2','X','%','0','2','X','-', + '%','0','2','X','%','0','2','X','%','0','2','X', + '%','0','2','X','%','0','2','X','%','0','2','X','}',0}; + static const WCHAR pid_fmtW[] = {'%','u',0}; + + WCHAR pidW[PKEY_PIDSTR_MAX + 1]; + LPWSTR p = psz; + int len; + + TRACE("(%p, %p, %u)\n", pkey, psz, cch); + + if (!psz) + return E_POINTER; + + /* GUIDSTRING_MAX accounts for null terminator, +1 for space character. */ + if (cch <= GUIDSTRING_MAX + 1) + return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + + if (!pkey) + { + psz[0] = '\0'; + return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } + + sprintfW(psz, guid_fmtW, pkey->fmtid.Data1, pkey->fmtid.Data2, + pkey->fmtid.Data3, pkey->fmtid.Data4[0], pkey->fmtid.Data4[1], + pkey->fmtid.Data4[2], pkey->fmtid.Data4[3], pkey->fmtid.Data4[4], + pkey->fmtid.Data4[5], pkey->fmtid.Data4[6], pkey->fmtid.Data4[7]); + + /* Overwrite the null terminator with the space character. */ + p += GUIDSTRING_MAX - 1; + *p++ = ' '; + cch -= GUIDSTRING_MAX - 1 + 1; + + len = sprintfW(pidW, pid_fmtW, pkey->pid); + + if (cch >= len + 1) + { + strcpyW(p, pidW); + return S_OK; + } + else + { + WCHAR *ptr = pidW + len - 1; + + psz[0] = '\0'; + *p++ = '\0'; + cch--; + + /* Replicate a quirk of the native implementation where the contents + * of the property ID string are written backwards to the output + * buffer, skipping the rightmost digit. */ + if (cch) + { + ptr--; + while (cch--) + *p++ = *ptr--; + } + + return HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER); + } +} diff --git a/include/propsys.idl b/include/propsys.idl index cc5770e13cb..c098041d292 100644 --- a/include/propsys.idl +++ b/include/propsys.idl @@ -795,6 +795,12 @@ interface ICreateObject : IUnknown ); } +cpp_quote("#define PKEY_PIDSTR_MAX 10") +cpp_quote("#define GUIDSTRING_MAX 39") +cpp_quote("#define PKEYSTR_MAX (GUIDSTRING_MAX + 1 + PKEY_PIDSTR_MAX)") + +cpp_quote("HRESULT WINAPI PSStringFromPropertyKey(REFPROPERTYKEY,LPWSTR,UINT);") + /* TODO: Add remainder of the C api here */ [