本文整理汇总了C++中InStream::in_check_rem方法的典型用法代码示例。如果您正苦于以下问题:C++ InStream::in_check_rem方法的具体用法?C++ InStream::in_check_rem怎么用?C++ InStream::in_check_rem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InStream
的用法示例。
在下文中一共展示了InStream::in_check_rem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: receive
void receive(InStream & stream) {
{
const unsigned expected = 4; // allowDisplayUpdates(1) + Padding(3)
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR,
"Truncated SuppressOutputPDUData: expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
}
this->allowDisplayUpdates_ = stream.in_uint8();
stream.in_skip_bytes(3); // Padding(3)
if (ALLOW_DISPLAY_UPDATES == this->allowDisplayUpdates_) {
{
const unsigned expected = 8; // left(2) + top(2) + right(2) + bottom(2)
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR,
"Truncated SuppressOutputPDUData(2): expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
}
this->left_ = stream.in_uint16_le();
this->top_ = stream.in_uint16_le();
this->right_ = stream.in_uint16_le();
this->bottom_ = stream.in_uint16_le();
}
} // void receive(InStream & stream)
示例2: ClientInputEventPDU_Recv
explicit ClientInputEventPDU_Recv(InStream & stream)
: numEvents(
[&stream](){
if (!stream.in_check_rem(2)) {
LOG(LOG_ERR, "SlowPath::ClientInputEventPDU: data truncated (numEvents)");
throw Error(ERR_RDP_SLOWPATH);
}
auto numEvents = stream.in_uint16_le();
const unsigned expected =
2 // pad(2)
+ numEvents * 12 // (time(4) + mes_type(2) + device_flags(2) + param1(2) + param2(2)) * 12
;
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR, "SlowPath::ClientInputEventPDU: data truncated, expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_SLOWPATH);
}
stream.in_skip_bytes(2); // pad
return numEvents;
}()
)
// (time(4) + mes_type(2) + device_flags(2) + param1(2) + param2(2)) * 12
, payload(stream.get_current(), this->numEvents * 12)
{
// This is the constructor body, we skip payload now that it is packaged
stream.in_skip_bytes(this->payload.get_capacity());
}
示例3: Error
static inline void prepare_compressed_data(InStream & compressed_data_stream, bool compressed,
uint16_t & MatchCount, uint8_t const * & MatchDetails, uint8_t const * & Literals,
size_t & literals_length)
{
if (compressed) {
unsigned expected = 2; // MatchCount(2)
if (!compressed_data_stream.in_check_rem(expected)) {
LOG(LOG_ERR, "RDP61_COMPRESSED_DATA: data truncated, expected=%u remains=%zu",
expected, compressed_data_stream.in_remain());
throw Error(ERR_RDP61_DECOMPRESS_DATA_TRUNCATED);
}
MatchCount = compressed_data_stream.in_uint16_le();
expected = MatchCount * 8; // MatchCount(2) * (MatchLength(2) + MatchOutputOffset(2) + MatchHistoryOffset(4))
if (!compressed_data_stream.in_check_rem(expected)) {
LOG(LOG_ERR, "RDP61_COMPRESSED_DATA: data truncated, expected=%u remains=%zu",
expected, compressed_data_stream.in_remain());
throw Error(ERR_RDP61_DECOMPRESS_DATA_TRUNCATED);
}
MatchDetails = compressed_data_stream.get_current();
compressed_data_stream.in_skip_bytes(expected);
}
else {
MatchCount = 0;
MatchDetails = nullptr;
}
literals_length = compressed_data_stream.in_remain();
Literals = (literals_length ? compressed_data_stream.get_current() : nullptr);
}
示例4: Error
explicit LogonInfoVersion1_Recv(InStream & stream) :
cbDomain(0),
cbUserName(0),
SessionId(0) {
memset(Domain, 0, sizeof(Domain));
memset(UserName, 0, sizeof(UserName));
unsigned expected = 4; // cbDomain(4)
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR,
"Truncated Logon Info Version 1 (data): expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
this->cbDomain = stream.in_uint32_le();
expected = 52 + // Domain(52)
4; // cbUserName(4)
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR,
"Truncated Logon Info Version 1 (data): expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
stream.in_uni_to_ascii_str(this->Domain, this->cbDomain,
sizeof(this->Domain));
stream.in_skip_bytes(52 - // Domain(52)
this->cbDomain);
this->cbUserName = stream.in_uint32_le();
expected = 512 + // UserName(512)
4; // SessionId(4)
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR,
"Truncated Logon Info Version 1 (data): expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
stream.in_uni_to_ascii_str(this->UserName, this->cbUserName,
sizeof(this->UserName));
stream.in_skip_bytes(512 - // UserName(512)
this->cbUserName);
this->SessionId = stream.in_uint32_le();
LOG(LOG_INFO,
"Logon Info Version 1 (data): Domain=\"%s\" UserName=\"%s\" SessionId=%d",
this->Domain, this->UserName, this->SessionId);
} // LogonInfoVersion1_Recv(InStream & stream)
示例5: recv
void recv(InStream & stream, uint16_t len) override {
this->len = len;
/* pad1(4) + pad2(4) + pad3(4) + pad4(4) + pad5(4) + pad6(4) + cache0Entries(2) + cache0MaximumCellSize(2) +
* cache1Entries(2) + cache1MaximumCellSize(2) + cache2Entries(2) + cache2MaximumCellSize(2)
*/
const unsigned expected = 36;
if (!stream.in_check_rem(expected)){
LOG(LOG_ERR, "Truncated BmpCacheCaps, need=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_MCS_PDU_TRUNCATED);
}
this->pad1 = stream.in_uint32_le();
this->pad2 = stream.in_uint32_le();
this->pad3 = stream.in_uint32_le();
this->pad4 = stream.in_uint32_le();
this->pad5 = stream.in_uint32_le();
this->pad6 = stream.in_uint32_le();
this->cache0Entries = stream.in_uint16_le();
this->cache0MaximumCellSize = stream.in_uint16_le();
this->cache1Entries = stream.in_uint16_le();
this->cache1MaximumCellSize = stream.in_uint16_le();
this->cache2Entries = stream.in_uint16_le();
this->cache2MaximumCellSize = stream.in_uint16_le();
}
示例6: LogonErrorsInfo_Recv
explicit LogonErrorsInfo_Recv(InStream & stream) :
ErrorNotificationData(0),
ErrorNotificationType(0) {
const unsigned expected = 4 + // ErrorNotificationData(4)
4; // ErrorNotificationType(4)
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR,
"Truncated Logon Info Field (data): expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
this->ErrorNotificationType = stream.in_uint32_le();
this->ErrorNotificationData = stream.in_uint32_le();
if ((this->ErrorNotificationType != LOGON_MSG_SESSION_CONTINUE) ||
(this->ErrorNotificationData != LOGON_FAILED_OTHER)) {
LOG(LOG_INFO,
"ErrorNotificationType=%s(0x%08X) \"%s\" ErrorNotificationData=%s(0x%08X) \"%s\"",
ErrorNotificationTypeToString(this->ErrorNotificationType),
this->ErrorNotificationType,
ErrorNotificationTypeToMessage(this->ErrorNotificationType),
ErrorNotificationDataToString(this->ErrorNotificationData),
this->ErrorNotificationData,
ErrorNotificationDataToMessage(this->ErrorNotificationData));
}
}
示例7: recv
void recv(InStream & stream)
{
if (!stream.in_check_rem(8)){
LOG(LOG_ERR, "SC_CORE short header");
throw Error(ERR_GCC);
}
this->userDataType = stream.in_uint16_le();
this->length = stream.in_uint16_le();
this->version = stream.in_uint32_le();
if (this->length < 12) {
if (this->length != 8) {
LOG(LOG_ERR, "SC_CORE invalid length (%u)", this->length);
throw Error(ERR_GCC);
}
return;
}
this->clientRequestedProtocols = stream.in_uint32_le();
if (this->length < 16) {
if (this->length != 12) {
LOG(LOG_ERR, "SC_CORE invalid length (%u)", this->length);
throw Error(ERR_GCC);
}
return;
}
this->earlyCapabilityFlags = stream.in_uint32_le();
if (this->length != 16) {
LOG(LOG_ERR, "SC_CORE invalid length (%u)", this->length);
throw Error(ERR_GCC);
}
}
示例8: ShareFlow_Recv
explicit ShareFlow_Recv(InStream & stream)
: flowMarker([&stream]{
if (!stream.in_check_rem(2+1+1+1+1+2)){
LOG(LOG_ERR,
"Truncated "
"[2: ShareFlow PDU packet]"
"[1: ShareFlow pad]"
"[1: ShareFlow PDU type]"
"[1: flow Identifier]"
"[1: flow number]"
"[2: ShareFlow PDU packet] , remains=%zu", stream.in_remain());
throw Error(ERR_SEC);
}
return stream.in_uint16_le();
}())
, pad(stream.in_uint8())
, pduTypeFlow(stream.in_uint8())
, flowIdentifier(stream.in_uint8())
, flowNumber(stream.in_uint8())
, mcs_channel(stream.in_uint16_le())
{
LOG(LOG_INFO, "Flow control packet %.4x (offset=%zu)", this->flowMarker, stream.get_offset());
if (this->flowMarker != 0x8000) {
LOG(LOG_ERR, "Expected flow control packet, got %.4x", this->flowMarker);
throw Error(ERR_SEC);
}
LOG(LOG_INFO, "PDUTypeFlow=%u", this->pduTypeFlow);
if (stream.in_remain()) {
LOG(LOG_INFO, "trailing bytes in FlowPDU, remains %zu bytes", stream.in_remain());
}
}
示例9: peekFlowPDU
// Return True if flowMarker is detected
// In these case we have FlowTestPDU, FlowResponsePDU or FlowStopPDU
// and not ShareControl header.
inline bool peekFlowPDU(const InStream & stream) {
if (!stream.in_check_rem(2)) {
throw Error(ERR_SEC);
}
return (stream.get_data()[stream.get_offset()] == 0)
&& (stream.get_data()[stream.get_offset()+1] == 0x80);
}
示例10: ShareControl_Recv
explicit ShareControl_Recv(InStream & stream)
: totalLength([&stream]() {
if (!stream.in_check_rem(2+2)){
LOG(LOG_ERR,
"Truncated [4: ShareControl packet] , remains=%zu", stream.in_remain());
throw Error(ERR_SEC);
}
return stream.in_uint16_le();
}())
, pduType(stream.in_uint16_le() & 0xF)
, PDUSource([&stream, this]() {
if (this->pduType == PDUTYPE_DEACTIVATEALLPDU && this->totalLength == 4) {
// should not happen
// but DEACTIVATEALLPDU seems to be broken on windows 2000
return static_cast<uint16_t>(0);
}
return stream.in_uint16_le();
}())
, payload([&stream, this]() {
if (this->pduType == PDUTYPE_DEACTIVATEALLPDU && this->totalLength == 4) {
// should not happen
// but DEACTIVATEALLPDU seems to be broken on windows 2000
return InStream(stream.get_current(), 0);
}
if (this->totalLength < 6) {
LOG(LOG_ERR, "ShareControl packet too short totalLength=%u pduType=%u mcs_channel=%u",
this->totalLength, this->pduType, this->PDUSource);
throw Error(ERR_SEC);
}
if (!stream.in_check_rem(this->totalLength - 6)) {
LOG(LOG_ERR, "Truncated ShareControl packet, need=%u remains=%zu",
this->totalLength - 6,
stream.in_remain());
throw Error(ERR_SEC);
}
return InStream(stream.get_current(), this->totalLength - 6);
}())
// body of constructor
{
if (this->totalLength == 0x8000) {
LOG(LOG_ERR, "Expected ShareControl header, got flowMarker");
throw Error(ERR_SEC);
}
stream.in_skip_bytes(this->payload.get_capacity());
}
示例11: receive
void receive(InStream & stream) {
unsigned expected = 18; /* destLeft(2) + destTop(2) + destRight(2) +
destBottom(2) + width(2) + height(2) +
bitsPerPixel(2) + flags(2) + bitmapLength(2) */
if (!stream.in_check_rem(expected)) {
LOG( LOG_ERR
, "BitmapData::receive TS_BITMAP_DATA - Truncated data, need=%u, remains=%zu"
, expected, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
this->dest_left = stream.in_uint16_le();
this->dest_top = stream.in_uint16_le();
this->dest_right = stream.in_uint16_le();
this->dest_bottom = stream.in_uint16_le();
this->width = stream.in_uint16_le();
this->height = stream.in_uint16_le();
this->bits_per_pixel = stream.in_uint16_le();
this->flags = stream.in_uint16_le();
this->bitmap_length = stream.in_uint16_le();
assert( (this->bits_per_pixel == 32)
|| (this->bits_per_pixel == 24)
|| (this->bits_per_pixel == 16)
|| (this->bits_per_pixel == 15)
|| (this->bits_per_pixel == 8 ));
if ( (this->flags & BITMAP_COMPRESSION)
&& !(this->flags & NO_BITMAP_COMPRESSION_HDR)) {
expected = 8; /* cbCompFirstRowSize(2) + cbCompMainBodySize(2) +
cbScanWidth(2) + cbUncompressedSize(2) */
if (!stream.in_check_rem(expected)) {
LOG( LOG_ERR
, "BitmapData::receive TS_CD_HEADER - Truncated data, need=18, remains=%zu"
, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
stream.in_skip_bytes(2); /* cbCompFirstRowSize (2 bytes) */
this->cb_comp_main_body_size = stream.in_uint16_le();
this->cb_scan_width = stream.in_uint16_le();
this->cb_uncompressed_size = stream.in_uint16_le();
}
}
示例12: UnusedEvent_Recv
explicit UnusedEvent_Recv(InStream & stream) {
const unsigned expected =
6; // pad4Octets(4) + pad2Octets(2)
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR, "SlowPath::UnusedEvent: data truncated, expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_SLOWPATH);
}
stream.in_skip_bytes(6); // pad4Octets(4) + pad2Octets(2)
}
示例13: recv
void recv(InStream & stream, uint16_t len)override {
this->len = len;
if (!stream.in_check_rem(2)) {
LOG(LOG_ERR, "Truncated CompDeskCaps, need=2 remains=%zu",
stream.in_remain());
throw Error(ERR_MCS_PDU_TRUNCATED);
}
this->CompDeskSupportLevel = stream.in_uint16_le();
}
示例14: recv
void recv(InStream & stream, uint16_t len)override {
this->len = len;
if (!stream.in_check_rem(4)){
LOG(LOG_ERR, "Truncated BrushCacheCaps, need=4 remains=%zu",
stream.in_remain());
throw Error(ERR_MCS_PDU_TRUNCATED);
}
this->brushSupportLevel = stream.in_uint32_le();
}
示例15: PlainNotify_Recv
explicit PlainNotify_Recv(InStream & stream) {
memset(Pad, 0, sizeof(Pad));
const unsigned expected = 576; // Pad(576)
if (!stream.in_check_rem(expected)) {
LOG(LOG_ERR,
"Truncated Plain Notify (data): expected=%u remains=%zu",
expected, stream.in_remain());
throw Error(ERR_RDP_DATA_TRUNCATED);
}
stream.in_copy_bytes(this->Pad, sizeof(this->Pad));
}