C++注入记事本升级版,给记事本弄爱心
#include <iostream>;
using namespace std;
#include <windows.h>;
#include <tlhelp32.h>;
#include <tchar.h>; BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam);
HWND GetMainWindow();
void MyPostMessage(HWND hWnd); extern "C" BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
HWND hWnd;
HWND hParWnd, hButWnd;
int d, d1;
switch (fdwReason)
{
case DLL_PROCESS_ATTACH: hWnd = GetMainWindow();
if (hWnd)
hWnd = ::FindWindowEx(hWnd, , TEXT("EDIT"), NULL);
if (hWnd)
{
::MessageBox(hWnd, TEXT("开始注入"), TEXT("提示"), MB_OK);
MyPostMessage(hWnd);
}
else
{
::MessageBox(hWnd, TEXT("记事本不存在"), TEXT("提示"), MB_OK);
}
break;
case DLL_PROCESS_DETACH:
// detach from process
break; case DLL_THREAD_ATTACH:
// attach to thread
break; case DLL_THREAD_DETACH:
// detach from thread
break;
}
return TRUE; // succesful
} BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam)
{
DWORD dwCurProcessId = *((DWORD*)lParam);
DWORD dwProcessId = ; GetWindowThreadProcessId(hwnd, &dwProcessId);
if (dwProcessId == dwCurProcessId && GetParent(hwnd) == NULL)
{
*((HWND *)lParam) = hwnd;
return FALSE;
}
return TRUE;
} HWND GetMainWindow()
{
DWORD dwCurrentProcessId = GetCurrentProcessId();
if (!EnumWindows(EnumWindowsProc, (LPARAM)&dwCurrentProcessId))
{
return (HWND)dwCurrentProcessId;
}
return NULL;
} void MyPostMessage(HWND hWnd)
{
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
PostMessageW(hWnd, WM_CHAR, L',', );
PostMessageW(hWnd, WM_CHAR, L']', );
PostMessageW(hWnd, WM_CHAR, L']', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
PostMessageW(hWnd, WM_CHAR, L'/', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
PostMessageW(hWnd, WM_CHAR, L']', );
PostMessageW(hWnd, WM_CHAR, L']', );
PostMessageW(hWnd, WM_CHAR, L']', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
PostMessageW(hWnd, WM_CHAR, L'/', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L']', );
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
PostMessageW(hWnd, WM_CHAR, L']', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L']', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L']', );
PostMessageW(hWnd, WM_CHAR, L'/', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L']', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
PostMessageW(hWnd, WM_CHAR, L'.', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'/', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'=', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L'=', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L'=', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L'=', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L'=', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L' ', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'=', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'^', );
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'/', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L' ', );
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'/', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'/', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'=', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'^', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'/', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'/', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'/', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'[', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'/', );
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'[', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\\', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'/', );
PostMessageW(hWnd, WM_CHAR, L'.', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L',', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L'O', );
}
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'.', );
PostMessageW(hWnd, WM_CHAR, L'\\', );
PostMessageW(hWnd, WM_CHAR, L'O', );
PostMessageW(hWnd, WM_CHAR, L'`', );
for (int i = ; i < ; i++) {
PostMessageW(hWnd, WM_CHAR, L' ', );
}
PostMessageW(hWnd, WM_CHAR, L'\n', );
}
Dll文件
#include <iostream>;
using namespace std;
#include <windows.h>;
#include <tlhelp32.h>;
#include <tchar.h>; HANDLE hThread = NULL;
//进程名称查找进程ID
DWORD ProcessFind(LPCTSTR Exename) //进程名称
{
HANDLE hProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (!hProcess)
{
return FALSE;
}
PROCESSENTRY32 info;
info.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hProcess, &info))
{
return FALSE;
}
while (TRUE)
{
cout << endl;
if (_tcscmp(info.szExeFile, Exename) == )
{
return info.th32ProcessID;//返回进程的ID
}
if (!Process32Next(hProcess, &info))
{
return FALSE;
}
}
return FALSE; } int dll_inject() {
//Dll文件地址,改成你自己的地址
const TCHAR *pLocDll = TEXT("F:\\工作\\项目\\控制台\\injection\\injection\\x64\\Release\\injectionDll.dll"); HANDLE hThread = NULL; //记事本进程名称
DWORD ProcessID = ProcessFind(TEXT("notepad.exe"));
if (!ProcessID) {
cout << "查找不到当前程序" << endl;
}
else {
//获取进程ID
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, TRUE, ProcessID); //获取dll大小
SIZE_T PathSize = (_tcslen(TEXT("injectionDll.dll")) + ) * sizeof(TCHAR); //申请内存
LPVOID StartAddress = VirtualAllocEx(hProcess, NULL, PathSize, MEM_COMMIT, PAGE_READWRITE); //写入内存
bool bSuccess = WriteProcessMemory(hProcess, StartAddress, TEXT("injectionDll.dll"), PathSize, );
if (!bSuccess)
{
cout << "写入失败" << endl;
}
else {
//在寄主申请内存
LPVOID strRmt = VirtualAllocEx(hProcess, nullptr, MAX_PATH, MEM_COMMIT, PAGE_READWRITE);
//获得注入DLL大小
size_t lenLocDll = * _tcslen(pLocDll);
//判断寄主申请内存是否成功
if (strRmt) {
//把DLL写入寄主内存
BOOL ret = WriteProcessMemory(hProcess, strRmt, pLocDll, lenLocDll, nullptr);
//获得LoadLibraryW的函数地址以使用LoadLibrary函数
LPTHREAD_START_ROUTINE loadlib = LPTHREAD_START_ROUTINE(GetProcAddress(GetModuleHandle(TEXT("Kernel32")), "LoadLibraryW"));
//注入
hThread = CreateRemoteThread(hProcess, nullptr, , loadlib, LPVOID(strRmt), , nullptr);
} /*
HANDLE hThread = CreateRemoteThread(hProcess, 0, 0, (LPTHREAD_START_ROUTINE)GetProcAddress(GetModuleHandle(_T("kernel32.dll")), "LoadLibrary"), StartAddress, 0, 0);*/ if (hThread == NULL)
{
cout << "在进程中注入失败:";
cout << GetLastError() << endl;
return -;
} WaitForSingleObject(hThread, INFINITE);
//到这里已经完成dll的加载即注入了,通过dll函数执行我们要完成的任务
//释放
VirtualFreeEx(hProcess, StartAddress,, MEM_RELEASE);
CloseHandle(hThread);
CloseHandle(hProcess);
}
}
}
int main()
{
dll_inject();
system("pause");
}
主程序
C++注入记事本升级版,给记事本弄爱心的更多相关文章
- C++注入记事本
#include <iostream>; using namespace std; #include <windows.h>; #include <tlhelp32.h& ...
- qt5.5实现 记事本程序
最近由于要做Qt相关的毕业设计课题,以前对Qt完全不了解,对于客户端图形界面程序,也只对Windows下的MFC熟悉, 所以,由于Qt的跨平台特性和相对比较纯的C++的特点,就准备学习一下吧.这两天逛 ...
- Swift3.0服务端开发(五) 记事本的开发(iOS端+服务端)
前边以及陆陆续续的介绍了使用Swift3.0开发的服务端应用程序的Perfect框架.本篇博客就做一个阶段性的总结,做一个完整的实例,其实这个实例在<Swift3.0服务端开发(一)>这篇 ...
- Windows 记事本的 ANSI、Unicode、UTF-8 这三种编码模式有什么区别?
[梁海的回答(99票)]: 简答.一些细节暂无精力查证,如果说错了还请指出. 一句话建议:涉及兼容性考量时,不要用记事本,用专业的文本编辑器保存为不带 BOM 的UTF-8. * * * 如果是为了跨 ...
- 微信小程序入门实例之记事本
主要实现思想都在代码的注释中,项目源码见github 首先上项目目录 app.js文件代码如下: //app.js App({ onLaunch: function() { //调用API从本地缓存中 ...
- 用tkinter写一个记事本程序(未完成)
之前在看tkinter与python编程 ,后面学opengl就把那本书搁置了.几天没用tkinter,怕是基本的创建组件那些都忘记了,所以想着用tkinter试着写一下记事本程序.一开始的时候以为很 ...
- sqlmap:入门(手工注入)
一. 联合查询注入union(less-1) 1. union操作符用于合并两个或多个select语句结果集: 2. union后的select语句必须拥有和最前的select语句拥有相同数量的字段, ...
- CTF-sql-宽字节注入
本文章主要涉及sql宽字节注入注入的原理讲解,如有错误,望指出.(附有目录,如需查看请点右下角) 一.首先介绍一下本篇文章所用到的知识点: 常用到的url编码: 空格:%20 单引号:%27 在sql ...
- div的优缺点
div+css优缺点 产生背景 HTML语言自HTML4.01以来,不再发布新版本,原因就在于HTML语言正变得越来越复杂化.专用化.即标记越来越多,甚至各个浏览器生产商也开发出只适合于其特定浏览 ...
随机推荐
- Linux 第六天
1)locate 在文件资料库中查找文件(需要文件资料库中有,新建的文件查不到,需要手动更新,updatedb.查不到/tmp目录下的文件) 语法:locate 文件名 常用选项: -i:无视大小写查 ...
- UVa 11645 Bits (暴力+组合数学)
题意:给定一个数 n,求 0 ~ n,中二进制表示中连续两个 1 出现的次数. 析:枚举连续的两个 1,从低位向高位进行枚举,然后前可以是任意数,后面也是任意的,如果 n 正好是 11 还要另算,举个 ...
- 【repost】学JS必看-JavaScript数据结构深度剖析
JavaScript以其强大灵活的特点,被广泛运用于各种类型的网站上.一直以来都没怎么好好学JS,只是略懂皮毛,看这篇文章时有读<PHP圣经>的感觉,作者深入浅出.生动形象地用各种实例给我 ...
- python 在unix下json格式显示结果
在使用命令号输出接口测试结果,发现无法按照期望的json格式进行显示.查阅资料发现python自带强大的工具. 直接上代码: import os,requests url = XXXXXX conte ...
- 解决eclipse部署maven时,src/main/resources里面配置文件加载不到webapp下classes路径下的问题
解决eclipse部署maven时,src/main/resources里面配置文件加载不到webapp下classes路径下的问题. 有时候是src/main/resources下面的,有时候是sr ...
- EF6 学习笔记(三):排序、过滤查询及分页
EF6 学习笔记索引目录页: ASP.NET MVC5 及 EF6 学习笔记 - (目录整理) 上篇:EF6 学习笔记(二):操练 CRUD 增删改查 本篇原文地址:Sorting, Filterin ...
- Qt中的CSS配置(QDarkStyleSheet)
QDarkStylesheet gihub地址 https://github.com/ColinDuquesnoy/QDarkStyleSheet
- cant found Microsoft.VSSDK.BuildTools.15.0.26201
如果在vs扩展开发中出现 严重性 代码 说明 项目 文件 行 禁止显示状态 错误 Failed to load 'C:\程序\EncodingNormalior\packages\Microsoft. ...
- Zhu-Takaoka Two-dimensional Pattern Matching
Two dimensional pattern matching. Details may be added later.... Corresponding more work can be foun ...
- 学爬虫,需要掌握哪些Python基础?
入手爬虫确实不要求你精通Python编程,但基础知识还是不能忽视的,那么我们需要哪些Python基础呢? 首先我们先来看看一个最简单的爬虫流程: 第一步要确定爬取页面的链接,由于我们通常爬取的内容 ...