Сейчас я пытаюсь нарисовать оверлеи в gdiplus, однако, когда я запускаю свою программу, она может найти наше окно, но она не будет рисовать мою линию наложения. Я что-то пропустил? Документация предполагает, что я должен быть в состоянии сделать это.
#include <windows.h>
#include <objidl.h>
#include <gdiplus.h>
#include <iostream>
using namespace Gdiplus;
#pragma comment (lib,"Gdiplus.lib")
VOID OnPaint(HDC hdc)
{
Graphics graphics(hdc);
Pen pen(Color(255, 0, 0, 0), 5);
graphics.DrawLine(&pen, 0, 0, 200, 100);
}
ULONG_PTR gdiplusToken;
int main() {
//Untitled - Notepad
HWND hWnd = FindWindow(NULL, TEXT("*Untitled - Notepad"));
// In top of main
GdiplusStartupInput gdiplusStartupInput;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
if (hWnd == 0) {
std::cout << "[-] - Unable to locate window!\n";
return 0;
}
std::cout << "[+] - Located Window, starting hook.\n";
HDC hdc = GetDC(FindWindowA(NULL, "*Untitled - Notepad"));
PAINTSTRUCT ps;
hdc = BeginPaint(hWnd, &ps);
if (hdc == ERROR) {
std::cout << "[-] - An error occured\n";
return 0;
}
OnPaint(hdc);
Sleep(3000);
EndPaint(hWnd, &ps);
std::cout << "Finished Drawing\n";
}