Browse Source

Made API Keys editable during Runtime

master
Tillman Staffen 1 month ago
parent
commit
b23a14fa16
  1. BIN
      Unreal/Content/SPIE/Widgets/Debug/W_DebugSPIEPage.uasset
  2. BIN
      Unreal/Plugins/BTools/Content/ConfigPawn/ConfigPawn.uasset
  3. BIN
      Unreal/Plugins/BTools/Content/DebugWidget/ChildWidgets/W_DebugWidget_EditableField.uasset
  4. 79
      Unreal/Plugins/BTools/Source/BTools/Private/BToolsBPLibrary.cpp

BIN
Unreal/Content/SPIE/Widgets/Debug/W_DebugSPIEPage.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Unreal/Plugins/BTools/Content/ConfigPawn/ConfigPawn.uasset (Stored with Git LFS)

Binary file not shown.

BIN
Unreal/Plugins/BTools/Content/DebugWidget/ChildWidgets/W_DebugWidget_EditableField.uasset (Stored with Git LFS)

Binary file not shown.

79
Unreal/Plugins/BTools/Source/BTools/Private/BToolsBPLibrary.cpp

@ -26,7 +26,7 @@
#include <TlHelp32.h> #include <TlHelp32.h>
//Create Shortscuts on Runtime //Create Shortscuts on Runtime
#include "Windows/AllowWindowsPlatformTypes.h" #include "Windows/AllowWindowsPlatformTypes.h"
#include <Windows.h> #include "Windows/WindowsHWrapper.h"
#include <shobjidl.h> #include <shobjidl.h>
#include <shlguid.h> #include <shlguid.h>
#include "Windows/HideWindowsPlatformTypes.h" #include "Windows/HideWindowsPlatformTypes.h"
@ -69,42 +69,54 @@ void UBToolsBPLibrary::TerminateProc(FTheProcHandle procHandle)
bool UBToolsBPLibrary::KillProcessByName(FString Name) bool UBToolsBPLibrary::KillProcessByName(FString Name)
{ {
bool killedProg = false;
#if PLATFORM_WINDOWS #if PLATFORM_WINDOWS
bool bKilledProcess = false;
if (Name.IsEmpty())
{
return false;
}
FString ProcNameWithExtension = Name; FString ProcNameWithExtension = Name;
if (ProcNameWithExtension.Find(TEXT(".exe"), ESearchCase::IgnoreCase, ESearchDir::FromEnd) == INDEX_NONE) if (!ProcNameWithExtension.EndsWith(TEXT(".exe"), ESearchCase::IgnoreCase))
{ {
ProcNameWithExtension += TEXT(".exe"); ProcNameWithExtension += TEXT(".exe");
} }
const HANDLE Snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
HANDLE SnapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (Snapshot == INVALID_HANDLE_VALUE)
if (SnapShot != INVALID_HANDLE_VALUE)
{ {
PROCESSENTRY32 Entry; return false;
}
PROCESSENTRY32 Entry = {};
Entry.dwSize = sizeof(PROCESSENTRY32); Entry.dwSize = sizeof(PROCESSENTRY32);
if (::Process32First(SnapShot, &Entry)) //Kill all progamms with there is more than one if (::Process32First(Snapshot, &Entry))
{ {
do do
{ {
if (FCString::Stricmp(*ProcNameWithExtension, Entry.szExeFile) == 0) if (FCString::Stricmp(*ProcNameWithExtension, Entry.szExeFile) == 0)
{ {
HANDLE processHandle = OpenProcess(PROCESS_ALL_ACCESS, false, Entry.th32ProcessID); const HANDLE ProcessHandle = ::OpenProcess(PROCESS_TERMINATE, false, Entry.th32ProcessID);
TerminateProcess(processHandle, 0); if (ProcessHandle)
//FPlatformProcess::TerminateProc(SnapShot, true); {
killedProg = true; if (::TerminateProcess(ProcessHandle, 0))
{
bKilledProcess = true;
} }
} while (::Process32Next(SnapShot, &Entry));
::CloseHandle(ProcessHandle);
} }
} }
} while (::Process32Next(Snapshot, &Entry));
}
::CloseHandle(SnapShot); ::CloseHandle(Snapshot);
return bKilledProcess;
#else
return false;
#endif #endif
return killedProg;
} }
int UBToolsBPLibrary::KillProcessesByPath(FString Dir) int UBToolsBPLibrary::KillProcessesByPath(FString Dir)
@ -169,36 +181,45 @@ bool UBToolsBPLibrary::IsProgramRunningByName(FString ProcName)
{ {
#if PLATFORM_WINDOWS #if PLATFORM_WINDOWS
if (ProcName.IsEmpty())
{
return false;
}
FString ProcNameWithExtension = ProcName; FString ProcNameWithExtension = ProcName;
if (ProcNameWithExtension.Find(TEXT(".exe"), ESearchCase::IgnoreCase, ESearchDir::FromEnd) == INDEX_NONE) if (!ProcNameWithExtension.EndsWith(TEXT(".exe"), ESearchCase::IgnoreCase))
{ {
ProcNameWithExtension += TEXT(".exe"); ProcNameWithExtension += TEXT(".exe");
} }
HANDLE SnapShot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); const HANDLE Snapshot = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (SnapShot != INVALID_HANDLE_VALUE) if (Snapshot == INVALID_HANDLE_VALUE)
{ {
PROCESSENTRY32 Entry; return false;
}
bool bIsRunning = false;
PROCESSENTRY32 Entry = {};
Entry.dwSize = sizeof(PROCESSENTRY32); Entry.dwSize = sizeof(PROCESSENTRY32);
if (::Process32First(SnapShot, &Entry)) if (::Process32First(Snapshot, &Entry))
{ {
do do
{ {
if (FCString::Stricmp(*ProcNameWithExtension, Entry.szExeFile) == 0) if (FCString::Stricmp(*ProcNameWithExtension, Entry.szExeFile) == 0)
{ {
return true; bIsRunning = true;
} break;
} while (::Process32Next(SnapShot, &Entry));
} }
} while (::Process32Next(Snapshot, &Entry));
} }
::CloseHandle(SnapShot); ::CloseHandle(Snapshot);
return bIsRunning;
#endif #else
return false; return false;
#endif
} }
FString UBToolsBPLibrary::GetLocalAppDataPath() FString UBToolsBPLibrary::GetLocalAppDataPath()

Loading…
Cancel
Save