[Kernel] Scope object type enum.

This commit is contained in:
gibbed
2020-11-22 20:21:05 -06:00
committed by Rick Gibbed
parent bdeae25353
commit 164aa8e8ca
33 changed files with 87 additions and 82 deletions

View File

@@ -131,7 +131,7 @@ dword_result_t NtCreateFile(lpdword_t handle_out, dword_t desired_access,
auto root_file = kernel_state()->object_table()->LookupObject<XFile>(
object_attrs->root_directory);
assert_not_null(root_file);
assert_true(root_file->type() == XObject::Type::kTypeFile);
assert_true(root_file->type() == XObject::Type::File);
root_entry = root_file->entry();
}
@@ -399,7 +399,7 @@ dword_result_t NtQueryFullAttributesFile(
root_file = kernel_state()->object_table()->LookupObject<XFile>(
obj_attribs->root_directory);
assert_not_null(root_file);
assert_true(root_file->type() == XObject::Type::kTypeFile);
assert_true(root_file->type() == XObject::Type::File);
assert_always();
}

View File

@@ -78,22 +78,21 @@ DECLARE_XBOXKRNL_EXPORT1(ObLookupThreadByThreadId, kNone, kImplemented);
dword_result_t ObReferenceObjectByHandle(dword_t handle,
dword_t object_type_ptr,
lpdword_t out_object_ptr) {
const static std::unordered_map<XObject::Type, uint32_t> obj_type_match = {
{XObject::kTypeEvent, 0xD00EBEEF},
{XObject::kTypeSemaphore, 0xD017BEEF},
{XObject::kTypeThread, 0xD01BBEEF}};
// These values come from how Xenia handles uninitialized kernel data exports.
// D###BEEF where ### is the ordinal.
const static std::unordered_map<XObject::Type, uint32_t> object_types = {
{XObject::Type::Event, 0xD00EBEEF},
{XObject::Type::Semaphore, 0xD017BEEF},
{XObject::Type::Thread, 0xD01BBEEF}};
auto object = kernel_state()->object_table()->LookupObject<XObject>(handle);
if (!object) {
return X_STATUS_INVALID_HANDLE;
}
uint32_t native_ptr = object->guest_object();
auto obj_type = obj_type_match.find(object->type());
if (obj_type != obj_type_match.end()) {
if (object_type_ptr && object_type_ptr != obj_type->second) {
auto object_type = object_types.find(object->type());
if (object_type != object_types.end()) {
if (object_type_ptr && object_type_ptr != object_type->second) {
return X_STATUS_OBJECT_TYPE_MISMATCH;
}
} else {

View File

@@ -432,7 +432,7 @@ dword_result_t NtCreateEvent(lpdword_t handle_ptr,
auto existing_object =
LookupNamedObject<XEvent>(kernel_state(), obj_attributes_ptr);
if (existing_object) {
if (existing_object->type() == XObject::kTypeEvent) {
if (existing_object->type() == XObject::Type::Event) {
if (handle_ptr) {
existing_object->RetainHandle();
*handle_ptr = existing_object->handle();
@@ -559,7 +559,7 @@ dword_result_t NtCreateSemaphore(lpdword_t handle_ptr,
auto existing_object =
LookupNamedObject<XSemaphore>(kernel_state(), obj_attributes_ptr);
if (existing_object) {
if (existing_object->type() == XObject::kTypeSemaphore) {
if (existing_object->type() == XObject::Type::Semaphore) {
if (handle_ptr) {
existing_object->RetainHandle();
*handle_ptr = existing_object->handle();
@@ -613,7 +613,7 @@ dword_result_t NtCreateMutant(lpdword_t handle_out,
auto existing_object = LookupNamedObject<XMutant>(
kernel_state(), obj_attributes.guest_address());
if (existing_object) {
if (existing_object->type() == XObject::kTypeMutant) {
if (existing_object->type() == XObject::Type::Mutant) {
if (handle_out) {
existing_object->RetainHandle();
*handle_out = existing_object->handle();
@@ -674,7 +674,7 @@ dword_result_t NtCreateTimer(lpdword_t handle_ptr, lpvoid_t obj_attributes_ptr,
auto existing_object =
LookupNamedObject<XTimer>(kernel_state(), obj_attributes_ptr);
if (existing_object) {
if (existing_object->type() == XObject::kTypeTimer) {
if (existing_object->type() == XObject::Type::Timer) {
if (handle_ptr) {
existing_object->RetainHandle();
*handle_ptr = existing_object->handle();