zoukankan      html  css  js  c++  java
  • C/C++ 查找目录指定文件HEX特征

    	// 获取 Temp 目录路径
    	TCHAR lpTempPathBuffer[MAX_PATH];
    	GetTempPath(MAX_PATH,lpTempPathBuffer);
    
    	// 拼接字符窜
        std::string inPath = lpTempPathBuffer;
    	inPath.append("\*");
    
        // 遍历 Temp 目录下的文件
        struct _finddata_t fileinfo;
        long handle = _findfirst(inPath.c_str(),&fileinfo);
        if(handle == -1){cout << "_findfirst 失败" << endl;}
        do{
    		// cout << fileName << endl;
    		// 筛选 .tmp 后缀的文件
    		string fileName = fileinfo.name;
    		if(fileName.find(".tmp")!=fileName.npos){
    			//cout << fileName << endl;
    			// 获取文件全路径
    			string fullPath = lpTempPathBuffer;
    			fullPath += fileName;
    			cout << fullPath << endl;
    
    			// 打开文件
    			ifstream fin(fullPath,ios::binary);
    			if(!fin){cout<<"打开文件失败"<<endl;}
    	
    			// 设置文件指针位置为 0xA00,当然也可以设置为其他的地方
    			fin.seekg(0xa00,ios::beg);
    			char buffer[16];
    			fin.read(buffer,16*sizeof(char));
    	
    			// 读取内容
    			for(int i=0;i<16;i++){
    				cout << hex << (unsigned short)((unsigned char)buffer[i]) << " ";
    				
    				// 对比你自己的特征数组(略)
    				// ...
    				// ...
    			}
    			
    			cout<<"
    *****************"<<endl;
    		}
    
        } while (!_findnext(handle,&fileinfo));
    

    版权声明: 本博客,文章与代码均为学习时整理的笔记,博客中除去明确标注有参考文献的文章,其他文章【均为原创】作品,转载请务必【添加出处】,您添加出处是我创作的动力!

    警告:如果您恶意转载本人文章,则您的整站文章,将会变为我的原创作品,请相互尊重!
  • 相关阅读:
    剑指offer_11:二进制中1的个数
    剑指offer_10:矩形覆盖
    spring mvc 访问静态资源
    spring context:component-scan ex
    spring aop配置未生效
    415 Unsupported Media Type
    spring mvc 接收List对象入参
    JIRA甘特图
    JIRA的工时
    JIRA导出工作日志到Excel
  • 原文地址:https://www.cnblogs.com/LyShark/p/15020073.html
Copyright © 2011-2022 走看看