|
|
52d60d |
/********************************************************/
|
|
|
52d60d |
/* ntcon: free-standing console interface definitions */
|
|
|
ab355e |
/* Copyright (C) 2013--2016 SysDeer Technologies, LLC */
|
|
|
52d60d |
/* Released under GPLv2 and GPLv3; see COPYING.NTCON. */
|
|
|
52d60d |
/********************************************************/
|
|
|
52d60d |
|
|
|
52d60d |
#include <pemagine/pemagine.h>
|
|
|
52d60d |
#include <ntcon/ntcon.h>
|
|
|
52d60d |
|
|
|
52d60d |
#define NT_STATUS_SUCCESS 0x00000000
|
|
|
52d60d |
#define NT_STATUS_INTERNAL_ERROR 0xC00000E5
|
|
|
52d60d |
|
|
|
52d60d |
#define NTCON_PTR_INIT(x,y) pvtbl->x = \
|
|
|
52d60d |
(ntcon_##x *)pe_get_procedure_address(hkernel, #y)
|
|
|
52d60d |
|
|
|
52d60d |
ntcon_api
|
|
|
52d60d |
int32_t __fastcall ntcon_vtbl_init(ntcon_vtbl * pvtbl)
|
|
|
52d60d |
{
|
|
|
52d60d |
void * hkernel;
|
|
|
52d60d |
|
|
|
52d60d |
if (!(hkernel = pe_get_kernel32_module_handle()))
|
|
|
52d60d |
return NT_STATUS_INTERNAL_ERROR;
|
|
|
52d60d |
|
|
|
52d60d |
/* console handles */
|
|
|
52d60d |
NTCON_PTR_INIT(alloc_console, AllocConsole);
|
|
|
52d60d |
NTCON_PTR_INIT(attach_console, AttachConsole);
|
|
|
52d60d |
NTCON_PTR_INIT(free_console, FreeConsole);
|
|
|
52d60d |
NTCON_PTR_INIT(get_std_handle, GetStdHandle);
|
|
|
52d60d |
|
|
|
52d60d |
/* read/write using std handles */
|
|
|
52d60d |
NTCON_PTR_INIT(get_number_of_console_input_events, GetNumberOfConsoleInputEvents);
|
|
|
52d60d |
NTCON_PTR_INIT(flush_console_input_buffer, FlushConsoleInputBuffer);
|
|
|
52d60d |
NTCON_PTR_INIT(peek_console_input_ansi, PeekConsoleInputA);
|
|
|
52d60d |
NTCON_PTR_INIT(peek_console_input_utf16, PeekConsoleInputW);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_ansi, ReadConsoleA);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_utf16, ReadConsoleW);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_input_ansi, ReadConsoleInputA);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_input_utf16, ReadConsoleInputW);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_output_ansi, ReadConsoleOutputA);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_output_utf16, ReadConsoleOutputW);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_ansi, WriteConsoleA);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_utf16, WriteConsoleW);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_input_ansi, WriteConsoleInputA);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_input_utf16, WriteConsoleInputW);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_output_ansi, WriteConsoleOutputA);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_output_utf16, WriteConsoleOutputW);
|
|
|
52d60d |
|
|
|
52d60d |
/* screen buffers */
|
|
|
52d60d |
NTCON_PTR_INIT(create_console_screen_buffer, CreateConsoleScreenBuffer);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_screen_buffer_info, GetConsoleScreenBufferInfo);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_screen_buffer_info_ex, GetConsoleScreenBufferInfoEx);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_screen_buffer_info_ex, SetConsoleScreenBufferInfoEx);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_screen_buffer_size, SetConsoleScreenBufferSize);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_active_screen_buffer, SetConsoleActiveScreenBuffer);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_window_info, SetConsoleWindowInfo);
|
|
|
52d60d |
NTCON_PTR_INIT(scroll_console_screen_buffer_ansi, ScrollConsoleScreenBufferA);
|
|
|
52d60d |
NTCON_PTR_INIT(scroll_console_screen_buffer_utf16, ScrollConsoleScreenBufferW);
|
|
|
52d60d |
|
|
|
52d60d |
/* code page */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_code_page, GetConsoleCP);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_code_page, SetConsoleCP);
|
|
|
52d60d |
|
|
|
52d60d |
/* console control */
|
|
|
52d60d |
NTCON_PTR_INIT(generate_console_ctrl_event, GenerateConsoleCtrlEvent);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_ctrl_handler, SetConsoleCtrlHandler);
|
|
|
52d60d |
|
|
|
52d60d |
/* interface mode */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_mode, GetConsoleMode);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_mode, SetConsoleMode);
|
|
|
52d60d |
|
|
|
52d60d |
/* console process list */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_process_list, GetConsoleProcessList);
|
|
|
52d60d |
|
|
|
52d60d |
/* aliases */
|
|
|
52d60d |
NTCON_PTR_INIT(add_console_alias_ansi, AddConsoleAliasA);
|
|
|
52d60d |
NTCON_PTR_INIT(add_console_alias_utf16, AddConsoleAliasW);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_alias_ansi, GetConsoleAliasA);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_alias_utf16, GetConsoleAliasW);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_aliases_ansi, GetConsoleAliasesA);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_aliases_utf16, GetConsoleAliasesW);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_aliases_length_ansi, GetConsoleAliasesLengthA);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_aliases_length_utf16, GetConsoleAliasesLengthW);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_alias_exes_ansi, GetConsoleAliasExesA);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_alias_exes_utf16, GetConsoleAliasExesW);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_alias_exes_length_ansi, GetConsoleAliasExesLengthA);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_alias_exes_length_utf16, GetConsoleAliasExesLengthW);
|
|
|
52d60d |
|
|
|
52d60d |
/* output attributes */
|
|
|
52d60d |
NTCON_PTR_INIT(fill_console_output_attribute, FillConsoleOutputAttribute);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_output_attribute, ReadConsoleOutputAttribute);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_output_attribute, WriteConsoleOutputAttribute);
|
|
|
52d60d |
|
|
|
52d60d |
/* output characters */
|
|
|
52d60d |
NTCON_PTR_INIT(fill_console_output_character_ansi, FillConsoleOutputCharacterA);
|
|
|
52d60d |
NTCON_PTR_INIT(fill_console_output_character_utf16, FillConsoleOutputCharacterW);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_output_character_ansi, ReadConsoleOutputCharacterA);
|
|
|
52d60d |
NTCON_PTR_INIT(read_console_output_character_utf16, ReadConsoleOutputCharacterW);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_output_character_ansi, WriteConsoleOutputCharacterA);
|
|
|
52d60d |
NTCON_PTR_INIT(write_console_output_character_utf16, WriteConsoleOutputCharacterW);
|
|
|
52d60d |
|
|
|
52d60d |
/* output code page */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_output_code_page, GetConsoleOutputCP);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_output_code_page, SetConsoleOutputCP);
|
|
|
52d60d |
|
|
|
52d60d |
/* text attributes */
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_text_attribute, SetConsoleTextAttribute);
|
|
|
52d60d |
|
|
|
52d60d |
/* cursor info */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_cursor_info, GetConsoleCursorInfo);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_cursor_info, SetConsoleCursorInfo);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_cursor_position, SetConsoleCursorPosition);
|
|
|
52d60d |
|
|
|
52d60d |
/* selection info */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_selection_info, GetConsoleSelectionInfo);
|
|
|
52d60d |
|
|
|
52d60d |
/* history info */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_history_info, GetConsoleHistoryInfo);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_history_info, SetConsoleHistoryInfo);
|
|
|
52d60d |
|
|
|
52d60d |
/* font info */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_font_size, GetConsoleFontSize);
|
|
|
52d60d |
NTCON_PTR_INIT(get_current_console_font, GetCurrentConsoleFont);
|
|
|
52d60d |
NTCON_PTR_INIT(get_current_console_font_ex, GetCurrentConsoleFontEx);
|
|
|
52d60d |
NTCON_PTR_INIT(set_current_console_font_ex, SetCurrentConsoleFontEx);
|
|
|
52d60d |
|
|
|
52d60d |
/* mouse capabilities */
|
|
|
52d60d |
NTCON_PTR_INIT(get_number_of_console_mouse_buttons, GetNumberOfConsoleMouseButtons);
|
|
|
52d60d |
|
|
|
52d60d |
/* window information */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_window, GetConsoleWindow);
|
|
|
52d60d |
NTCON_PTR_INIT(get_largest_console_window_size, GetLargestConsoleWindowSize);
|
|
|
52d60d |
|
|
|
52d60d |
/* console api: display mode */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_display_mode, GetConsoleDisplayMode);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_display_mode, SetConsoleDisplayMode);
|
|
|
52d60d |
|
|
|
52d60d |
/* console title */
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_title_ansi, GetConsoleTitleA);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_title_utf16, GetConsoleTitleW);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_title_ansi, SetConsoleTitleA);
|
|
|
52d60d |
NTCON_PTR_INIT(set_console_title_utf16, SetConsoleTitleW);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_original_title_ansi, GetConsoleOriginalTitleA);
|
|
|
52d60d |
NTCON_PTR_INIT(get_console_original_title_utf16, GetConsoleOriginalTitleW);
|
|
|
52d60d |
|
|
|
52d60d |
return NT_STATUS_SUCCESS;
|
|
|
52d60d |
}
|