diff --git a/Overlay/Include/Include.h b/Overlay/Include/Include.h new file mode 100644 index 0000000..7eda8f6 --- /dev/null +++ b/Overlay/Include/Include.h @@ -0,0 +1,8 @@ +#include +#include +#include +#include +#include +#pragma comment(lib, "dwmapi.lib") +#pragma warning(disable : 4996) +#pragma once \ No newline at end of file diff --git a/Overlay/Include/Options.h b/Overlay/Include/Options.h new file mode 100644 index 0000000..aaeb3a4 --- /dev/null +++ b/Overlay/Include/Options.h @@ -0,0 +1,5 @@ +#pragma once +#include "Include.h" +const MARGINS margins = { -1 ,-1, -1, -1 }; +const char g_szClassName[] = "overlay"; +bool isVisible = true; \ No newline at end of file diff --git a/Overlay/Include/Overlay.h b/Overlay/Include/Overlay.h new file mode 100644 index 0000000..49d487d --- /dev/null +++ b/Overlay/Include/Overlay.h @@ -0,0 +1,5 @@ +#pragma once +#include "Include.h" +#include "Options.h" +#include "../functions/addWatermark.h" +#include "../functions/captureScreen.h" \ No newline at end of file diff --git a/Overlay/Overlay.vcxproj b/Overlay/Overlay.vcxproj index b343f32..33b9ce0 100644 --- a/Overlay/Overlay.vcxproj +++ b/Overlay/Overlay.vcxproj @@ -130,6 +130,13 @@ + + + + + + + diff --git a/Overlay/Overlay.vcxproj.filters b/Overlay/Overlay.vcxproj.filters index 4327830..cc81683 100644 --- a/Overlay/Overlay.vcxproj.filters +++ b/Overlay/Overlay.vcxproj.filters @@ -3,4 +3,29 @@ + + + {84d30480-42d9-4793-b08b-1bb6712fd72b} + + + {140481ac-0012-4a9a-803c-5f6ddcde3cca} + + + + + Include + + + functions + + + functions + + + Include + + + Include + + \ No newline at end of file diff --git a/Overlay/functions/addWatermark.h b/Overlay/functions/addWatermark.h new file mode 100644 index 0000000..5fe4f86 --- /dev/null +++ b/Overlay/functions/addWatermark.h @@ -0,0 +1,26 @@ +#pragma once +#include "../Include/Include.h" + +void addWatermark(HDC hdc, HDC hdcDIB, BITMAPINFO bmi) +{ + HFONT hFont; + LOGFONT lf = { 0 }; + lf.lfHeight = -MulDiv(20, GetDeviceCaps(hdc, LOGPIXELSY), 72); // размер шрифта + lf.lfWeight = FW_NORMAL; // жирность шрифта + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfOutPrecision = OUT_TT_PRECIS; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfQuality = DEFAULT_QUALITY; + lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; + strcpy_s(lf.lfFaceName, "Arial"); + + hFont = CreateFontIndirect(&lf); + SelectObject(hdcDIB, hFont); + + std::string watermark = "vos.team"; + + SetTextColor(hdcDIB, RGB(255, 0, 255, 128)); + SetBkMode(hdcDIB, TRANSPARENT); + TextOut(hdcDIB, 10, 10, watermark.c_str(), watermark.length()); + DeleteObject(hFont); +} \ No newline at end of file diff --git a/Overlay/functions/captureScreen.h b/Overlay/functions/captureScreen.h new file mode 100644 index 0000000..e09fd8b --- /dev/null +++ b/Overlay/functions/captureScreen.h @@ -0,0 +1,43 @@ +#pragma once +#include "addWatermark.h" + +void captureScreen(std::string file_Name) +{ + HDC hdcScreen; + HDC hdcDIB; + HBITMAP hbmDIB; + BITMAPINFO bmi; + LPVOID lpvBits; + HANDLE hFile; + DWORD dwBytesWritten; + + + hdcScreen = GetDC(NULL); + hdcDIB = CreateCompatibleDC(hdcScreen); + ZeroMemory(&bmi, sizeof(BITMAPINFO)); + bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi.bmiHeader.biWidth = GetSystemMetrics(SM_CXSCREEN); + bmi.bmiHeader.biHeight = GetSystemMetrics(SM_CYSCREEN); + bmi.bmiHeader.biPlanes = 1; + bmi.bmiHeader.biBitCount = 24; + bmi.bmiHeader.biCompression = BI_RGB; + hbmDIB = CreateDIBSection(hdcScreen, &bmi, DIB_RGB_COLORS, &lpvBits, NULL, 0); + SelectObject(hdcDIB, hbmDIB); + BitBlt(hdcDIB, 0, 0, bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight, hdcScreen, 0, 0, SRCCOPY); + + // Добавление ватермарки на контекст + addWatermark(hdcScreen, hdcDIB, bmi); + + hFile = CreateFile(("C:\\Users\\" + (std::string)std::getenv("USERNAME") + "\\Documents\\vos.team\\" + file_Name).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + BITMAPFILEHEADER hdr = { }; + hdr.bfType = 0x4d42; // Буквы 'B' и 'M' + hdr.bfOffBits = sizeof(hdr) + sizeof(BITMAPINFOHEADER); + hdr.bfSize = hdr.bfOffBits + bmi.bmiHeader.biWidth * bmi.bmiHeader.biHeight * 3; + WriteFile(hFile, &hdr, sizeof(hdr), &dwBytesWritten, NULL); + WriteFile(hFile, &bmi.bmiHeader, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL); + WriteFile(hFile, lpvBits, bmi.bmiHeader.biWidth * bmi.bmiHeader.biHeight * 3, &dwBytesWritten, NULL); + CloseHandle(hFile); + DeleteObject(hbmDIB); + DeleteDC(hdcDIB); + ReleaseDC(NULL, hdcScreen); +} \ No newline at end of file diff --git a/Overlay/main.cpp b/Overlay/main.cpp index 1b3a264..2ceeb35 100644 --- a/Overlay/main.cpp +++ b/Overlay/main.cpp @@ -1,79 +1,4 @@ -#include -#include -#include -#include -#include -#pragma comment(lib, "dwmapi.lib") -#pragma warning(disable : 4996) - -const MARGINS margins = { -1 ,-1, -1, -1 }; -const char g_szClassName[] = "overlay"; -bool isVisible = true; - -void addWatermark(HDC hdc, HDC hdcDIB, BITMAPINFO bmi) -{ - HFONT hFont; - LOGFONT lf = { 0 }; - lf.lfHeight = -MulDiv(20, GetDeviceCaps(hdc, LOGPIXELSY), 72); // размер шрифта - lf.lfWeight = FW_NORMAL; // жирность шрифта - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfOutPrecision = OUT_TT_PRECIS; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfPitchAndFamily = DEFAULT_PITCH | FF_DONTCARE; - strcpy_s(lf.lfFaceName, "Arial"); - - hFont = CreateFontIndirect(&lf); - SelectObject(hdcDIB, hFont); - - std::string watermark = "vos.team"; - - SetTextColor(hdcDIB, RGB(255, 0, 255, 128)); - SetBkMode(hdcDIB, TRANSPARENT); - TextOut(hdcDIB, 10, 10, watermark.c_str(), watermark.length()); - DeleteObject(hFont); -} - -void captureScreen(std::string file_Name) -{ - HDC hdcScreen; - HDC hdcDIB; - HBITMAP hbmDIB; - BITMAPINFO bmi; - LPVOID lpvBits; - HANDLE hFile; - DWORD dwBytesWritten; - - - hdcScreen = GetDC(NULL); - hdcDIB = CreateCompatibleDC(hdcScreen); - ZeroMemory(&bmi, sizeof(BITMAPINFO)); - bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi.bmiHeader.biWidth = GetSystemMetrics(SM_CXSCREEN); - bmi.bmiHeader.biHeight = GetSystemMetrics(SM_CYSCREEN); - bmi.bmiHeader.biPlanes = 1; - bmi.bmiHeader.biBitCount = 24; - bmi.bmiHeader.biCompression = BI_RGB; - hbmDIB = CreateDIBSection(hdcScreen, &bmi, DIB_RGB_COLORS, &lpvBits, NULL, 0); - SelectObject(hdcDIB, hbmDIB); - BitBlt(hdcDIB, 0, 0, bmi.bmiHeader.biWidth, bmi.bmiHeader.biHeight, hdcScreen, 0, 0, SRCCOPY); - - // Добавление ватермарки на контекст - addWatermark(hdcScreen, hdcDIB, bmi); - - hFile = CreateFile(("C:\\Users\\" + (std::string)std::getenv("USERNAME") + "\\Documents\\vos.team\\" + file_Name).c_str(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - BITMAPFILEHEADER hdr = { }; - hdr.bfType = 0x4d42; // Буквы 'B' и 'M' - hdr.bfOffBits = sizeof(hdr) + sizeof(BITMAPINFOHEADER); - hdr.bfSize = hdr.bfOffBits + bmi.bmiHeader.biWidth * bmi.bmiHeader.biHeight * 3; - WriteFile(hFile, &hdr, sizeof(hdr), &dwBytesWritten, NULL); - WriteFile(hFile, &bmi.bmiHeader, sizeof(BITMAPINFOHEADER), &dwBytesWritten, NULL); - WriteFile(hFile, lpvBits, bmi.bmiHeader.biWidth * bmi.bmiHeader.biHeight * 3, &dwBytesWritten, NULL); - CloseHandle(hFile); - DeleteObject(hbmDIB); - DeleteDC(hdcDIB); - ReleaseDC(NULL, hdcScreen); -} +#include "Include/Overlay.h" LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {