用C语言写的迅雷看看XV文件提取器及C语言源代码
tfref
如果你没用过迅雷看看, 或是不知道XV文件的, ...
写了很久了, 但是担心版权问题, 一直没有帖出来~~~
能提取截止目前最新版本的迅雷看看XV文件. 好了, 不多说, 懒得多说.
还是开源吧, 效果图以后补上. 暂时没有需要转换的文件. :-)
这一版本我忘了写检查磁盘剩余空间的过程, 呃, ...
/* tabsize:4 */ #include <stdio.h> #include <string.h> #define _WIN32_WINNT 0x0502 #include <Windows.h>int cntFileProcessed = 0; //count file that processed, accumulated. int scrWidth; //screen widthvoid ResetCursorPos(void) {CONSOLE_SCREEN_BUFFER_INFO sbi;COORD co;HANDLE hOutput;hOutput = GetStdHandle(STD_OUTPUT_HANDLE);GetConsoleScreenBufferInfo(hOutput, &sbi);co.X = sbi.dwCursorPosition.X-(5+1+4); //e.g.:1024M,100%co.Y = sbi.dwCursorPosition.Y;SetConsoleCursorPosition(hOutput, co);//sure to leave hOutput as it wasreturn; }void ExtractFile(char* filespec) { #define BUFSIZE ((1<<20)*5) //5M bufferHANDLE hFileIn = NULL; //handle of input fileHANDLE hFileOut = NULL; //handle of output file DWORD dwSizeRead = 0; //the ReadFile function Read sizeDWORD dwSizeWritten = 0;//the WriteFile function Written sizeDWORD dwSize = 0;int magicNumber = 0; //you may know when you look, I suppose.int fileType = 0; //indicates what file it is LARGE_INTEGER li; //for SetFilePointer function use,2M offset of REAL movie data BYTE hdr[4]; //the *.xv file headerBYTE ch; // char* pchar; //tmp usechar fileOut[MAX_PATH]; //namely, the output fileBYTE* buffer = NULL; //block extraction data, every time it extracts 5MB data at mostchar* errMsg = NULL; //FormatMessageint lastErr = 0; //GetLastErrorint percent = 0; //percentage of processed dataint readSize = 0; //total size ReadDWORD fileSize; //total file size, for percentage useint prtLen; //the printf(and its relative) returnedint dotLen; //as you see at the screenint k; //I think you know... li.LowPart = 1<<21;li.HighPart = 0;buffer = (BYTE*)malloc(BUFSIZE); //5M buffer sizeif(buffer == NULL){fprintf(stderr, "内存分配失败!\n");return;}hFileIn = CreateFile(filespec, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);if(hFileIn == INVALID_HANDLE_VALUE){free(buffer);buffer = NULL;lastErr = GetLastError();if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, lastErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), (LPSTR)&errMsg, 1, NULL)){fprintf(stderr, "CreateFile:%s\n%s", filespec, errMsg);LocalFree((HLOCAL)errMsg);errMsg = NULL;}return;}fileSize = GetFileSize(hFileIn, NULL);if(fileSize <= 0x00200000){fprintf(stderr, "文件大小不正确,不能小于2M.(%s)\n", filespec);free(buffer);buffer = NULL;CloseHandle(hFileIn);hFileIn = NULL;return;}fileSize -= 0x00200000; //2M offset of REAL Video data SetFilePointerEx(hFileIn, li, NULL, FILE_BEGIN);if(!ReadFile(hFileIn, hdr, 4, &dwSizeRead, NULL) || dwSizeRead==0){lastErr = GetLastError();if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, lastErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), (LPSTR)&errMsg, 1, NULL)){fprintf(stderr, "ReadFile:%s\n%s", filespec, errMsg);LocalFree((HLOCAL)errMsg);errMsg = NULL;}CloseHandle(hFileIn);hFileIn = NULL;free(buffer);buffer = NULL;return;}magicNumber = (338-hdr[1])&0xFF;if((BYTE)(hdr[1]+magicNumber)=='R' && (BYTE)(hdr[2]+magicNumber)=='M' && (BYTE)(hdr[3]+magicNumber)=='F'){fileType = 1;goto _go;}magicNumber = (294-hdr[1])&0xFF;if((BYTE)(hdr[2]+magicNumber)==178 && (BYTE)(hdr[3]+magicNumber)==117) {fileType = 2;goto _go;}magicNumber = (332-hdr[1])&0xFF ;if((BYTE)(hdr[1]+magicNumber)==76 && (BYTE)(hdr[2]+magicNumber)==86){fileType = 3 ;goto _go;}magicNumber=(329-hdr[1])&0xFF ;if((BYTE)(hdr[1]+magicNumber)==73 && (BYTE)(hdr[2]+magicNumber)==70 && (BYTE)(hdr[3]+magicNumber)==70){fileType = 4 ;goto _go;}magicNumber=(256-hdr[1])&0xFF ;if(!(magicNumber+hdr[2])){fileType = 5 ;goto _go;}magicNumber=(256-hdr[1])&0xFF ;if((BYTE)(hdr[2]+magicNumber)==1 && (BYTE)(hdr[3]+magicNumber)==186){fileType = 6 ;goto _go;}magicNumber=(325-hdr[1])&0xFF ;if((BYTE)(hdr[1]+magicNumber)==69 && (BYTE)(hdr[2]+magicNumber)==223 && (BYTE)(hdr[3]+magicNumber)==163){fileType = 7 ;goto _go;}fprintf(stderr, "不能识别的文件格式!(%s)\n", filespec);free(buffer);buffer = NULL;CloseHandle(hFileIn);hFileIn = NULL;return;_go:ch = 0;pchar = strrchr(filespec,'\\');if(!pchar)pchar = strrchr(filespec, '/');pchar = pchar==NULL?filespec:pchar+1;switch(fileType){case 1://rm/rmvbch = 46;sprintf(fileOut, "%s%s", pchar, ".rmvb");break;case 2://wmvch = 48;sprintf(fileOut, "%s%s", pchar, ".wmv");break;case 3://flvch = 70;sprintf(fileOut, "%s%s", pchar, ".flv");break;case 4://avich = 82;sprintf(fileOut, "%s%s", pchar, ".avi");break;case 5://mp4ch = 0;sprintf(fileOut, "%s%s", pchar, ".mp4");break;case 6://mpegch = 0;sprintf(fileOut, "%s%s", pchar, ".mpeg");break;case 7://mkvch = 26;sprintf(fileOut, "%s%s", pchar, ".mkv");break;default:break;}hFileOut = CreateFile(fileOut, GENERIC_WRITE, FILE_SHARE_READ, NULL, /*CREATE_ALWAYS*/CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);if(hFileOut == INVALID_HANDLE_VALUE){lastErr = GetLastError();if(FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, lastErr, MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), (LPSTR)&errMsg, 1, NULL)){fprintf(stderr, "CreateFile:%s\n%s", fileOut, errMsg);LocalFree((HLOCAL)errMsg);errMsg = NULL;}CloseHandle(hFileIn);hFileIn = NULL;free(buffer);buffer = NULL;return;}WriteFile(hFileOut, (LPVOID)&ch, 1, &dwSizeWritten, NULL);//handle file headerfor(k = 1; k < 4; k++)hdr[k] = (BYTE)((hdr[k]+magicNumber)&0xFF);WriteFile(hFileOut, &hdr[1], 3, &dwSizeWritten, NULL);//handle encrypted data. is it simple?ReadFile(hFileIn, buffer, 1019, &dwSizeRead, NULL);for(k=0; k<1019; k++)buffer[k] = (BYTE)(buffer[k]+magicNumber & 0xFF);WriteFile(hFileOut, buffer, 1019, &dwSizeWritten, NULL);readSize += 1024;prtLen = printf("%s(%s)", filespec, strrchr(fileOut, '.'));dotLen = scrWidth-prtLen%scrWidth;if(dotLen<=10)dotLen += scrWidth;dotLen -= 1;while(dotLen--)printf(".");//it looks like this: left edge-->|mymov.xv(.flv).............1024M, 99% | <--right edge//copy rest file, original :-), and show sth. useful. how smart thunder kankan was.while(ReadFile(hFileIn, buffer, BUFSIZE, &dwSizeRead, NULL) && dwSizeRead != 0){WriteFile(hFileOut, buffer, dwSizeRead, &dwSizeWritten, NULL);readSize += dwSizeRead;ResetCursorPos();printf("%4dM,%3d%%", (int)(readSize/(1<<20)), (int)(readSize/(float)fileSize*100));}printf("\n");CloseHandle(hFileIn);CloseHandle(hFileOut);hFileIn = NULL;hFileOut = NULL;free(buffer);buffer = NULL;cntFileProcessed++;return; }//parse if there to be a wild char void HandleFile(char* filespec) {WIN32_FIND_DATA fd;HANDLE hFile = NULL;char findpath[260];char tmppath[260];char* pchar = NULL;hFile = FindFirstFile(filespec, &fd);if(hFile == INVALID_HANDLE_VALUE){fprintf(stderr, "没有文件用于处理!\n");return;}strncpy(findpath, filespec, sizeof(findpath));//we need to add a full current path to the dest file //since the fd.cFileName member does not include the pathpchar = strrchr(findpath, '\\');if(!pchar)pchar = strrchr(findpath, '/'); //sometimes, it's not back-slash-ed.if(pchar)*(pchar+1) = '\0';do {if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) //eliminate directory {if(pchar){sprintf(tmppath, "%s%s", findpath, fd.cFileName); //now it's full path ExtractFile(tmppath);}else{ExtractFile(fd.cFileName); //in current dir }}} while (FindNextFile(hFile, &fd)); //continue deep search FindClose(hFile);hFile = NULL;return; }void Usage(char* name) {char* ptr = strrchr(name, '\\'); //only the name we need, not the full pathchar* pmsg = "迅雷看看XV文件提取器 - 版本:1.0\n""作者:女孩不哭 编译时间:" __DATE__ " " __TIME__ "\n\n""使用方法:\"%s /y 文件\", 输出文件在当前工作目录下\n\n""敬告:迅雷XV文件包含受版权保护的内容.\n""本程序仅供研究和学习使用, 请自觉将提取的文件立即删除.\n""切勿将本程序及其提取的文件使用于任何其它用途.\n""对于使用本程序造成的任何后果, 由使用者自行承担法律责任!\n""要接受此协议, 请从命令行传入/y作为第1个参数, 文件作为第2个参数.\n";if(!ptr)ptr = strrchr(name, '/');if(!ptr) //the cur dir is just in the exe dirptr = name-1;//ptr+1printf(pmsg, ptr+1);return; }int main(int argc, char** argv) {CONSOLE_SCREEN_BUFFER_INFO sbi;if(argc!=3 || stricmp(argv[1], "/y")) //xve /y file format expected {Usage(argv[0]);return 1;}GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &sbi);scrWidth = sbi.dwSize.X; //width, in characters HandleFile(argv[2]); //enum files if a wild char is detectedprintf("处理了 %d 个文件!\n", cntFileProcessed);return 0; }
项目及bin下载:
http://alioss.twofei.com/windows/xve.7z
http://files.cnblogs.com/nbsofer/xve.7z
女孩不哭 @ 2012-08-18 23:37:03 @ http://www.cnblogs.com/nbsofer
PS:
其实我对迅雷看看没一点兴趣...
不过, 从XV文件看来, 迅雷很聪明~~~ 那个聪明, 你懂的.
2013-06-09测试, 仍然能用
转载于:https://www.cnblogs.com/memset/archive/2012/08/18/2645979.html
用C语言写的迅雷看看XV文件提取器及C语言源代码相关推荐
- xv视频提取器的一些用法
xv视频提取器的一些用法 检举|2011-10-23 10:36 提问者:1227433561|悬赏分:20|浏览次数:2094次 xv视频提取器的一些用法.我用的时候可以提取xv并将其转换为flv( ...
- c语言写贪吃蛇什么水平_学了一些C语言,也不知道自己学到什么程度,自己想写个贪吃蛇但是写不出来,想看懂下面这个程序,求解释...
已结贴√ 问题点数:20 回复次数:3 学了一些C语言,也不知道自己学到什么程度,自己想写个贪吃蛇但是写不出来,想看懂下面这个程序,求解释 #include//基本库 #include//系统库 #i ...
- c语言写程序思路考研题,快速解题 | 在考场C语言编程题
原标题:快速解题 | 在考场C语言编程题 对于考<C语言程序设计>的小伙伴们来说,程序设计题是很多同学觉得相对较难的一个版块.其题目虽然不算多,但在考研150分的试卷中,却占据了较大的比重 ...
- 用c语言写一个简单的名人名言播放器
由于上传不了太多代码,我只放了一部分代码块,用的switch语句,case跳转到首页或者下一页,没一页都做成函数包装起来,每一行用一个sleep延时处理.这是个笨方法,也可以用c调用文件调用文件,把搜 ...
- 用C语言写个字符串一维数组的逆序输出,c语言怎么用数组倒序输出
scanf("%d",&a[i]); //倒序输出数组内容 for( int *ptr=a+SIZE; ptr!=a; ) printf( "%d\t" ...
- 项目: 用C语言写一个图形化的音乐播放器 【C++ / C】
目录 最终效果 代码 资源地址 最终效果 代码 /************ 1开头的是周杰伦的歌 2开头的是林俊杰的歌 3开头的是许嵩的歌 *************/ #include<std ...
- c语言写数码管,各位大神,如何用C语言实现在数码管上实现1234同时亮
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 /*将移位寄存器内的数据锁存到输出寄存器并显示 */ /* ...
- c语言写一个程序有关泰勒公式,泰勒公式求e值——c语言算法实现
题目: 通过泰勒公式的变形:e = 1 + (1/1!) + (1/2!) + (1/3!) + - + (1/n!) (1/n! >= 10^-7)来求e的值 解析: 我们在看到由1到n的 ...
- 自定义函数删除字母C语言,[编程入门]自定义函数之字符提取-题解(C语言代码)...
解题思路:输入一个字符串,调用函数,遍历字符串中每一个字符,看是否含有aeiou字符,若有,将其保存到另一个字符型数组中,在主函数中对得到的字符型数组进行排序,输出. 注意事项:题目要求顺序输出元音字 ...
最新文章
- HTML5的明天,局部有小雨
- [Unity] Animator 播放 Mixamo 动画卡在第一帧的解决办法:勾选 Loop Time
- 抛体运动的小框架的源代码(rar)
- 如何提升鸿蒙战绩,蛰伏一年 鸿蒙系统2.0为我们带来了哪些升级?
- 简析面向对象中的继承,原型链,闭包之继承
- could not extract ResultSet/could not execute statement
- mysql分库分表 mycat_你们要的MyCat实现MySQL分库分表来了
- Fedora 13 咪咕播放器
- mac os 系统word文档批量更改图片尺寸问题汇总
- php是哪个快递,php快递查询API类(支持各种快递的查询)
- 嵌入式技术与应用专业毕业以后可以做什么?
- 基于FPGA的矩阵键盘检测
- TSW(Tencent Server Web)源码阅读指南
- free spaces
- android app分享到微信让应用来源显示qq浏览器或者是其他应用
- 存储系统——主存储器
- KPA EtherCAT主站协议栈基准
- 怎么选房能让房子升值20倍?这些因素很重要
- 10.摆平Linux正则表达式
- 【Python】Django展示html页面
热门文章
- 为什么我要用C写游戏 适合自己的才是最好的
- 【蓝桥杯Java_C组·从零开始卷】第三节(附)、for循环练习题(数据题与图形题)
- 数据库面试题【六、Sql的优化】
- 使用Memcache缓存mysql数据库操作的原理和缓存过程浅析
- 线程、协成、IO模型
- unity, 非public变量需要加[SerializeField]才能序列化
- centos下redis安装
- 举例什么时候会用到 call(), apply()
- 从一个实例看javascript几种常用格式的转换
- RESTORE DATABASE的standby选项