aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-09-27 20:08:44 +0200
committerStefan Boberg <[email protected]>2021-09-27 20:08:44 +0200
commitb1fd9980abf2091ece8f0f2b3ccb77b1847d4de8 (patch)
tree9c5b0c4c91d03cf185436c2b69b9c838b2c7bc3a
parentclang-format (diff)
downloadzen-b1fd9980abf2091ece8f0f2b3ccb77b1847d4de8.tar.xz
zen-b1fd9980abf2091ece8f0f2b3ccb77b1847d4de8.zip
zencore: Added ability to forcefully set the IsInteractiveSession state
-rw-r--r--zencore/include/zencore/zencore.h1
-rw-r--r--zencore/zencore.cpp33
2 files changed, 25 insertions, 9 deletions
diff --git a/zencore/include/zencore/zencore.h b/zencore/include/zencore/zencore.h
index 4b9c1af1b..b5b47d076 100644
--- a/zencore/include/zencore/zencore.h
+++ b/zencore/include/zencore/zencore.h
@@ -198,6 +198,7 @@ ZENCORE_API bool IsPointerToStack(const void* ptr); // Query if pointer is with
ZENCORE_API bool IsApplicationExitRequested();
ZENCORE_API void RequestApplicationExit(int ExitCode);
ZENCORE_API bool IsDebuggerPresent();
+ZENCORE_API void SetIsInteractiveSession(bool Value);
ZENCORE_API bool IsInteractiveSession();
ZENCORE_API void zencore_forcelinktests();
diff --git a/zencore/zencore.cpp b/zencore/zencore.cpp
index 3eb43c558..0b94f3bea 100644
--- a/zencore/zencore.cpp
+++ b/zencore/zencore.cpp
@@ -69,21 +69,36 @@ IsDebuggerPresent()
#endif
}
+std::optional<bool> InteractiveSessionFlag;
+
+void
+SetIsInteractiveSession(bool Value)
+{
+ InteractiveSessionFlag = Value;
+}
+
bool
IsInteractiveSession()
{
-#if ZEN_PLATFORM_WINDOWS
- DWORD dwSessionId = 0;
- if (ProcessIdToSessionId(GetCurrentProcessId(), &dwSessionId))
+ if (!InteractiveSessionFlag.has_value())
{
- return (dwSessionId != 0);
- }
-
- return false;
+#if ZEN_PLATFORM_WINDOWS
+ DWORD dwSessionId = 0;
+ if (ProcessIdToSessionId(GetCurrentProcessId(), &dwSessionId))
+ {
+ InteractiveSessionFlag = (dwSessionId != 0);
+ }
+ else
+ {
+ InteractiveSessionFlag = false;
+ }
#else
- // TODO: figure out what makes sense here
- return true;
+ // TODO: figure out what actually makes sense here
+ InteractiveSessionFlag = true;
#endif
+ }
+
+ return InteractiveSessionFlag.value();
}
//////////////////////////////////////////////////////////////////////////