本文整理汇总了C++中MACH_PORT_VALID函数的典型用法代码示例。如果您正苦于以下问题:C++ MACH_PORT_VALID函数的具体用法?C++ MACH_PORT_VALID怎么用?C++ MACH_PORT_VALID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MACH_PORT_VALID函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: setup_thread_target
error_t
setup_thread_target (void)
{
error_t err;
static task_t task;
static thread_t thread;
if (MACH_PORT_VALID (thread))
{
thread_terminate (thread);
mach_port_deallocate (mach_task_self (), thread);
}
if (MACH_PORT_VALID (task))
{
task_terminate (task);
mach_port_deallocate (mach_task_self (), task);
}
err = task_create (mach_task_self (), 0, &task);
if (err)
return err;
err = thread_create (task, &thread);
if (err)
return err;
return setup (thread, MACH_MSG_TYPE_COPY_SEND);
}
开发者ID:dreamsxin,项目名称:GNU-Hurd,代码行数:29,代码来源:rpcscan.c
示例2: setup_proc_target
error_t
setup_proc_target (void)
{
error_t err;
static task_t task;
static process_t proc, target;
static mach_msg_type_name_t targetType = MACH_MSG_TYPE_COPY_SEND;
if (! MACH_PORT_VALID (proc))
proc = getproc ();
if (MACH_PORT_VALID (task))
mach_port_deallocate (mach_task_self (), task);
if (MACH_PORT_VALID (target))
mach_port_deallocate (mach_task_self (), target);
err = task_create (mach_task_self (), 0, &task);
if (err)
return err;
err = proc_task2proc (proc, task, &target);
if (err)
return err;
return setup (target, targetType);
}
开发者ID:dreamsxin,项目名称:GNU-Hurd,代码行数:25,代码来源:rpcscan.c
示例3: mach_port_extract_member
kern_return_t
mach_port_extract_member(
ipc_space_t space,
mach_port_name_t name,
mach_port_name_t psname)
{
mach_port_name_t oldname;
ipc_object_t psobj;
ipc_object_t obj;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (!MACH_PORT_VALID(name) || !MACH_PORT_VALID(psname))
return KERN_INVALID_RIGHT;
kr = ipc_object_translate_two(space,
name, MACH_PORT_RIGHT_RECEIVE, &obj,
psname, MACH_PORT_RIGHT_PORT_SET, &psobj);
if (kr != KERN_SUCCESS)
return kr;
/* obj and psobj are both locked (and were locked in that order) */
assert(psobj != IO_NULL);
assert(obj != IO_NULL);
kr = ipc_pset_remove((ipc_pset_t)psobj, (ipc_port_t)obj);
io_unlock(psobj);
io_unlock(obj);
return kr;
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:32,代码来源:mach_port.c
示例4: increase_priority
error_t
increase_priority (void)
{
mach_port_t pset = MACH_PORT_NULL, psetcntl = MACH_PORT_NULL;
error_t err;
err = thread_get_assignment (mach_thread_self (), &pset);
if (err)
goto out;
err = host_processor_set_priv (_hurd_host_priv, pset, &psetcntl);
if (err)
goto out;
err = thread_max_priority (mach_thread_self (), psetcntl, 0);
if (err)
goto out;
err = task_priority (mach_task_self (), 2, 1);
out:
if (MACH_PORT_VALID (pset))
mach_port_deallocate (mach_task_self (), pset);
if (MACH_PORT_VALID (psetcntl))
mach_port_deallocate (mach_task_self (), psetcntl);
return err;
}
开发者ID:Larhard,项目名称:hurd,代码行数:28,代码来源:main.c
示例5: mach_port_set_attributes
kern_return_t
mach_port_set_attributes(
ipc_space_t space,
mach_port_name_t name,
int flavor,
mach_port_info_t info,
mach_msg_type_number_t count)
{
ipc_port_t port;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
switch (flavor) {
case MACH_PORT_LIMITS_INFO: {
mach_port_limits_t *mplp = (mach_port_limits_t *)info;
if (count < MACH_PORT_LIMITS_INFO_COUNT)
return KERN_FAILURE;
if (mplp->mpl_qlimit > MACH_PORT_QLIMIT_MAX)
return KERN_INVALID_VALUE;
if (!MACH_PORT_VALID(name))
return KERN_INVALID_RIGHT;
kr = ipc_port_translate_receive(space, name, &port);
if (kr != KERN_SUCCESS)
return kr;
/* port is locked and active */
ipc_mqueue_set_qlimit(&port->ip_messages, mplp->mpl_qlimit);
ip_unlock(port);
break;
}
case MACH_PORT_DNREQUESTS_SIZE: {
if (count < MACH_PORT_DNREQUESTS_SIZE_COUNT)
return KERN_FAILURE;
if (!MACH_PORT_VALID(name))
return KERN_INVALID_RIGHT;
kr = ipc_port_translate_receive(space, name, &port);
if (kr != KERN_SUCCESS)
return kr;
/* port is locked and active */
kr = ipc_port_dngrow(port, *(int *)info);
if (kr != KERN_SUCCESS)
return kr;
break;
}
default:
return KERN_INVALID_ARGUMENT;
/*NOTREACHED*/
}
return KERN_SUCCESS;
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:60,代码来源:mach_port.c
示例6: ProtThreadRegister
extern void ProtThreadRegister(Bool setup)
{
kern_return_t kr;
mach_msg_type_number_t old_exception_count = 1;
exception_mask_t old_exception_masks;
exception_behavior_t behavior;
mach_port_t old_exception_ports;
exception_behavior_t old_behaviors;
thread_state_flavor_t old_flavors;
mach_port_t self;
static mach_port_t setupThread = MACH_PORT_NULL;
self = mach_thread_self();
AVER(MACH_PORT_VALID(self));
/* Avoid setting up the exception handler for the thread that calls
ProtSetup twice, in the case where the mutator registers that thread
explicitly. We need a special case because we don't require thread
registration of the sole thread of a single-threaded mutator. */
if (setup) {
AVER(setupThread == MACH_PORT_NULL);
setupThread = self;
} else {
AVER(setupThread != MACH_PORT_NULL);
if (self == setupThread)
return;
}
/* Ask to receive EXC_BAD_ACCESS exceptions on our port, complete
with thread state and identity information in the message.
The MACH_EXCEPTION_CODES flag causes the code fields to be
passed 64-bits wide, matching protRequestStruct [Fuller_2013]. */
behavior = (exception_behavior_t)(EXCEPTION_STATE_IDENTITY | MACH_EXCEPTION_CODES);
AVER(MACH_PORT_VALID(protExcPort));
kr = thread_swap_exception_ports(self,
EXC_MASK_BAD_ACCESS,
protExcPort,
behavior,
THREAD_STATE_FLAVOR,
&old_exception_masks,
&old_exception_count,
&old_exception_ports,
&old_behaviors,
&old_flavors);
AVER(kr == KERN_SUCCESS);
if (kr != KERN_SUCCESS)
mach_error("ERROR: MPS thread_swap_exception_ports", kr); /* .trans.must */
AVER(old_exception_masks == EXC_MASK_BAD_ACCESS);
AVER(old_exception_count == 1);
AVER(old_exception_ports == MACH_PORT_NULL
|| old_exception_ports == protExcPort); /* .assume.only-port */
}
开发者ID:clojit,项目名称:rust-mps-obj,代码行数:52,代码来源:protxc.c
示例7: setup_auth_target
error_t
setup_auth_target (void)
{
static auth_t auth;
static mach_msg_type_name_t authType = MACH_MSG_TYPE_COPY_SEND;
if (MACH_PORT_VALID (auth))
mach_port_deallocate (mach_task_self (), auth);
auth = getauth ();
if (! MACH_PORT_VALID (auth))
return errno;
return setup (auth, authType);
}
开发者ID:dreamsxin,项目名称:GNU-Hurd,代码行数:15,代码来源:rpcscan.c
示例8: inode_pager_setup
memory_object_t
inode_pager_setup(
struct inode *inode)
{
struct i_mem_object *imo;
if (inode == NULL)
return MEMORY_OBJECT_NULL;
imo = inode->i_mem_object;
if (imo == NULL) {
/*
* First time this inode is mapped. Create a memory object.
*/
imo = imo_create(inode, TRUE);
if (imo == NULL)
return MEMORY_OBJECT_NULL;
}
imo_ref(imo); /* 1 ref for the mapper */
#ifdef INODE_PAGER_DEBUG
if (inode_pager_debug) {
printk("inode_pager_setup: imo 0x%p: obj 0x%x, inode 0x%p\n",
imo, imo->imo_mem_obj, imo->imo_inode);
}
#endif /* INODE_PAGER_DEBUG */
ASSERT(MACH_PORT_VALID(imo->imo_mem_obj));
return imo->imo_mem_obj;
}
开发者ID:rohsaini,项目名称:mkunity,代码行数:31,代码来源:inode_pager.c
示例9: osfmach3_get_time
void
osfmach3_get_time(
struct timeval *xtime)
{
tvalspec_t cur_time;
#ifdef __powerpc__
if (use_highres && MACH_PORT_VALID(rt_clock)) {
kern_return_t kr;
/*
* We want a higher resolution time: ask the microkernel.
* XXX this doesn't work on MP PowerMac systems.
*/
kr = clock_get_time(rt_clock, &cur_time);
if (kr != KERN_SUCCESS) {
MACH3_DEBUG(2, kr,
("osfmach3_get_time: clock_get_time(0x%x)",
rt_clock));
/* use mapped time */
MTS_TO_TS(serv_mtime, &cur_time);
}
} else {
MTS_TO_TS(serv_mtime, &cur_time);
}
#else /* __powerpc__ */
MTS_TO_TS(serv_mtime, &cur_time);
#endif /* __powerpc__ */
xtime->tv_sec = cur_time.tv_sec + base_time.tv_sec;
xtime->tv_usec = (cur_time.tv_nsec + base_time.tv_nsec) / 1000;
if (xtime->tv_usec >= USEC_PER_SEC) {
xtime->tv_sec++;
xtime->tv_usec -= USEC_PER_SEC;
}
}
开发者ID:rohsaini,项目名称:mkunity,代码行数:35,代码来源:map_time.c
示例10: mach_port_set_seqno
kern_return_t
mach_port_set_seqno(
ipc_space_t space,
mach_port_name_t name,
mach_port_seqno_t seqno)
{
ipc_port_t port;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (!MACH_PORT_VALID(name))
return KERN_INVALID_RIGHT;
kr = ipc_port_translate_receive(space, name, &port);
if (kr != KERN_SUCCESS)
return kr;
/* port is locked and active */
ipc_mqueue_set_seqno(&port->ip_messages, seqno);
ip_unlock(port);
return KERN_SUCCESS;
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:25,代码来源:mach_port.c
示例11: mach_port_set_mscount
kern_return_t
mach_port_set_mscount(
ipc_space_t space,
mach_port_name_t name,
mach_port_mscount_t mscount)
{
ipc_port_t port;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (!MACH_PORT_VALID(name))
return KERN_INVALID_RIGHT;
kr = ipc_port_translate_receive(space, name, &port);
if (kr != KERN_SUCCESS)
return kr;
/* port is locked and active */
ipc_port_set_mscount(port, mscount);
ip_unlock(port);
return KERN_SUCCESS;
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:25,代码来源:mach_port.c
示例12: mach_port_mod_refs
kern_return_t
mach_port_mod_refs(
ipc_space_t space,
mach_port_name_t name,
mach_port_right_t right,
mach_port_delta_t delta)
{
ipc_entry_t entry;
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (right >= MACH_PORT_RIGHT_NUMBER)
return KERN_INVALID_VALUE;
if (!MACH_PORT_VALID(name)) {
if (right == MACH_PORT_RIGHT_SEND ||
right == MACH_PORT_RIGHT_SEND_ONCE)
return KERN_SUCCESS;
return KERN_INVALID_NAME;
}
kr = ipc_right_lookup_write(space, name, &entry);
if (kr != KERN_SUCCESS)
return kr;
/* space is write-locked and active */
kr = ipc_right_delta(space, name, entry, right, delta); /* unlocks */
return kr;
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:31,代码来源:mach_port.c
示例13: mach_port_extract_right
kern_return_t
mach_port_extract_right(
ipc_space_t space,
mach_port_name_t name,
mach_msg_type_name_t msgt_name,
ipc_port_t *poly,
mach_msg_type_name_t *polyPoly)
{
kern_return_t kr;
if (space == IS_NULL)
return KERN_INVALID_TASK;
if (!MACH_MSG_TYPE_PORT_ANY(msgt_name))
return KERN_INVALID_VALUE;
if (!MACH_PORT_VALID(name)) {
/*
* really should copy out a dead name, if it is a send or
* send-once right being copied, but instead return an
* error for now.
*/
return KERN_INVALID_RIGHT;
}
kr = ipc_object_copyin(space, name, msgt_name, (ipc_object_t *) poly);
if (kr == KERN_SUCCESS)
*polyPoly = ipc_object_copyin_type(msgt_name);
return kr;
}
开发者ID:OpenDarwin-CVS,项目名称:SEDarwin,代码行数:31,代码来源:mach_port.c
示例14: ThreadRegister
Res ThreadRegister(Thread *threadReturn, Arena arena)
{
Res res;
Thread thread;
Ring ring;
void *p;
AVER(threadReturn != NULL);
res = ControlAlloc(&p, arena, sizeof(ThreadStruct));
if (res != ResOK)
return res;
thread = (Thread)p;
thread->arena = arena;
RingInit(&thread->arenaRing);
thread->serial = arena->threadSerial;
++arena->threadSerial;
thread->alive = TRUE;
thread->forking = FALSE;
thread->port = mach_thread_self();
AVER(MACH_PORT_VALID(thread->port));
thread->sig = ThreadSig;
AVERT(Thread, thread);
ProtThreadRegister();
ring = ArenaThreadRing(arena);
RingAppend(ring, &thread->arenaRing);
*threadReturn = thread;
return ResOK;
}
开发者ID:Ravenbrook,项目名称:mps,代码行数:35,代码来源:thxc.c
示例15: main
int
main (int argc, char **argv)
{
error_t err;
mach_port_t bootstrap;
argp_parse (&argp, argc, argv, 0, 0, 0);
if (MACH_PORT_VALID (opt_device_master))
{
err = open_console (opt_device_master);
assert_perror (err);
mach_port_deallocate (mach_task_self (), opt_device_master);
}
save_argv = argv;
task_get_bootstrap_port (mach_task_self (), &bootstrap);
if (bootstrap == MACH_PORT_NULL)
error (2, 0, "Must be started as a translator");
/* Fetch our proc server port for easy use. If we are booting, it is not
set yet and `getproc' returns MACH_PORT_NULL; we reset PROCSERVER in
S_exec_init (below). */
procserver = getproc ();
err = trivfs_add_port_bucket (&port_bucket);
if (err)
error (1, 0, "error creating port bucket");
err = trivfs_add_control_port_class (&trivfs_control_class);
if (err)
error (1, 0, "error creating control port class");
err = trivfs_add_protid_port_class (&trivfs_protid_class);
if (err)
error (1, 0, "error creating protid port class");
execboot_portclass = ports_create_class (deadboot, NULL);
/* Reply to our parent. */
err = trivfs_startup (bootstrap, 0,
trivfs_control_class, port_bucket,
trivfs_protid_class, port_bucket, &fsys);
/* Reply to our parent. */
err = trivfs_startup (bootstrap, 0,
trivfs_control_class, port_bucket,
trivfs_protid_class, port_bucket,
&fsys);
mach_port_deallocate (mach_task_self (), bootstrap);
if (err)
error (3, err, "Contacting parent");
/* Launch. */
ports_manage_port_operations_multithread (port_bucket, exec_demuxer,
2 * 60 * 1000, 0, 0);
return 0;
}
开发者ID:dreamsxin,项目名称:GNU-Hurd,代码行数:60,代码来源:main.c
示例16: pid_to_task
static task_t pid_to_task(int pid) {
task_t task = 0;
static task_t old_task = 0;
static int old_pid = -1;
kern_return_t kr;
if (old_task != 0 && old_pid == pid) {
return old_task;
} else if (old_task != 0 && old_pid != pid) {
//we changed the process pid so deallocate a ref from the old_task
//since we are going to get a new task
kr = mach_port_deallocate (mach_task_self (), old_task);
if (kr != KERN_SUCCESS) {
eprintf ("pid_to_task: fail to deallocate port\n");
return 0;
}
}
int err = task_for_pid (mach_task_self (), (pid_t)pid, &task);
if ((err != KERN_SUCCESS) || !MACH_PORT_VALID (task)) {
task = task_for_pid_workaround (pid);
if (task == MACH_PORT_NULL) {
task = task_for_pid_ios9pangu (pid);
if (task != MACH_PORT_NULL) {
//eprintf ("Failed to get task %d for pid %d.\n", (int)task, (int)pid);
//eprintf ("Missing priviledges? 0x%x: %s\n", err, MACH_ERROR_STRING (err));
return -1;
}
}
}
old_task = task;
old_pid = pid;
return task;
}
开发者ID:ghostbar,项目名称:radare2.deb,代码行数:32,代码来源:io_mach.c
示例17: iokit_lookup_connect_ref
EXTERN io_object_t
iokit_lookup_connect_ref(io_object_t connectRef, ipc_space_t space)
{
io_object_t obj = NULL;
if (connectRef && MACH_PORT_VALID(CAST_MACH_PORT_TO_NAME(connectRef))) {
ipc_port_t port;
kern_return_t kr;
kr = ipc_object_translate(space, CAST_MACH_PORT_TO_NAME(connectRef), MACH_PORT_RIGHT_SEND, (ipc_object_t *)&port);
if (kr == KERN_SUCCESS) {
assert(IP_VALID(port));
ip_reference(port);
ip_unlock(port);
iokit_lock_port(port);
if (ip_active(port) && (ip_kotype(port) == IKOT_IOKIT_CONNECT)) {
obj = (io_object_t) port->ip_kobject;
iokit_add_connect_reference(obj);
}
iokit_unlock_port(port);
ip_release(port);
}
}
return obj;
}
开发者ID:wzw19890321,项目名称:xnu-1,代码行数:30,代码来源:iokit_rpc.c
示例18: port_name_to_semaphore
/*
* Routine: port_name_to_semaphore
* Purpose:
* Convert from a port name in the current space to a semaphore.
* Produces a semaphore ref, which may be null.
* Conditions:
* Nothing locked.
*/
kern_return_t
port_name_to_semaphore(
mach_port_name_t name,
semaphore_t *semaphorep)
{
ipc_port_t kern_port;
kern_return_t kr;
if (!MACH_PORT_VALID(name)) {
*semaphorep = SEMAPHORE_NULL;
return KERN_INVALID_NAME;
}
kr = ipc_object_translate(current_space(), name, MACH_PORT_RIGHT_SEND,
(ipc_object_t *) &kern_port);
if (kr != KERN_SUCCESS) {
*semaphorep = SEMAPHORE_NULL;
return kr;
}
/* have the port locked */
assert(IP_VALID(kern_port));
*semaphorep = convert_port_to_semaphore(kern_port);
ip_unlock(kern_port);
return KERN_SUCCESS;
}
开发者ID:JackieXie168,项目名称:xnu,代码行数:35,代码来源:ipc_sync.c
示例19: pid_to_task
task_t pid_to_task(int pid) {
static task_t old_pid = -1;
static task_t old_task = -1;
task_t task = -1;
int err;
/* xlr8! */
if (old_task != -1 && old_pid == pid)
return old_task;
err = task_for_pid (mach_task_self (), (pid_t)pid, &task);
if ((err != KERN_SUCCESS) || !MACH_PORT_VALID (task)) {
task = task_for_pid_workaround (pid);
if (task == -1) {
eprintf ("Failed to get task %d for pid %d.\n", (int)task, (int)pid);
eprintf ("Reason: 0x%x: %s\n", err, (char *)MACH_ERROR_STRING (err));
eprintf ("You probably need to run as root or sign the binary.\n"
" Read doc/ios.md || doc/osx.md\n"
" make -C binr/radare2 ios-sign || osx-sign\n");
return -1;
}
}
old_pid = pid;
old_task = task;
return task;
}
开发者ID:sparkhom,项目名称:radare2,代码行数:26,代码来源:xnu_debug.c
示例20: main
int main() {
mach_port_t process_to_write;
kern_return_t error;
if(getuid() && geteuid()) {
printf("You need to be root to vm_write!\n");
} else{
error = task_for_pid(mach_task_self(), PID, &process_to_write);
if ((error != KERN_SUCCESS) || !MACH_PORT_VALID(process_to_write)) {
printf("Error getting the process!\n");
}
mach_port_name_t task;
vm_map_offset_t vmoffset;
vm_map_size_t vmsize;
uint32_t nesting_depth = 0;
struct vm_region_submap_info_64 vbr;
mach_msg_type_number_t vbrcount = 16;
kern_return_t kr;
if ((kr = mach_vm_region_recurse(process_to_write, &vmoffset, &vmsize,
&nesting_depth,
(vm_region_recurse_info_t)&vbr,
&vbrcount)) != KERN_SUCCESS)
{
printf("Error");
}
printf("%p\n", (void *) (uintptr_t)vmoffset);
}
return 0;
}
开发者ID:erayarslan,项目名称:vm_write-Example,代码行数:34,代码来源:base.c
注:本文中的MACH_PORT_VALID函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论