Search This Blog

Friday, March 07, 2008

Singularity Step by Step

Peace be upon you
Today I will go with you in something "from my point of view" is very cool and really nice idea, Microsoft Research guys was working on something called Singularity, this project aim to do operating system that highly safe, what does it mean"Highly Safe OS"? it means that the operating system will not has memory problems that was exist before(before means current days), Buffer over flow, memory leaks and so on, if you have history with development you will know that memory mistakes is the source of all evilness (Viruses and Worms) every evil thing depend on some kind of problem in the operating system or some application.
Now What Microsoft research guys have done is very cool, they made Operating System that uses .NET Framework as base for it, they did everything run above the framework, even the hardware drivers it run above the .NET framework, as they said before 95% of the Kernel is written in C#, 3% C/C++, 2% Assembly.
this Operating System "Singularity" make things run more safe, if this idea works out, in near future writing a virus will need lots of work and real genius, because being above the .NET framework means that the assembly "Application" that is running will have certain permissions and can't be just broken like what happen now, some how it will be hard to be hacked, it doesn't mean that all Operating System will be fully safe or it will not have memory problems, it will just prevent the memory problems from happen, it means that you will not have crashes "it will be very rare", now after this long introduction let us get our hands dirty with some work.
Required tools to have Singularity OS working
first you have to have some tools let us sort it,


Building Singularity OS

First of all install .NET framework 1.1


After unzipping the Downloaded file from codeplex "Please be sure to put the files in folder without any spaces in its name", click start-> Run
write"cmd" then press Enter


press enter again when you see this stuff show up on the screen

After that you will have a shortcut on your desktop for the RDK

After that right click on "My computer" -> click "Properties" -> click on "Advanced" tab -> click on "Environment Variables"
in the "System Variables" click on "New", in the "Variable Name" enter "SINGULARITY_ROOT" and in the value write "%Path where you unzip the file%\base"

double click on the "Singularity RDK 1.1" icon on your desktop, now you have command line window that is ready to receive commands and prepared for building the Singularity OS

write this commands in the command window
cd build
msb /t:build ..\Distro\World.proj
"world.proj" as described in the documentation has everything in the project, which means that you will build all the code, if you want to do something quick, use Tiny.proj

This operation may take lots of time, on my machine it took 50 minutes

after that in the last few lines, you will have the path of the .iso file "bootable" written in the log file
the log file name is written at the end of the screen log, when you open the log with notepad or what ever you use, search for ".iso"

Here is the files, this image is ready to be used and burnt on CD, to start it on real machine








Preparing the Loopback adapter
We need the Loopback adapter to allow the Microsoft Virtual PC to connect with the Real PC, in our case we need it because we will use the Network boot to start up the Singularity.

Go to control panel and double click on "Add Hardware"

Welcome screen, just click on Next

Select "Yes, I have connected my hardware" and press Next

at the bottom of the list select "Add a new hardware device" and press Next


Select "Network Adapters" from the categories list and press Next

From the left menu select "Microsoft" and from the right list Select "Microsoft Loopback Adapter" and press Next

Press"Next"

Now you have the loopback adapter and ready to be consumed

Now you have the new connection appears on "Network Connections"

Select properties of "Loopback adapter connection" and select "Internet Protocol" and press "Properties"

Enter the IP address "10.99.99.1" and the network mask is "255.255.255.0"








Preparing the Virtual PC
Press"New"

Welcome Screen Just press "Next"

Select "Create a virtual machine" and press Next

Enter the Machine name

Select the type "Other",

Select RAM size needed, I don't think we will need more than what is allocated as recommended

Select "new Virtual hard disk" and press "Next"

select the path and the name of the Virtual PC hard disk file name

press finish.

from the Virtual PC, click on "CD" Menu and click on "Capture ISO image"

after that the system will start as you can see, but I faced some problem with the keyboard, it wasn't working, I think there is a problem, or something wrong I have done :D, but it will work when I boot from the network, wait and I will show you.








Preparing for booting and debugging the system


open "Singularity RDK 1.1" from your desktop, enter this commands
cd boot
bootd /dhcp /tftp
this command open port and do some kind of network boot,

open anther "Singularity RDK 1.1" and write this commands
cd build
boottest ..\boot\pxe.vmc
the last command loads the floppy disk image, all what it does is load the operating system from the network from the ip "10.99.99.1" that's why we setup the loopback adapter

In this snapshot I tried to open the WinDbg but it didn't work, because the command can't find windbg.exe

Here I have added the path of the Windbg to the system path , the I tried again using the this command
cd build
dbg /pipe

after that the debugger started and as you can see there is 2 parts, part for the debug strings, this strings are coming out as trace log, down there the code where you are working on, use the command "break" in the "singularity" windows


when you use "Break" command, it cause a break point in the debugger, you can use this debugger to navigate through everything, stack, memory, current registers and so on

at this point, I wanted to show, how to start his stuff to be able to add our code, the code that i am planing to add and I hope that I success in that is adding Arabic Support to output screen, please pray for me, thanks for your time, it was really exhausting to write such topic, it takes lot of time, anyways it is good as long as you read it, thanks for your time



I forgot to tell you about the Network boot loading,
open the "Singularity RDK 1.1"
write this command
.\built\boottest.cmd /Net .\boot\pxe.vmc
here is the result in the command window, it will be pop anther window

here is the window, it is preparing and listening to the upcoming requests

here it is, now it is feeding the Virtual machine with booting needs,

P.S: in this network booting, I have used the Tiny build of the project



BR
Ahmed Essam

18 comments:

Anonymous said...

Excellent article!! Thanks for such a detailed Singularity guide. :)

Timer said...

جزاكم الله خيراً على هذه المعلومات القيمة


Thank you. Good work.

ahmedebeed555@yahoo.com

Rahul said...

How did U added the path of Windbg to the system path. I cant find that. Please help in that regard.

Ahmed Essam said...

Hi Rahul

Look, copy the path of the WinDBG and add it to the system variables "path", I have done that and it works with me, try and and tell me if it works or not

Rahul said...

Hi Ahmed,
I hadnt installed the Windows Debugging Tools, after installing them and adding the path to the system variables "path", i was able to get the WinDBG command working.
Thanks for this step-by-step tutorial. This is more elaborative than the one provided along with the Singularity RDK kit.

Anonymous said...

great article. i just wanna say that you compiled it good. you wrote that your keyboard didnt work. Just set more memory in virtual machine (from 128 to 256) and then it'll be working ;)

Ahmed Essam said...

Hi Gordon,

Really thanks for your reply, I read about that problem and I found that it is because the memory size as you have said, thanks for your care :), GOD bless you


BR
Ahmed Essam

Anonymous said...

have you tried vmware instead of microsoft's virtual pc?

Anonymous said...

Nice post man...

But your English really sucks....

Ahmed Essam said...

I know my English is sucks
you have to consider many things

this is not my native language
this is not one of the most used language
I can say what people can understand.

I am working to enhance my English language skills

Thanks for your comment

Abhinov said...

It didnt work in VMware Workstation 5.5 for me when i tried to mount the iso and boot it. I didnt try network boot,though.

Abhinov said...

http://www.codeplex.com/singularity/WorkItem/View.aspx?WorkItemId=3394

The issue of Singularity not booting in VMWare has been reported for quite sometime. Hopefully it will be fixed in future builds.

Anonymous said...

from where can i download singularity .......

Ahmed Essam said...

Here is the page of the project at Microsoft research
http://research.microsoft.com/en-us/projects/singularity/

here is the page from code plex, you can find the code there
http://www.codeplex.com/singularity

in the code plex page go to "source code", you can download any state of the project

Anonymous said...

Hello. Currently I am writing a paper for University about Singularity. I found your article and your screenshots nice to be mentioned and would like to include one screenshot of yours in my paper.
Am I allowed to do this?

Would be great to hear from you soon...
Regards,
Sebastian

Ahmed Essam said...

You are welcome to use the snapshots,

If you don't mind, It will be great if you put the blog on your references :), or just mention that you got the pictures form here :)

Mohamed Moshrif said...

Something to add, MS reseach is also working to grand a CIL processor which executes IL directly, if this was to be done, then no need to the C++/Assembly layer anymore :)

See this:

http://fs.ineta.ru/f.ashx?id=bf860399-6201-40d8-b038-c16271782a6c

Ahmed Essam said...

I think the use of IL is to be cross platform, this is what it should mean,

if we have a processor that runs IL, then what is wrong with x86, may be little bit ugly but it works :D

I saw diagram before for ARM processor and I got shocked when I saw BIG BOX saying that there is J2ME instructions implemented on the hardware, I think this is near for what you are saying, I will try to get this slides I think it will be useful for everybody.

Thanks for your comment Meshref, it means a lot :)