Tuesday, 14 April 2009

Portable Assembly Tutorial - Part 1

Introduction

Learning assembly is a major pain in the ass because there is little documentation on the subject compared to higher level languages like C++ or Java. Furthermore, different assemblers (Things that turn your assembly code into programs) have different ways of doing things, making switching between assemblers a difficult task.

To make things even more tricky, many assembly tutorial writers choose to write their tutorials in a manner which means the examples will only function on a certain operating system. To break from the mold, this tutorial gives examples that should function on Windows, OS X, Linux, BSD, Solaris and any other. In fact, you would have to be using a pretty strange system if these examples didn't work. This tutorial will also point out when parts of the code may vary on other popular assemblers.

So, in light of the lack of *easy to understand* documentation on the internet, I have decided to start writing a massive assembly tutorial, split up into many manageable sections for everyone to read. I have even targeted this tutorial at people who can't even program full stop. This tutorial isn't designed as a reference, later parts build off content from previous parts, so you should read all the parts in the right order.

This part (Part 1) will discuss why you would want to learn assembly and why I choose the options I choose in the this tutorial. I will also discuss how to use assemblers, which will lead nicely into Part 2, which is where I will show you how to write a "Hello World" code. The "Hello World" code is the classic code that people learning how to program write, and it just displays the phrase "Hello, World!" on the screen when it is run. I know you want to write a "Hello World" code right away, but before we can do this, we need to get a little info, which is what this part is all about.

I will also teach you how to use C functions (Features in the C language that gives you the ability to achieve certain things), but I do *not* assume you know C, so I will tell you exactly what the functions are doing.

As I said before, all the assembly examples on my tutorial will be portable, you should be able to assemble them on Windows, OS X, and *nix. That is why you won't see unportable stuff like stand-alone system calls (System calls are a way assembly can do things, but I won't be using them in this tutorial, because they are not portable. But, I will be teaching how to use 'system call variables' in a later part of this tutorial, which are system calls that are portable. But in the earlier parts, I will just use C functions which are also portable, and a lot easier).

Don't worry if you don't know what 'C functions' or 'System call variables' are, I will explain all of this later on!

Just to say, I haven't copied and pasted off a site, this is completely my work.


Why Assembly

Why the hell would anyone learn assembly when excellent languages like C++ and Java exist? Why would a n00b want to learn assembly before any other language? Well, there are a few reasons, both for and against. Here are a few....

Against Assembly -
> Takes ages to write a simple code.
> Different across operating systems, assemblers and platforms.
> Very easy to crash programs and even damage hardware.
> Little support and documentation.
> Fewer job opportunities than higher level languages.

For Assembly -
> Blazingly fast programs.
> You can reverse engineer any program without the source code (The code from what the program was built from).
> You can use C functions and system call variables to make code portable, these features will be explained throughout the tutorial.
> You can optimize compiled code generated from C, C++, Parcal etc compilers (Compilers turn higher level code like C++ into a working program).
> You can access powerful capabilities in hardware, which is something higher level languages couldn't dream of.
> You can use inline assembly (Assembly code embedded into your higher level code) to speed up trouble spots in higher level languages.
> You can avoid using capabilities exclusive to certain hardware to make your code, again, portable.
> It will be very easy to learn a higher level language once you know assembly, and you will have a solid understanding about how higher level languages actually work.


Which one?

There are many different types of assembly, there are different ways of doing the same thing. In my opinion, there are a few assemblers you should know about.

MASM -
Microsoft's assembler. This is only for Windows and is not maintained as a individual product anymore, but it is included with Visual Studio.NET. It uses the Intel Syntax (See more about syntaxes below). There is a another project called MASM32, which is non Microsoft, but I know little about this project...

NASM -
The Netwide assembler. It can be installed on many operating systems, including Windows, OS X and of course, *nix. It uses the Intel syntax.

Gas -
The GNU assembler. It is available on many operating systems including Windows, and it's on *nix and OS X by default on many versions. It uses the AT&T syntax by default. It can assemble code for so many platforms, including SPARC, x64 etc.

Other assemblers include FASM (Flat Assembler), YASM (Don't know it's acronym) and SOL_ASM (Solar Assembler).

When I say 'Intel syntax' or 'AT&T syntax', I mean how the language looks. A line of code that performs a certain task may look different from one syntax to another, even though they are both assembly. For example there may be certain symbols in one syntax that aren't used in the other. One may use keywords, whilst the other may use a different keyword.

The one we will be using is Gas, which uses the AT&T syntax. This is because it's the assembler that GCC uses, which means it will be easy to integrate C functions into it. So many people use GCC these days, it seems Gas is a good choice. Gas supports loads of hardware, more than NASM and MASM. It works very well with many GNU tools that are useful for assembly, like the profiler, debugger and compiler. The profiler allows us to check the speed of programs. The debugger is let's us go through our programs step by step. The compiler is used to assemble code that uses C functions (Because it's just so much easier than using the assembler). I doubt I will be covering these tools in my tutorial, except the assembler and the compiler. This tutorial is about teaching assembly, not how to use GNU assembly tools, since there is enough documentation on that subject.

The unfortunate thing about Gas, is that it uses AT&T syntax rather than Intel. This means it will be different to use Gas than NASM or MASM. But once you've learned assembly, it shouldn't be that hard to learn the differences. Major differences between them will be pointed out throughout the tutorial.


How to assemble stuff

Before I give you the example code in Part 2, I need to tell you how to assemble your code. Firstly, you will be writing your code into a text file. You can use Notepad (I wouldn't recommend it though) for Windows, OS X's text editor, or Gedit in Linux. You don't need to do anything special, you just type your code into it and save it. But here is the difference... when you save it you need to put .s at the end of the file name. This is called a file extension, and it's used to identify the file type to the operating system. .s means assembly source for Gas. Other assemblers like MASM use the .asm extension instead.

For example here is a good file name for some assembly code.
really_cool_computer_program.s
Here is a file name that isn't good....
really_cool_computer_program.txt.s

The file name can have spaces, but it's more easier to just use underscores instead. This avoids confusion when you tell Gas to assemble your code, which leads us to the next bit...

Using Gas is quite simple. It needs to be done in the command line (Don't worry, no command line knowledge needed, though it helps). Here is what you do....

Open the command line. It's in Start>All Programs>Accessories>Command Prompt on Windows. On OS X, it's in Application/Utilities/Terminal. On Linux/BSD it's...well.... everywhere.

Now you're in the evil command line, let's use Gas. Window's users will have to actually find the as.exe file on their system (Use the search tool) and manually type the entire location into the command line. OS X and *nix users on the other hand, should only need to just type 'as' into the command line.

Note that the ~ symbol means your Home directory in OS X/*nix.

So, you first type the program in. On Windows it would look something like this (I'm using the the Gas included with popular Dev-C++ compiler, but you could use any) -
c:\dev-cpp\bin\as.exe
On *nix/OS X, you only have to type this - as
Now, put a space after that. Now you have to type the address of the assembly code you want to assemble -
On Windows -
c:\dev-cpp\bin\as.exe c:\documents and settings\user\desktop\assembly_source.s
On *nix/OS X -
as ~/Desktop/assembly_source.s

Don't hit enter yet....

Now, that's all well and good, but we need to tell the assembler where to dump the 'object code' it creates using your assembly code. Object code is the 'half way' point between a assembly source and a finished program. Notice in the next example how the second address is the same file, but it ends with .o rather than .s? The output should always end with .o. Now, add another space and add '-o' and put a space after this. Then you write the address of the place where you want to put the finished.

On Windows it would be like this -
c:\dev-cpp\bin\as.exe c:\documents and settings\user\desktop\assembly_source.s -o c:\documents and settings\user\desktop\assembly_source.o
And on *nix/OS X
as ~/Desktop/assembly_source.s -o ~/Desktop/assembly_source.o

Now see that file with .o at the end of it? That's the file that will be converted to a finished program using a process called 'Linking'. You don't need to know how this works right now, just accept that it works =)

Linking a file is the same process as before, but with a few modifications....
firstly, as is replaced with ld. And now the file that ends with a .o is the first address, not the second. The second address is the finished program. Here is a example in Windows -
c:\dev-cpp\bin\ld.exe c:\documents and settings\user\desktop\assembly_source.o -o c:\documents and settings\user\desktop\assembly_source.exe
And on OS X/*nix -
ld ~/Desktop/assembly_source.o -o ~/Desktop/assembly_source

Note that a Windows program has a .exe extension, whilst a *nix file doesn't have one at all. I'm not sure about OS X though, I think it's .app.

Now you know how to assemble programs, you should go onto part 2, which will tell you the basic layout of a assembly program, and a "Hello World" code.

PART 2 WILL BE WRITTEN SOON! =)

SunSpyda

Monday, 23 March 2009

Configuring Vim

The Vim text editor is available on nearly every OS around (Primarily *nix), and it is popular among heavy text users like programmers. It is configured by modifying the .vimrc file.

The .vimrc file is located here on most OSes -
~/.vimrc

You change settings by writing lines into the file. Vim then checks this file before it runs, and applies any settings in the file. Each setting needs to be on it's own line. You can modify the .vimrc file with any standard text editor like Gedit, Kwrite, or even Vim itself.

These are options that could make your life a bit easier.


syntax on

This will make Vim highlight your text, depending on what programming language you are using. If you don't use Vim for programming, you will probably find no use for this.


set tabstop=x

By default, tabs are 8 spaces, and it is the same on most text editors. Some people (like me) prefer a different amount like 4. The x represents the amount of spaces a tab should be. So, if I wanted my tabs to be 4 spaces, I would add this line -

set tabstop=4


shiftwidth=x

Similar to above, but it applies to reindent operations and automatic C indentation.


set autoindent

This is another feature coders will like. It does what it says on the tin, it automatically indents, for example the line after a {.


set nobackup
set nowritebackup


Vim will backup active files out the box. This is so if Vim dies for some strange reason, you won't lose that much work. Unfortunately, the backups seem to cause conflicts sometimes when reopening files and other things, so it is best to turn this off, and just manually backup when required.


set ruler

This will give some useful information on the bottom line like what line you are on and stuff.


These are just a few options you can modify on the Vim editor. Here is my ~/.vimrc file, in case you want to take a look -

syntax on
set nocompatible
set tabstop=4
set shiftwidth=4
set autoindent
set smartindent
set nobackup
set nowritebackup
set ruler

Wednesday, 11 March 2009

My Review of the Linux/Unix OSes

I have used many Linux/Unix OSes, so I decided to review a few of them, so newcomers to *nix have a easier time deciding. I will add more as I use more.


>>> Ubuntu Linux <<<


UI -
Gnome DE. Very easy to use and it comes with many GUI tools to manage your machine. Nearly all point-and-click for casual users. Verbose bootup hidden with a graphical Ubuntu screen like WIndows. No CLI needed for casual use.

Ease of Use -
Very easy. All works out the box most of the time. Graphical wizard installation and Wubi makes install very simple. Automatic partitioning. Wubi allows installation through WIndows. Grub picks up the other OSs and automatically configures itself 99% of the time. Anything casual can be done through Gnome. Preconfigured with easy going defaults. Easy for Windows users. Experienced users might find it restricting though.

Hardware Support -
Wonderful. Picks up hardware and installs drivers without even asking a lot of the time. Installs closed source drivers like ATI graphic cards. Comes with a hardware testing tool. X11 failed on one of my dual head machines whilst booting of the live CD, indicating that it might be lacking dual head graphic card support. Picks up quite a few WiFi NICs. Overall, very good.

Speed -
Not impressive at all. Slow boot up, Gnome often lags, and it takes a while to do basic things. It's faster than Windows, but compared to other Linux/BSD distros, it seems really slow. It will thrash older hardware, so don't use it on older machines. This is probably caused by Gnome and lots of GUI tools.

Out of Box Security -
Pretty decent. It comes with UFW preinstalled that blocks all ports by default, unless a application tries to establish a connection. All preinstalled programs don't encounter any issues with the firewall, but user installed programs might. Access to root has been blocked, you will need to use Sudo and Su to gain root access. Most GUI tools will just prompt for a password when needed. Assumes the user isn't a security pro. GUI is available for the firewall, just apt-get GUFW.

Updates -
LTS versions are released every two years. People wanting a more robust OS should just upgrade to LTS versions. New versions are released every 6 months. Updates are easy to get - just click a icon in the notification area. There have been many stories of people upgrading and breaking their OS. These stories are quite rare though.

Use as a Seedbox or Server -
No way. The fact that it comes with so many applications and a full fledged Gnome DE installed means that this is too bloated for a server. The Ubuntu Server Edition is pointless, seeing as Debian is probably the same but less bloat.

My recommendations -
It's bloat and GUI will be great for new users, but will simply restrict seasoned users. Power users should use Debian if they want a similar OS to Ubuntu, but without the bloat. As I said before, this OS is NOT suitable for servers/seedboxs. Then again, Ubuntu does seem to have better out-of-box hardware support.


>>> Debian GNU/Linux <<<


UI -
Default install CD comes with Gnome as optional install. A KDE and XFCE disk is also available, but these don't offer the option to select what you want to install (God knows why.). The default install with 'Desktop Environment' is quite bloated, but not as much as Ubuntu. It comes with many GUI tools, but many things are still best done through the CLI on Debian more so than Ubuntu. Install without 'Desktop Enviroment' will give you a CLI interface.

Ease of Use -
Easy, but not quite as easy as Ubuntu. New versions even come with a GUI installer (Type gui at boot.). Install is quite easy, and will automatically partition HDD. Not many difficult questions, even on expert install. The Debian installer really has come a long way. If 'Desktop Environment' was selected, you will get a complete Gnome DE and GDM installed, meaning you will also have a GUI login prompt. Apt-get is really easy, and if you installed 'Desktop Environment' there will be a nice GUI tool to do it for you, like on Ubuntu. Easy to use, with many GUI tools If you don't install 'Desktop Enviroment' then it will be a little more tricky to use, but it should be fine for CLI users.

Speed -
Pretty good. It certainly beats Ubuntu, even with a 'Desktop Environment' install. If you installed it without 'Desktop Environment' it performs pretty good. It runs well on old hardware. Reasonable boot up and doesn't often lag.

Out of Box Security -
Not sure about this one. I forgot to check what packet filter it uses by default. But Debian is known for it's solid kernel and it's stable updates (Not including Debian Sid obviously.). Some tweaking could make this a good server install.

Updates -
As I said above, Debian Stable releases robust updates that won't panic your kernel =) Some of the software on the ports is out of date by two years, which means it is stable, but it won't exactly be cutting edge. Update seemed to go fine for me. You can use apt-get like on Ubuntu.

Use as a Seedbox or Server -
Definitely. It has a solid kernel, stable updates and it is pretty zippy. On a server you shouldn't install X, so don't bother installing 'Desktop Environment' on a server.

My recommendations -
If you want a zippy workstation, don't install 'Desktop Enviroment'. Install it without it and in the CLI 'sudo get apt-get gnome-core gdm xorg xserver' will install essentials of Gnome without unneeded programs.


>>> Arch Linux <<<>

UI -
CLI only on install. You will need to download, install and set up a DE/XWM separately. Modifying configuration files is the only way to do many things. CLI knowledge is a must. A new user jumping into Arch will learn the CLI very quickly. Arch sometimes puts things like configuration files into non-standard places, so configuring it may need some research.

Ease of Use -
Not for someone who wants an easy GUI environment out the box. Installing a DE/XWM will require some knowledge. Not easy to use.

Speed -
One of the fastest Linuxes I have used. Due to the lack of junk and bloat on Arch, it is a very zippy little OS and it will out perform most other popular Linuxes out the box. Even with a GUI installed, it was still very fast. Extremely fast boot up. For those who want it fast, this may be the one.

Out of Box Security -
Being honest, I didn't really do any security testing on Arch. Lack of unneeded features will make it more secure. Arch has had a reputation for including bleeding edge features into the ports and OS, some of which aren't that stable. Do some research into the version you are going to download before downloading, to see if any major bugs have been found.

Updates -
Packman worked very well for me. It was fast, efficient and it didn't seem to dependent. As I said before, Arch is bleeding edge, so expect an unstable package every now and then.

Use as a Seedbox or Server -
No. It's speed may be good for a server, but it's bleeding edge features wont. If you are going to install to a server be prepared to get screwed over by unstable packages.

My recommendations -
As a workstation OS, Arch is perfect. Fast, uncluttered and a fast package system. For servers it may not be stable enough though. This may be the perfect OS for power user's desktops/laptops.


>>> OpenBSD <<<

UI -
CLI only. Despite X can be installed off the disk, it's only a windowing system. No GUI tools, no chrome, no DEs or anything else. Included XWMs are TWM and FVWM, both of which are really only for seasoned *nix users, not n00bs. Configuration files are the only way to configure it, except some really basic Unix shell scripts like 'adduser'. You will need to do your homework if you don't come from a BSD OS, even if you are a Linux pro. Knowing Vi is a must; no GNU editors are included. This will be very difficult for n00bs.

Ease of Use -
Not easy in the slightest. The only way to configure is by modding files using Vi, which most casual Linux users probably haven't touched. However, a skilled *nix power user will find it's simplicity wonderful, with much of it being very logical (From a Unix point of view). Installing X won't give a easy life for n00bs, because the only XWMs included are not suitable for n00bs, and they still rely on the CLI. This OS is *extremely* secure out of the box, so much configuring will have to be done to make it usable for a workstation, as OpenBSD excels at firewalls, routers and secure server usage out the box, not workstations. This configuration process will require a decent Unix knowledge. Although configuring to make it more secure wont be needed.

Speed -
Despite it's known issues with performance, I found it to be one of the fastest OSes I had ever used. So why do some people find it slow, yet others find it very fast? I don't know. How fast it works on your computer is unknown until you test it. I got lucky it seems, OpenBSD is super fast for me. Despite the rumor, OpenBSD *does* have SMP support, but it's pretty limited at the moment. Overall OpenBSD's performance varies wildly. But if the SMP kernel doesn't support your SMP CPU, it truly will crawl.

Out of Box Security -
OpenBSD has only had 2 remote holes in the default install in over 10 years! The security of this OS is absolutely amazing. It makes Debian look as insecure as Win98 in comparison. These guys created OpenSSH, a standard that is used by OSX, Novell, Sun, IBM, Nokia and a whole range of other companies. The most secure version of OpenSSH is the one included with OpenBSD. I have read many reliable stories off renown tech sites, about how OpenBSD systems have survived attacks that no other OSes (Including Solaris and FreeBSD) have. PF is an amazing firewall and it eats IPTables for breakfast. Security is OpenBSD's top priority, and it really shows.

Updates -
As far as updating the OS goes, updating probably won't be required, because it's rare that security bugs are found. It will just keep on running securely, even if it's out of date. Applications are a different story. They have a different package tree for every version. If you want to run software that isn't on the package tree, then being able to install that application will probably not happen, unless you want to build your own port..... OpenBSD isn't compatible in the slightest to be honest.

Use as a Seedbox or Server -
For knowledgeable Unix people, this OS would (IMHO) be the ultimate OS for this use. It's secure out the box, and it doesn't have services that aren't needed. It is minimalistic and it won't contain junk that isn't needed. People who want a GUI server/seedbox will be very disappointed. Ubuntu and Windows Server people will find OpenBSD's way of doing things archaic. If you want a server that just works, OpenBSD isn't for you, unless you know a bit about Unix already.

My recommendations -
If you haven't done your research, OpenBSD can be frustrating to use. Knowing Linux probably won't help you here. If you want a ROCK solid computer, this is the OS to go for. On the other hand, if OpenBSD doesn't support your SMP CPU, it will crawl, so there is no point in using it. It worked on my main PCs, and it hasn't crashed once. ever. It's security is just bliss. No tweaking, because its ultra secure out of the box. OpenBSD has serious flaws and serious pros. If the flaws don't apply to you, feel free to use it. If you are a Windows person, or a cutting edge SMP CPU owner, or a person who is happy with tweaking their OS to make it more secure, don't use OpenBSD. If your CPU is supported, and you like using *nix, and you want a rock solid OS, use it.


That's all for now. I will add a few more later on.

Wednesday, 4 March 2009

Windows Cleanup Batch Script

OK, I'm getting tired of people recommending Windows clean up software to each other. Clean up software is often bloated & won't clean everything. So I have made this tutorial to show you how to make a file you click & it does it all for you. No software needed. Here we go....

Create a new file using Notepad & call it "cleanup.bat"

Now it's created, right click it & press "edit".

Now copy this into it -


@echo off
DEL /S /Q /F "%systemroot%\temp\*.*"
DEL /S /Q /F "%systemroot%\prefech\*.*"
DEL /S /Q /F "%username%\cookies\*.*"
DEL /S /Q /F "%username%\local settings\temp\*.*"
DEL /S /Q /F "%username%\temporary internet files\*.*"
DEL /S /Q /F "%username%\recent\*.*"
DEL /S /Q /F "%systemdrive%\documents and settings\localservice\cookies\*.*"
DEL /S /Q /F "%systemdrive%\documents and settings\localservice\local settings\temp\*.*"
DEL /S /Q /F "%systemdrive%\documents and settings\localservice\local settings\temporary internet files\*.*"
DEL /S /Q /F "%systemdrive%\documents and settings\networkservice\cookies\*.*"
DEL /S /Q /F "%systemdrive%\documents and settings\networkservice\local settings\temp\*.*"
DEL /S /Q /F "%systemdrive%\documents and settings\networkservice\local settings\temporary internet files\*.*"
CLS
echo System Cleanup Complete =)
pause


This will only clean up Windows directories. You will need to add your own directories for third party programs like Firefox, to get it to clean them.

Now save it. Whenever you want to clean your PC, just double click it & watch it do it's magic....

Accessing External Drives on Unix Terminal

My friend just installed OpenBSD on my recommendation, but when he went to copy his music from his external HDD, he found he didn't have a clue what to do, since OpenBSD doesn't have a /media directory or a auto mounter, and Gnome won't show non root drives up until they are manually mounted. So after I shown him how to do it, I decided to write a brief tutorial on it. This technique will probably work on most other Unix OSs around (Including Mac OSes that are based on Mach/BSD) , but it may differ a lot on Linux, since Linux uses a easier system now on most distros.

When typing in commands I give you the commands in quotation marks.... Don't put the quotation marks into the commands =)

Plug in your external drive.
Wait about 6 seconds, for Unix to find and initialize the drive.
Open up a terminal. I doesn't matter which shell it is using.
Type 'dmesg' and press enter.
Look at the bottom of the output 'dmesg' gave you.

When I plugged my iPod Mini in, this is the information 'dmesg' gave me at the bottom.

inumass0 at uhub0 port 1 configuration 1 interface 0 "Apple iPod mini" rev 2.00/0.01 addr 2
umass0: using SCSI over Bulk-Only
scsibus1 at umass0: 2 targets, initiator 0
sd0 at scsibus1 targ 1 lun 0: SCSI0 0/direct removable
sd0: 3906MB, 497 cyl, 255 head, 63 sec, 512 bytes/sec, 7999488 sec total


From reading this, I learned that my iPod was 'sd0'. I gathered this information from the last two lines. It should be similar for you.

Now type 'disklabel XXX'. replace XXX with whatever your drive is called by BSD. For me, it was called 'sd0'. For you it may be different.

Now, you will see the partitions on the drive. You need to spot the partition you want to mount. For example, if you want to access a 40GB iPod, you should probably look for the partition that is using FAT32 and has around 32GB in size. I will show a example below. You may see some partitions that you weren't aware of, don't worry about this.

This is the 'disklabel' output for my iPod.

# size offset fstype [fsize bsize cpg]
c: 7999488 0 unused 0 0
i: 32067 63 unused 0 0
j: 7903980 80325 MSDOS
k: 48195 32130 ext2fs

The partition I payed attention to was 'j:' because it had a large size and it says it is using a MSDOS filesystem (FAT32), which common sense tells me its the partition I want. The reason for the other partitions is due to BSD and hidden partitions on iPods.

So I now know that my iPod is sd0 and the partition I want is 'j'.

Now you need to create a directory to access your drive from. So, if you want it in /home/user/ipod you would have to create that directory by typing 'mkdir -p /home/user/ipod' into the terminal and pressing enter. For this example I created a directory in /mnt/iPod by typing 'mkdir -p /mnt/iPod' into the terminal and pressing enter. Now you have your directory you want to access the drive from.

Now, let's mount the drive.

My iPod is sd0, and I want to mount partition j. I want to mount it into /mnt/iPod. So, this is what I would type.

mount /dev/sda0j /mnt/iPod

This is the syntax...

mount /dev/XY Z

X=The drive name (For me it was sda0)
Y=The partition letter (For me it was j. This comes straight after the drive name with no space)
Z=The directory you want to access the drive from.

So, if I wanted to mount the drive 'hda1' partition 'e', and access it from directory /root/External_HDD I would type this...

mount /dev/hda1e /root/External_HDD

That's it. This should really only be used on servers and stuff. Sane people would install an auto mounter on a workstation PC, making their lives a lot easier. Hope that helped some of you out. =D

Sunday, 2 November 2008

Installing & Using The Borland C++ Compiler


The Borland C++ Compiler is a command line based C++ compiler for Windows. I have been using DevC++ as my C++ IDE, but I decided I wanted to write the source in notepad & just use a simple command line compiler to compile it. Due to some of the difficulties I had with installing & using it, I decided to write a tutorial about installing it & using it. There is a Borland IDE, but the command line version is free.


Downloading It

Firstly, I will give the link to the download page. This is a link to the official page -
http://cc.codegear.com/Free.aspx?id=24778

The first thing you notice, is that you need to register with them to download it. So we are going to just give them a fake email address & fake infomation. Obviously, pick the correct country, so it gives you the right language.
You will have to have cookies enabled for the page. Left click the 'Create Account' button. You should now have a 'Download Now' botton on the page. Left click it.

Now you have to agree to their TOS. Their TOS says you can't make nuclear weapons with their product, so if that was the plan don't download it... =)

Click 'Agree (Let Me Download It)'.

Now your download manager will come up asking you what to do with it. Tell it to save the file onto your desktop. Now wait a few seconds whilst it downloads. Once it's downloaded, go onto the next step.


Installing It

Now, there should be a icon oon your desktop that's called 'freecommandLinetools.exe'. Run it. Now a installation wizard has came up. Press 'Next'. It will ask you where you want to put the Borland Compiler. Let it install it in the default directory. Once done, click 'Finish'. A dialog box will come up. Click 'Yes'. Now it will begin to install. Once the installation has finished, a dialog box will come up. Press 'OK'.

Using It

Unlike most programs, Borland Compiler won't place any shortcut on the start menu. So we will have to find the program ourselves. I'm assuming from now on that you installed it in the default directory. In Windows Explorer, go to C:\Borland\BCC55\Bin. We can't just run the program by clicking on it, as it just shuts down as soon as it opens up. So we have to run the program from the command line. First, open the command line by typing cmd into the run dialog box. Now you should have the command prompt on screen. Type cd
C:\Borland\BCC55\Bin into the command prompt & press enter. Now type bcc32.exe & press enter. Now the compiler have been opened. To compile a file, you would type bcc32 -path of c++ source file- -Destination of binary-. See the next section for more infomation.


Example

I have just written a C++ source file in Notepad. First, I would save the file in Notepad by pressing CTRL-S. Then I would change the 'Save As Type' drop down menu to 'All Files'. Then I would name it Filename.cpp .Now I would work out the path of where I saved it. I saved it in c:\programs\program.cpp. I want the compiled binary to end up in c:\program.exe So, then I would run The Borland Compiler and type -

bcc32
c:\programs\program.cpp -n c:\program.exe

Then it should turn the .cpp file into a .exe file. The compile has worked. You can now run the .exe file by double clicking it.

That's how to use the basic elements of The Borland Compiler

Tuesday, 28 October 2008

My Review Of The Mojave Experiment


I have always defended Linux as being far better than Windows. But recently in Linux Vs Windows Vista forum threads, pro Windows forum users have been pointing me to the link to something called '
The Mojave Project'. They all say this proves Vista is good. So I decided to take a look. First let's look at the actual site.


The site

The first thing I got asked when I tried to go onto the site was 'Please install Microsoft Silverlight'. After clicking 'load page without Silverlight', nothing happened. I disabled my script blocker, to find out that most of the site was in flash. Why not use HTML? But like Vista, they filled it with unnecessary code, rather than making it operate fast.

The site was slow & full of useless stuff. So I pressed the '
What is the mojave experiment' button. Rather than taking me to a page explaining this, it decided to load up even more flash script to open a transparent box, which had the explanation inside it. Why not just have a new page?

A lot of people told me this site wasn't anything to do with Microsoft. Why does it say '
This site is hosted for Microsoft' at the bottom? Obviously it is.

The site is badly made. Onto the theory of the experiment....



The Mojave Experiment Theory


Ok, so here is the idea. They get Vista & they try to make it look like a different Windows Operating system called 'Mojave'. Then they ask users what they think of Mojave. This experiment is meant to prove whether Vista is actually bad, or people think it is because of what they have heard.

Here is what the site said -
'
What do people think of Windows Vista when they don’t know it's Windows Vista? To find out, we disguised it as "the next Microsoft Operating System" codenamed, "Mojave" so regular people who've never used Windows Vista could see what it can do – and decide for themselves.'

OK, first things first. Nobody skilled at computers could of participated in this experiment. This is because nobody skilled at computers would of really believed that there was a new Windows operating system they had never heard of. So I have worked out already, that all the people in this experiment didn't know anything about computers. Now I am going to show why their end results were not too accurate either.


Their statistics


These statistics were made from the end result of the experiment.


'94% of respondents rated the “new OS” codenamed Windows “Mojave” higher than they initially rated Windows Vista before
the demo.'

Hang on a second!
'so regular people who've never used Windows Vista could see what it can do'
They say here that they were users who hadn't used Vista before.... But an earlier explanation of this experiment says that they have already used Vista & they have evaluated it. Two contradictory statements.


'Types of Computer Users participating in the “Mojave Experiment:”
  • 84% Windows XP users
  • 22% Apple OS users
  • 14% Pre-Windows XP users
  • 1% Linux users
  • Some users use multiple platforms.'
They have missed out a type of user.... The user who actually knows about computers. As I said before, advance users couldn't of been used in this experiment. So this isn't a fair representation of computer users globally. So these statistics are unfair as well.


Their Facts


Which they try to use to advertise Vista. I thought this was an experiment, not an advertising site....


'The phishing filter in Internet Explorer 7 – which is included with Windows Vista – stops about 1 million phishing attempts every week.'

Firefox & Opera have been able to do this for a long time.


'In the first quarter of 2008, Windows Vista had 25% fewer total vulnerabilities than Windows XP SP2.'

SP3 is out now for XP. They're using out of date statistics .
The reason it has less security vulnerabilities is because nobody could be bothered to try to hack Vista, because most people were still on XP. Vista will get hacked more often when it becomes popular.


'In 2007, Windows Vista had half the number of critical vulnerabilities than Windows XP SP2 did during the same period.'

That's because most of Microsoft's programmers were busy fixing Vista's vulnerabilitys, rather than XP's.


'Since Release to Market, the total number of devices and components supported on Windows Vista has more than doubled.
Thousands of the most popular devices and software programs are now compatible with Windows Vista.'

If someone wants compatibility, they will use XP not Vista. There is no doubt that XP is more compatible with hardware & software than Vista.


The Videos

I'm not gonna watch a load of people tell me how great their new Vista start menu is. I could not be bothered to even watch one of them. The funny thing is, The videos on the main page actually have a lot of the same people in it. Three of the videos have images of the same person. This probably means that they couldn't find enough people for the experiment. The fewer people you have for an experiment, the less accurate it will be.

If I could actually be bothered to watch the videos, I would probably find loads more biased infomation.


Conclusion


Call this an experiment?!

It had contradictory statistics,
It had facts that did not matter,
It only used computer begginers for the experiment,
& it is linked to Microsoft, so obviously, it is going to talk about how great Vista is.
Other OSs rock, without having to put unrealistic, commercialised experiments on the net.

Hardening XP's Security


Windows in a very insecure operating system by default, so many setting have to be changed in order to make it more secure. In this tutorial I will be showing you what the administrative tools security options mean & how to configure them.


This tutorial is only designed for XP professional. XP home edition probably will not have some of these options available.


Finding & running administrative tools

If you're running XP professional, you should already have administrative tools installed.

Here is how to open it.

Open the Run dialog box & type 'control admintools' into it without the quotation marks or italics.

Now a windows should come up called 'Administrative Tools'.


Disable unnecessary services that could be a security risk

Windows has many services enabled that aren't necessary & could be used by a hacker to compromise your system.

By taking these steps, you will disable remote desktop & the ability for people to modify your registry over the net.

Despite the fact that remote services are reasonably secure, there has been security holes found in it.

Obviously, if you use remote services, ignore this stage.

In the 'Administrative Tools' window, open up 'Services'.

Another windows will come up called 'Services'.

In the services windows, find something called 'Remote Desktop Help Session Manager'

Doubleclick on it. Another window will come up.

In the new window, go onto the combo box & select 'Disabled'.

Close the window.

In the 'Services' window, find something called 'Remote Registry'

Doubleclick on it. Another window will come up.

In the new window, go onto the combo box & select 'Disabled'.

Close the window.

Close the 'Services' window.


Setting up the system's security

In the 'Administrative Tools' window, open 'Local Security Policy'.

A new windows called 'Local Security Settings' will come up.

In the 'Local Security Settings' windows, open 'Password Policy'

To change a option, double left click on it. A window for that option will come up. You can use this window to modify that option's settings.

Here are the options & explanations. Read the descriptions, before deciding whether to set them.

Enforce password history -
This option can make it so users can't use the same passwords for their user account, as they have used in the past. The number means how many passwords will be remembered. For example, if I used the password '1234' in the past & I tried to set that password again, it would not allow me. If the amount of passwords remembered was 10 then that means I would not be able to set a password that is the same as any of the past 10 passwords I have used. If it is older than the last ten passwords I have ever set, then I would be allowed to use it. This setting is useful, because if the user uses the same password over & over again, then there is a high chance that someone could work it out.

Maximum password age -
This option can stop users for having the same password for a long period of time. If the password age is 10 days then after 10 days of creating a password, the user will be required to change it. This is useful, because this stops users from keeping the same password for a long time. If the same password is kept for a long time, it might be found out.

Minimum password age-
This option stops users from changing their password multiple times within a brief period. If the setting was 3 days, then I would have to wait 3 days after changing a password before I can change it again.

Minimum password length -
This option stops users from having short passwords. Short passwords are easier to hack, so this makes sure that users can't have short passwords. For example if you put 6 as the setting, I could only have passwords over 6 characters long. If I tried to create a shorter password, I would not be allowed.

Password must meet complexity requirements -
This option makes sure that user passwords are complicated, so they are hard to crack. A password with just letters is not complex. A password with letters, numbers, Capital letters & symbols is complex. This helps stop user account passwords from being brute forced.

Store password using reversible encryption for all users in the domain -
Enabling this option will weaken password protection, so leave it disabled.

These are all the options in this section.

Now click the 'Up One Level' button. It looks like a yellow folder with a up arrow on it.

Double click on 'Account Lockout Policy'

To change a option, double left click on it. A window for that option will come up. You can use this window to modify that option's settings.

Here are the options & explanations. Read the descriptions, before deciding whether to set them.

Account lockout duration -
Sets up how long a account is locked out. Why would an account become locked out? Read the next option to find out.

Account lockout threshold -
How many times a user can attempt to logon with an incorrect password before the account is locked out. For example, if your setting was at 3 & I tried to log on & typed incorrect passwords 3 times in a row, it would lock the account out.

Reset account lockout duration counter after -
To be honest, I have no idea what it does. Most people say you should set this as the same as your 'Account lockout duration'.

These are all the options in this section.

That's all for now. It is only a third complete.

My Review Of Google Chrome

The internet giant Google has built there own internet browser, so I decided to download it & take a look. Knowing Google, this program might be a good competitor to Mozilla Firefox 3. It’s ‘Each tab is it’s own process’ & ‘Incognito’ features are some of it’s selling points. So has Google made yet another quality product, or have they made a undesirable browser?
I downloaded Chrome from here -
http://www.google.com/chrome


Installation

Rather than using a setup file that installs itself from the file, it uses a setup file that downloads it off the net for you & then installs it. After a installation process that took a reasonably long time, it gave me the option to import all the settings from Firefox. This certainly makes migrating from Firefox to Chrome a bit easier. It also offers to be your default browser, but it isn’t default. You can’t import Firefox’s setting whilst Firefox is running, so I had to restart Firefox. I decided I would write the rest of this review from Chrome. All my Firefox bookmarks, browsing history & recently closed tabs were all loaded into Chrome without a hitch. Now onto first impressions…


The Graphical User Interface

This is a whole new layout. No menu bar, no status bar & no toolbars. Is this an improvement? Rather than providing a toolbar which you can customize, they have implemented a locked toolbar which only has back, forward & the address bar. Through the settings you can also make a Home button. It also has combined the Go button & the Stop button into one…. It would seem logical to combine it with the Refresh button, not the Go button. Where are the bookmarks? I don’t have a clue. There is a bookmark option on Chrome’s default home site, but there is no menu. You can have a bookmark toolbar if you want, but you can’t just have a menu. Having a toolbar, rather than a menu just wastes screen space. This is useless, as being able to access bookmarks quickly is best achieved through a drop down menu. Whenever your cursor goes over a link, a little text box will scroll into view in the corner, telling you the URL of he link. When your cursor leaves, it goes. All the settings & page configuration are located in 2 small menus in the top right hand corner of the screen.


Speed & Multitasking Capabilities


On my 10 year old laptop, multitasking can result in a OS failure. So let’s see how many tabs I can open up before I crash my PC -
After about 12 tabs were open & Loading up data from the internet, my PC started so have occasional slowups, but mostly, it coped with Chrome very well. This shows that Chrome is certainly efficient with the system’s resources. A then decided to load up multiple seperate instances of Chrome. Again, it coped very well & none of the instances of Chrome had any noticeable GUI lag. Despite it’s slightly flash GUI, it’s fast responding & won’t make your PC crawl. I also noticed that it loaded up webpages a lot faster than Firefox.


Incognito Mode


Often crudely nicknamed by many as ‘Porn Mode’. This mode will not record site history or search history. Once you leave Incognito mode, all the cookies that your PC accepted in this mode will be deleted. Rather than making a tab that is in this mode, it will create an entire Chrome window for this mode. To be honest I’m not impressed by this. My Firefox is configured to be more safe than this by DEFAULT. If it was so stealth then it wouldn’t accept cookies full stop. Firefox has had the steather addon for a while, so Chrome hasn’t made a new feature.


Conclusion

Google Chrome shows promising features. But it is still in early days & it shows it. It is superior to Internet Explorer 7, But compared to Fierfox it has a long way to go. Most of the ‘new features’ aren’t actually new.

Here are the things that need to be improved -

- Customizable toolbars. Have a drag & drop system like Firefox.
- Bookmarks menu. A toolbar & a bookmark new tab page don’t cut it. Menus are the best way of seeing a large amount of bookmarks fast.
- Optional menu toolbar. The menu toolbar should be an option. I mean the toolbar that has File, Edit, View & so on.
- Better default security options. Accepting all cookies should also be turned off by default.
- Script blocker & a easy to use advert blocker should both be integrated or available as an addon.
- Enable the Home button by default.

Optimize XP


XP is the best Windows operating system except server in my opinion. It can be made to be very fast by performing simple steps. Here is a list of things you can do to speed it up;



Switch off the unnecessary GUI effects

Making your menus fade & the windows have moving effects isn’t an improvement & it will slow down the PC. So here is how to remove it….

Right click My Computer.

Click ‘Properties‘.

On the properties window, click on the ‘Advance‘ tab.

In the performance area, press ‘Settings‘.

Select the radio button option that says ‘Adjust for best performance‘.

Tick ‘Smooth edges of screen fonts‘. Reading blocky text can put strain on the eyes, so this one will be left on.

If you want to keep the theme you have running, tick ‘Use visual styles on windows and buttons‘.

Click ‘Apply‘.


Defragment the hard drive regularly

Everyone knows this one.

To defragment your hard drive do the following -

Left click start menu.

Click ‘All Programs‘.

Click ‘Accessories’.

Click 'System Tools'.

Click 'Disk Defragmenter'.

Select on the drive you want to defragment.

Click 'Defragment'.

The defragmenting process might take a while, but your PC will be a lot faster once it is finished.


Setting up efficient RAM usage

Now click on the ‘Advance‘ tab.

Make sure that ‘Programs’ is selected on both radio buttons.

On the virtual memory tab click ‘Change‘.

Select the radio button called ‘Custom Size‘.

make the ‘Initial‘ size the same as the ‘Maximum size‘.

Click ‘Apply‘.

Close the Virtual Memory Window.

Close the Performance options window.


Disable automatic download of updates

I personally don’t get updates for windows. But as many do, this section had to be included.

As soon as you connect to the net, XP will try to clog up your connection with updates. So, I will show you how to get XP to tell you that there are updates available, but it wont update them, unless you tell them to.

This means that you can update when you aren’t doing anything else on the net.

Click on the ‘Automatic Updates‘ tab.

Select the radio buttin called ‘Notify me but don’t automaticly download or install them’.

Click ‘Apply‘.


Turn off System Restore

If something goes wrong on my XP, I will fix it myself, not use System Restore.

If you use System Restore ignore this step. If you fix problems yourself & don’t use System Restore then read on.

System restore can use up a lot of system resources.

Click the ‘System Restore‘ tab.

Tick the ‘Turn off System Restore‘ option.

Click ‘Apply‘.

Close the System Properties window.


Setting up Display Properties

Right click anywhere on the desktop. Click ‘Properties‘.

On the Display Properties window, click on the ‘Desktop’ tab,

Click the ‘Customize Desktop’ button.

Untick the ‘Run Desktop Cleanup Wizard every 30 days‘.

XP will no longer hassle you about clearing up your desktop. This could speed up Explorer a tiny bit.

Close the Desktop Items window.

Click on the ‘appearance‘ tab.

Click ‘Effects‘.

Untick ‘Use the following transition effect for menu & tooltips‘.

Untick ‘Show shadows under menus‘.

Untick ‘Show window contents while dragging‘.

Close the effects window.

Click on the ‘Screen Saver’ tab.

Select the combo box & select ‘(none)’

Close the Display Properties window.


Configuring the control Panel

Go onto the control panel.

In the control Panel, open up the ‘Mouse‘ option.

Click on the ‘Pointers‘ tab.

Make sure that ‘Enable pointer shadow‘ is unticked.

Set the combo box in the scheme section to ‘None‘.

Close the Mouse Properties window.

In the control panel window, click ’sounds & audio devices’.

Put the device volume at the highest & untick ‘Place volume icon in taskbar‘.
I found that it is best to leave XP’s volume at highest & modify volume through the speakers or media player. Removing it from the taskbar will remove a unessessary icon.

Click on the ’sounds’ tab.

On the combo box select ‘No Sounds‘. This will stop the sounds XP makes when booting up & using Explorer etc. This will probably speed up XP a very small amount.

Close the Sounds & Audio Properties window.

In the control Panel, open the taskbar & start menu option.

In the Taskbar & Start menu Properties window, untick ‘Hide inactive icons’. It is best to be able to see all running system tray icons, without hiding them.

Click on the start menu tab.

Click ‘Customize‘ button.

In the Programs section, put the number of programs of programs on start menu to 0. This means that XP wont have to remember what programs you have been using recently.

Click Clear List.

Click on the ‘Advance‘ tab.

Untick ‘List my most recently opened documents‘. This means that XP wont have to remember what documents you have been accessing recently

Close the Customize start menu window.

Close the Taskbar & Menu Properties window.

Close the Control Panel.

Disabling services that aren’t being used

You will need to use administrative tools to disable services.

If you’re running XP professional, you should already have administrative tools installed.

Here is how to open it.

Open the Run dialog box & type ‘control admintools‘ into it without the quotation marks or italics.

Now a window should come up called ‘Administrative Tools‘.

Obviously, if you use remote services, ignore this stage.

In the ‘Administrative Tools‘ window, open up ‘Services‘.

Another windows will come up called ‘Services‘.

In the services windows, find something called ‘Remote Desktop Help Session Manager‘

Doubleclick on it. Another window will come up.

In the new window, go onto the combo box & select ‘Disabled‘.

Close the window.

In the ‘Services‘ window, find something called ‘Remote Registry‘

Doubleclick on it. Another window will come up.

In the new window, go onto the combo box & select ‘Disabled‘.

Close the window.

Close the ‘Services‘ window.