summaryrefslogtreecommitdiffhomepage
path: root/src/ldso/pe_terminate_current_process.c
blob: e7619380c9876428e6a049b25e8b36619231aab8 (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
/*****************************************************************************/
/*  pemagination: a (virtual) tour into portable bits and executable bytes   */
/*  Copyright (C) 2013--2020  SysDeer Technologies, LLC                      */
/*  Released under GPLv2 and GPLv3; see COPYING.PEMAGINE.                    */
/*****************************************************************************/

#include <psxtypes/psxtypes.h>
#include <pemagine/pemagine.h>
#include "pe_os.h"

int32_t pe_terminate_current_process(int32_t estatus)
{
	void *				hntdll;
	os_zw_terminate_process *	zw_terminate_process;

	/* init */
	if (!(hntdll = pe_get_ntdll_module_handle()))
		return OS_STATUS_INTERNAL_ERROR;

	if (!(zw_terminate_process = (os_zw_terminate_process *)pe_get_procedure_address(
			hntdll,"ZwTerminateProcess")))
		return OS_STATUS_INTERNAL_ERROR;

	return zw_terminate_process(
		OS_CURRENT_PROCESS_HANDLE,
		estatus);
}