汉编卷土重来?

时间:2022-12-17 00:21:39

先看下面的程序:

汉编卷土重来?

然后大家猜猜是什么语言编写的呢?

其实是把脚本代码中的label进行汉字替换即可。先定义label替换的对子

如果=if
函数=function
否则=else
返回=return
新增=new
空=null
尝试=try
捕错=catch
变量=var

画图消息=WM_PAINT
获得设备上下文=GetDC
释放设备上下文=ReleaseDC
文本输出=TextOut
串长度=length
左鼠标按下消息=WM_LBUTTONDOWN
鼠标移动消息=WM_MOUSEMOVE
窗口销毁消息=WM_DESTROY
退出=Exit
产生实心刷子=CreateSolidBrush
产生GDI长方形=BuildGDIRect
填充长方形=FillRect
销毁GDI对象=DeleteObject
设置背景模式=SetBkMode
透明=TRANSPARENT
转换成整数=parseInt
消息窗=MessageBox
注册窗口类=RegisterClassEx

 汉编卷土重来?

下面函数是提取脚本中的label:

  1. void Analyzelabel(char *code,int len,KeywordManager *m,LabelNumberList &list)
  2. {
  3.     int i;
  4.     tagLabelNumber label;
  5.     unsigned char *s=(unsigned char *)code;
  6.     for(i=0;i<len;i++)
  7.     {
  8.         if(s[i]>0x6F || (s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z') || s[i]=='_')//charater
  9.         {
  10.             label.begin_pos=i;
  11.             if(s[i]>0x7F)
  12.                 i++;
  13.             while(s[i]>0x7F || (s[i]>='a' && s[i]<='z') || (s[i]>='A' && s[i]<='Z') || s[i]=='_' || (s[i]>='0' && s[i]<='9'))
  14.             {
  15.                 i++;
  16.                 if(s[i]>0x7F)
  17.                     i++;
  18.                 if(s[i]==0)
  19.                     break;
  20.             }
  21.             label.end_pos=i;
  22.             label.len=i-label.begin_pos;
  23.             memcpy(label.label,code+label.begin_pos,label.len);
  24.             label.label[label.len]=0;
  25.             label.type=eltLabel;
  26.             if(m->IsKeyword(label.label))
  27.             {
  28.                 label.type=eltKeyword;
  29.             }else
  30.             if(m->IsConstant(label.label))
  31.             {
  32.                 label.type=eltConstant;
  33.             }
  34.             list.push_back(label);
  35.         }else
  36.         if(s[i]=='/"' || s[i]=='/'')
  37.         {
  38.             label.begin_pos=i;
  39.             int count1;
  40.             int count2;
  41.             if(s[i]=='/"')
  42.             {
  43.                 count1=1;
  44.                 count2=0;
  45.             }else
  46.             {
  47.                 count1=0;
  48.                 count2=1;
  49.             }
  50.             i++;
  51.             while(count1>0 || count2>0)
  52.             {
  53.                 if(s[i]=='/"')
  54.                     count1--;
  55.                 else
  56.                 if(s[i]=='/'')
  57.                     count2--;
  58.                 else
  59.                 if(s[i]=='//')
  60.                 {
  61.                     i++;
  62.                 }
  63.                 i++;
  64.             }
  65.             label.end_pos=i;
  66.             label.len=i-label.begin_pos;
  67.             label.type=eltString;
  68.             list.push_back(label);
  69.         }
  70.     }
  71. }

然后逐个替换即可。是不是很容易?

 

这个看上去像IDE的程序 Duceland Widgets Engine 是含源的,从这里下载。