日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

用C语言写的迅雷看看XV文件提取器及C语言源代码

發布時間:2024/6/14 编程问答 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 用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语言源代码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。