diff options
| author | Lioncash <mathew1800@gmail.com> | 2019-02-25 10:13:52 -0500 |
|---|---|---|
| committer | Lioncash <mathew1800@gmail.com> | 2019-02-25 11:12:32 -0500 |
| commit | 5167d1577d6b4074f46ad90864d6e0d6119089a3 (patch) | |
| tree | 8debfe33cc6f0abefb1c5dbb8ae6c01bf9b0e932 /src/core/hle/kernel/handle_table.h | |
| parent | 4f8cd74061464d01e0c3a4ea47a4141e3597cb57 (diff) | |
kernel/handle_table: Allow process capabilities to limit the handle table size
The kernel allows restricting the total size of the handle table through
the process capability descriptors. Until now, this functionality wasn't
hooked up. With this, the process handle tables become properly restricted.
In the case of metadata-less executables, the handle table will assume
the maximum size is requested, preserving the behavior that existed
before these changes.
Diffstat (limited to 'src/core/hle/kernel/handle_table.h')
| -rw-r--r-- | src/core/hle/kernel/handle_table.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index 5fa55c783..44901391b 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h @@ -50,6 +50,20 @@ public: ~HandleTable(); /** + * Sets the number of handles that may be in use at one time + * for this handle table. + * + * @param handle_table_size The desired size to limit the handle table to. + * + * @returns an error code indicating if initialization was successful. + * If initialization was not successful, then ERR_OUT_OF_MEMORY + * will be returned. + * + * @pre handle_table_size must be within the range [0, 1024] + */ + ResultCode SetSize(s32 handle_table_size); + + /** * Allocates a handle for the given object. * @return The created Handle or one of the following errors: * - `ERR_HANDLE_TABLE_FULL`: the maximum number of handles has been exceeded. @@ -104,6 +118,13 @@ private: std::array<u16, MAX_COUNT> generations; /** + * The limited size of the handle table. This can be specified by process + * capabilities in order to restrict the overall number of handles that + * can be created in a process instance + */ + u16 table_size = static_cast<u16>(MAX_COUNT); + + /** * Global counter of the number of created handles. Stored in `generations` when a handle is * created, and wraps around to 1 when it hits 0x8000. */ |
