汉编卷土重来?

先看下面的程序:

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

其实是把脚本代码中的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:

void Analyzelabel(char *code,int len,KeywordManager *m,LabelNumberList &list)
{
    
int i;
    tagLabelNumber label;
    unsigned 
char *s=(unsigned char *)code;
    
for(i=0;i<len;i++)
    {
        
if(s[i]>0x6F || (s[i]>='a' && s[i]<='z'|| (s[i]>='A' && s[i]<='Z'|| s[i]=='_')//charater
        {
            label.begin_pos
=i;
            
if(s[i]>0x7F)
                i
++;

            
while(s[i]>0x7F || (s[i]>='a' && s[i]<='z'|| (s[i]>='A' && s[i]<='Z'|| s[i]=='_' || (s[i]>='0' && s[i]<='9'))
            {
                i
++;
                
if(s[i]>0x7F)
                    i
++;

                
if(s[i]==0)
                    
break;
            }

            label.end_pos
=i;
            label.len
=i-label.begin_pos;
            memcpy(label.label,code
+label.begin_pos,label.len);
            label.label[label.len]
=0;

            label.type
=eltLabel;
            
if(m->IsKeyword(label.label))
            {
                label.type
=eltKeyword;
            }
else
            
if(m->IsConstant(label.label))
            {
                label.type
=eltConstant;
            }

            list.push_back(label);
        }
else
        
if(s[i]=='\"' || s[i]=='\'')
        {
            label.begin_pos
=i;

            
int count1;
            
int count2;
            
if(s[i]=='\"')
            {
                count1
=1;
                count2
=0;
            }
else
            {
                count1
=0;
                count2
=1;
            }

            i
++;

            
while(count1>0 || count2>0)
            {
                
if(s[i]=='\"')
                    count1
--;
                
else
                
if(s[i]=='\'')
                    count2--;
                
else
                
if(s[i]=='\\')
                {
                    i
++;
                }

                i
++;
            }

            label.end_pos
=i;
            label.len
=i-label.begin_pos;
            label.type
=eltString;

            list.push_back(label);
        }
    }
}

 

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

 

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

 

 

posted @ 2008-12-17 09:57  yesry  阅读(478)  评论(5编辑  收藏  举报