From 602af97c269bdc211cc7aeb34e436152053395cc Mon Sep 17 00:00:00 2001 From: Marcos Magueta Date: Fri, 8 May 2026 17:31:36 -0300 Subject: restructure project --- .gitignore | 29 +++++++ Main.vcxproj | 97 --------------------- Main.vcxproj.filters | 14 --- Main/Main.cpp | 11 --- Makefile | 34 ++++++++ NT.slnx | 8 -- NT.vcxproj | 166 ----------------------------------- NT.vcxproj.filters | 39 --------- NT.vcxproj.user | 4 - NtDll.cpp | 17 ---- RelationalNT.sln | 27 ++++++ RelationalNT.vcxproj | 101 ++++++++++++++++++++++ RelationalNT.vcxproj.filters | 31 +++++++ Runtime/NtContext.cpp | 10 --- Runtime/NtContext.h | 182 -------------------------------------- framework.h | 5 -- include/NT.h | 202 +++++++++++++++++++++++++++++++++++++++++++ pch.cpp | 5 -- pch.h | 13 --- src/NT.cpp | 29 +++++++ 20 files changed, 453 insertions(+), 571 deletions(-) delete mode 100644 Main.vcxproj delete mode 100644 Main.vcxproj.filters delete mode 100644 Main/Main.cpp create mode 100644 Makefile delete mode 100644 NT.slnx delete mode 100644 NT.vcxproj delete mode 100644 NT.vcxproj.filters delete mode 100644 NT.vcxproj.user delete mode 100644 NtDll.cpp create mode 100644 RelationalNT.sln create mode 100644 RelationalNT.vcxproj create mode 100644 RelationalNT.vcxproj.filters delete mode 100644 Runtime/NtContext.cpp delete mode 100644 Runtime/NtContext.h delete mode 100644 framework.h create mode 100644 include/NT.h delete mode 100644 pch.cpp delete mode 100644 pch.h create mode 100644 src/NT.cpp diff --git a/.gitignore b/.gitignore index f2fd3ed..4f6d968 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,33 @@ .vs +build out x64 +Debug +Release +Win32 +[Bb]in +[Oo]bj +*.aps +*.db +*.ipch +*.iobj +*.ipdb +*.ilk +*.lastbuildstate +*.log +*.obj +*.opendb +*.pdb +*.recipe +*.sdf +*.suo +*.tlog +*.user *.vcxproj.user +RNT +RNT.exe +RNT.dll +RNT.exp +RNT.lib +libRNT.so +libRNT.dylib diff --git a/Main.vcxproj b/Main.vcxproj deleted file mode 100644 index 2bfa6bd..0000000 --- a/Main.vcxproj +++ /dev/null @@ -1,97 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 18.0 - Win32Proj - {ea0ab0d0-241f-4bd0-aefe-28d42bd6cf1d} - Main - 10.0 - - - - Application - true - v145 - Unicode - - - Application - false - v145 - true - Unicode - - - Application - true - v145 - Unicode - - - Application - false - v145 - true - Unicode - - - - - - - - - - - - - - - - - - - - - - Level3 - true - true - stdcpp20 - $(ProjectDir);%(AdditionalIncludeDirectories) - - - Console - true - - - - - - - - {28338d4e-8618-418d-8728-f71ffaaf5c4e} - - - - - - diff --git a/Main.vcxproj.filters b/Main.vcxproj.filters deleted file mode 100644 index 153390a..0000000 --- a/Main.vcxproj.filters +++ /dev/null @@ -1,14 +0,0 @@ - - - - - {4fc737f1-c7a5-4376-a066-2a32d752a2ff} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - - - Source Files - - - diff --git a/Main/Main.cpp b/Main/Main.cpp deleted file mode 100644 index 5eb314e..0000000 --- a/Main/Main.cpp +++ /dev/null @@ -1,11 +0,0 @@ -#include - -#include "Runtime/NtContext.h" - -int main() -{ - nt::NtContext nt; - - std::cout << "NT context running: " << (nt.IsRunning() ? "yes" : "no") << '\n'; - return nt.IsRunning() ? 0 : 1; -} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..5ab688b --- /dev/null +++ b/Makefile @@ -0,0 +1,34 @@ +CXX = cl +TARGET = RNT.exe +OBJECT = NT.obj +SOURCE = src\NT.cpp +INCDIR = include +DEFINES = /DNT_CONSOLE_APP /DNT_WAIT_ON_EXIT +INCLUDE_FLAG = /I$(INCDIR) +COMPILE_FLAGS = /std:c++17 /W4 /EHsc +COMPILE_ONLY = /c +OBJECT_OUT = /Fo:$(OBJECT) +LINK_FLAGS = +TARGET_OUT = /Fe:$(TARGET) +REMOVE = del /Q + +all: $(TARGET) + +windows: all + +unix: + $(MAKE) CXX=c++ TARGET=RNT OBJECT=NT.o SOURCE=src/NT.cpp DEFINES=-DNT_CONSOLE_APP INCLUDE_FLAG=-Iinclude COMPILE_FLAGS="-std=c++17 -Wall -Wextra" COMPILE_ONLY=-c OBJECT_OUT="-o NT.o" LINK_FLAGS= TARGET_OUT="-o RNT" REMOVE="rm -f" all + +linux: unix + +macos: + $(MAKE) CXX=c++ TARGET=RNT OBJECT=NT.o SOURCE=src/NT.cpp DEFINES=-DNT_CONSOLE_APP INCLUDE_FLAG=-Iinclude COMPILE_FLAGS="-std=c++17 -Wall -Wextra" COMPILE_ONLY=-c OBJECT_OUT="-o NT.o" LINK_FLAGS= TARGET_OUT="-o RNT" REMOVE="rm -f" all + +$(TARGET): $(OBJECT) + $(CXX) $(LINK_FLAGS) $(OBJECT) $(TARGET_OUT) + +$(OBJECT): $(SOURCE) + $(CXX) $(DEFINES) $(INCLUDE_FLAG) $(COMPILE_FLAGS) $(COMPILE_ONLY) $(SOURCE) $(OBJECT_OUT) + +clean: + -$(REMOVE) RNT.exe RNT $(OBJECT) NT.o RNT.exp RNT.lib diff --git a/NT.slnx b/NT.slnx deleted file mode 100644 index b41bc87..0000000 --- a/NT.slnx +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - diff --git a/NT.vcxproj b/NT.vcxproj deleted file mode 100644 index 5bdceff..0000000 --- a/NT.vcxproj +++ /dev/null @@ -1,166 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - 18.0 - Win32Proj - {28338d4e-8618-418d-8728-f71ffaaf5c4e} - NT - 10.0 - - - - DynamicLibrary - true - v145 - Unicode - - - DynamicLibrary - false - v145 - true - Unicode - - - DynamicLibrary - true - v145 - Unicode - - - DynamicLibrary - false - v145 - true - Unicode - - - - - - - - - - - - - - - - - - - - - nt - - - - Level3 - true - $(ProjectDir);%(AdditionalIncludeDirectories) - WIN32;_DEBUG;NT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - stdcpp20 - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - true - true - $(ProjectDir);%(AdditionalIncludeDirectories) - WIN32;NDEBUG;NT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - stdcpp20 - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - $(ProjectDir);%(AdditionalIncludeDirectories) - _DEBUG;NT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - stdcpp20 - Use - pch.h - - - Windows - true - false - - - - - Level3 - true - true - true - $(ProjectDir);%(AdditionalIncludeDirectories) - NDEBUG;NT_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) - true - stdcpp20 - Use - pch.h - - - Windows - true - false - - - - - - - - - - - Create - Create - Create - Create - - - - - - - diff --git a/NT.vcxproj.filters b/NT.vcxproj.filters deleted file mode 100644 index ff46ef1..0000000 --- a/NT.vcxproj.filters +++ /dev/null @@ -1,39 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Header Files - - - Header Files - - - Header Files - - - - - Source Files - - - Source Files - - - Source Files - - - diff --git a/NT.vcxproj.user b/NT.vcxproj.user deleted file mode 100644 index 88a5509..0000000 --- a/NT.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/NtDll.cpp b/NtDll.cpp deleted file mode 100644 index 160b970..0000000 --- a/NtDll.cpp +++ /dev/null @@ -1,17 +0,0 @@ -// NtDll.cpp : Defines the entry point for nt.dll. -#include "pch.h" - -BOOL APIENTRY DllMain(HMODULE hModule, - DWORD ul_reason_for_call, - LPVOID lpReserved) -{ - switch (ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - case DLL_THREAD_ATTACH: - case DLL_THREAD_DETACH: - case DLL_PROCESS_DETACH: - break; - } - return TRUE; -} diff --git a/RelationalNT.sln b/RelationalNT.sln new file mode 100644 index 0000000..aa88815 --- /dev/null +++ b/RelationalNT.sln @@ -0,0 +1,27 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 18 +VisualStudioVersion = 18.0.35730.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{BC8A1FFA-BEE3-4634-8014-F334798102B3}") = "RelationalNT", "RelationalNT.vcxproj", "{FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}.Debug|x64.ActiveCfg = Debug|x64 + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}.Debug|x64.Build.0 = Debug|x64 + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}.Debug|x86.ActiveCfg = Debug|Win32 + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}.Debug|x86.Build.0 = Debug|Win32 + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}.Release|x64.ActiveCfg = Release|x64 + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}.Release|x64.Build.0 = Release|x64 + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}.Release|x86.ActiveCfg = Release|Win32 + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/RelationalNT.vcxproj b/RelationalNT.vcxproj new file mode 100644 index 0000000..8176edc --- /dev/null +++ b/RelationalNT.vcxproj @@ -0,0 +1,101 @@ + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + 18.0 + {FBC1C0B4-8B54-4A18-A91E-8A72767C5AE7} + RelationalNT + MakeFileProj + + + + + + Makefile + true + v145 + + + Makefile + false + v145 + + + Makefile + true + v145 + + + Makefile + false + v145 + + + + + + + + + + + + + + + + + + + + + + + + + nmake /f "$(ProjectDir)Makefile" windows + nmake /f "$(ProjectDir)Makefile" clean && nmake /f "$(ProjectDir)Makefile" windows + nmake /f "$(ProjectDir)Makefile" clean + $(ProjectDir)RNT.exe + NT_CONSOLE_APP;NT_WAIT_ON_EXIT;_CONSOLE + $(ProjectDir)include + $(ProjectDir)RNT.exe + + $(ProjectDir) + + + + + + + + + + + + + + + + + + diff --git a/RelationalNT.vcxproj.filters b/RelationalNT.vcxproj.filters new file mode 100644 index 0000000..c942ddf --- /dev/null +++ b/RelationalNT.vcxproj.filters @@ -0,0 +1,31 @@ + + + + + {76F32F28-90C1-4399-9DA9-BAA6B807C2C8} + cpp;c;cxx + + + {0F8561B5-9FD4-4E00-AEDB-9630D26B0C4E} + h;hpp;hxx + + + {21EA6EE4-A66E-43F8-843B-F8E25DFF8E5F} + + + + + Source Files + + + + + Header Files + + + + + Build Files + + + diff --git a/Runtime/NtContext.cpp b/Runtime/NtContext.cpp deleted file mode 100644 index 248fdaf..0000000 --- a/Runtime/NtContext.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "pch.h" -#include "Runtime/NtContext.h" - -namespace nt -{ - bool NtContext::IsRunning() const - { - return true; - } -} diff --git a/Runtime/NtContext.h b/Runtime/NtContext.h deleted file mode 100644 index 4e28f9f..0000000 --- a/Runtime/NtContext.h +++ /dev/null @@ -1,182 +0,0 @@ -#pragma once -#include -#include -#include -#include - -#ifdef NT_EXPORTS -#define NT_API __declspec(dllexport) -#else -#define NT_API __declspec(dllimport) -#endif - -enum OBJECT_TYPE { - MULTIGROUP, - RELATION, - TUPLE, - ATTRIBUTE, - TRANSACTION -}; - -enum METHOD { - OPEN, - CLOSE, - PARSE, // To plug a secondary namespace - SECURITY -}; - -enum AUTH_CLAIM { - READ, - WRITE -}; - -enum AUTH_METHOD { - CERTIFICATE, - PLAIN_TEXT -}; - -namespace nt -{ - class NT_API ObjectManager - { - public: - class IObject { - virtual ~IObject() {} - }; - class Multigroup : IObject {}; - class Relation : IObject {}; - class Tuple : IObject {}; - class Transaction : IObject {}; - struct object_type { - OBJECT_TYPE label; - // If the object is not durable. E.g.: TRANSACTION - bool disposable; - std::set methods; - }; - struct registry_head { - uint32_t reference_count; - uint32_t handle_count; - struct object_type* type; - std::vector path; - //security_descriptor to be added later, maybe also a set of labels - }; - struct registry { - struct registry_head* head; - IObject object; - // TODO: Treat as a list for now, but ideally it's a tree - struct registry* next; - }; - struct registry** registry; - // Looks into this registry and attempts to retrieve the entry - struct registry* Find(const std::vector object_path){} - }; - - class NT_API PermissionsManager - { - public: - // For validating connections at login - std::set Firewall(AUTH_METHOD method) {} - // For validating permission to an object - const bool Access(const std::vector object_path, const void* connection_context) { - // Checks the security descriptor on the head of the object we find in the ObjectManager::registry - // Then additionally check other metadata yet to be defined in the connection_context, - // like user group, policy, etc. - // Yet to decide if this should be summoned at every attempt to get ahold of an object, - // that might produce significant overhead. How can we solve this? - } - }; - - class NT_API NamespaceReferenceManager - { - }; - - class NT_API CursorManager - { - }; - - class NT_API IdentityManager - { - public: - // Looks into the methods of the object type and asserts if it can be opened - const bool CanOpen(struct ObjectManager::registry* object) {} - }; - - class NT_API LifecycleManager - { - public: - // If object is not being monitored already, monitors the lifecycle by updating the handle count. - // Maybe also look at the reference count and kill some categories of disposable objects no longer referenced by other objects, like transactions. - // Think of other use cases later. - void Monitor(struct ObjectManager::registry* object) {} - // Serializes contention for the change of a mutable reference. - // This can be used in, for example, the HEAD of a branch to serialize the access. - // If the object does not causes contention, like a relation (since they are immutable, just like multigroups, all snapshots) - // then just approve, as they do not cause any contention. Transactions also do not cause any, - // the only things that do are mutable reference states in shared sessions, - // for example: the HEAD of a branch, namespace collisions (creating two branches with the same name, or two multigroups with the same name from the same state, etc), - // multi-branch atomic commits (which I wish to not have as it damages isolation), - // garbage collection of old state (as in, we want to delete an old-enough history to save up space), etc. - const bool Contention(struct ObjectManager::registry* object){} - // The inverse of `Monitor`, stops monitoring. - // Maybe garbage collect here also if the counters goes to zero. - void Unmonitor(struct ObjectManager::registry* object) {} - }; - - class NT_API HandlerManager - { - public: - // This is supposed to represent an authorized access to a certain object in the registry - // This increases the handle count in the object manager - // We should consider adding on the object manager a vector of all the handles that refer to an object - struct handle {}; - void DeallocateHandle(struct handle* handle) {} - struct handle Open(std::vector object_path, void* connection_context) { - struct ObjectManager::registry* retrieved_object = ObjectManager::Find((const std::vector)object_path); - if (PermissionsManager::Access(retrieved_object, (const void*)connection_context) - && IdentityManager::CanOpen(retrieved_object) - && LifecycleManager::Contention(retrieved_object)) { - // Starts monitoring this guy - LifecycleManager::Monitor(retrieved_object); - return {}; // Return a successful handle - } - else { - // Return something more algebraic instead of null or an int - return {}; - }; - } - bool Close(struct handle *handle) { - // Somehow grab the object pointer and connection (maybe drop it...) from the handle - struct ObjectManager::registry* object = handle->object; - void* connection_context = handle->connection_context; - // Checking for permissions here may be relevant. - // What if we have a handle but no permission? Spooky - if (PermissionsManager::Access(object, connection_context) - && IdentityManager::CanClose(object) - // TODO: I think that in this case we do not need to worry about contention. - // But be careful to evaluate this scenario later. - //&& LifecycleManager::Contention(retrieved_object) - ) { - // Stops monitoring this guy - LifecycleManager::Unmonitor(object); - DeallocateHandle(handle); - return true; // Return a successful handle - } - else { - // Return something more algebraic instead of null or an int. - // It's kinda bad to not even report what went wrong. - return false; - }; - } - }; - - class NT_API WAM - { - }; - - class NT_API NT - { - public: - bool IsRunning() const; - void SimulateEntryCall() {}; - }; -} diff --git a/framework.h b/framework.h deleted file mode 100644 index 54b83e9..0000000 --- a/framework.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers -// Windows Header Files -#include diff --git a/include/NT.h b/include/NT.h new file mode 100644 index 0000000..a24d9d4 --- /dev/null +++ b/include/NT.h @@ -0,0 +1,202 @@ +#pragma once +#include +#include +#include +#include + +#if defined(_WIN32) && defined(NT_CONSOLE_APP) +#define NT_API +#elif defined(_WIN32) && defined(NT_EXPORTS) +#define NT_API __declspec(dllexport) +#elif defined(_WIN32) +#define NT_API __declspec(dllimport) +#else +#define NT_API +#endif + +enum OBJECT_TYPE { + MULTIGROUP, + RELATION, + TUPLE, + ATTRIBUTE, + TRANSACTION +}; + +enum METHOD { + OPEN, + CLOSE, + PARSE, // To plug a secondary namespace + SECURITY +}; + +enum AUTH_CLAIM { + READ, + WRITE +}; + +enum AUTH_METHOD { + CERTIFICATE, + PLAIN_TEXT +}; + +namespace nt +{ + class NT_API ObjectManager + { + public: + class IObject { + public: + virtual ~IObject() = default; + }; + class Multigroup : IObject {}; + class Relation : IObject {}; + class Tuple : IObject {}; + class Transaction : IObject {}; + struct object_type { + OBJECT_TYPE label; + // If the object is not durable. E.g.: TRANSACTION + bool disposable; + std::set methods; + }; + struct registry_head { + uint32_t reference_count; + uint32_t handle_count; + struct object_type* type; + std::vector path; + //security_descriptor to be added later, maybe also a set of labels + }; + struct registry { + struct registry_head* head; + IObject object; + // TODO: Treat as a list for now, but ideally it's a tree + struct registry* next; + }; + struct registry** entries; + // Looks into this registry and attempts to retrieve the entry + struct registry* Find(const std::vector object_path) { return nullptr; } + }; + + class NT_API PermissionsManager + { + public: + // For validating connections at login + std::set Firewall(AUTH_METHOD method) { return {}; } + // For validating permission to an object + const bool Access(const ObjectManager::registry* object, const void* connection_context) { + // Checks the security descriptor on the head of the object we find in the ObjectManager::registry + // Then additionally check other metadata yet to be defined in the connection_context, + // like user group, policy, etc. + // Yet to decide if this should be summoned at every attempt to get ahold of an object, + // that might produce significant overhead. How can we solve this? + return object != nullptr && connection_context != nullptr; + } + }; + + class NT_API NamespaceReferenceManager + { + }; + + class NT_API CursorManager + { + }; + + class NT_API IdentityManager + { + public: + // Looks into the methods of the object type and asserts if it can be opened + const bool CanOpen(ObjectManager::registry* object) { return object != nullptr; } + const bool CanClose(ObjectManager::registry* object) { return object != nullptr; } + }; + + class NT_API LifecycleManager + { + public: + // If object is not being monitored already, monitors the lifecycle by updating the handle count. + // Maybe also look at the reference count and kill some categories of disposable objects no longer referenced by other objects, like transactions. + // Think of other use cases later. + void Monitor(ObjectManager::registry* object) {} + // Serializes contention for the change of a mutable reference. + // This can be used in, for example, the HEAD of a branch to serialize the access. + // If the object does not causes contention, like a relation (since they are immutable, just like multigroups, all snapshots) + // then just approve, as they do not cause any contention. Transactions also do not cause any, + // the only things that do are mutable reference states in shared sessions, + // for example: the HEAD of a branch, namespace collisions (creating two branches with the same name, or two multigroups with the same name from the same state, etc), + // multi-branch atomic commits (which I wish to not have as it damages isolation), + // garbage collection of old state (as in, we want to delete an old-enough history to save up space), etc. + const bool Contention(ObjectManager::registry* object){ return object != nullptr; } + // The inverse of `Monitor`, stops monitoring. + // Maybe garbage collect here also if the counters goes to zero. + void Unmonitor(ObjectManager::registry* object) {} + }; + + class NT_API HandlerManager + { + public: + // This is supposed to represent an authorized access to a certain object in the registry + // This increases the handle count in the object manager + // We should consider adding on the object manager a vector of all the handles that refer to an object + struct handle { + ObjectManager::registry* object = nullptr; + void* connection_context = nullptr; + }; + void DeallocateHandle(struct handle* handle) {} + struct handle Open(std::vector object_path, void* connection_context) { + ObjectManager objects; + PermissionsManager permissions; + IdentityManager identities; + LifecycleManager lifecycles; + ObjectManager::registry* retrieved_object = objects.Find((const std::vector)object_path); + if (permissions.Access(retrieved_object, (const void*)connection_context) + && identities.CanOpen(retrieved_object) + && lifecycles.Contention(retrieved_object)) { + // Starts monitoring this guy + lifecycles.Monitor(retrieved_object); + return { retrieved_object, connection_context }; // Return a successful handle + } + else { + // Return something more algebraic instead of null or an int + return {}; + }; + } + bool Close(struct handle *handle) { + if (handle == nullptr) { + return false; + } + PermissionsManager permissions; + IdentityManager identities; + LifecycleManager lifecycles; + // Somehow grab the object pointer and connection (maybe drop it...) from the handle + ObjectManager::registry* object = handle->object; + void* connection_context = handle->connection_context; + // Checking for permissions here may be relevant. + // What if we have a handle but no permission? Spooky + if (permissions.Access(object, connection_context) + && identities.CanClose(object) + // TODO: I think that in this case we do not need to worry about contention. + // But be careful to evaluate this scenario later. + //&& LifecycleManager::Contention(retrieved_object) + ) { + // Stops monitoring this guy + lifecycles.Unmonitor(object); + DeallocateHandle(handle); + return true; // Return a successful handle + } + else { + // Return something more algebraic instead of null or an int. + // It's kinda bad to not even report what went wrong. + return false; + }; + } + }; + + class NT_API WAM + { + }; + + class NT_API NT + { + public: + bool IsRunning() const; + void SimulateEntryCall() {}; + }; +} diff --git a/pch.cpp b/pch.cpp deleted file mode 100644 index 64b7eef..0000000 --- a/pch.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// pch.cpp: source file corresponding to the pre-compiled header - -#include "pch.h" - -// When you are using pre-compiled headers, this source file is necessary for compilation to succeed. diff --git a/pch.h b/pch.h deleted file mode 100644 index 885d5d6..0000000 --- a/pch.h +++ /dev/null @@ -1,13 +0,0 @@ -// pch.h: This is a precompiled header file. -// Files listed below are compiled only once, improving build performance for future builds. -// This also affects IntelliSense performance, including code completion and many code browsing features. -// However, files listed here are ALL re-compiled if any one of them is updated between builds. -// Do not add files here that you will be updating frequently as this negates the performance advantage. - -#ifndef PCH_H -#define PCH_H - -// add headers that you want to pre-compile here -#include "framework.h" - -#endif //PCH_H diff --git a/src/NT.cpp b/src/NT.cpp new file mode 100644 index 0000000..15bf63d --- /dev/null +++ b/src/NT.cpp @@ -0,0 +1,29 @@ +#include "NT.h" + +#ifdef NT_CONSOLE_APP +#include +#endif + +namespace nt +{ + bool NT::IsRunning() const + { + return true; + } +} + +#ifdef NT_CONSOLE_APP +int main() +{ + const nt::NT runtime; + std::cout << "RNT running: " << (runtime.IsRunning() ? "yes" : "no") << '\n'; + const int exit_code = runtime.IsRunning() ? 0 : 1; + +#ifdef NT_WAIT_ON_EXIT + std::cout << "Press Enter to exit..."; + std::cin.get(); +#endif + + return exit_code; +} +#endif -- cgit v1.2.3