VC模仿Rundll32.exe
来源:互联网 发布:上汽进出口 知乎 编辑:程序博客网 时间:2024/05/22 23:42
/* * FileName: my_Rundll32.cpp * Creator: 冷却 * Date: 2009年10月7日 * Comment: 模仿Windows里的一个名为Rundll32.exe的小工具 */ #include <windows.h> #pragma comment(linker, "/subsystem:windows") typedef void (*EntryPoint)( HWND hwnd, // handle to owner window HINSTANCE hinst, // instance handle for the DLL LPTSTR lpCmdLine, // string the DLL will parse int nCmdShow // show state ); int WINAPI WinMain( HINSTANCE hInstance, // handle to current instance HINSTANCE hPrevInstance, // handle to previous instance LPSTR lpCmdLine, // command line int nCmdShow // show state ) { if ( strlen(lpCmdLine)==0 ) { return -1; } char* buf=lpCmdLine; char* tmp=NULL; bool haveArg=true; int n,n1; int len = strlen(buf); tmp = strchr(buf, ','); if ( tmp == NULL ) { return -1; } int commaPos = (tmp-buf); int spacePos; tmp = strchr(buf, ' '); if ( tmp == NULL ) { spacePos = len; haveArg = false; } else { spacePos = (tmp-buf); } char* dllName=NULL; char* funName=NULL; char* arguments=NULL; dllName = new char[commaPos+1]; funName = new char[spacePos-commaPos]; if ( haveArg ) { arguments = new char[len-spacePos]; } else { arguments = new char[1]; strcpy(arguments, ""); } for ( n=0; n<commaPos; n++ ) { dllName[n] = buf[n]; } dllName[commaPos]=0; for ( n1=0,n=(commaPos+1); n<spacePos; n1++,n++ ) { funName[n1] = buf[n]; } funName[spacePos-commaPos-1]=0; if ( haveArg ) { for ( n1=0,n=spacePos+1; n<len; n1++,n++) { arguments[n1] = buf[n]; } arguments[len-spacePos-1]=0; } //这部分为核心部分,其余的均是为了解析参数 HINSTANCE dll_handle = LoadLibrary(dllName); if ( dll_handle != NULL ) { EntryPoint my_fun = (EntryPoint)GetProcAddress(dll_handle, funName); if ( my_fun != NULL ) { my_fun((HWND)hInstance, dll_handle, arguments, nCmdShow); } else { MessageBox(0,"丢失条目!",0,0); } } else { MessageBox(0,"找不到指定的模块!",0,0); } FreeLibrary(dll_handle); // delete[] dllName; delete[] funName; if ( haveArg ) { delete[] arguments; } return 0; }
阅读全文
0 0
- VC模仿Rundll32.exe
- 模仿Rundll32.exe
- 模仿Rundll32.exe
- rundll32.exe
- rundll32.exe
- 关于rundll32.exe
- Rundll32.exe使用方法大全
- Rundll32.exe介绍
- Rundll32.exe文件详解
- Rundll32.exe文件详解
- Rundll32.exe使用详解
- Rundll32.exe文件详解
- rundll32.exe进程详述
- Rundll32.exe进程
- rundll32.exe进程详述
- rundll32.exe的用途
- Rundll32.exe 进程
- Rundll32.exe文件详解
- 2016小米-懂二进制-Java
- linux 一台机器的并发量是咋确定的呢? 能接收多少并发estab数量
- 根据进程名判断进程是否运行
- java链接数据库插入数据中文乱码
- Makefile 入门
- VC模仿Rundll32.exe
- java中this关键字的基本使用
- Eclipse安装efxclipse插件(JavaFX工具)
- 暑期项目开发实训 Day5
- Linux系统CentOs7 安装mysql并启动
- 一个新手对java网站项目管理的理解,浅谈MVN,Git,SVN
- CodeForces
- 1248: Let the Balloon Rise
- iOS-浅谈runtime运行时机制01-类与对象的内部结构