how does procexp close a mutex held by another process?

后端 未结 2 395
广开言路
广开言路 2021-01-03 08:03

I am trying to close a mutex that is being held by a process on Windows using Win32 functions. This can be done using procexp but I need to do it programmatically without us

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 08:59

    Just adding a complete answer. I had to add the following the following code to handles.cpp after the mutex is recognized:

         HANDLE realHandle;  
         ret = DuplicateHandle(processHandle, (HANDLE)handle.Handle, GetCurrentProcess(), &realHandle, 0, TRUE, DUPLICATE_CLOSE_SOURCE);  
    
             if(!ret)  
                   printf("DuplicateHandle Problem!");  
    
             if (!CloseHandle(realHandle))  
        {  
          printf("Problem closing the copied handle");  
        }  
        printf("", realHandle);  
      }  
    

提交回复
热议问题