了解一下Windows Cracker
Windows Cracker
消息拆析宏
可以为消息进行参数分解
无需记住或查阅资料来了解WParam和lParam的意义
可以忘记旧的消息处理方式:switch/case
不适合于大型复杂的需要处理大量消息的应用: coding is slow and program debugging and maintenance become slow as the application grows.
WindowsX.h
包含三种类型的宏: Macro APIs, window message crackers, Control APIs
优点:
1)减少强制类型转换数量,避免强制类型转换出错;
2)程序可读性增强;
3)16位和Win32 API之间的转换;
4)简便易懂(宏);
5)容易与现存代码结合;
6)可用于C语言和C++语言;
7)可效仿编制自己的宏;
8) 使用这些宏,你不必关心和了解隐含的Windows结构。
代码Demo:
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include <cstdio>
FILE* fp = NULL; /* BOOL Cls_OnCreate(HWND hwnd, LPCREATESTRUCT lpCreateStruct) */
//#define HANDLE_WM_CREATE(hwnd, wParam, lParam, fn) ((fn)((hwnd), (LPCREATESTRUCT)(lParam)) ? 0L : (LRESULT)-1L)
//#define FORWARD_WM_CREATE(hwnd, lpCreateStruct, fn) (BOOL)(DWORD)(fn)((hwnd), WM_CREATE, 0L, (LPARAM)(LPCREATESTRUCT)(lpCreateStruct)) BOOL fnWndProc_OnCreate(HWND hWnd, LPCREATESTRUCT lpCreateStruct)
{
fprintf(fp," Entering fnWndProc_OnCreate()\n");
fprintf(fp," hWnd = %u\n",(unsigned)hWnd);
fprintf(fp," Leaving fnWndProc_OnCreate()\n\n"); /* MSDN states WM_CREATE should return 0 to continue and -1 for failure */
//return FALSE; /* but the HANDLE_WM_CREATE macro translates return values greater than zero to 0, and the rest to -1. */
return TRUE;
} /* void Cls_OnSize(HWND hwnd, UINT state, int cx, int cy) */
// #define HANDLE_WM_SIZE(hwnd, wParam, lParam, fn) ((fn)((hwnd), (UINT)(wParam), (int)(short)LOWORD(lParam), (int)(short)HIWORD(lParam)), 0L)
// #define FORWARD_WM_SIZE(hwnd, state, cx, cy, fn) (void)(fn)((hwnd), WM_SIZE, (WPARAM)(UINT)(state), MAKELPARAM((cx), (cy))) void fnWndProc_OnSize(HWND hWnd, UINT state, int cx, int cy)
{
fprintf(fp," Entering fnWndProc_OnSize()\n");
fprintf(fp," Width = %d\tHeight = %d\n",cx,cy);
fprintf(fp," Leaving fnWndProc_OnSize()\n\n");
} /* void Cls_OnPaint(HWND hwnd) */
// #define HANDLE_WM_PAINT(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
// #define FORWARD_WM_PAINT(hwnd, fn) (void)(fn)((hwnd), WM_PAINT, 0L, 0L) void fnWndProc_OnPaint(HWND hWnd)
{
PAINTSTRUCT ps;
HDC hDC; fprintf(fp," Entering fnWndProc_OnPaint()\n");
hDC=BeginPaint(hWnd,&ps);
fprintf(fp," Painting Window!\n");
fprintf(fp," ps.rcPaint.right = %d\n",(int)ps.rcPaint.right);
fprintf(fp," ps.rcPaint.bottom = %d\n",(int)ps.rcPaint.bottom);
EndPaint(hWnd,&ps);
fprintf(fp," Leaving fnWndProc_OnPaint()\n\n");
} /* void Cls_OnClose(HWND hwnd) */
// #define HANDLE_WM_CLOSE(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
// #define FORWARD_WM_CLOSE(hwnd, fn) (void)(fn)((hwnd), WM_CLOSE, 0L, 0L) void fnWndProc_OnClose(HWND hWnd)
{
fprintf(fp," Entering fnWndProc_OnClose()\n");
fprintf(fp," hWnd = %u\n",(unsigned)hWnd);
DestroyWindow(hWnd);
fprintf(fp," Leaving fnWndProc_OnClose()\n");
} /* void Cls_OnDestroy(HWND hwnd) */
// #define HANDLE_WM_DESTROY(hwnd, wParam, lParam, fn) ((fn)(hwnd), 0L)
// #define FORWARD_WM_DESTROY(hwnd, fn) (void)(fn)((hwnd), WM_DESTROY, 0L, 0L) void fnWndProc_OnDestroy(HWND hWnd)
{
fprintf(fp," Entering fnWndProc_OnDestroy()\n");
fprintf(fp," hWnd = %u\n",(unsigned)hWnd);
PostQuitMessage();
fprintf(fp," Leaving fnWndProc_OnDestroy()\n");
} LRESULT CALLBACK fnWndProc(HWND hwnd, unsigned int msg, WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
HANDLE_MSG(hwnd, WM_CREATE, fnWndProc_OnCreate);
HANDLE_MSG(hwnd, WM_SIZE, fnWndProc_OnSize);
HANDLE_MSG(hwnd, WM_PAINT, fnWndProc_OnPaint);
HANDLE_MSG(hwnd, WM_CLOSE, fnWndProc_OnClose);
HANDLE_MSG(hwnd, WM_DESTROY, fnWndProc_OnDestroy);
default:return (DefWindowProc(hwnd, msg, wParam, lParam));
}
} int WINAPI WinMain(HINSTANCE hIns, HINSTANCE hPrevIns, LPSTR lpszArgument, int nShow)
{
TCHAR szClassName[] = _T("Debugging Windows Programs");
WNDCLASSEX wc;
MSG messages;
HWND hWnd; wc.lpszClassName = szClassName; wc.lpfnWndProc=fnWndProc;
wc.cbSize = sizeof(WNDCLASSEX); wc.style=CS_DBLCLKS;
wc.hIcon = LoadIcon(NULL,IDI_APPLICATION); wc.hInstance=hIns;
wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor=LoadCursor(NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; wc.cbWndExtra=;
wc.lpszMenuName = NULL; wc.cbClsExtra=;
RegisterClassEx(&wc);
fp = fopen("Output.txt","w");
fprintf(fp,"Output.txt Opened In WinMain()\n");
hWnd = CreateWindowEx(,szClassName,szClassName,WS_OVERLAPPEDWINDOW,,,,,HWND_DESKTOP,,hIns,);
ShowWindow(hWnd,nShow);
while(GetMessage(&messages,NULL,,))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
fprintf(fp,"Output.txt Closed In WinMain()\n");
fclose(fp); return messages.wParam;
}
输出Output.txt
Output.txt Opened In WinMain()
Entering fnWndProc_OnCreate()
hWnd = 658154
Leaving fnWndProc_OnCreate() Entering fnWndProc_OnSize()
Width = 304 Height = 267
Leaving fnWndProc_OnSize() Entering fnWndProc_OnPaint()
Painting Window!
ps.rcPaint.right = 304
ps.rcPaint.bottom = 267
Leaving fnWndProc_OnPaint() Entering fnWndProc_OnClose()
hWnd = 658154
Entering fnWndProc_OnDestroy()
hWnd = 658154
Leaving fnWndProc_OnDestroy()
Leaving fnWndProc_OnClose()
Output.txt Closed In WinMain()
参考:http://www.cplusplus.com/forum/windows/59737/
http://www.softpedia.com/get/Programming/SDK-DDK/Message-Cracker-Wizard.shtml (Message Cracker Wizard)
An innovative tool makes every Windows developer forget about the old way of handling messages!
百度云:http://pan.baidu.com/s/1dFkTds9%20 密码:8q7o
了解一下Windows Cracker的更多相关文章
- Windows下底层数据包发送实战
1.简介 所谓“底层数据包”指的是在“运行”于数据链路层的数据包,简单的说就是“以太网帧”,而我们常用的Socket只能发送“运行”在传输层的TCP.UDP等包,这些传输层数据包已经能满足绝大部分需求 ...
- 基于Windows环境下Myeclipse10.0下载安装破解及jdk的下载安装及环境变量的配置
jdk的安装及环境变量的配置 1.安装JDK开发环境 附上jdk安装包的百度云链接 链接:http://pan.baidu.com/s/1mh6QTs8 密码:jkb6(当然自行去官网下载最好哒,可以 ...
- 7 Best Free RAR Password Unlocker Software For Windows
Here is the list of Best Free RAR Password Unlocker Software for Windows. These software run differe ...
- Windows Server2003 IIS服务器安全配置整理
一.系统的安装 1.按照Windows2003安装光盘的提示安装,默认情况下2003没有把IIS6.0安装在系统里面.2.IIS6.0的安装 开始菜单—>控制面板—>添加或删除程序—& ...
- WINDOWS常用端口列表
按端口号可分为3大类: (1)公认端口(Well Known Ports):从0到1023,它们紧密绑定(binding)于一些服务.通常这些端口的通讯明确表明了某种服务的协议.例如:80端口实际上总 ...
- 我是如何破解你的WINDOWS密码的 ?(2)
介绍 在这个系类的第一部分中,我们揭示了windows创建和储存密码的机制.我们也涉猎了一点两种加密方法的弱点和破解的方法.在这系列的第二篇也是最后一篇文章中,我会实战用网上免费的工具一步一步的来破解 ...
- Windows server 2012 添加中文语言包(英文转为中文)(离线)
Windows server 2012 添加中文语言包(英文转为中文)(离线) 相关资料: 公司环境:亚马孙aws虚拟机 英文版Windows2012 中文SQL Server2012安装包,需要安装 ...
- Windows Server 2012 NIC Teaming介绍及注意事项
Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...
- C# 注册 Windows 热键
闲扯: 前几日,一个朋友问我如何实现按 F1 键实现粘贴(Ctrl+V)功能,百度了一个方法,发给他,他看不懂(已经是 Boss 的曾经的码农),我就做了个Demo给他参考.今日得空,将 Demo 整 ...
随机推荐
- SqlServer 如何知道是否发生了索引碎片
--如何知道是否发生了索引碎片 SELECT object_name(dt.object_id) Tablename,si.name IndexName,dt.avg_fragmentation_in ...
- 解决MAC下xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools)的问题
将系统升级到了最新10.13.3 macOS High Sierra后,在使用ctags命令时会出现如下问题: xcrun: error: invalid active developer path ...
- 在Windows上开发PHP扩展模块
环境: window + php + apache + vc6 + cygwin 下载:php二进制文件: php-5.3.10-Win32-VC9-x86 php源码包:php-5.3 ...
- flask celery 使用方法
一.安装 由于celery4.0不支持window,如果在window上安装celery4.0将会出现下面的错误flask_clery 你现在只能安装pip install celery==3.1 二 ...
- u-boot mkconfig文件分析
#!/bin/sh -e #遇到非0返回 就退出脚本 # Script to create header files and links to configure # U-Boot for a spe ...
- Ubuntu 16.04和win10双系统时间不一致解决办法
windows10和ubuntu16.04双系统,装完后,在windows下时间不对,之前的老办法是: sudo gedit /etc/default/rcS 2 utc=yes 改成utc=no 然 ...
- maven jetty指定端口启动
eclipse里修改 Goals值 Tomcat -Dmaven.tomcat.port=8080 tomcat:run Jetty -Djetty.port=8081 jetty:run
- 爬取千万淘宝商品的python脚本
import time import leveldb from urllib.parse import quote_plus import re import json import itertool ...
- SQL Server 2008 压缩日志
USE [master]GOALTER DATABASE DNName SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE DNName SET RECO ...
- HIVE中的order by操作
hive中常见的高级查询包括:group by.Order by.join.distribute by.sort by.cluster by.Union all.今天我们来看看order by操作,O ...