Reversed Engineering Approach For Converting Legacy TurboC Application To 64 Bit Application - Final Report
Reversed Engineering Approach For Converting Legacy TurboC Application To 64 Bit Application - Final Report
á
The aim of the project is to convert convetional legacy turbo c programs, which are
meant to run in 16 bit operating system and can not be executed in modern operating
Many legacuy applications are developed using C. Usch applications find no takers as
the Time passes by. Therefore making such programs obsolete and it requires such
that can automatically perform such step. In this project we develop a unique
get executed.
Reverse engineering has its origins in the analysis of hardware for commercial or
military advantage. The purpose is to deduce design decisions from end products with
little or no additional knowledge about the procedures involved in the original
production. The same techniques are subsequently being researched for application to
legacy software systems, not for industrial or defence ends, but rather to replace
incorrect, incomplete, or otherwise unavailable documentation.
The term Ê Ê Ê as applied to software means different things to different
people, prompting Chikofsky and Cross to write a paper researching the various uses
and defining a taxonomy. From their paper, they state, "Reverse engineering is the
process of analyzing a subject system to create representations of the system at a
higher level of abstraction."[6] It can also be seen as "going backwards through the
development cycle". In this model, the output of the implementation phase (in source
code form) is reverse-engineered back to the analysis phase, in an inversion of the
traditional waterfall model. Reverse engineering is a process of examination only: the
software system under consideration is not modified (which would make it re-
engineering). Software anti-tamper technology is used to deter both reverse engineering
and re-engineering of proprietary software and software-powered systems. In practice,
two main types of reverse engineering emerge. In the first case, source code is already
On a related note, black box testing in software engineering has a lot in common with
reverse engineering. The tester usually has the API, but their goals are to find bugs and
undocumented features by bashing the product from outside.
r
The aim of the project is to convert conventional legacy TURBO C programs, which are
meant to run in 16 bit operating system and can not be executed in modern operating
systems to C# programs which can be executed in 64 bit operating system
architecture.
1) Rewriting the whole application to the modern environment using manual code
mapping
2) Extracting the underneath business logic of the legacy applications and expose
them over the web using web services.
3) Using inter-process communication to call the business logic from high end
applications and so on.
The approaches can be roughly categorized into two major ways: top down approach
and bottom up approach. In all these approaches the logic becomes rigid. i.e. the
business logic present in the legacy applications are reserved and any changes in the
application needs to be redesigned. But in a real time business scenario, it might be
required that the business logic may be changed or there may be other sub logic that
needs to be associated with them. Now consider the following scenario:
Let us assume for a case study that we have a banking application that supports
transactions like opening an account in the bank, deposit, withdraw and also to view the
transaction. But the new business logic may require third party transfer, i.e. transfer of
the amount from one bank account to another, case based transaction: for example
prohibiting the withdraw in case of insufficient balance or not allowing a certain
In short the Mapping of legacy applications to the new environment requires following
Existing System is time consuming and do take a lot of tedious effort. Therefore in this
project we develop a simple solution to achieve the prerequisite of the mapping of c
code to c# Code. The features of the codes are:
Since the user presumed to use this system are qualified so it is believed that
they have proper knowledge of computers and Internet and hence they will be able to
operate it in a fair manner.
YY Y
c YYY
Y
Y
c Y
Y Y
Y
YY
Y
Y
Y
Y
Y
Y Y
Y
Y
Y
YYY Y
!
"
3) Language:Visual C#2010
!
"
2)Hard Disk:80 GB
3)RAM:1 GB
lstProgram.Items.Add(s);
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
lstProgram.Items.Clear();
ProgScan();
}
anz.CommentStripMultiLine();
progA = anz.Lines;
lstProgram.Items.Clear();
for (int i = 0; i < progA.Length; i++)
{
lstProgram.Items.Add(progA[i]);
}
this.Text = anz.msg;
}
EachToken.Add(pinclude[i]);
}
else
{
EachToken.Add(pinclude[i]);
ListViewItem lvm = new ListViewItem(new string[] {
pinclude[i].Contents, pinclude[i].VariableDataType.ToString(),
pinclude[i].StartLine.ToString(), pinclude[i].InitialValue });
lvm.Tag = new string[] { pinclude[i].Contents,
pinclude[i].VariableDataType.ToString(), pinclude[i].StartLine.ToString(),
pinclude[i].InitialValue };
lvPointers.Items.Add(lvm);
}
}
}
}
}
}
}
lvFunctions.Items.Add(lvm);
}
}
void AddCSharpHeaders()
{
lstConverted.Items.Add("using System;");
lstConverted.Items.Add("using System.Collections;");
lstConverted.Items.Add("using System.Collections.Generic;");
lstConverted.Items.Add("using System.Text;");
}
}
}
return form;
}
string FindFunction(int ln)
{
}
}
return form;
}
string FindPointers(int ln)
{
}
else
{
form = form + ";";
}
}
}
form = "";
return form;
}
int i = Analyze.IncludeEnds+1;
AddCSharpHeaders();
lstConverted.Items.Add("public class SampleClass{");
int ci=lstConverted.Items.Count-1;
for (; i < Analyze.MainLocation; i++)
{
lstConverted.Items.Add(lstProgram.Items[i]);
}
if (form1.Length > 2)
{
MessageBox.Show(form1 + lstProgram.Items[i].ToString().Replace("&",
"out "));
lstConverted.Items.Add(form1 +
lstProgram.Items[i].ToString().Replace("&", "out "));
}
else
{
string form2 = FindPointers(i);
if (form2.Length > 1)
{
lstConverted.Items.Add(form2);
}
else
{
lstConverted.Items.Add(lstProgram.Items[i].ToString().Replace("&",
"out "));
}
}
}
else
{
lstConverted.Items.Add(form);
}
string[] print = File.ReadAllLines("printf.txt");
foreach (string s in print)
{
lstConverted.Items.Add(s);
}
print = File.ReadAllLines("scanf.txt");
foreach (string s in print)
{
lstConverted.Items.Add(s);
}
lstConverted.Items.Add("}");
string[] conv = new string[lstConverted.Items.Count];
for (int j = 0; j < lstConverted.Items.Count; j++)
{
conv[j] = lstConverted.Items[j].ToString();
}
int i = 0;
#endregion
}
catch (Exception ex)
{
}
i++;
}
int i = 0;
while (i < Lines.Length)
{
try
{
if (commentFound)
{
}
/// <summary>
/// Removes the blank codes by comparing each line with "" and removing them
/// </summary>
/// <returns></returns>
public ArrayList RemoveBlank()
{
ArrayList al = new ArrayList();
foreach (string s in Lines)
{
if (s != "")
{
al.Add(s);
}
}
return al;
}
public static int IncludeEnds=0;
/// <summary>
/// It searches for the include statement
/// 1. the reule is: it searches for #include statement, then
/// 2. from < to > is extracted as Contents
/// 3. Type=INCLUDE, start and end Line are same, the line where it is found
/// </summary>
}
i++;
}
return Nl;
}
/// <summary>
/// this program extracts the loops and their inner values
/// first divide the program into an array of characters
/// Loop in the characters, search for {
/// push the data in the stack
/// search for } pop from stack
/// </summary>
public List<ProgramBlocks> LoopStructure()
!"
!
%*
Y
c
@ $
%
$ @& &
C# is Microsoft¶s latest object oriented programming language developed for .NET platform &
.NET is Microsoft¶s latest platform technology for creating web services. C# is a C++ based
language & was developed to provide portability for distributed applications over network &
Internet. Application development in .NET platform can be done in multiple languages including
C#, C++ & visual basic. Programmers developed in all these languages are complied to
Microsoft¶s intermediate language (IL) & executed within common language run time (CLR) .We
explain the core elements of .NET & how web applications are developed & run with this
technology. NET is not a programming language it is a virtual machine technology (similar to
Java virtual machine technology) with a framework that provides capability to run a verity of web
applications. The .NET framework class library provides set of classes that provides essential
functionality for applications build within the .NET environment. Web functionality, XML support,
database support, threading & distributed computing support is provided by the .NET framework
class library. All .NET code is translated to Microsoft intermediate language & run with CLR
.CLR is similar to Java virtual machine (JVM) .The IL code is language independent & similar to
Java byte code .A single .NET application may consist of several different languages .Two very
important features of CLR are language interoperability & language independence.
Introduction to C#
C# is a modern, object oriented language that enables programmers to quickly build a wide
range of applications for the new Microsoft .NET platform, which provides tools & services that
fully exploit both computing & communication. Because of its elegant object oriented design .C#
is a great choice for architecting a wide range of components from high level business objects to
system level applications using simple C# language constructs, these component can be
converted into XML web services, allowing them to be invoked across the internet, from any
language running on any operating system. More than any thing else, C# is designed to bring
rapid development to the C++ programmer without sacrificing the power & control that have
been a hallmark of C & C++. Because of this heritage C# has a high degree of fidelity with C &
C++. Developers familiar with these languages can quickly become productive in C#
C# is the new language with the power of C++ & the slickness of visual basic. It cleans
up many of the syntactic peculiarities of C++ without diluting much of its flavor (thereby
enabling C++ developers to transition to it with little difficulty). And its superiority over
VB6 in facilitating powerful OO implementation is without question. C# with clean OO
syntax & large class library (in conjunction with .NET & the base class libraries) could
be the µmost productive mainstream language¶ & it is an ECMA standard language that
offers the potential of being available across many platform .For the serious developer
wanting Microsoft¶s most productive & mainstream .NET language, C# is the choice.
Properties:
Properties will be a familiar concept to Delphi & Visual basic users. The motivation is for the
language to formalize the concept of getter/ setter methods, which is an extensively used
pattern, particularly in RAD (Rapid Application developments) tools.
Outsize;
Label.font.bold=true;
The code is immediately more readable by those who are using foot & label . There is similar
simplicity when implementing properties:
Java/C++ :
Return size;
Size=value;
@
Particularly for read/write properties, C# provides a cleaner way of handling this concept .the
relationship between a get & set method is inherent in C#, while has to be maintained in Java or
C++. There are many benefits of this approach. It encourages programmers to think in terms of
properties, whether that property is more natural as read/write Vs read only, or whether it really
a shouldn¶t be a property at all. If you wish to change the name of your property, you only have
one place to look (I¶ve seen getters & setters several lines away from each other). Comments
only have to be made once, & won¶t get out of sync with each other .it is feasible that an IDE
could help out here (& in fact I suggest they do), but one should remember an essential principle
in programming is to try to make abstractions model our problem well space well. A language,
which supports properties, will reap the benefits of that better abstraction.
Indexers :
C# provides indexers allow objects to be treated like array, except that like properties, each
element is exposed with a get and/ or set method.
Get {
Set {
if (value !=null ) {
Stories [index]=value;
Pointer arithmetic:
Pointer arithmetic can be performed in C# within methods marked with the unsafe modifier.
When pointer point to garbage collected objects, the complier enforces the use of fixed word to
pin the object. This is because garbage collectors relay on moving objects around to reclaim
memory, but if this happens when you are dealing with raw pointers you will be pointing to
garbage. The choice of the word ³unsafe ³will be chosen since it discourages developers from
using pointers unless they really need to.
Rectangular Arrays:
C# allows both jagged & rectangular arrays to be created. Jagged arrays are pretty much the
same as Java arrays. Rectangular arrays allow a more efficient and accurate representation for
certain problems .An example of such an array would be:
Int [1][1][1];
In combination with struts, C# can provide a level of efficiency making it a good choice for areas
such as graphics & mathematics.
á@ D
Hello world
Using system;
Class Hello {
Execution
Hello
u Builder design pattern: The builder pattern allows a client object to construct a complex
object by specifying only its type & content. The client is shielded from the details of the
objects construction.
u Remoting in C#.
u C# component based development.
Run the CSharp program in the Visual Studio 2010 Command Prompt
Run it and we get the proper output according to the proper input
á
u Interoperability.
u Lost documentation: Reverse engineering often is done because the
documentation of a particular device has been lost (or was never written), and
the person who built it is no longer available. Integrated circuits often seem to
have been designed on obsolete, proprietary systems, which means that the only
way to incorporate the functionality into new technology is to reverse-engineer
the existing chip and then re-design it.
u Product analysis. To examine how a product works, what components it consists
of, estimate costs, and identify potential patent infringement.
u Digital update/correction. To update the digital version (e.g. CAD model) of an
object to match an "as-built" condition.
u Security auditing.
u Acquiring sensitive data by disassembling and analysing the design of a system
component.
u Military or commercial espionage. Learning about an enemy's or competitor's
latest research by stealing or capturing a prototype and dismantling it.
u Removal of copy protection, circumvention of access restrictions.
u Creation of unlicensed/unapproved duplicates.
u Materials harvesting, sorting, or scrapping.
u Academic/learning purposes.
u Curiosity.
u Competitive technical intelligence (understand what your competitor is actually
doing versus what they say they are doing).