赞
踩
- /*************************************/
- //wnd.h
- //
- /***********************************/
- #pragma once
-
- #define WM_GRAYCONTROLES WM_USER+100
-
- #define APP_NAME L"植物大战僵尸修改器 v1.2"
-
-
- #define WND_W 360
- #define WND_H 230
-
- #define IMG_H 55
-
- #define ID_TIMER 1
- #define TIMER_SLEEP_TIME 1000
-
- #include <windows.h>
- #include <tchar.h>
- #include <Commctrl.h>
- #include <psapi.h>
- #include <process.h>
-
-
- #pragma comment(lib, "psapi")
- #pragma comment(lib, "comctl32.lib")
-
- #pragma comment(linker,"/manifestdependency:\"type='win32'\
- name='Microsoft.Windows.Common-Controls' "\
- "version='6.0.0.0' \
- processorArchitecture='*'\
- publicKeyToken='6595b64144ccf1df' \
- language='*'\"")
-
- BOOL CALLBACK DlgProc(HWND,UINT,WPARAM,LPARAM);
- LRESULT CALLBACK WndProc(HWND,UINT,WPARAM,LPARAM);
-
- BOOL EnableDebugPrivilege(HANDLE hProcess);
- HWND FindDestWnd();
- DWORD GetPIDFromeWnd();
- HANDLE OpenProcessWithDbg(DWORD PID);
-
-
- DWORD GetPIDFromeProcesses(LPCTSTR lpWndName);
-
- /*************************************/
- //wnd.cpp
- //
- /***********************************/
-
-
- #include "Wnd.h"
- #include "resource.h"
- #include "InjectCode.h"
-
- BOOL g_bWndActive = false;
-
- BOOL EnableDebugPrivilege(HANDLE hProcess)
- {
- HANDLE hToken;
- LUID luid;
- TOKEN_PRIVILEGES tp;
-
- //打开令牌环
- BOOL bOK = OpenProcessToken(hProcess,TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY,&hToken);
- if(!bOK)
- return FALSE;
-
- bOK = LookupPrivilegeValue(NULL,SE_SECURITY_NAME,&luid);
- if(!bOK)
- return FALSE;
-
- tp.PrivilegeCount = 1;
- tp.Privileges[0].Luid = luid;
- tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
-
- //调整权限
- bOK = AdjustTokenPrivileges(hToken, FALSE, &tp, sizeof(TOKEN_PRIVILEGES),NULL,NULL);
-
- if(!bOK)
- return FALSE;
- CloseHandle(hToken);
- return TRUE;
- }
-
-
- int WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR lpCmdLine, int nShowCmd)
- {
- InitCommonControls();
-
- HWND hWnd;
- MSG msg;
- TCHAR szClsName[] = L"MainWnd";
- WNDCLASSEX wcex;
-
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.hInstance = hInst;
- wcex.lpfnWndProc = WndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
-
- wcex.hbrBackground = (HBRUSH)(COLOR_MENUBAR+1);
- wcex.lpszClassName = szClsName;
- wcex.lpszMenuName = NULL;
- wcex.style = 0;
- wcex.hIconSm = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON1));
- wcex.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(IDI_ICON2));
-
- if(!RegisterClassEx(&wcex))
- return 0;
-
- hWnd = CreateWindowEx(
- WS_EX_CONTROLPARENT,
- szClsName,
- APP_NAME,
- (WS_CLIPCHILDREN
- |WS_CLIPSIBLINGS
- |WS_MINIMIZEBOX
- |WS_SYSMENU
- |WS_CAPTION
- |WS_TABSTOP)
- &(~WS_MAXIMIZEBOX ),
- GetSystemMetrics(SM_CXFULLSCREEN)/2-WND_W/2,
- GetSystemMetrics(SM_CYFULLSCREEN)/2-WND_H/2,
- WND_W,
- WND_H,
- NULL,
- NULL,
- hInst,NULL);
- if(!hWnd)
- return 0;
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。