开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 402|回复: 5
收起左侧

[已解决] 发现一个C语言的解析文件的代码,谁能转易语言

 关闭 [复制链接]
结帖率:100% (7/7)
发表于 2023-12-11 00:54:23 | 显示全部楼层 |阅读模式   江西省赣州市
50精币
发现一个C语言的解析文件的代码,谁能转易语言


  
/*
* =====================================================================================
*
*       Filename:  unpack.c
*
*    Description:  仅作为代码分享,转载请注明作者
*          (相对于把整大块文件读入内存,此程序运行时对系统开销比较小的特点);
*
*        Version:  1.0
*        Created:  2013年03月28日 22时34分52秒
*       Revision:  none
*       Compiler:  gcc
*
*         Author:  linkscue (scue),
*   Organization:  
*
* =====================================================================================
*/
#include   
#include   
#include   
#define u8 unsigned char
#define u32 unsigned int
#define u16 unsigned short
#define BUFFER_SIZE 4
/*
* u32  magic
* u32  paket_size
* u32  flag=0x1
* u8   Hardware[8]
* u32  Filetype
* u32  data_size
* u8   date[16]
* u8   time[16]
* u8   filename[32]
* u8   other[paket_size-92]
* */
int realStrlen (char *string){
int i=0;
char ch=NULL;
while ( (ch = * (string + i)) != ' \xFF' ) {
i++;
}
return i;
}
void hello (){
printf ("\n");
printf ("Welcome to use linkscue unpack huawei official rom tool!\n");
}
int main ( int argc, char *argv[] )
{
hello ();
if (argc == 1) {
printf ("\n");
printf ("usage: %s unpack.app\n", argv[0]);
exit (0);
}
char *file;
FILE *fp,*fd;
u32 tmp;
u32 magic=0xa55aaa55;
u32 paket_size=0;
u32 flag=1;
u8  hwid[8]="";
u32 filetype=0;
u32 data_size=0;
u8  date[16]="";
u8  time[16]="";
u8  filename[32]="";
int other_size=0;
int number=1;
char basename[32]="";
char basehwid[8]="";
int fp_start=0;
int fp_local=0;
int i=0,count=0,counts=0;
int end_point=0;
file=argv[1];
if ( (fp=fopen (file,"rb")) == NULL) {
printf ("open file failure!\n",file);
exit (1);
}
printf ("\n");
while (!feof (fp)) {
fscanf (fp, "%4c", &tmp);
if (tmp == magic) {
fp_start= (ftell (fp)-4);
fscanf (fp, "%4c",&paket_size);
fscanf (fp, "%4c",&flag);
fscanf (fp, "%8c",&hwid);
fscanf (fp, "%4c",&filetype);
fscanf (fp, "%4c",&data_size);
fscanf (fp, "%16c",&date);
fscanf (fp, "%16c",&time);
fscanf (fp, "%32c",&filename);
other_size= ( paket_size - 92 );
fseek (fp, other_size, SEEK_CUR);
if ( strcmp (filename,"INPUT") == 0 ) {
sprintf (basename, "output_%02d.img", number);
strncpy (filename, basename, sizeof (filename));
number++;
}
//            if ( (int)paket_size <= 0 || (int)data_size <= 0) {
//                continue;
//            }
strncpy (basehwid, hwid , realStrlen (hwid));
printf ("At: 0x%08x hw: %s size: %-10d time: %s_%s -->  %s\n", fp_start, basehwid, data_size, date, time, filename);
if ( (fd=fopen (filename,"wb"))==NULL) {
printf ("open %s to write data failure!\n", filename);
fseek (fp, 88, SEEK_CUR);
continue;
}
u8 buffer[BUFFER_SIZE];
counts = 0;
while ( counts < data_size ){
if (feof (fp)) {                 /* if the file is end, break! */
break;
}
count = fread (buffer, 1, BUFFER_SIZE, fp);
fwrite (buffer, 1 , BUFFER_SIZE, fd);
counts+=count;
}
//            printf ("paket size is 0x%08x, count is %d,  data start at 0x%08x, this time end at 0x%08x\n", paket_size,counts, (paket_size+fp_start), ftell (fp));
fclose (fd);
fseek (fp, ( fp_start + 92 ) , SEEK_SET);
}
}
//    printf ("Unpack %s ok!\n", file);
fclose (fp);
return EXIT_SUCCESS;
}

最佳答案

查看完整内容

看来不会C 不行阿 去火山论坛 问问这段代码 能转成DLL 或是火山调用 让C和C++高手搞成DLL 模块 供易语言调用

回答提醒:如果本帖被关闭无法回复,您有更好的答案帮助楼主解决,请发表至 源码区 可获得加分喔。
友情提醒:本版被采纳的主题可在 申请荣誉值 页面申请荣誉值,获得 1点 荣誉值,荣誉值可兑换荣誉会员、终身vip用户组。
快捷通道:申请荣誉值无答案申请取消悬赏投诉有答案未采纳为最佳
结帖率:100% (9/9)
发表于 2023-12-11 00:54:24 | 显示全部楼层   山西省太原市
看来不会C 不行阿 去火山论坛 问问这段代码 能转成DLL 或是火山调用 让C和C++高手搞成DLL 模块 供易语言调用

点评

这才多少代码,没必要吧   香港特别行政区*  发表于 2023-12-11 13:38

评分

参与人数 1荣誉 +1 收起 理由
笨潴 + 1 热心帮助他人,荣誉+1,希望继续努力(*^__^*) 嘻嘻!

查看全部评分

回复

使用道具 举报

结帖率:100% (9/9)
发表于 2023-12-13 20:22:25 | 显示全部楼层   山西省太原市
让炫彩试试吧 他的IDE 直接拖进去 汉化下
回复

使用道具 举报

结帖率:0% (0/3)

签到天数: 2 天

发表于 2023-12-20 15:52:20 | 显示全部楼层   四川省乐山市
tcc编译错误
回复

使用道具 举报

结帖率:0% (0/3)

签到天数: 2 天

发表于 2023-12-20 15:52:58 | 显示全部楼层   四川省乐山市
那前面几个包含文件是什么?不显示。#include   
#include   
#include   前三个。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 诚聘英才| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 800073686,邮箱:800073686@b.qq.com
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表