Blob Blame History Raw
/********************************************************/
/*  ntapi: Native API core library                      */
/*  Copyright (C) 2013--2021  SysDeer Technologies, LLC */
/*  Released under GPLv2 and GPLv3; see COPYING.NTAPI.  */
/********************************************************/

#ifndef ___NTAPI_FNAPI_H_
#define ___NTAPI_FNAPI_H_

#include <psxtypes/psxtypes.h>
#include <ntapi/ntapi.h>
#include "ntapi_hash_table.h"

#ifdef __cplusplus
extern "C" {
#endif

#define NTAPI_UFN(fn)   __attr_protected__ ntapi_##fn __ntapi_##fn
#define NTAPI_SFN(fn)   __attr_protected__ ntapi_##fn __ntapi_tt_##fn
#define NTAPI_VFN(fn,v) __attr_protected__ ntapi_##fn __ntapi_##fn##_##v

/* internal prototypes */
typedef int32_t __stdcall ntapi_tt_create_remote_runtime_data(
	__in		void *				hprocess,
	__in_out	nt_runtime_data_block *		runtime_data);

typedef void ** __cdecl ntapi_tt_get_csr_port_handle_addr_by_logic(void);

/* nt_object.h */
NTAPI_UFN(tt_open_ipc_object_directory);
NTAPI_UFN(tt_create_ipc_object_directory_entry);
NTAPI_UFN(tt_open_dev_object_directory);
NTAPI_UFN(tt_create_dev_object_directory_entry);
NTAPI_UFN(tt_create_keyed_object_directory);
NTAPI_UFN(tt_open_keyed_object_directory);
NTAPI_UFN(tt_create_keyed_object_directory_entry);
NTAPI_UFN(tt_keyed_object_to_key);
NTAPI_UFN(tt_sid_copy);
NTAPI_UFN(tt_sid_compare);

/* nt_crc32.h */
NTAPI_UFN(tt_buffer_crc32);
NTAPI_UFN(tt_mbstr_crc32);
NTAPI_UFN(tt_crc32_table);

/* nt_crc64.h */
NTAPI_UFN(tt_buffer_crc64);
NTAPI_UFN(tt_mbstr_crc64);
NTAPI_UFN(tt_crc64_table);

/* nt_file.h */
NTAPI_UFN(tt_get_file_handle_type);
NTAPI_UFN(tt_open_logical_parent_directory);
NTAPI_UFN(tt_open_physical_parent_directory);
NTAPI_UFN(tt_open_volume_by_guid);


/* nt_ipc.h */
NTAPI_UFN(ipc_connect_by_attr);
NTAPI_UFN(ipc_connect_by_name);
NTAPI_UFN(ipc_connect_by_symlink);
NTAPI_UFN(ipc_connect_by_port);
NTAPI_UFN(ipc_connect_section_by_attr);
NTAPI_UFN(ipc_connect_section_by_name);
NTAPI_UFN(ipc_connect_section_by_symlink);
NTAPI_UFN(ipc_connect_section_by_port);
NTAPI_UFN(ipc_get_port_by_attr);
NTAPI_UFN(ipc_get_port_section_by_attr);
NTAPI_UFN(ipc_init_section_by_port);
NTAPI_UFN(ipc_disconnect_unmap_section_by_port);
NTAPI_VFN(ipc_create_pipe,v1);
NTAPI_VFN(ipc_create_pipe,v2);

/* nt_sem.h */
NTAPI_UFN(sem_create);
NTAPI_UFN(sem_open);
NTAPI_UFN(sem_fcntl);
NTAPI_UFN(sem_ioctl);
NTAPI_UFN(sem_query);
NTAPI_UFN(sem_set);
NTAPI_UFN(sem_cancel);
NTAPI_UFN(sem_free);

/* nt_msq.h */
NTAPI_UFN(msq_create);
NTAPI_UFN(msq_open);
NTAPI_UFN(msq_send);
NTAPI_UFN(msq_recv);
NTAPI_UFN(msq_fcntl);
NTAPI_UFN(msq_ioctl);
NTAPI_UFN(msq_query);
NTAPI_UFN(msq_set);
NTAPI_UFN(msq_cancel);
NTAPI_UFN(msq_free);

/* nt_afl.h */
NTAPI_UFN(afl_create);
NTAPI_UFN(afl_open);
NTAPI_UFN(afl_fcntl);
NTAPI_UFN(afl_ioctl);
NTAPI_UFN(afl_query);
NTAPI_UFN(afl_set);
NTAPI_UFN(afl_cancel);
NTAPI_UFN(afl_free);

/* nt_ldr */
NTAPI_UFN(ldr_load_system_dll);
NTAPI_UFN(ldr_create_state_snapshot);
NTAPI_UFN(ldr_revert_state_to_snapshot);

/* nt_string.h */
NTAPI_UFN(tt_string_null_offset_multibyte);
NTAPI_UFN(tt_string_null_offset_short);
NTAPI_UFN(tt_string_null_offset_dword);
NTAPI_UFN(tt_string_null_offset_qword);
NTAPI_UFN(tt_string_null_offset_ptrsize);
NTAPI_UFN(tt_strcmp_multibyte);
NTAPI_UFN(tt_strcmp_utf16);
NTAPI_UFN(tt_strncmp_multibyte);
NTAPI_UFN(tt_strncmp_utf16);
NTAPI_UFN(tt_aligned_block_memset);
NTAPI_UFN(tt_aligned_block_memcpy);
NTAPI_UFN(tt_aligned_block_memlock);
NTAPI_UFN(tt_init_unicode_string_from_utf16);
NTAPI_UFN(tt_memcpy_utf16);
NTAPI_UFN(tt_aligned_memcpy_utf16);
NTAPI_UFN(tt_generic_memset);
NTAPI_UFN(tt_generic_memcpy);
NTAPI_UFN(tt_uint16_to_hex_utf16);
NTAPI_UFN(tt_uint32_to_hex_utf16);
NTAPI_UFN(tt_uint64_to_hex_utf16);
NTAPI_UFN(tt_uintptr_to_hex_utf16);

NTAPI_UFN(tt_hex_utf16_to_uint16);
NTAPI_UFN(tt_hex_utf16_to_uint32);
NTAPI_UFN(tt_hex_utf16_to_uint64);
NTAPI_UFN(tt_hex_utf16_to_uintptr);

NTAPI_UFN(tt_hex_utf8_to_uint16);
NTAPI_UFN(tt_hex_utf8_to_uint32);
NTAPI_UFN(tt_hex_utf8_to_uint64);
NTAPI_UFN(tt_hex_utf8_to_uintptr);

NTAPI_UFN(tt_uint16_to_hex_utf8);
NTAPI_UFN(tt_uint32_to_hex_utf8);
NTAPI_UFN(tt_uint64_to_hex_utf8);
NTAPI_UFN(tt_uintptr_to_hex_utf8);
NTAPI_UFN(tt_uintptr_to_dec_utf16);
NTAPI_UFN(tt_uintptr_to_dec_utf8);
NTAPI_UFN(tt_uintptr_to_dec_null_utf16);
NTAPI_UFN(tt_uintptr_to_dec_null_utf8);
NTAPI_UFN(tt_dec_utf16_to_uint16);
NTAPI_UFN(tt_dec_utf16_to_uint32);
NTAPI_UFN(tt_dec_utf16_to_uint64);
NTAPI_UFN(tt_dec_utf16_to_uintptr);
NTAPI_SFN(wcslen);

/* nt_guid.h */
NTAPI_UFN(tt_guid_to_string_utf16);
NTAPI_UFN(tt_string_to_guid_utf16);
NTAPI_UFN(tt_string_to_guid_utf8);

/* nt_sysinfo.h */
NTAPI_UFN(tt_get_system_directory_native_path);
NTAPI_UFN(tt_get_system_directory_dos_path);
NTAPI_UFN(tt_get_system_directory_handle);
NTAPI_UFN(tt_get_system_info_snapshot);

/* nt_thread.h */
NTAPI_UFN(tt_create_thread);
NTAPI_UFN(tt_create_local_thread);
NTAPI_UFN(tt_create_remote_thread);

/* nt_process.h */
NTAPI_UFN(tt_fork);
NTAPI_VFN(tt_fork,v1);
NTAPI_VFN(tt_fork,v2);
NTAPI_UFN(tt_create_remote_process_params);
NTAPI_UFN(tt_create_remote_runtime_data);
NTAPI_VFN(tt_create_native_process,v1);
NTAPI_VFN(tt_create_native_process,v2);
NTAPI_UFN(tt_spawn_native_process);
NTAPI_UFN(tt_spawn_foreign_process);
NTAPI_UFN(tt_get_runtime_data);
NTAPI_UFN(tt_init_runtime_data);
NTAPI_UFN(tt_update_runtime_data);
NTAPI_UFN(tt_exec_map_image_as_data);
NTAPI_UFN(tt_exec_unmap_image);

/* nt_token.h */
NTAPI_UFN(tt_enable_token_privilege);
NTAPI_UFN(tt_disable_token_privilege);

/* nt_section.h */
NTAPI_UFN(tt_get_section_name);

/* nt_sync.h */
NTAPI_UFN(tt_create_inheritable_event);
NTAPI_UFN(tt_create_private_event);
NTAPI_UFN(tt_wait_for_dummy_event);

/* nt_port.h */
NTAPI_UFN(tt_port_guid_from_type);
NTAPI_UFN(tt_port_type_from_guid);
NTAPI_UFN(tt_port_generate_keys);
NTAPI_UFN(tt_port_format_keys);
NTAPI_UFN(tt_port_name_from_attr);
NTAPI_UFN(tt_port_attr_from_name);
NTAPI_UFN(tt_port_attr_from_string);
NTAPI_UFN(tt_port_attr_from_symlink);

/* nt_argv.h */
NTAPI_UFN(tt_get_cmd_line_utf16);
NTAPI_UFN(tt_get_peb_env_block_utf16);
NTAPI_UFN(tt_parse_cmd_line_args_utf16);
NTAPI_UFN(tt_get_argv_envp_utf8);
NTAPI_UFN(tt_get_argv_envp_utf16);
NTAPI_UFN(tt_get_env_var_meta_utf8);
NTAPI_UFN(tt_get_env_var_meta_utf16);
NTAPI_UFN(tt_array_copy_utf8);
NTAPI_UFN(tt_array_copy_utf16);
NTAPI_UFN(tt_array_convert_utf8_to_utf16);
NTAPI_UFN(tt_array_convert_utf16_to_utf8);

/* nt_blitter.h */
NTAPI_UFN(blt_alloc);
NTAPI_UFN(blt_free);
NTAPI_UFN(blt_acquire);
NTAPI_UFN(blt_obtain);
NTAPI_UFN(blt_possess);
NTAPI_UFN(blt_release);
NTAPI_UFN(blt_get);
NTAPI_UFN(blt_set);

/* nt_unicode.h */
NTAPI_UFN(uc_validate_unicode_stream_utf8);
NTAPI_UFN(uc_validate_unicode_stream_utf16);
NTAPI_UFN(uc_get_code_point_byte_count_utf8);
NTAPI_UFN(uc_get_code_point_byte_count_utf16);
NTAPI_UFN(uc_convert_unicode_stream_utf8_to_utf16);
NTAPI_UFN(uc_convert_unicode_stream_utf8_to_utf32);
NTAPI_UFN(uc_convert_unicode_stream_utf16_to_utf8);
NTAPI_UFN(uc_convert_unicode_stream_utf16_to_utf32);


/* nt_daemon.h */
NTAPI_UFN(dsr_init);
NTAPI_UFN(dsr_create_port);

/* nt_acl.h */
NTAPI_UFN(acl_init_common_descriptor);
NTAPI_UFN(acl_init_common_descriptor_meta);

/* nt_vfd.h */
NTAPI_UFN(vfd_dev_name_init);

/* nt_tty.h */
NTAPI_UFN(tty_create_session);
NTAPI_UFN(tty_join_session);
NTAPI_UFN(tty_connect);
NTAPI_UFN(tty_client_session_disconnect);
NTAPI_UFN(tty_client_session_query);
NTAPI_UFN(tty_client_session_set);
NTAPI_UFN(tty_client_process_register);
NTAPI_UFN(tty_query_information_section);
NTAPI_UFN(tty_query_information_server);
NTAPI_UFN(tty_query_information_service);
NTAPI_UFN(tty_query_server_pts_slot_info);
NTAPI_UFN(tty_request_peer);
NTAPI_UFN(pty_open);
NTAPI_UFN(pty_open_pair);
NTAPI_UFN(pty_reopen);
NTAPI_UFN(pty_inherit );
NTAPI_UFN(pty_inherit_runtime_ctty );
NTAPI_UFN(pty_close);
NTAPI_UFN(pty_read);
NTAPI_UFN(pty_write);
NTAPI_UFN(pty_ioctl);
NTAPI_UFN(pty_query);
NTAPI_UFN(pty_xquery);
NTAPI_UFN(pty_set);
NTAPI_UFN(pty_cancel);

/* nt_socket.h */
NTAPI_VFN(sc_socket,v1);
NTAPI_VFN(sc_socket,v2);
NTAPI_VFN(sc_bind,v1);
NTAPI_VFN(sc_bind,v2);
NTAPI_VFN(sc_connect,v1);
NTAPI_VFN(sc_connect,v2);
NTAPI_VFN(sc_getsockname,v1);
NTAPI_VFN(sc_getsockname,v2);
NTAPI_VFN(sc_getpeername,v1);
NTAPI_VFN(sc_getpeername,v2);
NTAPI_VFN(sc_server_accept_connection,v1);
NTAPI_VFN(sc_server_accept_connection,v2);
NTAPI_UFN(sc_server_duplicate_socket);
NTAPI_UFN(sc_setsockopt);
NTAPI_UFN(sc_getsockopt);
NTAPI_UFN(sc_listen);
NTAPI_UFN(sc_accept);
NTAPI_UFN(sc_send);
NTAPI_UFN(sc_recv);
NTAPI_UFN(sc_shutdown);
NTAPI_UFN(sc_wait);

/* nt_mount.h */
NTAPI_UFN(tt_get_dos_drive_device_handle);
NTAPI_UFN(tt_get_dos_drive_root_handle);
NTAPI_UFN(tt_get_dos_drive_device_name);
NTAPI_UFN(tt_get_dos_drive_mount_points);
NTAPI_UFN(tt_dev_mount_points_to_statfs);
NTAPI_UFN(tt_get_dos_drive_letter_from_device);

/* nt_istat.h */
NTAPI_UFN(tt_istat);

/* nt_stat.h */
NTAPI_UFN(tt_stat);

/* nt_statfs.h */
NTAPI_UFN(tt_statfs);

/* nt_hashes.h */
NTAPI_UFN(tt_populate_hashed_import_table);

/* nt_guid.h */
NTAPI_UFN(tt_guid_copy);
NTAPI_UFN(tt_guid_compare);
NTAPI_UFN(tt_guid_to_string_utf16);
NTAPI_UFN(tt_string_to_guid_utf16);
NTAPI_UFN(tt_guid_to_string_utf8);
NTAPI_UFN(tt_string_to_guid_utf8);

/* log */
NTAPI_UFN(log_write);
NTAPI_UFN(log_fn_call);
NTAPI_UFN(log_msg);

/* debug */
NTAPI_UFN(tt_debug_create_object);
NTAPI_UFN(tt_debug_create_attach_object);
NTAPI_UFN(tt_debug_execution_flow);
NTAPI_UFN(tt_debug_break_process);

/* csrss */
NTAPI_VFN(tt_get_csr_port_handle_addr_by_logic,i386);
NTAPI_VFN(tt_get_csr_port_handle_addr_by_logic,x86_64);
NTAPI_UFN(csr_port_handle);

#ifdef __cplusplus
}
#endif
#endif