📄 sheltest.c
字号:
#define STRICT
#include <windows.h>
#include "shellinj.h"
#define MSGSIZE 512
#define MAXMSGS 20
HWND hMainWin;
HINSTANCE hInstance;
char Messages[MAXMSGS][MSGSIZE];
int nMessages = 0;
void Paint(HWND hWin)
{
PAINTSTRUCT ps;
int FontHeight, loop;
HDC DC = BeginPaint(hWin, &ps);
TEXTMETRIC tm;
GetTextMetrics(DC, &tm);
FontHeight = tm.tmHeight + tm.tmExternalLeading;
for (loop = 0; loop < nMessages; loop++)
TextOut(DC, 0, loop * FontHeight, Messages[loop], lstrlen(Messages[loop]));
EndPaint(hWin, &ps);
}
void ShellMsg(HWND hWin, WPARAM WParam, LPARAM LParam)
{
static const char *ShellMsgNames[] =
{
NULL, /*there is no HSHELL_xxx message with a value of 0*/
"HSHELL_WINDOWCREATED",
"HSHELL_WINDOWDESTROYED",
"HSHELL_ACTIVATESHELLWINDOW",
"HSHELL_WINDOWACTIVATED",
"HSHELL_GETMINRECT",
"HSHELL_REDRAW",
"HSHELL_TASKMAN",
"HSHELL_LANGUAGE"
};
char Text[512];
if (WParam == HSHELL_GETMINRECT)
{
RECT r;
SIGetMinRect(&r);
wsprintf(Text, "%s (%08x) (%d,%d,%d,%d)", ShellMsgNames[WParam],
LParam, r.left, r.top, r.right, r.bottom);
}
else
wsprintf(Text, "%s (%08x)", ShellMsgNames[WParam], LParam);
if (nMessages < MAXMSGS)
lstrcpy(Messages[nMessages++], Text);
else
{
memmove(Messages[0], Messages[1], sizeof(Messages)-MSGSIZE);
lstrcpy(Messages[MAXMSGS-1], Text);
}
InvalidateRect(hWin, NULL, TRUE);
}
/******************************************/
LRESULT CALLBACK WndProc(HWND hWin, UINT Msg, WPARAM WParam, LPARAM LParam)
{
static UINT uShellMsg = 0;
if (uShellMsg == 0)
uShellMsg = RegisterWindowMessage("SHELLHOOK");
switch (Msg)
{
case WM_CREATE:
if (!SIAddClientWindow(hWin, WM_USER+101))
MessageBox(hWin, "SIAddClientWindow Failed", "", MB_OK);
return 0;
case WM_DESTROY:
SIRemoveClientWindow(hWin);
PostQuitMessage(0);
break;
case WM_PAINT:
Paint(hWin);
break;
case WM_USER+101:
ShellMsg(hWin, WParam, LParam);
break;
}
return DefWindowProc(hWin, Msg, WParam, LParam);
}
#ifdef __BORLANDC__
# pragma argsused
#endif
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int Show)
{
WNDCLASS wc;
MSG msg;
SIStartup();
memset(Messages, 0, sizeof(Messages));
hInstance = hInst;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon((HINSTANCE) NULL, IDI_APPLICATION);
wc.hCursor = LoadCursor((HINSTANCE) NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = "MainMenu";
wc.lpszClassName = "COMtest";
if (!RegisterClass(&wc))
return FALSE;
/* Create the main window. */
hMainWin = CreateWindow("COMtest",
"Shell-Injector COM Test",
WS_OVERLAPPEDWINDOW | WS_MAXIMIZE, CW_USEDEFAULT,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, (HWND)
NULL, (HMENU) NULL, hInst, (LPVOID) NULL);
if (!hMainWin)
return FALSE;
/* Show the window and paint its contents. */
ShowWindow(hMainWin, Show);
UpdateWindow(hMainWin);
/* Start the message loop. */
while (GetMessage(&msg, (HWND) NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
SIShutdown();
return msg.wParam;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -