Store the hook table in the thread queue instead of the thread structure, and make sure the queue is allocated when setting a hook.