Check kernel object types when looking up ids.

Some games misuse it, need to return an error.
Merge pull request #2354 from unknownbrackets/kernel-objects

Check kernel object types when looking up ids