https://git.reactos.org/?p=reactos.git;a=commitdiff;h=c10901966e233dbc3bcb25a33a8161a5c34009e9

commit c10901966e233dbc3bcb25a33a8161a5c34009e9
Author:     Pierre Schweitzer <pie...@reactos.org>
AuthorDate: Sun Dec 30 21:25:48 2018 +0100
Commit:     Pierre Schweitzer <pie...@reactos.org>
CommitDate: Sun Dec 30 21:44:40 2018 +0100

    [SERVICES] Properly check again PID
    
    This fixes services not being found.
    With that commit and the previous one, I_QueryTagInformation is now fully
    functionnal and properly returns service name for a specific tag
---
 base/system/services/database.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/base/system/services/database.c b/base/system/services/database.c
index 60e6d4bea1..11e0d0d676 100644
--- a/base/system/services/database.c
+++ b/base/system/services/database.c
@@ -147,7 +147,8 @@ ScmGetServiceImageByImagePath(LPWSTR lpImagePath)
 
 
 DWORD
-ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams, 
PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
+ScmGetServiceNameFromTag(IN PTAG_INFO_NAME_FROM_TAG_IN_PARAMS InParams,
+                         OUT PTAG_INFO_NAME_FROM_TAG_OUT_PARAMS *OutParams)
 {
     PLIST_ENTRY ServiceEntry;
     PSERVICE CurrentService;
@@ -172,7 +173,7 @@ ScmGetServiceNameFromTag(PTAG_INFO_NAME_FROM_TAG_IN_PARAMS 
InParams, PTAG_INFO_N
         {
             CurrentImage = CurrentService->lpImage;
             /* And matching the PID */
-            if (CurrentImage->hProcess == (HANDLE)InParams->dwPid)
+            if (CurrentImage->dwProcessId == InParams->dwPid)
             {
                 break;
             }
@@ -220,7 +221,10 @@ Cleanup:
     /* If failure, free allocated memory */
     if (dwError != ERROR_SUCCESS)
     {
-        MIDL_user_free(OutBuffer);
+        if (OutBuffer != NULL)
+        {
+            MIDL_user_free(OutBuffer);
+        }
     }
 
     /* Return error/success */

Reply via email to