PDA

Просмотр полной версии : Как получить скриншот directx окна гташки


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 - Киберфорум (https://www.blast.hk/redirect/aHR0cHM6Ly93d3cuY3liZXJmb3J1bS5ydS93aW4tYXBpL3Rocm VhZDE1MjY0MjEuaHRtbA)

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

www.cyberforum.ru


Capturing an Image - Win32 apps (https://www.blast.hk/redirect/aHR0cHM6Ly9kb2NzLm1pY3Jvc29mdC5jb20vZW4tdXMvd2luZG 93cy93aW4zMi9nZGkvY2FwdHVyaW5nLWFuLWltYWdlP3JlZGly ZWN0ZWRmcm9tPU1TRE4)

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,



гораздо быстрее будет делать скриншот с помощью 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 - Киберфорум (https://www.blast.hk/redirect/aHR0cHM6Ly93d3cuY3liZXJmb3J1bS5ydS93aW4tYXBpL3Rocm VhZDE1MjY0MjEuaHRtbA)

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

www.cyberforum.ru


Capturing an Image - Win32 apps (https://www.blast.hk/redirect/aHR0cHM6Ly9kb2NzLm1pY3Jvc29mdC5jb20vZW4tdXMvd2luZG 93cy93aW4zMi9nZGkvY2FwdHVyaW5nLWFuLWltYWdlP3JlZGly ZWN0ZWRmcm9tPU1TRE4)

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