Ejemplo n.º 1
0
// pg 108
NTSTATUS NTAPI NtMapViewOfSection(
	HANDLE SectionHandle,
	HANDLE ProcessHandle,
	PVOID *BaseAddress,
	ULONG ZeroBits,
	ULONG CommitSize,
	PLARGE_INTEGER SectionOffset,
	PULONG ViewSize,
	SECTION_INHERIT InheritDisposition,
	ULONG AllocationType,
	ULONG Protect )
{
	process_t *p = NULL;
	BYTE *addr = NULL;
	NTSTATUS r;

	trace("%p %p %p %lu %08lx %p %p %u %08lx %08lx\n",
			SectionHandle, ProcessHandle, BaseAddress, ZeroBits, CommitSize,
			SectionOffset, ViewSize, InheritDisposition, AllocationType, Protect );

	r = process_from_handle( ProcessHandle, &p );
	if (r < STATUS_SUCCESS)
		return r;

	section_t *section = 0;
	r = object_from_handle( section, SectionHandle, 0 );
	if (r < STATUS_SUCCESS)
		return r;

	r = copy_from_user( &addr, BaseAddress, sizeof addr );
	if (r < STATUS_SUCCESS)
		return r;

	if (addr)
		trace("requested specific address %p\n", addr);

	r = verify_for_write( ViewSize, sizeof *ViewSize );
	if (r < STATUS_SUCCESS)
		return r;

	r = section->mapit( p->vm, addr, ZeroBits,
						MEM_COMMIT | (AllocationType&MEM_TOP_DOWN), Protect );
	if (r < STATUS_SUCCESS)
		return r;

	r = copy_to_user( BaseAddress, &addr, sizeof addr );

	trace("mapped at %p\n", addr );

	return r;
}
Ejemplo n.º 2
0
NTSTATUS NTAPI NtCreateThread(
	PHANDLE Thread,
	ACCESS_MASK DesiredAccess,
	POBJECT_ATTRIBUTES ObjectAttributes,
	HANDLE Process,
	PCLIENT_ID ClientId,
	PCONTEXT Context,
	PINITIAL_TEB InitialTeb,
	BOOLEAN CreateSuspended )
{
	INITIAL_TEB init_teb;
	CONTEXT ctx;
	NTSTATUS r;
	process_t *p;
	thread_t *t = NULL;
	CLIENT_ID id;

	dprintf("%p %08lx %p %p %p %p %p %d\n", Thread, DesiredAccess, ObjectAttributes,
			Process, ClientId, Context, InitialTeb, CreateSuspended);

	r = copy_from_user( &ctx, Context, sizeof ctx );
	if (r < STATUS_SUCCESS)
		return r;

	r = copy_from_user( &init_teb, InitialTeb, sizeof init_teb );
	if (r < STATUS_SUCCESS)
		return r;

	r = process_from_handle( Process, &p );
	if (r < STATUS_SUCCESS)
		return r;

	memset( &id, 0, sizeof id );
	r = create_thread( &t, p, &id, &ctx, &init_teb, CreateSuspended );

	if (r == STATUS_SUCCESS)
	{
		r = alloc_user_handle( t, DesiredAccess, Thread );
		release( t );
	}

	if (r == STATUS_SUCCESS)
		r = copy_to_user( ClientId, &id, sizeof id );

	return r;
}
Ejemplo n.º 3
0
NTSTATUS NTAPI NtUnmapViewOfSection(
	HANDLE ProcessHandle,
	PVOID BaseAddress )
{
	process_t *p = NULL;
	NTSTATUS r;

	trace("%p %p\n", ProcessHandle, BaseAddress );

	r = process_from_handle( ProcessHandle, &p );
	if (r < STATUS_SUCCESS)
		return r;

	r = p->vm->unmap_view( BaseAddress );

	return r;
}