Skip to content

Commit a68dae7

Browse files
author
HackMemory
authored
Create GetScreenshot.php
1 parent f787efa commit a68dae7

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

examples/GetScreenshot.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
$hScreenDC = DFFI::callFunction("gdi32", "int", "CreateDCA", ["DISPLAY", 0, 0, 0], ["string", "int", "int", "int"]);
4+
$hMemoryDC = DFFI::callFunction("gdi32", "int", "CreateCompatibleDC", [$hScreenDC], ["int"]);
5+
6+
$width = DFFI::callFunction("gdi32", "int", "GetDeviceCaps", [$hMemoryDC, 8], ["int", "int"]);
7+
$height = DFFI::callFunction("gdi32", "int", "GetDeviceCaps", [$hMemoryDC, 10], ["int", "int"]);
8+
9+
$hBitmap = DFFI::callFunction("gdi32", "int", "CreateCompatibleBitmap", [$hScreenDC, $width, $height], ["int", "int", "int"]);
10+
$hOldBitmap = DFFI::callFunction("gdi32", "int", "SelectObject", [$hMemoryDC, $hBitmap], ["int", "int"]);
11+
12+
DFFI::callFunction("gdi32", "bool", "BitBlt", [$hMemoryDC, 0, 0, $width, $height, $hScreenDC, 0, 0, 0x00CC0020], ["int", "int", "int","int", "int", "int","int", "int", "int",]);
13+
DFFI::callFunction("gdi32", "int", "SelectObject", [$hMemoryDC, $hOldBitmap], ["int", "int"]);
14+
15+
DFFI::callFunction("user32", "bool", "OpenClipboard", [0], ["int"]);
16+
DFFI::callFunction("user32", "bool", "EmptyClipboard", [], []);
17+
DFFI::callFunction("user32", "bool", "SetClipboardData", [2, $hBitmap], ["int", "int"]);
18+
DFFI::callFunction("user32", "bool", "CloseClipboard", [], []);
19+
20+
DFFI::callFunction("gdi32", "bool", "DeleteDC", ["int"], [$hMemoryDC]);
21+
DFFI::callFunction("gdi32", "bool", "DeleteDC", ["int"], [$hMemoryDC]);

0 commit comments

Comments
 (0)