Author: mjansen
Date: Mon Jun 19 16:37:47 2017
New Revision: 75135
URL:
http://svn.reactos.org/svn/reactos?rev=75135&view=rev
Log:
[APPHELP] Implement Sdb[Un]packAppCompatData and SdbGetAppCompatDataSize. CORE-13284
Modified:
trunk/reactos/dll/appcompat/apphelp/apphelp.spec
trunk/reactos/dll/appcompat/apphelp/hsdb.c
Modified: trunk/reactos/dll/appcompat/apphelp/apphelp.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/apph…
==============================================================================
--- trunk/reactos/dll/appcompat/apphelp/apphelp.spec [iso-8859-1] (original)
+++ trunk/reactos/dll/appcompat/apphelp/apphelp.spec [iso-8859-1] Mon Jun 19 16:37:47
2017
@@ -51,7 +51,7 @@
@ stdcall SdbFreeFileAttributes(ptr)
@ stub SdbFreeFileInfo
@ stub SdbFreeFlagInfo
-@ stub SdbGetAppCompatDataSize
+@ stdcall SdbGetAppCompatDataSize(ptr)
@ stdcall SdbGetAppPatchDir(ptr wstr long)
@ stdcall SdbGetBinaryTagData(ptr long)
@ stdcall SdbGetDatabaseID(ptr ptr)
@@ -103,7 +103,8 @@
@ stdcall SdbOpenDatabase(wstr long)
@ stub SdbOpenDbFromGuid
@ stub SdbOpenLocalDatabase
-@ stub SdbPackAppCompatData
+@ stdcall SdbPackAppCompatData(ptr ptr ptr ptr)
+@ stdcall SdbUnpackAppCompatData(ptr wstr ptr ptr)
@ stub SdbQueryApphelpInformation
@ stub SdbQueryBlockUpgrade
@ stub SdbQueryContext
Modified: trunk/reactos/dll/appcompat/apphelp/hsdb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/appcompat/apphelp/hsdb…
==============================================================================
--- trunk/reactos/dll/appcompat/apphelp/hsdb.c [iso-8859-1] (original)
+++ trunk/reactos/dll/appcompat/apphelp/hsdb.c [iso-8859-1] Mon Jun 19 16:37:47 2017
@@ -29,6 +29,19 @@
#define MAX_LAYER_LENGTH 256
#define GPLK_USER 1
#define GPLK_MACHINE 2
+
+typedef struct _ShimData
+{
+ WCHAR szModule[MAX_PATH];
+ DWORD dwSize;
+ DWORD dwMagic;
+ SDBQUERYRESULT Query;
+ WCHAR szLayer[MAX_LAYER_LENGTH];
+ DWORD unknown; // 0x14c
+} ShimData;
+
+#define SHIMDATA_MAGIC 0xAC0DEDAB
+
static BOOL WINAPI SdbpFileExists(LPCWSTR path)
{
@@ -554,3 +567,79 @@
+BOOL WINAPI SdbPackAppCompatData(HSDB hsdb, PSDBQUERYRESULT pQueryResult, PVOID* ppData,
DWORD *pdwSize)
+{
+ ShimData* pData;
+ HRESULT hr;
+ DWORD n;
+
+ if (!pQueryResult || !ppData || !pdwSize)
+ {
+ SHIM_WARN("Invalid params: %p, %p, %p\n", pQueryResult, ppData,
pdwSize);
+ return FALSE;
+ }
+
+ pData = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ShimData));
+ if (!pData)
+ {
+ SHIM_WARN("Unable to allocate %d bytes\n", sizeof(ShimData));
+ return FALSE;
+ }
+
+ GetWindowsDirectoryW(pData->szModule, _countof(pData->szModule));
+ hr = StringCchCatW(pData->szModule, _countof(pData->szModule),
L"\\system32\\apphelp.dll");
+ if (!SUCCEEDED(hr))
+ {
+ SHIM_ERR("Unable to append module name (0x%x)\n", hr);
+ RtlFreeHeap(RtlGetProcessHeap(), 0, pData);
+ return FALSE;
+ }
+
+ pData->dwSize = sizeof(*pData);
+ pData->dwMagic = SHIMDATA_MAGIC;
+ pData->Query = *pQueryResult;
+ pData->unknown = 0;
+ pData->szLayer[0] = UNICODE_NULL; /* TODO */
+
+ SHIM_INFO("\ndwFlags 0x%x\ndwMagic 0x%x\ntrExe 0x%x\ntrLayer
0x%x",
+ pData->Query.dwFlags, pData->dwMagic, pData->Query.atrExes[0],
pData->Query.atrLayers[0]);
+
+ /* Database List */
+ /* 0x0 {GUID} NAME */
+
+ for (n = 0; n < pQueryResult->dwLayerCount; ++n)
+ {
+ SHIM_INFO("Layer 0x%x\n", pQueryResult->atrLayers[n]);
+ }
+
+ *ppData = pData;
+ *pdwSize = pData->dwSize;
+
+ return TRUE;
+}
+
+BOOL WINAPI SdbUnpackAppCompatData(HSDB hsdb, LPCWSTR pszImageName, PVOID pData,
PSDBQUERYRESULT pQueryResult)
+{
+ ShimData* pShimData = pData;
+
+ if (!pShimData || pShimData->dwMagic != SHIMDATA_MAGIC || pShimData->dwSize
< sizeof(ShimData))
+ return FALSE;
+
+ if (!pQueryResult)
+ return FALSE;
+
+ /* szLayer? */
+
+ *pQueryResult = pShimData->Query;
+ return TRUE;
+}
+
+DWORD WINAPI SdbGetAppCompatDataSize(ShimData* pData)
+{
+ if (!pData || pData->dwMagic != SHIMDATA_MAGIC)
+ return 0;
+
+
+ return pData->dwSize;
+}
+