From a21fad184f402c153796d90c81e2f833c3365eae Mon Sep 17 00:00:00 2001 From: kyoubate-haruka <46010460+kyoubate-haruka@users.noreply.github.com> Date: Tue, 30 Sep 2025 20:50:06 +0200 Subject: [PATCH] sekito: only initialize Y3 I/O dll on field --- common/hooklib/y3.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/common/hooklib/y3.c b/common/hooklib/y3.c index ff99bc5..86cb063 100644 --- a/common/hooklib/y3.c +++ b/common/hooklib/y3.c @@ -365,21 +365,27 @@ int* CALL API_Connect(char* szPortName) { return NULL; } - hr = y3_dll.init(); - if (FAILED(hr)) { - dprintf("Y3: Hook DLL initialization failed: %lx\n", hr); - return NULL; - } - char number[2]; strncpy(number, szPortName + 3, 2); - return (int*)(uintptr_t)atoi(number); + int* hDevice = (int*)(uintptr_t)atoi(number); + + if (hDevice == Y3_COM_FIELD) { + hr = y3_dll.init(); + if (FAILED(hr)) { + dprintf("Y3: Hook DLL initialization failed: %lx\n", hr); + return NULL; + } + } + + return hDevice; } int CALL API_Close(int* hDevice) { dprintf("Y3: %s(%p)\n", __func__, hDevice); - y3_dll.close(); + if (hDevice == Y3_COM_FIELD) { + y3_dll.close(); + } return 0; }