| 4579 |
void XsProcClipboard(PCHAR buff) |
void XsProcClipboard(PCHAR buff) |
| 4580 |
{ |
{ |
| 4581 |
int len, blen; |
int len, blen; |
| 4582 |
char *p, *cbbuff, hdr[20]; |
char *p, *cbbuff, hdr[20], notify_buff[130]; |
| 4583 |
HGLOBAL cbmem; |
HGLOBAL cbmem; |
| 4584 |
int wide_len; |
int wide_len; |
| 4585 |
HGLOBAL wide_cbmem; |
HGLOBAL wide_cbmem; |
| 4593 |
if (*p++ == ';') { |
if (*p++ == ';') { |
| 4594 |
if (*p == '?' && *(p+1) == 0) { // Read access |
if (*p == '?' && *(p+1) == 0) { // Read access |
| 4595 |
if (ts.CtrlFlag & CSF_CBREAD) { |
if (ts.CtrlFlag & CSF_CBREAD) { |
| 4596 |
|
if (ts.NotifyClipboardAccess) { |
| 4597 |
|
NotifyInfoMessage(&cv, "remote host reads clipboard contents", "Clipboard Access"); |
| 4598 |
|
} |
| 4599 |
strncpy_s(hdr, sizeof(hdr), "\033]52;", _TRUNCATE); |
strncpy_s(hdr, sizeof(hdr), "\033]52;", _TRUNCATE); |
| 4600 |
if (strncat_s(hdr, sizeof(hdr), buff, p - buff) == 0) { |
if (strncat_s(hdr, sizeof(hdr), buff, p - buff) == 0) { |
| 4601 |
CBStartPasteB64(HVTWin, hdr, "\033\\"); |
CBStartPasteB64(HVTWin, hdr, "\033\\"); |
| 4602 |
} |
} |
| 4603 |
} |
} |
| 4604 |
|
else if (ts.NotifyClipboardAccess) { |
| 4605 |
|
NotifyWarnMessage(&cv, "Reject clipboard read access from remote", "Rejected Clipboard Access"); |
| 4606 |
|
} |
| 4607 |
} |
} |
| 4608 |
else if (ts.CtrlFlag & CSF_CBWRITE) { // Write access |
else if (ts.CtrlFlag & CSF_CBWRITE) { // Write access |
| 4609 |
len = strlen(buff); |
len = strlen(buff); |
| 4628 |
cbbuff[len] = 0; |
cbbuff[len] = 0; |
| 4629 |
GlobalUnlock(cbmem); |
GlobalUnlock(cbmem); |
| 4630 |
|
|
| 4631 |
|
if (ts.NotifyClipboardAccess) { |
| 4632 |
|
_snprintf_s(notify_buff, sizeof(notify_buff), _TRUNCATE, "remote host writes clipboard.\n--\n%s", cbbuff); |
| 4633 |
|
NotifyInfoMessage(&cv, notify_buff, "Clipboard Access"); |
| 4634 |
|
} |
| 4635 |
|
|
| 4636 |
wide_len = MultiByteToWideChar(CP_ACP, 0, cbbuff, -1, NULL, 0); |
wide_len = MultiByteToWideChar(CP_ACP, 0, cbbuff, -1, NULL, 0); |
| 4637 |
wide_cbmem = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR) * wide_len); |
wide_cbmem = GlobalAlloc(GMEM_MOVEABLE, sizeof(WCHAR) * wide_len); |
| 4638 |
if (wide_cbmem) { |
if (wide_cbmem) { |
| 4650 |
CloseClipboard(); |
CloseClipboard(); |
| 4651 |
} |
} |
| 4652 |
} |
} |
| 4653 |
|
else if (ts.NotifyClipboardAccess) { |
| 4654 |
|
NotifyWarnMessage(&cv, "Reject clipboard write access from remote", "Rejected Clipboard Access"); |
| 4655 |
|
} |
| 4656 |
} |
} |
| 4657 |
} |
} |
| 4658 |
|
|