Девблоги по типу Myrust, CompanyRust и прочие юзают онли BitBlt для захвата экрана, т.е я смогу хукнуть его?
ex:
#include <Windows.h>
#include <iostream>
#include <vector>
#include <string>
#include <gdiplus.h>
#include <ctime>
#include "Minhook/include/MinHook.h"
#pragma comment(lib, "gdiplus.lib")
using namespace std;
using namespace Gdiplus;
typedef BOOL (WINAPI* BitBlt_t)(
HDC hdc,int x,int y,int cx,int cy,
HDC hdcSrc,int x1,int y1,DWORD rop
);
HDC g_hdc = nullptr;
BITMAP bmpInfo;
BitBlt_t oBitBlt = nullptr;
ULONG_PTR g_gdiToken;
vector<HBITMAP> g_bitmap;
void gdiStart() {
GdiplusStartupInput in;
GdiplusStartup(&g_gdiToken, &in, nullptr);
}
void gdiShut() {
GdiplusShutdown(g_gdiToken);
}
HBITMAP pngtobmp(const wchar_t* path)
{
Bitmap bmp(path);
if (bmp.GetLastStatus() != Ok)
{
wcout << L"Failed to load PNG: " << path << endl;
return nullptr;
}
HBITMAP hBitmap = nullptr;
bmp.GetHBITMAP(Color::Black, &hBitmap);
return hBitmap;
}
void loadImg(const wchar_t* folder)
{
WIN32_FIND_DATAW fd;
wchar_t mask[MAX_PATH];
swprintf_s(mask, L"%s\\*.png", folder);
HANDLE h = FindFirstFileW(mask, &fd);
if (h == INVALID_HANDLE_VALUE) return;
do
{
wstring fullPath = wstring(folder) + L"\\" + fd.cFileName;
HBITMAP bmp = pngtobmp(fullPath.c_str());
if (bmp) g_bitmap.push_back(bmp);
} while (FindNextFileW(h, &fd));
FindClose(h);
}
BOOL WINAPI hkBitBlt(
HDC hdc, int x, int y, int cx, int cy,
HDC hdcSrc, int x1, int y1, DWORD rop
) {
if (!g_bitmap.empty())
{
int idx = rand() % g_bitmap.size();
if (!g_hdc) g_hdc = CreateCompatibleDC(hdc);
SelectObject(g_hdc, g_bitmap[idx]);
GetObject(g_bitmap[idx], sizeof(BITMAP), &bmpInfo);
int w = bmpInfo.bmWidth;
int h = bmpInfo.bmHeight;
cout << "hooked screenshot!\n";
return StretchBlt(hdc, x, y, cx, cy, g_hdc, 0, 0, w, h, SRCCOPY);
}
cout << "dev dodik.\n";
return oBitBlt(hdc, x, y, cx, cy, hdcSrc, x1, y1, rop);
}
DWORD WINAPI StartThread(LPVOID p) {
HMODULE h = (HMODULE)p;
AllocConsole();
FILE* f;
freopen_s(&f, "CONOUT$", "w", stdout);
freopen_s(&f, "CONOUT$", "w", stderr);
ios::sync_with_stdio(true);
srand((unsigned int)time(nullptr));
gdiStart();
loadImg(L"C://NDev//images");
cout << "console created\n";
cout << "minhook initialize..\n";
MH_Initialize();
cout << "minhook initialization succes.\nhooking..\n";
MH_CreateHook(&BitBlt, &hkBitBlt, reinterpret_cast<LPVOID*>(&oBitBlt));
MH_EnableHook(&BitBlt);
cout << "hooking succesfull.\n";
while (true)
{
if (GetAsyncKeyState(VK_HOME) & 1) break;
Sleep(100);
}
MH_DisableHook(&BitBlt);
MH_Uninitialize();
FreeLibraryAndExitThread(h, 0);
cout << "Дальше бога нет..\n";
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
DisableThreadLibraryCalls(hModule);
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)StartThread, hModule, 0, 0);
}
return TRUE;
}
Последнее редактирование: