ANTICHAT

ANTICHAT (https://forum.antichat.xyz/index.php)
-   Общие вопросы программирования (https://forum.antichat.xyz/forumdisplay.php?f=206)
-   -   Как получить скриншот directx окна гташки (https://forum.antichat.xyz/showthread.php?t=1395555)

derr0x 24.07.2021 14:42

Всем привет, можете подкинуть статью где это реализовано, или же подсказать какие функции хукать, что бы получаться пиксели гташки

Receiver 25.07.2021 17:46

гораздо быстрее будет делать скриншот с помощью GDI++:

C++:





Код:

// ConsoleApplication10.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include
#include
#include
#pragma comment(lib, "GdiPlus.lib")
using
namespace
Gdiplus
;
static
const
GUID png
=
{
0x557cf406
,
0x1a04
,
0x11d3
,
{
0x9a
,
0x73
,
0x00
,
0x00
,
0xf8
,
0x1e
,
0xf3
,
0x2e
}
}
;
int
main
(
void
)
{
GdiplusStartupInput gdiplusStartupInput
;
ULONG_PTR gdiplusToken
;
GdiplusStartup
(
&
gdiplusToken
,
&
gdiplusStartupInput
,
NULL
)
;
HDC window_dc
,
memdc
;
HBITMAP membit
;
// Получаем DC окна по его HWND
HWND window_handle
=
FindWindowA
(
0
,
"GTA SA:MP"
)
;
window_dc
=
GetDC
(
window_handle
)
;
// Определяем разрешение экрана
int
Height
,
Width
;
Height
=
GetSystemMetrics
(
SM_CYSCREEN
)
;
Width
=
GetSystemMetrics
(
SM_CXSCREEN
)
;
// Создаем новый DC, идентичный десктоповскому и битмап размером с экран.
memdc
=
CreateCompatibleDC
(
window_dc
)
;
membit
=
CreateCompatibleBitmap
(
window_dc
,
Width
,
Height
)
;
SelectObject
(
memdc
,
membit
)
;
// Улыбаемся... Снято!
BitBlt
(
memdc
,
0
,
0
,
Width
,
Height
,
window_dc
,
0
,
0
,
SRCCOPY
)
;
HBITMAP hBitmap
;
hBitmap
=
(
HBITMAP
)
SelectObject
(
memdc
,
membit
)
;
Gdiplus
::
Bitmap
bitmap
(
hBitmap
,
NULL
)
;
bitmap
.
Save
(
L
"screen.png"
,
&
png
)
;
DeleteObject
(
hBitmap
)
;
return
0
;
}



Скриншот с GDI+ - C++ WinAPI - Киберфорум

Скриншот с GDI+ C++ WinAPI Решение и ответ на вопрос 1526421

www.cyberforum.ru


Capturing an Image - Win32 apps

You can use a bitmap to capture an image, and you can store the captured image in memory, display it at a different location in your application's window, or display it in another window.

docs.microsoft.com

derr0x 25.07.2021 18:25

Узнал, что ставятся хуки на функии endscene/present,

Цитата:

Сообщение от RECEIVER

гораздо быстрее будет делать скриншот с помощью GDI++:

C++:





Код:

// ConsoleApplication10.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include
#include
#include
#pragma comment(lib, "GdiPlus.lib")
using
namespace
Gdiplus
;
static
const
GUID png
=
{
0x557cf406
,
0x1a04
,
0x11d3
,
{
0x9a
,
0x73
,
0x00
,
0x00
,
0xf8
,
0x1e
,
0xf3
,
0x2e
}
}
;
int
main
(
void
)
{
GdiplusStartupInput gdiplusStartupInput
;
ULONG_PTR gdiplusToken
;
GdiplusStartup
(
&
gdiplusToken
,
&
gdiplusStartupInput
,
NULL
)
;
HDC window_dc
,
memdc
;
HBITMAP membit
;
// Получаем DC окна по его HWND
HWND window_handle
=
FindWindowA
(
0
,
"GTA SA:MP"
)
;
window_dc
=
GetDC
(
window_handle
)
;
// Определяем разрешение экрана
int
Height
,
Width
;
Height
=
GetSystemMetrics
(
SM_CYSCREEN
)
;
Width
=
GetSystemMetrics
(
SM_CXSCREEN
)
;
// Создаем новый DC, идентичный десктоповскому и битмап размером с экран.
memdc
=
CreateCompatibleDC
(
window_dc
)
;
membit
=
CreateCompatibleBitmap
(
window_dc
,
Width
,
Height
)
;
SelectObject
(
memdc
,
membit
)
;
// Улыбаемся... Снято!
BitBlt
(
memdc
,
0
,
0
,
Width
,
Height
,
window_dc
,
0
,
0
,
SRCCOPY
)
;
HBITMAP hBitmap
;
hBitmap
=
(
HBITMAP
)
SelectObject
(
memdc
,
membit
)
;
Gdiplus
::
Bitmap
bitmap
(
hBitmap
,
NULL
)
;
bitmap
.
Save
(
L
"screen.png"
,
&
png
)
;
DeleteObject
(
hBitmap
)
;
return
0
;
}



Скриншот с GDI+ - C++ WinAPI - Киберфорум

Скриншот с GDI+ C++ WinAPI Решение и ответ на вопрос 1526421

www.cyberforum.ru


Capturing an Image - Win32 apps

You can use a bitmap to capture an image, and you can store the captured image in memory, display it at a different location in your application's window, or display it in another window.

docs.microsoft.com


Я об этом знаю) Но ведь функция BitBlt получает, то что рисуется вообще на экран, то есть если окно гташки свернуто, то BitBlt не захватит оконо гташки, мне нужно что то типо функции PrintWindow, но это чисто для Gdi


Время: 16:45