mfc能否反编译
㈠ MFC下如何关闭外部程序,例如关闭一个以notepad.exe D:\\text.txt打开的进程
STARTUPINFOsi;
PROCESS_INFORMATIONpi;
LPTSTRszCmdline=_tcsp(TEXT("notepad.exeD:\text.txt"));
ZeroMemory(&si,sizeof(si));
si.cb=sizeof(si);
ZeroMemory(&pi,sizeof(pi));
//Startthechildprocess.
if(!CreateProcess(NULL,//Nomolename(usecommandline)
szCmdline,//Commandline
NULL,//Processhandlenotinheritable
NULL,//Threadhandlenotinheritable
FALSE,//SethandleinheritancetoFALSE
0,//Nocreationflags
NULL,//Useparent'senvironmentblock
NULL,//Useparent'sstartingdirectory
&si,//PointertoSTARTUPINFOstructure
&pi)//PointertoPROCESS_INFORMATIONstructure
)
{
printf("CreateProcessfailed(%d). ",GetLastError());
return;
}
//Waituntilchildprocessexits.
WaitForSingleObject(pi.hProcess,INFINITE);
//这里就是关闭
//Closeprocessandthreadhandles.
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
后,子进程就与父进程彻底脱离关系了,在Windows下进程之间的关系比较弱,不仅没有父进程收割子进程退出状态这一回事,甚至连getppid这样的API也没有。这又导致了两个现象,
1)Windows下不用当心Linux下的僵死进程问题。
2.)当失去句柄仅仅知道进程ID时,Windows下甚至无法判断此进程是否就是原有进程,(用OpenProcess打开的句柄无法判定是否就是原来的进程)假如此进程已经结束,也无法获取到进程的退出状态。(在Windows下获取进程退出状态必须得保留进程的句柄,然后调用GetExitCodeProcess)
3.现在一般的游戏都已经不允许直接运行了,这点的目的很简单,加大别人用反编译软件调试游戏主程序的难度。按照CreateProcess的默认参数的直接创建原游戏主程序时,会碰到一个问题,及当发生原程序发生缺少动态库等情况时,原有系统弹出的提示对话框会被调用CreateProcess的进程吞掉,使得这类错误被掩盖,因为此时CreateProcess返回值实际是成功的。这时候,将CreateProcess的参数Process Creation Flags设为CREATE_DEFAULT_ERROR_MODE就可以让原有的提示窗口弹出来。
4. Process Creation Flags设为CREATE_SUSPENDED时,可以将欲创建进程挂起,这时想对新进程干啥都行,甚至可以尝试更改其代码段以影响程序运行,(但是大部分带监控的杀毒软件会有警告)。然后用ResumeThread API去让原进程的主线程运行起来。
5.CreateProcess创建的进程句柄实际代表的是一个Windows核心对象,适用于Windows核心对象的操作都可以对进程句柄进行,(核心对象的概念请参考《WIndows核心编程》,其中包括WaitForSingleObject等同步API。
㈡ 【MFC高手请进!!!】反编译出来的 MFC42.#4108 是什么函数积分用完了还没挣,抱歉!帮个忙!!
MFC42.#4108
?IsSelected@CView@@UBEHPBVCObject@@@Z
public: virtual int __thiscall CView::IsSelected(class CObject const *)const
MFC42.#5037
?OnSize@CScrollView@@QAEXIHH@Z
public: void __thiscall CScrollView::OnSize(unsigned int,int,int)
MFC42.#5053
?OnSysColorChange@CWnd@@IAEXXZ
protected: void __thiscall CWnd::OnSysColorChange(void)
MFC42.#5064
?OnToolHitTest@CToolBar@@UBEHVCPoint@@PAUtagTOOLINFOA@@@Z
public: virtual int __thiscall CToolBar::OnToolHitTest(class CPoint,struct tagTOOLINFOA *)const
MFC42.#5065
?OnToolHitTest@CWnd@@UBEHVCPoint@@PAUtagTOOLINFOA@@@Z
public: virtual int __thiscall CWnd::OnToolHitTest(class CPoint,struct tagTOOLINFOA *)const
㈢ 有关于Visual Studio 2005 EXE程序反编译成可用代码的问题~!~
你应该选择使用静态库啊。动态库你要运行必须连相关的dll一起拷贝到别人电脑上去!
还有一些特别的情况,虽然是针对VC2005的,但是对VC6也有参考价值。
前面一些是我在网上找的,后面的有些是我自己现添加的,希望对你有帮助!
报错"由于应用程序配置不正确,应用程序未能启动.重新安装应用程序可能会纠正这个问题"
//------------------------------------------------------
这个问题主要出现在XP环境下运行由Visual C++2003/2005编译的MFC程序时
问题现象是XP运行此类程序时,报错"由于应用程序配置不正确,应用程序未能启动.重新安装应用程序可能会纠正这个问题"
这个问题似乎许多人遇见过.在CSDN和微软社区里面都有人提到.但是没有完整的解决方案
这个问题的解决一共会遇见2个子问题
最早出现这个错误我和许多人认为的一样
认为是缺乏DLL库文件导致.但是在测试机复制了DLL甚至安装了.net framework 2.0以后
都无法解决问题,最后确认不是由缺乏DLL所致
因为程序是纯win32的应用程,非托管代码,所以也无需.net framework
Visual C++2003/2005默认的MFC程序是使用动态MFC库(Use MFC in a Shared DLL)来链接的
而动态MFC库使用的是Multi-threaded DLL (/MD)
由于XP对于PE文件格式监测更加严格.
就会导致部分使用多线程DLL的可执行文件在调用的时候出错
修改项目属性的编译开关
Project->Property->configuration Properties->C/C++->Code Generation->Runtime Library
修改成Multi-threaded (/MT)
修改了Runtime类型以后
需要将MFC的编译类型也改成静态库
Project->Property->configuration Properties->General->Use of MFC
修改成Use MFC in a Static Library
一部分情况下在这步就能解决问题
另外一部分情况会遇见如下情况
编译器报错
CODE:
nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)
[Copy to clipboard]
产生这个问题的原因是库依赖关系
在Project->Property->configuration Properties->Linker->Command Line
加入编译开关/verbose:lib可以显示详细的库链接顺序
CODE:
------ Build started: Project: PerfMonDemo, Configuration: Release Win32 ------
Linking...
Searching libraries
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\pdh.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\DelayImp.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\libcpmt.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\nafxcw.lib:
nafxcw.lib(afxmem.obj) : error LNK2005: "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z) already defined in libcpmt.lib(newaop.obj)
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\libcmt.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\kernel32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\user32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\gdi32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\msimg32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comdlg32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\winspool.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\advapi32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shell32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comctl32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shlwapi.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\uuid.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oledlg.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ole32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleaut32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\urlmon.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\atls.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ws2_32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\mswsock.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleacc.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\pdh.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\DelayImp.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\libcpmt.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\nafxcw.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\libcmt.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\kernel32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\user32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\gdi32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\msimg32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comdlg32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\winspool.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\advapi32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shell32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comctl32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shlwapi.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\uuid.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oledlg.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ole32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleaut32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\urlmon.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\atls.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ws2_32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\mswsock.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleacc.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\pdh.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\DelayImp.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\libcpmt.lib:
Finished searching libraries
Searching libraries
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\pdh.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\DelayImp.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\libcpmt.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\nafxcw.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\libcmt.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\kernel32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\user32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\gdi32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\msimg32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comdlg32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\winspool.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\advapi32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shell32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\comctl32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\shlwapi.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\uuid.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oledlg.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ole32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleaut32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\urlmon.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\OLDNAMES.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\atls.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\ws2_32.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\mswsock.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\oleacc.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib\pdh.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\DelayImp.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\lib\libcpmt.lib:
Searching d:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\lib\nafxcw.lib:
Finished searching libraries
.\Release/PerfMonDemo.exe : fatal error LNK1169: one or more multiply defined symbols found
Build log was saved at "file://d:\Dev\Performance Monitor\Release\BuildLog.htm"
PerfMonDemo - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
[Copy to clipboard]
我们发现在libcpmt.lib声明过的operator new在nafxcw.lib中再次定义
解决方法如下
Project->Property->configuration Properties->Linker->Input->Additional Dependencies
加入
nafxcw.lib
libcpmt.lib
Project->Property->configuration Properties->Linker->Input->Ignore Specific Library
加入
nafxcw.lib
libcpmt.lib
这样链接程序就不会先按照默认顺序来连接这两个库文件
而是在最后在加入对他们的引用.这样就避免了这个问题
下面是一张可能发生冲突的列表
若要使用此运行时库 请忽略这些库
单线程 (libc.lib) libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib
多线程 (libcmt.lib) libc.lib、msvcrt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib
使用 DLL 的多线程 (msvcrt.lib) libc.lib、libcmt.lib、libcd.lib、libcmtd.lib、msvcrtd.lib
调试单线程 (libcd.lib) libc.lib、libcmt.lib、msvcrt.lib、libcmtd.lib、msvcrtd.lib
调试多线程 (libcmtd.lib) libc.lib、libcmt.lib、msvcrt.lib、libcd.lib、msvcrtd.lib
使用 DLL 的调试多线程 (msvcrtd.lib) libc.lib、libcmt.lib、msvcrt.lib、libcd.lib、libcmtd.lib
//本人曾经对上面的方法进行测试,修改后可能出现XX无法解析的情况,请大家使用MSDN查找该函数,并且找到该函数对应的lib库文件。将其添加到附加依赖项或者是用#pragma comment(lib,"xxx.lib")将其添加到代码中!
㈣ 怎么在没有源代码的情况下修改一个软件用的MFC。反编译还是有别的办法
不用反编译,用钩子函数就可以。windows系统打补丁就是用这种技术。大概是设计一个新的dll库文件挂在原来的程序上,实现一些功能的替换