Blame src/ldr/ntapi_ldr_load_system_dll.c

dd89bb
/********************************************************/
dd89bb
/*  ntapi: Native API core library                      */
dde53a
/*  Copyright (C) 2013--2017  Z. Gilboa                 */
dd89bb
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
dd89bb
/********************************************************/
dd89bb
dd89bb
#include <psxtypes/psxtypes.h>
dd89bb
#include <ntapi/nt_ldr.h>
dd89bb
#include <ntapi/ntapi.h>
dd89bb
#include "ntapi_impl.h"
dd89bb
dd89bb
int32_t	__stdcall __ntapi_ldr_load_system_dll(
dd89bb
	__in	void *			hsysdir		__optional,
dd89bb
	__in	wchar16_t *		base_name,
ee679a
	__in	uint16_t		base_name_size,
dd89bb
	__in	uint32_t *		image_flags	__optional,
dd89bb
	__out	void **			image_base)
dd89bb
{
dd89bb
	int32_t			status;
22238c
	wchar16_t *		sysdir;
22238c
	nt_unicode_string	nt_sysdir;
dd89bb
	nt_unicode_string	nt_image_name;
dd89bb
	uintptr_t		buffer[0x80];
dd89bb
c713d8
	(void)image_flags;
c713d8
dd89bb
	/* stack buffer */
22238c
	__ntapi->tt_aligned_block_memset(
22238c
		buffer,0,sizeof(buffer));
dd89bb
22238c
	sysdir = (wchar16_t *)buffer;
dd89bb
22238c
	if ((status = __ntapi->tt_get_system_directory_dos_path(
22238c
			hsysdir,
22238c
			sysdir,sizeof(buffer),
22238c
			0,0,&nt_sysdir)))
dd89bb
		return status;
dd89bb
22238c
	nt_image_name.strlen = base_name_size;
22238c
	nt_image_name.maxlen = base_name_size;
22238c
	nt_image_name.buffer = base_name;
22238c
22238c
	return __ntapi->ldr_load_dll(
22238c
		sysdir,0,
dd89bb
		&nt_image_name,
dd89bb
		image_base);
dd89bb
}