pykd/pykd/dbgio.cpp
SND\kernelnet_cp 5ef445611c [0.1.x] added : !pycmd implementation
git-svn-id: https://pykd.svn.codeplex.com/svn@70280 9b283d60-5439-405e-af05-b73fd8c4d996
2017-11-08 17:06:26 +04:00

127 lines
3.0 KiB
C++

#include "stdafx.h"
#include <iostream>
#include "dbgio.h"
#include "dbgclient.h"
#include "windbg.h"
namespace pykd {
///////////////////////////////////////////////////////////////////////////////////
void DebugClient::dprint( const std::wstring &str, bool dml )
{
if ( WindbgGlobalSession::isInit() )
{
for ( size_t i = 0; i < str.size() / 100 + 1; ++i )
{
m_control->ControlledOutputWide(
dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL,
L"%ws",
str.substr( i*100, min( str.size() - i*100, 100 ) ).c_str()
);
}
}
else
{
std::wcout << str;
}
}
void dprint( const std::wstring &str, bool dml )
{
g_dbgClient->dprint( str, dml );
}
///////////////////////////////////////////////////////////////////////////////////
void DebugClient::dprintln( const std::wstring &str, bool dml )
{
this->dprint( str + L"\r\n", dml );
}
void dprintln( const std::wstring &str, bool dml )
{
g_dbgClient->dprintln( str, dml );
}
///////////////////////////////////////////////////////////////////////////////////
void DebugClient::eprint( const std::wstring &str )
{
if ( WindbgGlobalSession::isInit() )
{
for ( size_t i = 0; i < str.size() / 100 + 1; ++i )
{
m_control->OutputWide(
DEBUG_OUTPUT_ERROR,
L"%ws",
str.substr( i*100, min( str.size() - i*100, 100 ) ).c_str()
);
}
}
else
{
std::wcerr << str;
}
}
void eprint( const std::wstring &str )
{
g_dbgClient->eprint( str );
}
///////////////////////////////////////////////////////////////////////////////////
void DebugClient::eprintln( const std::wstring &str )
{
this->eprint( str + L"\r\n");
}
void eprintln( const std::wstring &str )
{
g_dbgClient->eprintln( str );
}
///////////////////////////////////////////////////////////////////////////////////
void
DbgOut::write( const std::wstring &str )
{
if ( WindbgGlobalSession::isInit() )
{
for ( size_t i = 0; i < str.size() / 100 + 1; ++i )
{
m_control->ControlledOutputWide(
DEBUG_OUTCTL_AMBIENT_TEXT,
DEBUG_OUTPUT_NORMAL,
L"%ws",
str.substr( i*100, min( str.size() - i*100, 100 ) ).c_str()
);
}
}
else
{
std::wcerr << str;
}
}
///////////////////////////////////////////////////////////////////////////////////
std::string
DbgIn::readline()
{
char str[0x100];
ULONG inputSize = 0;
m_control->Input( str, sizeof(str), &inputSize );
return std::string( str ) + "\n";
}
///////////////////////////////////////////////////////////////////////////////////
}; // namesapce pykd