[SHIMENG] Don't crash on a shim not found
authorMark Jansen <mark.jansen@reactos.org>
Mon, 11 Mar 2019 21:47:22 +0000 (22:47 +0100)
committerMark Jansen <mark.jansen@reactos.org>
Thu, 14 Mar 2019 19:02:01 +0000 (20:02 +0100)
CORE-15846

dll/appcompat/apphelp/shimeng.c

index 3520266..d1ba71d 100644 (file)
@@ -1142,10 +1142,13 @@ VOID SeiInit(PUNICODE_STRING ProcessImage, HSDB hsdb, SDBQUERYRESULT* pQuery)
             SHIMENG_INFO("Using SHIM \"%S!%S\"\n", DllName, ShimName);
 
             /* Ask this shim what hooks it needs (and pass along the commandline) */
+            dwHookCount = 0;
             pHookApi = pShimModuleInfo->pGetHookAPIs(AnsiCommandLine.Buffer, ShimName, &dwHookCount);
             SHIMENG_INFO("GetHookAPIs returns %d hooks for DLL \"%wZ\" SHIM \"%S\"\n", dwHookCount, &UnicodeDllName, ShimName);
-            if (dwHookCount)
+            if (dwHookCount && pHookApi)
                 pShimInfo = SeiAppendHookInfo(pShimModuleInfo, pHookApi, dwHookCount, ShimName);
+            else
+                dwHookCount = 0;
 
             /* If this shim has hooks, create the include / exclude lists */
             if (pShimInfo)