// Native resource-service protocol and client helpers. #pragma once #include #include #include #include #define NTL_RESOURCE_PROTOCOL_VERSION 2u #define NTL_RESOURCE_PATH_MAX 1024u #define NTL_RESOURCE_FLAG_NONE 0x00000000u #define NTL_RESOURCE_RESOLVE_FLAG_MODIFY 0x00000001u #define NTL_RESOURCE_OP_LOOKUP 1u #define NTL_RESOURCE_OP_QUERY 2u #define NTL_RESOURCE_OP_BIND 3u #define NTL_RESOURCE_OP_UNBIND 4u #define NTL_RESOURCE_OP_RESOLVE 5u #define NTL_RESOURCE_KIND_INVALID 0u #define NTL_RESOURCE_KIND_CAPABILITY 1u #define NTL_RESOURCE_KIND_VOLUME 2u #define NTL_RESOURCE_KIND_DIRECTORY 3u #define NTL_RESOURCE_KIND_DEVICE 4u // Request header followed immediately by PathLength bytes of canonical native resource path. typedef struct NTL_RESOURCE_REQUEST { uint32_t Size; uint32_t Version; uint32_t Operation; uint32_t Flags; SYS_RIGHTS Rights; SYS_RIGHTS ExportRights; uint32_t Kind; uint32_t PathLength; uint32_t Reserved; } NTL_RESOURCE_REQUEST; // Every resource request receives one fixed-size reply. Successful lookup additionally transfers one handle. typedef struct NTL_RESOURCE_REPLY { uint32_t Size; uint32_t Version; uint32_t Operation; uint32_t Flags; KSTATUS Status; uint32_t Kind; uint32_t ResolvedLength; uint32_t Reserved; } NTL_RESOURCE_REPLY; #if defined(NTL_SYSCALL_STATIC) #define NTL_RESOURCE_API #elif defined(NTL_SYSCALL_BUILD) #define NTL_RESOURCE_API __declspec(dllexport) #else #define NTL_RESOURCE_API #endif // Connects one session to the globally registered resource service. NTL_RESOURCE_API KSTATUS NtlResourceConnect(SYS_HANDLE* sessionOut); NTL_RESOURCE_API KSTATUS NtlResourceOpenSystemRoot(SYS_RIGHTS desiredRights, SYS_HANDLE* handleOut); // Connects one session through an explicitly delegated resource-listener capability. NTL_RESOURCE_API KSTATUS NtlResourceConnectListener(SYS_HANDLE listenerHandle, SYS_HANDLE* sessionOut); // Resolves one canonical global resource name to an attenuated capability. NTL_RESOURCE_API KSTATUS NtlResourceLookup(SYS_HANDLE session, SYS_STRING_VIEW path, SYS_RIGHTS desiredRights, SYS_HANDLE* handleOut); // Queries resource metadata without transferring the resource capability. NTL_RESOURCE_API KSTATUS NtlResourceQuery(SYS_HANDLE session, SYS_STRING_VIEW path, uint32_t* kindOut); // Resolves the longest bound resource prefix of one canonical absolute path. // ResolvedLength receives the byte length of the matched resource name; the remaining // path, after one optional '/', is relative to the returned volume/directory capability. NTL_RESOURCE_API KSTATUS NtlResourceResolve(SYS_HANDLE session, SYS_STRING_VIEW path, uint32_t flags, SYS_HANDLE* rootHandleOut, uint32_t* kindOut, uint32_t* resolvedLengthOut); // Binds one capability into an administrative session with an explicit namespace-rights grant and export ceiling. NTL_RESOURCE_API KSTATUS NtlResourceBind(SYS_HANDLE session, SYS_STRING_VIEW path, uint32_t kind, SYS_HANDLE resourceHandle, SYS_RIGHTS namespaceRights, SYS_RIGHTS exportRights); // Removes one name from an administrative resource session. Existing looked-up capabilities remain valid. NTL_RESOURCE_API KSTATUS NtlResourceUnbind(SYS_HANDLE session, SYS_STRING_VIEW path); // Disconnects and closes one resource session endpoint. NTL_RESOURCE_API KSTATUS NtlResourceClose(SYS_HANDLE session); #undef NTL_RESOURCE_API