diff options
author | midipix <writeonce@midipix.org> | 2017-01-29 01:48:24 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2017-01-28 21:54:01 -0500 |
commit | dd1a85ac7ce0c3e2aa16243c73a9aaae7da384fb (patch) | |
tree | ae6c61035a6af4dcdb6c320c18d579f498362799 | |
parent | 3a475bed2393e3c5d4782ede3fc6549f2e38ce26 (diff) | |
download | pemagine-dd1a85ac7ce0c3e2aa16243c73a9aaae7da384fb.tar.bz2 pemagine-dd1a85ac7ce0c3e2aa16243c73a9aaae7da384fb.tar.xz |
ldso: added pe_terminate_current_process().
-rw-r--r-- | include/pemagine/pemagine.h | 4 | ||||
-rw-r--r-- | project/common.mk | 1 | ||||
-rw-r--r-- | src/internal/pe_os.h | 6 | ||||
-rw-r--r-- | src/ldso/pe_terminate_current_process.c | 27 |
4 files changed, 38 insertions, 0 deletions
diff --git a/include/pemagine/pemagine.h b/include/pemagine/pemagine.h index 781ef59..e88e244 100644 --- a/include/pemagine/pemagine.h +++ b/include/pemagine/pemagine.h @@ -286,6 +286,10 @@ pe_api int32_t pe_open_physical_parent_directory( uint32_t open_options); +pe_api int32_t pe_terminate_current_process( + int32_t estatus); + + #ifdef __cplusplus } #endif diff --git a/project/common.mk b/project/common.mk index bf0e5af..719394e 100644 --- a/project/common.mk +++ b/project/common.mk @@ -16,6 +16,7 @@ API_SRCS = \ src/ldso/pe_load_framework_loader.c \ src/ldso/pe_open_image_from_addr.c \ src/ldso/pe_open_physical_parent_directory.c \ + src/ldso/pe_terminate_current_process.c \ src/meta/pe_get_image_stack_heap_info.c \ src/meta/pe_get_symbol_module_info.c \ src/meta/pe_get_symbol_name.c \ diff --git a/src/internal/pe_os.h b/src/internal/pe_os.h index ba7da0e..449433e 100644 --- a/src/internal/pe_os.h +++ b/src/internal/pe_os.h @@ -158,10 +158,16 @@ typedef int32_t __stdcall os_zw_open_file( __in uint32_t share_access, __in uint32_t open_options); + typedef int32_t __stdcall os_ldr_load_dll( __in wchar16_t * image_path __optional, __in uint32_t * image_flags __optional, __in struct pe_unicode_str * image_name, __out void ** image_base); + +typedef int32_t __stdcall os_zw_terminate_process( + __in void * hprocess, + __in int32_t status); + #endif diff --git a/src/ldso/pe_terminate_current_process.c b/src/ldso/pe_terminate_current_process.c new file mode 100644 index 0000000..ce0294d --- /dev/null +++ b/src/ldso/pe_terminate_current_process.c @@ -0,0 +1,27 @@ +/*****************************************************************************/ +/* pemagination: a (virtual) tour into portable bits and executable bytes */ +/* Copyright (C) 2013--2017 Z. Gilboa */ +/* 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); +} |