diff options
| author | Per Larsson <[email protected]> | 2021-09-17 13:11:04 +0200 |
|---|---|---|
| committer | Per Larsson <[email protected]> | 2021-09-17 13:11:04 +0200 |
| commit | d812fcc3eab88733cbef084eefd089d22177aae4 (patch) | |
| tree | bb64fa6c64f9707246577de148749b35d1e25987 /zenutil | |
| parent | Added helper function for iterating string tokens. (diff) | |
| parent | Added namespace scopes to more includes for better consistency (diff) | |
| download | zen-d812fcc3eab88733cbef084eefd089d22177aae4.tar.xz zen-d812fcc3eab88733cbef084eefd089d22177aae4.zip | |
Merge branch 'main' of https://github.com/EpicGames/zen
Diffstat (limited to 'zenutil')
| -rw-r--r-- | zenutil/include/zenutil/zenserverprocess.h (renamed from zenutil/include/zenserverprocess.h) | 16 | ||||
| -rw-r--r-- | zenutil/zenserverprocess.cpp | 62 | ||||
| -rw-r--r-- | zenutil/zenutil.vcxproj | 5 | ||||
| -rw-r--r-- | zenutil/zenutil.vcxproj.filters | 5 |
4 files changed, 52 insertions, 36 deletions
diff --git a/zenutil/include/zenserverprocess.h b/zenutil/include/zenutil/zenserverprocess.h index b659f6e58..f0924f048 100644 --- a/zenutil/include/zenserverprocess.h +++ b/zenutil/include/zenutil/zenserverprocess.h @@ -5,6 +5,7 @@ #include <zencore/enumflags.h> #include <zencore/logging.h> #include <zencore/thread.h> +#include <zencore/uid.h> #include <gsl/gsl-lite.hpp> @@ -12,6 +13,8 @@ #include <filesystem> #include <optional> +namespace zen { + class ZenServerEnvironment { public: @@ -106,9 +109,10 @@ public: FRIEND_ENUM_CLASS_FLAGS(FlagsEnum); - void Reset(); - void SignalShutdownRequest(); - bool AddSponsorProcess(uint32_t Pid); + zen::Oid GetSessionId() const { return zen::Oid::FromMemory(SessionId); } + void Reset(); + void SignalShutdownRequest(); + bool AddSponsorProcess(uint32_t Pid); }; static_assert(sizeof(ZenServerEntry) == 256); @@ -121,8 +125,10 @@ public: void Snapshot(std::function<void(const ZenServerEntry&)>&& Callback); private: - void* m_hMapFile = nullptr; - ZenServerEntry* m_Data; + void* m_hMapFile = nullptr; + ZenServerEntry* m_Data = nullptr; int m_MaxEntryCount = 131072 / sizeof(ZenServerEntry); ZenServerEntry* m_OurEntry = nullptr; }; + +} diff --git a/zenutil/zenserverprocess.cpp b/zenutil/zenserverprocess.cpp index 2f2b3bd33..c504ce7da 100644 --- a/zenutil/zenserverprocess.cpp +++ b/zenutil/zenserverprocess.cpp @@ -1,6 +1,6 @@ // Copyright Epic Games, Inc. All Rights Reserved. -#include "zenserverprocess.h" +#include "zenutil/zenserverprocess.h" #include <zencore/except.h> #include <zencore/filesystem.h> @@ -17,44 +17,46 @@ ////////////////////////////////////////////////////////////////////////// +namespace zen { + namespace zenutil { -class SecurityAttributes -{ -public: - inline SECURITY_ATTRIBUTES* Attributes() { return &m_Attributes; } + class SecurityAttributes + { + public: + inline SECURITY_ATTRIBUTES* Attributes() { return &m_Attributes; } -protected: - SECURITY_ATTRIBUTES m_Attributes{}; - SECURITY_DESCRIPTOR m_Sd{}; -}; + protected: + SECURITY_ATTRIBUTES m_Attributes{}; + SECURITY_DESCRIPTOR m_Sd{}; + }; -// Security attributes which allows any user access + // Security attributes which allows any user access -class AnyUserSecurityAttributes : public SecurityAttributes -{ -public: - AnyUserSecurityAttributes() + class AnyUserSecurityAttributes : public SecurityAttributes { - m_Attributes.nLength = sizeof m_Attributes; - m_Attributes.bInheritHandle = false; // Disable inheritance - - const BOOL success = InitializeSecurityDescriptor(&m_Sd, SECURITY_DESCRIPTOR_REVISION); - - if (success) + public: + AnyUserSecurityAttributes() { - const BOOL bSetOk = SetSecurityDescriptorDacl(&m_Sd, TRUE, (PACL)NULL, FALSE); + m_Attributes.nLength = sizeof m_Attributes; + m_Attributes.bInheritHandle = false; // Disable inheritance - if (bSetOk) - { - m_Attributes.lpSecurityDescriptor = &m_Sd; - } - else + const BOOL success = InitializeSecurityDescriptor(&m_Sd, SECURITY_DESCRIPTOR_REVISION); + + if (success) { - zen::ThrowLastError("SetSecurityDescriptorDacl failed", std::source_location::current()); + const BOOL bSetOk = SetSecurityDescriptorDacl(&m_Sd, TRUE, (PACL)NULL, FALSE); + + if (bSetOk) + { + m_Attributes.lpSecurityDescriptor = &m_Sd; + } + else + { + zen::ThrowLastError("SetSecurityDescriptorDacl failed", std::source_location::current()); + } } } - } -}; + }; } // namespace zenutil @@ -628,3 +630,5 @@ ZenServerInstance::GetBaseUri() const return "http://localhost:{}"_format(m_BasePort); } + +} // namespace zen diff --git a/zenutil/zenutil.vcxproj b/zenutil/zenutil.vcxproj index fcb27dff3..3bf6111f7 100644 --- a/zenutil/zenutil.vcxproj +++ b/zenutil/zenutil.vcxproj @@ -100,13 +100,16 @@ <ClCompile Include="zenserverprocess.cpp" /> </ItemGroup> <ItemGroup> - <ClInclude Include="include\zenserverprocess.h" /> + <ClInclude Include="include\zenutil\zenserverprocess.h" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\zencore\zencore.vcxproj"> <Project>{d75bf9ab-c61e-4fff-ad59-1563430f05e2}</Project> </ProjectReference> </ItemGroup> + <ItemGroup> + <None Include="xmake.lua" /> + </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> diff --git a/zenutil/zenutil.vcxproj.filters b/zenutil/zenutil.vcxproj.filters index ca1414842..9952e7159 100644 --- a/zenutil/zenutil.vcxproj.filters +++ b/zenutil/zenutil.vcxproj.filters @@ -4,6 +4,9 @@ <ClCompile Include="zenserverprocess.cpp" /> </ItemGroup> <ItemGroup> - <ClInclude Include="include\zenserverprocess.h" /> + <ClInclude Include="include\zenutil\zenserverprocess.h" /> + </ItemGroup> + <ItemGroup> + <None Include="xmake.lua" /> </ItemGroup> </Project>
\ No newline at end of file |