In-Kernel mach message receiving...
In-Kernel mach message receiving...
- Subject: In-Kernel mach message receiving...
- From: Mario Ströhlein <email@hidden>
- Date: Mon, 07 Oct 2013 22:18:24 +0200
Hello list,
I'm having trouble at really getting the difference between a mach_port_t (aka ipc_port_t) and mach_port_name_t. What I want to achieve is to allocate a mach port with receive rights and receive its messages.
What I tried so far.
ipc_port_alloc() which gives me a mach_port_t and a mach_port_name_t. With ipc_space_kernel it panic()s immediately. So I have used a task_t and use get_task_ipcspace() and it's okay.
As far as looking at XNU sources it leaves the port in a locked state. Which is bad.
So I tried the slightly higher level mach_port_allocate() which just gives me a mach_port_name_t back.
To get a mach_port_t from it I tried ipc_object_copying() which succeeds and I get the desired mach_port_t back, I think, it is almost a valid pointer. But after that I want to send this port back
to the User-Space task with mach_msg_send_from_kernel() which panic()s. LLDB backtrace tells me that something regarding locking is not okay.
I also experimented with ipc_port_alloc_special() and a few other calls. ipc_port_make_send(), ipc_object_copyin_from_kernel, and and and...
But even when I manage to send an allocated port (in the tasks ipc space) back to the User-Space task from kernel, which I already managed at somepoint, but don't know anymore how
exactly I managed that due to too many experimenting and trial and error.
Also the use of CAST_MACH_PORT_TO_NAME() and CAST_MACH_NAME_TO_PORT() are totally unclear to me.
After successfull delivery of the port I spawn a new kernel thread upon which I want to receive messages. Tried with mach_msg_receive() and mach_msg_overwrite() I end up with a return code of
MACH_RCV_INVALID_NAME.
So my question is, how to allocate a mach_port_t (aka ipc_port_t) with receive rights and receive messages on it. At it's best in ipc_space_kernel or ipc_space_reply so I must not rely on a user-space task.
Many thanks in advance.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden