From b23a14fa161c47986291d0bbc3f5b5a473d5ed1b Mon Sep 17 00:00:00 2001 From: Tillman Staffen Date: Tue, 17 Mar 2026 09:33:20 +0100 Subject: [PATCH] Made API Keys editable during Runtime --- .../SPIE/Widgets/Debug/W_DebugSPIEPage.uasset | 3 + .../Content/ConfigPawn/ConfigPawn.uasset | 4 +- .../W_DebugWidget_EditableField.uasset | 4 +- .../Source/BTools/Private/BToolsBPLibrary.cpp | 97 +++++++++++-------- 4 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 Unreal/Content/SPIE/Widgets/Debug/W_DebugSPIEPage.uasset diff --git a/Unreal/Content/SPIE/Widgets/Debug/W_DebugSPIEPage.uasset b/Unreal/Content/SPIE/Widgets/Debug/W_DebugSPIEPage.uasset new file mode 100644 index 0000000..af51814 --- /dev/null +++ b/Unreal/Content/SPIE/Widgets/Debug/W_DebugSPIEPage.uasset @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fcd2d39bab71ac731116033713dc63ac79a745ac7a423b46711ad3a040edc3be +size 67675 diff --git a/Unreal/Plugins/BTools/Content/ConfigPawn/ConfigPawn.uasset b/Unreal/Plugins/BTools/Content/ConfigPawn/ConfigPawn.uasset index 7f02d07..4a1b0d9 100644 --- a/Unreal/Plugins/BTools/Content/ConfigPawn/ConfigPawn.uasset +++ b/Unreal/Plugins/BTools/Content/ConfigPawn/ConfigPawn.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:ac47b15c4ccfb00fda35823112be3169fe1782f139752507b80b0451c8fbd58e -size 668869 +oid sha256:6d249f33d5690bc82f00a4469b67360b4866cbdbdc8123d22d8319dba95ccfaf +size 694809 diff --git a/Unreal/Plugins/BTools/Content/DebugWidget/ChildWidgets/W_DebugWidget_EditableField.uasset b/Unreal/Plugins/BTools/Content/DebugWidget/ChildWidgets/W_DebugWidget_EditableField.uasset index 2eb7b6c..da34361 100644 --- a/Unreal/Plugins/BTools/Content/DebugWidget/ChildWidgets/W_DebugWidget_EditableField.uasset +++ b/Unreal/Plugins/BTools/Content/DebugWidget/ChildWidgets/W_DebugWidget_EditableField.uasset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:bbe0aa606a6ea4c1510450ebc3338eea48ce9424e97612e3745a7eafda60fa4f -size 296903 +oid sha256:fb249697f4f53cd3ef63d4fef2667bcc2dfd584f991acc255d68a9933dcba64f +size 281742 diff --git a/Unreal/Plugins/BTools/Source/BTools/Private/BToolsBPLibrary.cpp b/Unreal/Plugins/BTools/Source/BTools/Private/BToolsBPLibrary.cpp index c4eb7a3..365a6a1 100644 --- a/Unreal/Plugins/BTools/Source/BTools/Private/BToolsBPLibrary.cpp +++ b/Unreal/Plugins/BTools/Source/BTools/Private/BToolsBPLibrary.cpp @@ -26,7 +26,7 @@ #include //Create Shortscuts on Runtime #include "Windows/AllowWindowsPlatformTypes.h" - #include + #include "Windows/WindowsHWrapper.h" #include #include #include "Windows/HideWindowsPlatformTypes.h" @@ -69,42 +69,54 @@ void UBToolsBPLibrary::TerminateProc(FTheProcHandle procHandle) bool UBToolsBPLibrary::KillProcessByName(FString Name) { - bool killedProg = false; #if PLATFORM_WINDOWS + bool bKilledProcess = false; + + if (Name.IsEmpty()) + { + return false; + } FString ProcNameWithExtension = Name; - if (ProcNameWithExtension.Find(TEXT(".exe"), ESearchCase::IgnoreCase, ESearchDir::FromEnd) == INDEX_NONE) + if (!ProcNameWithExtension.EndsWith(TEXT(".exe"), ESearchCase::IgnoreCase)) { ProcNameWithExtension += TEXT(".exe"); } - - HANDLE SnapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (SnapShot != INVALID_HANDLE_VALUE) + const HANDLE Snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (Snapshot == INVALID_HANDLE_VALUE) { - PROCESSENTRY32 Entry; - Entry.dwSize = sizeof(PROCESSENTRY32); + return false; + } - if (::Process32First(SnapShot, &Entry)) //Kill all progamms with there is more than one + PROCESSENTRY32 Entry = {}; + Entry.dwSize = sizeof(PROCESSENTRY32); + + if (::Process32First(Snapshot, &Entry)) + { + do { - do + if (FCString::Stricmp(*ProcNameWithExtension, Entry.szExeFile) == 0) { - if (FCString::Stricmp(*ProcNameWithExtension, Entry.szExeFile) == 0) + const HANDLE ProcessHandle = ::OpenProcess(PROCESS_TERMINATE, false, Entry.th32ProcessID); + if (ProcessHandle) { - HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, false, Entry.th32ProcessID); - TerminateProcess(processHandle, 0); - //FPlatformProcess::TerminateProc(SnapShot, true); - killedProg = true; + if (::TerminateProcess(ProcessHandle, 0)) + { + bKilledProcess = true; + } + + ::CloseHandle(ProcessHandle); } - } while (::Process32Next(SnapShot, &Entry)); - } + } + } while (::Process32Next(Snapshot, &Entry)); } - ::CloseHandle(SnapShot); - + ::CloseHandle(Snapshot); + return bKilledProcess; +#else + return false; #endif - - return killedProg; } int UBToolsBPLibrary::KillProcessesByPath(FString Dir) @@ -169,36 +181,45 @@ bool UBToolsBPLibrary::IsProgramRunningByName(FString ProcName) { #if PLATFORM_WINDOWS + if (ProcName.IsEmpty()) + { + return false; + } FString ProcNameWithExtension = ProcName; - if (ProcNameWithExtension.Find(TEXT(".exe"), ESearchCase::IgnoreCase, ESearchDir::FromEnd) == INDEX_NONE) + if (!ProcNameWithExtension.EndsWith(TEXT(".exe"), ESearchCase::IgnoreCase)) { ProcNameWithExtension += TEXT(".exe"); } - HANDLE SnapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); - if (SnapShot != INVALID_HANDLE_VALUE) + const HANDLE Snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); + if (Snapshot == INVALID_HANDLE_VALUE) { - PROCESSENTRY32 Entry; - Entry.dwSize = sizeof(PROCESSENTRY32); + return false; + } - if (::Process32First(SnapShot, &Entry)) + bool bIsRunning = false; + + PROCESSENTRY32 Entry = {}; + Entry.dwSize = sizeof(PROCESSENTRY32); + + if (::Process32First(Snapshot, &Entry)) + { + do { - do + if (FCString::Stricmp(*ProcNameWithExtension, Entry.szExeFile) == 0) { - if (FCString::Stricmp(*ProcNameWithExtension, Entry.szExeFile) == 0) - { - return true; - } - } while (::Process32Next(SnapShot, &Entry)); - } + bIsRunning = true; + break; + } + } while (::Process32Next(Snapshot, &Entry)); } - ::CloseHandle(SnapShot); - -#endif - + ::CloseHandle(Snapshot); + return bIsRunning; +#else return false; +#endif } FString UBToolsBPLibrary::GetLocalAppDataPath()