示例#1
0
static
load_return_t
load_threadstack(
	thread_t	thread,
	uint32_t	*ts,
	uint32_t	total_size,
	mach_vm_offset_t	*user_stack,
	int *customstack
)
{
	kern_return_t	ret;
	uint32_t	size;
	int		flavor;
	uint32_t	stack_size;

	while (total_size > 0) {
		flavor = *ts++;
		size = *ts++;
		if (UINT32_MAX-2 < size ||
		    UINT32_MAX/sizeof(uint32_t) < size+2)
			return (LOAD_BADMACHO);
		stack_size = (size+2)*sizeof(uint32_t);
		if (stack_size > total_size)
			return(LOAD_BADMACHO);
		total_size -= stack_size;

		/*
		 * Third argument is a kernel space pointer; it gets cast
		 * to the appropriate type in thread_userstack() based on
		 * the value of flavor.
		 */
		ret = thread_userstack(thread, flavor, (thread_state_t)ts, size, user_stack, customstack);
		if (ret != KERN_SUCCESS) {
			return(LOAD_FAILURE);
		}
		ts += size;	/* ts is a (uint32_t *) */
	}
	return(LOAD_SUCCESS);
}
示例#2
0
static
load_return_t
load_threadstack(
    thread_t	thread,
    unsigned long	*ts,
    unsigned long	total_size,
    user_addr_t	*user_stack,
    int *customstack
)
{
    kern_return_t	ret;
    unsigned long	size;
    int		flavor;
    unsigned long	stack_size;

    while (total_size > 0) {
        flavor = *ts++;
        size = *ts++;
        stack_size = (size+2)*sizeof(unsigned long);
        if (stack_size > total_size)
            return(LOAD_BADMACHO);
        total_size -= stack_size;

        /*
         * Third argument is a kernel space pointer; it gets cast
         * to the appropriate type in thread_userstack() based on
         * the value of flavor.
         */
        ret = thread_userstack(thread, flavor, (thread_state_t)ts, size, user_stack, customstack);
        if (ret != KERN_SUCCESS) {
            return(LOAD_FAILURE);
        }
        ts += size;	/* ts is a (unsigned long *) */
    }
    return(LOAD_SUCCESS);
}