在不了解领域的情况下对 VB6 代码进行逆向工程的最佳实践方法 [英] Bestpractice approaches for reverse engineering VB6 code with out knowledge of the domain

查看:19
本文介绍了在不了解领域的情况下对 VB6 代码进行逆向工程的最佳实践方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目标状态:将VB6代码移植到C#中,承担整个项目以及可能涉及的所有过程.

target state: Porting VB6 Code into C#, undertake the whole project with all conceivable processes that are involved.

如果您不了解该领域,您会采用什么方法?

What would be your approach if you do not have knowledge about the domain?

几乎有任何文档,只有用 VB6 编写的遗留代码(最多 100.000 - 300.000 行代码和注释 vb6 文件,其中包含最多 14.000 行代码).

There is nearly any documentation, just legacy code (up to 100.000 - 300.000 lines of code and comments vb6 files that contain up to 14.000 lines of code) written in VB6.

推荐答案

免责声明:我为 Great Migrations 工作

Disclaimer: I work for Great Migrations

为了谋生,我们将大型 VB6/ASP/COM 应用程序重写为 .NET(主要是 C#),并且我们开发了一个软件分析和重新设计工具来帮助我们做到这一点.这个工具本质上就像一个 VB6/ASP/COM 编译器和一个编写 .NET 代码的反编译器.当然,由于 VB6 平台与 .NET 非常不同,直接编译/反编译是不可取的或不可行的,因此我们的工具有一个分析器",可以实现各种代码重新设计算法来处理 VB6-C# 不兼容问题.还有一个可编程的作者",允许迁移团队制定规则来设置 .NET 代码文件、重构代码,以及做一些事情,比如用 .NET 类替换 COM API 和 ActiveX 控件——这取决于团队的需要或想要.

We rewrite large VB6/ASP/COM applications to .NET (primarily C#) for a living and we have developed a software analysis and reengineering tool to help us do it. This tool is essentially like a VB6/ASP/COM compiler and a decompiler that authors .NET codes. Of course since the VB6 platform is very different from .NET, a direct compile/decompile is not desirable or viable, so our tool has an "analyzer" that implements various code reengineering algorithms to deal with VB6-C# incompatibilities. There is also a programmable "author" that allows the migration team to prescribe rules for setting up .NET code files, restructuring the code, and doing things like replacing COM APIs and ActiveX controls with .NET classes -- depending on what the team needs or wants.

作为编译和分析代码的副产品,我们的工具生成了整个 VB6/ASP/COM 系统正在升级的模型.该模型可用于生成有关系统内部结构的极其详细的报告.这些模型可用于帮助对代码进行逆向工程——如果您知道要问的正确问题,并且您需要了解问题域才能做好工作.

As a by product of compiling and analyzing the code our tool produces a model of the entire VB6/ASP/COM system being upgraded. This model can be used to produce extremely detailed reports about the internal structure of the system. These models can be used to help reverse-engineer the code -- if you know the right questions to ask and you would need to understand the problem domain to do a good job.

当然,一旦您拥有完整的 .NET,您就可以使用各种分析和代码审查工具来处理程序集.某些版本的 Visual Studio 具有这些工具,并且有开源工具,例如 FxCop、NDepends).我还使用了一些很棒的动态分析工具(EQUATEC Tracer).

Of course once you have build-complete .NET, you can use the various analytics and code review tools that work off assemblies. Some versions of Visual Studio have these tools and there are open source tools such as FxCop, NDepends). There are also some fantastic dynamic analysis tools (EQUATEC Tracer) that I have used.

最终,尽管迁移团队将非常努力地验证任何未知系统.即使您停留在同一个平台上,如果您不知道如何运行应用程序以及如何设置/输入预期输入以及查找/验证预期输出,则您将无法证明应用程序是正确的".我们通常把这个留给客户!

In the end though migration teams are going to very hard pressed to verify any unknown system. Even if you are staying on the same platform, you would unable to prove an application it is "correct" if you do not know how to run it and how to setup/enter expected inputs and find/verify expected outputs. We normally leave this to the customer!

如果我们正在为客户进行验证,我们会严重依赖并行测试来验证您系统的新版本——假设我们知道如何运行遗留应用程序,我们假设给定相同的输入集和用例它应该表现出相同的行为并产生相同的结果.我在单元测试圈听说过这个批准测试.

If we are doing verification for the customer, we rely heavily on side-by-side testing to validate the new version of your system -- assuming we know how to run the legacy application we assume that given the same sets of inputs and usecases it should exhibit the same behaviors and produce the same results. I have heard this Approval Tests in unit testing circles.

我承认我们也非常依赖这样的知识,即 VB6/COM 代码是对系统数据结构和逻辑的完整、详细、正式和经过生产测试的描述,并且我们正在通过测试和重新测试这些信息系统转型.自 1977 年以来,我们一直在开发编译器,我们在这个 VB6/ASP 编译器上非常努力,以确保我们生成的 .NET 代码保留原始 VB6 的语义.每次都不是 100% - 但它一直在接近.然后再次手动操作也不能保证第一次尝试时 100% 正确的代码......

I admit we also rely heavily on the knowledge that the VB6/COM code is a complete, detailed, formal and production tested description of the data structures and logic of the system and that we are putting this information through a tested and retested systematic transformation. We have been developing compilers since 1977 and we have worked very hard on this VB6/ASP compiler to make sure the .NET codes that we generate preserves the semantics of the original VB6. It is not 100% every time - but it is getting closer all the time. Then again doing things by hand does not guarantee 100% correct code on the first try either...

这篇关于在不了解领域的情况下对 VB6 代码进行逆向工程的最佳实践方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆