mirror of
https://github.com/EnderIce2/rpc-bridge.git
synced 2025-05-25 22:14:38 +00:00
Add Stop option in GUI
This commit is contained in:
parent
8cd44da368
commit
6e99e11250
11
bridge.c
11
bridge.c
@ -63,6 +63,8 @@ LPTSTR GetErrorMessage();
|
||||
extern BOOL RunningAsService;
|
||||
BOOL RetryNewConnection;
|
||||
BOOL IsLinux;
|
||||
HANDLE hOut = NULL;
|
||||
HANDLE hIn = NULL;
|
||||
|
||||
static force_inline int linux_syscall(int num,
|
||||
int arg1, int arg2, int arg3,
|
||||
@ -312,7 +314,6 @@ void ConnectToSocket(int fd)
|
||||
}
|
||||
}
|
||||
|
||||
HANDLE hOut = NULL;
|
||||
void PipeBufferInThread(LPVOID lpParam)
|
||||
{
|
||||
bridge_thread *bt = (bridge_thread *)lpParam;
|
||||
@ -543,10 +544,10 @@ NewConnection:
|
||||
|
||||
bridge_thread bt = {fd, hPipe};
|
||||
|
||||
HANDLE hIn = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE)PipeBufferInThread,
|
||||
(LPVOID)&bt,
|
||||
0, NULL);
|
||||
hIn = CreateThread(NULL, 0,
|
||||
(LPTHREAD_START_ROUTINE)PipeBufferInThread,
|
||||
(LPVOID)&bt,
|
||||
0, NULL);
|
||||
print("Created in thread %#lx\n", hIn);
|
||||
|
||||
hOut = CreateThread(NULL, 0,
|
||||
|
45
gui.c
45
gui.c
@ -1,3 +1,4 @@
|
||||
#include <windowsx.h>
|
||||
#include <windows.h>
|
||||
#include <winuser.h>
|
||||
#include <assert.h>
|
||||
@ -17,19 +18,44 @@ void CreateBridge();
|
||||
extern BOOL IsLinux;
|
||||
|
||||
HWND hwnd = NULL;
|
||||
HANDLE hBridge = NULL;
|
||||
extern HANDLE hOut;
|
||||
extern HANDLE hIn;
|
||||
|
||||
BOOL IsAlreadyRunning = FALSE;
|
||||
VOID HandleStartButton(BOOL Silent)
|
||||
{
|
||||
if (IsAlreadyRunning)
|
||||
{
|
||||
HWND item = GetDlgItem(hwnd, 4);
|
||||
SetWindowText(item, "Do you want to start, install or remove the bridge?");
|
||||
RedrawWindow(item, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
|
||||
item = GetDlgItem(hwnd, /* Start Button */ 1);
|
||||
Button_SetText(item, "Start");
|
||||
EnableWindow(item, FALSE);
|
||||
RedrawWindow(item, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
|
||||
|
||||
print("Killing %#x, %#lx and waiting for %#lx\n", hIn, hOut, hBridge);
|
||||
TerminateThread(hIn, 0);
|
||||
TerminateThread(hOut, 0);
|
||||
WaitForSingleObject(hBridge, INFINITE);
|
||||
|
||||
EnableWindow(item, TRUE);
|
||||
IsAlreadyRunning = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsLinux)
|
||||
{
|
||||
ShowWindow(hwnd, SW_MINIMIZE);
|
||||
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateBridge,
|
||||
NULL, 0, NULL);
|
||||
hBridge = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateBridge,
|
||||
NULL, 0, NULL);
|
||||
|
||||
HWND item = GetDlgItem(hwnd, /* Start Button */ 1);
|
||||
EnableWindow(item, FALSE);
|
||||
Button_SetText(item, "Stop");
|
||||
item = GetDlgItem(hwnd, 4);
|
||||
SetWindowText(item, "Bridge is running...");
|
||||
IsAlreadyRunning = TRUE;
|
||||
ShowWindow(hwnd, SW_MINIMIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -48,14 +74,15 @@ VOID HandleStartButton(BOOL Silent)
|
||||
|
||||
/* Service doesn't exist; running without any service */
|
||||
|
||||
ShowWindow(hwnd, SW_MINIMIZE);
|
||||
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateBridge,
|
||||
NULL, 0, NULL);
|
||||
hBridge = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CreateBridge,
|
||||
NULL, 0, NULL);
|
||||
|
||||
HWND item = GetDlgItem(hwnd, /* Start Button */ 1);
|
||||
EnableWindow(item, FALSE);
|
||||
Button_SetText(item, "Stop");
|
||||
item = GetDlgItem(hwnd, 4);
|
||||
|
||||
SetWindowText(item, "Bridge is running...");
|
||||
IsAlreadyRunning = TRUE;
|
||||
ShowWindow(hwnd, SW_MINIMIZE);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user