| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 594 人关注过本帖
标题:dll 使用
只看楼主 加入收藏
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
结帖率:79.17%
收藏
 问题点数:0 回复次数:1 
dll 使用

#include<stdio.h>
#include<windows.h>
#include<string.h>

__declspec(dllexport) void demo()
{
#define PASSWORD_SIZE 100
#define PASSWORD "myGOODpassword\n"

int count = 0;
char buff[PASSWORD_SIZE]="";

for(;;)
{
// 提示用户输入密码并且读取他
printf("enter password: ");
fgets(&buff[0],PASSWORD_SIZE,stdin);

// 针对参数值匹配输入的密码
if(strcmp(&buff[0],PASSWORD))
{
// “声诉”密码不匹配
printf("WRONG password\n");
}
else break;

// 鉴定失败计数值+1,并且在密码试输三次后终止程序运行
if(++count > 2) return ;
}
// 程序执行到这里,意味着用户输入的密码是正确的
printf("password ok!\n");
}

int main()
{
HMODULE hmod;
void (*zzz)();
if(( hmod=LoadLibrary("crackme.exe") )
&&(zzz=(void(*)())GetProcAddress(hmod,"Demo")))
zzz();
return 0;
}
上面的程序怎么运行呀??因为直接编译,发现没有调用void demo()函数

搜索更多相关主题的帖子: dll windows PASSWORD include 
2007-11-18 17:58
vfdff
Rank: 6Rank: 6
等 级:侠之大者
威 望:8
帖 子:2172
专家分:425
注 册:2005-7-15
收藏
得分:0 

#include<stdio.h>
#include<windows.h>
#include<string.h>

extern "C"_declspec(dllexport) void demo();

int main()
{
//HMODULE hmod;
HINSTANCE hmod = NULL;
//void (*CreateFromFunct)();
typedef void (*VPF)();
VPF CreateFromFunct;
hmod=LoadLibrary("mycrack.dll");
if(hmod) {
CreateFromFunct=(VPF) GetProcAddress(hmod,"demo");
if(CreateFromFunct) CreateFromFunct();
else printf("Could not obtain function pointer\n");
}
else printf("Could not load mycrack.dll\n");

return 0;
}
修改成上面的代码后,运行提示 Could not obtain function pointer
这个说明 装载 mycrack.dll 成功
既然装载 mycrack.dll 成功,却不能得到 CreateFromFunct,是不是能说明这个库中没有demo这个函数?


~~~~~~~~~~~~~~~好好学习~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2007-11-20 16:44
快速回复:dll 使用
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014243 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved