Skip to content

Commit bb8ea77

Browse files
DllUnInject add sem release, Monitor wait for prrocess
1 parent 575b281 commit bb8ea77

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

APIHOOK/DllUnInject/DllUnInject.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66

77
int main()
88
{
9+
HANDLE hSemaphoreStatus;
10+
11+
//hSemaphoreStatus = OpenSemaphore(SYNCHRONIZE, FALSE, L"APIHOOK_Monitor_Semaphore_Status");
12+
hSemaphoreStatus = CreateSemaphore(NULL, 0, 1, L"APIHOOK_Monitor_Semaphore_Status");
13+
if (!hSemaphoreStatus)
14+
{
15+
printf("CreateSemaphore ERROR\n");
16+
return 0;
17+
}
18+
ReleaseSemaphore(hSemaphoreStatus, 1, NULL);
19+
CloseHandle(hSemaphoreStatus);
20+
hSemaphoreStatus = NULL;
21+
922
return 0;
1023
}
1124

APIHOOK/DllUnInject/DllUnInject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#pragma once

APIHOOK/DllUnInject/stdafx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include <stdio.h>
1111
#include <tchar.h>
12+
#include <windows.h>
1213

1314

1415

APIHOOK/Monitor/Monitor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ void StartMonitor()
8989
return;
9090
}
9191
OutputDebugString(L"CreateProcess DllInject.exe\n");
92-
92+
WaitForSingleObject(pi.hProcess, INFINITE);
93+
OutputDebugString(L"DllInject.exe Finished\n");
9394

9495
WaitForSingleObject(hThreadLog, INFINITE);
9596
ReleaseMutex(hMutexSingleton);
@@ -117,10 +118,14 @@ void StopMonitor()
117118
return;
118119
}
119120
OutputDebugString(L"CreateProcess DllUnInject.exe\n");
121+
WaitForSingleObject(pi.hProcess, INFINITE);
122+
OutputDebugString(L"DllUnInject.exe Finished\n");
120123

121124
}
122125

123126
void RestartMonitor()
124127
{
125128
OutputDebugString(L"Do restart \n");
129+
StopMonitor();
130+
StartMonitor();
126131
}

0 commit comments

Comments
 (0)