summaryrefslogtreecommitdiffhomepage
path: root/src/ldr/ntapi_ldr_load_system_dll.c
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2015-07-27 04:01:18 -0400
committermidipix <writeonce@midipix.org>2015-07-27 04:01:18 -0400
commitdd89bb8ad4fe184a34b5dbdda237e640fc82121b (patch)
tree5e80d2da35f5892f92be29f57982b2708e6bd99b /src/ldr/ntapi_ldr_load_system_dll.c
parentdcdadc2702712fa750ed255ed1dfa354522797a0 (diff)
downloadntapi-dd89bb8ad4fe184a34b5dbdda237e640fc82121b.tar.bz2
ntapi-dd89bb8ad4fe184a34b5dbdda237e640fc82121b.tar.xz
entered advanced internal development stage.
Diffstat (limited to 'src/ldr/ntapi_ldr_load_system_dll.c')
-rw-r--r--src/ldr/ntapi_ldr_load_system_dll.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/ldr/ntapi_ldr_load_system_dll.c b/src/ldr/ntapi_ldr_load_system_dll.c
new file mode 100644
index 0000000..d417590
--- /dev/null
+++ b/src/ldr/ntapi_ldr_load_system_dll.c
@@ -0,0 +1,44 @@
+/********************************************************/
+/* ntapi: Native API core library */
+/* Copyright (C) 2013,2014,2015 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;
+}