program Subliminal;
uses Windows, Messages;
function GdiplusStartup(out hToken: Cardinal; input, output: PChar): Cardinal; stdcall external 'gdiplus';
function GdipLoadImageFromFile(lpFileName: PWideChar; out hImage: Cardinal): Cardinal; stdcall external 'gdiplus';
function GdipCreateFromHDC(hDC: Cardinal; out hGraphics: Cardinal): Cardinal; stdcall external 'gdiplus';
function GdipDrawImage(hGraphics, hImage, x, y: Cardinal): Cardinal; stdcall external 'gdiplus';
function GdipDisposeImage(hImage: Cardinal): Cardinal; stdcall external 'gdiplus';
function GdipDeleteGraphics(hGraphics: Cardinal): Cardinal; stdcall external 'gdiplus';
procedure GdiplusShutdown(hToken: Cardinal); stdcall external 'gdiplus';
var
Msg: TMsg;
Point, Last: TPoint;
nop: Cardinal = $C358016A;
PaintStruct: TPaintStruct;
hScreen, hCanvas, Width, Height, hToken, hImage, hGraphics, hWnd, hRgn, hMouse: Cardinal;
WndClass: TWndClass = (lpfnWndProc: @nop; lpszClassName: 'sub');
begin
CreateMutex(nil, True, WndClass.lpszClassName);
if GetLastError <> 0 then Exit;
hScreen := GetDC(0);
hCanvas := CreateCompatibleDC(0);
Width := GetDeviceCaps(hScreen, HORZRES); //
Height := GetDeviceCaps(hScreen, VERTRES); //
SelectObject(hCanvas, CreateCompatibleBitmap(hScreen, Width, Height));
GdiplusStartup(hToken, #1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0, nil);
GdipLoadImageFromFile('C:\WINDOWS\Web\Wallpaper\Cazador.jpg', hImage); // path
GdipCreateFromHDC(hCanvas, hGraphics);
GdipDrawImage(hGraphics, hImage, 0, 0);
GdipDeleteGraphics(hGraphics);
GdipDisposeImage(hImage);
RegisterClass(WndClass);
hWnd := CreateWindowEx(WS_EX_TOOLWINDOW + WS_EX_TOPMOST + WS_EX_LAYERED, WndClass.lpszClassName, nil, WS_POPUP + WS_VISIBLE, 0, 0, Width, Height, 0, 0, HInstance, nil);
SetCursor(CreateCursor(0, 0, 0, 0, 0, PChar(''), PChar('')));
SetLayeredWindowAttributes(hWnd, 0, 55, LWA_ALPHA);
SetPriorityClass(INFINITE, IDLE_PRIORITY_CLASS);
SetTimer(hWnd, 0, 55, nil);
while GetMessage(Msg, 0, 0, 0) do
if Msg.message = WM_PAINT then
begin
BitBlt(BeginPaint(hWnd, PaintStruct), 0, 0, Width, Height, hCanvas, 0, 0, SRCCOPY);
EndPaint(hWnd, PaintStruct);
end
else if (Msg.message = WM_TIMER) or (Msg.message = WM_MOUSEMOVE) then
begin
GetCursorPos(Point);
BringWindowToTop(hWnd);
if PInt64(@Point)^ <> PInt64(@Last)^ then
begin
Last := Point;
hRgn := CreateRectRgn(0, 0, Width, Height);
GetWindowRgn(hWnd, hRgn);
CombineRgn(hRgn, hRgn, hMouse, RGN_XOR); // "if hMouse <> 0"
DeleteObject(hMouse);
hMouse := CreateRectRgn(Point.X, Point.Y, Point.X + 1, Point.Y + 1); // LWA_COLORKEY needs to refresh the canvas
CombineRgn(hRgn, hRgn, hMouse, RGN_XOR);
SetWindowRgn(hWnd, hRgn, False);
DeleteObject(hRgn)
end;
end
else
DispatchMessage(Msg);
GdiplusShutdown(hToken);
end.