Esempio n. 1
0
Console::Console()
  : impl(new Impl())
{
    // Get current text attributes.
    CONSOLE_SCREEN_BUFFER_INFO info;
    GetConsoleScreenBufferInfo(get_device_handle(StdOut), &info);
    impl->m_default_attributes[StdOut] = info.wAttributes;
    GetConsoleScreenBufferInfo(get_device_handle(StdErr), &info);
    impl->m_default_attributes[StdErr] = info.wAttributes;
}
Esempio n. 2
0
void Console::set_text_color(
    const Device    device,
    const Color     color)
{
    assert(device < NumDevices);
    if (color == DefaultColor)
    {
        SetConsoleTextAttribute(
            get_device_handle(device),
            impl->m_default_attributes[device]);
    }
    else
    {
        SetConsoleTextAttribute(
            get_device_handle(device),
            get_color_code(color));
    }
}
Esempio n. 3
0
void c_tun_device_windows::init() {
	_fact("Creating TUN/TAP (windows version)");

	m_guid = get_device_guid();
	_fact("GUID " << to_string(m_guid));
	m_handle = get_device_handle();
	m_stream_handle_ptr = std::make_unique<boost::asio::windows::stream_handle>(m_ioservice, m_handle);
	m_mac_address = get_mac(m_handle);

	m_buffer.fill(0);
	if (!m_stream_handle_ptr->is_open()) throw std::runtime_error("TUN/TAP stream handle open error");
	_fact("Start reading from TUN");
	m_stream_handle_ptr->async_read_some(boost::asio::buffer(m_buffer),
			boost::bind(&c_tun_device_windows::handle_read, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}