Implement kernel handle encoding
Some checks failed
Builds / ExectOS (amd64, debug) (push) Failing after 28s
Builds / ExectOS (i686, debug) (push) Failing after 25s
Builds / ExectOS (i686, release) (push) Failing after 37s
Builds / ExectOS (amd64, release) (push) Failing after 38s

This commit is contained in:
2026-07-14 23:04:48 +02:00
parent 68e08d3065
commit f99e919cb7
4 changed files with 105 additions and 0 deletions

View File

@@ -92,6 +92,7 @@ list(APPEND XTOSKRNL_SOURCE
${XTOSKRNL_SOURCE_DIR}/mm/quota.cc
${XTOSKRNL_SOURCE_DIR}/ob/data.cc
${XTOSKRNL_SOURCE_DIR}/ob/devmap.cc
${XTOSKRNL_SOURCE_DIR}/ob/handle.cc
${XTOSKRNL_SOURCE_DIR}/ob/lifecycl.cc
${XTOSKRNL_SOURCE_DIR}/ob/obdir.cc
${XTOSKRNL_SOURCE_DIR}/ob/obmgr.cc

View File

@@ -12,6 +12,7 @@
#include <xtos.hh>
#include <ob/devmap.hh>
#include <ob/handle.hh>
#include <ob/lifecycl.hh>
#include <ob/obdir.hh>
#include <ob/obmgr.hh>

View File

@@ -0,0 +1,27 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtoskrnl/includes/ob/handle.hh
* DESCRIPTION: Object Manager Handle Management
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
*/
#ifndef __XTOSKRNL_OB_HANDLE_HH
#define __XTOSKRNL_OB_HANDLE_HH
#include <xtos.hh>
/* Object Manager */
namespace OB
{
class Handle
{
public:
STATIC XTFASTCALL HANDLE DecodeKernelHandle(IN HANDLE Handle);
STATIC XTFASTCALL HANDLE EncodeKernelHandle(IN HANDLE Handle);
STATIC XTFASTCALL ULONG GetHandleAttributes(IN PHANDLE_TABLE_ENTRY HandleTableEntry);
};
}
#endif /* __XTOSKRNL_OB_HANDLE_HH */

76
xtoskrnl/ob/handle.cc Normal file
View File

@@ -0,0 +1,76 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtoskrnl/ob/handle.cc
* DESCRIPTION: Object Manager Handle Management
* DEVELOPERS: Aiken Harris <harraiken91@gmail.com>
*/
#include <xtos.hh>
/**
* Encodes a standard handle into a kernel-space handle.
*
* @param Handle
* Supplies the raw standard handle to be encoded.
*
* @return This routine returns the encoded kernel handle.
*
* @since XT 1.0
*/
XTFASTCALL
HANDLE
OB::Handle::DecodeKernelHandle(IN HANDLE Handle)
{
/* Clear the kernel handle flag */
return (HANDLE)(OBJECT_HANDLE_KERNEL_MASK ^ (ULONG_PTR)Handle);
}
/**
* Decodes a kernel-space handle into a standard handle.
*
* @param Handle
* Supplies the encoded kernel handle to be decoded.
*
* @return This routine returns the decoded standard handle.
*
* @since XT 1.0
*/
XTFASTCALL
HANDLE
OB::Handle::EncodeKernelHandle(IN HANDLE Handle)
{
/* Set the kernel handle flag */
return (HANDLE)(OBJECT_HANDLE_KERNEL_MASK | (ULONG_PTR)Handle);
}
/**
* Retrieves and decodes the handle attributes from a given handle table entry.
*
* @param HandleTableEntry
* Supplies a pointer to the handle table entry to inspect.
*
* @return This routine returns a bitmask representing the active handle attributes.
*
* @since XT 1.0
*/
XTFASTCALL
ULONG
OB::Handle::GetHandleAttributes(IN PHANDLE_TABLE_ENTRY HandleTableEntry)
{
ULONG Attributes;
/* Extract the base attributes */
Attributes = HandleTableEntry->ObAttributes;
/* Check if the protect-on-close access bit is set */
if(HandleTableEntry->GrantedAccess & OBJECT_ACCESS_PROTECT_CLOSE_BIT)
{
/* Retain valid handle attributes and set the protect-close flag */
return (Attributes & OBJECT_HANDLE_ATTRIBUTES) | OBJECT_PROTECT_CLOSE;
}
/* Isolate and return the inherit and audit-on-close flags */
return Attributes & (OBJECT_INHERIT | OBJECT_AUDIT_OBJECT_CLOSE);
}