UINT GetNextUserF(FILE *file)
{
char cUser[MAX_LINELENGTH ],*token;
FILE *fUser;
int i,flag=0;
if(NULL==(fUser=fopen(sUserRoad,"r+"))) file://sUserRoad:是保存用户名的路径及文件名
{
MessageBox(GetActiveWindow(),"打开文件时出错。","消息",0);
if(fUser!=NULL)fclose(fUser);
return 0;
}
while(!feof(fUser))
{
for(i=0;i
if(NULL==fgets(cUser,MAX_LINELENGTH,fUser))
{
bCheckUser=FALSE;//记录用户名枚举完
fclose(fUser);
return 0;
}
token=strtok(cUser,SETPRATE);// #define SETPRATE " \t\n\r"
do
{
WaitForSingleObject(gEventNextUser,INFINITE);
// 等待“新用户名”事件
gEventNextUser.ResetEvent();//复位。
for(i=0;i
strcpy(cCurrentUser,token);//改变当前用户名。
gEventUserOk.SetEvent();//发送“用户名完成”事件
}while((token=strtok(NULL,SETPRATE))!=NULL);
}
return 1;
}
5.密码枚举:
UINT GetNextPassL(LPVOID pParam)
{
int i,j,iPre;
char cBuf[MAX_PASSWORD_LENGTH];
BEGIN:
for(int m=0;m
{
file://char cCurrentCharList[MAX_CHARLIST_LENGTH]:当前密码组成字符集合列表
file://例如:cCurrentCharList =“abcd”:表示枚举的密码由abcd组成
file://int cCurrentPCList[MAX_CHARLIST_LENGTH]:指向当前密码
file://组成字符集合列表的列表
file://例如:4444:表示生成密码为“dddd”,
file://4231:表示生成密码为“dbca”......
cCurrentPCList[m]= iCharCount;
// iCharCount:密码组成字符的字符个数
}
while( cCurrentPCList[0]>=0)//如果CurList.cCurrentPCList[0]<0 结束
{
for(int n=0;n
while(1)
{
for(i=0;i
{
cBuf[i]=cCurrentCharList[cCurrentPCList[i]];
}
WaitForSingleObject(gEventNextPass,INFINITE);
// 等待“新密码”事件
gEventNextPass.ResetEvent();//复位。
for(int n=0;n
strcpy( cCurrentPass,cBuf);//改变当前密码。
gEventPassOk.SetEvent();//送密码完成事件
file://进行cCurrentPCList数组的处理。
if(( cCurrentPCList[i-1]--)==0)break;
}
file://最后一位复iCharCount;;
cCurrentPCList[i-1]= iCharCount;
iPre=1;//借位标志
for(j=i-2;j>=0;j--)
{
if(( cCurrentPCList[j]-=iPre)<0)
{
if(j==0)break;//结束。
cCurrentPCList[j]= iCharCount;iPre=1;//复位J,向上借位。
}
else {iPre=0;continue;}//不必再向上借位。
}
}
if(cCurrentPCList[0]<=0)
{
file://复位,进入下一个循环。
if(!bCheckUser)//如果用户名枚举完
{
MessageBox(GetActiveWindow(),"所有的用户名及密码已枚举完。","消息",0);
return 0;
}
gEventNextUser.SetEvent();//发送“新用户名”事件
WaitForSingleObject(gEventUserOk,INFINITE);
file://等待“用户名完成”事件
gEventUserOk.ResetEvent();//复位。
goto BEGIN;
}
return 0;
}


