@ stub SdbFreeFileInfo
@ stub SdbFreeFlagInfo
@ stub SdbGetAppCompatDataSize
-@ stub SdbGetAppPatchDir
+@ stdcall SdbGetAppPatchDir(ptr wstr long)
@ stdcall SdbGetBinaryTagData(ptr long)
@ stdcall SdbGetDatabaseID(ptr ptr)
@ stub SdbGetDatabaseInformation
SdbFree(db);
}
+/**
+ * Retrieves AppPatch directory.
+ *
+ * @param [in] db Handle to the shim database.
+ * @param [out] path Pointer to memory in which path shall be written.
+ * @param [in] size Size of the buffer in characters.
+ */
+BOOL WINAPI SdbGetAppPatchDir(HSDB db, LPWSTR path, DWORD size)
+{
+ static WCHAR* default_dir = NULL;
+
+ if(!default_dir)
+ {
+ WCHAR* tmp = NULL;
+ UINT len = GetSystemWindowsDirectoryW(NULL, 0) + lstrlenW((CONST WCHAR[]){'\\','A','p','p','P','a','t','c','h',0});
+ tmp = SdbAlloc((len + 1)* sizeof(WCHAR));
+ if(tmp)
+ {
+ UINT r = GetSystemWindowsDirectoryW(tmp, len+1);
+ if (r && r < len)
+ {
+ if (SUCCEEDED(StringCchCatW(tmp, len+1, (CONST WCHAR[]){'\\','A','p','p','P','a','t','c','h',0})))
+ {
+ if(InterlockedCompareExchangePointer((void**)&default_dir, tmp, NULL) == NULL)
+ tmp = NULL;
+ }
+ }
+ if (tmp)
+ SdbFree(tmp);
+ }
+ }
+
+ /* In case function fails, path holds empty string */
+ if (size > 0)
+ *path = 0;
+
+ if (!db)
+ {
+ return SUCCEEDED(StringCchCopyW(path, size, default_dir));
+ }
+ else
+ {
+ /* fixme */
+ return FALSE;
+ }
+}
+
/**
* Parses a string to retrieve a GUID.
*