MFC DLL

来源:互联网 发布:免费教务软件 编辑:程序博客网 时间:2024/06/05 07:36

其他:DLL劫持防范:可以采用数字签名,通过计算DLL文件的数字签名,在加在时候进行验证即可。

Regular DLL:凡是支持DLL技术的都可以使用,不限于MFC程序使用。

Exten DLL:MFC DLL的扩展,用来导出MFC类,一般仅在MFC中使用。

条件宏:AFX_EXT_CLASS#ifndef AFX_EXT_DATA    #ifdef _AFXEXT        #define AFX_EXT_CLASS       AFX_CLASS_EXPORT        #define AFX_EXT_API         AFX_API_EXPORT        #define AFX_EXT_DATA        AFX_DATA_EXPORT        #define AFX_EXT_DATADEF    #else        #define AFX_EXT_CLASS       AFX_CLASS_IMPORT        #define AFX_EXT_API         AFX_API_IMPORT        #define AFX_EXT_DATA        AFX_DATA_IMPORT        #define AFX_EXT_DATADEF    #endif#endif

XXX.h

#ifdef DLL_API#else#define DLL_API __declspec(dllimport)

XXX.cpp

/*在DLL的工程文件中定义导出宏,如果没有定义这个宏,头文件会自动设置为导入模式,这样在给到其他应用工程的时候无需手动填写__declspec(dllexport)*/#define DLL_API  __declspec(dllexport)#include "XXX.h"

应用程序的配置信息保存:
通常可以自定义配置信息的格式,并写入文件,下次打开文件载入就可以使用。
windows下的保存配置信息手法:ini文件 注册表

//ini文件格式[节]key1 = value1key2 = value2key3 = value3//“=”左边类似注册表中的键,“=”右边相当于键值//微软提供的相应的API函数WriteProfileString("节名", "键", "键值");WritePrivateProfileString//语法详见MSDN

//regedit 注册表编辑器,每个计算机一般有5个根键
扩展可以支持环境变量的识别(%windir%)
Metasploit windows渗透工具 获取明文密码

RegCreateKeyEx()
没有就创建,有了就直接打开它

LONG RegCreateKeyEx(  HKEY hKey,        // handle to open key  LPCTSTR lpSubKey, // subkey name  DWORD Reserved,   // reserved  LPTSTR lpClass,   // class string  DWORD dwOptions,  // special options  REGSAM samDesired,// desired security access  LPSECURITY_ATTRIBUTES lpSecurityAttributes, // inheritance  PHKEY phkResult,  // key handle   LPDWORD lpdwDisposition  // disposition value buffer);LONG RegSetValueEx(  HKEY hKey,           // handle to key  LPCTSTR lpValueName, // value name  DWORD Reserved,      // reserved  DWORD dwType,        // value type  CONST BYTE *lpData,  // value data  DWORD cbData         // size of value data);RegCloseKey(hKey);LONG RegDeleteValue(                    HKEY hKey,              // handle to key                    LPCTSTR lpValueName);   // value name)

查询注册表:

0 0
原创粉丝点击