summaryrefslogtreecommitdiffhomepage
path: root/src/ldr/ntapi_ldr_load_system_dll.c
blob: 1bd2bbc0b4312f0ac3fed2e72eaf52607c6cda19 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/********************************************************/
/*  ntapi: Native API core library                      */
/*  Copyright (C) 2013--2016  Z. Gilboa                 */
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
/********************************************************/

#include <psxtypes/psxtypes.h>
#include <ntapi/nt_ldr.h>
#include <ntapi/ntapi.h>
#include "ntapi_impl.h"

int32_t	__stdcall __ntapi_ldr_load_system_dll(
	__in	void *			hsysdir		__optional,
	__in	wchar16_t *		base_name,
	__in	uint32_t		base_name_size,
	__in	uint32_t *		image_flags	__optional,
	__out	void **			image_base)
{
	int32_t			status;
	nt_unicode_string	nt_image_name;
	uintptr_t		buffer[0x80];

	/* stack buffer */
	__ntapi->tt_aligned_block_memset(buffer,0,sizeof(buffer));

	status = __ntapi->tt_get_system_directory_dos_path(
		hsysdir,
		(wchar16_t *)buffer,
		sizeof(buffer),
		base_name,
		base_name_size,
		&nt_image_name);

	if (status != NT_STATUS_SUCCESS)
		return status;

	status = __ntapi->ldr_load_dll(
		0,
		0,
		&nt_image_name,
		image_base);

	return status;
}